control_dto

package
v0.0.35 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AGENT_CMD_REGISTER uint8 = 1
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AgentCmdReq

type AgentCmdReq struct {
	MsgId     string `json:"msg_id"`
	Cmd       uint8  `json:"cmd"`
	AgentType uint8  `json:"agent_type"`
	AgentId   string `json:"agent_id"`
	Ts        int64  `json:"ts"`
	Msg       string `json:"msg"`
}

type AgentCmdResp

type AgentCmdResp struct {
	MsgId string `json:"msg_id"` // echo
	Cmd   uint8  `json:"cmd"`
	Ts    int64  `json:"ts"`
	Msg   string `json:"msg"`
	Error string `json:"error,omitempty"`
}

type AgentRegisterReq added in v0.0.31

type AgentRegisterReq struct {
	AgentId  string `json:"agent_id"`            // required, TODO: use uuid
	PubKey   string `json:"pub_key,omitempty"`   // optional, pop's pub key, may be generate by pop-controller
	RenewKey bool   `json:"renew_key,omitempty"` //
}

type AgentRegisterRespBase added in v0.0.31

type AgentRegisterRespBase struct {
	WgPublicKey  string `json:"public_key,omitempty"`  // [optional][connector/pop]agent's, controller 分配
	WgPrivateKey string `json:"private_key,omitempty"` // [optional][connector/pop]agent's, controller 分配

	AgentId string `json:"agent_id"`         // [required]connector id or pop id
	Access  bool   `json:"access,omitempty"` //
	Error   string `json:"error,omitempty"`  //
}

type AgentSelectedPopResp added in v0.0.31

type AgentSelectedPopResp struct {
	PopId        string `json:"pop_id"`                // pop id
	WgPublicKey  string `json:"public_key"`            // pop's public_key
	WgIP         string `json:"wg_ip"`                 // pop's wg IP
	WgNetwork    string `json:"network"`               // pop's network, cidr format: 10.0.0.1/24
	WgEndpoint   string `json:"endpoint"`              // pop's Endpoint
	WgPort       int    `json:"port"`                  // pop's listen port
	WgAllowedIPs string `json:"allowed_ips,omitempty"` //
	WgDNS        string `json:"dns,omitempty"`         //
}

client/connector 连接到的pop 信息,

type ClientCacheInfo added in v0.0.12

type ClientCacheInfo struct {
	IP        string `json:"ip"`         // CIDR format?
	PublicKey string `json:"public_key"` //
	ClientId  string `json:"client_id"`  // 可以是client-id/pop-id/connector-id
	Type      uint8  `json:"type"`       // pop/connector/client, pop service订阅消息,需要知道对端是什么类型,他没有访问数据库的权限

}

Client can be pop/connector/client 对pop而言,连接到当前pop的所有设备(包括client/pop/connector)都可以看做是pop的client 对client而言,一个client id同时只能有一个client在线,多个uid也不行, 需要UID的话,可以从db里面获取,而不是从cache里,handlerClientLogin 发生在登录的时候,可以拿到client对应的user的info

func (*ClientCacheInfo) GetClientAddCmd added in v0.0.12

func (c *ClientCacheInfo) GetClientAddCmd() (fullCmd, b64 string)

func (*ClientCacheInfo) GetClientB64 added in v0.0.12

func (c *ClientCacheInfo) GetClientB64() (raw, b64 string)

func (*ClientCacheInfo) GetClientWgPeer added in v0.0.12

func (c *ClientCacheInfo) GetClientWgPeer(toRemove bool) (peerConfig *wg_core.WgPeer, err error)

peer is client/connector/pop toRemove means peer is offline/session timeout/kickoff

type ConnectorRegisterResp

type ConnectorRegisterResp struct {
	AgentRegisterRespBase

	// pop's info
	Pop  AgentSelectedPopResp `json:"pop"`
	WgIP string               `json:"wg_ip"` // [required]connector's, controller 分配给 connector 的 wg IP
}

type PopRegisterIfaceResp

type PopRegisterIfaceResp struct {
	WgEndpoint   string `json:"endpoint"`              // required, public-ip:listen-port
	WgPort       int    `json:"port"`                  // required, pop's listen-port
	WgNetwork    string `json:"network"`               // required, wg ip pool, generate by pop-controller
	WgAllowedIps string `json:"allowed_ips,omitempty"` // required, generate by pop-controller
	WgDns        string `json:"dns,omitempty"`         // ?
	WgIP         string `json:"wg_ip"`                 // required, internal wg ip for wg client to connect, should be consist with Network
}

type PopRegisterResp

type PopRegisterResp struct {
	AgentRegisterRespBase

	WgInterfaces map[string]PopRegisterIfaceResp `json:"interfaces,omitempty"` // pop's
	Clients      []ClientCacheInfo               `json:"clients,omitempty"`    // include client/pop/connector
}

type WgClientConnResp added in v0.0.8

type WgClientConnResp struct {
	AgentRegisterRespBase

	// pop's info
	Pop    AgentSelectedPopResp `json:"pop"`
	WgIP   string               `json:"wg_ip"`            // [required]client's, controller 分配给client的 wg IP
	Groups []string             `json:"groups,omitempty"` //
}

Jump to

Keyboard shortcuts

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