msgsess

package
v0.0.0-...-d81ffa1 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package msgsess contains session message definitions and parsing methods, to be sent over relay or directly.

Session message interface definitions are sealed within this package.

Index

Constants

View Source
const (
	PingMessage       = MessageType(0x00)
	PongMessage       = MessageType(0x01)
	RendezvousMessage = MessageType(0xFF)
)
View Source
const NaclBoxNonceLen = 24

Variables

Magic is the 8 byte header of all session messages "🪄🧦" F0 9F AA 84 F0 9F A7 A6

View Source
var MagicBytes = []byte{0xF0, 0x9F, 0xAA, 0x84, 0xF0, 0x9F, 0xA7, 0xA6}

Functions

func LooksLikeSessionWireMessage

func LooksLikeSessionWireMessage(pkt []byte) bool

Types

type ClearMessage

type ClearMessage struct {
	Session key.SessionPublic

	Message SessionMessage
}

ClearMessage represents a full session wire message in decrypted view

type MessageType

type MessageType byte

type Ping

type Ping struct {
	TxID TxID

	// Allegedly the sender's nodekey address
	NodeKey key.NodePublic

	// TODO implement padding
	Padding int
}

func (*Ping) Debug

func (p *Ping) Debug() string

func (*Ping) MarshalSessionMessage

func (p *Ping) MarshalSessionMessage() []byte

type Pong

type Pong struct {
	TxID [12]byte

	Src netip.AddrPort // 18 bytes (16+2) on the wire; v4-mapped ipv6 for IPv4
}

func (*Pong) Debug

func (p *Pong) Debug() string

func (*Pong) MarshalSessionMessage

func (p *Pong) MarshalSessionMessage() []byte

type Rendezvous

type Rendezvous struct {
	MyAddresses []netip.AddrPort
}

func (*Rendezvous) Debug

func (r *Rendezvous) Debug() string

func (*Rendezvous) MarshalSessionMessage

func (r *Rendezvous) MarshalSessionMessage() []byte

type SessionMessage

type SessionMessage interface {
	MarshalSessionMessage() []byte

	// todo maybe convert to slog.Group?
	Debug() string
}

func ParseSessionMessage

func ParseSessionMessage(usrMsg []byte) (SessionMessage, error)

type TxID

type TxID [12]byte

func NewTxID

func NewTxID() TxID

type VersionMarker

type VersionMarker byte

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