socks

package
v0.9.2 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package socks implements the parts of the SOCKS protocol version 5 needed to accept CONNECT requests. See https://tools.ietf.org/html/rfc1928.

Index

Constants

View Source
const (
	Succeeded               = Reply(0)
	ServerFailure           = Reply(1)
	NotAllowed              = Reply(2)
	NetworkUnreachable      = Reply(3)
	HostUnreachable         = Reply(4)
	ConnectionRefused       = Reply(5)
	TTLExpired              = Reply(6)
	CommandNotSupported     = Reply(7)
	AddressTypeNotSupported = Reply(8)
)

Variables

View Source
var (
	ErrUnsupportedVersion = errors.New("socks: unsupported version")
	ErrUnsupportedAuth    = errors.New("socks: unsupported auth")
	ErrUnsupportedAddress = errors.New("socks: unsupported address")
	ErrUnsupportedCommand = errors.New("socks: unsupported command")
)

Functions

func Authenticate

func Authenticate(conn net.Conn) error

Authenticate performs the SOCKS5 method negotiation, accepting only the no-authentication method (the proxy itself is unauthenticated).

func ParseRequest

func ParseRequest(conn net.Conn) (string, uint16, error)

ParseRequest reads a SOCKS5 request and returns the requested host and port. Only the CONNECT command is supported. IPv4, IPv6, and domain-name address types are all accepted; the returned host is the literal address string.

func SendReply

func SendReply(conn net.Conn, reply Reply) error

SendReply writes a SOCKS5 reply with an all-zero bound address.

Types

type Reply

type Reply byte

Reply is a SOCKS5 reply code.

Jump to

Keyboard shortcuts

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