protocol

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package protocol defines the packet format and types for the P2P tunnel.

Index

Constants

View Source
const (
	TypeConnect uint8 = 0x01 // New TCP connection request
	TypeData    uint8 = 0x02 // TCP data payload
	TypeClose   uint8 = 0x03 // Connection close notification
)

Packet type constants.

View Source
const HeaderSize = 9

HeaderSize is the fixed header size: Type(1) + SocketID(4) + SeqNum(4).

Variables

This section is empty.

Functions

func Encode

func Encode(pkt *Packet) []byte

Encode serializes a Packet into a byte slice for DataChannel transmission.

Types

type Packet

type Packet struct {
	Type     uint8  // TypeConnect, TypeData, or TypeClose
	SocketID uint32 // Hashed identifier from 4-tuple
	SeqNum   uint32 // Per-socketID sequence number
	Payload  []byte // Only used for TypeData
}

Packet represents a tunnel protocol packet transmitted over the DataChannel.

func Decode

func Decode(data []byte) (*Packet, error)

Decode deserializes a byte slice into a Packet.

Jump to

Keyboard shortcuts

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