file

package
v0.0.15 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2019 License: MIT Imports: 12 Imported by: 12

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

	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) GetId

func (s *Client) GetId() int

type Config

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

func DeepCopyConfig

func DeepCopyConfig(c *Config) *Config

深拷贝Config

type Csv

type Csv struct {
	Tasks            []*Tunnel
	Path             string
	Hosts            []*Host   //域名列表
	Clients          []*Client //客户端
	RunPath          string    //存储根目录
	ClientIncreaseId int       //客户端id
	TaskIncreaseId   int       //任务自增ID
	HostIncreaseId   int
	sync.Mutex
}
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) GetTaskId

func (s *Csv) GetTaskId() int

func (*Csv) Init

func (s *Csv) Init()

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)

func (*Csv) NewHost

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

func (*Csv) NewTask

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

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

type Flow

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

func (*Flow) Add

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

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

func (*Host) GetRandomTarget

func (s *Host) GetRandomTarget() string

type Tunnel

type Tunnel struct {
	Id        int     //Id
	Port      int     //服务端监听端口
	Mode      string  //启动方式
	Target    string  //目标
	Status    bool    //设置是否开启
	RunStatus bool    //当前运行状态
	Client    *Client //所属客户端id
	Ports     string  //客户端与服务端传递
	Flow      *Flow
	Remark    string //备注
	NoStore   bool
}

Jump to

Keyboard shortcuts

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