core

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2024 License: Apache-2.0 Imports: 32 Imported by: 0

README

NHP-Device架构设计

  1. Device负责NHP报文与消息的转换。Device初始化时需要指定类型和私钥。Device视自身类型只对相应的包进行处理。

  2. 用于承载发送和接收报文的buffer比较大,所以由Device的内存Pool统一发放并回收(如果依赖于Go后台垃圾回收,高并发时会造成大量内存开销)。所以在开发时一定要注意buffer的分配Device.AllocatePoolPacket() 和回收Device.ReleasePoolPacket()

    • 报文buffer回收点位于
      • 发送报文被发送后(本地transaction除外)
      • 接收报文解析完毕时(远程transaction除外)
      • 本地或远程transaction线程停止时
  3. 上层逻辑调用接口SendMsgToPacket将消息转换成加密报文并发送到连接。

  4. 上层逻辑调用接口RecvPacketToMsg将加密报文解析成消息后放入DecryptedMsgQueue队列并等待处理(通常情况)。

    • 特殊情况:如果请求发起方已指定接收通道,解析后的消息会被送到请求方指定的消息通道ResponseMsgCh,而不放进常规消息队列进行排队。
  5. 交互(transaction):一次请求需要等待一次回复的操作称为交互。一次由Device发起的交互请求为本地交互(LocalTransaction),一次由Device接收到的交互请求为远程交互(RemoteTransaction)。由于回应报文需要继承请求报文生成的ChainKey,所以所有的交互分发由Device进行管理。

  6. 连接上下文(ConnectionData):由上层逻辑传入的与连接相关的所有信息,Device在加密消息后将报文发送到连接。一个连接可以进行多个transaction

  7. 在建立发送请求时,需要创建MsgAssembler结构体。

    • Agent和AC必须填写消息类型HeaderType、对端RemoteAddr、对端公钥PeerPk和消息明文Message(如无特殊情况都采用消息压缩)。将填写好的MsgAssembler发给各自的sendMessageRoutine() 即可进行新连接的建立或寻找已存在连接并进行转换后报文的发送。

    • Server必须填写消息类型HeaderType、连接上下文ConnData、对端公钥PeerPk和消息明文Message(如无特殊情况都采用消息压缩)。将填写好的MsgAssembler发给Device.SendMsgToPacket() 即可进行转换后报文的发送。

    • 如果存在交互,可以直接使用上一条获得的 *PacketParserData填入MsgAssembler结构体的PrevParserData字段,从而可以省略填写RemoteAddrConnDataPeerPk

    • 如果请求期待回复数据,需要创建一个接收PacketParserData的通道,并对MsgAssembler结构体的ResponseMsgCh字段赋值。

Documentation

Index

Constants

View Source
const (
	MaxMemoryUsage         = 1 * 1024 * 1024 * 1024 // 1GB
	PacketBufferSize       = 4096
	PacketBufferPoolSize   = MaxMemoryUsage / PacketBufferSize
	AllocateTimeToOverload = 2 // 2 seconds
	SendQueueSize          = 10240
	RecvQueueSize          = 10240
)

device

View Source
const (
	MinimalRecvIntervalMs  = 20  // millisecond
	ThreatCountBeforeBlock = 1   // block at 2nd attempt
	CookieRegenerateTime   = 120 // second
	CookieRoundTripTimeMs  = 20  // millisecond
)

session

View Source
const (
	AgentLocalTransactionResponseTimeoutMs  = 5 * 1000                                     // millisecond
	ServerLocalTransactionResponseTimeoutMs = AgentLocalTransactionResponseTimeoutMs - 300 // millisecond
	ACLocalTransactionResponseTimeoutMs     = ServerLocalTransactionResponseTimeoutMs      // millisecond

	RemoteTransactionProcessTimeoutMs = 10 * 1000 // millisecond
)

transaction

