socksclient

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2026 License: Apache-2.0 Imports: 7 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package socksclient is the minimal RFC 1928 client double the SOCKS service's suites exercise — the only SOCKS client written in-tree: standard clients are the compatibility surface, and nothing here grows past the dialect the service pins — method none, CONNECT, UDP ASSOCIATE, whole datagrams.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Connect

func Connect(conn net.Conn, address string) (net.Conn, error)

Connect negotiates method none over conn and issues CONNECT for address, returning the spliced leg: bytes written cross at the destination, and the destination's bytes return.

func DecodeDatagram

func DecodeDatagram(b []byte) (payload []byte, from netip.AddrPort, err error)

DecodeDatagram parses one reply datagram: the payload and the source its header names.

func EncodeDatagram

func EncodeDatagram(payload []byte, dst netip.AddrPort) []byte

EncodeDatagram frames payload for dst the way the client leg sends it.

Types

type Refused

type Refused struct {
	Rep byte
}

Refused is a service refusal: the reply code it answered with.

func (*Refused) Error

func (e *Refused) Error() string

type Relay

type Relay struct {
	// Conn is the client's own UDP socket.
	Conn net.PacketConn
	// Addr is the relay endpoint the ASSOCIATE reply carried — the exit's
	// true address and the relay's port.
	Addr netip.AddrPort
}

Relay is one association's client leg: the packet conn the client's datagrams ride beside the relay endpoint the reply named.

func Associate

func Associate(conn net.Conn, pc net.PacketConn) (*Relay, error)

Associate negotiates method none over conn and issues UDP ASSOCIATE, returning the relay endpoint the reply named beside the client's own datagram leg, pc.

func (*Relay) ReadFrom

func (r *Relay) ReadFrom(payload []byte) (int, netip.AddrPort, error)

ReadFrom waits one reply: its payload and the source the header names.

func (*Relay) WriteTo

func (r *Relay) WriteTo(payload []byte, dst netip.AddrPort) error

WriteTo sends payload to dst through the association, the SOCKS header naming the destination.

Jump to

Keyboard shortcuts

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