From fa3a7da859c1801e3c54d503891d1e90c7da1df0 Mon Sep 17 00:00:00 2001 From: nadoo <287492+nadoo@users.noreply.github.com> Date: Mon, 13 Apr 2020 12:26:21 +0800 Subject: [PATCH] socks4: fix compile problem --- proxy/dialer.go | 12 ++++++++++++ proxy/socks4/socks4.go | 3 --- proxy/trojan/packet.go | 2 +- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/proxy/dialer.go b/proxy/dialer.go index ec5df2f..6cdd184 100644 --- a/proxy/dialer.go +++ b/proxy/dialer.go @@ -11,11 +11,23 @@ import ( // Dialer is used to create connection. type Dialer interface { + TCPDialer + UDPDialer +} + +// TCPDialer is used to create connection. +type TCPDialer interface { // Addr is the dialer's addr Addr() string // Dial connects to the given address Dial(network, addr string) (c net.Conn, err error) +} + +// UDPDialer is used to create connection. +type UDPDialer interface { + // Addr is the dialer's addr + Addr() string // DialUDP connects to the given address DialUDP(network, addr string) (pc net.PacketConn, writeTo net.Addr, err error) diff --git a/proxy/socks4/socks4.go b/proxy/socks4/socks4.go index 61c5471..3560344 100644 --- a/proxy/socks4/socks4.go +++ b/proxy/socks4/socks4.go @@ -62,9 +62,6 @@ func (s *SOCKS4) Addr() string { return s.addr } -// NextDialer returns the next dialer. -func (s *SOCKS4) NextDialer(dstAddr string) proxy.Dialer { return s.dialer.NextDialer(dstAddr) } - // Dial connects to the address addr on the network net via the SOCKS4 proxy. func (s *SOCKS4) Dial(network, addr string) (net.Conn, error) { switch network { diff --git a/proxy/trojan/packet.go b/proxy/trojan/packet.go index 7485e67..24a3c7f 100644 --- a/proxy/trojan/packet.go +++ b/proxy/trojan/packet.go @@ -60,7 +60,7 @@ func (pc *PktConn) ReadFrom(b []byte) (int, net.Addr, error) { return n, nil, err } -// ReadFrom implements the necessary function of net.PacketConn. +// WriteTo implements the necessary function of net.PacketConn. func (pc *PktConn) WriteTo(b []byte, addr net.Addr) (int, error) { var buf bytes.Buffer buf.Write(pc.tgtAddr)