protocol

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Version         = "gonzb-connect/1.0"
	MessageOffer    = "offer"
	MessageAnswer   = "answer"
	MessageConnect  = "connect"
	MessageError    = "error"
	MaxMessageBytes = 128 << 10
)

Variables

This section is empty.

Functions

func NodeIDFromPublicKey

func NodeIDFromPublicKey(publicKey ed25519.PublicKey) string

func ValidNodeID

func ValidNodeID(value string) bool

Types

type Envelope

type Envelope struct {
	ProtocolVersion string `json:"protocol_version"`
	MessageType     string `json:"message_type"`
	SessionID       string `json:"session_id"`
	SourceNodeID    string `json:"source_node_id"`
	TargetNodeID    string `json:"target_node_id"`
	CreatedAt       string `json:"created_at"`
	ExpiresAt       string `json:"expires_at"`
	Nonce           string `json:"nonce"`
	PayloadSHA256   string `json:"payload_sha256"`
	SourcePublicKey string `json:"source_public_key"`
	Payload         string `json:"payload"`
	Signature       string `json:"signature"`
}

Envelope signs the hash of the exact SDP payload, not a re-encoded form. Coordinators inspect routing metadata but never need to parse Payload.

func NewEnvelope

func NewEnvelope(ctx context.Context, signer Signer, messageType, sessionID, targetNodeID, payload string, now time.Time, ttl time.Duration) (Envelope, error)

func (Envelope) Verify

func (e Envelope) Verify(now time.Time, tolerance time.Duration) (ed25519.PublicKey, error)

type ReplayCache

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

func NewReplayCache

func NewReplayCache() *ReplayCache

func NewReplayCacheWithLimit

func NewReplayCacheWithLimit(limit int) *ReplayCache

func (*ReplayCache) Consume

func (r *ReplayCache) Consume(sourceNodeID, nonce string, expiresAt, now time.Time) bool

type Signer

type Signer interface {
	NodeID(context.Context) (string, error)
	PublicKey(context.Context) (ed25519.PublicKey, error)
	Sign(context.Context, []byte) ([]byte, error)
}

Jump to

Keyboard shortcuts

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