lib

package
v0.0.0-...-dc1520d Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2018 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	VERIFY_EER = "vkey"
	WORK_MAIN  = "main"
	WORK_CHAN  = "chan"
	RES_SIGN   = "sign"
	RES_MSG    = "msg0"
	TEST_FLAG  = "tst"
	CONN_TCP   = "tcp"
	CONN_UDP   = "udp"
)
View Source
const (
	COMPRESS_NONE = iota
	COMPRESS_SNAPY_ENCODE
	COMPRESS_SNAPY_DECODE
	COMPRESS_GZIP_ENCODE
	COMPRESS_GZIP_DECODE
)
View Source
const (
	UserPassAuth = uint8(2)
)

Variables

View Source
var (
	TcpPort = flag.Int("tcpport", 8284, "客户端与服务端通信端口")

	RunList map[string]interface{} //运行中的任务

	CsvDb *Csv
)

Functions

func AddTask

func AddTask(t *TaskList) error

func BadRequest

func BadRequest(w http.ResponseWriter)

func DecodeRequest

func DecodeRequest(data []byte) (*http.Request, error)

将字节转为request

func DecodeResponse

func DecodeResponse(data []byte) (*http.Response, error)

将字节转为response

func DelTask

func DelTask(vKey string) error

func DomainCheck

func DomainCheck(domain string) bool

func EncodeRequest

func EncodeRequest(r *http.Request) ([]byte, error)

将request转为bytes

func EncodeResponse

func EncodeResponse(r *http.Response) ([]byte, error)

// 将response转为字节

func GetEncodeResponse

func GetEncodeResponse(req *http.Request) ([]byte, error)

发送请求并转为bytes

func GetRandomString

func GetRandomString(l int) string

生成随机验证密钥

func Gethostbyname

func Gethostbyname(hostname string) string

func InitFromCsv

func InitFromCsv()

从csv文件中恢复任务

func InitMode

func InitMode()

func Md5

func Md5(s string) string

生成32位md5字串

func ProcessHost

func ProcessHost(c *Conn, s *TunnelModeServer) error

多客户端域名代理

func ProcessHttp

func ProcessHttp(c *Conn, s *TunnelModeServer) error

http代理模式

func ProcessTunnel

func ProcessTunnel(c *Conn, s *TunnelModeServer) error

tcp隧道模式

func StartTask

func StartTask(vKey string) error

func StopServer

func StopServer(cFlag string) error

Types

type Config

type Config struct {
	SiteList []Site
	Replace  int
}

type Conn

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

func NewConn

func NewConn(conn net.Conn) *Conn

func (*Conn) Close

func (s *Conn) Close() error

func (*Conn) GetCompressTypeFromConn

func (s *Conn) GetCompressTypeFromConn() (en, de int)

获取压缩方式

func (*Conn) GetHost

func (s *Conn) GetHost() (method, address string, rb []byte, err error)

从tcp报文中解析出host

func (*Conn) GetHostFromConn

func (s *Conn) GetHostFromConn() (typeStr string, host string, en, de int, err error)

读取host 连接地址 压缩类型

func (*Conn) GetLen

func (s *Conn) GetLen() (int, error)

获取长度

func (*Conn) Read

func (s *Conn) Read(b []byte) (int, error)

func (*Conn) ReadFlag

func (s *Conn) ReadFlag() (string, error)

读取flag

func (*Conn) ReadFromCompress

func (s *Conn) ReadFromCompress(b []byte, compress int) (int, error)

压缩方式读

func (*Conn) ReadLen

func (s *Conn) ReadLen(len int) ([]byte, error)

读取指定内容长度

func (*Conn) SetAlive

func (s *Conn) SetAlive()

设置连接为长连接

func (*Conn) Write

func (s *Conn) Write(b []byte) (int, error)

func (*Conn) WriteCompress

func (s *Conn) WriteCompress(b []byte, compress int) (n int, err error)

压缩方式写

func (*Conn) WriteCompressType

func (s *Conn) WriteCompressType(en, de int)

写压缩方式

func (*Conn) WriteHost

func (s *Conn) WriteHost(ltype string, host string) (int, error)

写连接类型 和 host地址

func (*Conn) WriteLen

func (s *Conn) WriteLen(buf []byte) (int, error)

写入长度

type Csv

type Csv struct {
	Tasks   []*TaskList
	Path    string
	Bridge  *Tunnel
	RunList map[string]interface{}
	Hosts   []*HostList //域名列表
}

func InitCsvDb

func InitCsvDb() *Csv

func NewCsv

func NewCsv(path string, bridge *Tunnel, runList map[string]interface{}) *Csv

func (*Csv) AddRunList

func (s *Csv) AddRunList(vKey string, svr interface{})

func (*Csv) DelHost

func (s *Csv) DelHost(host string) error

func (*Csv) DelRunList

func (s *Csv) DelRunList(vKey string)

func (*Csv) DelTask

func (s *Csv) DelTask(vKey string) error

func (*Csv) GetHostList

func (s *Csv) GetHostList(start, length int, vKey string) ([]*HostList, int)

func (*Csv) GetTask

