Documentation ¶
Index ¶
- Constants
- func NewPacketListener(endpoint transport.PacketEndpoint) (transport.PacketListener, error)
- type Client
- func (c *Client) DialStream(ctx context.Context, dstAddr string) (transport.StreamConn, error)
- func (c *Client) EnablePacket(packetDialer transport.PacketDialer)
- func (c *Client) ListenPacket(ctx context.Context) (net.PacketConn, error)
- func (c *Client) SetCredentials(username, password []byte) error
- type ReplyCode
Constants ¶
const ( ErrGeneralServerFailure = ReplyCode(0x01) ErrConnectionNotAllowedByRuleset = ReplyCode(0x02) ErrNetworkUnreachable = ReplyCode(0x03) ErrHostUnreachable = ReplyCode(0x04) ErrConnectionRefused = ReplyCode(0x05) ErrTTLExpired = ReplyCode(0x06) ErrCommandNotSupported = ReplyCode(0x07) ErrAddressTypeNotSupported = ReplyCode(0x08) )
SOCKS reply codes, as enumerated in https://datatracker.ietf.org/doc/html/rfc1928#section-6.
const ( CmdConnect = byte(1) CmdBind = byte(2) CmdUDPAssociate = byte(3) )
SOCKS5 commands, from https://datatracker.ietf.org/doc/html/rfc1928#section-4.
Variables ¶
This section is empty.
Functions ¶
func NewPacketListener ¶
func NewPacketListener(endpoint transport.PacketEndpoint) (transport.PacketListener, error)
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func NewClient ¶
func NewClient(streamEndpoint transport.StreamEndpoint) (*Client, error)
NewClient creates a SOCKS5 client that routes connections to a SOCKS5 proxy listening at the given transport.StreamEndpoint.
func (*Client) DialStream ¶
DialStream implements transport.StreamDialer.DialStream using SOCKS5. It will send the auth method, auth credentials (if auth is chosen), and the connect requests in one packet, to avoid an additional roundtrip. The returned [error] will be of type ReplyCode if the server sends a SOCKS error reply code, which you can check against the error constants in this package using errors.Is.
func (*Client) EnablePacket ¶
func (c *Client) EnablePacket(packetDialer transport.PacketDialer)
EnablePacket enables the use of the Client as a transport.PacketListener. It takes the transport.PacketDialer used to connect to the SOCKS5 packet endpoint.
func (*Client) ListenPacket ¶
ListenPacket creates a net.PacketConn for dialing to SOCKS5 server.