lib

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2019 License: MIT Imports: 32 Imported by: 0

Documentation

Index

Constants

View Source
const (
	VERIFY_EER         = "vkey"
	WORK_MAIN          = "main"
	WORK_CHAN          = "chan"
	RES_SIGN           = "sign"
	RES_MSG            = "msg0"
	CONN_SUCCESS       = "sucs"
	CONN_ERROR         = "fail"
	TEST_FLAG          = "tst"
	CONN_TCP           = "tcp"
	CONN_UDP           = "udp"
	Unauthorized_BYTES = `HTTP/1.1 401 Unauthorized
Content-Type: text/plain; charset=utf-8
WWW-Authenticate: Basic realm="easyProxy"

401 Unauthorized`
)
View Source
const (
	COMPRESS_NONE_ENCODE = iota
	COMPRESS_NONE_DECODE
	COMPRESS_SNAPY_ENCODE
	COMPRESS_SNAPY_DECODE
	IO_EOF = "PROXYEOF"
)
View Source
const (
	UserPassAuth = uint8(2)
)

Variables

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

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

	CsvDb *Csv
)
View Source
var GlobalHostSessions *session.Manager

Functions

func AddTask

func AddTask(t *ServerConfig) error

func AesDecrypt

func AesDecrypt(crypted, key []byte) ([]byte, error)

de

func AesEncrypt

func AesEncrypt(origData, key []byte) ([]byte, error)

en

func BadRequest

func BadRequest(w http.ResponseWriter)

error

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 GetBoolByStr

func GetBoolByStr(s string) bool

get bool by str

func GetEncodeResponse

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

发送请求并转为bytes

func GetIntNoerrByStr

func GetIntNoerrByStr(str string) int

func GetLenByBytes

func GetLenByBytes(buf []byte) (int, error)

解析出长度

func GetLenBytes

func GetLenBytes(buf []byte) (b []byte, err error)

获取长度+内容

func GetRandomString

func GetRandomString(l int) string

生成随机验证密钥

func GetStrByBool

func GetStrByBool(b bool) string

get str by bool

func Gethostbyname

func Gethostbyname(hostname string) string

通过host获取对应的ip地址

func InitClient added in v0.0.7

func InitClient()

func InitFromCsv

func InitFromCsv()

从csv文件中恢复任务

func InitMode

func InitMode()

func Md5

func Md5(s string) string

生成32位md5字串

func PKCS5Padding

func PKCS5Padding(ciphertext []byte, blockSize int) []byte

补全

func PKCS5UnPadding

func PKCS5UnPadding(origData []byte) []byte

去补

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

new conn

func (*Conn) Close

func (s *Conn) Close() error

close

func (*Conn) GetConnInfoFromConn

func (s *Conn) GetConnInfoFromConn() (en, de int, crypt, mux bool)

获取压缩方式,是否加密

func (*Conn) GetHost

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

从tcp报文中解析出host,连接类型等

func (*Conn) GetHostFromConn

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

读取host 连接地址 压缩类型

func (*Conn) GetLen

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

获取长度

func (*Conn) Read

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

read

func (*Conn) ReadFlag

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

读取flag

func (*Conn) ReadFrom

func (s *Conn) ReadFrom(b []byte, compress int, crypt bool) (int, error)

单独读(加密|压缩)

func (*Conn) ReadLen

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

读取指定长度内容

func (*Conn) SetAlive

func (s *Conn) SetAlive()

设置连接为长连接

func (*Conn) Write

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

write

func (*Conn) WriteConnInfo

func (s *Conn) WriteConnInfo(en, de int, crypt, mux bool)

写压缩方式,加密

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)

写入长度+内容 粘包

func (*Conn) WriteTo

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

单独写(加密|压缩)

type CryptConn

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

func NewCryptConn

func NewCryptConn(conn net.Conn, crypt bool) *CryptConn

func (*CryptConn) Read

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

解密读

func (*CryptConn) Write

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

加密写

type Csv

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

func InitCsvDb

func InitCsvDb() *Csv

func NewCsv

func NewCsv(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) GetServerConfig

func (s *Csv) GetServerConfig(start, length int, typeVal string) ([]*ServerConfig, int)

func (*Csv) GetTask

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

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 *ServerConfig)

func (*Csv) StoreHostToCsv

func (s *Csv) StoreHostToCsv()

func (*Csv) StoreTasksToCsv

func (s *Csv) StoreTasksToCsv()

func (*Csv) UpdateTask

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

type HostList

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

type HostServer

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

host

func NewHostServer

func NewHostServer(cnf *ServerConfig) *HostServer

TODO:host模式的客户端,无需指定和监听端口等

func (*HostServer) Close

func (s *HostServer) Close() error

close

func (*HostServer) Start

func (s *HostServer) Start() error

开始

type HttpModeServer

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

func NewHttpModeServer

func NewHttpModeServer(bridge *Tunnel, cnf *ServerConfig) *HttpModeServer

http

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 ServerConfig

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

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, crypt bool) *SnappyConn

func (*SnappyConn) Read

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

snappy压缩读 包含解密

func (*SnappyConn) Write

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

snappy压缩写 包含加密

type Sock5ModeServer

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

func NewSock5ModeServer

func NewSock5ModeServer(bridge *Tunnel, cnf *ServerConfig) *Sock5ModeServer

new

func (*Sock5ModeServer) Auth

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

socks5 auth

func (*Sock5ModeServer) Close

func (s *Sock5ModeServer) Close() error

close

func (*Sock5ModeServer) Start

func (s *Sock5ModeServer) Start() error

start

type TRPClient

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

func NewRPClient

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

new client

func (*TRPClient) Start

func (s *TRPClient) Start() error

start

type Tunnel

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

func (*Tunnel) DelClientSignal

func (s *Tunnel) DelClientSignal(cFlag string)

删除通信通道

func (*Tunnel) DelClientTunnel

func (s *Tunnel) DelClientTunnel(cFlag string)

删除隧道

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, crypt, mux bool) (c *Conn, err error)

得到一个tcp隧道

func (*Tunnel) ReturnSignal

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

重回slice 复用

func (*Tunnel) ReturnTunnel

func (s *Tunnel) ReturnTunnel(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(process process, bridge *Tunnel, cnf *ServerConfig) *TunnelModeServer

tcp|http|host

func (*TunnelModeServer) Close

func (s *TunnelModeServer) Close() error

close

func (*TunnelModeServer) Start

func (s *TunnelModeServer) Start() error

开始

type UdpModeServer

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

func NewUdpModeServer

func NewUdpModeServer(bridge *Tunnel, cnf *ServerConfig) *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

new

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