core

package
v0.0.0-...-30bf9de Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2023 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	IPAddressNone = 0
	IPAddressIPv4 = 1
	IPAddressIPv6 = 2
	AddressSize   = 19
)
View Source
const AckBitsBytes = 32
View Source
const AckBytes = 8
View Source
const AddressBytes = 19
View Source
const ChallengePacket = byte(1)
View Source
const ChallengeTokenBytes = 8 + AddressBytes + 8
View Source
const ChonkleBytes = 15
View Source
const ConnectTokenExpireSeconds = 20
View Source
const EncryptedChallengeTokenBytes = NonceBytes_SecretBox + ChallengeTokenBytes + HMACBytes_SecretBox
View Source
const EnvelopeBytes = 8
View Source
const EthernetHeaderBytes = 18
View Source
const FlagsBytes = 1
View Source
const Flags_ChallengeToken = (1 << 0)
View Source
const GatewayIdBytes = 32
View Source
const HMACBytes_Box = 16
View Source
const HMACBytes_SecretBox = 16
View Source
const IPv4HeaderBytes = 18
View Source
const MagicBytes = 8
View Source
const MinPayloadBytes = 1000
View Source
const NonceBytes_Box = 24
View Source
const NonceBytes_SecretBox = 24
View Source
const PacketTypeBytes = 1
View Source
const PacketsPerSecondBytes = 1
View Source
const PayloadPacket = byte(0)
View Source
const PittleBytes = 2
View Source
const PostfixBytes = HMACBytes_Box + PittleBytes
View Source
const PrivateKeyBytes_Box = 32
View Source
const PrivateKeyBytes_SecretBox = 32
View Source
const PublicKeyBytes_Box = 32
View Source
const SequenceBytes = 8
View Source
const ServerIdBytes = 32
View Source
const SessionIdBytes = 32
View Source
const SessionTokenExtensionSeconds = 10
View Source
const UDPHeaderBytes = 8
View Source
const UserIdBytes = 32
View Source
const VersionBytes = 1

Variables

This section is empty.

Functions

func AddressEqual

func AddressEqual(a *net.UDPAddr, b *net.UDPAddr) bool

func AdvancedPacketFilter

func AdvancedPacketFilter(data []byte, magic []byte, fromAddress []byte, fromPort uint16, toAddress []byte, toPort uint16, packetLength int) bool

func BasicPacketFilter

func BasicPacketFilter(packetData []byte, packetLength int) bool

func Debug

func Debug(s string, params ...interface{})

func Decrypt_Box

func Decrypt_Box(senderPublicKey []byte, receiverPrivateKey []byte, nonce []byte, buffer []byte, bytes int) error

func Decrypt_SecretBox

func Decrypt_SecretBox(privateKey []byte, nonce []byte, buffer []byte, bytes int) error

func Encrypt_Box

func Encrypt_Box(senderPrivateKey []byte, receiverPublicKey []byte, nonce []byte, buffer []byte, bytes int) int

func Encrypt_SecretBox

func Encrypt_SecretBox(privateKey []byte, nonce []byte, buffer []byte, bytes int) int

func Error

func Error(s string, params ...interface{})

func GenerateChonkle

func GenerateChonkle(output []byte, magic []byte, fromAddressData []byte, fromPort uint16, toAddressData []byte, toPort uint16, packetLength int)

func GenerateConnectToken

func GenerateConnectToken(userId []byte, envelopeUpKbps uint32, envelopeDownKbps uint32, packetsPerSecond uint8, gatewayAddress *net.UDPAddr, gatewayPublicKey []byte, senderPrivateKey []byte, receiverPublicKey []byte) []byte

func GeneratePittle

func GeneratePittle(output []byte, fromAddress []byte, fromPort uint16, toAddress []byte, toPort uint16, packetLength int)

func GetAckBits

func GetAckBits(latestReceivedSequence uint64, receivedPackets []uint64, ack_bits []byte)

func GetAddressData

func GetAddressData(address *net.UDPAddr, addressData []byte, addressPort *uint16)

func IdEqual

func IdEqual(a []byte, b []byte) bool

func IdString

func IdString(id []byte) string

func Info

func Info(s string, params ...interface{})

func Keygen_Box

func Keygen_Box() ([]byte, []byte)

func Keygen_SecretBox

func Keygen_SecretBox() []byte

func PacketBytesFromPayload

func PacketBytesFromPayload(payloadBytes int) int

func ParseAddress

