agent

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2025 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxConcurrentConnection      = 256
	DefaultConnectionTimeoutMs   = 30 * 1000 // 30 seconds to delete idle connection
	PacketQueueSizePerConnection = 8         // nhp agent does not need large transactions
)

Variables

View Source
var (
	ExeDirPath string
)

Functions

This section is empty.

Types

type Config

type Config struct {
	LogLevel            int    `json:"logLevel"`
	DefaultCipherScheme int    `json:"defaultCipherScheme"`
	PrivateKeyBase64    string `json:"privateKey"`
	KnockUser           `mapstructure:",squash"`
	DHPExeCMD           string
}

type KnockResource

type KnockResource struct {
	AuthServiceId string `json:"aspId"`
	ResourceId    string `json:"resId"`
	ServerAddr    string `json:"serverAddr"`
}

func (*KnockResource) Id

func (res *KnockResource) Id() string

type KnockTarget

type KnockTarget struct {
	sync.Mutex
	KnockResource
	ServerPeer           *core.UdpPeer
	LastKnockSuccessTime time.Time
}

func (*KnockTarget) Server

func (kt *KnockTarget) Server() *core.UdpPeer

func (*KnockTarget) SetResource

func (kt *KnockTarget) SetResource(res *KnockResource)

func (*KnockTarget) SetServer

func (kt *KnockTarget) SetServer(peer *core.UdpPeer)

type KnockUser

type KnockUser struct {
	UserId         string
	OrganizationId string
	UserData       map[string]any
}

type Peers

type Peers struct {
	Servers []*core.UdpPeer
}

type Resources

type Resources struct {
	Resources []*KnockResource
}

type UdpAgent

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

func (*UdpAgent) AddResource

func (a *UdpAgent) AddResource(res *KnockResource) error

func (*UdpAgent) AddServer

func (a *UdpAgent) AddServer(server *core.UdpPeer)

func (*UdpAgent) ExitKnockRequest

func (a *UdpAgent) ExitKnockRequest(res *KnockTarget) (ackMsg *common.ServerKnockAckMsg, err error)

func (*UdpAgent) FindServerPeerFromResource

func (a *UdpAgent) FindServerPeerFromResource(res *KnockResource) *core.UdpPeer

func (*UdpAgent) GetFirstServerPeer added in v0.4.1

func (a *UdpAgent) GetFirstServerPeer() (serverPeer *core.UdpPeer)

func (*UdpAgent) HandleCookieMessage

func (a *UdpAgent) HandleCookieMessage(ppd *core.PacketParserData) bool

func (*UdpAgent) IsRunning

func (a *UdpAgent) IsRunning() bool

func (*UdpAgent) Knock

func (a *UdpAgent) Knock(res *KnockTarget) (ackMsg *common.ServerKnockAckMsg, err error)

func (*UdpAgent) ListResource

func (a *UdpAgent) ListResource(target *KnockTarget) (lrtMsg *common.ServerListResultMsg, err error)

func (*UdpAgent) RegisterPublicKey

func (a *UdpAgent) RegisterPublicKey(otp string, target *KnockTarget) (rakMsg *common.ServerRegisterAckMsg, err error)

func (*UdpAgent) RemoveResource

func (a *UdpAgent) RemoveResource(aspId string, resId string)

func (*UdpAgent) RemoveServer

func (a *UdpAgent) RemoveServer(serverKey string)

func (*UdpAgent) RequestOtp

func (a *UdpAgent) RequestOtp(target *KnockTarget) error

func (*UdpAgent) ResolvePeer

func (a *UdpAgent) ResolvePeer(peer *core.UdpPeer) (*core.UdpPeer, net.Addr)

if the server uses hostname as destination, find the correct peer with the actual IP address

func (*UdpAgent) SendDARMsgToServer added in v0.4.1

func (a *UdpAgent) SendDARMsgToServer(server *core.UdpPeer, msg common.DARMsg, ztdo string, output string) bool

func (*UdpAgent) SendPacket

func (a *UdpAgent) SendPacket(pkt *core.Packet, conn *UdpConn) (n int, err error)

func (*UdpAgent) SetCheckResults

func (a *UdpAgent) SetCheckResults(results map[string]any)

func (*UdpAgent) SetDeviceId

func (a *UdpAgent) SetDeviceId(devId string)

func (*UdpAgent) SetKnockUser

func (a *UdpAgent) SetKnockUser(usrId string, orgId string, userData map[string]any)

func (*UdpAgent) Start

func (a *UdpAgent) Start(dirPath string, logLevel int) (err error)

dirPath: the path of app or shared library entry point logLevel: 0: silent, 1: error, 2: info, 3: debug, 4: verbose

func (*UdpAgent) StartDecodeZtdo added in v0.4.1

func (a *UdpAgent) StartDecodeZtdo(ztdo string, output string)

Convert ztdo file to Source file * ztdo: Ztdo file path output: Decrypted file output path

func (*UdpAgent) StartKnockLoop

func (a *UdpAgent) StartKnockLoop() int

func (*UdpAgent) Stop

func (a *UdpAgent) Stop()

export Stop

func (*UdpAgent) StopConfigWatch

func (a *UdpAgent) StopConfigWatch()

func (*UdpAgent) StopKnockLoop

func (a *UdpAgent) StopKnockLoop()

type UdpConn

type UdpConn struct {
	ConnData *core.ConnectionData
	// contains filtered or unexported fields
}

func (*UdpConn) Close

func (c *UdpConn) Close()

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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