From 441230ff77b3046472babbd812bfd9377fe1aa14 Mon Sep 17 00:00:00 2001 From: Jakob Borg Date: Sun, 28 Jan 2018 10:24:48 +0100 Subject: [PATCH] cmd/stdiscosrc: Handle address family indicator on other schemes than tcp --- cmd/stdiscosrv/apisrv.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/cmd/stdiscosrv/apisrv.go b/cmd/stdiscosrv/apisrv.go index 3190a04b9..a5428fa20 100644 --- a/cmd/stdiscosrv/apisrv.go +++ b/cmd/stdiscosrv/apisrv.go @@ -18,6 +18,7 @@ import ( "net/http" "net/url" "strconv" + "strings" "sync" "time" @@ -334,13 +335,14 @@ func fixupAddresses(remote net.IP, addresses []string) []string { ip := net.ParseIP(host) if host == "" || ip.IsUnspecified() { - // Do not use IPv6 remote address if requested scheme is tcp4 - if uri.Scheme == "tcp4" && remote.To4() == nil { + // Do not use IPv6 remote address if requested scheme is ...4 + // (i.e., tcp4, kcp4, etc.) + if strings.HasSuffix(uri.Scheme, "4") && remote.To4() == nil { continue } - // Do not use IPv4 remote address if requested scheme is tcp6 - if uri.Scheme == "tcp6" && remote.To4() != nil { + // Do not use IPv4 remote address if requested scheme is ...6 + if strings.HasSuffix(uri.Scheme, "6") && remote.To4() != nil { continue }