brook

package module
v20200502.0.0-...-0896176 Latest Latest
Warning

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

Go to latest
Published: May 1, 2020 License: GPL-3.0 Imports: 45 Imported by: 0

README

Brook

Build Status Wiki Slides Youtube Telegram Group Telegram Channel

Brook


v20200502

  • CLI: Add $ brook dns
  • CLI: Add $ brook pac
  • GUI: Support multiple servers

Some useful tutorial resources


Table of Contents

What is Brook

Brook is a cross-platform proxy/vpn software.
Brook's goal is to keep it simple, stupid and not detectable.

Install via nami

install CLI using nami on Linux/BSD/macOS

nami install github.com/txthinking/brook

or install CLI on Archlinux

pacman -S brook

or download CLI from releases

install GUI on macOS

brew cask install brook

or download GUI: macOS, Windows, Android, iOS

CLI contains server and client, GUI only contains client. iOS client only supports non-China AppStore.

Brook

NAME:
   Brook - A Cross-Platform Proxy/VPN Software

USAGE:
   brook [global options] command [command options] [arguments...]

VERSION:
   20200502

AUTHOR:
   Cloud <cloud@txthinking.com>

COMMANDS:
   server        Run as brook server
   servers       Run as multiple brook servers
   client        Run as brook client, with brook server, to start a socks5 proxy or a http proxy
   tunnel        Run as tunnel, with brook server
   dns           Run as DNS server, with brook server
   tproxy        Run as transparent proxy, with brook server, only works on Linux
   tun           Run as tun, with brook server
   wsserver      Run as brook wsserver, it will start a standard http server and websocket server
   wsclient      Run as brook wsclient, with brook wsserver, to start a socks5 proxy or a http proxy
   link          Print brook link
   qr            Print brook server QR code
   relay         Run as standalone relay
   relays        Run as multiple standalone relays
   socks5        Run as standalone standard socks5 server
   socks5tohttp  Convert socks5 to http proxy
   pac           Run as PAC server or save PAC to file
   systemproxy   Set system proxy with pac url, or remove, only works on macOS/Windows
   ssserver      Run as shadowsocks server, fixed method is aes-256-cfb
   ssservers     Run as shadowsocks multiple servers, fixed method is aes-256-cfb
   ssclient      Run as shadowsocks client, with shadowsocks server, to start a socks5 proxy or a http proxy, fixed method is aes-256-cfb
   howto         Print some useful tutorial resources
   help, h       Shows a list of commands or help for one command

GLOBAL OPTIONS:
   --debug, -d               Enable debug (default: false)
   --listen value, -l value  Listen address for debug (default: ":6060")
   --help, -h                show help (default: false)
   --version, -v             print the version (default: false)

COPYRIGHT:
   https://github.com/txthinking/brook
Server
# Run as a brook server
$ brook server -l listen_address:port -p password

More parameters: $ brook server -h

Client
# Run as brook client, connect to brook server, start a socks5 proxy server
$ brook client -s server_address:port -p password -l listen_address:port -i socks5_server_ip

More parameters: $ brook client -h

Tunnel
# Run as tunnel, connect to brook server
$ brook tunnel -s server_address:port -p password -l listen_address:port -t tunnel_to_address:port

More parameters: $ brook tunnel -h

DNS Server
# Run as DNS server, connect to brook server
$ brook dns -s server_address:port -p password -l listen_address:port

More parameters: $ brook dns -h

Transparent Proxy

See wiki

Tun
# Run as tun, connect to brook server, proxy all TCP/UDP. [ROOT privileges required].
$ sudo brook tun -s server_address:port -p password -l 127.0.0.1:1080

# Must exit by Ctrl+C

More parameters: $ brook tun -h

See wiki for more tutorials

WebSocket Server
# Run as a brook wsserver
$ brook wsserver -l listen_address:port -p password
# Run as a brook wsserver with domain, make sure your domain name has been successfully resolved, 80 and 443 are open, brook will automatically issue certificate for you
$ brook wsserver --domain yourdomain.com -p password