View Source
const (
	HeaderCommonSize      = 24
	HeaderSize            = 160
	HeaderSizeEx          = 224
	SymmetricKeySize      = 32
	PrivateKeySize        = 32
	PublicKeySize         = 32
	PublicKeySizeEx       = 64
	HashSize              = 32
	CookieSize            = 32
	TimestampSize         = 8
	GCMNonceSize          = 12
	GCMTagSize            = 16
	PublicKeyBase64Size   = 44
	PublicKeyBase64SizeEx = 88
)

packet

View Source
const (
	InitialChainKeyString = "NHP keygen v.20230421@clouddeep.cn"
	InitialHashString     = "NHP hashgen v.20230421@deepcloudsdp.com"
)

noise

View Source
const (
	CIPHER_SCHEME_CURVE int = iota
	CIPHER_SCHEME_GMSM
)
View Source
const (
	NHP_NO_DEVICE = iota
	NHP_AGENT
	NHP_SERVER
	NHP_AC
	NHP_RELAY
)
View Source
const (
	NHP_KPL = iota // general keepalive packet
	NHP_KNK        // agent sends knock to server
	NHP_ACK        // server replies knock status to agent
	NHP_AOP        // server asks ac for operation
	NHP_ART        // ac replies server for operation result
	NHP_LST        // agent requests server for listing services and applications
	NHP_LRT        // server replies to agent with services and applications result
	NHP_COK        // server sends cookie to agent
	NHP_RKN        // agent sends reknock to server
	NHP_RLY        // relay sends relayed packet to server
	NHP_AOL        // ac sends online status to server
	NHP_AAK        // server sends ack to ac after receving ac's online status
	NHP_OTP        // agent requests server for one-time-password
	NHP_REG        // agent asks server for registering
	NHP_RAK        // server sends back ack when agent registers correctly
	NHP_ACC        // agent sends to ac/resource for actual ip access
	NHP_EXT        // agent requests immediate disconnection
)
View Source
const (
	NHP_FLAG_EXTENDEDLENGTH = 1 << iota
	NHP_FLAG_COMPRESS
)

header flags (bit 0 - bit 11)

View Source
const (
	MinimalNSLookupTime = 300 // second
)

hostname resolve

View Source
const (
	MinimalPeerAddressHoldTime = 5 // second
)

peer

View Source
const (
	NHP_FLAG_SCHEME_GMSM = 0 << 12
)

cipher scheme combination (bit 11 - bit 15)

View Source
const ProtocolVersionMajor = 1

protocol

View Source
const ProtocolVersionMinor = 0

Variables

