brook

package module
v0.0.0-...-6436a23 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2017 License: GPL-3.0 Imports: 19 Imported by: 0

README

Brook

Build Status Go Report Card Wiki

Brook

Table of Content

What is Brook

Brook is a cross-platform(Linux/MacOS/Windows/Android/iOS) proxy/vpn software.
Brook's goal is to reduce the configuration steps. Keep it simple, stupid.

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_macos_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.app.zip Client MacOS amd64 GUI
Brook.exe Client Windows amd64 GUI
Brook.386.exe Client Windows 386 GUI
App Store Client iOS - GUI
Google Play / Brook.apk Client Android - GUI

MacOS GUI Client

  • Need MacOS version >= 10.12
  • If MacOS prompts it is from an unidentified developer, then go System Preferences -> Security & Privacy, click Open Anyway
  • You may prefer to copy Brook.app to Application folder
  • Follow this pac white list auto proxy rule

Windows GUI Client

  • Need Windows version >= 7
  • Please set chrome as your default browser
  • You may need to run as an administrator
  • Follow this pac white list auto proxy rule

Android Client

  • Need Android version >= 5.0
  • Follow this pac white list auto proxy rule
  • Not tested on IPv6

iOS Client

Server

NAME:
   Brook - A Cross-Platform Proxy Software

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

VERSION:
   20170909

AUTHOR:
   Cloud <cloud@txthinking.com>

COMMANDS:
     server        Run as server mode
     servers       Run as multiple servers mode
     client        Run as client mode
     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
     relay         Run as relay mode
     relays        Run as multiple relays mode
     qr            Print brook server QR code
     socks5        Run as raw socks5 server
     socks5tohttp  Convert socks5 to http proxy
     help, h       Shows a list of commands or help for one command

GLOBAL OPTIONS:
   --debug, -d               Enable debug, more logs
   --listen value, -l value  Listen address for debug (default: ":6060")
   --help, -h                show help
   --version, -v             print the version
Brook Server
# Run as a brook server
$ brook bkserver -l :9999 -p password -t 10
# Run as a brook server with music
$ brook bkserver -l :9999 -p password -t 10 -m music_name
# Run as multiple brook servers
$ brook bkservers \
        -l ":9999 password" \
        -l ":8888 password" \
        -l ":7777 password music_name" \
        -l ":6666 password music_name" \
        -t 10

More about Brook Music

If you run a public/shared server, do not forget this parameter --deadline 60 or -d 60

Shadowsocks Server
# Run as a shadowsocks server
$ brook ssserver -l :9999 -p password -t 10
# Run as multiple shadowsocks servers
$ brook ssservers \
        -l ":9999 password" \
        -l ":8888 password" \
        -t 10

Fixed method is aes-256-cfb

If you run a public/shared server, do not forget this parameter --deadline 60 or -d 60

Run as Daemon

With nohup

# Start
$ nohup brook bkserver -l :9999 -p password -t 10 &

# Stop
$ killall brook

With systemd

If your linux run with systemd, like Ubuntu 16.04, Archlinux, etc:

# Install
$ curl -L git.io/getbrook | sudo bash
$ sudo systemctl daemon-reload

# Config command options
$ sudo vim /etc/default/brook

# Start
$ sudo systemctl start brook.service

# Stop
$ sudo systemctl stop brook.service

# Start on bootup
$ sudo systemctl enable brook.service
Relay Server

What is Relay Server

client <---> relay server <---> server

Relay Server

# Run as a relay server
$ brook relay -l :9999 -s server_address:port -t 10
# Run as multiple relay servers
$ brook relays \
        -l ":9999 server1_address:port" \
        -l ":8888 server2_address:port" \
        -t 10

Client (CLI)