More parameters: $ brook wsserver -h

WebSocket Client
# Run as brook wsclient, connect to brook wsserver, start a socks5 proxy server
$ brook wsclient -s ws://wsserver_address:port -p password -l listen_address:port -i socks5_server_ip
# Run as brook wsclient, connect to brook wsserver with domain, start a http proxy
$ brook wsclient -s wss://wsserver_domain:port -p password -l listen_address:port --http

More parameters: $ brook wsclient -h

$ brook link -s server_address:port -p password
$ brook link -s ws://wsserver_address:port -p password
$ brook link -s wss://wsserver_domain:port -p password

More parameters: $ brook link -h

QR
$ brook qr -s server_address:port -p password
$ brook qr -s ws://wsserver_address:port -p password
$ brook qr -s wss://wsserver_domain:port -p password

More parameters: $ brook qr -h

Relay
# Run as relay
$ brook relay -l listen_address:port -r relay_to_address:port

More parameters: $ brook relay -h

Socks5 Server
# Run as standard socks5 server
$ brook socks5 -l listen_address:port -i server_ip

More parameters: $ brook socks5 -h

Socks5 to http
# Convert socks5 proxy to http proxy
$ brook socks5tohttp -l listen_address:port -s socks5_server_address:port

More parameters: $ brook socks5tohttp -h

PAC
# Create PAC server
$ brook pac -l listen_address_port

# Save PAC to local file
$ brook pac -f /path/to/file.pac

More parameters: $ brook pac -h

System Proxy
# Set system PAC proxy
$ brook systemproxy -u pac_url

# Clear system PAC proxy
$ brook systemproxy -r

More parameters: $ brook systemproxy -h

Shadowsocks
# Run as shadowsocks server
$ brook ssserver -l listen_address:port -p password

More parameters: $ brook ssserver -h

# Run as shadowsocks client, connect to shadowsocks server, start a socks5 proxy server
$ brook ssclient -s ssserver_address:port -p password -l listen_address:port -i socks5_server_ip

More parameters: $ brook ssclient -h

Fixed method is aes-256-cfb

How to

Some useful tutorial resources

Contributing

Please read CONTRIBUTING.md first

License

Licensed under The GPLv3 License

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Debug bool = false

Functions

func Decrypt

func Decrypt(p, b []byte) (a byte, addr, port, data []byte, err error)

Decrypt data.

func DecryptLength

func DecryptLength(p, b []byte) (int, error)

Decrypt data length.

func EnableDebug

func EnableDebug()

EnableDebug.

func Encrypt

func Encrypt(p, b []byte) ([]byte, error)

Encrypt data.

func EncryptLength

func EncryptLength(p, b []byte) ([]byte, error)

Encrypt data length.

func ErrorReply

func ErrorReply(r *socks5.Request, c *net.TCPConn, e error) error

func GetAddressFromURL

func GetAddressFromURL(s string) (string, error)

func GetKey

func GetKey(p, n []byte) ([]byte, error)

GetKey.

func IncrementNonce

func IncrementNonce(n []byte) []byte

IncrementNonce loves your compute to use Little Endian.

func Link(server, password string) string

Link

func MakeSSKey

func MakeSSKey(password string) []byte

MakeSSKey used to make shadowsocks aes-256-cfb key.

func PrepareKey

func PrepareKey(p []byte) ([]byte, []byte, error)

PrepareKey.

func QR

func QR(server, password string)

QR generate and print QR code.

func ReadFrom

func ReadFrom(c net.Conn, k, n []byte, hasTime bool) ([]byte, []byte, error)

ReadFrom.

func WriteTo

func WriteTo(c net.Conn, d, k, n []byte, needTime bool) ([]byte, int, error)

WriteTo.

Types

type CipherConn

type CipherConn struct {
	// contains filtered or unexported fields
}

CipherConn is the encrypted connection.

func NewCipherConn

func NewCipherConn(c net.Conn, key []byte, iv []byte) (*CipherConn, error)

