file

package
v0.26.6 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2020 License: GPL-3.0 Imports: 17 Imported by: 12

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetMapKeys added in v0.21.0

func GetMapKeys(m sync.Map, isSort bool, sortKey, order string) (keys []int)

Types

type Client

type Client struct {
	Cnf             *Config
	Id              int        //id
	VerifyKey       string     //verify key
	Addr            string     //the ip of client
	Remark          string     //remark
	Status          bool       //is allow connect
	IsConnect       bool       //is the client connect
	RateLimit       int        //rate /kb
	Flow            *Flow      //flow setting
	Rate            *rate.Rate //rate limit
	NoStore         bool       //no store to file
	NoDisplay       bool       //no display on web
	MaxConn         int        //the max connection num of client allow
	NowConn         int32      //the connection num of now
	WebUserName     string     //the username of web login
	WebPassword     string     //the password of web login
	ConfigConnAllow bool       //is allow connected by config file
	MaxTunnelNum    int
	Version         string
	sync.RWMutex
}

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) GetTunnelNum added in v0.22.0

func (s *Client) GetTunnelNum() (num int)

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)

type Config

type Config struct {
	U        string
	P        string
	Compress bool
	Crypt    bool
}

type DbUtils added in v0.21.0

type DbUtils struct {
	JsonDb *JsonDb
}
var (
	Db *DbUtils
)

func GetDb added in v0.21.0

func GetDb() *DbUtils

init csv from file

func (*DbUtils) DelClient added in v0.21.0

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

func (*DbUtils) DelHost added in v0.21.0

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

func (*DbUtils) DelTask added in v0.21.0

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

func (*DbUtils) GetClient added in v0.21.0

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

func (*DbUtils) GetClientIdByVkey added in v0.21.0

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

func (*DbUtils) GetClientList added in v0.21.0

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

func (*DbUtils) GetHost added in v0.21.0

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

func (*DbUtils) GetHostById added in v0.21.0

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

func (*DbUtils) GetIdByVerifyKey added in v0.21.0

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

func (*DbUtils) GetInfoByHost added in v0.21.0

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

get key by host from x

func (*DbUtils) GetTask added in v0.21.0

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

func (*DbUtils) GetTaskByMd5Password added in v0.21.0

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

md5 password

func (*DbUtils) IsHostExist added in v0.21.0

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

func (*DbUtils) IsPubClient added in v0.21.0

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

func (*DbUtils) NewClient added in v0.21.0

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

func (*DbUtils) NewHost added in v0.21.0

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

func (*DbUtils) NewTask added in v0.21.0

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

func (*DbUtils) UpdateClient added in v0.21.0

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

func (*DbUtils) UpdateTask added in v0.21.0

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

func (*DbUtils) VerifyUserName added in v0.21.0

func (s *DbUtils) VerifyUserName(username string, id int) (res bool)

func (*DbUtils) VerifyVkey added in v0.21.0

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

type Flow

type Flow struct {
	ExportFlow int64
	InletFlow  int64
	FlowLimit  int64
	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 //host
	HeaderChange string //header change
	HostChange   string //host change
	Location     string //url router
	Remark       string //remark
	Scheme       string //http https all
	CertFilePath string
	KeyFilePath  string
	NoStore      bool
	IsClose      bool
	Flow         *Flow
	Client       *Client
	Target       *Target //目标
	Health       `json:"-"`
	sync.RWMutex
}

type JsonDb added in v0.21.0

type JsonDb struct {
	Tasks            sync.Map
	Hosts            sync.Map
	HostsTmp         sync.Map
	Clients          sync.Map
	RunPath          string
	ClientIncreaseId int32  //client increased id
	TaskIncreaseId   int32  //task increased id
	HostIncreaseId   int32  //host increased id
	TaskFilePath     string //task file path
	HostFilePath     string //host file path
	ClientFilePath   string //client file path
}

func NewJsonDb added in v0.21.0

func NewJsonDb(runPath string) *JsonDb

func (*JsonDb) GetClient added in v0.21.0

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

func (*JsonDb) GetClientId added in v0.21.0

func (s *JsonDb) GetClientId() int32

func (*JsonDb) GetHostId added in v0.21.0

func (s *JsonDb) GetHostId() int32

func (*JsonDb) GetTaskId added in v0.21.0

func (s *JsonDb) GetTaskId() int32

func (*JsonDb) LoadClientFromJsonFile added in v0.21.0

func (s *JsonDb) LoadClientFromJsonFile()

func (*JsonDb) LoadHostFromJsonFile added in v0.21.0

func (s *JsonDb) LoadHostFromJsonFile()

func (*JsonDb) LoadTaskFromJsonFile added in v0.21.0

func (s *JsonDb) LoadTaskFromJsonFile()

func (*JsonDb) StoreClientsToJsonFile added in v0.21.0

func (s *JsonDb) StoreClientsToJsonFile()

func (*JsonDb) StoreHostToJsonFile added in v0.21.0

func (s *JsonDb) StoreHostToJsonFile()

func (*JsonDb) StoreTasksToJsonFile added in v0.21.0

func (s *JsonDb) StoreTasksToJsonFile()

type MultiAccount added in v0.26.0

type MultiAccount struct {
	AccountMap map[string]string // multi account and pwd
}

type Pair added in v0.21.0

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

A data structure to hold a key/value pair.

type PairList added in v0.21.0

type PairList []*Pair

A slice of Pairs that implements sort.Interface to sort by Value.

func (PairList) Len added in v0.21.0

func (p PairList) Len() int

func (PairList) Less added in v0.21.0

func (p PairList) Less(i, j int) bool

func (PairList) Swap added in v0.21.0

func (p PairList) Swap(i, j int)

type Target added in v0.21.0

type Target struct {
	TargetStr  string
	TargetArr  []string
	LocalProxy bool
	sync.RWMutex
	// contains filtered or unexported fields
}

func (*Target) GetRandomTarget added in v0.21.0

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

type Tunnel

type Tunnel struct {
	Id           int
	Port         int
	ServerIp     string
	Mode         string
	Status       bool
	RunStatus    bool
	Client       *Client
	Ports        string
	Flow         *Flow
	Password     string
	Remark       string
	TargetAddr   string
	NoStore      bool
	LocalPath    string
	StripPre     string
	Target       *Target
	MultiAccount *MultiAccount
	Health
	sync.RWMutex
}

Jump to

Keyboard shortcuts

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