Brook Client
# Run as brook client, start a socks5 proxy
$ brook bkclient -l 127.0.0.1:1080 -s server_address:port -p password
# Run as brook client, start a http(s) proxy
$ brook bkclient -l 127.0.0.1:8080 -s server_address:port -p password --http
# Run as brook client with music, music must be same as server's
$ brook bkclient -l 127.0.0.1:1080 -s server_address:port -p password -m muisc_name
Shadowsocks Client
# Run as shadowsocks client, start a socks5 proxy
$ brook ssclient -l 127.0.0.1:1080 -s server_address:port -p password
# Run as shadowsocks client, start a http(s) proxy
$ brook ssclient -l 127.0.0.1:8080 -s server_address:port -p password --http

Developer

$ go get github.com/txthinking/brook/cli/brook
$ brook -h
Contributing
  • Please create PR on develop branch

License

Licensed under The GPLv3 License

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnableDebug

func EnableDebug()

EnableDebug will print more logs

func GetAddressFromURL

func GetAddressFromURL(s string) (string, error)

func HasPort

func HasPort(host string) bool

func MakeSSKey

func MakeSSKey(password string) []byte

MakeSSKey used to make shadowsocks aes-256-cfb key

func QR

func QR(server, password, music string)

QR generate and print QR code

func RunBKClient

func RunBKClient(address, server, password string, timeout, deadline int, m string) error

RunBKClient used to make a new BKClient and start a socks5 proxy to listen

func RunBKHTTPClient

func RunBKHTTPClient(address, server, password string, timeout, deadline int, m string) error

RunBKHTTPClient used to make a new BKClient and start a http proxy to listen

func RunBKServer

func RunBKServer(address, password string, timeout, deadline int, m string) error

RunBKServer used to make a new BKServer and start to listen

func RunRelay

func RunRelay(address, server string, timeout, deadline int) error

RunRelay used to make a new Relay and start to listen

func RunS5Client

func RunS5Client(address, server, password string, timeout, deadline int) error

RunS5Client used to make a new S5Client and start a socks5 proxy to listen

func RunS5Server

func RunS5Server(address, password string, timeout, deadline int) error

RunS5Server used to make a new S5Server and start to listen

func RunSSClient

func RunSSClient(address, server, password string, timeout, deadline int) error

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

func RunSSHTTPClient

func RunSSHTTPClient(address, server, password string, timeout, deadline int) error

RunSSHTTPClient used to make a new SSClient and start a http proxy to listen

func RunSSServer

func RunSSServer(address, password string, timeout, deadline int) error

RunSSServer used to make a new SSServer and start to listen

func RunSocks5Server

func RunSocks5Server(address, username, password string, timeout, deadline 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

Types

type BKClient

type BKClient struct {
	Address         string
	Password        string
	Server          string
	Timeout         int
	Deadline        int
	Music           music.Music
	Dial            Dialer
	Listen          net.Listener
	HTTPMiddleman   HTTPMiddleman
	Socks5Middleman Socks5Middleman
}

BKClient is the client of brook protocol

func NewBKClient

func NewBKClient(address, server, password string, timeout, deadline int, m string, dial Dialer) (*BKClient, error)

NewBKClient returns a new BKClient, dial can be set to nil

func (*BKClient) ListenAndServe

func (c *BKClient) ListenAndServe(sm Socks5Middleman) error

ListenAndServe will let client start to listen and serve, sm can be nil

func (*BKClient) ListenAndServeHTTP

func (c *BKClient) ListenAndServeHTTP(h HTTPMiddleman) error

ListenAndServeHTTP will let client start a http(s) proxy to listen and serve. For just a http proxy server, so httpmiddleman can be nil

func (*BKClient) Shutdown

func (c *BKClient) Shutdown() error

Shutdown used to stop the client

type BKServer

type BKServer struct {
	Address  string
	Password string
	Timeout  int
	Deadline int
	Music    music.Music
	Listen   net.Listener
}

BKServer is the server of brook protocol

func NewBKServer

func NewBKServer(address, password string, timeout, deadline int, m string) (*BKServer, error)

NewBKServer returns a new BKServer

func (*BKServer) ListenAndServe

func (s *BKServer) ListenAndServe() error

ListenAndServe will let server start to listen and serve

func (*BKServer) Shutdown

func (s *BKServer) Shutdown() error

Shutdown used to stop the server

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 DefaultDial

type DefaultDial struct {
}

DefaultDial is the default dialer which dial with tcp network

func (*DefaultDial) Dial

func (d *DefaultDial) Dial(network, addr string) (net.Conn, error)

Dial a remote address

type Dialer

type Dialer interface {
	Dial(network, addr string) (net.Conn, error)
}

Dialer is a common interface for dialing

type HTTPMiddleman

type HTTPMiddleman interface {
	// HandleHTTPProxy does not need to close conn,
	// Addr is the absoluteURI, RFC 2396
	// if handled is true or err is not nil that means the request has been handled
	HandleHTTPProxy(method, addr string, request []byte, conn *net.TCPConn) (handled bool, err error)
}

HTTPMiddleman is a middleman who can intercept and handle request

type Relay

type Relay struct {
	Address  string
	Server   string
	Timeout  int
	Deadline int
	Listen   net.Listener
}

Relay is a relay for two network

func NewRelay

func NewRelay(address, server string, timeout, deadline int) *Relay

NewRelay returns a new Relay

func (*Relay) ListenAndServe

func (r *Relay) ListenAndServe() error

ListenAndServe will let relay start to listen and serve

func (*Relay) Shutdown

func (r *Relay) Shutdown() error

Shutdown used to stop the relay

type S5Client

type S5Client struct {
	Address  string
	Password string
	Server   string
	Timeout  int
	Deadline int
	Dial     Dialer
	Listen   net.Listener
}

S5Client is the client of socks5 encrypt protocol

func NewS5Client

func NewS5Client(address, server, password string, timeout, deadline int, dial Dialer) *S5Client

NewS5Client returns a new S5Client

func (*S5Client) ListenAndServe

func (c *S5Client) ListenAndServe() error

ListenAndServe will let client start to listen and serve

func (*S5Client) Shutdown

func (c *S5Client) Shutdown() error

Shutdown used to stop the client

type S5Server

type S5Server struct {
	Address  string
	Password string
	Timeout  int
	Deadline int
	Listen   net.Listener
}

S5Server is the server of socks5 encrypt protocol

func NewS5Server

func NewS5Server(address, password string, timeout, deadline int) *S5Server

NewS5Server returns a new S5Server

func (*S5Server) ListenAndServe

func (s *S5Server) ListenAndServe() error

ListenAndServe will let server start to listen and serve

func (*S5Server) Shutdown

func (s *S5Server) Shutdown() error

Shutdown used to stop the server

type SSClient

type SSClient struct {
	Address         string
	Password        string
	Server          string
	Timeout         int
	Deadline        int
	Dial            Dialer
	Listen          net.Listener
	HTTPMiddleman   HTTPMiddleman
	Socks5Middleman Socks5Middleman
}

SSClient is the client of shadowsocks protocol

func NewSSClient

func NewSSClient(address, server, password string, timeout, deadline int, dial Dialer) *SSClient

NewSSClient returns a new SSClient

func (*SSClient) ListenAndServe

func (c *SSClient) ListenAndServe(sm Socks5Middleman) error

ListenAndServe will let client start to listen and serve

func (*SSClient) ListenAndServeHTTP

func (c *SSClient) ListenAndServeHTTP(h HTTPMiddleman) error

ListenAndServeHTTP will let client start a http(s) proxy to listen and serve. For just a http proxy server, so httpmiddleman can be nil

func (*SSClient) Shutdown

func (c *SSClient) Shutdown() error

Shutdown used to stop the client

type SSServer

type SSServer struct {
	Address  string
	Password string
	Timeout  int
	Deadline int
	Listen   net.Listener
}

SSServer is the server of shadowsocks protocol

func NewSSServer

func NewSSServer(address, password string, timeout, deadline int) *SSServer

NewSSServer returns a new SSServer

func (*SSServer) ListenAndServe

func (s *SSServer) ListenAndServe() error

ListenAndServe will let server start to listen and serve

func (*SSServer) Shutdown

func (s *SSServer) Shutdown() error

Shutdown used to stop the server

type Socks5Middleman

type Socks5Middleman interface {
	// HandleSocks5Proxy does not need to close conn,
	// if handled is true or err is not nil that means the request has been handled
	HandleSocks5Proxy(request *socks5.Request, conn *net.TCPConn) (handled bool, err error)
}

Socks5Middleman is a middleman who can intercept and handle request

type Socks5Server

type Socks5Server struct {
	Address         string
	UserName        string
	Password        string
	Timeout         int
	Deadline        int
	Dial            Dialer
	Listen          net.Listener
	Socks5Middleman Socks5Middleman
}

Socks5Server is the client of raw socks5 protocol

func NewSocks5Server

func NewSocks5Server(address, userName, password string, timeout, deadline int, dial Dialer) *Socks5Server

NewSocks5Server returns a new Socks5Server, dial can be set to nil

func (*Socks5Server) ListenAndForward

func (c *Socks5Server) ListenAndForward(sm Socks5Middleman, addr string) error

ListenAndForward will let client start a no auth socks5 proxy to listen and forward to another socks5, c.UserName, c.Password will effect the forwarded socks5, sm can be nil

func (*Socks5Server) ListenAndServe

func (c *Socks5Server) ListenAndServe(sm Socks5Middleman) error

ListenAndServe will let client start to listen and serve, sm can be nil

func (*Socks5Server) Shutdown

func (c *Socks5Server) Shutdown() error

Shutdown used to stop the client

type Socks5ToHTTP

type Socks5ToHTTP struct {
	Address       string
	Socks5Address string
	Dial          proxy.Dialer
	Timeout       int
	Deadline      int
	Listen        net.Listener
	HTTPMiddleman HTTPMiddleman
}

func NewSocks5ToHTTP

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

func (*Socks5ToHTTP) ListenAndServe

func (s *Socks5ToHTTP) ListenAndServe(h HTTPMiddleman) error

func (*Socks5ToHTTP) Shutdown

func (s *Socks5ToHTTP) Shutdown() error

type WhiteHTTPMiddleman

type WhiteHTTPMiddleman struct {
	Timeout  int
	Deadline int
}

WhiteHTTPMiddleman is a HTTPMiddleman who only handle domain in white list

func NewWhiteHTTPMiddleman

func NewWhiteHTTPMiddleman(timeout, deadline int) *WhiteHTTPMiddleman

NewWhiteHTTPMiddleman returns a WhiteHTTPMiddleman which can used to handle http proxy request

func (*WhiteHTTPMiddleman) HandleHTTPProxy

func (w *WhiteHTTPMiddleman) HandleHTTPProxy(method, addr string, request []byte, conn *net.TCPConn) (handled bool, err error)

HandleHTTPProxy handle http proxy request, if the domain is in the white list

type WhiteSocks5Middleman

type WhiteSocks5Middleman struct {
	Timeout  int
	Deadline int
	Dial     Dialer
}

WhiteSocks5Middleman is a Socks5Middleman who only handle domain in white list

func NewWhiteSocks5Middleman

func NewWhiteSocks5Middleman(timeout, deadline int, dial Dialer) *WhiteSocks5Middleman

NewWhiteSocks5Middleman returns a WhiteSocks5Middleman which can used to handle http proxy request

func (*WhiteSocks5Middleman) HandleSocks5Proxy

func (w *WhiteSocks5Middleman) HandleSocks5Proxy(request *socks5.Request, c *net.TCPConn) (handled bool, err error)

HandleSocks5Proxy handle http proxy request, if the domain is in the white list

Directories

Path Synopsis
cli

Jump to

Keyboard shortcuts

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