cmd/stdiscosrc: Handle address family indicator on other schemes than tcp

This commit is contained in:
Jakob Borg 2018-01-28 10:24:48 +01:00
parent a0514bb1a7
commit 441230ff77

View File

@ -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
}