file

package
v0.20.2 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2019 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Cnf       *Config
	Id        int        //id
	VerifyKey string     //验证密钥
	Addr      string     //客户端ip地址
	Remark    string     //备注
	Status    bool       //是否开启
	IsConnect bool       //是否连接
	RateLimit int        //速度限制 /kb
	Flow      *Flow      //流量
	Rate      *rate.Rate //速度控制
	NoStore   bool
	NoDisplay bool
	MaxConn   int //客户端最大连接数
	NowConn   int //当前连接数

	ConfigConnAllow bool
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewClient added in v0.0.15

func NewClient(vKey string, noStore bool, noDisplay bool) *Client

func (*Client) AddConn added in v0.0.16

func (s *Client) AddConn()

func (*Client) CutConn added in v0.0.16

func (s *Client) CutConn()

func (*Client) GetConn added in v0.0.16

func (s *Client) GetConn() bool

func (*Client) HasHost added in v0.18.0

func (s *Client) HasHost(h *Host) bool

func (*Client) HasTunnel added in v0.18.0

func (s *Client) HasTunnel(t *Tunnel) (exist bool)

func (*Client) ModifyTarget added in v0.18.1

func (s *Client) ModifyTarget()

modify the hosts and the tunnels by health information

type Config

type Config struct {
	U        string //socks5验证用户名
	P        string //socks5验证密码
	Compress bool   //压缩方式
	Crypt    bool   //是否加密
}

type Csv

type Csv struct {
	Tasks            sync.Map
	Hosts            sync.Map //域名列表
	HostsTmp         sync.Map
	Clients          sync.Map //客户端
	RunPath          string   //存储根目录
	ClientIncreaseId int32    //客户端id
	TaskIncreaseId   int32    //任务自增ID
	HostIncreaseId   int32    //host increased id
}
var (
	CsvDb *Csv
)

func GetCsvDb

func GetCsvDb() *Csv

init csv from file

func NewCsv

func NewCsv(runPath string) *Csv

func (*Csv) DelClient

func (s *Csv) DelClient(id int) error

func (*Csv) DelHost

func (s *Csv) DelHost(id int) error

func (*Csv) DelTask

func (s *Csv) DelTask(id int) error

func (*Csv) GetClient

func (s *Csv) GetClient(id int) (c *Client, err error)

func (*Csv) GetClientId

func (s *Csv) GetClientId() int32

func (*Csv) GetClientIdByVkey added in v0.0.15

func (s *Csv) GetClientIdByVkey(vkey string) (id int, err error)

func (*Csv) GetClientList

func (s *Csv) GetClientList(start, length int, search string, clientId int) ([]*Client, int)

func (*Csv) GetHost

func (s *Csv) GetHost(start, length int, id int, search string) ([]*Host, int)

func (*Csv) GetHostById added in v0.0.15

func (s *Csv) GetHostById(id int) (h *Host, err error)

func (*Csv) GetHostId added in v0.0.15

func (s *Csv) GetHostId() int32

func (*Csv) GetIdByVerifyKey

func (s *Csv) GetIdByVerifyKey(vKey string, addr string) (id int, err error)

func (*Csv) GetInfoByHost added in v0.0.15

func (s *Csv) GetInfoByHost(host string, r *http.Request) (h *Host, err error)

get key by host from x

func (*Csv) GetMapLen added in v0.19.0

func (s *Csv) GetMapLen(m sync.Map) int

func (*Csv) GetTask

func (s *Csv) GetTask(id int) (t *Tunnel, err error)

func (*Csv) GetTaskByMd5Password added in v0.18.0

func (s *Csv) GetTaskByMd5Password(p string) (t *Tunnel)

md5 password

func (*Csv) GetTaskId

func (s *Csv) GetTaskId() int32

func (*Csv) IsHostExist added in v0.0.15

func (s *Csv) IsHostExist(h *Host) bool

func (*Csv) IsPubClient added in v0.20.1

func (s *Csv) IsPubClient(id int) bool

func (*Csv) LoadClientFromCsv

func (s *Csv) LoadClientFromCsv()

func (*Csv) LoadHostFromCsv

func (s *Csv) LoadHostFromCsv()

func (*Csv) LoadTaskFromCsv

func (s *Csv) LoadTaskFromCsv()

func (*Csv) NewClient

func (s *Csv) NewClient(c *Client) error

func (*Csv) NewHost

func (s *Csv) NewHost(t *Host) error

func (*Csv) NewTask

func (s *Csv) NewTask(t *Tunnel) (err error)

func (*Csv) StoreClientsToCsv

func (s *Csv) StoreClientsToCsv()

func (*Csv) StoreHostToCsv

func (s *Csv) StoreHostToCsv()

func (*Csv) StoreTasksToCsv

func (s *Csv) StoreTasksToCsv()

func (*Csv) UpdateClient

func (s *Csv) UpdateClient(t *Client) error

func (*Csv) UpdateTask

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

func (*Csv) VerifyVkey added in v0.0.16

func (s *Csv) VerifyVkey(vkey string, id int) (res bool)

type Flow

type Flow struct {
	ExportFlow int64 //出口流量
	InletFlow  int64 //入口流量
	FlowLimit  int64 //流量限制,出口+入口 /M
	sync.RWMutex
}

func (*Flow) Add

func (s *Flow) Add(in, out int64)

type Health added in v0.18.1

type Health struct {
	HealthCheckTimeout  int
	HealthMaxFail       int
	HealthCheckInterval int
	HealthNextTime      time.Time
	HealthMap           map[string]int
	HttpHealthUrl       string
	HealthRemoveArr     []string
	HealthCheckType     string
	HealthCheckTarget   string
	sync.RWMutex
}

type Host

type Host struct {
	Id           int
	Host         string //启动方式
	Target       string //目标
	HeaderChange string //host修改
	HostChange   string //host修改
	Location     string //url 路由
	Flow         *Flow
	Client       *Client
	Remark       string //备注
	NowIndex     int
	TargetArr    []string
	NoStore      bool
	Scheme       string //http https all
	IsClose      bool
	Health
	sync.RWMutex
}

func (*Host) GetRandomTarget

func (s *Host) GetRandomTarget() (string, error)

type Tunnel

type Tunnel struct {
	Id         int //Id
	Port       int //服务端监听端口
	ServerIp   string
	Mode       string   //启动方式
	Target     string   //目标
	TargetArr  []string //目标
	Status     bool     //设置是否开启
	RunStatus  bool     //当前运行状态
	Client     *Client  //所属客户端id
	Ports      string   //客户端与服务端传递
	Flow       *Flow
	Password   string //私密模式密码,唯一
	Remark     string //备注
	TargetAddr string
	NoStore    bool
	LocalPath  string
	StripPre   string
	NowIndex   int
	Health
	sync.RWMutex
}

func (*Tunnel) GetRandomTarget added in v0.18.1

func (s *Tunnel) GetRandomTarget() (string, error)

Jump to

Keyboard shortcuts

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