View Source
var (
	ErrSuccess = newError(C.ERR_NHP_SUCCESS, "")

	// device
	ErrCipherNotSupported = newError(C.ERR_NHP_CIPHER_NOT_SUPPORTED, "cipher scheme not supported")
	ErrNotApplicable      = newError(C.ERR_NHP_OPERATION_NOT_APPLICABLE, "operation not applicable")
	ErrCreateDeviceFailed = newError(C.ERR_NHP_CREATE_DEVICE_FAILED, "failed to create nhp device")
	ErrCloseDeviceFailed  = newError(C.ERR_NHP_CLOSE_DEVICE_FAILED, "attempt to close a non-initialized nhp device")
	ErrRuntimePanic       = newError(C.ERR_NHP_SDK_RUNTIME_PANIC, "runtime panic encountered")

	// initiator and encryption
	ErrEmptyPeerPublicKey      = newError(C.ERR_NHP_EMPTY_PEER_PUBLIC_KEY, "remote peer public key is not set")
	ErrEphermalECDHPeerFailed  = newError(C.ERR_NHP_EPHERMAL_ECDH_PEER_FAILED, "ephermal ECDH failed with peer")
	ErrDeviceECDHPeerFailed    = newError(C.ERR_NHP_DEVICE_ECDH_PEER_FAILED, "device ECDH failed with peer")
	ErrIdentityTooLong         = newError(C.ERR_NHP_IDENTITY_TOO_LONG, "identity exceeds max length")
	ErrDataCompressionFailed   = newError(C.ERR_NHP_DATA_COMPRESSION_FAILED, "data compression failed")
	ErrPacketSizeExceedsBuffer = newError(C.ERR_NHP_PACKET_SIZE_EXCEEDS_BUFFER, "packet size longer than send buffer")

	// responder and decryption
	ErrCloseConnection                = newError(C.ERR_NHP_CLOSE_CONNECTION, "disengage nhp access immediately")
	ErrIncorrectPacketSize            = newError(C.ERR_NHP_INCORRECT_PACKET_SIZE, "incorrect packet size")
	ErrMessageTypeNotMatchDevice      = newError(C.ERR_NHP_MESSAGE_TYPE_NOT_MATCH_DEVICE, "message type does not match device")
	ErrServerOverload                 = newError(C.ERR_NHP_SERVER_OVERLOAD, "the packet is dropped due to server overload")
	ErrHMACCheckFailed                = newError(C.ERR_NHP_HMAC_CHECK_FAILED, "HMAC validation failed")
	ErrServerHMACCheckFailed          = newError(C.ERR_NHP_SERVER_HMAC_CHECK_FAILED, "server HMAC validation failed")
	ErrDeviceECDHEphermalFailed       = newError(C.ERR_NHP_DEVICE_ECDH_EPHERMAL_FAILED, "device ECDH failed with ephermal")
	ErrPeerIdentityVerificationFailed = newError(C.ERR_NHP_PEER_IDENTITY_VERIFICATION_FAILED, "failed to verify peer's identity with apk")
	ErrAEADDecryptionFailed           = newError(C.ERR_NHP_AEAD_DECRYPTION_FAILED, "aead decryption failed")
	ErrDataDecompressionFailed        = newError(C.ERR_NHP_DATA_DECOMPRESSION_FAILED, "data decompression failed")
	ErrDeviceECDHObtainedPeerFailed   = newError(C.ERR_NHP_DEVICE_ECDH_OBTAINED_PEER_FAILED, "device ECDH failed with obtained peer")
	ErrServerRejectWithCookie         = newError(C.ERR_NHP_SERVER_REJECT_WITH_COOKIE, "server overload, stop processing packet and return cookie")
	ErrReplayPacketReceived           = newError(C.ERR_NHP_REPLAY_PACKET_RECEIVED, "received replay packet, drop")
	ErrFloodPacketReceived            = newError(C.ERR_NHP_FLOOD_PACKET_RECEIVED, "received flood packet, drop")
	ErrStalePacketReceived            = newError(C.ERR_NHP_STALE_PACKET_RECEIVED, "received stale packet, drop")
)

device sdk errors

Functions

func AeadFromKey

func AeadFromKey(t GcmTypeEnum, key *[SymmetricKeySize]byte) (aead cipher.AEAD)

func CBCDecryption

func CBCDecryption(t GcmTypeEnum, key *[SymmetricKeySize]byte, ciphertext []byte, inPlace bool) ([]byte, error)

func CBCEncryption

func CBCEncryption(t GcmTypeEnum, key *[SymmetricKeySize]byte, plaintext []byte, inPlace bool) ([]byte, error)

func ErrorToErrorNumber

func ErrorToErrorNumber(err error) int

func ErrorToString

func ErrorToString(err error) string

func HeaderTypeToDeviceType

func HeaderTypeToDeviceType(t int) int

func HeaderTypeToString

func HeaderTypeToString(t int) string

func IsZero

func IsZero(arr []byte) bool

func NewHash

func NewHash(t HashTypeEnum) (h hash.Hash)

func SetZero

func SetZero(arr []byte)

Types

type CipherSuite

type CipherSuite struct {
	Scheme   int
	EccType  EccTypeEnum
	HashType HashTypeEnum
	GcmType  GcmTypeEnum
}

func NewCipherSuite

func NewCipherSuite(scheme int) (ciphers *CipherSuite)

init cipher suite

type ConnectionData

type ConnectionData struct {
	// atomic data, keep 64bit(8-bytes) alignment for 32-bit system compatibility
	InitTime           int64 // local connection setup time. immutable after created
	LastRemoteSendTime int64
	LastLocalSendTime  int64
	LastLocalRecvTime  int64

	sync.Mutex
	sync.WaitGroup

	// common
	Device           *Device
	LocalAddr        *net.UDPAddr
	RemoteAddr       *net.UDPAddr
	CookieStore      *CookieStore
	TimeoutMs        int
	SendQueue        chan *Packet
	RecvQueue        chan *Packet
	BlockSignal      chan struct{}
	SetTimeoutSignal chan struct{}
	StopSignal       chan struct{}

	// remote transactions
	RemoteTransactionMutex sync.Mutex
	RemoteTransactionMap   map[uint64]*RemoteTransaction

	// specific
	RecvThreatCount int32
	// contains filtered or unexported fields
}

func (*ConnectionData) AddRemoteTransaction

func (c *ConnectionData) AddRemoteTransaction(t *RemoteTransaction)

RemoteTransaction

func (*ConnectionData) Close

func (c *ConnectionData) Close()

func (*ConnectionData) Equal

func (c *ConnectionData) Equal(other *ConnectionData) bool

func (*ConnectionData) FindRemoteTransaction

func (c *ConnectionData) FindRemoteTransaction(id uint64) *RemoteTransaction

func (*ConnectionData) ForwardInboundPacket

func (c *ConnectionData) ForwardInboundPacket(pkt *Packet)

func (*ConnectionData) ForwardOutboundPacket

func (c *ConnectionData) ForwardOutboundPacket(pkt *Packet)

func (*ConnectionData) IsClosed

func (c *ConnectionData) IsClosed() bool

func (*ConnectionData) SendBlockSignal

func (c *ConnectionData) SendBlockSignal()

func (*ConnectionData) SetTimeout

func (c *ConnectionData) SetTimeout(ms int)

type CookieStore

type CookieStore struct {
	CurrCookie     [CookieSize]byte
	PrevCookie     [CookieSize]byte
	LastCookieTime int64
}

func (*CookieStore) Clear

func (cs *CookieStore) Clear()

func (*CookieStore) Set

func (cs *CookieStore) Set(cookie []byte)

type Device

type Device struct {
	Overload atomic.Bool

	DecryptedMsgQueue chan *PacketParserData
	// contains filtered or unexported fields
}

func NewDevice

func NewDevice(t int, prk []byte, option *DeviceOptions) *Device

func (*Device) AddLocalTransaction

func (d *Device) AddLocalTransaction(t *LocalTransaction)

LocalTransaction

func (*Device) AddPeer

func (d *Device) AddPeer(peer Peer)

func (*Device) AllocatePoolPacket

func (d *Device) AllocatePoolPacket() *Packet

func (*Device) CheckRecvHeaderType

func (d *Device) CheckRecvHeaderType(t int) bool

func (*Device) FindLocalTransaction

func (d *Device) FindLocalTransaction(id uint64) *LocalTransaction

func (*Device) IsOverload

func (d *Device) IsOverload() bool

func (*Device) IsTransactionRequest

func (d *Device) IsTransactionRequest(t int) bool

func (*Device) IsTransactionResponse

func (d *Device) IsTransactionResponse(t int) bool

func (*Device) LocalTransactionTimeout

func (d *Device) LocalTransactionTimeout() int

func (*Device) LookupPeer

func (d *Device) LookupPeer(pk []byte) Peer

func (*Device) MsgToPacket

func (d *Device) MsgToPacket(md *MsgData) (mad *MsgAssemblerData, err error)

同步线性处理

func (*Device) NextCounterIndex

func (d *Device) NextCounterIndex() uint64

func (*Device) PacketToMsg

func (d *Device) PacketToMsg(pd *PacketData) (ppd *PacketParserData, err error)

同步线性处理

func (*Device) PublicKeyBase64

func (d *Device) PublicKeyBase64() string

func (*Device) PublicKeyExBase64

func (d *Device) PublicKeyExBase64() string

func (*Device) RecvPacketToMsg

func (d *Device) RecvPacketToMsg(pd *PacketData)

func (*Device) RecvPrecheck

func (d *Device) RecvPrecheck(pkt *Packet) (int, int, error)

func (*Device) ReleasePoolPacket

func (d *Device) ReleasePoolPacket(pkt *Packet)

func (*Device) RemoteTransactionTimeout

func (d *Device) RemoteTransactionTimeout() int

func (*Device) RemovePeer

func (d *Device) RemovePeer(pubKey string)

func (*Device) ResetPeers

func (d *Device) ResetPeers()

func (*Device) SendMsgToPacket

func (d *Device) SendMsgToPacket(md *MsgData)

func (*Device) SetOption

func (d *Device) SetOption(option DeviceOptions)

func (*Device) SetOverload

func (d *Device) SetOverload(overloaded bool)

func (*Device) Start

func (d *Device) Start()

func (*Device) Stop

func (d *Device) Stop()

type DeviceOptions

type DeviceOptions struct {
	DisableAgentPeerValidation  bool
	DisableServerPeerValidation bool
	DisableACPeerValidation     bool
	DisableRelayPeerValidation  bool
}

type DeviceTypeEnum

type DeviceTypeEnum = int

type EccTypeEnum

type EccTypeEnum int
const (
	ECC_CURVE25519 EccTypeEnum = iota
	ECC_SM2
	ECC_UMI
)

type Ecdh

type Ecdh interface {
	SetPrivateKey(prk []byte) error
	PrivateKey() []byte
	PublicKey() []byte
	SharedSecret(pbk []byte) []byte
	Name() string
	PrivateKeyBase64() string
	PublicKeyBase64() string
	Identity() []byte
	MidPublicKey() []byte
}

func ECDHFromKey

func ECDHFromKey(t EccTypeEnum, prk []byte) (e Ecdh)

func NewECDH

func NewECDH(t EccTypeEnum) (e Ecdh)

type Error

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

func ErrorCodeToError

func ErrorCodeToError(number int) *Error

func (*Error) Error

func (e *Error) Error() string

implment NhpError interface

func (*Error) ErrorCode

func (e *Error) ErrorCode() string

func (*Error) ErrorNumber

func (e *Error) ErrorNumber() int

func (*Error) SetExtraError

func (e *Error) SetExtraError(err error)

type GcmTypeEnum

type GcmTypeEnum int
const (
	GCM_AES256 GcmTypeEnum = iota
	GCM_SM4
	GCM_CHACHA20POLY1305
)

type HashTypeEnum

type HashTypeEnum int
const (
	HASH_BLAKE2S HashTypeEnum = iota
	HASH_SM3
	HASH_SHA256
)
type Header interface {
	SetTypeAndPayloadSize(int, int)
	TypeAndPayloadSize() (int, int)
	Size() int
	SetVersion(int, int)
	Version() (int, int)
	SetFlag(uint16)
	Flag() uint16
	SetCounter(uint64)
	Counter() uint64
	Bytes() []byte
	NonceBytes() []byte
	EphermeralBytes() []byte
	StaticBytes() []byte
	TimestampBytes() []byte
	IdentityBytes() []byte
	HMACBytes() []byte
}

type InitiatorScheme

type InitiatorScheme interface {
	CreateMsgAssemblerData(d *Device, md *MsgData) (mad *MsgAssemblerData, err error)
	DeriveMsgAssemblerDataFromPrevParserData(ppd *PacketParserData, t int, message []byte) (mad *MsgAssemblerData)
	SetPeerPublicKey(d *Device, mad *MsgAssemblerData, peerPk []byte) (err error)
	EncryptBody(d *Device, mad *MsgAssemblerData) (err error)
}

type LocalTransaction

type LocalTransaction struct {
	NextPacketCh  chan *Packet           // higher level entities should redirect packet to this channel
	ExternalMsgCh chan *PacketParserData // a channel to receive an external msg to complete the transaction
	// contains filtered or unexported fields
}

func (*LocalTransaction) Run

func (t *LocalTransaction) Run()

type MsgAssemblerData

