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) (n int, 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 MetadataTypeToByte(typ protocol.MetadataType) byte
- func NewDialer(nextDialer proxy.Dialer, header protocol.Header) (proxy.Dialer, error)
- func NewGcm(key []byte) (cipher.AEAD, error)
- func ParseMetadataType(t byte) protocol.MetadataType
- type CipherConf
- type Dialer
- type Key
- type Metadata
- type TCPConn
- type UDPConn
- func (c *UDPConn) Close() error
- func (c *UDPConn) Read(b []byte) (n int, err error)
- func (c *UDPConn) ReadFrom(b []byte) (n int, addr net.Addr, err error)
- func (c *UDPConn) RemoteAddr() net.Addr
- func (c *UDPConn) Write(b []byte) (n int, err error)
- func (c *UDPConn) WriteTo(b []byte, addr net.Addr) (int, error)
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 ¶
func MetadataTypeToByte ¶ added in v1.1.3
func MetadataTypeToByte(typ protocol.MetadataType) byte
func ParseMetadataType ¶ added in v1.1.3
func ParseMetadataType(t byte) protocol.MetadataType
Types ¶
type CipherConf ¶
type Key ¶
type Key struct { CipherConf CipherConf MasterKey []byte }
type TCPConn ¶
func NewTCPConn ¶
func NewTCPConn(conn net.Conn, metadata protocol.Metadata, masterKey []byte, bloom *disk_bloom.FilterGroup) (crw *TCPConn, err error)
func (*TCPConn) ReadMetadata ¶
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) RemoteAddr ¶ added in v1.1.3
Click to show internal directories.
Click to hide internal directories.