fix
This commit is contained in:
parent
2fcdcb8a43
commit
90b349749c
@ -10,7 +10,7 @@ type Associate struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (sf *Associate) getUDPConn() *net.UDPConn {
|
func (sf *Associate) getUDPConn() *net.UDPConn {
|
||||||
return sf.underConn.(*underUDPConn).udpConn
|
return sf.underConn.(*underAssociate).udpConn
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sf *Associate) SetReadBuffer(bytes int) error {
|
func (sf *Associate) SetReadBuffer(bytes int) error {
|
||||||
|
@ -85,7 +85,7 @@ func (sf *Client) Dial(network, addr string) (net.Conn, error) {
|
|||||||
return nil, errors.New("not support network")
|
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
|
conn := *sf // clone a client
|
||||||
|
|
||||||
_, err := net.ResolveTCPAddr(network, addr)
|
_, err := net.ResolveTCPAddr(network, addr)
|
||||||
@ -105,7 +105,7 @@ func (sf *Client) DialTCP(network, addr string) (*Connect, error) {
|
|||||||
return &Connect{&conn}, nil
|
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
|
conn := *sf // clone a client
|
||||||
|
|
||||||
remoteAddress, err := net.ResolveUDPAddr(network, raddr)
|
remoteAddress, err := net.ResolveUDPAddr(network, raddr)
|
||||||
@ -140,7 +140,7 @@ func (sf *Client) DialUDP(network string, laddr *net.UDPAddr, raddr string) (*As
|
|||||||
conn.Close()
|
conn.Close()
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
conn.underConn = &underUDPConn{
|
conn.underConn = &underAssociate{
|
||||||
udpConn,
|
udpConn,
|
||||||
conn.bufferPool,
|
conn.bufferPool,
|
||||||
remoteAddress,
|
remoteAddress,
|
||||||
|
@ -8,13 +8,13 @@ import (
|
|||||||
"github.com/thinkgos/go-socks5/statute"
|
"github.com/thinkgos/go-socks5/statute"
|
||||||
)
|
)
|
||||||
|
|
||||||
type underUDPConn struct {
|
type underAssociate struct {
|
||||||
udpConn *net.UDPConn
|
udpConn *net.UDPConn
|
||||||
bufferPool bufferpool.BufPool
|
bufferPool bufferpool.BufPool
|
||||||
remoteAddress net.Addr
|
remoteAddress net.Addr
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sf *underUDPConn) Read(b []byte) (int, error) {
|
func (sf *underAssociate) Read(b []byte) (int, error) {
|
||||||
b1 := sf.bufferPool.Get()
|
b1 := sf.bufferPool.Get()
|
||||||
defer sf.bufferPool.Put(b1)
|
defer sf.bufferPool.Put(b1)
|
||||||
|
|
||||||
@ -30,7 +30,7 @@ func (sf *underUDPConn) Read(b []byte) (int, error) {
|
|||||||
return n, nil
|
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)
|
datagram, err := statute.NewDatagram(sf.remoteAddress.String(), b)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
@ -38,26 +38,26 @@ func (sf *underUDPConn) Write(b []byte) (int, error) {
|
|||||||
return sf.udpConn.Write(datagram.Bytes())
|
return sf.udpConn.Write(datagram.Bytes())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sf *underUDPConn) Close() error {
|
func (sf *underAssociate) Close() error {
|
||||||
return sf.udpConn.Close()
|
return sf.udpConn.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sf *underUDPConn) LocalAddr() net.Addr {
|
func (sf *underAssociate) LocalAddr() net.Addr {
|
||||||
return sf.udpConn.LocalAddr()
|
return sf.udpConn.LocalAddr()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sf *underUDPConn) RemoteAddr() net.Addr {
|
func (sf *underAssociate) RemoteAddr() net.Addr {
|
||||||
return sf.remoteAddress
|
return sf.remoteAddress
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sf *underUDPConn) SetDeadline(t time.Time) error {
|
func (sf *underAssociate) SetDeadline(t time.Time) error {
|
||||||
return sf.udpConn.SetDeadline(t)
|
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)
|
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)
|
return sf.udpConn.SetWriteDeadline(t)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user