Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS
Mirrored from https://github.com/Slazee/caddy.git
Synced Nov 14, 05:15 UTC
Use "IsUnixNetwork" function instead of repeating the logic
Matthew Holt committed
Dec 6, 2019 at 12:00 UTC
b07f6958aca4e275ff1d1aebabd0eef0e0e4b330
2 files changed
+5
-4
listeners.go
+4
-3
@@ -360,7 +360,7 @@ func SplitNetworkAddress(a string) (network, host, port string, err error) {
360
network = strings.ToLower(strings.TrimSpace(a[:idx]))
361
a = a[idx+1:]
362
}
363
- if network == "unix" || network == "unixgram" || network == "unixpacket" {
363
+ if isUnixNetwork(network) {
364
host = a
365
return
366
}
@@ -369,8 +369,9 @@ func SplitNetworkAddress(a string) (network, host, port string, err error) {
369
}
370
371
// JoinNetworkAddress combines network, host, and port into a single
372
-// address string of the form accepted by ParseNetworkAddress(). For unix sockets, the network
373
-// should be "unix" and the path to the socket should be given as the
372
+// address string of the form accepted by ParseNetworkAddress(). For
373
+// unix sockets, the network should be "unix" (or "unixgram" or
374
+// "unixpacket") and the path to the socket should be given as the
375
// host parameter.
376
func JoinNetworkAddress(network, host, port string) string {
377
var a string
modules/caddyhttp/reverseproxy/healthchecks.go
+1
-1
@@ -117,7 +117,7 @@ func (h *Handler) doActiveHealthChecksForAllHosts() {
117
return
118
}
119
hostAddr := addr.JoinHostPort(0)
120
- if addr.Network == "unix" || addr.Network == "unixgram" || addr.Network == "unixpacket" {
120
+ if addr.IsUnixNetwork() {
121
// this will be used as the Host portion of a http.Request URL, and
122
// paths to socket files would produce an error when creating URL,
123
// so use a fake Host value instead; unix sockets are usually local