shadowsocks

package
v0.0.0-...-6daa40f Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2024 License: AGPL-3.0 Imports: 23 Imported by: 6

Documentation

Index

Constants

View Source
const DefaultBucketSize = 300
View Source
const (
	TCPChunkMaxLen = (1 << (16 - 2)) - 1
)

Variables

View Source
var (
	DefaultSaltGeneratorType = RandomSaltGeneratorType
	DefaultIodizedSource     = "https://github.com/explore"
)
View Source
var (
	ErrFailInitCipher = fmt.Errorf("fail to initiate cipher")
)
View Source
var (
	ErrInvalidMetadata = fmt.Errorf("invalid metadata")
)

Functions

func BytesSizeForMetadata

func BytesSizeForMetadata(firstTwoByte []byte) (int, error)

func CalcPaddingLen

func CalcPaddingLen(masterKey []byte, bodyWithoutAddr []byte, req bool) (length int)

func DecryptUDP

func DecryptUDP(writeTo []byte, key *Key, shadowBytes []byte, reusedInfo []byte) (n int, err error)

DecryptUDP will decrypt the data in place

func DecryptUDPFromPool

func DecryptUDPFromPool(key *Key, shadowBytes []byte, reusedInfo []byte) (buf pool.PB, err error)

DecryptUDP will decrypt the data in place

func EncryptUDPFromPool

func EncryptUDPFromPool(key *Key, b []byte, salt []byte, reusedInfo []byte) (shadowBytes pool.PB, err error)

EncryptUDPFromPool returns shadowBytes from pool. the shadowBytes MUST be put back.

func EncryptedPayloadLen

func EncryptedPayloadLen(plainTextLen int, tagLen int) int

func MetadataTypeToByte

func MetadataTypeToByte(typ protocol.MetadataType) byte

func NewDialer

func NewDialer(nextDialer netproxy.Dialer, header protocol.Header) (netproxy.Dialer, error)

func ParseMetadataType

func ParseMetadataType(t byte) protocol.MetadataType

Types

type Dialer

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

func (*Dialer) Dial

func (d *Dialer) Dial(network, addr string) (netproxy.Conn, error)

type DummySaltGenerator

type DummySaltGenerator struct {
	Closed  chan struct{}
	Success bool
}

func NewDummySaltGenerator

func NewDummySaltGenerator() *DummySaltGenerator

func (*DummySaltGenerator) Close

func (g *DummySaltGenerator) Close() error

func (*DummySaltGenerator) Get

func (g *DummySaltGenerator) Get() []byte

type IodizedSaltGenerator

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

func NewIodizedSaltGenerator

func NewIodizedSaltGenerator(salt []byte, saltSize, bucketSize int, fromPool bool) (*IodizedSaltGenerator, error)

func (*IodizedSaltGenerator) Close

func (g *IodizedSaltGenerator) Close() error

func (*IodizedSaltGenerator) Get

func (g *IodizedSaltGenerator) Get() []byte

type Key

type Key struct {
	CipherConf *ciphers.CipherConf
	MasterKey  []byte
}

type Metadata

type Metadata struct {
	protocol.Metadata
	LenMsgBody uint32
}

func NewMetadata

func NewMetadata(bytesMetadata []byte) (*Metadata, error)

func (*Metadata) Bytes

func (meta *Metadata) Bytes() (b []byte, err error)

func (*Metadata) BytesFromPool

func (meta *Metadata) BytesFromPool() (b []byte, err error)

type RandomSaltGenerator

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

func NewRandomSaltGenerator

func NewRandomSaltGenerator(saltSize int, fromPool bool) (*RandomSaltGenerator, error)

func (*RandomSaltGenerator) Close

func (g *RandomSaltGenerator) Close() error

func (*RandomSaltGenerator) Get

func (g *RandomSaltGenerator) Get() []byte

type SaltGenerator

type SaltGenerator interface {
	Get() []byte
	Close() error
}

func GetSaltGenerator

func GetSaltGenerator(masterKey []byte, saltLen int) (sg SaltGenerator, err error)

type SaltGeneratorType

type SaltGeneratorType int
const (
	IodizedSaltGeneratorType SaltGeneratorType = iota
	RandomSaltGeneratorType
)

type TCPConn

type TCPConn struct {
	netproxy.Conn
	// contains filtered or unexported fields
}

func NewTCPConn

func NewTCPConn(conn netproxy.Conn, metadata protocol.Metadata, masterKey []byte, bloom *disk_bloom.FilterGroup) (crw *TCPConn, err error)

func (*TCPConn) Close

func (c *TCPConn) Close() error

func (*TCPConn) Read

func (c *TCPConn) Read(b []byte) (n int, err error)

func (*TCPConn) ReadMetadata

func (c *TCPConn) ReadMetadata() (metadata Metadata, err error)

func (*TCPConn) Write

func (c *TCPConn) Write(b []byte) (n int, err error)

type UdpConn

type UdpConn struct {
	netproxy.PacketConn
	// contains filtered or unexported fields
}

func NewUdpConn

func NewUdpConn(conn netproxy.PacketConn, proxyAddress string, metadata protocol.Metadata, masterKey []byte, bloom *disk_bloom.FilterGroup) (*UdpConn, error)

func (*UdpConn) Close

func (c *UdpConn) Close() error

func (*UdpConn) Read

func (c *UdpConn) Read(b []byte) (n int, err error)

func (*UdpConn) ReadFrom

func (c *UdpConn) ReadFrom(b []byte) (n int, addr netip.AddrPort, err error)

func (*UdpConn) Write

func (c *UdpConn) Write(b []byte) (n int, err error)

func (*UdpConn) WriteTo

func (c *UdpConn) WriteTo(b []byte, addr string) (int, error)

Jump to

Keyboard shortcuts

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