type MsgAssemblerData struct {
	BasePacket *Packet

	LocalInitTime int64
	TransactionId uint64

	CipherScheme int
	HeaderType   int
	BodySize     int
	HeaderFlag   uint16
	BodyCompress bool

	ExternalCookie *[CookieSize]byte
	RemotePubKey   []byte

	ResponseMsgCh chan<- *PacketParserData
	Error         error
	// contains filtered or unexported fields
}

func (*MsgAssemblerData) Destroy

func (mad *MsgAssemblerData) Destroy()

type MsgData

type MsgData struct {
	RemoteAddr     *net.UDPAddr      // used by agent and ac create a new connection or pick an existing connection for msg sending
	ConnData       *ConnectionData   // used by server to pick an existing connection for msg sending
	PrevParserData *PacketParserData // when PrevParserData is set, RemoteAddr, ConnData, TransactionId and PeerPk will be overridden
	CipherScheme   int               // 0: curve25519/chacha20/blake2s, 1: sm2/sm4/sm3
	TransactionId  uint64
	HeaderType     int
	Compress       bool
	ExternalPacket *Packet
	ExternalCookie *[CookieSize]byte
	Message        []byte
	PeerPk         []byte
	EncryptedPktCh chan *MsgAssemblerData
	ResponseMsgCh  chan *PacketParserData
}

type NhpError

type NhpError interface {
	Error() string
	ErrorCode() string
	ErrorNumber() int
}

type NoiseFactory

type NoiseFactory struct {
	HashType HashTypeEnum
}

func (*NoiseFactory) HMAC1

func (n *NoiseFactory) HMAC1(dst *[HashSize]byte, key, in0 []byte)

func (*NoiseFactory) HMAC2

func (n *NoiseFactory) HMAC2(dst *[HashSize]byte, key, in0, in1 []byte)

func (*NoiseFactory) KeyGen1

func (n *NoiseFactory) KeyGen1(dst0 *[HashSize]byte, key, input []byte)

func (*NoiseFactory) KeyGen2

func (n *NoiseFactory) KeyGen2(dst0, dst1 *[HashSize]byte, key, input []byte)

func (*NoiseFactory) KeyGen3

func (n *NoiseFactory) KeyGen3(dst0, dst1, dst2 *[HashSize]byte, key, input []byte)

func (*NoiseFactory) MixHash

func (n *NoiseFactory) MixHash(dst *[HashSize]byte, key []byte, input []byte)

func (*NoiseFactory) MixKey

func (n *NoiseFactory) MixKey(dst *[SymmetricKeySize]byte, key []byte, input []byte)

type Packet

type Packet struct {
	Buf           *PacketBuffer
	HeaderType    int
	PoolAllocated bool
	KeepAfterSend bool // only applicable for sending
	Content       []byte
}

func (*Packet) Counter

func (pkt *Packet) Counter() uint64

func (*Packet) Flag

func (pkt *Packet) Flag() uint16

func (*Packet) HeaderTypeAndSize

func (pkt *Packet) HeaderTypeAndSize() (t int, s int)

type PacketBuffer

type PacketBuffer = [PacketBufferSize]byte

type PacketBufferPool

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

packet buffer pool

func (*PacketBufferPool) Get

func (bp *PacketBufferPool) Get() *PacketBuffer

must be called after Init()

func (*PacketBufferPool) Init

func (bp *PacketBufferPool) Init(max uint32)

func (*PacketBufferPool) Put

func (bp *PacketBufferPool) Put(packet *PacketBuffer)

must be called after Init()

type PacketData

type PacketData struct {
	BasePacket             *Packet
	ConnData               *ConnectionData
	PrevAssemblerData      *MsgAssemblerData
	ConnLastRemoteSendTime *int64
	ConnCookieStore        *CookieStore
	ConnPeerPublicKey      *[PublicKeySizeEx]byte
	InitTime               int64
	DecryptedMsgCh         chan *PacketParserData
}

type PacketParserData

