Documentation ¶
Index ¶
- Constants
- Variables
- func New(stream net.Conn, password, method string, frameType FrameType, flags ...uint8) (net.Conn, error)
- type AEADCipher
- type AEADCipherImpl
- type CipherStream
- func (cs *CipherStream) Close() error
- func (cs *CipherStream) CloseWrite() error
- func (cs *CipherStream) MarkConnUnusable() bool
- func (cs *CipherStream) Read(b []byte) (int, error)
- func (cs *CipherStream) ReadFrame() (*Frame, error)
- func (cs *CipherStream) ReadFrom(r io.Reader) (n int64, err error)
- func (cs *CipherStream) Release()
- func (cs *CipherStream) Write(b []byte) (int, error)
- func (cs *CipherStream) WriteFrame(f *Frame) error
- func (cs *CipherStream) WritePing(b []byte, flag uint8) error
- func (cs *CipherStream) WriteRST(flag uint8) error
- type Frame
- type FrameIter
- type FrameType
- type Header
- func (h *Header) FrameType() FrameType
- func (h *Header) HasPad() bool
- func (h *Header) IsDNSProto() bool
- func (h *Header) IsDataFrame() bool
- func (h *Header) IsNeedACK() bool
- func (h *Header) IsPingFrame() bool
- func (h *Header) IsRSTACKFrame() bool
- func (h *Header) IsRSTFINFrame() bool
- func (h *Header) IsTCPProto() bool
- func (h *Header) IsUDPProto() bool
- func (h *Header) PayloadLen() int
- type Payload
Constants ¶
const ( // MaxPayloadSize is the maximum size of payload, set to 16KB. MaxPayloadSize = 1<<14 - 1 MaxCipherRelaySize = MaxPayloadSize + MaxPayloadSize/2 )
const ( MethodAes256GCM = "aes-256-gcm" MethodChaCha20Poly1305 = "chacha20-poly1305" )
const ( Http2HeaderLen = 9 PaddingSize = 64 MaxPaddingSize = 255 MinPaddingSize = 64 )
const ( FlagTCP uint8 = 1 << iota FlagUDP FlagICMP FlagPad FlagNeedACK FlagFIN FlagACK FlagDNS )
const FlagDefault uint8 = 0
Variables ¶
Functions ¶
Types ¶
type AEADCipher ¶
type AEADCipher interface { Encrypt(plaintext []byte) (ciphertext []byte, err error) Decrypt(ciphertext []byte) (plaintext []byte, err error) NonceSize() int Overhead() int }
func NewAes256GCM ¶
func NewAes256GCM(password []byte) (AEADCipher, error)
NewAes256GCM creates a aes-gcm AEAD instance
func NewChaCha20Poly1305 ¶
func NewChaCha20Poly1305(password []byte) (AEADCipher, error)
NewChaCha20Poly1305 creates a chacha20-poly1305 AEAD instance
type AEADCipherImpl ¶
type AEADCipherImpl struct {
// contains filtered or unexported fields
}
func (*AEADCipherImpl) Decrypt ¶
func (aci *AEADCipherImpl) Decrypt(ciphertext []byte) (plaintext []byte, err error)
Decrypt decrypts data using 256-bit AEAD. This both hides the content of the data and provides a check that it hasn't been altered. Expects input form nonce|ciphertext|tag where '|' indicates concatenation.
func (*AEADCipherImpl) Encrypt ¶
func (aci *AEADCipherImpl) Encrypt(plaintext []byte) (ciphertext []byte, err error)
Encrypt encrypts data using 256-bit AEAD. This both hides the content of the data and provides a check that it hasn't been altered. Output takes the form nonce|ciphertext|tag where '|' indicates concatenation.
func (*AEADCipherImpl) NonceSize ¶
func (aci *AEADCipherImpl) NonceSize() int
NonceSize return underlying aead nonce size
func (*AEADCipherImpl) Overhead ¶
func (aci *AEADCipherImpl) Overhead() int
Overhead return underlying aead overhead size
type CipherStream ¶
type CipherStream struct { net.Conn AEADCipher // contains filtered or unexported fields }
func (*CipherStream) Close ¶ added in v2.3.0
func (cs *CipherStream) Close() error
func (*CipherStream) CloseWrite ¶ added in v2.1.0
func (cs *CipherStream) CloseWrite() error
func (*CipherStream) MarkConnUnusable ¶ added in v2.4.1
func (cs *CipherStream) MarkConnUnusable() bool
func (*CipherStream) ReadFrame ¶ added in v2.3.0
func (cs *CipherStream) ReadFrame() (*Frame, error)
func (*CipherStream) Release ¶
func (cs *CipherStream) Release()
func (*CipherStream) WriteFrame ¶ added in v2.3.0
func (cs *CipherStream) WriteFrame(f *Frame) error
func (*CipherStream) WriteRST ¶
func (cs *CipherStream) WriteRST(flag uint8) error
type Frame ¶ added in v2.3.0
func NewFrame ¶ added in v2.3.0
func NewFrame(ft FrameType, payload []byte, flag uint8, cipher AEADCipher) *Frame
func (*Frame) EncodeWithCipher ¶ added in v2.3.0
type FrameIter ¶ added in v2.3.0
type FrameIter struct {
// contains filtered or unexported fields
}
func NewFrameIter ¶ added in v2.3.0
func NewFrameIter(r io.Reader, cipher AEADCipher) *FrameIter
type Header ¶ added in v2.3.0
type Header struct {
// contains filtered or unexported fields
}
func (*Header) HasPad ¶ added in v2.3.0
HasPad returns true if http2 header frame has pad field, panic if header's length not equals Http2HeaderLen
func (*Header) IsDNSProto ¶ added in v2.4.0
func (*Header) IsDataFrame ¶ added in v2.3.0
func (*Header) IsPingFrame ¶ added in v2.3.0
func (*Header) IsRSTACKFrame ¶ added in v2.3.0
func (*Header) IsRSTFINFrame ¶ added in v2.3.0
func (*Header) IsTCPProto ¶ added in v2.3.0
func (*Header) IsUDPProto ¶ added in v2.3.0
func (*Header) PayloadLen ¶ added in v2.3.0
PayloadLen returns payload length in http2 header frame, panic if header's length not equals Http2HeaderLen
type Payload ¶ added in v2.3.0
type Payload struct {
// contains filtered or unexported fields
}