From 90b349749c8e1e60d2e01b78adb28d82df96c9d2 Mon Sep 17 00:00:00 2001 From: mo Date: Thu, 6 Aug 2020 14:35:01 +0800 Subject: [PATCH] fix --- client_socks5/associate.go | 2 +- client_socks5/client.go | 6 +++--- client_socks5/underconn.go | 18 +++++++++--------- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/client_socks5/associate.go b/client_socks5/associate.go index 27488bc..3029b51 100644 --- a/client_socks5/associate.go +++ b/client_socks5/associate.go @@ -10,7 +10,7 @@ type Associate struct { } func (sf *Associate) getUDPConn() *net.UDPConn { - return sf.underConn.(*underUDPConn).udpConn + return sf.underConn.(*underAssociate).udpConn } func (sf *Associate) SetReadBuffer(bytes int) error { diff --git a/client_socks5/client.go b/client_socks5/client.go index d1f00c0..293db94 100644 --- a/client_socks5/client.go +++ b/client_socks5/client.go @@ -85,7 +85,7 @@ func (sf *Client) Dial(network, addr string) (net.Conn, error) { return nil, errors.New("not support network") } -func (sf *Client) DialTCP(network, addr string) (*Connect, error) { +func (sf *Client) DialTCP(network, addr string) (net.Conn, error) { conn := *sf // clone a client _, err := net.ResolveTCPAddr(network, addr) @@ -105,7 +105,7 @@ func (sf *Client) DialTCP(network, addr string) (*Connect, error) { return &Connect{&conn}, nil } -func (sf *Client) DialUDP(network string, laddr *net.UDPAddr, raddr string) (*Associate, error) { +func (sf *Client) DialUDP(network string, laddr *net.UDPAddr, raddr string) (net.Conn, error) { conn := *sf // clone a client remoteAddress, err := net.ResolveUDPAddr(network, raddr) @@ -140,7 +140,7 @@ func (sf *Client) DialUDP(network string, laddr *net.UDPAddr, raddr string) (*As conn.Close() return nil, err } - conn.underConn = &underUDPConn{ + conn.underConn = &underAssociate{ udpConn, conn.bufferPool, remoteAddress, diff --git a/client_socks5/underconn.go b/client_socks5/underconn.go index 63b50e6..e4de7c5 100644 --- a/client_socks5/underconn.go +++ b/client_socks5/underconn.go @@ -8,13 +8,13 @@ import ( "github.com/thinkgos/go-socks5/statute" ) -type underUDPConn struct { +type underAssociate struct { udpConn *net.UDPConn bufferPool bufferpool.BufPool remoteAddress net.Addr } -func (sf *underUDPConn) Read(b []byte) (int, error) { +func (sf *underAssociate) Read(b []byte) (int, error) { b1 := sf.bufferPool.Get() defer sf.bufferPool.Put(b1) @@ -30,7 +30,7 @@ func (sf *underUDPConn) Read(b []byte) (int, error) { return n, nil } -func (sf *underUDPConn) Write(b []byte) (int, error) { +func (sf *underAssociate) Write(b []byte) (int, error) { datagram, err := statute.NewDatagram(sf.remoteAddress.String(), b) if err != nil { return 0, err @@ -38,26 +38,26 @@ func (sf *underUDPConn) Write(b []byte) (int, error) { return sf.udpConn.Write(datagram.Bytes()) } -func (sf *underUDPConn) Close() error { +func (sf *underAssociate) Close() error { return sf.udpConn.Close() } -func (sf *underUDPConn) LocalAddr() net.Addr { +func (sf *underAssociate) LocalAddr() net.Addr { return sf.udpConn.LocalAddr() } -func (sf *underUDPConn) RemoteAddr() net.Addr { +func (sf *underAssociate) RemoteAddr() net.Addr { return sf.remoteAddress } -func (sf *underUDPConn) SetDeadline(t time.Time) error { +func (sf *underAssociate) SetDeadline(t time.Time) error { return sf.udpConn.SetDeadline(t) } -func (sf *underUDPConn) SetReadDeadline(t time.Time) error { +func (sf *underAssociate) SetReadDeadline(t time.Time) error { return sf.udpConn.SetReadDeadline(t) } -func (sf *underUDPConn) SetWriteDeadline(t time.Time) error { +func (sf *underAssociate) SetWriteDeadline(t time.Time) error { return sf.udpConn.SetWriteDeadline(t) }