Documentation
¶
Index ¶
- Constants
- Variables
- func AcquireIp(username, macAddr string) net.IP
- func CloseCSess(token string)
- func CloseSess(token string)
- func CopyStruct(a interface{}, b interface{}, fields ...string) (err error)
- func DelSess(token string)
- func DelSessByStoken(stoken string)
- func GenToken() string
- func LimitClient(user string, close bool) bool
- func ReleaseIp(ip net.IP, macAddr string)
- func Start()
- type ConnSession
- type LType
- type LimitRater
- type Online
- type Onlines
- type Payload
- type Session
Constants ¶
View Source
const BandwidthPeriodSec = 2 // 流量速率统计周期(秒)
View Source
const MaxMtu = 1460
Variables ¶
View Source
var (
IpPool = &ipPoolConfig{}
)
Functions ¶
func CloseCSess ¶ added in v0.1.0
func CloseCSess(token string)
func CopyStruct ¶
用b的所有字段覆盖a的 如果fields不为空, 表示用b的特定字段覆盖a的 a应该为结构体指针
func DelSessByStoken ¶
func DelSessByStoken(stoken string)
func LimitClient ¶
Types ¶
type ConnSession ¶
type ConnSession struct {
Sess *Session
MasterSecret string // dtls协议的 master_secret
IpAddr net.IP // 分配的ip地址
LocalIp net.IP
MacHw net.HardwareAddr // 客户端mac地址,从Session取出
RemoteAddr string
Mtu int
TunName string
Client string // 客户端 mobile pc
CstpDpd int
Group *dbdata.Group
Limit *LimitRater
BandwidthUp uint32 // 使用上行带宽 Byte
BandwidthDown uint32 // 使用下行带宽 Byte
BandwidthUpPeriod uint32 // 前一周期的总量
BandwidthDownPeriod uint32
BandwidthUpAll uint32 // 使用上行带宽总量
BandwidthDownAll uint32 // 使用下行带宽总量
CloseChan chan struct{}
PayloadIn chan *Payload
PayloadOut chan *Payload
// contains filtered or unexported fields
}
连接sess
func (*ConnSession) Close ¶
func (cs *ConnSession) Close()
func (*ConnSession) SetMtu ¶
func (cs *ConnSession) SetMtu(mtu string)
func (*ConnSession) SetTunName ¶
func (cs *ConnSession) SetTunName(name string)
type LimitRater ¶
type LimitRater struct {
// contains filtered or unexported fields
}
type Online ¶
type Online struct {
Token string `json:"token"`
Username string `json:"username"`
Group string `json:"group"`
MacAddr string `json:"mac_addr"`
Ip net.IP `json:"ip"`
RemoteAddr string `json:"remote_addr"`
TunName string `json:"tun_name"`
Mtu int `json:"mtu"`
Client string `json:"client"`
BandwidthUp string `json:"bandwidth_up"`
BandwidthDown string `json:"bandwidth_down"`
BandwidthUpAll string `json:"bandwidth_up_all"`
BandwidthDownAll string `json:"bandwidth_down_all"`
LastLogin time.Time `json:"last_login"`
}
func OnlineSess ¶
func OnlineSess() []Online
type Session ¶
type Session struct {
Sid string // auth返回的 session-id
Token string // session信息的唯一token
DtlsSid string // dtls协议的 session_id
MacAddr string // 客户端mac地址
UniqueIdGlobal string // 客户端唯一标示
Username string // 用户名
Group string
AuthStep string
AuthPass string
LastLogin time.Time
IsActive bool
// 开启link需要设置的参数
CSess *ConnSession
// contains filtered or unexported fields
}
func NewSession ¶
func SToken2Sess ¶
func Token2Sess ¶
func (*Session) NewConn ¶
func (s *Session) NewConn() *ConnSession
Click to show internal directories.
Click to hide internal directories.