protocol

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2026 License: AGPL-3.0 Imports: 53 Imported by: 0

Documentation

Index

Constants

View Source
const KeepAliveProtoBit byte = 0x20
View Source
const SpliceProtoBit byte = 0x80

Variables

View Source
var ErrSwitchRaw = errors.New("whispera: framed switched to raw")

Functions

func AppendShapePad added in v0.0.6

func AppendShapePad(out []byte, n int) []byte

func AuthToken

func AuthToken(authKey []byte, window int64, sessionID []byte) string

func Client

func Client(ctx context.Context, cfg *ClientConfig) (net.Conn, error)

func ClientAuthToken

func ClientAuthToken(authKey, sessionID []byte) string

func DialRTDatagrams added in v0.0.2

func DialRTDatagrams(ctx context.Context, cfg *ClientConfig) error

func EnsureSNICerts added in v0.0.5

func EnsureSNICerts(decoyCertDir string)

func FullFrameEnabled added in v0.0.4

func FullFrameEnabled() bool

func KeepAliveEnabled added in v0.0.5

func KeepAliveEnabled() bool

func LearnedSelPub added in v0.0.6

func LearnedSelPub(idPub string) string

func ListenAndServe

func ListenAndServe(ctx context.Context, cfg *ServerConfig) error

func MaintainSNICerts added in v0.0.6

func MaintainSNICerts(ctx context.Context, decoyCertDir string)

func NetConnOf added in v0.0.2

func NetConnOf(c net.Conn) net.Conn

func NewSessionCache

func NewSessionCache(capacity int) any

func ParseDenial added in v0.0.5

func ParseDenial(b []byte) (string, bool)

func ProbeClockDrift

func ProbeClockDrift(authKey []byte, token string, sessionID []byte) (driftWindows int64, found bool)

func RememberSelPub added in v0.0.6

func RememberSelPub(idPub, selPub string)

func SNICertPaths

func SNICertPaths(decoyCertDir, sni string) (certPath, keyPath string, ok bool)

func SPKIPin

func SPKIPin(cert *x509.Certificate) string

func SetCertIdentity

func SetCertIdentity(id *CertIdentity)

func ShapePadLen added in v0.0.6

func ShapePadLen(room int) int

func SharedSessionCache

func SharedSessionCache() any

func SpliceEnabled

func SpliceEnabled() bool

func StartDecoy

func StartDecoy(ctx context.Context, gate *DecoyGate, cfg *ClientConfig)

func StreamMuxEnabled added in v0.0.2

func StreamMuxEnabled() bool

func VerifyAuthToken

func VerifyAuthToken(authKey []byte, token string, sessionID []byte) bool

func WriteDenial added in v0.0.5

func WriteDenial(w io.Writer, msg string)

Types

type AcceptedConn added in v0.0.5

type AcceptedConn struct {
	Conn      net.Conn
	UserID    string
	SessionID []byte
	Secret    []byte
}

type CertIdentity

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

func LoadOrCreateCertIdentity

func LoadOrCreateCertIdentity(path string) (*CertIdentity, error)

func (*CertIdentity) PubB64

func (id *CertIdentity) PubB64() string

func (*CertIdentity) SelectorKey added in v0.0.5

func (c *CertIdentity) SelectorKey() (*ecdh.PrivateKey, error)

func (*CertIdentity) SelectorPub added in v0.0.5

func (c *CertIdentity) SelectorPub() []byte

type ClientConfig

type ClientConfig struct {
	ServerAddr    string
	ServerName    string
	ServerNames   []string
	SharedSecret  []byte
	ServerCertPin string
	ServerIDPub   string
	ServerSelPub  string
	SessionCache  any
	TCPDialer     func(ctx context.Context, network, addr string) (net.Conn, error)

	EnableQUIC bool
	QUICAddr   string
	OnQUICConn func(*quicgo.Conn)

	HelloSplitOffset int
	HelloID          utls.ClientHelloID
	HelloRaw         []byte
	OnHandshake      func(result HandshakeResult, latency time.Duration)
	OnServerSelPub   func(selPub string)
	OnLiveReset      func()
	OnLiveOK         func()
}

type ClonedCertInfo

