file

package
v0.23.1 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2019 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetMapKeys

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
	sync.RWMutex
}

func NewClient

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

func (*Client) AddConn

func (s *Client) AddConn()

func (*Client) CutConn

func (s *Client) CutConn()

func (*Client) GetConn

func (s *Client) GetConn() bool

func (*Client) GetTunnelNum

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

func (*Client) HasHost

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

func (*Client) HasTunnel

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

type Config

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

type DbUtils

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

func GetDb

func GetDb() *DbUtils

init csv from file

func (*DbUtils) DelClient

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

func (*DbUtils) DelHost

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

func (*DbUtils) DelTask

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

func (*DbUtils) GetClient

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

func (*DbUtils) GetClientIdByVkey

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

func (*DbUtils) GetClientList

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

func (*DbUtils) GetHost

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

func (*DbUtils) GetHostById

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

func (*DbUtils) GetIdByVerifyKey

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

func (*DbUtils) GetInfoByHost

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

get key by host from x

func (*DbUtils) GetTask

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

func (*DbUtils) GetTaskByMd5Password

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

md5 password

func (*DbUtils) IsHostExist

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

func (*DbUtils) IsPubClient

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

func (*DbUtils) NewClient

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

func (*DbUtils) NewHost

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

func (*DbUtils) NewTask

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

func (*DbUtils) UpdateClient

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

func (*DbUtils) UpdateTask

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

func (*DbUtils) VerifyUserName

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

func (*DbUtils) VerifyVkey

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

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

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

func NewJsonDb(runPath string) *JsonDb

func (*JsonDb) GetClient

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

func (*JsonDb) GetClientId

func (s *JsonDb) GetClientId() int32

func (*JsonDb) GetHostId

func (s *JsonDb) GetHostId() int32

func (*JsonDb) GetTaskId

func (s *JsonDb) GetTaskId() int32

func (*JsonDb) LoadClientFromJsonFile

func (s *JsonDb) LoadClientFromJsonFile()

func (*JsonDb) LoadHostFromJsonFile

func (s *JsonDb) LoadHostFromJsonFile()

func (*JsonDb) LoadTaskFromJsonFile

func (s *JsonDb) LoadTaskFromJsonFile()

func (*JsonDb) StoreClientsToJsonFile

func (s *JsonDb) StoreClientsToJsonFile()

func (*JsonDb) StoreHostToJsonFile

func (s *JsonDb) StoreHostToJsonFile()

func (*JsonDb) StoreTasksToJsonFile

func (s *JsonDb) StoreTasksToJsonFile()

type Pair

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

A data structure to hold a key/value pair.

type PairList

type PairList []*Pair

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

func (PairList) Len

func (p PairList) Len() int

func (PairList) Less

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

func (PairList) Swap

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

type Target

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

func (*Target) GetRandomTarget

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
	Health
	sync.RWMutex
}

Jump to

Keyboard shortcuts

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