wire

package
v0.69.1 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AEADAlgorithmAES256GCM         = "aes-256-gcm"
	AEADAlgorithmXChaCha20Poly1305 = "xchacha20-poly1305"

	CryptoRandomSize = 32
)
View Source
const (
	ProtocolV1 = "v1"
	ProtocolV2 = "v2"

	WireVersionV2 = 2

	FrameTypeClientHello uint16 = 1
	FrameTypeServerHello uint16 = 2
	FrameTypeMessage     uint16 = 16

	MessageCodecJSON           = "json"
	DefaultMaxFramePayloadSize = 64 * 1024

	MagicV2 = "FRP\x00\x02\r\n"
)

Variables

This section is empty.

Functions

func CheckMagic

func CheckMagic(conn net.Conn) (out net.Conn, isV2 bool, err error)

func HashCryptoTranscript

func HashCryptoTranscript(clientHelloPayload, serverHelloPayload []byte) []byte

func IsSupportedAEADAlgorithm

func IsSupportedAEADAlgorithm(algorithm string) bool

func PreferredAEADAlgorithms

func PreferredAEADAlgorithms() []string

func SelectAEADAlgorithm

func SelectAEADAlgorithm(clientAlgorithms []string) (string, bool)

func Supports

func Supports(list []string, value string) bool

func ValidateClientHello

func ValidateClientHello(h ClientHello) error

func ValidateCryptoCapabilities

func ValidateCryptoCapabilities(c CryptoCapabilities) error

func ValidateServerHelloForClient

func ValidateServerHelloForClient(clientHello ClientHello, serverHello ServerHello) error

func WriteMagic

func WriteMagic(w io.Writer) error

func WriteMagicIfV2

func WriteMagicIfV2(w io.Writer, wireProtocol string) error

Types

type BootstrapInfo

type BootstrapInfo struct {
	Transport string `json:"transport,omitempty"`
	TLS       bool   `json:"tls,omitempty"`
	TCPMux    bool   `json:"tcpMux,omitempty"`
}

type ClientCapabilities

type ClientCapabilities struct {
	Message MessageCapabilities `json:"message,omitempty"`
	Crypto  CryptoCapabilities  `json:"crypto,omitempty"`
}

type ClientHello

type ClientHello struct {
	Bootstrap    BootstrapInfo      `json:"bootstrap,omitempty"`
	Capabilities ClientCapabilities `json:"capabilities,omitempty"`
}

func NewClientHello

func NewClientHello(bootstrap BootstrapInfo) (ClientHello, error)

type Conn

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

func NewConn

func NewConn(rw io.ReadWriter) *Conn

func (*Conn) ReadFrame

func (c *Conn) ReadFrame() (*Frame, error)

func (*Conn) ReadJSONFrame

func (c *Conn) ReadJSONFrame(frameType uint16, out any) error

func (*Conn) UnmarshalFrame

func (c *Conn) UnmarshalFrame(f *Frame, out any) error

func (*Conn) WriteFrame

func (c *Conn) WriteFrame(f *Frame) error

func (*Conn) WriteJSONFrame

func (c *Conn) WriteJSONFrame(frameType uint16, in any) error

type CryptoCapabilities

type CryptoCapabilities struct {
	Algorithms   []string `json:"algorithms,omitempty"`
	ClientRandom []byte   `json:"clientRandom,omitempty"`
}

type CryptoContext

type CryptoContext struct {
	Algorithm      string
	TranscriptHash []byte
}

func NewClientCryptoContext

func NewClientCryptoContext(clientHelloPayload, serverHelloPayload []byte) (*CryptoContext, error)

func NewCryptoContext

func NewCryptoContext(algorithm string, clientHelloPayload, serverHelloPayload []byte) *CryptoContext

type CryptoSelection

type CryptoSelection struct {
	Algorithm    string `json:"algorithm,omitempty"`
	ServerRandom []byte `json:"serverRandom,omitempty"`
}

type Frame

type Frame struct {
	Type    uint16
	Flags   uint16
	Payload []byte
}

func NewJSONFrame

func NewJSONFrame(frameType uint16, in any) (*Frame, error)

type MessageCapabilities

type MessageCapabilities struct {
	Codecs []string `json:"codecs,omitempty"`
}

type MessageSelection

type MessageSelection struct {
	Codec string `json:"codec,omitempty"`
}

type ServerHello

type ServerHello struct {
	Selected ServerSelection `json:"selected,omitempty"`
	Error    string          `json:"error,omitempty"`
}

func DefaultServerHello

func DefaultServerHello() ServerHello

func NewServerHello

func NewServerHello(clientHello ClientHello) (ServerHello, error)

type ServerSelection

type ServerSelection struct {
	Message MessageSelection `json:"message,omitempty"`
	Crypto  CryptoSelection  `json:"crypto,omitempty"`
}

Jump to

Keyboard shortcuts

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