socks5test

package
v2.8.48 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2026 License: MIT Imports: 6 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 socks5test provides a minimal in-process RFC 1928 / RFC 1929 SOCKS5 server for tests.

It listens on loopback, records every CONNECT request it receives, and either relays to the requested target or answers with a configured failure code. Domain-name targets (`socks5h`) resolve through a fixed in-memory table, so tests never touch real DNS or the internet.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Request

type Request struct {
	// Domain is true when the client sent ATYP DOMAINNAME (remote DNS).
	Domain bool
	// Host is the requested IP literal or domain name.
	Host string
	Port int
}

Request is one CONNECT request seen by the server.

type Server

type Server struct {
	// User and Pass, when User is non-empty, require RFC 1929 username/password authentication.
	User, Pass string
	// Hosts maps domain names to the address they resolve to at the proxy (remote DNS).
	Hosts map[string]string
	// Reply, when non-zero, answers every CONNECT with this SOCKS reply code instead of relaying.
	Reply byte
	// Stall makes the server accept connections and never answer (handshake timeout tests).
	Stall bool
	// contains filtered or unexported fields
}

Server is an in-process SOCKS5 proxy.

func (*Server) Accepts

func (s *Server) Accepts() int

Accepts returns how many TCP connections the server accepted.

func (*Server) Addr

func (s *Server) Addr() string

Addr returns the server's `127.0.0.1:port`.

func (*Server) AuthFailures

func (s *Server) AuthFailures() int

AuthFailures returns how many RFC 1929 authentications were rejected.

func (*Server) Close

func (s *Server) Close()

Close stops the listener and all open connections.

func (*Server) Requests

func (s *Server) Requests() []Request

Requests returns a copy of the CONNECT requests received so far.

func (*Server) Start

func (s *Server) Start(t testing.TB)

Start listens on 127.0.0.1:0 and serves until the test ends.

Jump to

Keyboard shortcuts

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