summaryrefslogtreecommitdiff
path: root/listeners.go
diff options
context:
space:
mode:
Diffstat (limited to 'listeners.go')
-rw-r--r--listeners.go13
1 files changed, 7 insertions, 6 deletions
diff --git a/listeners.go b/listeners.go
index 5bf85a0..f922144 100644
--- a/listeners.go
+++ b/listeners.go
@@ -205,7 +205,7 @@ func (na NetworkAddress) listen(ctx context.Context, portOffset uint, config net
// IsUnixNetwork returns true if na.Network is
// unix, unixgram, or unixpacket.
func (na NetworkAddress) IsUnixNetwork() bool {
- return isUnixNetwork(na.Network)
+ return IsUnixNetwork(na.Network)
}
// JoinHostPort is like net.JoinHostPort, but where the port
@@ -289,8 +289,9 @@ func (na NetworkAddress) String() string {
return JoinNetworkAddress(na.Network, na.Host, na.port())
}
-func isUnixNetwork(netw string) bool {
- return netw == "unix" || netw == "unixgram" || netw == "unixpacket"
+// IsUnixNetwork returns true if the netw is a unix network.
+func IsUnixNetwork(netw string) bool {
+ return strings.HasPrefix(netw, "unix")
}
// ParseNetworkAddress parses addr into its individual
@@ -310,7 +311,7 @@ func ParseNetworkAddress(addr string) (NetworkAddress, error) {
if network == "" {
network = "tcp"
}
- if isUnixNetwork(network) {
+ if IsUnixNetwork(network) {
return NetworkAddress{
Network: network,
Host: host,
@@ -353,7 +354,7 @@ func SplitNetworkAddress(a string) (network, host, port string, err error) {
network = strings.ToLower(strings.TrimSpace(beforeSlash))
a = afterSlash
}
- if isUnixNetwork(network) {
+ if IsUnixNetwork(network) {
host = a
return
}
@@ -384,7 +385,7 @@ func JoinNetworkAddress(network, host, port string) string {
if network != "" {
a = network + "/"
}
- if (host != "" && port == "") || isUnixNetwork(network) {
+ if (host != "" && port == "") || IsUnixNetwork(network) {
a += host
} else if port != "" {
a += net.JoinHostPort(host, port)