NewCipherConn returns a new CipherConn, iv length must be equal aes.BlockSize.

func (*CipherConn) Close

func (c *CipherConn) Close() error

Close is just like net.Conn interface.

func (*CipherConn) LocalAddr

func (c *CipherConn) LocalAddr() net.Addr

LocalAddr is just like net.Conn interface.

func (*CipherConn) Read

func (c *CipherConn) Read(b []byte) (n int, err error)

Read is just like net.Conn interface.

func (*CipherConn) RemoteAddr

func (c *CipherConn) RemoteAddr() net.Addr

RemoteAddr is just like net.Conn interface.

func (*CipherConn) SetDeadline

func (c *CipherConn) SetDeadline(t time.Time) error

SetDeadline is just like net.Conn interface.

func (*CipherConn) SetReadDeadline

func (c *CipherConn) SetReadDeadline(t time.Time) error

SetReadDeadline is just like net.Conn interface.

func (*CipherConn) SetWriteDeadline

func (c *CipherConn) SetWriteDeadline(t time.Time) error

SetWriteDeadline is just like net.Conn interface.

func (*CipherConn) Write

func (c *CipherConn) Write(b []byte) (n int, err error)

Write is just like net.Conn interface.

type Client

type Client struct {
	Server          *socks5.Server
	RemoteAddr      string
	Password        []byte
	TCPTimeout      int
	TCPDeadline     int
	UDPDeadline     int
	TCPListen       *net.TCPListener
	Socks5Middleman plugin.Socks5Middleman
	HTTPMiddleman   plugin.HTTPMiddleman
	ClientAuthman   plugin.ClientAuthman
	Cache           *cache.Cache
}

Client.

func NewClient

func NewClient(addr, ip, server, password string, tcpTimeout, tcpDeadline, udpDeadline, udpSessionTime int) (*Client, error)

NewClient returns a new Client.

func (*Client) HTTPHandle

func (x *Client) HTTPHandle(c *net.TCPConn) error

HTTPHandle handles http request.

func (*Client) ListenAndServe

func (x *Client) ListenAndServe() error

ListenAndServe will let client start a socks5 proxy.

func (*Client) ListenAndServeHTTP

func (x *Client) ListenAndServeHTTP() error

ListenAndServeHTTP will let client start a http proxy.

func (*Client) SetClientAuthman

func (x *Client) SetClientAuthman(m plugin.ClientAuthman)

SetClientAuthman sets authman plugin.

func (*Client) SetHTTPMiddleman

func (x *Client) SetHTTPMiddleman(m plugin.HTTPMiddleman)

SetHTTPMiddleman sets httpmiddleman plugin.

func (*Client) SetSocks5Middleman

func (x *Client) SetSocks5Middleman(m plugin.Socks5Middleman)

SetSocks5Middleman sets socks5middleman plugin.

func (*Client) Shutdown

func (x *Client) Shutdown() error

Shutdown used to stop the client.

func (*Client) TCPHandle

func (x *Client) TCPHandle(s *socks5.Server, c *net.TCPConn, r *socks5.Request) error

TCPHandle handles tcp request.

func (*Client) UDPHandle

func (x *Client) UDPHandle(s *socks5.Server, addr *net.UDPAddr, d *socks5.Datagram) error

UDPHandle handles udp request.

type DNS

type DNS struct {
	TCPAddr          *net.TCPAddr
	UDPAddr          *net.UDPAddr
	RemoteTCPAddr    *net.TCPAddr
	RemoteUDPAddr    *net.UDPAddr
	Password         []byte
	Domains          map[string]byte
	DefaultDNSServer string
	ListDNSServer    string
	TCPListen        *net.TCPListener
	UDPConn          *net.UDPConn
	Cache            *cache.Cache
	TCPDeadline      int
	TCPTimeout       int
	UDPDeadline      int
	RunnerGroup      *runnergroup.RunnerGroup
}

DNS.

func NewDNS