type ClonedCertInfo struct {
	Subject   string
	DNSNames  []string
	NotBefore time.Time
	NotAfter  time.Time
}

func CloneCertToFiles

func CloneCertToFiles(domain, outCert, outKey string) (*ClonedCertInfo, error)

func RecloneCertToFiles added in v0.0.6

func RecloneCertToFiles(domain, outCert, outKey string) (*ClonedCertInfo, error)

type DecoyGate

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

func NewDecoyGate

func NewDecoyGate() *DecoyGate

func (*DecoyGate) Close

func (g *DecoyGate) Close()

func (*DecoyGate) Enter

func (g *DecoyGate) Enter()

func (*DecoyGate) Leave

func (g *DecoyGate) Leave()

type FramedConn added in v0.0.5

type FramedConn struct {
	net.Conn
	// contains filtered or unexported fields
}

func NewFramedConn added in v0.0.5

func NewFramedConn(c net.Conn) *FramedConn

func (*FramedConn) Close added in v0.0.5

func (c *FramedConn) Close() error

func (*FramedConn) CloseUnderlying added in v0.0.5

func (c *FramedConn) CloseUnderlying() error

func (*FramedConn) EndStream added in v0.0.5

func (c *FramedConn) EndStream() error

func (*FramedConn) Read added in v0.0.5

func (c *FramedConn) Read(b []byte) (int, error)

func (*FramedConn) Reset added in v0.0.5

func (c *FramedConn) Reset()

func (*FramedConn) Reusable added in v0.0.5

func (c *FramedConn) Reusable() bool

func (*FramedConn) StreamDone added in v0.0.5

func (c *FramedConn) StreamDone() bool

func (*FramedConn) SwitchRaw added in v0.0.6

func (c *FramedConn) SwitchRaw() error

func (*FramedConn) SwitchedRaw added in v0.0.6

func (c *FramedConn) SwitchedRaw() bool

func (*FramedConn) Write added in v0.0.5

func (c *FramedConn) Write(b []byte) (int, error)

type HandshakeResult

type HandshakeResult int
const (
	HandshakeOK HandshakeResult = iota
	HandshakeResetFast
	HandshakeIncomplete
	HandshakeRejected
	HandshakeError
)

func (HandshakeResult) Reward

func (r HandshakeResult) Reward() float64

type HandshakeStrategy

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

func NewHandshakeStrategy

func NewHandshakeStrategy() *HandshakeStrategy

func (*HandshakeStrategy) Load added in v0.0.4

func (h *HandshakeStrategy) Load(path string) error

func (*HandshakeStrategy) Observe

func (h *HandshakeStrategy) Observe(ctx string, arm int, r HandshakeResult)

func (*HandshakeStrategy) Record added in v0.0.4

func (h *HandshakeStrategy) Record(ctx string, r HandshakeResult)

func (*HandshakeStrategy) Save added in v0.0.4

func (h *HandshakeStrategy) Save(path string) error

func (*HandshakeStrategy) Select added in v0.0.4

func (h *HandshakeStrategy) Select(ctx string, arms int) int

Select returns the arm (a tactic index into a repertoire of the given size) to use for this context. It holds the current arm while its survival signal is healthy and switches to the best arm on record only once survival drops — adapt when found, not on every dial — but occasionally explores a less-tried arm so every tactic keeps getting measured on real traffic.

func (*HandshakeStrategy) SelectSplit

func (h *HandshakeStrategy) SelectSplit(ctx string) (offset, arm int)

type Keys

type Keys struct {
	Auth []byte
}

func DeriveKeys

func DeriveKeys(sharedSecret []byte) *Keys

type ServerConfig

type ServerConfig struct {
	ListenAddr       string
	ExtraListenAddrs []string
	BackendH2CAddr   string
	TLSCert          string
	TLSKey           string
	Domain           string
	ACMEDir          string
	DecoyOrigin      string
	DecoyCertDir     string
	AsymBiasRatio    float64
	SharedSecret     []byte

	QUICListenAddr       string
	ExtraQUICListenAddrs []string

	GetUsers     func() []UserEntry
	UsersVersion func() uint64
	OnConn       func(AcceptedConn)
	// contains filtered or unexported fields
}

type UserEntry

type UserEntry struct {
	UserID string
	PSK    []byte
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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