shuttle

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

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

Go to latest
Published: Dec 12, 2018 License: Apache-2.0 Imports: 36 Imported by: 0

README

Shuttle

Shuttle is a cross-platform network proxy tool based on Go. Feel free to join our Slack or Telegram. (logo created by @不二

Shuttle

(Translated by wao1201, reviewed by Joe Hill.)

Introduction

Shuttle is a cross-platform network proxy tool based on Go.

  • SOCKS5SOCKS5 over TLSshadowsocks protocols supported.
  • Proxying via rules: domain, IP CIDR and GEO-IP.
  • Customized policy: direct, reject and proxy.
  • Multiple proxy servers selection and grouping management. The policy of servers selection can be RTT(Round-trip time) or manual select.
  • HTTP/HTTPS traffic capture, reverse proxy, request head modification, response head modification and fake return value supported.
  • DNS parsing types: static, direct, remote.

Module Structure:

shuttle_architecture

Screenshots:

Introduction

Features

  • Proxy type
    • TCP(HTTP/HTTPS)
    • UDP
  • HTTP/HTTPS request extension
    • Traffic capture (MITM supported)
    • URL rewrite
    • Request/response modification
    • Request mapping
  • Remote servers management
    • Server grouping
    • Protocols supported
      • shadowsocks
      • SOCKS5
      • SOCKS5 over TLS
    • Grouping server selection policy
      • RTT
      • Manual select
  • Outbound Mode
    • Global, direct and reject
    • Rules
      • DOMAIN: full name match
      • DOMAIN-SUFFIX: suffix match
      • DOMAIN-KEYWORD: keyword match
      • IP-CIDR: IP range match
      • GEO-IP: GEO-IP route supported
  • DNS parsing type
    • static:static address mapping
    • direct:local DNS resolve
    • remote:remote server DNS resolve (prevent DNS Cache Poisoning)
  • External module
    • API ( see API document for details)
    • Web UI
      • Web UI (angular6 + ant design)

Installation & Launch

macOS
Preparation

Download the zip file from release and unzip it. The Folder structure is shown below.

shuttle
   ├── RespFiles/ #mock file directory
   ├── shuttle  #shuttle main executable
   ├── shuttle.yaml #config file
   └── start.sh #launch script

Open the config file, shuttle.yaml. Make sure all the ports are all configured correctly before launching. The default ports in config file are 8080, 8081 and 8082.

General:
  http-port: "8080"  #http/https port
  socks-port: "8081" #socks port
  controller-port: "8082" #dashboard port
Launch

Go to the shuttle directory and enter the command below in terminal/CMD to launch the app.

./start.sh #no output

Open your browser and visit http://localhost:8082 (For example, use the default settings controller-port: "8082"). The application has already run successfully if you can visit the dashboard on your browser. Otherwise check the shuttle.log for more details and new issues anytime.

System Configuration

If you can visit http://c.sipt.top on your browser, you can skip the following steps directly.

Open System Preference => Network => Advanced => Proxy,there are 3 main options:

  • Web Proxy(HTTP) set to 127.0.0.1:8080 (for example, http-port: "8080")
  • Web Proxy(HTTPS) set to 127.0.0.1:8080(for example, http-port: "8080"
  • SOCKS Proxy set to 127.0.0.1:8080(for example, socks-port: "8081"

Press OK and click Apply. The proxy settings are working if you can see the dashboard by visiting http://c.sipt.top on browser.

Enter the following commands to make Terminal.app go through proxies:

export https_proxy="http://127.0.0.1:8080"
export http_proxy="http://127.0.0.1:8080"
export all_proxy="socks5://127.0.0.1:8081"
Windows
Preparation

Download the zip file from release and unzip it. The Folder structure is shown below.

shuttle
   ├── RespFiles/ #mock file directory
   ├── shuttle  #shuttle main executable
   ├── shuttle.yaml #config file
   └── startup.bat #launch script

Open the config file, shuttle.yaml. Make sure all the ports are all configured correctly before launching. The default ports in config file are 8080, 8081 and 8082.

General:
  http-port: "8080"  #http/https port
  socks-port: "8081" #socks port
  controller-port: "8082" #dashboard port
Launch

Double-click startup.bat, there will be no output on screen. Open your browser and visit http://localhost:8082 (For example, use the default settings controller-port: "8082"). The application has already run successfully if you can visit the dashboard on your browser. Otherwise check the shuttle.log for more details and new issues anytime.

System Configuration

If you could open http://c.sipt.top in your browser, you can skip the following steps directly.

Open System Preference => Network => Proxy, set to 127.0.0.1:8080(for example: http-port: "8080"). The proxy settings are working if you can see the dashboard by visiting http://c.sipt.top on browser.

Linux
Preparation

Download the zip file from release and unzip it. The Folder structure is shown below.

shuttle
   ├── RespFiles/ #mock file directory
   ├── shuttle  #shuttle main executable
   ├── shuttle.yaml #config file
   └── start.sh #launch script

Open the config file, shuttle.yaml. Make sure all the ports are all configured correctly before launching. The default ports in config file are 8080, 8081 and 8082.

General:
  http-port: "8080"  #http/https port
  socks-port: "8081" #socks port
  controller-port: "8082" #dashboard port
Launch

Go to the shuttle directory and enter the command below in terminal/CMD to launch the app.

./start.sh #no output

Open your browser and visit http://localhost:8082 (For example, use the default settings controller-port: "8082"). The application has already run successfully if you can visit the dashboard on your browser. Otherwise check the shuttle.log for more details and new issues anytime.

Configuration

Version
ver: v1.0.1

Current config file only supports v1.0.1. Don't edit yourself.

General Settings
General:
  loglevel: "info"
  dns-server:
  - "114.114.114.114"
  - "223.5.5.5"
  http-port: "8080"
  http-interface: "0.0.0.0"
  socks-port: "8081"
  socks-interface: "0.0.0.0"
  controller-port: "8082"
  controller-interface: "0.0.0.0"
Name Description Value
loglevel Log output level, better use level: info or error trace,debug,info,error
dns-server DNS server address IP address
http-port HTTP/HTTPS port
http-interface HTTP/HTTPS port
socks-port SOCKS port
socks-interface SOCKS control
controller-port dashboard port
controller-interface dashboard control
Proxy Settings

Server name and server group name should not be repeating. DIRECT, REJECT and GLOBAL are reserved name.

Server
Proxy:
  "🇯🇵JP_a": ["ss", "jp.a.example.com", "12345", "rc4-md5", "123456"]
  "🇯🇵JP_b": ["ss", "jp.b.example.com", "12345", "rc4-md5", "123456"]
  "🇯🇵JP_c": ["ss", "jp.c.example.com", "12345", "rc4-md5", "123456"]
  "🇭🇰HK_a": ["ss", "hk.a.example.com", "12345", "rc4-md5", "123456"]
  "🇭🇰HK_b": ["ss", "hk.b.example.com", "12345", "rc4-md5", "123456"]
  "🇭🇰HK_c": ["ss", "hk.c.example.com", "12345", "rc4-md5", "123456"]
  "🇺🇸US_a": ["ss", "us.a.example.com", "12345", "rc4-md5", "123456"]
  "🇺🇸US_b": ["ss", "us.b.example.com", "12345", "rc4-md5", "123456"]
  "🇺🇸US_c": ["ss", "hk.c.example.com", "12345", "rc4-md5", "123456"]
  "socks": ["socks", "localhost", "12345"]
  "socks-tls": ["socks-tls", "localhost", "12345", "skip-verify"]
  "socks-auth": ["socks", "localhost", "12345", "user", "password"]
  "socks-tls-auth": ["socks-tls", "localhost", "12345", "skip-verify", "user", "password"]
  ...

Server protocols:

  • ss: shadowsocks;

    format:

    "server name": ["ss", "domain/IP", "port", "cipher", "password"]
    

    Current supported encryption methods:

    • aes-128-cfb
    • aes-192-cfb
    • aes-256-cfb
    • aes-128-ctr
    • aes-192-ctr
    • aes-256-ctr
    • des-cfb
    • bf-cfb
    • cast5-cfb
    • rc4-md5
    • chacha20
    • chacha20-ietf
    • salsa20
    • aes-256-gcm
    • aes-192-gcm
    • aes-128-gcm
    • chacha20-ietf-poly1305
  • socks: SOCKS5;

    Support username/password authentication.

    "server name": ["socks", "domain/IP", "port"] 
    "server name": ["socks", "domain/IP", "port", "username", "password"]
    
  • socks-tls: SOCKS5 over TLS;

    Support username/password authentication. Use: skip-verify or verify for checking server's certificate.

    "server name": ["socks-tls", "domain/IP", "ca check or not", "port"] 
    "server name": ["socks-tls", "domain/IP", "ca check or not", "port", "username", "password"]
    
Server Group
Proxy-Group:
  "Auto": ["rtt", "🇭🇰HK_a", "🇭🇰HK_b", "🇭🇰HK_c", "🇯🇵JP_a", "🇯🇵JP_b", "🇯🇵JP_c", "🇺🇸US_a", "🇺🇸US_b", "🇺🇸US_c"]
  "HK": ["select", "🇭🇰HK_a", "🇭🇰HK_b", "🇭🇰HK_c"]
  "JP": ["select", "🇯🇵JP_a", "🇯🇵JP_b", "🇯🇵JP_c"]
  "US": ["select", "🇺🇸US_a", "🇺🇸US_b", "🇺🇸US_c"]
  "Proxy": ["select", "Auto", "HK", "JP", "US"]
  "nProxy": ["select", "DIRECT"]

Format

"group name": ["option", "server name/server group name", ... ]
Option Description
select manual select
rtt select the server that has the shortest transaction time between local(through remote server) to www.gstatic.com
DNS
Local-DNS:
- ["DOMAIN", "localhost", "static", "127.0.0.1"]
- ["DOMAIN-KEYWORD", "google", "remote", ""]
- ["DOMAIN-SUFFIX", "baidu.com", "direct", "114.114.114.114"]

Format

- ["match option", "value", "resolve method", "parameter"]
Match Option Description Value
DOMAIN-SUFFIX match domain suffix domain suffix
DOMAIN match domain domain
DOMAIN-KEYWORD match domain keyword keyword
Resolve Option Description Parameter
static static resolve corresponding IP adress
direct use DNS to resolve DNS address
remote use remote server to resolve N/A
Request/Response Modification & URL Rewrite

HTTPS(turn the MitM on)

Http-Map:
  Req-Map: #request modification config
    - url-rex: "^http://www.zhihu.com"
      type: "UPDATE"
      items:
        - ["HEADER", "Scheme", "http"]
  Resp-Map: #response modification config
      - url-rex: "^http://www.zhihu.com"
      type: "UPDATE"
      items:
         - ["STATUS", "", "301"]
         - ["HEADER", "Location", "http://www.jianshu.com"]
Name Description
url-rex Use regex to match requested URL
type UPDATE(modification)and MOCK(local data return),(Resp-Maponly supportsUPDATE)
items An array: ["modify type", "Key", "Value"] (details on the following table)
Modify Type Description Condition
HEADER Add/modify header (Example) (Req-MaporResp-Map) type:(UPDATEorMOCK)
STATUS Modify return status code (Example) (Resp-Map) type:(UPDATEorMOCK)
BODY Response Body(Example)
(HTTPS domain must exists and supports HTTPS)
(Resp-Map) type:(MOCK)
URL Use url-rex to replace URL
Currently, HTTPS is not supported (URL Rewrite)
(Req-Map) type:(UPDATE)
Examples:
Header Modify

Add Scheme: http to every request that matches ^http://www.zhihu.com

Http-Map:
  Req-Map:
      - url-rex: "^http://www.zhihu.com"
      type: "UPDATE"
      items:
        - ["HEADER", "Scheme", "http"]
Request Mapping

If the type is MOCK, all HTTP domains are good to go but HTTPS domains must exist and support HTTPS

For every request that matches ^http://www.baidu.com/$, return directly.

{
  "name": "Shuttle",
  "github-link": "https://github.com/sipt/shuttle",
  "data": "response mock"
}

Create a file called mocks.json to write in the data above under RespFiles directory.

Config:

Http-Map:
  Req-Map:
    - url-rex: "^http://www.wogaoxing.abcascb" #all HTTP domains are good to go
      type: "MOCK"
      items:
        - ["STATUS", "", "200"] #return status code:200 OK
        - ["HEADER", "Content-Type", "application/json"] #add header
        - ["BODY", "", "mock.json"] #return data matches RespFiles/mock.json
    - url-rex: "^https://www.baidu.com" #For HTTPS, domains must exist and support HTTPS
      type: "MOCK"
      items:
        - ["STATUS", "", "200"] #return status code:200 OK
        - ["HEADER", "Content-Type", "application/json"] #add header
        - ["BODY", "", "mock.json"] #return data matches RespFiles/mock.json
URL Rewrite

HTTPS is not supported currently

For every request that matches ^http://www.baidu.com, use reverse proxy to redirect to http://www.zhihu.com

Http-Map:
  Req-Map:
    - url-rex: "^http://www.baidu.com"
      type: "UPDATE"
      items:
       - ["URL", "", "http://www.zhihu.com"]
MitM
MITM: 
  rules: ["*.baidu.com", "*.zhihu.com"] #Domains allowed for MitM
  ca: (base64) # CA certificate and private key, no need for configuration, Shuttle will generate them automatically and store here
  key: (base64)
Rule Configuration
Rule: # Proxy rules
- ["DOMAIN-SUFFIX", "gitlab.anjian.com", "DIRECT", ""]
# - [Match full domain,domain,go through Proxy group,]
- ["DOMAIN", "sipt.top", "Proxy", ""]
# - [keyword match,keyword,connection reject,]
- ["DOMAIN-KEYWORD", "zjtoolbar", "REJECT", ""]
# - [IP range match,IP range,direct connection,]
- ["IP-CIDR", "127.0.0.0/8", "DIRECT", ""]
# - [GEOIP match,China, go through nProxy group,]
- ["GEOIP", "CN", "nProxy", ""]
# - [match none of above,, go through Proxy group,]
- ["FINAL", "", "Proxy", ""]

Format.

- ["match option","value","connection type","memo"]
Match Option Description Value
DOMAIN-SUFFIX match domain suffix domain suffix
DOMAIN match full domain name domain
DOMAIN-KEYWORD match domain keyword keyword
IP-CIDR match IP range IP range
GEOIP GEOIP match country code
FINAL match none of above N/A
Connection Type Description
DIRECT connect designated server directly
REJECT connection rejected
Server name
Server group name

Web Dashboard

http://c.sipt.top

Servers

Servers

  1. GLOBAL group was created by Shuttle. It will be selected in "Remote Mode".
  2. Refresh RTT-Time.
  3. Check new.
  4. Up/Down speed.
  5. Outbound Mode: Rule Mode, Remote Mode, Direct Mode, Reject Mode.
  6. Dump: Capturing HTTP requests; MitM: Man-in-the-MiddleAttack.
  7. Reload the config file. Shutdown the Shuttle.
DNS Cache

dns-cache Check all DNS records The Refresh button and Clear button is on the left-hand corner. The Refresh button currently only support all records refresh.

Records

Records Check all request, and the corresponding rule. Currently, only the latest 500 entries will be stored, and keyword filter is supported

Traffic Capture

You can enable Dump for HTTP traffic capture. All the Dumped Data would show the DOWNLOAD icon the every records. You can click and see for more detail.

It's a little bit complicated for HTTPS traffic capture. You can follow the steps to try it out.

Cert

  1. Generate a certificate. A new CA would be generated and stored in the config file when you click the GENERATE button each time.
  2. Click DOWNLOAD button to download the CA.
  3. Add the CA to system and trust the CA.
  4. The table above will list all HTTPS traffic that could be captured based on rules. You can add yourt own rules. Shuttle will not capture the HTTPS traffic matched no rules..
  5. You should enable both Dump and MitM to make HTTPS traffic capture available.

Large file download

large_dump

Enter the file name in the input filed, then click download.

The dumped data just shows "The file is too large" instead of data detail for the better webpage performance when the file data size is over 2MB. You can download it for more details.

Build from source
go get -d github.com/sipt/shuttle
cd $GOPATH/src/github.com/sipt/shuttle/assets
go generate # package html and GeoLite2-Country.mmdb resources into assets/assets.go
cd $GOPATH/src/github.com/sipt/shuttle/cmd
go build -tags release

Documentation

Index

Constants

View Source
const (
	DumpOrderWrite = iota
	DumpOrderClose

	DumpRequestEntity
	DumpResponseEntity

	DumpFileDir       = "temp"
	DumpRequestFile   = DumpFileDir + string(os.PathSeparator) + "%d_req.dump"
	DumpResponseFile  = DumpFileDir + string(os.PathSeparator) + "%d_resp.dump"
	LargeRequestBody  = 2 * 1024 * 1024 // 5MB
	LargeResponseBody = 2 * 1024 * 1024 // 5MB
)
View Source
const (
	HTTP  = "http"
	HTTPS = "https"
)
View Source
const (
	ModifyTypeURL    = "URL"
	ModifyTypeHeader = "HEADER"
	ModifyTypeStatus = "STATUS"
	ModifyTypeBody   = "BODY"

	ModifyMock   = "MOCK"
	ModifyUpdate = "UPDATE"

	BodyFileDir = "RespFiles"
)
View Source
const (
	CmdTCP = 0x01
	CmdUDP = 0x03

	ProtocolSocks = "SOCKS"
	ProtocolHttp  = "HTTP"
	ProtocolHttps = "HTTPS"

	AddrTypeIPv4   = 0x01 //    0x01:IPv4
	AddrTypeDomain = 0x03 //    0x03:域名
	AddrTypeIPv6   = 0x04 //    0x04:IPv6
)
View Source
const (
	RecordStatus = 1
	RecordUp     = 2
	RecordDown   = 3
	RecordAppend = 4
	RecordRemove = 5

	RecordStatusActive    = "Active"
	RecordStatusCompleted = "Completed"
	RecordStatusReject    = "Reject"
	RecordStatusFailed    = "Failed"
)

Variables

View Source
var (
	ControllerDomain string
	ControllerPort   string
	HTTPProxyPort    string
)
View Source
var (
	ErrorReadTimeOut  = errors.New("read time out")
	ErrorWriteTimeOut = errors.New("write time out")
	ErrorReject       = errors.New("connection reject")

	ErrorServerNotFound = errors.New("server or server group not found")

	ErrorUnknowType = errors.New("unknow type")
)
View Source
var MitMRules []string

Functions

func AppendMitMRules

func AppendMitMRules(r string)

func ApplyHTTPModifyConfig

func ApplyHTTPModifyConfig(config IHttpModifyConfig) (err error)

func ApplyMITMConfig

func ApplyMITMConfig(config IMITMConfig) error

func ClearRecords

func ClearRecords()

func ConnectFilter

func ConnectFilter(hreq *http.Request, connID int64) (rule *rule2.Rule, server *proxy.Server, conn connect.IConn, err error)

func CurrentSpeed

func CurrentSpeed() (int, int)

func FilterByReq

func FilterByReq(req IRequest) (r *rule.Rule, s *proxy.Server, err error)

func GenerateCA

func GenerateCA() (mitm *config.Mitm, err error)

func GetAllowDump

func GetAllowDump() bool

func GetAllowMitm

func GetAllowMitm() bool

func GetCACert

func GetCACert() []byte

func GetMitMRules

func GetMitMRules() []string

func HandleHTTP

func HandleHTTP(co net.Conn)

func HostName

func HostName(req *http.Request) (host string)

func HttpTransport

func HttpTransport(lc, sc connect.IConn, allowDump bool, first *http.Request)

func InitConfigValue

func InitConfigValue(conf IConfigValue)

func IsPass

func IsPass(host, port, ip string) bool

func LoadCA

func LoadCA(caPem, keyPem []byte) (*x509.Certificate, *rsa.PrivateKey, error)

func Mimt

func Mimt(lc, sc connect.IConn) (connect.IConn, connect.IConn, error)

func ProxyHTTP

func ProxyHTTP(lc connect.IConn, hreq *http.Request)

func ProxyHTTP2

func ProxyHTTP2()

func ProxyHTTPS

func ProxyHTTPS(lc connect.IConn, hreq *http.Request)

func Recover

func Recover(fs ...func())

func RegisterPusher

func RegisterPusher(p Pusher)

注册推送

func RemoveMitMRules

func RemoveMitMRules(r string)

func RequestModify

func RequestModify(req *http.Request, isHttps bool) *http.Response

func RequestModifyOrMock

func RequestModifyOrMock(req *HttpRequest, hreq *http.Request, isHttps bool) (respBuf []byte, err error)

func ResponseModify

func ResponseModify(req *http.Request, resp *http.Response, isHttps bool)

func SetAllowDump

func SetAllowDump(b bool)

func SetAllowMitm

func SetAllowMitm(b bool)

func SetDump

func SetDump(d IDump)

func SetMitMRules

func SetMitMRules(rs []string)

init MitMRules

func SocksHandle

func SocksHandle(co net.Conn)

func StrToUint16

func StrToUint16(v string) (i uint16, err error)

func ToWriter

func ToWriter(w func([]byte) (int, error)) io.Writer

Types

type Box

type Box struct {
	ID    int64
	Op    int
	Value interface{}
}

type DirectChannel

type DirectChannel struct{}

func (*DirectChannel) Transport

func (d *DirectChannel) Transport(lc, sc connect.IConn)

type FileDump

type FileDump struct {
	sync.RWMutex
	Actives map[int64]*SequenceHeap
	// contains filtered or unexported fields
}

func (*FileDump) Clear

func (f *FileDump) Clear() error

func (*FileDump) Complete

func (f *FileDump) Complete(id int64) error

func (*FileDump) Dump

func (f *FileDump) Dump(id int64) (req io.ReadCloser, reqSize int64, resp io.ReadCloser, respSize int64, err error)

func (*FileDump) InitDump

func (f *FileDump) InitDump(id int64) error

func (*FileDump) WriteRequest

func (f *FileDump) WriteRequest(id int64, data []byte) (n int, err error)

func (*FileDump) WriteResponse

func (f *FileDump) WriteResponse(id int64, data []byte) (n int, err error)

type HttpChannel

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

func (*HttpChannel) Transport

func (h *HttpChannel) Transport(lc, sc connect.IConn, first *http.Request) (err error)

type HttpRequest

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

HTTP Request

func NewHttpRequest

func NewHttpRequest(network string, domain string, ip string, port string, protocol string,
	target string, connID int64, answer *dns.Answer) *HttpRequest

func (*HttpRequest) Addr

func (r *HttpRequest) Addr() string

return domain!=""?domain:ip

func (*HttpRequest) Answer

func (r *HttpRequest) Answer() *dns.Answer

func (*HttpRequest) Domain

func (r *HttpRequest) Domain() string

func (*HttpRequest) Host

func (r *HttpRequest) Host() string

return domain/ip:[port]

func (*HttpRequest) ID

func (r *HttpRequest) ID() int64

return request id

func (*HttpRequest) IP

func (r *HttpRequest) IP() string

func (*HttpRequest) Network

func (r *HttpRequest) Network() string

func (*HttpRequest) Port

func (r *HttpRequest) Port() string

func (*HttpRequest) SetAnswer

func (r *HttpRequest) SetAnswer(answer *dns.Answer)

type IConfigValue

type IConfigValue interface {
	GetControllerDomain() string
	GetControllerPort() string
	GetHTTPPort() string
}

type IDump

type IDump interface {
	InitDump(int64) error
	WriteRequest(int64, []byte) (n int, err error)
	WriteResponse(int64, []byte) (n int, err error)
	Dump(int64) (req io.ReadCloser, reqSize int64, resp io.ReadCloser, respSize int64, err error)
	Complete(int64) error
	Clear() error
}

func GetDump

func GetDump() IDump

type IHttpModifyConfig

type IHttpModifyConfig interface {
	GetHTTPMap() *config.HttpMap
}

type IMITMConfig

type IMITMConfig interface {
	GetMITM() *config.Mitm
	SetMITM(*config.Mitm)
}

type IRequest

type IRequest interface {
	Network() string
	Domain() string
	IP() string
	Port() string
	Answer() *dns.Answer
	SetAnswer(*dns.Answer)

	ID() int64    //return request id
	Host() string //return [domain/ip]:[port]
	Addr() string //return domain!=""?domain:ip
}

type Item

type Item struct {
	Value  interface{}
	Ticket int64
}

type LinkedList

type LinkedList struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func (*LinkedList) Append

func (l *LinkedList) Append(r *Record)

func (*LinkedList) Clear

func (l *LinkedList) Clear()

func (*LinkedList) Get

func (l *LinkedList) Get(id int64) *Record

func (*LinkedList) List

func (l *LinkedList) List() []Record

func (*LinkedList) Put

func (l *LinkedList) Put(id int64, op int, v interface{})

type MinArrange

type MinArrange struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewMinArrange

func NewMinArrange() *MinArrange

func (*MinArrange) Close

func (m *MinArrange) Close()

func (*MinArrange) Pop

func (m *MinArrange) Pop() (item *Item)

func (*MinArrange) Push

func (m *MinArrange) Push(v *Item)

type MinHeap

type MinHeap []*Item

func (*MinHeap) Len

func (m *MinHeap) Len() int

func (*MinHeap) Less

func (m *MinHeap) Less(i, j int) bool

func (*MinHeap) Pop

func (m *MinHeap) Pop() interface{}

func (*MinHeap) Push

func (m *MinHeap) Push(x interface{})

func (*MinHeap) Swap

func (m *MinHeap) Swap(i, j int)

type ModifyPolicy

type ModifyPolicy struct {
	Type   string
	UrlRex string

	MVs []*ModifyValue
	// contains filtered or unexported fields
}

type ModifyValue

type ModifyValue struct {
	Type  string
	Key   string
	Value string
}

type Pusher

type Pusher func(interface{})

type Record

type Record struct {
	ID       int64
	Protocol string
	Created  time.Time
	Proxy    *proxy.Server
	Rule     *rule.Rule
	Status   string
	Up       int
	Down     int
	URL      string
	Dumped   bool
}

func GetRecord

func GetRecord(id int64) *Record

func GetRecords

func GetRecords() []Record

type SequenceHeap

type SequenceHeap struct {
	*MinArrange
	// contains filtered or unexported fields
}

func NewSequenceHeap

func NewSequenceHeap() *SequenceHeap

func (*SequenceHeap) Pop

func (s *SequenceHeap) Pop() interface{}

func (*SequenceHeap) Push

func (s *SequenceHeap) Push(v interface{})

type Shunt

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

func NewShunt

func NewShunt(w1, w2 io.Writer) *Shunt

分流

func (*Shunt) Write

func (s *Shunt) Write(p []byte) (n int, err error)

type SocksRequest

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

|VER | CMD | RSV | ATYP | DST.ADDR | DST.PORT |

func (*SocksRequest) Addr

func (r *SocksRequest) Addr() string

return domain!=""?domain:ip

func (*SocksRequest) Answer

func (r *SocksRequest) Answer() *dns.Answer

func (*SocksRequest) Domain

func (r *SocksRequest) Domain() string

func (*SocksRequest) Host

func (r *SocksRequest) Host() string

return domain/ip:[port]

func (*SocksRequest) ID

func (r *SocksRequest) ID() int64

return request id

func (*SocksRequest) IP

func (r *SocksRequest) IP() string

func (*SocksRequest) Network

func (r *SocksRequest) Network() string

func (*SocksRequest) Port

func (r *SocksRequest) Port() string

func (*SocksRequest) SetAnswer

func (r *SocksRequest) SetAnswer(answer *dns.Answer)

type Speed

type Speed struct {
	UpSpeed   int
	DownSpeed int
	UpBytes   int
	DownBytes int
	Cancel    chan bool
	// contains filtered or unexported fields
}

func (*Speed) Start

func (s *Speed) Start()

Jump to

Keyboard shortcuts

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