ss2022

package
v0.1.34 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2023 License: MIT Imports: 12 Imported by: 0

README

Documentation

Index

Constants

View Source
const (
	// RequestHeaderFixedChunkLength
	// https://github.com/Shadowsocks-NET/shadowsocks-specs/blob/main/2022-1-shadowsocks-2022-edition.md#312-format
	// Request stream:
	// +--------+------------------------+---------------------------+------------------------+---------------------------+---+
	// |  salt  | encrypted header chunk |  encrypted header chunk   | encrypted length chunk |  encrypted payload chunk  |...|
	// +--------+------------------------+---------------------------+------------------------+---------------------------+---+
	// | 16/32B |     11B + 16B tag      | variable length + 16B tag |  2B length + 16B tag   | variable length + 16B tag |...|
	// +--------+------------------------+---------------------------+------------------------+---------------------------+---+
	//
	RequestHeaderFixedChunkLength = 1 + 8 + 2

	// PacketMinimalHeaderSize
	// https://github.com/Shadowsocks-NET/shadowsocks-specs/blob/main/2022-1-shadowsocks-2022-edition.md#322-format-and-separate-header
	// Packet:
	// +---------------------------+---------------------------+
	// | encrypted separate header |       encrypted body      |
	// +---------------------------+---------------------------+
	// |            16B            | variable length + 16B tag |
	// +---------------------------+---------------------------+
	//
	// Separate header:
	// +------------+-----------+
	// | session ID | packet ID |
	// +------------+-----------+
	// |     8B     |   u64be   |
	// +------------+-----------+
	//
	PacketMinimalHeaderSize = 16 + 16
)

Variables

View Source
var (
	ErrMissingPSK = errors.New("missing psk")
)

Functions

func Key

func Key(key []byte, keyLength int) []byte

func SessionKey

func SessionKey(psk []byte, salt []byte, keyLength int) []byte

Types

type Method

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

func NewMethod

func NewMethod(method string, password string) (*Method, error)

type Pair

type Pair[T any] struct {
	Name   string
	Method *Method
	Val    T
}

type Tester

type Tester[T any] struct {
	Lists []Pair[T]
}

func NewTester

func NewTester[T any]() *Tester[T]

func (*Tester[T]) Add

func (t *Tester[T]) Add(name, method, password string, val T) (err error)

func (*Tester[T]) Test

func (t *Tester[T]) Test(peeker peek.Peeker, cb func(name string, val T)) (bool, error)

func (*Tester[T]) TestPacket

func (t *Tester[T]) TestPacket(packet []byte) (bool, string, T)

Jump to

Keyboard shortcuts

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