func ParseAddress(input string) *net.UDPAddr

func ProcessAcks

func ProcessAcks(ackSequence uint64, ack_bits []byte, ackedPackets []uint64, ackBuffer []uint64) []uint64

func RandomBytes

func RandomBytes(bytes int) []byte

func RandomBytes_InPlace

func RandomBytes_InPlace(buffer []byte)

func ReadAddress

func ReadAddress(buffer []byte, index *int, address *net.UDPAddr) bool

func ReadBool

func ReadBool(data []byte, index *int, value *bool) bool

func ReadBytes

func ReadBytes(data []byte, index *int, value []byte, bytes uint32) bool

func ReadChallengeToken

func ReadChallengeToken(buffer []byte, index *int, token *ChallengeToken) bool

func ReadConnectData

func ReadConnectData(buffer []byte, index *int, connectData *ConnectData) bool

func ReadEncryptedChallengeToken

func ReadEncryptedChallengeToken(buffer []byte, index *int, token *ChallengeToken, privateKey []byte) bool

func ReadEncryptedSessionToken

func ReadEncryptedSessionToken(buffer []byte, index *int, token *SessionToken, senderPublicKey []byte, receiverPrivateKey []byte) bool

func ReadFloat32

func ReadFloat32(data []byte, index *int, value *float32) bool

func ReadFloat64

func ReadFloat64(data []byte, index *int, value *float64) bool

func ReadSessionToken

func ReadSessionToken(buffer []byte, index *int, token *SessionToken) bool

func ReadString

func ReadString(data []byte, index *int, value *string, maxStringLength uint32) bool

func ReadUint16

func ReadUint16(data []byte, index *int, value *uint16) bool

func ReadUint32

func ReadUint32(data []byte, index *int, value *uint32) bool

func ReadUint64

func ReadUint64(data []byte, index *int, value *uint64) bool

func ReadUint8

func ReadUint8(data []byte, index *int, value *uint8) bool

func WirePacketBits

func WirePacketBits(packetBytes int) int

func WriteAddress

func WriteAddress(buffer []byte, index *int, address *net.UDPAddr)

func WriteBool

func WriteBool(data []byte, index *int, value bool)

func WriteBytes

func WriteBytes(data []byte, index *int, value []byte, numBytes int)

func WriteChallengeToken

func WriteChallengeToken(buffer []byte, index *int, token *ChallengeToken)

func WriteConnectData

func WriteConnectData(buffer []byte, index *int, connectData *ConnectData)

func WriteEncryptedChallengeToken

func WriteEncryptedChallengeToken(buffer []byte, index *int, token *ChallengeToken, privateKey []byte)

func WriteEncryptedSessionToken

func WriteEncryptedSessionToken(buffer []byte, index *int, token *SessionToken, senderPrivateKey []byte, receiverPublicKey []byte)

func WriteFloat32

func WriteFloat32(data []byte, index *int, value float32)

func WriteFloat64

func WriteFloat64(data []byte, index *int, value float64)

func WriteSessionToken

func WriteSessionToken(buffer []byte, index *int, token *SessionToken)

func WriteString

func WriteString(data []byte, index *int, value string, maxStringLength uint32)

func WriteUint16

func WriteUint16(data []byte, index *int, value uint16)

func WriteUint32

func WriteUint32(data []byte, index *int, value uint32)

func WriteUint64

func WriteUint64(data []byte, index *int, value uint64)

func WriteUint8

func WriteUint8(data []byte, index *int, value uint8)

Types

type ChallengeToken

type ChallengeToken struct {
	ExpireTimestamp uint64
	ClientAddress   net.UDPAddr
	GatewayAddress  net.UDPAddr
	Sequence        uint64
}

type ConnectData

type ConnectData struct {
	ClientPublicKey  [PublicKeyBytes_Box]byte
	ClientPrivateKey [PrivateKeyBytes_Box]byte
	GatewayAddress   net.UDPAddr
	GatewayPublicKey [PublicKeyBytes_Box]byte
	EnvelopeUpKbps   uint32
	EnvelopeDownKbps uint32
	PacketsPerSecond uint8
}

type SessionToken

type SessionToken struct {
	ExpireTimestamp  uint64
	SessionId        [SessionIdBytes]byte
	UserId           [UserIdBytes]byte
	EnvelopeUpKbps   uint32
	EnvelopeDownKbps uint32
	PacketsPerSecond uint8
}

Jump to

Keyboard shortcuts

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