Skip to content

Commit b986bac

Browse files
committed
remove unused function
1 parent 57b7ea6 commit b986bac

2 files changed

Lines changed: 0 additions & 47 deletions

File tree

internal/api/proxy.go

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,6 @@ import (
88
"net/url"
99
)
1010

11-
// proxyDialAddr returns proxyURL.Host with a default port appended if one is
12-
// not already present (443 for https, 80 for http).
13-
func proxyDialAddr(proxyURL *url.URL) string {
14-
// net.SplitHostPort returns an error when the input doesn't contain a port
15-
if _, _, err := net.SplitHostPort(proxyURL.Host); err == nil {
16-
return proxyURL.Host
17-
}
18-
if proxyURL.Scheme == "https" {
19-
return net.JoinHostPort(proxyURL.Hostname(), "443")
20-
}
21-
return net.JoinHostPort(proxyURL.Hostname(), "80")
22-
}
23-
2411
// withProxyTransport modifies the given transport to handle proxying of unix, socks5 and http connections.
2512
//
2613
// Note: baseTransport is considered to be a clone created with transport.Clone()

internal/api/proxy_test.go

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -397,37 +397,3 @@ func TestWithProxyTransport_ProxyRejectsConnect(t *testing.T) {
397397
})
398398
}
399399
}
400-
401-
func TestProxyDialAddr(t *testing.T) {
402-
tests := []struct {
403-
name string
404-
url string
405-
want string
406-
}{
407-
{"https with port", "https://proxy.example.com:8443", "proxy.example.com:8443"},
408-
{"https without port", "https://proxy.example.com", "proxy.example.com:443"},
409-
{"http with port", "http://proxy.example.com:8080", "proxy.example.com:8080"},
410-
{"http without port", "http://proxy.example.com", "proxy.example.com:80"},
411-
{"ipv4 with port", "http://192.168.1.100:3128", "192.168.1.100:3128"},
412-
{"ipv4 without port https", "https://10.0.0.1", "10.0.0.1:443"},
413-
{"ipv4 without port http", "http://172.16.0.5", "172.16.0.5:80"},
414-
{"ipv6 with port", "http://[::1]:8080", "[::1]:8080"},
415-
{"ipv6 without port https", "https://[2001:db8::1]", "[2001:db8::1]:443"},
416-
{"ipv6 without port http", "http://[fe80::1]", "[fe80::1]:80"},
417-
{"localhost with port", "http://localhost:9090", "localhost:9090"},
418-
{"localhost without port https", "https://localhost", "localhost:443"},
419-
{"localhost without port http", "http://localhost", "localhost:80"},
420-
}
421-
for _, tt := range tests {
422-
t.Run(tt.name, func(t *testing.T) {
423-
u, err := url.ParseRequestURI(tt.url)
424-
if err != nil {
425-
t.Fatalf("parse URL: %v", err)
426-
}
427-
got := proxyDialAddr(u)
428-
if got != tt.want {
429-
t.Errorf("proxyHostPort(%s) = %q, want %q", tt.url, got, tt.want)
430-
}
431-
})
432-
}
433-
}

0 commit comments

Comments
 (0)