Skip to content

Commit 1d3ee81

Browse files
committed
add format for dial proxy command
1 parent a7b3771 commit 1d3ee81

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

dial.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77

88
type DialProxyCommand []string
99

10-
func (p *DialProxyCommand) DialContext(ctx context.Context, network string, address string) (net.Conn, error) {
10+
func (p *DialProxyCommand) Format(network string, address string) ([]string, error) {
1111
host, port, err := net.SplitHostPort(address)
1212
if err != nil {
1313
return nil, err
@@ -22,6 +22,14 @@ func (p *DialProxyCommand) DialContext(ctx context.Context, network string, addr
2222
for i := range proxy {
2323
proxy[i] = ReplaceEscape(proxy[i], m)
2424
}
25+
return proxy, nil
26+
}
27+
28+
func (p *DialProxyCommand) DialContext(ctx context.Context, network string, address string) (net.Conn, error) {
29+
proxy, err := p.Format(network, address)
30+
if err != nil {
31+
return nil, err
32+
}
2533
cp := ProxyCommand(ctx, proxy[0], proxy[1:]...)
2634
return cp.Stdio()
2735
}

0 commit comments

Comments
 (0)