Skip to content

Commit 7d3eca5

Browse files
authored
Merge pull request #475 from rancher-sandbox/port-may-be-empty-string
Allow Proxy ports to be marshalled as strings
2 parents 9182b5a + c60e648 commit 7d3eca5

File tree

2 files changed

+18
-16
lines changed

2 files changed

+18
-16
lines changed

pkg/osutil/dns_darwin.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,14 @@ func DNSAddresses() ([]string, error) {
2929
return addresses, nil
3030
}
3131

32-
func proxyURL(proxy string, port int) string {
32+
func proxyURL(proxy string, port interface{}) string {
3333
if !strings.Contains(proxy, "://") {
3434
proxy = "http://" + proxy
3535
}
36-
if port != 0 {
37-
proxy = fmt.Sprintf("%s:%d", proxy, port)
36+
if portNumber, ok := port.(float64); ok && portNumber != 0 {
37+
proxy = fmt.Sprintf("%s:%.0f", proxy, portNumber)
38+
} else if portString, ok := port.(string); ok && portString != "" {
39+
proxy = fmt.Sprintf("%s:%s", proxy, portString)
3840
}
3941
return proxy
4042
}

pkg/sysprof/network_darwin.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,17 @@ type DNS struct {
1515
}
1616

1717
type Proxies struct {
18-
ExceptionList []string `json:"ExceptionList"` // default: ["*.local", "169.254/16"]
19-
FTPEnable string `json:"FTPEnable"`
20-
FTPPort int `json:"FTPPort"`
21-
FTPProxy string `json:"FTPProxy"`
22-
FTPUser string `json:"FTPUser"`
23-
HTTPEnable string `json:"HTTPEnable"`
24-
HTTPPort int `json:"HTTPPort"`
25-
HTTPProxy string `json:"HTTPProxy"`
26-
HTTPUser string `json:"HTTPUser"`
27-
HTTPSEnable string `json:"HTTPSEnable"`
28-
HTTPSPort int `json:"HTTPSPort"`
29-
HTTPSProxy string `json:"HTTPSProxy"`
30-
HTTPSUser string `json:"HTTPSUser"`
18+
ExceptionList []string `json:"ExceptionList"` // default: ["*.local", "169.254/16"]
19+
FTPEnable string `json:"FTPEnable"`
20+
FTPPort interface{} `json:"FTPPort"`
21+
FTPProxy string `json:"FTPProxy"`
22+
FTPUser string `json:"FTPUser"`
23+
HTTPEnable string `json:"HTTPEnable"`
24+
HTTPPort interface{} `json:"HTTPPort"`
25+
HTTPProxy string `json:"HTTPProxy"`
26+
HTTPUser string `json:"HTTPUser"`
27+
HTTPSEnable string `json:"HTTPSEnable"`
28+
HTTPSPort interface{} `json:"HTTPSPort"`
29+
HTTPSProxy string `json:"HTTPSProxy"`
30+
HTTPSUser string `json:"HTTPSUser"`
3131
}

0 commit comments

Comments
 (0)