shadowaead

package
v0.2.7 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2024 License: GPL-2.0 Imports: 21 Imported by: 12

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
	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",
}

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 added in v0.2.1

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

func NewMultiService added in v0.2.1

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

func (*MultiService[U]) Name added in v0.2.1

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

func (*MultiService[U]) NewConnection added in v0.2.1

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

func (*MultiService[U]) NewError added in v0.2.1

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

func (*MultiService[U]) NewPacket added in v0.2.1

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

func (*MultiService[U]) UpdateUsers added in v0.2.1

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

func (*MultiService[U]) UpdateUsersWithPasswords added in v0.2.1

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

func (*MultiService[U]) WriteIsThreadUnsafe added in v0.2.1

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