Browse Source
			
			
			Use "IsUnixNetwork" function instead of repeating the logic
			
			
				master
			
			
		 
		
			
				
					
						 Matthew Holt
					
					6 years ago
						Matthew Holt
					
					6 years ago
					
				 
				
			 
		 
		
			
				
					
					No known key found for this signature in database
					
						
							GPG Key ID: 2A349DD577D586A5
						
					
				
			
		
		
		
	
		
			
				 2 changed files with 
5 additions and 
4 deletions
			 
			
		 
		
			
				- 
					
					
					 
					listeners.go
				
- 
					
					
					 
					modules/caddyhttp/reverseproxy/healthchecks.go
				
				
				
					
						
							
								
									
	
		
			
				
					|  |  | @ -360,7 +360,7 @@ func SplitNetworkAddress(a string) (network, host, port string, err error) { | 
			
		
	
		
			
				
					|  |  |  | 		network = strings.ToLower(strings.TrimSpace(a[:idx])) | 
			
		
	
		
			
				
					|  |  |  | 		a = a[idx+1:] | 
			
		
	
		
			
				
					|  |  |  | 	} | 
			
		
	
		
			
				
					|  |  |  | 	if network == "unix" || network == "unixgram" || network == "unixpacket" { | 
			
		
	
		
			
				
					|  |  |  | 	if isUnixNetwork(network) { | 
			
		
	
		
			
				
					|  |  |  | 		host = a | 
			
		
	
		
			
				
					|  |  |  | 		return | 
			
		
	
		
			
				
					|  |  |  | 	} | 
			
		
	
	
		
			
				
					|  |  | @ -369,8 +369,9 @@ func SplitNetworkAddress(a string) (network, host, port string, err error) { | 
			
		
	
		
			
				
					|  |  |  | } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | // JoinNetworkAddress combines network, host, and port into a single
 | 
			
		
	
		
			
				
					|  |  |  | // address string of the form accepted by ParseNetworkAddress(). For unix sockets, the network
 | 
			
		
	
		
			
				
					|  |  |  | // should be "unix" and the path to the socket should be given as the
 | 
			
		
	
		
			
				
					|  |  |  | // address string of the form accepted by ParseNetworkAddress(). For
 | 
			
		
	
		
			
				
					|  |  |  | // unix sockets, the network should be "unix" (or "unixgram" or
 | 
			
		
	
		
			
				
					|  |  |  | // "unixpacket") and the path to the socket should be given as the
 | 
			
		
	
		
			
				
					|  |  |  | // host parameter.
 | 
			
		
	
		
			
				
					|  |  |  | func JoinNetworkAddress(network, host, port string) string { | 
			
		
	
		
			
				
					|  |  |  | 	var a string | 
			
		
	
	
		
			
				
					|  |  | 
 | 
			
		
	
								
							
						
					 
					
				 
			 
		
			
			
			
			
			
			
				
				
					
						
							
								
									
	
		
			
				
					|  |  | @ -117,7 +117,7 @@ func (h *Handler) doActiveHealthChecksForAllHosts() { | 
			
		
	
		
			
				
					|  |  |  | 				return | 
			
		
	
		
			
				
					|  |  |  | 			} | 
			
		
	
		
			
				
					|  |  |  | 			hostAddr := addr.JoinHostPort(0) | 
			
		
	
		
			
				
					|  |  |  | 			if addr.Network == "unix" || addr.Network == "unixgram" || addr.Network == "unixpacket" { | 
			
		
	
		
			
				
					|  |  |  | 			if addr.IsUnixNetwork() { | 
			
		
	
		
			
				
					|  |  |  | 				// this will be used as the Host portion of a http.Request URL, and
 | 
			
		
	
		
			
				
					|  |  |  | 				// paths to socket files would produce an error when creating URL,
 | 
			
		
	
		
			
				
					|  |  |  | 				// so use a fake Host value instead; unix sockets are usually local
 | 
			
		
	
	
		
			
				
					|  |  | 
 |