func (s *Csv) GetTask(vKey string) (v *TaskList, err error)

func (*Csv) GetTaskList

func (s *Csv) GetTaskList(start, length int, typeVal string) ([]*TaskList, int)

func (*Csv) Init

func (s *Csv) Init()

func (*Csv) LoadHostFromCsv

func (s *Csv) LoadHostFromCsv()

func (*Csv) LoadTaskFromCsv

func (s *Csv) LoadTaskFromCsv()

func (*Csv) NewHost

func (s *Csv) NewHost(t *HostList)

func (*Csv) NewTask

func (s *Csv) NewTask(t *TaskList)

func (*Csv) StoreHostToCsv

func (s *Csv) StoreHostToCsv()

func (*Csv) StoreTasksToCsv

func (s *Csv) StoreTasksToCsv()

func (*Csv) UpdateTask

func (s *Csv) UpdateTask(t *TaskList) error

type GzipConn

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

func NewGzipConn

func NewGzipConn(conn net.Conn) *GzipConn

func (*GzipConn) Read

func (s *GzipConn) Read(b []byte) (n int, err error)

func (*GzipConn) Write

func (s *GzipConn) Write(b []byte) (n int, err error)

type HostList

type HostList struct {
	Vkey   string //服务端与客户端通信端口
	Host   string //启动方式
	Target string //目标
}

type HostServer

type HostServer struct {
}

host

func NewHostServer

func NewHostServer() *HostServer

func (*HostServer) Close

func (s *HostServer) Close() error

func (*HostServer) Start

func (s *HostServer) Start() error

开始

type HttpModeServer

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

func NewHttpModeServer

func NewHttpModeServer(httpPort int, bridge *Tunnel, enCompress int, deCompress int, vKey string) *HttpModeServer

func (*HttpModeServer) Start

func (s *HttpModeServer) Start()

开始

type JsonStruct

type JsonStruct struct {
}

func NewJsonStruct

func NewJsonStruct() *JsonStruct

func (*JsonStruct) Load

func (jst *JsonStruct) Load(filename string) (Config, error)

type Site

type Site struct {
	Host string
	Url  string
	Port int
}

type SnappyConn

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

func NewSnappyConn

func NewSnappyConn(conn net.Conn) *SnappyConn

func (*SnappyConn) Read

func (s *SnappyConn) Read(b []byte) (n int, err error)

func (*SnappyConn) Write

func (s *SnappyConn) Write(b []byte) (n int, err error)

type Sock5ModeServer

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

func NewSock5ModeServer

func NewSock5ModeServer(httpPort int, u, p string, brige *Tunnel, enCompress int, deCompress int, vKey string) *Sock5ModeServer

func (*Sock5ModeServer) Auth

func (s *Sock5ModeServer) Auth(c net.Conn) error

func (*Sock5ModeServer) Close

func (s *Sock5ModeServer) Close() error

func (*Sock5ModeServer) Start

func (s *Sock5ModeServer) Start() error

type TRPClient

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

func NewRPClient

func NewRPClient(svraddr string, tcpNum int, vKey string) *TRPClient

func (*TRPClient) Start

func (s *TRPClient) Start() error

type TaskList

type TaskList struct {
	TcpPort      int    //服务端与客户端通信端口
	Mode         string //启动方式
	Target       string //目标
	VerifyKey    string //flag
	U            string //socks5验证用户名
	P            string //socks5验证密码
	Compress     string //压缩方式
	Start        int    //是否开启
	IsRun        int    //是否在运行
	ClientStatus int    //客户端状态
}

type Tunnel

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

func (*Tunnel) GetSignal

func (s *Tunnel) GetSignal(cFlag string) (err error, conn *Conn)

得到一个通信通道

func (*Tunnel) GetTunnel

func (s *Tunnel) GetTunnel(cFlag string, en, de int) *Conn

得到一个tcp隧道

func (*Tunnel) ReturnSignal

func (s *Tunnel) ReturnSignal(conn *Conn, cFlag string)

重回slice 复用

func (*Tunnel) StartTunnel

func (s *Tunnel) StartTunnel() error

type TunnelModeServer

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

func NewTunnelModeServer

func NewTunnelModeServer(httpPort int, tunnelTarget string, process process, bridge *Tunnel, enCompress int, deCompress int, vKey string) *TunnelModeServer

func (*TunnelModeServer) Close

func (s *TunnelModeServer) Close() error

func (*TunnelModeServer) Start

func (s *TunnelModeServer) Start() error

开始

type UdpModeServer

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

func NewUdpModeServer

func NewUdpModeServer(udpPort int, tunnelTarget string, bridge *Tunnel, enCompress int, deCompress int, vKey string) *UdpModeServer

func (*UdpModeServer) Close

func (s *UdpModeServer) Close() error

func (*UdpModeServer) Start

func (s *UdpModeServer) Start() error

开始

type WebServer

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

web管理方式

func NewWebServer

func NewWebServer(bridge *Tunnel) *WebServer

func (*WebServer) Start

func (s *WebServer) Start()

开始

Jump to

Keyboard shortcuts

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