func NewDNS(addr, server, password, defaultDNSServer, listDNSServer, list string, tcpTimeout, tcpDeadline, udpDeadline int) (*DNS, error)

NewDNS.

func (*DNS) Has

func (s *DNS) Has(host string) bool

func (*DNS) ListenAndServe

func (s *DNS) ListenAndServe() error

Run server.

func (*DNS) RunTCPServer

func (s *DNS) RunTCPServer() error

RunTCPServer starts tcp server.

func (*DNS) RunUDPServer

func (s *DNS) RunUDPServer() error

RunUDPServer starts udp server.

func (*DNS) Shutdown

func (s *DNS) Shutdown() error

Shutdown server.

func (*DNS) TCPHandle

func (s *DNS) TCPHandle(c *net.TCPConn) error

TCPHandle handles request.

func (*DNS) UDPHandle

func (s *DNS) UDPHandle(addr *net.UDPAddr, b []byte) error

UDPHandle handles packet.

type PAC

type PAC struct {
	Addr string
	File string
	// global/white/black
	Proxy      string
	Mode       string
	DomainURL  string
	CidrURL    string
	DomainData []byte
	CidrData   []byte
	HTTPServer *http.Server
	Body       []byte
}

func NewPAC

func NewPAC(addr, file, proxy, mode, domainURL, cidrURL string) *PAC

func (*PAC) ListenAndServe

func (p *PAC) ListenAndServe() error

func (*PAC) MakeBody

func (p *PAC) MakeBody() (io.Reader, error)

func (*PAC) ServeHTTP

func (p *PAC) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*PAC) Shutdown

func (p *PAC) Shutdown() error

func (*PAC) WriteToFile

func (p *PAC) WriteToFile() error

func (*PAC) WriteToStdout

func (p *PAC) WriteToStdout() error

type Relay

type Relay struct {
	TCPAddr       *net.TCPAddr
	UDPAddr       *net.UDPAddr
	RemoteTCPAddr *net.TCPAddr
	RemoteUDPAddr *net.UDPAddr
	TCPListen     *net.TCPListener
	UDPConn       *net.UDPConn
	Cache         *cache.Cache
	TCPDeadline   int
	TCPTimeout    int
	UDPDeadline   int
	RunnerGroup   *runnergroup.RunnerGroup
}

Relay is relay server.

func NewRelay

func NewRelay(addr, remote string, tcpTimeout, tcpDeadline, udpDeadline int) (*Relay, error)

NewRelay returns a Relay.

func (*Relay) ListenAndServe

func (s *Relay) ListenAndServe() error

Run server.

func (*Relay) RunTCPServer

func (s *Relay) RunTCPServer() error

RunTCPServer starts tcp server.

func (*Relay) RunUDPServer

func (s *Relay) RunUDPServer() error

RunUDPServer starts udp server.

func (*Relay) Shutdown

func (s *Relay) Shutdown() error

Shutdown server.

func (*Relay) TCPHandle

func (s *Relay) TCPHandle(c *net.TCPConn) error

TCPHandle handles request.

func (*Relay) UDPHandle

func (s *Relay) UDPHandle(addr *net.UDPAddr, b []byte) error

UDPHandle handles packet.

type SSClient

type SSClient struct {
	Server          *socks5.Server
	RemoteAddr      string
	Password        []byte
	TCPTimeout      int
	TCPDeadline     int
	UDPDeadline     int
	TCPListen       *net.TCPListener
	Socks5Middleman plugin.Socks5Middleman
	HTTPMiddleman   plugin.HTTPMiddleman
	Cache           *cache.Cache
}

SSClient.

func NewSSClient

func NewSSClient(addr, ip, server, password string, tcpTimeout, tcpDeadline, udpDeadline, udpSessionTime int) (*SSClient, error)

NewSSClient returns a new SSClient.

func (*SSClient) Decrypt

func (x *SSClient) Decrypt(cd []byte) (a byte, addr, port, data []byte, err error)

Decrypt data.

func (*SSClient) Encrypt

func (x *SSClient) Encrypt(rawdata []byte) ([]byte, error)

