socks5

package
v0.0.17 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 20, 2024 License: Apache-2.0 Imports: 12 Imported by: 1

Documentation

Index

Constants

View Source
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.

View Source
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

This section is empty.

Types

type Client added in v0.0.17

type Client struct {
	// contains filtered or unexported fields
}

func NewClient added in v0.0.17

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 added in v0.0.17

func (c *Client) DialStream(ctx context.Context, dstAddr string) (transport.StreamConn, error)

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 added in v0.0.17

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 added in v0.0.17

func (c *Client) ListenPacket(ctx context.Context) (net.PacketConn, error)

ListenPacket creates a net.PacketConn for dialing to SOCKS5 server.

func (*Client) SetCredentials added in v0.0.17

func (c *Client) SetCredentials(username, password []byte) error

type ReplyCode added in v0.0.5

type ReplyCode byte

ReplyCode is a byte-unsigned number that represents a SOCKS error as indicated in the REP field of the server response.

func (ReplyCode) Error added in v0.0.5

func (e ReplyCode) Error() string

Error returns a human-readable description of the error, based on the SOCKS5 RFC.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL