brook

package module
v0.0.0-...-6db6248 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2022 License: GPL-3.0 Imports: 47 Imported by: 0

README

Creek

Brook is a cross-platform network tool designed for developers. Creek on the other hand is based on brook (fully compatible), but it offers more features. The aim is to provide a more user-friendly interface and a way to easily manage multiple Brook instances and clients.

Installation

At the moment I'm not providing any pre-built binaries (coming soon). You can however build the project yourself, it's pretty straightforward and fast.

First, you need to have the Go compiler installed. You can download it and install it easily on Windows, Linux and macOS, just follow the instructions on the official website.

Once you have Go installed, you can build the project as easily as running the following commands:

git clone https://github.com/Klaushayan/creek
cd creek/cli/creek
go build .

And a binary named creek will be created in the cli/creek directory.

Server

Both the server and the client work the same way they do in the original Brook. The only difference is that a few options have been added.

creek server -l :9999 -p hello

Client

Creek servers are completely compatible with Brook clients.

GUI Client

replace 1.2.3.4 with your server IP

  • brook server: 1.2.3.4:9999
  • password: hello

CLI Client

create socks5://127.0.0.1:1080

creek client -s 1.2.3.4:9999 -p hello

Roadmap

  • Limit the number of IP addresses that can connect to the server
  • Block IP addresses
  • Logging into a file
  • An API for managing the server
  • Session management to manage multiple instances of the server
  • Web panel for easier configuration, management and monitoring

Documentation

For more features, please check the Documentation.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Debug bool = false
View Source
var Dial1 x.Dialer1
View Source
var ServerPacket func([]byte, []byte) ([]byte, []byte, WriterFunc, error) = func(dst, b []byte) ([]byte, []byte, WriterFunc, error) {
	f := func(f func([]byte) (int, error)) io.Writer {
		return WriteFunc(f)
	}
	return dst, b, f, nil
}

Functions

func BlockAddress

func BlockAddress(address string, ds map[string]byte, c4, c6 []*net.IPNet, c *cache.Cache, geo []string) bool

func EnableDebug

func EnableDebug()

EnableDebug.

func ErrorReply

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

func GetAddressFromURL

func GetAddressFromURL(s string) (string, error)
func Link(kind, s, username, password string) string

func LinkExtra

func LinkExtra(kind, s, username, password string, v url.Values) string

func ListHasDomain

func ListHasDomain(ds map[string]byte, domain string, c *cache.Cache) bool

func ListHasIP

func ListHasIP(c4, c6 []*net.IPNet, i net.IP, c *cache.Cache, geo []string) bool

func NextNonce

func NextNonce(b []byte)
func ParseLink(link string) (kind, s, username, password string, err error)

func ParseLinkExtra

func ParseLinkExtra(link string) (kind, s, username, password string, v url.Values, err error)

func QR

func QR(kind, s, username, password string)

func ReadCIDRList

func ReadCIDRList(url string) ([]*net.IPNet, error)

func ReadData

func ReadData(url string) ([]byte, error)

func ReadDomainList

func ReadDomainList(url string) (map[string]byte, error)

func ReadList

func ReadList(url string) ([]string, error)

func Resolve4

func Resolve4(host string) (string, error)

func Resolve6

func Resolve6(host string) (string, error)

func Socks5Test

func Socks5Test(s, u, p, domain, a, ds string) error

func WaitReadErr

func WaitReadErr(conn net.Conn)

Types

type Client

type Client struct {
	Server        *socks5.Server
	ServerAddress string
	Password      []byte
	TCPTimeout    int
	UDPTimeout    int
	UDPOverTCP    bool
}

Client.

func NewClient

func NewClient(addr, ip, server, password string, tcpTimeout, udpTimeout int) (*Client, error)

NewClient returns a new Client.

func (*Client) ListenAndServe

func (x *Client) ListenAndServe() error

ListenAndServe will let client start a socks5 proxy.

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.

func (*Client) UDPOverTCPHandle

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

type CreekManager

type CreekManager struct {
	WSServers []WSServerJSON
	Relays    []RelayJSON
	Port      int
}

func (*CreekManager) AddRelay

func (cm *CreekManager) AddRelay(w http.ResponseWriter, r *http.Request)

func (*CreekManager) AddWSServer

func (cm *CreekManager) AddWSServer(w http.ResponseWriter, r *http.Request)

func (*CreekManager) NewCreekManager

func (cm *CreekManager) NewCreekManager(port int) (*CreekManager, error)

func (*CreekManager) NewMap

func (cm *CreekManager) NewMap(rj *RelayJSON) (*Map, error)

func (*CreekManager) NewWSServer

func (cm *CreekManager) NewWSServer(wsj *WSServerJSON) (*WSServer, error)

type DNS

type DNS struct {
	TCPAddr            *net.TCPAddr
	UDPAddr            *net.UDPAddr
	ServerTCPAddr      *net.TCPAddr
	ServerUDPAddr      *net.UDPAddr
	Password           []byte
	BypassDomains      map[string]byte
	DNSServer          string
	DNSServerForBypass string
	TCPListen          *net.TCPListener
	UDPConn            *net.UDPConn
	UDPExchanges       *cache.Cache
	TCPTimeout         int
	UDPTimeout         int
	RunnerGroup        *runnergroup.RunnerGroup
	UDPSrc             *cache.Cache
	WSClient           *WSClient
	BlockDomain        map[string]byte
	BypassCache        *cache.Cache
	BlockCache         *cache.Cache
	UDPOverTCP         bool
}

DNS.

func NewDNS

func NewDNS(addr, server, password, dnsServer, dnsServerForBypass, bypassList string, tcpTimeout, udpTimeout int, blockDomainList string) (*DNS, error)

NewDNS.

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 DNSServer

type DNSServer struct {
	TCPAddr           *net.TCPAddr
	UDPAddr           *net.UDPAddr
	DNS               string
	DisableIPv4Domain map[string]byte
	DisableIPv6Domain map[string]byte
	BlockDomain       map[string]byte
	BlockGeo          []string
	DisableIPv4Cache  *cache.Cache
	DisableIPv6Cache  *cache.Cache
	BlockCache        *cache.Cache
	TCPListen         *net.TCPListener
	UDPConn           *net.UDPConn
	UDPExchanges      *cache.Cache
	UDPSrc            *cache.Cache
	TCPTimeout        int
	UDPTimeout        int
	RunnerGroup       *runnergroup.RunnerGroup
}

func NewDNSServer

func NewDNSServer(addr, dns, disableIPv4DomainList, disableIPv6DomainList, blockDomainList string, blockGeo []string, tcpTimeout, udpTimeout int) (*DNSServer, error)

NewDNS.

func (*DNSServer) ListenAndServe

func (s *DNSServer) ListenAndServe() error

Run server.

func (*DNSServer) RunTCPServer

func (s *DNSServer) RunTCPServer() error

RunTCPServer starts tcp server.

func (*DNSServer) RunUDPServer

func (s *DNSServer) RunUDPServer() error

RunUDPServer starts udp server.

func (*DNSServer) Shutdown

func (s *DNSServer) Shutdown() error

Shutdown server.

func (*DNSServer) TCPHandle

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

TCPHandle handles request.

func (*DNSServer) UDPHandle

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

UDPHandle handles packet.

type Exchanger

type Exchanger interface {
	Exchange(remote net.Conn) error
	NetworkName() string
	Clean()
	SetTimeout(int)
}

func MakeStreamServer

func MakeStreamServer(password []byte, c net.Conn, timeout int, withoutbrook bool) (Exchanger, []byte, error)

type Firewall

type Firewall struct {
	MaxConnections     int
	BlockPeriod        int64
	ConnectionCooldown int64
	// contains filtered or unexported fields
}

func NewFirewall

func NewFirewall(maxConnections, blockPeriod, connectionCooldown int) *Firewall

func (*Firewall) Block

func (f *Firewall) Block(ip ...IP)

func (*Firewall) BlockIPList

func (f *Firewall) BlockIPList(w http.ResponseWriter, r *http.Request)

func (*Firewall) ChangeConfig

func (f *Firewall) ChangeConfig(w http.ResponseWriter, r *http.Request)

func (*Firewall) IsBlocked