Encrypt data.

func (*SSClient) HTTPHandle

func (x *SSClient) HTTPHandle(c *net.TCPConn) error

HTTPHandle handles http request.

func (*SSClient) ListenAndServe

func (x *SSClient) ListenAndServe() error

ListenAndServe will let client start a socks5 proxy.

func (*SSClient) ListenAndServeHTTP

func (x *SSClient) ListenAndServeHTTP() error

ListenAndServeHTTP will let client start a http proxy.

func (*SSClient) SetHTTPMiddleman

func (x *SSClient) SetHTTPMiddleman(m plugin.HTTPMiddleman)

SetHTTPMiddleman sets httpmiddleman plugin.

func (*SSClient) SetSocks5Middleman

func (x *SSClient) SetSocks5Middleman(m plugin.Socks5Middleman)

SetSocks5Middleman sets socks5middleman plugin.

func (*SSClient) Shutdown

func (x *SSClient) Shutdown() error

Shutdown used to stop the client.

func (*SSClient) TCPHandle

func (x *SSClient) TCPHandle(s *socks5.Server, c *net.TCPConn, r *socks5.Request) error

TCPHandle handles tcp request.

func (*SSClient) UDPHandle

func (x *SSClient) UDPHandle(s *socks5.Server, addr *net.UDPAddr, d *socks5.Datagram) error

UDPHandle handles udp request.

func (*SSClient) WrapCipherConn

func (x *SSClient) WrapCipherConn(conn *net.TCPConn) (*CipherConn, error)

WrapChiperConn makes a chiper conn.

type SSServer

type SSServer struct {
	Password    []byte
	TCPAddr     *net.TCPAddr
	UDPAddr     *net.UDPAddr
	TCPListen   *net.TCPListener
	UDPConn     *net.UDPConn
	Cache       *cache.Cache
	TCPDeadline int
	TCPTimeout  int
	UDPDeadline int
	RunnerGroup *runnergroup.RunnerGroup
}

SSServer.

func NewSSServer

func NewSSServer(addr, password string, tcpTimeout, tcpDeadline, udpDeadline int) (*SSServer, error)

NewSSServer.

func (*SSServer) Decrypt

func (s *SSServer) Decrypt(cd []byte) (a byte, addr, port, data []byte, err error)

Decrypt data.

func (*SSServer) Encrypt

func (s *SSServer) Encrypt(a byte, h, p, d []byte) ([]byte, error)

Encrypt data.

func (*SSServer) ListenAndServe

func (s *SSServer) ListenAndServe() error

ListenAndServe server.

func (*SSServer) RunTCPServer

func (s *SSServer) RunTCPServer() error

RunTCPServer starts tcp server.

func (*SSServer) RunUDPServer

func (s *SSServer) RunUDPServer() error

RunUDPServer starts udp server.

func (*SSServer) Shutdown

func (s *SSServer) Shutdown() error

Shutdown server.

func (*SSServer) TCPHandle

func (s *SSServer) TCPHandle(c *net.TCPConn) error

TCPHandle handles request.

func (*SSServer) UDPHandle

func (s *SSServer) UDPHandle(addr *net.UDPAddr, b []byte) error

UDPHandle handles packet.

func (*SSServer) WrapCipherConn

func (s *SSServer) WrapCipherConn(conn net.Conn) (*CipherConn, error)

WrapChiperConn makes a chiper conn.

type Server

type Server struct {
	Password      []byte
	TCPAddr       *net.TCPAddr
	UDPAddr       *net.UDPAddr
	TCPListen     *net.TCPListener
	UDPConn       *net.UDPConn
	Cache         *cache.Cache
	TCPDeadline   int
	TCPTimeout    int
	UDPDeadline   int
	ServerAuthman plugin.ServerAuthman
	RunnerGroup   *runnergroup.RunnerGroup
}

Server.

func NewServer

func NewServer(addr, password string, tcpTimeout, tcpDeadline, udpDeadline int) (*Server, error)

NewServer.

