Skip to content

Commit e4964df

Browse files
authored
Merge pull request #1640 from ArmingLou/fix-proxy
Fix unable to use the network proxy configuration of the MacOS(10.15)
2 parents 98df308 + 8f01cdc commit e4964df

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

pkg/osutil/dns_darwin.go

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,20 @@ func DNSAddresses() ([]string, error) {
2828
}
2929

3030
func proxyURL(proxy string, port interface{}) string {
31-
if !strings.Contains(proxy, "://") {
31+
if strings.Contains(proxy, "://") {
32+
if portNumber, ok := port.(float64); ok && portNumber != 0 {
33+
proxy = fmt.Sprintf("%s:%.0f", proxy, portNumber)
34+
} else if portString, ok := port.(string); ok && portString != "" {
35+
proxy = fmt.Sprintf("%s:%s", proxy, portString)
36+
}
37+
} else {
38+
if portNumber, ok := port.(float64); ok && portNumber != 0 {
39+
proxy = net.JoinHostPort(proxy, fmt.Sprintf("%.0f", portNumber))
40+
} else if portString, ok := port.(string); ok && portString != "" {
41+
proxy = net.JoinHostPort(proxy, portString)
42+
}
3243
proxy = "http://" + proxy
3344
}
34-
if portNumber, ok := port.(float64); ok && portNumber != 0 {
35-
proxy = net.JoinHostPort(proxy, fmt.Sprintf("%.0f", portNumber))
36-
} else if portString, ok := port.(string); ok && portString != "" {
37-
proxy = net.JoinHostPort(proxy, portString)
38-
}
3945
return proxy
4046
}
4147

0 commit comments

Comments
 (0)