func (f *Firewall) IsBlocked(ip string) bool

func (*Firewall) IsConnected

func (f *Firewall) IsConnected(ip string) bool

func (*Firewall) ServeBlockedIPs

func (f *Firewall) ServeBlockedIPs(w http.ResponseWriter, r *http.Request)

func (*Firewall) ServeConfig

func (f *Firewall) ServeConfig(w http.ResponseWriter, r *http.Request)

func (*Firewall) ServeConnectedIPs

func (f *Firewall) ServeConnectedIPs(w http.ResponseWriter, r *http.Request)

func (*Firewall) Unblock

func (f *Firewall) Unblock(ip string)

func (*Firewall) Verify

func (f *Firewall) Verify(ip string) bool

type IP

type IP struct {
	Address         string `json:"address"`
	New             bool   `json:"new"`
	FirstConnection int64  `json:"first_connection"`
	LastConnection  int64  `json:"last_connection"`
}

func NewIP

func NewIP(s string) IP

func (IP) String

func (ip IP) String() string

type IPList

type IPList []IP

func (IPList) String

func (ips IPList) String() string

type Job

type Job struct {
	JobChan  chan func()
	PingChan chan string
	Quit     chan struct{}
	Started  bool
	// contains filtered or unexported fields
}

func NewJob

func NewJob(job func()) *Job

func NewJobWithArgument

func NewJobWithArgument(job func(...any)) *Job

func (*Job) Start

func (j *Job) Start() error

Uses a string channel to get pinged and executes the job function given in the constructor

func (*Job) StartWithArgument

func (j *Job) StartWithArgument() error

Uses a string channel to get strings and executes the job function given in the constructor with the string value in the channel

func (*Job) StartWithChannel

func (j *Job) StartWithChannel() error

Uses a func channel as the job channel and does not use the job function given in the constructor

func (*Job) StartWithTicker

func (j *Job) StartWithTicker(interval time.Duration) error

Uses a ticker as the job channel based on the interval

func (*Job) Stop

func (j *Job) Stop() error

This stops all jobs

type Map

type Map struct {
	TCPAddr       *net.TCPAddr
	UDPAddr       *net.UDPAddr
	RemoteAddress string
	ServerTCPAddr *net.TCPAddr
	ServerUDPAddr *net.UDPAddr
	Password      []byte
	TCPListen     *net.TCPListener
	UDPConn       *net.UDPConn
	UDPExchanges  *cache.Cache
	TCPTimeout    int
	UDPTimeout    int
	RunnerGroup   *runnergroup.RunnerGroup
	UDPSrc        *cache.Cache
	WSClient      *WSClient
	UDPOverTCP    bool
}

Map.

func NewMap

func NewMap(from, to, remote, password string, tcpTimeout, udpTimeout int) (*Map, error)

NewMap.

func (*Map) ListenAndServe

func (s *Map) ListenAndServe() error

Run server.

func (*Map) RunTCPServer

func (s *Map) RunTCPServer() error

RunTCPServer starts tcp server.

func (*Map) RunUDPServer

func (s *Map) RunUDPServer() error

RunUDPServer starts udp server.

func (*Map) Shutdown

func (s *Map) Shutdown() error

Shutdown server.

func (*Map) TCPHandle

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

TCPHandle handles request.

func (*Map) UDPHandle

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

UDPHandle handles packet.

type PAC

type PAC struct {
	Addr       string
	File       string
	Proxy      string
	DomainURL  string
	DomainData []byte
	HTTPServer *http.Server
	Body       []byte
}

func NewPAC

