mirror of
				https://github.com/moby/moby.git
				synced 2022-11-09 12:21:53 -05:00 
			
		
		
		
	portallocator: use const for default port-ranges, instead of init()
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
		
							parent
							
								
									b57e71941e
								
							
						
					
					
						commit
						1f90fdd973
					
				
					 3 changed files with 16 additions and 11 deletions
				
			
		| 
						 | 
				
			
			@ -9,15 +9,6 @@ import (
 | 
			
		|||
	"github.com/sirupsen/logrus"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
var (
 | 
			
		||||
	// defaultPortRangeStart indicates the first port in port range
 | 
			
		||||
	defaultPortRangeStart = 49153
 | 
			
		||||
	// defaultPortRangeEnd indicates the last port in port range
 | 
			
		||||
	// consistent with default /proc/sys/net/ipv4/ip_local_port_range
 | 
			
		||||
	// upper bound on linux
 | 
			
		||||
	defaultPortRangeEnd = 60999
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func sanitizePortRange(start int, end int) (newStart, newEnd int, err error) {
 | 
			
		||||
	if start > defaultPortRangeEnd || end < defaultPortRangeStart || start > end {
 | 
			
		||||
		return 0, 0, fmt.Errorf("Request out allowed range [%v, %v]",
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										12
									
								
								libnetwork/portallocator/portallocator_unix.go
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								libnetwork/portallocator/portallocator_unix.go
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,12 @@
 | 
			
		|||
// +build !windows
 | 
			
		||||
 | 
			
		||||
package portallocator
 | 
			
		||||
 | 
			
		||||
const (
 | 
			
		||||
	// defaultPortRangeStart indicates the first port in port range
 | 
			
		||||
	defaultPortRangeStart = 49153
 | 
			
		||||
	// defaultPortRangeEnd indicates the last port in port range
 | 
			
		||||
	// consistent with default /proc/sys/net/ipv4/ip_local_port_range
 | 
			
		||||
	// upper bound on linux
 | 
			
		||||
	defaultPortRangeEnd = 60999
 | 
			
		||||
)
 | 
			
		||||
| 
						 | 
				
			
			@ -1,9 +1,11 @@
 | 
			
		|||
package portallocator
 | 
			
		||||
 | 
			
		||||
func init() {
 | 
			
		||||
const (
 | 
			
		||||
	// defaultPortRangeStart indicates the first port in port range
 | 
			
		||||
	defaultPortRangeStart = 60000
 | 
			
		||||
	// defaultPortRangeEnd indicates the last port in port range
 | 
			
		||||
	defaultPortRangeEnd = 65000
 | 
			
		||||
}
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func getDynamicPortRange() (start int, end int, err error) {
 | 
			
		||||
	return defaultPortRangeStart, defaultPortRangeEnd, nil
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue