brook

package module
v0.0.0-...-1366149 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2020 License: GPL-3.0 Imports: 38 Imported by: 0

README

Brook

Build Status Wiki

Brook


v20200102
  • 🔊 Please uninstall or delete the old GUI client first❗️
  • Add Brook WebSocket mode, with or without TLS. If with TLS, Brook will automatically request/issue certificate for your domain.
  • GUI Client supports QR scanning
  • GUI Client supports custom rules
  • macOS Client renamed to Brook.pkg (Because many users don't know that needed to copy or drag from dmg)
  • Windows Client renamed to Brook.msi
  • develop branch is deleted, PR to master and keep master stable
  • Keep it simple, stupid

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.

Download

Download Server/Client OS Arch Remark
brook Server & Client Linux amd64 CLI
brook_linux_386 Server & Client Linux 386 CLI
brook_linux_arm64 Server & Client Linux arm64 CLI
brook_linux_arm5 Server & Client Linux arm5 CLI
brook_linux_arm6 Server & Client Linux arm6 CLI
brook_linux_arm7 Server & Client Linux arm7 CLI
brook_linux_mips Server & Client Linux mips CLI
brook_linux_mipsle Server & Client Linux mipsle CLI
brook_linux_mips_softfloat Server & Client Linux mips_softfloat CLI
brook_linux_mipsle_softfloat Server & Client Linux mipsle_softfloat CLI
brook_linux_mips64 Server & Client Linux mips64 CLI
brook_linux_mips64le Server & Client Linux mips64le CLI
brook_linux_mips64_softfloat Server & Client Linux mips64_softfloat CLI
brook_linux_mips64le_softfloat Server & Client Linux mips64le_softfloat CLI
brook_linux_ppc64 Server & Client Linux ppc64 CLI
brook_linux_ppc64le Server & Client Linux ppc64le CLI
brook_darwin_amd64 Server & Client macOS amd64 CLI
brook_windows_amd64.exe Server & Client Windows amd64 CLI
brook_windows_386.exe Server & Client Windows 386 CLI
Brook.pkg Client macOS amd64 GUI
Brook.msi Client Windows amd64 GUI
App Store Client iOS - GUI
Brook.apk(No Google Play) Client Android - GUI

See wiki for more tutorials

Packages

ArchLinux
sudo pacman -S brook
macOS(GUI)
brew cask install brook

Brook

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

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

VERSION:
   20200101

COMMANDS:
   server        Run as server mode
   servers       Run as multiple servers mode
   client        Run as client mode
   wsserver      Run as websocket server mode
   wsclient      Run as websocket client mode
   tunnel        Run as tunnel mode on client-site
   tproxy        Run as tproxy mode on client-site, transparent proxy, only works on Linux
   vpn           Run as VPN mode on client-site
   ssserver      Run as shadowsocks server mode, fixed method is aes-256-cfb
   ssservers     Run as shadowsocks multiple servers mode, fixed method is aes-256-cfb
   ssclient      Run as shadowsocks client mode, fixed method is aes-256-cfb
   socks5        Run as raw socks5 server
   relay         Run as relay mode
   relays        Run as multiple relays mode
   link          Print brook link
   qr            Print brook server QR code
   socks5tohttp  Convert socks5 to http proxy
   systemproxy   Set system proxy with pac url, or remove, only works on macOS/Windows
   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 :9999 -p password
# Run as multiple brook servers
$ brook servers -l ":9999 password" -l ":8888 password"

If you run a public/shared server, do not forget this parameter --tcpDeadline

Client
# Run as brook client, start a socks5 proxy socks5://127.0.0.1:1080
$ brook client -l 127.0.0.1:1080 -i 127.0.0.1 -s server_address:port -p password
# Run as brook client, start a http(s) proxy http(s)://127.0.0.1:8080
$ brook client -l 127.0.0.1:8080 -i 127.0.0.1 -s server_address:port -p password --http
WSServer
# Run as a brook wsserver
$ brook wsserver -l :9999 -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 txthinking.com -p password

If you run a public/shared server, do not forget this parameter --tcpDeadline

WSClient
# Run as brook wsclient, connect brook wsserver
$ brook wsclient -l 127.0.0.1:1080 -i 127.0.0.1 -s ws://1.2.3.4:5 -p password
# Run as brook wsclient, connect brook wsserver with tls
$ brook wsclient -l 127.0.0.1:1080 -i 127.0.0.1 -s wss://txthinking.com:443 -p password
GUI Client

See download

Tunnel
# Run as tunnel 127.0.0.1:5 to 1.2.3.4:5
$ brook tunnel -l 127.0.0.1:5 -t 1.2.3.4:5 -s server_address:port -p password
Tproxy (usually used on Linux router box)

See wiki

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

# Must exit by Ctrl+C

See wiki for more tutorials

Relay
# Run as relay to 1.2.3.4:5
$ brook relay -l :5 -r 1.2.3.4:5
Socks5
# Run as a raw socks5 server 1.2.3.4:1080
$ brook socks5 -l :1080 -i 1.2.3.4
Socks5 to HTTP
# Convert socks5://127.0.0.1:1080 to http(s)://127.0.0.1:8080 proxy
$ brook socks5tohttp -l 127.0.0.1:8080 -s 127.0.0.1:1080
Shadowsocks
# Run as a shadowsocks server
$ brook ssserver -l :9999 -p password
# Run as multiple shadowsocks servers
$ brook ssservers -l ":9999 password" -l ":8888 password"

If you run a public/shared server, do not forget this parameter --tcpDeadline

# Run as shadowsocks client, start a socks5 proxy socks5://127.0.0.1:1080
$ brook ssclient -l 127.0.0.1:1080 -i 127.0.0.1 -s server_address:port -p password
# Run as shadowsocks client, start a http(s) proxy http(s)://127.0.0.1:8080
$ brook ssclient -l 127.0.0.1:8080 -i 127.0.0.1 -s server_address:port -p password --http

Fixed method is aes-256-cfb

See wiki for more tutorials

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
View Source
var Traffic = &traffic{
	Threshold: 200 * 1024,
	onData:    func(int, int, int) {},
	ports:     make(map[int]*portTraffic),
}

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 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 RunClient

func RunClient(address, ip, server, password string, tcpTimeout, tcpDeadline, udpDeadline, udpSessionTime int) error

RunClient used to make a new Client and start a socks5 proxy to listen

func RunClientAsHTTP

func RunClientAsHTTP(address, ip, server, password string, tcpTimeout, tcpDeadline, udpDeadline, udpSessionTime int) error

RunClientAsHTTP used to make a new Client and start a http proxy to listen

func RunRelay

func RunRelay(address, remote string, tcpTimeout, tcpDeadline, udpDeadline int) error

RunRelay used to make a new Relay and start to listen

func RunSSClient

func RunSSClient(address, ip, server, password string, tcpTimeout, tcpDeadline, udpDeadline, udpSessionTime int) error

RunSSClient used to make a new Client and start a socks5 proxy to listen

func RunSSClientAsHTTP

func RunSSClientAsHTTP(address, ip, server, password string, tcpTimeout, tcpDeadline, udpDeadline, udpSessionTime int) error

RunSSClientAsHTTP used to make a new Client and start a http proxy to listen

func RunSSServer

func RunSSServer(address, password string, tcpTimeout, tcpDeadline, udpDeadline int) error

RunSSServer used to make a new Server and start to listen

func RunServer

func RunServer(address, password string, tcpTimeout, tcpDeadline, udpDeadline int) error

RunServer used to make a new Server and start to listen

func RunSocks5Server

func RunSocks5Server(address, ip, username, password string, tcpTimeout, tcpDeadline, udpDeadline, udpSessionTime int) error

RunSocks5Server used to make a new Socks5Server and start a raw socks5 proxy to listen

func RunSocks5ToHTTP

func RunSocks5ToHTTP(address, socks5 string, timeout, deadline int) error

RunSocks5ToHTTP used to make a new Socks5ToHTTP and start a http proxy to listen

func RunStreamClient

func RunStreamClient(address, ip, server, password string, tcpTimeout, tcpDeadline, udpDeadline, udpSessionTime int) error

RunStreamClient used to make a new StreamClient and start a socks5 proxy to listen

func RunStreamClientAsHTTP

func RunStreamClientAsHTTP(address, ip, server, password string, tcpTimeout, tcpDeadline, udpDeadline, udpSessionTime int) error

RunClientAsHTTP used to make a new StreamClient and start a http proxy to listen

func RunStreamServer

func RunStreamServer(address, password string, tcpTimeout, tcpDeadline, udpDeadline int) error

RunStreamServer used to make a new StreamServer and start to listen

func RunSystemProxy

func RunSystemProxy(remove bool, pac string) error

RunSystemProxy used to set/remove system proxy

func RunTunnel

func RunTunnel(address, to, server, password string, tcpTimeout, tcpDeadline, udpDeadline int) error

RunTunnel used to start a tunnel

func WriteTo

func WriteTo(c net.Conn, d, k, n []byte, needTime bool) ([]byte, 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
}

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) 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 Relay

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

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
}

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
	UDPExchanges *cache.Cache
	TCPDeadline  int
	TCPTimeout   int
	UDPDeadline  int
}

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
	UDPExchanges *cache.Cache
	TCPDeadline  int
	TCPTimeout   int
	UDPDeadline  int
}

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) 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 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
	Dial          proxy.Dialer
	Timeout       int
	Deadline      int
	Listen        *net.TCPListener
	HTTPMiddleman plugin.HTTPMiddleman
}