func NewPAC(addr, file, proxy, domainURL 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 PacketClient

type PacketClient struct {
	Server        net.Conn
	Password      []byte
	RB            []byte
	WB            []byte
	Dst           []byte
	Timeout       int
	RemoteAddress net.Addr
}

func NewPacketClient

func NewPacketClient(password []byte) *PacketClient

func (*PacketClient) Clean

func (c *PacketClient) Clean()

func (*PacketClient) LocalToServer

func (c *PacketClient) LocalToServer(dst, d []byte, server net.Conn, timeout int) error

func (*PacketClient) RunServerToLocal

func (c *PacketClient) RunServerToLocal(server net.Conn, timeout int, tolocal func(dst, d []byte) (int, error)) error

func (*PacketClient) ServerToLocal

func (c *PacketClient) ServerToLocal(server net.Conn, timeout int, tolocal func(dst, d []byte) (int, error)) error

type PacketServer

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

func NewPacketServer

func NewPacketServer(password []byte) *PacketServer

func (*PacketServer) Clean

func (s *PacketServer) Clean()

func (*PacketServer) RemoteToClient

func (s *PacketServer) RemoteToClient(remote net.Conn, timeout int, dst []byte, toclient io.Writer) error

type PacketStream

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

func NewPacketStream

func NewPacketStream(w func(d []byte) (int, error)) (*PacketStream, func(b []byte) error)

func (*PacketStream) Close

func (c *PacketStream) Close() error

func (*PacketStream) LocalAddr

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

func (*PacketStream) Read

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

func (*PacketStream) RemoteAddr

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

func (*PacketStream) SetDeadline

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

func (*PacketStream) SetReadDeadline

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

func (*PacketStream) SetWriteDeadline

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

func (*PacketStream) Write

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

type Relay

type Relay struct {
	TCPAddr      *net.TCPAddr
	UDPAddr      *net.UDPAddr
	Remote       string
	TCPListen    *net.TCPListener
	UDPConn      *net.UDPConn
	UDPExchanges *cache.Cache
	TCPTimeout   int
	UDPTimeout   int
	RunnerGroup  *runnergroup.RunnerGroup
	UDPSrc       *cache.Cache
}

Relay is relay server.

func NewRelay

func NewRelay(addr, remote string, tcpTimeout, udpTimeout 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.Conn) error

TCPHandle handles request.

func (*Relay) UDPHandle

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

UDPHandle handles packet.

type RelayJSON

type RelayJSON struct {
	Server     string `json:"server"`
	From       string `json:"from"`
	To         string `json:"to"`
	Remote     string `json:"remote"`
	Password   string `json:"password"`
	TCPTimeout int    `json:"tcp_timeout"`
	UDPTimeout int    `json:"udp_timeout"`
	Object     *Map
}

type Server

type Server struct {
	Password     []byte
	TCPAddr      *net.TCPAddr
	UDPAddr      *net.UDPAddr
	TCPListen    *net.TCPListener
	UDPConn      *net.UDPConn
	UDPExchanges *cache.Cache
	TCPTimeout   int
	UDPTimeout   int
	RunnerGroup  *runnergroup.RunnerGroup
	UDPSrc       *cache.Cache
	BlockDomain  map[string]byte
	BlockCIDR4   []*net.IPNet
	BlockCIDR6   []*net.IPNet
	BlockGeoIP   []string
	BlockCache   *cache.Cache
	BlockLock    *sync.RWMutex
	Done         chan byte
	Dial         func(network, laddr, raddr string) (net.Conn, error)
}

Server.

func NewServer

func NewServer(addr, password string, tcpTimeout, udpTimeout int, blockDomainList, blockCIDR4List, blockCIDR6List string, updateListInterval int64, blockGeoIP []string) (*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(ss Exchanger, dst []byte) error

TCPHandle handles request.

func (*Server) UDPHandle

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

UDPHandle handles packet.

func (*Server) UDPOverTCPHandle

func (s *Server) UDPOverTCPHandle(ss Exchanger, src string, dstb []byte) error

type SimpleStreamClient

type SimpleStreamClient struct {
	Server  net.Conn
	Timeout int
	Network string
	RB      []byte
	WB      []byte
}

func NewSimpleStreamClient

func NewSimpleStreamClient(network string, password, dst []byte, server net.Conn, timeout int) (*SimpleStreamClient, error)

func (*SimpleStreamClient) Clean

func (s *SimpleStreamClient) Clean()

func (*SimpleStreamClient) Exchange

func (c *SimpleStreamClient) Exchange(local net.Conn) error

func (*SimpleStreamClient) NetworkName

func (s *SimpleStreamClient) NetworkName() string

func (*SimpleStreamClient) SetTimeout

func (s *SimpleStreamClient) SetTimeout(i int)

type SimpleStreamServer

type SimpleStreamServer struct {
	Client  net.Conn
	Timeout int
	Network string
	RB      []byte
	WB      []byte
}

func NewSimpleStreamServer

func NewSimpleStreamServer(password []byte, client net.Conn, timeout int) (*SimpleStreamServer, []byte, error)

func (*SimpleStreamServer) Clean

func (s *SimpleStreamServer) Clean()

func (*SimpleStreamServer) Exchange

func (s *SimpleStreamServer) Exchange(remote net.Conn) error

func (*SimpleStreamServer) NetworkName

func (s *SimpleStreamServer) NetworkName() string

func (*SimpleStreamServer) SetTimeout

func (s *SimpleStreamServer) SetTimeout(i int)

type Socks5Dial1

type Socks5Dial1 struct {
	Client *socks5.Client
}

func NewSocks5Dial1

func NewSocks5Dial1(server, username, password string, tcpTimeout, udpTimeout int) (*Socks5Dial1, error)

func (*Socks5Dial1) Dial

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

func (*Socks5Dial1) DialTCP

func (d *Socks5Dial1) DialTCP(network string, laddr, raddr *net.TCPAddr) (net.Conn, error)

func (*Socks5Dial1) DialUDP

func (d *Socks5Dial1) DialUDP(network string, laddr, raddr *net.UDPAddr) (net.Conn, error)

type Socks5Server

type Socks5Server struct {
	Server *socks5.Server
}

Socks5Server is raw socks5 server.

func NewSocks5Server

func NewSocks5Server(addr, ip, userName, password string, tcpTimeout, udpTimeout int) (*Socks5Server, error)

NewSocks5Server returns a new Socks5Server.

func (*Socks5Server) ListenAndServe

func (x *Socks5Server) ListenAndServe() error

ListenAndServe will let client start to listen and serve.

func (*Socks5Server) Shutdown

func (x *Socks5Server) Shutdown() error

Shutdown used to stop the client.

type Socks5ToHTTP

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

func NewSocks5ToHTTP

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

func (*Socks5ToHTTP) Handle

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

func (*Socks5ToHTTP) ListenAndServe

func (s *Socks5ToHTTP) ListenAndServe() error

func (*Socks5ToHTTP) Shutdown

func (s *Socks5ToHTTP) Shutdown() error

type StreamClient

type StreamClient struct {
	Server net.Conn

	RB            []byte
	WB            []byte
	Timeout       int
	Network       string
	RemoteAddress net.Addr
	Cache         []byte
	// contains filtered or unexported fields
}

func NewStreamClient

func NewStreamClient(network string, password, dst []byte, server net.Conn, timeout int) (*StreamClient, error)

func (*StreamClient) Clean

func (c *StreamClient) Clean()

func (*StreamClient) Exchange

func (c *StreamClient) Exchange(local net.Conn) error

func (*StreamClient) NetworkName

func (s *StreamClient) NetworkName() string

func (*StreamClient) ReadL

func (c *StreamClient) ReadL() (int, error)

func (*StreamClient) SetTimeout

func (s *StreamClient) SetTimeout(i int)

func (*StreamClient) WriteL

func (c *StreamClient) WriteL(l int) error

type StreamServer

type StreamServer struct {
	Client net.Conn

	RB      []byte
	WB      []byte
	Timeout int
	Network string
	// contains filtered or unexported fields
}

func NewStreamServer

func NewStreamServer(password []byte, client net.Conn, timeout int) (*StreamServer, []byte, error)

func (*StreamServer) Clean

func (s *StreamServer) Clean()

func (*StreamServer) Exchange

func (s *StreamServer) Exchange(remote net.Conn) error

func (*StreamServer) NetworkName

func (s *StreamServer) NetworkName() string

func (*StreamServer) Read

func (s *StreamServer) Read() (int, error)

func (*StreamServer) SetTimeout

func (s *StreamServer) SetTimeout(i int)

func (*StreamServer) Write

func (s *StreamServer) Write(l int) error

type Tproxy

type Tproxy struct {
	TCPAddr       *net.TCPAddr
	UDPAddr       *net.UDPAddr
	ServerTCPAddr *net.TCPAddr
	ServerUDPAddr *net.UDPAddr
	Password      []byte
	TCPListen     *net.TCPListener
	UDPConn       *net.UDPConn
	UDPExchanges  *cache.Cache
	UDPSrc        *cache.Cache
	TCPTimeout    int
	UDPTimeout    int
	RunnerGroup   *runnergroup.RunnerGroup
	EnableIPv6    bool
	Cidr4         []*net.IPNet
	Cidr6         []*net.IPNet
	BypassCache   *cache.Cache
	WSClient      *WSClient
	UDPOverTCP    bool
}

Tproxy.

func NewTproxy

func NewTproxy(addr, s, password string, enableIPv6 bool, cidr4url, cidr6url string, tcpTimeout, udpTimeout int, address string, insecure, withoutbrook bool, roots *x509.CertPool, udpovertcp bool) (*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 UDPExchange

type UDPExchange struct {
	Conn net.Conn
	Any  interface{}
	Dst  []byte
}

type WSClient

type WSClient struct {
	Server         *socks5.Server
	ServerHost     string
	ServerAddress  string
	TLSConfig      *tls.Config
	Password       []byte
	TCPTimeout     int
	UDPTimeout     int
	TCPListen      *net.TCPListener
	Path           string
	UDPExchanges   *cache.Cache
	WithoutBrook   bool
	PasswordSha256 []byte
}

WSClient.

func NewWSClient

func NewWSClient(addr, ip, server, password string, tcpTimeout, udpTimeout int) (*WSClient, error)

NewWSClient.

func (*WSClient) DialWebsocket

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

func (*WSClient) ListenAndServe

func (x *WSClient) ListenAndServe() error

ListenAndServe will let client start a socks5 proxy.

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
	Firewall       *Firewall
	TCPTimeout     int
	UDPTimeout     int
	Path           string
	UDPSrc         *cache.Cache
	BlockDomain    map[string]byte
	BlockCIDR4     []*net.IPNet
	BlockCIDR6     []*net.IPNet
	BlockGeoIP     []string
	BlockCache     *cache.Cache
	BlockLock      *sync.RWMutex
	Done           chan byte
	WSSServerPort  int64
	Cert           []byte
	CertKey        []byte
	WithoutBrook   bool
	PasswordSha256 []byte
	Dial           func(network, laddr, raddr string) (net.Conn, error)
}

WSServer.

func NewWSServer

func NewWSServer(addr, password, domain, path string, tcpTimeout, udpTimeout int, blockDomainList, blockCIDR4List, blockCIDR6List string, updateListInterval int64, blockGeoIP []string, maxClients int, connectionCooldown int, blockTimeout 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(ss Exchanger, dst []byte) error

TCPHandle handles request.

func (*WSServer) UDPHandle

func (s *WSServer) UDPHandle(ss Exchanger, src string, dstb []byte) error

UDPHandle handles packet.

type WSServerJSON

type WSServerJSON struct {
	Addr               string   `json:"addr"`
	Password           string   `json:"password"`
	Domain             string   `json:"domain"`
	Path               string   `json:"path"`
	TCPTimeout         int      `json:"tcp_timeout"`
	UDPTimeout         int      `json:"udp_timeout"`
	BlockDomainList    string   `json:"block_domain_list"`
	BlockCIDR4List     string   `json:"block_cidr4_list"`
	BlockCIDR6List     string   `json:"block_cidr6_list"`
	UpdateListInterval int64    `json:"update_list_interval"`
	BlockGeoIP         []string `json:"block_geoip"`
	MaxClients         int      `json:"max_clients"`
	ConnectionCooldown int      `json:"connection_cooldown"`
	BlockTimeout       int      `json:"block_timeout"`
	Object             *WSServer
}

type WriteFunc

type WriteFunc func([]byte) (int, error)

func (WriteFunc) Write

func (f WriteFunc) Write(b []byte) (int, error)

type WriterFunc

type WriterFunc func(func([]byte) (int, error)) io.Writer

func PacketClientToRemote

func PacketClientToRemote(p, b []byte) ([]byte, []byte, WriterFunc, error)

Directories

Path Synopsis
cli

Jump to

Keyboard shortcuts

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