diff --git a/chain.go b/chain.go index 22ea44f..cf77cf8 100644 --- a/chain.go +++ b/chain.go @@ -143,7 +143,7 @@ func (c *Chain) dialWithOptions(addr string, options *ChainOptions) (net.Conn, e return nil, err } - cc, err := route.LastNode().Client.Connect(conn, addr, IPAddrConnectOption(ipAddr)) + cc, err := route.LastNode().Client.Connect(conn, ipAddr, AddrConnectOption(addr)) if err != nil { conn.Close() return nil, err diff --git a/client.go b/client.go index e563059..fca8f04 100644 --- a/client.go +++ b/client.go @@ -202,15 +202,15 @@ func QUICConfigHandshakeOption(config *QUICConfig) HandshakeOption { // ConnectOptions describes the options for Connector.Connect. type ConnectOptions struct { - IPAddr string + Addr string } // ConnectOption allows a common way to set ConnectOptions. type ConnectOption func(opts *ConnectOptions) -// IPAddrConnectOption specifies the corresponding IP:PORT of the connected target address. -func IPAddrConnectOption(ipAddr string) ConnectOption { +// AddrConnectOption specifies the corresponding address of the target. +func AddrConnectOption(addr string) ConnectOption { return func(opts *ConnectOptions) { - opts.IPAddr = ipAddr + opts.Addr = addr } } diff --git a/http2.go b/http2.go index 988d2cd..d0e8878 100644 --- a/http2.go +++ b/http2.go @@ -29,11 +29,6 @@ func HTTP2Connector(user *url.Userinfo) Connector { } func (c *http2Connector) Connect(conn net.Conn, addr string, options ...ConnectOption) (net.Conn, error) { - var cOpts ConnectOptions - for _, opt := range options { - opt(&cOpts) - } - cc, ok := conn.(*http2ClientConn) if !ok { return nil, errors.New("wrong connection type") @@ -81,9 +76,6 @@ func (c *http2Connector) Connect(conn net.Conn, addr string, options ...ConnectO closed: make(chan struct{}), } - if cOpts.IPAddr != "" { - addr = cOpts.IPAddr - } hc.remoteAddr, _ = net.ResolveTCPAddr("tcp", addr) hc.localAddr, _ = net.ResolveTCPAddr("tcp", cc.addr) diff --git a/socks.go b/socks.go index 8881471..4d77608 100644 --- a/socks.go +++ b/socks.go @@ -262,14 +262,6 @@ func SOCKS4Connector() Connector { } func (c *socks4Connector) Connect(conn net.Conn, addr string, options ...ConnectOption) (net.Conn, error) { - var cOpts ConnectOptions - for _, opt := range options { - opt(&cOpts) - } - if cOpts.IPAddr != "" { - addr = cOpts.IPAddr - } - taddr, err := net.ResolveTCPAddr("tcp4", addr) if err != nil { return nil, err