shadowsocks

package
v1.1.11 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2022 License: AGPL-3.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxNonceSize = 12
	ATypeIPv4    = 1
	ATypeDomain  = 3
	ATypeIpv6    = 4
)
View Source
const (
	TCPChunkMaxLen = (1 << (16 - 2)) - 1
)

Variables

View Source
var (
	CiphersConf = map[string]CipherConf{
		"chacha20-ietf-poly1305": {KeyLen: 32, SaltLen: 32, NonceLen: 12, TagLen: 16, NewCipher: chacha20poly1305.New},
		"chacha20-poly1305":      {KeyLen: 32, SaltLen: 32, NonceLen: 12, TagLen: 16, NewCipher: chacha20poly1305.New},
		"aes-256-gcm":            {KeyLen: 32, SaltLen: 32, NonceLen: 12, TagLen: 16, NewCipher: NewGcm},
		"aes-128-gcm":            {KeyLen: 16, SaltLen: 16, NonceLen: 12, TagLen: 16, NewCipher: NewGcm},
	}
	ZeroNonce  [MaxNonceSize]byte
	ReusedInfo = []byte("ss-subkey")
)
View Source
var (
	ErrFailInitCihper = fmt.Errorf("fail to initiate cipher")
)
View Source
var (
	ErrInvalidMetadata = errors.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(key Key, shadowBytes []byte) (n int, err error)

DecryptUDP will decrypt the data in place

func EVPBytesToKey

func EVPBytesToKey(password string, keyLen int) (key []byte)

func EncryptUDPFromPool

func EncryptUDPFromPool(key Key, b []byte) (shadowBytes []byte, err error)

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

func EncryptedPayloadLen

func EncryptedPayloadLen(plainTextLen int, tagLen int) int

func MD5Sum

func MD5Sum(d []byte) []byte

func MetadataTypeToByte added in v1.1.3

func MetadataTypeToByte(typ protocol.MetadataType) byte

func NewDialer added in v1.1.3

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

func NewGcm

func NewGcm(key []byte) (cipher.AEAD, error)

func ParseMetadataType added in v1.1.3

func ParseMetadataType(t byte) protocol.MetadataType

Types

type CipherConf

type CipherConf struct {
	KeyLen    int
	SaltLen   int
	NonceLen  int
	TagLen    int
	NewCipher func(key []byte) (cipher.AEAD, error)
}

func (*CipherConf) Verify

func (conf *CipherConf) Verify(buf []byte, masterKey []byte, salt []byte, cipherText []byte, subKey *[]byte) ([]byte, bool)

type Dialer added in v1.1.3

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

func (*Dialer) Dial added in v1.1.3

func (d *Dialer) Dial(network string, addr string) (c net.Conn, err error)

type Key

type Key struct {
	CipherConf 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)

func (*Metadata) BytesFromPool

func (meta *Metadata) BytesFromPool() (b []byte)

type TCPConn

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

func NewTCPConn

func NewTCPConn(conn net.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 {
	Timeout time.Duration
	net.PacketConn
	// contains filtered or unexported fields
}

func NewUDPConn

func NewUDPConn(conn net.PacketConn, metadata protocol.Metadata, masterKey []byte, bloom *disk_bloom.FilterGroup) (*UDPConn, error)

func (*UDPConn) Close added in v1.1.3

func (c *UDPConn) Close() error

func (*UDPConn) Read added in v1.1.3

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

func (*UDPConn) ReadFrom added in v1.1.3

func (c *UDPConn) ReadFrom(b []byte) (n int, addr net.Addr, err error)

func (*UDPConn) RemoteAddr added in v1.1.3

func (c *UDPConn) RemoteAddr() net.Addr

func (*UDPConn) Write added in v1.1.3

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

func (*UDPConn) WriteTo added in v1.1.3

func (c *UDPConn) WriteTo(b []byte, addr net.Addr) (int, error)

Jump to

Keyboard shortcuts

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