func (*Server) ListenAndServe

func (s *Server) ListenAndServe() error

Run server.

func (*Server) RunTCPServer

func (s *Server) RunTCPServer() error

RunTCPServer starts tcp server.

func (*Server) RunUDPServer

func (s *Server) RunUDPServer() error

RunUDPServer starts udp server.

func (*Server) SetServerAuthman

func (s *Server) SetServerAuthman(m plugin.ServerAuthman)

SetServerAuthman sets authman plugin.

func (*Server) Shutdown

func (s *Server) Shutdown() error

Shutdown server.

func (*Server) TCPHandle

func (s *Server) TCPHandle(c *net.TCPConn) error

TCPHandle handles request.

func (*Server) UDPHandle

func (s *Server) UDPHandle(addr *net.UDPAddr, b []byte) error

UDPHandle handles packet.

type ServerUDPExchange

type ServerUDPExchange struct {
	ClientAddr *net.UDPAddr
	RemoteConn *net.UDPConn
	Internet   plugin.Internet
}

type Socks5Server

type Socks5Server struct {
	Server          *socks5.Server
	Socks5Middleman plugin.Socks5Middleman
	TCPTimeout      int
	TCPDeadline     int
	UDPDeadline     int
	UDPSessionTime  int
	ForwardAddress  string
	ForwardUserName string
	ForwardPassword string
	Cache           *cache.Cache
}

Socks5Server is raw socks5 server.

func NewSocks5Server

func NewSocks5Server(addr, ip, userName, password string, tcpTimeout, tcpDeadline, udpDeadline, udpSessionTime int) (*Socks5Server, error)

NewSocks5Server returns a new Socks5Server.

func (*Socks5Server) ListenAndForward

func (x *Socks5Server) ListenAndForward(addr, username, password string) error

ListenAndForward will let client start a proxy to listen and forward to another socks5.

func (*Socks5Server) ListenAndServe

func (x *Socks5Server) ListenAndServe() error

ListenAndServe will let client start to listen and serve.

func (*Socks5Server) SetSocks5Middleman

func (x *Socks5Server) SetSocks5Middleman(m plugin.Socks5Middleman)

SetSocks5Middleman sets socks5middleman plugin.

func (*Socks5Server) Shutdown

func (x *Socks5Server) Shutdown() error

Shutdown used to stop the client.

func (*Socks5Server) TCPHandle

func (x *Socks5Server) TCPHandle(s *socks5.Server, c *net.TCPConn, r *socks5.Request) error

TCPHandle handles tcp request.

func (*Socks5Server) UDPHandle

func (x *Socks5Server) UDPHandle(s *socks5.Server, addr *net.UDPAddr, d *socks5.Datagram) error

UDPHandle handles udp request.

type Socks5ToHTTP

type Socks5ToHTTP struct {
	Addr           *net.TCPAddr
	Socks5Address  string
	Socks5Username string
	Socks5Password string
	Dial           proxy.Dialer
	Timeout        int
	Deadline       int
	Listen         *net.TCPListener
	HTTPMiddleman  plugin.HTTPMiddleman
}

func NewSocks5ToHTTP

func NewSocks5ToHTTP(addr, socks5addr, socks5username, socks5password string, timeout, deadline int) (*Socks5ToHTTP, error)

func (*Socks5ToHTTP) Handle

func (s *Socks5ToHTTP) Handle(c *net.TCPConn) error

func (*Socks5ToHTTP) ListenAndServe

func (s *Socks5ToHTTP) ListenAndServe() error

func (*Socks5ToHTTP) SetHTTPMiddleman

func (s *Socks5ToHTTP) SetHTTPMiddleman(m plugin.HTTPMiddleman)

SetHTTPMiddleman sets httpmiddleman plugin.

func (*Socks5ToHTTP) Shutdown

func (s *Socks5ToHTTP) Shutdown() error

type Tproxy

