shadowaead_2022

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2023 License: GPL-2.0 Imports: 35 Imported by: 1

Documentation

Index

Constants

View Source
const (
	HeaderTypeClient              = 0
	HeaderTypeServer              = 1
	MaxPaddingLength              = 900
	PacketNonceSize               = 24
	MaxPacketSize                 = 65535
	RequestHeaderFixedChunkLength = 1 + 8 + 2
	PacketMinimalHeaderSize       = 30
)

Variables

View Source
var (
	ErrMissingPSK            = E.New("missing psk")
	ErrBadHeaderType         = E.New("bad header type")
	ErrBadTimestamp          = E.New("bad timestamp")
	ErrBadRequestSalt        = E.New("bad request salt")
	ErrSaltNotUnique         = E.New("salt not unique")
	ErrBadClientSessionId    = E.New("bad client session id")
	ErrPacketIdNotUnique     = E.New("packet id not unique")
	ErrTooManyServerSessions = E.New("server session changed more than once during the last minute")
	ErrPacketTooShort        = E.New("packet too short")
)
View Source
var (
	ErrNoPadding  = E.New("bad request: missing payload or padding")
	ErrBadPadding = E.New("bad request: damaged padding")
)
View Source
var List = []string{
	"2022-blake3-aes-128-gcm",
	"2022-blake3-aes-256-gcm",
	"2022-blake3-chacha20-poly1305",
}

Functions

func Blake3KeyedHash

func Blake3KeyedHash(reader io.Reader) io.Reader

func Key

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

func New

func New(method string, pskList [][]byte, timeFunc func() time.Time) (shadowsocks.Method, error)

func NewService

func NewService(method string, psk []byte, udpTimeout int64, handler shadowsocks.Handler, timeFunc func() time.Time) (shadowsocks.Service, error)

func NewServiceWithPassword

func NewServiceWithPassword(method string, password string, udpTimeout int64, handler shadowsocks.Handler, timeFunc func() time.Time) (shadowsocks.Service, error)

func NewWithPassword

func NewWithPassword(method string, password string, timeFunc func() time.Time) (shadowsocks.Method, error)

func SessionKey

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

Types

type Method

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

func (*Method) DialConn

func (m *Method) DialConn(conn net.Conn, destination M.Socksaddr) (net.Conn, error)

func (*Method) DialEarlyConn

func (m *Method) DialEarlyConn(conn net.Conn, destination M.Socksaddr) net.Conn

func (*Method) DialPacketConn

func (m *Method) DialPacketConn(conn net.Conn) N.NetPacketConn

func (*Method) Name

func (m *Method) Name() string

type MultiService

type MultiService[U comparable] struct {
	*Service
	// contains filtered or unexported fields
}

func NewMultiService

func NewMultiService[U comparable](method string, iPSK []byte, udpTimeout int64, handler shadowsocks.Handler, timeFunc func() time.Time) (*MultiService[U], error)

func NewMultiServiceWithPassword

func NewMultiServiceWithPassword[U comparable](method string, password string, udpTimeout int64, handler shadowsocks.Handler, timeFunc func() time.Time) (*MultiService[U], error)

func (*MultiService[U]) NewConnection

func (s *MultiService[U]) NewConnection(ctx context.Context, conn net.Conn, metadata M.Metadata) error

func (*MultiService[U]) NewPacket

func (s *MultiService[U]) NewPacket(ctx context.Context, conn N.PacketConn, buffer *buf.Buffer, metadata M.Metadata) error

func (*MultiService[U]) UpdateUsers

func (s *MultiService[U]) UpdateUsers(userList []U, keyList [][]byte) error

func (*MultiService[U]) UpdateUsersWithPasswords

func (s *MultiService[U]) UpdateUsersWithPasswords(userList []U, passwordList []string) error

func (*MultiService[U]) WriteIsThreadUnsafe

func (s *MultiService[U]) WriteIsThreadUnsafe()

type RelayService

type RelayService[U comparable] struct {
	// contains filtered or unexported fields
}

func NewRelayService

func NewRelayService[U comparable](method string, psk []byte, udpTimeout int64, handler shadowsocks.Handler) (*RelayService[U], error)

func NewRelayServiceWithPassword

func NewRelayServiceWithPassword[U comparable](method string, password string, udpTimeout int64, handler shadowsocks.Handler) (*RelayService[U], error)

func (*RelayService[U]) Name

func (s *RelayService[U]) Name() string

func (*RelayService[U]) NewConnection

func (s *RelayService[U]) NewConnection(ctx context.Context, conn net.Conn, metadata M.Metadata) error

func (*RelayService[U]) NewError

func (s *RelayService[U]) NewError(ctx context.Context, err error)

func (*RelayService[U]) NewPacket

func (s *RelayService[U]) NewPacket(ctx context.Context, conn N.PacketConn, buffer *buf.Buffer, metadata M.Metadata) error

func (*RelayService[U]) Password

func (s *RelayService[U]) Password() string

func (*RelayService[U]) UpdateUsers

func (s *RelayService[U]) UpdateUsers(userList []U, keyList [][]byte, destinationList []M.Socksaddr) error

func (*RelayService[U]) UpdateUsersWithPasswords

func (s *RelayService[U]) UpdateUsersWithPasswords(userList []U, passwordList []string, destinationList []M.Socksaddr) error

func (*RelayService[U]) WriteIsThreadUnsafe

func (s *RelayService[U]) WriteIsThreadUnsafe()

type Service

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

func (*Service) Name

func (s *Service) Name() string

func (*Service) NewConnection

func (s *Service) NewConnection(ctx context.Context, conn net.Conn, metadata M.Metadata) error

func (*Service) NewError

func (s *Service) NewError(ctx context.Context, err error)

func (*Service) NewPacket

func (s *Service) NewPacket(ctx context.Context, conn N.PacketConn, buffer *buf.Buffer, metadata M.Metadata) error

func (*Service) Password

func (s *Service) Password() string

func (*Service) WriteIsThreadUnsafe

func (s *Service) WriteIsThreadUnsafe()

type SlidingWindow

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

SlidingWindow maintains a sliding window of uint64 counters.

func (*SlidingWindow) Add

func (f *SlidingWindow) Add(counter uint64)

Add adds counter to the sliding window without checking if the counter is valid. Call Check beforehand to make sure the counter is valid.

func (*SlidingWindow) Check

func (f *SlidingWindow) Check(counter uint64) bool

Check checks whether counter can be accepted by the sliding window filter.

func (*SlidingWindow) Reset

func (f *SlidingWindow) Reset()

Reset resets the filter to its initial state.

Jump to

Keyboard shortcuts

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