de

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
	DoType_Default               = "ZTDO"    //The DHP protocol enforces encryption by default, and its core data unit is the Zero Trust Data Object (ZTDO)。
	DoType_Other                 = "OTHER"
)

Variables

View Source
var (
	ExeDirPath string
)

Functions

func DecodeKey

func DecodeKey(encodedKey string) ([]byte, error)

Decode the Base64 encoded key into a byte array

func DecodeZtoFile

func DecodeZtoFile(ztdofileName string, decodeBase64Key string, newFileSaveDir string)

func EncodeToZtoFile

func EncodeToZtoFile(sourceFilePath string, targetZtdoFilePath string, ztoMetaInfo core.ZtdoMetaInfo) (zoId string, encryptionKey string)

EncodeToZtoFile * sourceFilePath: targetZtdoFilePath:

func GenerateKey

func GenerateKey() (string, error)

Generates a 256-bit random key and returns a Base64-encoded string

func ReadMetaFile

func ReadMetaFile(filePath string) (core.ZtdoMetaInfo, error)

read Meta file

func ReadPolicyFile

func ReadPolicyFile(filePath string) (common.DHPPolicy, error)

read Polic file

func WriteConfig

func WriteConfig(key string, objectId string) error

WriteConfig writes to etc/config.json file

Types

type Config

type Config struct {
	LogLevel            int
	PrivateKeyBase64    string
	DefaultCipherScheme int `json:"defaultCipherScheme"`
}

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 UdpConn

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

func (*UdpConn) Close

func (c *UdpConn) Close()

type UdpDevice

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

func (*UdpDevice) AddServer

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

func (*UdpDevice) GetServerPeer

func (a *UdpDevice) GetServerPeer() (serverPeer *core.UdpPeer)

get first server

func (*UdpDevice) IsRunning

func (a *UdpDevice) IsRunning() bool

func (*UdpDevice) RemoveServer

func (a *UdpDevice) RemoveServer(serverKey string)

func (*UdpDevice) ResolvePeer

func (a *UdpDevice) 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 (*UdpDevice) SendDHPRegister

func (a *UdpDevice) SendDHPRegister(doId string, policy common.DHPPolicy, dataKey string)

func (*UdpDevice) SendNHPDRG

func (a *UdpDevice) SendNHPDRG(server *core.UdpPeer, msg common.DRGMsg) bool

send NHP_DRG to NHP-Server

func (*UdpDevice) SendPacket

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

func (*UdpDevice) Start

func (a *UdpDevice) 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 (*UdpDevice) Stop

func (a *UdpDevice) Stop()

export Stop

func (*UdpDevice) StopConfigWatch

func (a *UdpDevice) StopConfigWatch()

type ZtdoConfig

type ZtdoConfig struct {
	EncryptionKey string `json:"encryptionKey"`
}

The Config structure is used to represent the structure of the configuration file

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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