socks5

package module
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2020 License: MIT Imports: 16 Imported by: 14

README

socks5

Socks5/Socks5h server and client

Build Status Go Report Card GoDoc GitHub license gocover.io

Usage

API Documentation

Example

  • Support for the CONNECT command
  • Support for the BIND command
  • Support for the ASSOCIATE command

License

Pouch is licensed under the MIT License. See LICENSE for the full license text.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Addr

type Addr struct {
	Name string // fully-qualified domain name
	IP   net.IP
	Port int
}

Addr is a SOCKS-specific address. Either Name or IP is used exclusively.

func (Addr) Address

func (a Addr) Address() string

Address returns a string suitable to dial; prefer returning IP-based address, fallback to Name

func (*Addr) Network

func (a *Addr) Network() string

func (*Addr) String

func (a *Addr) String() string

type Authentication

type Authentication interface {
	Auth(cmd Command, username, password string) bool
}

Authentication proxy authentication

func UserAuth

func UserAuth(username, password string) Authentication

UserAuth basic authentication

type AuthenticationFunc

type AuthenticationFunc func(cmd Command, username, password string) bool

AuthenticationFunc Authentication interface is implemented

func (AuthenticationFunc) Auth

func (f AuthenticationFunc) Auth(cmd Command, username, password string) bool

Auth authentication processing

type Command added in v0.2.1

type Command byte

Command is a SOCKS Command.

const (
	ConnectCommand   Command = 0x01
	BindCommand      Command = 0x02
	AssociateCommand Command = 0x03
)

func (Command) String added in v0.2.1

func (cmd Command) String() string

type Dialer

type Dialer struct {
	// ProxyNetwork network between a proxy server and a client
	ProxyNetwork string
	// ProxyAddress proxy server address
	ProxyAddress string
	// ProxyDial specifies the optional dial function for
	// establishing the transport connection.
	ProxyDial func(context.Context, string, string) (net.Conn, error)
	// Username use username authentication if not empty
	Username string
	// Password use password authentication if not empty,
	// only valid if username is set
	Password string
	// IsResolve resolve domain name on locally
	IsResolve bool
	// Resolver optionally specifies an alternate resolver to use
	Resolver *net.Resolver
	// Timeout is the maximum amount of time a dial will wait for
	// a connect to complete. The default is no timeout
	Timeout time.Duration
}

Dialer is a SOCKS5 dialer.

func NewDialer

func NewDialer(addr string) (*Dialer, error)

NewDialer returns a new Dialer that dials through the provided proxy server's network and address.

func (*Dialer) Dial

func (d *Dialer) Dial(network, address string) (net.Conn, error)

Dial connects to the provided address on the provided network.

func (*Dialer) DialContext

func (d *Dialer) DialContext(ctx context.Context, network, address string) (net.Conn, error)

DialContext connects to the provided address on the provided network.

func (*Dialer) Listen added in v0.2.1

func (d *Dialer) Listen(ctx context.Context, network, address string) (net.Listener, error)

type Server

type Server struct {
	// Authentication is proxy authentication
	Authentication Authentication
	// ProxyDial specifies the optional proxyDial function for
	// establishing the transport connection.
	ProxyDial func(context.Context, string, string) (net.Conn, error)
	// Logger error log
	Logger *log.Logger
	// Context is default context
	Context context.Context
}

Server is accepting connections and handling the details of the SOCKS5 protocol

func NewServer

func NewServer() *Server

NewServer creates a new Server

func (*Server) ListenAndServe

func (s *Server) ListenAndServe(network, addr string) error

ListenAndServe is used to create a listener and serve on it

func (*Server) Serve

func (s *Server) Serve(l net.Listener) error

Serve is used to serve connections from a listener

func (*Server) ServeConn

func (s *Server) ServeConn(conn net.Conn)

ServeConn is used to serve a single connection.

type UDPConn added in v0.2.1

type UDPConn struct {
	net.Conn
	// contains filtered or unexported fields
}

func NewUDPConn added in v0.2.1

func NewUDPConn(raw net.Conn, address string) (*UDPConn, error)

func (*UDPConn) Read added in v0.2.1

func (c *UDPConn) Read(b []byte) (int, error)

Read implements the net.Conn Read method.

func (*UDPConn) ReadFrom added in v0.2.1

func (c *UDPConn) ReadFrom(p []byte) (n int, addr net.Addr, err error)

ReadFrom implements the net.PacketConn ReadFrom method.

func (*UDPConn) Write added in v0.2.1

func (c *UDPConn) Write(b []byte) (int, error)

Write implements the net.Conn Write method.

func (*UDPConn) WriteTo added in v0.2.1

func (c *UDPConn) WriteTo(p []byte, addr net.Addr) (n int, err error)

WriteTo implements the net.PacketConn WriteTo method.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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