file

package
v0.18.2 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2019 License: MIT Imports: 16 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 //当前连接数

	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) 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            []*Tunnel
	Path             string
	Hosts            []*Host   //域名列表
	Clients          []*Client //客户端
	RunPath          string    //存储根目录
	ClientIncreaseId int       //客户端id
	TaskIncreaseId   int       //任务自增ID
	HostIncreaseId   int
	sync.RWMutex
}
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) (v *Client, err error)

func (*Csv) GetClientId

func (s *Csv) GetClientId() int

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) ([]*Client, int)

func (*Csv) GetHost

func (s *Csv) GetHost(start, length int, id int) ([]*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() int

func (*Csv) GetIdByVerifyKey

func (s *Csv) GetIdByVerifyKey(vKey string, addr string) (int, 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) GetTask

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

func (*Csv) GetTaskByMd5Password added in v0.18.0

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

md5 password

func (*Csv) GetTaskId

func (s *Csv) GetTaskId() int

func (*Csv) IsHostExist added in v0.0.15

func (s *Csv) IsHostExist(h *Host) 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) 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) UpdateHost

func (s *Csv) UpdateHost(t *Host) 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) 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
}

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      //服务端监听端口
	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