shadowaead

package
v0.2.6 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2023 License: GPL-2.0 Imports: 27 Imported by: 1

Documentation

Index

Constants

View Source
const (
	MaxPacketSize          = 16*1024 - 1
	PacketLengthBufferSize = 2
)

https://shadowsocks.org/en/wiki/AEAD-Ciphers.html

View Source
const (
	// Overhead
	// crypto/cipher.gcmTagSize
	// golang.org/x/crypto/chacha20poly1305.Overhead
	// github.com/sina-ghaderi/poly1305.TagSize
	// github.com/ericlagergren/siv.TagSize
	// github.com/ericlagergren/aegis.TagSize128L
	// github.com/ericlagergren/aegis.TagSize256
	// github.com/Yawning/aez.aeadOverhead
	// github.com/oasisprotocol/deoxysii.TagSize
	Overhead = 16
)

Variables

View Source
var ErrBadHeader = E.New("bad header")
View Source
var List = []string{
	"aes-128-gcm",
	"aes-192-gcm",
	"aes-256-gcm",
	"chacha20-ietf-poly1305",
	"xchacha20-ietf-poly1305",

	"rabbit128-poly1305",
	"aes-128-gcm-siv",
	"aes-256-gcm-siv",
	"aegis-128l",
	"aegis-256",
	"aez-384",
	"deoxys-ii-256-128",
	"lea-128-gcm",
	"lea-192-gcm",
	"lea-256-gcm",
}

Functions

func Kdf

func Kdf(key, iv []byte, buffer *buf.Buffer)

Types

type BufferedWriter

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

func (*BufferedWriter) Flush

func (w *BufferedWriter) Flush() error

func (*BufferedWriter) Write

func (w *BufferedWriter) Write(p []byte) (n int, err error)

type Method

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

func New

func New(method string, key []byte, password string) (*Method, error)

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 {
	// contains filtered or unexported fields
}

func NewMultiService

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

func (*MultiService[U]) Name

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

func (*MultiService[U]) NewConnection

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

func (*MultiService[U]) NewError

func (s *MultiService[U]) NewError(ctx context.Context, err 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 Reader

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

func NewRawReader

func NewRawReader(upstream io.Reader, cipher cipher.AEAD, buffer []byte, nonce []byte) *Reader

func NewReader

func NewReader(upstream io.Reader, cipher cipher.AEAD, maxPacketSize int) *Reader

func (*Reader) Buffer

func (r *Reader) Buffer() *buf.Buffer

func (*Reader) Cached

func (r *Reader) Cached() int

func (*Reader) CachedSlice

func (r *Reader) CachedSlice() []byte

func (*Reader) Discard

func (r *Reader) Discard(n int) error

func (*Reader) Read

func (r *Reader) Read(b []byte) (n int, err error)

func (*Reader) ReadByte

func (r *Reader) ReadByte() (byte, error)

func (*Reader) ReadChunk

func (r *Reader) ReadChunk(buffer *buf.Buffer, chunk []byte) error

func (*Reader) ReadExternalChunk

func (r *Reader) ReadExternalChunk(chunk []byte) error

func (*Reader) ReadWithLength

func (r *Reader) ReadWithLength(length uint16) error

func (*Reader) ReadWithLengthChunk

func (r *Reader) ReadWithLengthChunk(lengthChunk []byte) error

func (*Reader) Upstream

func (r *Reader) Upstream() any

func (*Reader) WriteTo

func (r *Reader) WriteTo(writer io.Writer) (n int64, err error)

type Service

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

func NewService

func NewService(method string, key []byte, password string, udpTimeout int64, handler shadowsocks.Handler) (*Service, error)

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 (c *Service) WriteIsThreadUnsafe()

type Writer

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

func NewRawWriter

func NewRawWriter(upstream io.Writer, cipher cipher.AEAD, maxPacketSize int, buffer []byte, nonce []byte) *Writer

func NewWriter

func NewWriter(upstream io.Writer, cipher cipher.AEAD, maxPacketSize int) *Writer

func (*Writer) Buffer

func (w *Writer) Buffer() *buf.Buffer

func (*Writer) BufferedWriter

func (w *Writer) BufferedWriter(reversed int) *BufferedWriter

func (*Writer) ReadFrom

func (w *Writer) ReadFrom(r io.Reader) (n int64, err error)

func (*Writer) Upstream

func (w *Writer) Upstream() any

func (*Writer) Write

func (w *Writer) Write(p []byte) (n int, err error)

func (*Writer) WriteChunk

func (w *Writer) WriteChunk(buffer *buf.Buffer, chunk []byte)

func (*Writer) WriteVectorised

func (w *Writer) WriteVectorised(buffers []*buf.Buffer) error

Jump to

Keyboard shortcuts

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