Documentation ¶
Index ¶
- Constants
- Variables
- func BytesSizeForMetadata(firstTwoByte []byte) (int, error)
- func CalcPaddingLen(masterKey []byte, bodyWithoutAddr []byte, req bool) (length int)
- func DecryptUDP(key Key, shadowBytes []byte) (plainText []byte, err error)
- func EVPBytesToKey(password string, keyLen int) (key []byte)
- func EncryptUDPFromPool(key Key, b []byte) (shadowBytes []byte, err error)
- func EncryptedPayloadLen(plainTextLen int, tagLen int) int
- func MD5Sum(d []byte) []byte
- func NewGcm(key []byte) (cipher.AEAD, error)
- type CipherConf
- type Key
- type Metadata
- type MetadataType
- type TCPConn
- type UDPConn
- type UDPConnMapping
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 CalcPaddingLen ¶
func DecryptUDP ¶
DecryptUDP will decrypt the data in place
func EVPBytesToKey ¶
func EncryptUDPFromPool ¶
EncryptUDPFromPool returns shadowBytes from pool. the shadowBytes MUST be put back.
func EncryptedPayloadLen ¶
Types ¶
type CipherConf ¶
type Key ¶
type Key struct { CipherConf CipherConf MasterKey []byte }
type Metadata ¶
type Metadata struct { Type MetadataType Hostname string Port uint16 Cmd protocol.MetadataCmd LenMsgBody uint32 }
func NewMetadata ¶
func (*Metadata) BytesFromPool ¶
type MetadataType ¶
type MetadataType int
const ( MetadataTypeReserved0 MetadataType = iota MetadataTypeIPv4 MetadataTypeReserved2 MetadataTypeDomain MetadataTypeIPv6 // MetadataTypeMsg indicates it's a message from SweetLisa. // [MetadataType(1)][MetadataCmd(1)] MetadataTypeMsg )
type TCPConn ¶
func NewTCPConn ¶
func NewTCPConn(conn net.Conn, conf CipherConf, masterKey []byte, bloom *disk_bloom.FilterGroup) (crw *TCPConn, err error)
func (*TCPConn) ReadMetadata ¶
type UDPConn ¶
func NewUDPConn ¶
type UDPConnMapping ¶
func NewUDPConnMapping ¶
func NewUDPConnMapping() *UDPConnMapping
func (*UDPConnMapping) Insert ¶
func (m *UDPConnMapping) Insert(key string, val *net.UDPConn) *UDPConn
pass val=nil for stating it is establishing
func (*UDPConnMapping) Remove ¶
func (m *UDPConnMapping) Remove(key string)
Click to show internal directories.
Click to hide internal directories.