Documentation ¶
Index ¶
- Variables
- func ReplyVersionSpecificError(ctx context.Context, ver message.VersionMismatchError, conn net.Conn)
- type Client
- func (c *Client) BindRequest(ctx context.Context, addr net.Addr, option *message.OptionSet) (*ProxyTCPListener, error)
- func (c *Client) ConnectRequest(ctx context.Context, addr net.Addr, initData []byte, option *message.OptionSet) (net.Conn, error)
- func (c *Client) Dial(network string, addr string) (net.Conn, error)
- func (c *Client) DialContext(ctx context.Context, network string, addr string) (net.Conn, error)
- func (c *Client) Listen(network string, addr string) (net.Listener, error)
- func (c *Client) ListenContext(ctx context.Context, network string, addr string) (net.Listener, error)
- func (c *Client) ListenPacket(network string, addr string) (net.PacketConn, error)
- func (c *Client) ListenPacketContext(ctx context.Context, network string, addr string) (net.PacketConn, error)
- func (c *Client) NoopRequest(ctx context.Context) error
- func (c *Client) UDPAssociateRequest(ctx context.Context, addr net.Addr, option *message.OptionSet) (*ProxyUDPConn, error)
- type CommandHandler
- type MessageReplyCodeError
- type ProxyTCPConn
- type ProxyTCPListener
- func (t *ProxyTCPListener) Accept() (net.Conn, error)
- func (t *ProxyTCPListener) AcceptContext(ctx context.Context) (net.Conn, error)
- func (t *ProxyTCPListener) Addr() net.Addr
- func (t *ProxyTCPListener) Close() error
- func (t *ProxyTCPListener) LocalAddr() net.Addr
- func (t *ProxyTCPListener) ProxyRemoteAddr() net.Addr
- type ProxyUDPConn
- func (u *ProxyUDPConn) Close() error
- func (u *ProxyUDPConn) LocalAddr() net.Addr
- func (u *ProxyUDPConn) ProxyBindAddr() net.Addr
- func (u *ProxyUDPConn) ProxyRemoteAddr() net.Addr
- func (u *ProxyUDPConn) Read(p []byte) (int, error)
- func (u *ProxyUDPConn) ReadFrom(p []byte) (int, net.Addr, error)
- func (u *ProxyUDPConn) RemoteAddr() net.Addr
- func (u *ProxyUDPConn) SetDeadline(t time.Time) error
- func (u *ProxyUDPConn) SetReadDeadline(t time.Time) error
- func (u *ProxyUDPConn) SetWriteDeadline(t time.Time) error
- func (u *ProxyUDPConn) Write(p []byte) (int, error)
- func (u *ProxyUDPConn) WriteTo(p []byte, addr net.Addr) (int, error)
- type Server
- type ServerWorker
- func (s *ServerWorker) BindHandler(ctx context.Context, cc SocksConn)
- func (s *ServerWorker) ClearUnusedResource(ctx context.Context)
- func (s *ServerWorker) ConnectHandler(ctx context.Context, cc SocksConn)
- func (s *ServerWorker) ForwardICMP(ctx context.Context, msg *icmp.Message, ip *net.IPAddr, ver int)
- func (s *ServerWorker) NoopHandler(ctx context.Context, cc SocksConn)
- func (s *ServerWorker) ServeDatagram(ctx context.Context, dgram nt.Datagram)
- func (s *ServerWorker) ServeMuxConn(ctx context.Context, mux nt.MultiplexedConn)
- func (s *ServerWorker) ServeSeqPacket(ctx context.Context, dgramSrc nt.SeqPacket)
- func (s *ServerWorker) ServeStream(ctx context.Context, conn net.Conn)
- func (s *ServerWorker) UDPAssociateHandler(ctx context.Context, cc SocksConn)
- type SocksConn
- func (c SocksConn) ConnID() string
- func (c SocksConn) Destination() message.SocksAddr
- func (c SocksConn) WriteReply(code message.ReplyCode, ep net.Addr, opt *message.OptionSet) error
- func (c SocksConn) WriteReplyAddr(code message.ReplyCode, ep net.Addr) error
- func (c SocksConn) WriteReplyCode(code message.ReplyCode) error
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func ReplyVersionSpecificError ¶
func ReplyVersionSpecificError(ctx context.Context, ver message.VersionMismatchError, conn net.Conn)
ReplyVersionSpecificError guess which protocol client is using, reply corresponding "version error", then close conn.
Types ¶
type Client ¶
type Client struct { // server address Server string // use TLS and DTLS when connect to server Encrypted bool // use QUIC QUIC bool // send datagram over TCP, when use QUIC, send datagram over QUIC stream instead of QUIC datagram UDPOverTCP bool // function to create underlying connection, net.Dial will used when it is nil DialFunc func(ctx context.Context, network string, addr string) (net.Conn, error) // authentication method to be used, can be nil AuthenticationMethod auth.ClientAuthenticationMethod // should client request session UseSession bool // how much token will requested UseToken uint32 // suggested bind backlog Backlog int EnableICMP bool // contains filtered or unexported fields }
Client is a SOCKS 6 client, implements net.Dialer, net.Listener.
func (*Client) BindRequest ¶
func (*Client) ConnectRequest ¶
func (*Client) DialContext ¶
func (*Client) ListenContext ¶
func (*Client) ListenPacket ¶
func (*Client) ListenPacketContext ¶
func (*Client) NoopRequest ¶
NoopRequest send a NOOP request.
type CommandHandler ¶
type MessageReplyCodeError ¶
func (MessageReplyCodeError) Error ¶
func (m MessageReplyCodeError) Error() string
type ProxyTCPConn ¶
type ProxyTCPConn struct {
// contains filtered or unexported fields
}
ProxyTCPConn represents a proxied TCP connection, implements net.Conn.
func (*ProxyTCPConn) ProxyLocalAddr ¶
func (t *ProxyTCPConn) ProxyLocalAddr() net.Addr
func (*ProxyTCPConn) ProxyRemoteAddr ¶
func (t *ProxyTCPConn) ProxyRemoteAddr() net.Addr
func (*ProxyTCPConn) RemoteAddr ¶
func (t *ProxyTCPConn) RemoteAddr() net.Addr
type ProxyTCPListener ¶
type ProxyTCPListener struct {
// contains filtered or unexported fields
}
func (*ProxyTCPListener) AcceptContext ¶
func (*ProxyTCPListener) Addr ¶
func (t *ProxyTCPListener) Addr() net.Addr
func (*ProxyTCPListener) Close ¶
func (t *ProxyTCPListener) Close() error
func (*ProxyTCPListener) LocalAddr ¶
func (t *ProxyTCPListener) LocalAddr() net.Addr
func (*ProxyTCPListener) ProxyRemoteAddr ¶
func (t *ProxyTCPListener) ProxyRemoteAddr() net.Addr
type ProxyUDPConn ¶
type ProxyUDPConn struct {
// contains filtered or unexported fields
}
ProxyUDPConn represents a SOCKS 6 UDP client "connection", implements net.PacketConn, net.Conn.
func (*ProxyUDPConn) Close ¶
func (u *ProxyUDPConn) Close() error
func (*ProxyUDPConn) LocalAddr ¶
func (u *ProxyUDPConn) LocalAddr() net.Addr
LocalAddr return client-proxy connection's client side address.
func (*ProxyUDPConn) ProxyBindAddr ¶
func (u *ProxyUDPConn) ProxyBindAddr() net.Addr
ProxyBindAddr return proxy's outbound address.
func (*ProxyUDPConn) ProxyRemoteAddr ¶
func (u *ProxyUDPConn) ProxyRemoteAddr() net.Addr
ProxyRemoteAddr return client-proxy connection's proxy side address.
func (*ProxyUDPConn) Read ¶
func (u *ProxyUDPConn) Read(p []byte) (int, error)
Read implements net.Conn.
func (*ProxyUDPConn) RemoteAddr ¶
func (u *ProxyUDPConn) RemoteAddr() net.Addr
func (*ProxyUDPConn) SetDeadline ¶
func (u *ProxyUDPConn) SetDeadline(t time.Time) error
func (*ProxyUDPConn) SetReadDeadline ¶
func (u *ProxyUDPConn) SetReadDeadline(t time.Time) error
func (*ProxyUDPConn) SetWriteDeadline ¶
func (u *ProxyUDPConn) SetWriteDeadline(t time.Time) error
type Server ¶
type Server struct { Address string CleartextPort uint16 EncryptedPort uint16 QuicPort uint16 TLSConfig *tls.Config Worker *ServerWorker // contains filtered or unexported fields }
Server is a SOCKS 6 over TCP/TLS/UDP/DTLS server zero value is a cleartext only server with default server worker.
type ServerWorker ¶
type ServerWorker struct { Authenticator auth.ServerAuthenticator Rule func(cc SocksConn) bool CommandHandlers map[message.CommandCode]CommandHandler // VersionErrorHandler will handle non-SOCKS6 protocol request. // VersionErrorHandler should close connection by itself VersionErrorHandler func(ctx context.Context, ver message.VersionMismatchError, conn net.Conn) DatagramVersionErrorHandler func(ctx context.Context, ver message.VersionMismatchError, dgram nt.Datagram) Outbound nt.Outbound // control UDP NAT filtering behavior, // mapping behavior is always Endpoint Independent. // // when false, use Endpoint Independent filtering (Full Cone) // // when true, use Address Dependent filtering (Restricted Cone) AddressDependentFiltering bool // require request message fully received in first packet // // Yes, TCP has no "packet" -- but that's only makes sense for people // who never need to touch the dark side of Internet. // Packet are everywhere in a packet switched network, // you can create a stream on it and hide it behind API, // but it's still a packet sequence on wire. IgnoreFragmentedRequest bool EnableICMP bool HandshakeTimeout time.Duration StreamTimeout time.Duration DatagramTimeout time.Duration // contains filtered or unexported fields }
ServerWorker is a customizeable SOCKS 6 server.
func NewServerWorker ¶
func NewServerWorker() *ServerWorker
NewServerWorker create a standard SOCKS 6 server.
func (*ServerWorker) BindHandler ¶
func (s *ServerWorker) BindHandler( ctx context.Context, cc SocksConn, )
func (*ServerWorker) ClearUnusedResource ¶
func (s *ServerWorker) ClearUnusedResource(ctx context.Context)
ClearUnusedResource clear no longer used resources (UDP associations, etc.) only need to call it once for each ServerWorker.
func (*ServerWorker) ConnectHandler ¶
func (s *ServerWorker) ConnectHandler( ctx context.Context, cc SocksConn, )
func (*ServerWorker) ForwardICMP ¶
func (*ServerWorker) NoopHandler ¶
func (s *ServerWorker) NoopHandler( ctx context.Context, cc SocksConn, )
func (*ServerWorker) ServeDatagram ¶
func (s *ServerWorker) ServeDatagram( ctx context.Context, dgram nt.Datagram, )
func (*ServerWorker) ServeMuxConn ¶
func (s *ServerWorker) ServeMuxConn( ctx context.Context, mux nt.MultiplexedConn, )
func (*ServerWorker) ServeSeqPacket ¶
func (s *ServerWorker) ServeSeqPacket( ctx context.Context, dgramSrc nt.SeqPacket, )
func (*ServerWorker) ServeStream ¶
func (s *ServerWorker) ServeStream( ctx context.Context, conn net.Conn, )
ServeStream process incoming TCP and TLS connection return when connection process complete, e.g. remote closed connection.
func (*ServerWorker) UDPAssociateHandler ¶
func (s *ServerWorker) UDPAssociateHandler( ctx context.Context, cc SocksConn, )
type SocksConn ¶
type SocksConn struct { Conn net.Conn MuxConn nt.MultiplexedConn Request *message.Request // request sent by client ClientID string // client identifier provided by authenticator Session []byte // the session this connection belongs to StreamID uint32 // stream id provided by client InitialData []byte // client's initial data }
SocksConn represents a SOCKS 6 connection received by server.
func (SocksConn) Destination ¶
Destination is endpoint included in client's request.
func (SocksConn) WriteReply ¶
WriteReply write operation reply with given parameter to client.
func (SocksConn) WriteReplyAddr ¶
WriteReplyAddr see WriteReply.