Documentation
¶
Index ¶
- Constants
- type AcceptClientConnect
- type ActionProxy
- type Agent
- type AgentMessageCallbackFunc
- type AgentStream
- type Auth
- type Config
- type ManagePlatform
- func (mgr *ManagePlatform) ConnectToPlatform()
- func (mgr *ManagePlatform) GetServer(clientId string) *server.Server
- func (mgr *ManagePlatform) GetServerSocket(clientId string) *network.Socket
- func (mgr *ManagePlatform) Hearts()
- func (mgr *ManagePlatform) ListenAgentConnect(onAcceptSocket, onDisconnect network.SocketCallbackFunc) error
- func (mgr *ManagePlatform) OnClosed() error
- func (mgr *ManagePlatform) OnClosing() bool
- type PlatformActionInfo
- type ProxyInfo
- type Requst
- type Socket
- func (a *Socket) Close() error
- func (a *Socket) LocalAddr() net.Addr
- func (a *Socket) ReadFrom(p []byte) (int, net.Addr, error)
- func (a *Socket) SetDeadline(t time.Time) error
- func (a *Socket) SetReadDeadline(t time.Time) error
- func (a *Socket) SetWriteDeadline(t time.Time) error
- func (a *Socket) WriteTo(p []byte, addr net.Addr) (int, error)
Constants ¶
View Source
const ( ACTION_REG = "register" AGENT_PKG_SIZE = 4096 AGENT_HEAD_SIZE = 4 AGENT_PEER_SIZE = 16 PROXY_MAGIC = "CGTW" PROXY_FLAG_DEST_SVR = 0x01 PROXY_FLAG_AUTH_REQ = 0x02 PROXY_FLAG_AUTH_SYN = 0x04 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AcceptClientConnect ¶
type AcceptClientConnect func(chan AgentStream)
type ActionProxy ¶
type ActionProxy struct {
Success interface{} `json:"success"`
Type string `json:"type"` // 一般是json
Action string `json:"action"`
Data ProxyInfo `json:"data"`
}
func (*ActionProxy) IsSuccess ¶
func (a *ActionProxy) IsSuccess() bool
type Agent ¶
type Agent struct {
//基础网络连接
NetConn net.PacketConn
//接入的会话列表
Socket *Socket
//当前代理的远程地址
RemoteAddress net.Addr
//当前主机的代理配置信息
Proxy *ProxyInfo
Server *server.Server
Config *Config
}
type AgentStream ¶
type ManagePlatform ¶
type ManagePlatform struct {
//用于串联代理中心和主机之间的通讯
AgentStreamChannel chan AgentStream
framework.CloseableObject
Agents map[int]*Agent
// contains filtered or unexported fields
}
func NewManagePlatform ¶
func NewManagePlatform(cfg *Config) *ManagePlatform
func (*ManagePlatform) ConnectToPlatform ¶
func (mgr *ManagePlatform) ConnectToPlatform()
func (*ManagePlatform) GetServer ¶
func (mgr *ManagePlatform) GetServer(clientId string) *server.Server
func (*ManagePlatform) GetServerSocket ¶
func (mgr *ManagePlatform) GetServerSocket(clientId string) *network.Socket
func (*ManagePlatform) Hearts ¶
func (mgr *ManagePlatform) Hearts()
func (*ManagePlatform) ListenAgentConnect ¶
func (mgr *ManagePlatform) ListenAgentConnect(onAcceptSocket, onDisconnect network.SocketCallbackFunc) error
func (*ManagePlatform) OnClosed ¶
func (mgr *ManagePlatform) OnClosed() error
func (*ManagePlatform) OnClosing ¶
func (mgr *ManagePlatform) OnClosing() bool
type PlatformActionInfo ¶
type PlatformActionInfo struct {
Action string `json:"action"`
From string `json:"from"`
Info utils.JsonObject `json:"info"`
}
PlatformActionInfo 连接管理平台的信息
type ProxyInfo ¶
type ProxyInfo struct {
ProxyIp string `json:"proxy_ip"`
ProxyPort string `json:"proxy_port"`
ProxyExternalIp string `json:"proxy_external_ip"` //管理平台的外网ip
ProxyExternalPort string `json:"proxy_external_port"` //管理平台的外网端口
ProxyAddr string //实际使用的地址
Idx int `json:"idx"`
AllowExternal bool `json:"allow_external" default:"false"` //是否允许外网连接
}
type Requst ¶
type Requst struct {
MgrAddr string `json:"mgr_addr"` // 管理平台的地址
Token string `json:"token"` // 管理平台的token
DevId string `json:"dev_id"` // 管理平台的dev_id
ProxyId string `json:"proxy_id"` // 管理平台的proxy_id
Proxy bool `json:"proxy"` // 是否代理
CliId string `json:"client_id"` // 客户端ID
NetType string // 网络类型
SvcType string // 服务地址
SvcAddr string `json:"service"` // 目标地址
LoAddr string `json:"lo_addr"` // 本地监听地址,此时需要设置 up_buf down_buf
UpBuf int `json:"up_buf"` // TCP的上行缓冲区大小,默认64KB,此大小会影响吞吐、延迟
DownBuf int `json:"down_buf"` // TCP的下行缓冲区大小,默认64KB,此大小会影响吞吐、延迟
}
Click to show internal directories.
Click to hide internal directories.