func NewSocks5ToHTTP

func NewSocks5ToHTTP(addr, socks5addr 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 StreamClient

type StreamClient struct {
	Server          *socks5.Server
	RemoteAddr      string
	Password        []byte
	TCPTimeout      int
	TCPDeadline     int // Not refreshed
	UDPDeadline     int
	Socks5Middleman plugin.Socks5Middleman
	HTTPMiddleman   plugin.HTTPMiddleman
	TCPListen       *net.TCPListener
}

StreamClient

func NewStreamClient

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

NewStreamClient returns a new StreamClient

func (*StreamClient) Decrypt

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

Decrypt data

func (*StreamClient) Encrypt

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

Encrypt data

func (*StreamClient) HTTPHandle

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

HTTPHandle handle http request

func (*StreamClient) ListenAndServe

func (x *StreamClient) ListenAndServe() error

ListenAndServe will let client start a socks5 proxy sm can be nil

func (*StreamClient) ListenAndServeHTTP

func (x *StreamClient) ListenAndServeHTTP() error

ListenAndServeHTTP will let client start a http proxy m can be nil

func (*StreamClient) SetHTTPMiddleman

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

SetHTTPMiddleman sets httpmiddleman plugin

func (*StreamClient) SetSocks5Middleman

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

SetSocks5Middleman sets socks5middleman plugin

func (*StreamClient) Shutdown

func (x *StreamClient) Shutdown() error

Shutdown used to stop the client

func (*StreamClient) TCPHandle

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

TCPHandle handles tcp request

func (*StreamClient) UDPHandle

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

UDPHandle handles udp request

func (*StreamClient) WrapCipherConn

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

WrapChiperConn make a chiper conn

type StreamServer

type StreamServer struct {
	Password     []byte
	TCPAddr      *net.TCPAddr
	UDPAddr      *net.UDPAddr
	TCPListen    *net.TCPListener
	UDPConn      *net.UDPConn
	UDPExchanges *cache.Cache
	TCPDeadline  int // Not refreshed
	TCPTimeout   int
	UDPDeadline  int
}

StreamServer

func NewStreamServer

func NewStreamServer(addr, password string, tcpTimeout, tcpDeadline, udpDeadline int) (*StreamServer, error)

NewStreamServer

func (*StreamServer) Decrypt

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

Decrypt data

func (*StreamServer) Encrypt

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

Encrypt data

func (*StreamServer) ListenAndServe

func (s *StreamServer) ListenAndServe() error

Run server

func (*StreamServer) RunTCPServer

func (s *StreamServer) RunTCPServer() error

RunTCPServer starts tcp server

func (*StreamServer) RunUDPServer

func (s *StreamServer) RunUDPServer() error

RunUDPServer starts udp server

func (*StreamServer) Shutdown

func (s *StreamServer) Shutdown() error

Shutdown server

func (*StreamServer) TCPHandle

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

TCPHandle handle request

func (*StreamServer) UDPHandle

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

UDPHandle handle packet

func (*StreamServer) WrapCipherConn

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

WrapChiperConn make a chiper conn

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
	UDPExchanges  *cache.Cache
	TCPDeadline   int
	TCPTimeout    int
	UDPDeadline   int
}

Tproxy.

func NewTproxy

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

NewTproxy.

func (*Tproxy) ListenAndServe

func (s *Tproxy) ListenAndServe() error

Run server.

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 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
	UDPExchanges  *cache.Cache
	TCPDeadline   int
	TCPTimeout    int
	UDPDeadline   int
}

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 UDPExchange

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

type VPN

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

VPN.

func NewVPN

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

NewVPN.

func (*VPN) AddRoutes

func (v *VPN) AddRoutes() error

AddRoutes adds routes.

func (*VPN) DeleteRoutes

func (v *VPN) DeleteRoutes() error

DeleteRoutes deletes routes.

func (*VPN) ListenAndServe

func (v *VPN) ListenAndServe() error

ListenAndServe starts to run VPN.

func (*VPN) Shutdown

func (v *VPN) Shutdown() error

Shutdown stops VPN.

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{}
}

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) 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 WSServer

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

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) 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.

type WSUDPExchange

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

Directories

Path Synopsis
cli

Jump to

Keyboard shortcuts

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