type PacketParserData struct {
	ConnData     *ConnectionData
	CipherScheme int
	Ciphers      *CipherSuite

	LocalInitTime int64
	SenderTrxId   uint64

	HeaderType   int
	BodySize     int
	HeaderFlag   uint16
	BodyCompress bool
	Overload     bool

	SenderIdentity         []byte
	SenderMidPublicKey     []byte
	ConnLastRemoteSendTime *int64
	ConnCookieStore        *CookieStore
	ConnPeerPublicKey      *[PublicKeySizeEx]byte
	RemotePubKey           []byte
	BodyMessage            []byte

	Error error
	// contains filtered or unexported fields
}

func (*PacketParserData) Destroy

func (ppd *PacketParserData) Destroy()

func (*PacketParserData) IsAllowedAtOverload

func (ppd *PacketParserData) IsAllowedAtOverload() bool

type Peer

type Peer interface {
	DeviceType() int
	Name() string
	PublicKey() []byte
	PublicKeyBase64() string

	IsExpired() bool

	HostOrAddr() string
	SendAddr() net.Addr
	LastSendTime() int64
	UpdateSend(currTime int64)

	RecvAddr() net.Addr
	LastRecvTime() int64
	UpdateRecv(currTime int64, currAddr net.Addr)
	CheckRecvAddress(currTime int64, currAddr net.Addr) bool
}

type RemoteTransaction

type RemoteTransaction struct {
	NextMsgCh chan *MsgData // higher level entities should redirect message to this channel
	// contains filtered or unexported fields
}

func (*RemoteTransaction) Run

func (t *RemoteTransaction) Run()

type ResponderScheme

type ResponderScheme interface {
	CreatePacketParserData(d *Device, pd *PacketData) (ppd *PacketParserData, err error)
	DerivePacketParserDataFromPrevAssemblerData(mad *MsgAssemblerData, pkt *Packet, initTime int64) (ppd *PacketParserData)
	// contains filtered or unexported methods
}

type UdpPeer

type UdpPeer struct {
	sync.Mutex

	// immutable fields. Don't change them after creation
	PubKeyBase64 string `json:"pubKeyBase64"`
	Hostname     string `json:"host,omitempty"`
	Ip           string `json:"ip"`
	Port         int    `json:"port"`
	Type         int    `json:"type"`
	ExpireTime   int64  `json:"expireTime"`
	// contains filtered or unexported fields
}

func (*UdpPeer) CheckRecvAddress

func (p *UdpPeer) CheckRecvAddress(currTime int64, currAddr net.Addr) bool

a peer should not have multiple layer-4 addresses within its hold time

func (*UdpPeer) CopyResolveStatus

func (p *UdpPeer) CopyResolveStatus(other *UdpPeer)

func (*UdpPeer) DeviceType

func (p *UdpPeer) DeviceType() DeviceTypeEnum

func (*UdpPeer) HostOrAddr

func (p *UdpPeer) HostOrAddr() string

func (*UdpPeer) IsExpired

func (p *UdpPeer) IsExpired() bool

func (*UdpPeer) LastRecvTime

func (p *UdpPeer) LastRecvTime() int64

func (*UdpPeer) LastSendTime

func (p *UdpPeer) LastSendTime() int64

func (*UdpPeer) Name

func (p *UdpPeer) Name() string

func (*UdpPeer) PublicKey

func (p *UdpPeer) PublicKey() []byte

func (*UdpPeer) PublicKeyBase64

func (p *UdpPeer) PublicKeyBase64() string

func (*UdpPeer) RecvAddr

func (p *UdpPeer) RecvAddr() net.Addr

func (*UdpPeer) ResolvedIp

func (p *UdpPeer) ResolvedIp() string

func (*UdpPeer) SendAddr

func (p *UdpPeer) SendAddr() net.Addr

func (*UdpPeer) UpdateRecv

func (p *UdpPeer) UpdateRecv(currTime int64, currAddr net.Addr)

func (*UdpPeer) UpdateSend

func (p *UdpPeer) UpdateSend(currTime int64)

Directories

Path Synopsis
scheme

Jump to

Keyboard shortcuts

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