Documentation
¶
Index ¶
Constants ¶
View Source
const ( MessageTypeRequest = iota MessageTypeResponse )
View Source
const ( // random nonce + unix epoch timestamp + type + AEAD tag RequestPacketSize = chacha20poly1305.NonceSizeX + 8 + 1 + chacha20poly1305.Overhead // random nonce + unix epoch timestamp + type + IP + port + AEAD tag ResponsePacketSize = chacha20poly1305.NonceSizeX + 8 + 1 + 16 + 2 + chacha20poly1305.Overhead )
View Source
const ( // MaxEpochDiff is the maximum allowed time difference between a received timestamp and system time. MaxEpochDiff = 30 // MaxTimeDiff is the maximum allowed time difference between a received timestamp and system time. MaxTimeDiff = MaxEpochDiff * time.Second // ReplayWindowDuration defines the amount of time during which a nonce check is necessary. ReplayWindowDuration = MaxTimeDiff * 2 )
Variables ¶
Functions ¶
func CheckUnixEpochTimestamp ¶
CheckUnixEpochTimestamp checks the Unix Epoch timestamp in the buffer and returns an error if the timestamp exceeds the allowed time difference from system time.
This function does not check buffer length. Make sure it's at least 8 bytes long.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client generates request packets and parses response packets.
func (*Client) ParseResponse ¶
ParseResponse parses the response packet and returns the client IP and port.
func (*Client) PutRequest ¶
PutRequest writes a request packet to the first RequestPacketSize bytes of the given buffer.
Click to show internal directories.
Click to hide internal directories.