type Tproxy struct {
	TCPAddr       *net.TCPAddr
	UDPAddr       *net.UDPAddr
	RemoteTCPAddr *net.TCPAddr
	RemoteUDPAddr *net.UDPAddr
	Password      []byte
	TCPListen     *net.TCPListener
	UDPConn       *net.UDPConn
	Cache         *cache.Cache
	TCPDeadline   int
	TCPTimeout    int
	UDPDeadline   int
	RunnerGroup   *runnergroup.RunnerGroup
}

Tproxy.

func NewTproxy

func NewTproxy(addr, remote, password string, tcpTimeout, tcpDeadline, udpDeadline int) (*Tproxy, error)

NewTproxy.

func (*Tproxy) ClearAutoScripts

func (s *Tproxy) ClearAutoScripts() error

func (*Tproxy) ListenAndServe

func (s *Tproxy) ListenAndServe() error

Run server.

func (*Tproxy) RunAutoScripts

func (s *Tproxy) RunAutoScripts() error

func (*Tproxy) RunTCPServer

func (s *Tproxy) RunTCPServer() error

RunTCPServer starts tcp server.

func (*Tproxy) RunUDPServer

func (s *Tproxy) RunUDPServer() error

RunUDPServer starts udp server.

func (*Tproxy) Shutdown

func (s *Tproxy) Shutdown() error

Shutdown server.

func (*Tproxy) TCPHandle

func (s *Tproxy) TCPHandle(c *net.TCPConn) error

TCPHandle handles request.

func (*Tproxy) UDPHandle

func (s *Tproxy) UDPHandle(addr, daddr *net.UDPAddr, b []byte) error

type TproxyUDPExchange

type TproxyUDPExchange struct {
	RemoteConn *net.UDPConn
	LocalConn  *net.UDPConn
}

type Tun

type Tun struct {
	Client             *Client
	Tunnel             *Tunnel
	Tun                *gotun2socks.Tun2Socks
	ServerIP           string
	TunGateway         string
	OriginalDNSServers []string
	RunnerGroup        *runnergroup.RunnerGroup
}

Tun.

func NewTun

func NewTun(addr, server, password, dns string, tcpTimeout, tcpDeadline, udpDeadline, udpSessionTime int, tunDevice, tunIP, tunGateway, tunMask string) (*Tun, error)

NewTun.

func (*Tun) AddRoutes

func (v *Tun) AddRoutes() error

AddRoutes adds routes.

func (*Tun) DeleteRoutes

func (v *Tun) DeleteRoutes() error

DeleteRoutes deletes routes.

func (*Tun) ListenAndServe

func (v *Tun) ListenAndServe() error

ListenAndServe starts to run Tun.

func (*Tun) Shutdown

func (v *Tun) Shutdown() error

Shutdown stops Tun.

type Tunnel

type Tunnel struct {
	TCPAddr       *net.TCPAddr
	UDPAddr       *net.UDPAddr
	ToAddr        string
	RemoteTCPAddr *net.TCPAddr
	RemoteUDPAddr *net.UDPAddr
	Password      []byte
	TCPListen     *net.TCPListener
	UDPConn       *net.UDPConn
	Cache         *cache.Cache
	TCPDeadline   int
	TCPTimeout    int
	UDPDeadline   int
	RunnerGroup   *runnergroup.RunnerGroup
}

Tunnel.

func NewTunnel

func NewTunnel(addr, to, remote, password string, tcpTimeout, tcpDeadline, udpDeadline int) (*Tunnel, error)

NewTunnel.

func (*Tunnel) ListenAndServe

func (s *Tunnel) ListenAndServe() error

Run server.

func (*Tunnel) RunTCPServer

func (s *Tunnel) RunTCPServer() error

RunTCPServer starts tcp server.

func (*Tunnel) RunUDPServer

func (s *Tunnel) RunUDPServer() error

RunUDPServer starts udp server.

func (*Tunnel) Shutdown

func (s *Tunnel) Shutdown() error

Shutdown server.

func (*Tunnel) TCPHandle

func (s *Tunnel) TCPHandle(c *net.TCPConn) error

