websocket

package
v0.0.0-...-489b733 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2024 License: NIST-PD-fallback Imports: 5 Imported by: 0

Documentation

Overview

Package websocket parses WebSocket frames out of TCP payload.

Index

Constants

View Source
const (
	FlagFin  = 0x80
	OpBinary = 0x02
)

WebSocket flags and opcodes.

Variables

This section is empty.

Functions

func AnonymizeXForwardedFor

func AnonymizeXForwardedFor(p []byte)

AnonymizeXForwardedFor recognizes an UPGRADE request and anonymizes IP address enclosed in X-Forwarded-For header. Initial 24 bits of IPv4 address and 48 bits of IPv6 address are kept; later bits are set to zeros.

Types

type Frame

type Frame struct {
	FlagOp     uint8
	MaskingKey []byte
	Payload    []byte
}

Frame contains a WebSocket frame.

func ExtractBinaryFrames

func ExtractBinaryFrames(input []byte) (frames []Frame, e error)

ExtractBinaryFrames extracts unfragmented binary frames from TCP payload. Returns the first error encountered; extracted frames are still valid.

func (*Frame) Decode

func (f *Frame) Decode(input []byte) (rest []byte, e error)

Decode decodes a frame.

func (*Frame) Unmask

func (f *Frame) Unmask()

Unmask changes MaskingKey to zero and reveals the payload.

Jump to

Keyboard shortcuts

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