Skip to content
/ socks5 Public

A sub-RFC1928 SOCKS5 server implementation in Go with zero external dependencies.

License

Notifications You must be signed in to change notification settings

gaukas/socks5

Repository files navigation

socks5

A sub-RFC1928 SOCKS5 server supporting custom transport layer implemented in pure Go with no external dependency.

Overview

This package implements the SOCKS5 protocol as described in RFC1928 in Go with no external dependency. Unlike a traditional SOCKS5 server, this implementation separates the SOCKS5 server from the actual proxy server, which allows it to be used with any custom transport and/or in other applications.

SOCKS5 Features

  • Authentication Methods
    • NO AUTHENTICATION REQUIRED
    • USERNAME/PASSWORD (untested)
    • GSSAPI (custom support possible via PrivateMethods in Authenticator)
  • Commands
    • CONNECT
    • BIND
    • UDP ASSOCIATE

Usage

It is mandatory to provide a Proxy implementation to spin up a SOCKS5 Server with this package.

A Proxy interface provides a general-purpose proxy backend service with following methods:

type Proxy interface {
	Connect(dst net.Addr) (conn net.Conn, err error)
	Bind(dst net.Addr) (net.Listener, error)
	UDPAssociate() (net.PacketConn, error)
}

Essentially, by allowing custom Proxy, this package enables high programmability and flexibility for how SOCKS5 server proxies network traffic. It is possible to implement a Proxy that proxies traffic via another remote server via some more complex protocol such as TLS.

An example of a Proxy implementation can be found as localProxy in proxy.go. If a Server is spun up with this localProxy, it will act as a traditional SOCKS5 server that proxies traffic directly from the machine it runs on.