TCPHandle handles request.

func (*Tunnel) UDPHandle

func (s *Tunnel) UDPHandle(addr *net.UDPAddr, b []byte) error

UDPHandle handles packet.

type WSClient

type WSClient struct {
	Server          *socks5.Server
	RemoteAddr      string
	RemoteAddress   string
	TLSConfig       *tls.Config
	Password        []byte
	TCPTimeout      int
	TCPDeadline     int
	UDPDeadline     int
	TCPListen       *net.TCPListener
	Socks5Middleman plugin.Socks5Middleman
	HTTPMiddleman   plugin.HTTPMiddleman
	TLSConnCapacity chan struct{}
	Cache           *cache.Cache
	ClientAuthman   plugin.ClientAuthman
}

WSClient.

func NewWSClient

func NewWSClient(addr, ip, server, password string, tcpTimeout, tcpDeadline, udpDeadline, udpSessionTime int) (*WSClient, error)

NewWSClient.

func (*WSClient) DialWebsocket

func (x *WSClient) DialWebsocket() (net.Conn, error)

func (*WSClient) HTTPHandle

func (x *WSClient) HTTPHandle(c *net.TCPConn) error

HTTPHandle handles http request.

func (*WSClient) ListenAndServe

func (x *WSClient) ListenAndServe() error

ListenAndServe will let client start a socks5 proxy.

func (*WSClient) ListenAndServeHTTP

func (x *WSClient) ListenAndServeHTTP() error

ListenAndServeHTTP will let client start a http proxy.

func (*WSClient) SetClientAuthman

func (x *WSClient) SetClientAuthman(m plugin.ClientAuthman)

SetClientAuthman sets authman plugin.

func (*WSClient) SetHTTPMiddleman

func (x *WSClient) SetHTTPMiddleman(m plugin.HTTPMiddleman)

SetHTTPMiddleman sets httpmiddleman plugin.

func (*WSClient) SetSocks5Middleman

func (x *WSClient) SetSocks5Middleman(m plugin.Socks5Middleman)

SetSocks5Middleman sets socks5middleman plugin.

func (*WSClient) Shutdown

func (x *WSClient) Shutdown() error

Shutdown used to stop the client.

func (*WSClient) TCPHandle

func (x *WSClient) TCPHandle(s *socks5.Server, c *net.TCPConn, r *socks5.Request) error

TCPHandle handles tcp request.

func (*WSClient) UDPHandle

func (x *WSClient) UDPHandle(s *socks5.Server, addr *net.UDPAddr, d *socks5.Datagram) error

UDPHandle handles udp request.

type WSClientUDPExchange

type WSClientUDPExchange struct {
	ClientAddr *net.UDPAddr
	RemoteConn net.Conn
}

type WSServer

type WSServer struct {
	Password      []byte
	Domain        string
	TCPAddr       *net.TCPAddr
	HTTPServer    *http.Server
	HTTPSServer   *http.Server
	TCPDeadline   int
	TCPTimeout    int
	UDPDeadline   int
	ServerAuthman plugin.ServerAuthman
}

WSServer.

func NewWSServer

func NewWSServer(addr, password, domain string, tcpTimeout, tcpDeadline, udpDeadline int) (*WSServer, error)

NewWSServer.

func (*WSServer) ListenAndServe

func (s *WSServer) ListenAndServe() error

Run server.

func (*WSServer) ServeHTTP

func (s *WSServer) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*WSServer) SetServerAuthman

func (s *WSServer) SetServerAuthman(m plugin.ServerAuthman)

SetServerAuthman sets authman plugin.

func (*WSServer) Shutdown

func (s *WSServer) Shutdown() error

Shutdown server.

func (*WSServer) TCPHandle

func (s *WSServer) TCPHandle(c net.Conn) error

TCPHandle handles request.

func (*WSServer) UDPHandle

func (s *WSServer) UDPHandle(c net.Conn) error

UDPHandle handles packet.

Directories

Path Synopsis
cli

Jump to

Keyboard shortcuts

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