utils

package
v0.0.0-...-277102e Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2024 License: GPL-3.0 Imports: 33 Imported by: 0

Documentation

Index

Constants

View Source
const (
	VersionSSL30 = 0x0300
	VersionTLS10 = 0x0301
	VersionTLS11 = 0x0302
	VersionTLS12 = 0x0303
)
View Source
const CipherBlockLen = 8192

Variables

This section is empty.

Functions

func CopyBuffer

func CopyBuffer(b []byte) []byte

func CopyBuffers

func CopyBuffers(bufs [][]byte) []byte

func GenTLSClientHello

func GenTLSClientHello(b []byte, serverName string, sessionID []byte, sessionTicket []byte) int

func GenTLSServerHello

func GenTLSServerHello(b []byte, l int, sessionID []byte) int

GenTLSServerHello generate tls server hello for simple-obfs note: the function don't check the length of buffer

func GetBuf

func GetBuf(n int) []byte

func GetIvLen

func GetIvLen(method string) int

func GetRandomBytes

func GetRandomBytes(len int) []byte

func HttpProxyTo

func HttpProxyTo(w http.ResponseWriter, r *http.Request, target string)

func IsAEAD

func IsAEAD(method string) bool

func IsValidHTTPMethod

func IsValidHTTPMethod(m string) bool

IsValidHTTPMethod indicates whether m is a valid http method

func ListenSubUDP

func ListenSubUDP(network, address string) (net.Listener, error)

ListenSubUDP returns net.Listener

func ListenSubUDPWithConn

func ListenSubUDPWithConn(conn net.PacketConn) (net.Listener, error)

ListenSubUDPWithConn returns net.Listener

func ListenSubUDPWithConnAndCtx

func ListenSubUDPWithConnAndCtx(conn net.PacketConn, ctx *UDPServerCtx) (net.Listener, error)

ListenSubUDPWithConnAndCtx returns net.Listener

func ListenSubUDPWithCtx

func ListenSubUDPWithCtx(network, address string, ctx *UDPServerCtx) (net.Listener, error)

ListenSubUDPWithCtx returns net.Listener

func NewChaCha20BlockCrypt

func NewChaCha20BlockCrypt(key []byte) (*chacha20BlockCrypt, error)

func NewUDPListener

func NewUDPListener(address string) (conn *net.UDPConn, err error)

NewUDPListener simplely calls the net.ListenUDP and create a udp listener

func PipeForUDPServer

func PipeForUDPServer(c1, c2 net.Conn, ctx *UDPServerCtx)

PipeForUDPServer is a simple pipe loop for udp server

func PipeUDPOverTCP

func PipeUDPOverTCP(udpconn net.Conn, tcpconn net.Conn, bufpool *sync.Pool, timeout time.Duration, pseudo []byte)

func PprofEnabled

func PprofEnabled() bool

PprofEnabled returns whether pprof is enabled

func PutBuf

func PutBuf(b []byte)

func PutCipherBlock

func PutCipherBlock(b *CipherBlock)

func PutRandomBytes

func PutRandomBytes(b []byte)

func RunProfileHTTPServer

func RunProfileHTTPServer(addr string)

RunProfileHTTPServer do nothing

func SliceToString

func SliceToString(b []byte) (s string)

func SplitHostAndPort

func SplitHostAndPort(hostport string) (host string, port int, err error)

func SplitIPAndPort

func SplitIPAndPort(ipport string) (ip net.IP, port int, err error)

func StringToSlice

func StringToSlice(s string) (b []byte)

Types

type AEADDecryptCipherStream

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

func (*AEADDecryptCipherStream) Read

func (a *AEADDecryptCipherStream) Read(p []byte) (n int, err error)

type AEADEncryptCipherStream

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

type AddrCtx

type AddrCtx struct {
	net.Addr
	Ctx interface{}
}

AddrCtx carries a ctx inteface and can sotre some control message

type AsyncRunner

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

func (*AsyncRunner) Run

func (a *AsyncRunner) Run(f func())

type AtomicFlag

type AtomicFlag uint32

AtomicFlag is an atomic flag(or boolean)

func (*AtomicFlag) Set

func (a *AtomicFlag) Set(flag bool) bool

Set sets the atomic flag to flag and returns old value

func (*AtomicFlag) Test

func (a *AtomicFlag) Test() bool

Test tests if flag is set to true

type CheckCallback

type CheckCallback func(key, value interface{}) (ok bool)

CheckCallback is used to check if a key can be deleted the key won't be deleted if it returns true

type CipherBlock

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

func GetCipherBlock

func GetCipherBlock() *CipherBlock

type CipherStream

type CipherStream interface {
	io.ReadWriter

	GetIV() []byte
}

func NewAESCFBDecrypter

func NewAESCFBDecrypter(key []byte, ivLen int) (rw CipherStream, err error)

func NewAESCFBEncrypter

func NewAESCFBEncrypter(key, iv []byte) (rw CipherStream, err error)

func NewAESCTRDecrypter

func NewAESCTRDecrypter(key []byte, ivLen int) (rw CipherStream, err error)

func NewAESCTREncrypter

func NewAESCTREncrypter(key, iv []byte) (rw CipherStream, err error)

func NewAESGCMDecrypter

func NewAESGCMDecrypter(key []byte, ivLen int) (CipherStream, error)

func NewAESGCMEncrypter

func NewAESGCMEncrypter(key, iv []byte) (CipherStream, error)

func NewChaCha20Decrypter

func NewChaCha20Decrypter(key []byte, ivLen int) (rw CipherStream, err error)

func NewChaCha20Encrypter

func NewChaCha20Encrypter(key, iv []byte) (rw CipherStream, err error)

func NewChacha20Poly1305Decrypter

func NewChacha20Poly1305Decrypter(key []byte, ivLen int) (CipherStream, error)

func NewChacha20Poly1305Encrypter

func NewChacha20Poly1305Encrypter(key, iv []byte) (CipherStream, error)

func NewDecrypter

func NewDecrypter(method, password string) (dec CipherStream, err error)

func NewEncrypter

func NewEncrypter(method, password string) (enc CipherStream, err error)

func NewPlainDecrypter

func NewPlainDecrypter(_ []byte, _ int) (CipherStream, error)

func NewPlainEncrypter

func NewPlainEncrypter(_, _ []byte) (CipherStream, error)

func NewRC4MD5Decrypter

func NewRC4MD5Decrypter(key []byte, ivLen int) (rw CipherStream, err error)

func NewRC4MD5Encrypter

func NewRC4MD5Encrypter(key, iv []byte) (rw CipherStream, err error)

func NewSalsa20Decrypter

func NewSalsa20Decrypter(key []byte, ivLen int) (CipherStream, error)

func NewSalsa20Encrypter

func NewSalsa20Encrypter(key, iv []byte) (CipherStream, error)

type ClientHelloMsg

type ClientHelloMsg struct {
	Raw                          []byte
	Vers                         uint16
	Random                       []byte
	SessionId                    []byte
	CipherSuites                 []uint16
	CompressionMethods           []uint8
	NextProtoNeg                 bool
	ServerName                   string
	OcspStapling                 bool
	Scts                         bool
	SupportedCurves              []CurveID
	SupportedPoints              []uint8
	TicketSupported              bool
	SessionTicket                []uint8
	SignatureAndHashes           []signatureAndHash
	SecureRenegotiation          []byte
	SecureRenegotiationSupported bool
	AlpnProtocols                []string
}

func ParseTLSClientHelloMsg

func ParseTLSClientHelloMsg(b []byte) (ok bool, n int, msg *ClientHelloMsg)

ParseTLSClientHelloMsg scan the buffer and try to parse TLS Client Hello Message ok returns false if it's not tls hello msg

func (*ClientHelloMsg) Marshal

func (m *ClientHelloMsg) Marshal() []byte

func (*ClientHelloMsg) Unmarshal

func (m *ClientHelloMsg) Unmarshal(data []byte) bool

type Conn

type Conn interface {
	net.Conn
	WriteBuffers([][]byte) (int, error)
}

Conn represents a net.Conn that implement WriteBuffers method WriteBuffers can write serveral buffers at a time

type CopyConn

type CopyConn struct {
	net.Conn
}

CopyConn implements Conn

func (*CopyConn) WriteBuffers

func (conn *CopyConn) WriteBuffers(bufs [][]byte) (n int, err error)

WriteBuffers directly copy all buffers into a larger buf and send it

type CurveID

type CurveID uint16

CurveID is the type of a TLS identifier for an elliptic curve. See http://www.iana.org/assignments/tls-parameters/tls-parameters.xml#tls-parameters-8

const (
	CurveP256 CurveID = 23
	CurveP384 CurveID = 24
	CurveP521 CurveID = 25
	X25519    CurveID = 29
)

type DeleteCallback

type DeleteCallback func(key, value interface{})

DeleteCallback is called when a key is deleting

type Die

type Die struct {
	RWLock
	// contains filtered or unexported fields
}

func (*Die) Ch

func (d *Die) Ch() (ch <-chan bool)

func (*Die) Die

func (d *Die) Die(f func())

func (*Die) IsDead

func (d *Die) IsDead() (dead bool)

type DomainRoot

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

DomainRoot is a simple trie tree

func NewDomainRoot

func NewDomainRoot() *DomainRoot

NewDomainRoot returns a new domainroot and init it

func (*DomainRoot) Get

func (root *DomainRoot) Get() (hosts []string)

func (*DomainRoot) Put

func (root *DomainRoot) Put(host string)

Put put a new host into domainroot

func (*DomainRoot) Test

func (root *DomainRoot) Test(host string) bool

type DupConn

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

func NewDupConn

func NewDupConn(conn net.Conn, magnification int) *DupConn

func (*DupConn) Read

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

func (*DupConn) Write

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

type ExitCleaner

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

func (*ExitCleaner) Delete

func (c *ExitCleaner) Delete(index int) func()

func (*ExitCleaner) Exit

func (c *ExitCleaner) Exit()

func (*ExitCleaner) Push

func (c *ExitCleaner) Push(f func()) int

type Expires

type Expires struct {
	E time.Time
	L RWLock
}

func (*Expires) IsExpired

func (e *Expires) IsExpired() bool

func (*Expires) IsExpiredAndUpdate

func (e *Expires) IsExpiredAndUpdate(d time.Duration) bool

func (*Expires) Update

func (e *Expires) Update(d time.Duration)

type Extension

type Extension struct {
	Type   uint16
	Length uint16
	Data   []byte
}

type FecConn

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

FecConn implements FEC decoder and encoder

func NewFecConn

func NewFecConn(conn net.Conn, datashard, parityshard int) *FecConn

func (*FecConn) Read

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

func (*FecConn) Write

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

type HTTPHeaderParser

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

HTTPHeaderParser is a parser for http request and reply header

func NewHTTPHeaderParser

func NewHTTPHeaderParser(buf []byte) *HTTPHeaderParser

NewHTTPHeaderParser new a http parser

func (*HTTPHeaderParser) Delete

func (p *HTTPHeaderParser) Delete(key []byte) (ok bool)

Delete deletes a key-value pair from http headers

func (*HTTPHeaderParser) Encode

func (p *HTTPHeaderParser) Encode(b []byte) (n int, err error)

Encode encodes the http message to a byte buffer

func (*HTTPHeaderParser) GetBuf

func (p *HTTPHeaderParser) GetBuf() []byte

GetBuf return the buffer of parser

func (*HTTPHeaderParser) GetFirstLine

func (p *HTTPHeaderParser) GetFirstLine() (line []byte, err error)

GetFirstLine returns the first line of http request or reply

func (*HTTPHeaderParser) GetFirstLine1

func (p *HTTPHeaderParser) GetFirstLine1() ([]byte, error)

GetFirstLine1 returns the first string in the first line

func (*HTTPHeaderParser) GetFirstLine2

func (p *HTTPHeaderParser) GetFirstLine2() ([]byte, error)

GetFirstLine2 returns the second string in the first line

func (*HTTPHeaderParser) GetFirstLine3

func (p *HTTPHeaderParser) GetFirstLine3() ([]byte, error)

GetFirstLine3 returns the third string in the first line

func (*HTTPHeaderParser) HeaderLen

func (p *HTTPHeaderParser) HeaderLen() int

HeaderLen returns the hteader length of http message

func (*HTTPHeaderParser) Load

func (p *HTTPHeaderParser) Load(key []byte) (values [][]byte, ok bool)

Load returns the values in the http headers, or nil if no key is present.The OK indicates whether key-value was found in the headers

func (*HTTPHeaderParser) Ok

func (p *HTTPHeaderParser) Ok() bool

func (*HTTPHeaderParser) Read

func (p *HTTPHeaderParser) Read(b []byte) (ok bool, err error)

Read scan the bytes in buffer, ok == true if read a full http-header, err != nil if error occurs

func (*HTTPHeaderParser) Reset

func (p *HTTPHeaderParser) Reset()

Reset reset the state of http header parser

func (*HTTPHeaderParser) Store

func (p *HTTPHeaderParser) Store(key []byte, value []byte) (ok bool)

Store appends a key-value pair to the headers

func (*HTTPHeaderParser) StoreFirstline1

func (p *HTTPHeaderParser) StoreFirstline1(b []byte) (ok bool)

StoreFirstline1 store the first string of http first line

func (*HTTPHeaderParser) StoreFirstline2

func (p *HTTPHeaderParser) StoreFirstline2(b []byte) (ok bool)

StoreFirstline2 store the first string of http first line

func (*HTTPHeaderParser) StoreFirstline3

func (p *HTTPHeaderParser) StoreFirstline3(b []byte) (ok bool)

StoreFirstline3 store the first string of http first line

type IPTree

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

IPTree implements radix tree for IP tree

func NewIPTree

func NewIPTree() *IPTree

NewIPTree creates IP tree

func (*IPTree) Insert

func (tree *IPTree) Insert(s string)

Insert inserts a CIDR string or an ip string to the tree

func (*IPTree) InsertIP

func (tree *IPTree) InsertIP(ip net.IP)

InsertIP inserts an IP to the tree

func (*IPTree) InsertIPNet

func (tree *IPTree) InsertIPNet(ipnet *net.IPNet)

InsertIPNet inserts an ipnet to the tree, eg: 127.0.0.1/24

func (*IPTree) Test

func (tree *IPTree) Test(s string) bool

Test test whether an IP string is in the tree

func (*IPTree) TestIP

func (tree *IPTree) TestIP(ip net.IP) bool

TestIP test whether an net.IP is in the tree

type LRU

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

LRU implements a simple and thread-safe LRU cache

func NewLRU

func NewLRU(maxlen int, onCheck CheckCallback, onDelete DeleteCallback) *LRU

NewLRU init a new lru

func (*LRU) Add

func (lru *LRU) Add(key, value interface{})

Add inserts new key and value into the lru

func (*LRU) Delete

func (lru *LRU) Delete(key interface{}) (value interface{}, ok bool)

Delete deletes the key from cache, returns its value and if cache has the key

func (*LRU) DeleteOldest

func (lru *LRU) DeleteOldest() (key, value interface{}, ok bool)

DeleteOldest deletes the oldest entry from cache returns its key, value and if delete is successful

func (*LRU) Has

func (lru *LRU) Has(key interface{}) (ok bool)

Has test if the key is in the lru cache, and don't update the lru

func (*LRU) Length

func (lru *LRU) Length() int

Length returns the number of entries

func (*LRU) Load

func (lru *LRU) Load(key interface{}) (value interface{}, ok bool)

Load get the value from lru cache with given key, ok returns false if key is not in the lru

type Lock

type Lock struct {
	sync.Mutex
}

func (*Lock) RunInLock

func (l *Lock) RunInLock(f func())

type Locker

type Locker interface {
	RunInLock(f func())
}

type PlainCipherStream

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

func (*PlainCipherStream) GetIV

func (p *PlainCipherStream) GetIV() []byte

func (*PlainCipherStream) Read

func (p *PlainCipherStream) Read(b []byte) (n int, err error)

func (*PlainCipherStream) Write

func (p *PlainCipherStream) Write(b []byte) (n int, err error)

type RWLock

type RWLock struct {
	sync.RWMutex
}

func (*RWLock) RunInLock

func (l *RWLock) RunInLock(f func())

func (*RWLock) RunInRLock

func (l *RWLock) RunInRLock(f func())

type RWLocker

type RWLocker interface {
	Locker
	RunInRLock(f func())
}

type RandomDropConn

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

func NewRandomDropConn

func NewRandomDropConn(conn net.Conn, dropRate int) *RandomDropConn

func (*RandomDropConn) Read

func (conn *RandomDropConn) Read(b []byte) (n int, err error)

func (*RandomDropConn) Write

func (conn *RandomDropConn) Write(b []byte) (n int, err error)

type RateLogConn

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

func NewRateLogConn

func NewRateLogConn(conn net.Conn, name string) *RateLogConn

func (*RateLogConn) Close

func (conn *RateLogConn) Close() error

func (*RateLogConn) GetAndClearNRW

func (conn *RateLogConn) GetAndClearNRW() (int, int)

func (*RateLogConn) Read

func (conn *RateLogConn) Read(b []byte) (n int, err error)

func (*RateLogConn) Write

func (conn *RateLogConn) Write(b []byte) (n int, err error)

type Salsa20CipherStream

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

func (*Salsa20CipherStream) GetIV

func (b *Salsa20CipherStream) GetIV() []byte

func (*Salsa20CipherStream) Read

func (b *Salsa20CipherStream) Read(p []byte) (n int, err error)

func (*Salsa20CipherStream) Write

func (b *Salsa20CipherStream) Write(p []byte) (n int, err error)

type ServerHelloMsg

type ServerHelloMsg struct {
	Raw                          []byte
	Vers                         uint16
	Random                       []byte
	SessionId                    []byte
	CipherSuite                  uint16
	CompressionMethod            uint8
	NextProtoNeg                 bool
	NextProtos                   []string
	OcspStapling                 bool
	Scts                         [][]byte
	TicketSupported              bool
	SecureRenegotiation          []byte
	SecureRenegotiationSupported bool
	AlpnProtocol                 string
	OtherExtensions              []Extension
}

func ParseTLSServerHelloMsg

func ParseTLSServerHelloMsg(b []byte) (ok bool, n int, msg *ServerHelloMsg)

ParseTLSServerHelloMsg scan the buffer and try to parse TLS ServerHello Message ok returns false if it's not tls server hello msg

func (*ServerHelloMsg) Marshal

func (m *ServerHelloMsg) Marshal() []byte

func (*ServerHelloMsg) Unmarshal

func (m *ServerHelloMsg) Unmarshal(data []byte) bool

type SliceConn

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

func NewSliceConn

func NewSliceConn(conn net.Conn, mtu int) *SliceConn

func (*SliceConn) Read

func (conn *SliceConn) Read(b []byte) (n int, err error)

func (*SliceConn) Write

func (conn *SliceConn) Write(b []byte) (n int, err error)

type SubConn

type SubConn struct {
	net.PacketConn
	// contains filtered or unexported fields
}

SubConn is the child connection of a net.PacketConn

func (*SubConn) Close

func (conn *SubConn) Close() error

Close close the connection and delete it from connsMap

func (*SubConn) Read

func (conn *SubConn) Read(b []byte) (n int, err error)

func (*SubConn) RemoteAddr

func (conn *SubConn) RemoteAddr() net.Addr

RemoteAddr return the address of peer

func (*SubConn) SetReadDeadline

func (conn *SubConn) SetReadDeadline(t time.Time) error

SetReadDeadline set the dealdine of read

func (*SubConn) Write

func (conn *SubConn) Write(b []byte) (n int, err error)

func (*SubConn) WriteBuffers

func (conn *SubConn) WriteBuffers(bufs [][]byte) (n int, err error)

WriteBuffers directly copy all buffers into a larger buf and send it

type SubUDPListener

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

SubUDPListener implements net.Listener and acts like tcp net.Listener

func (*SubUDPListener) Accept

func (listener *SubUDPListener) Accept() (net.Conn, error)

Accept accepts a new net.Conn from listner

func (*SubUDPListener) AcceptSub

func (listener *SubUDPListener) AcceptSub() (*SubConn, error)

AcceptSub accepts a new subconn from listner

func (*SubUDPListener) Addr

func (listener *SubUDPListener) Addr() net.Addr

Addr returns the local address of underlying packet connection

func (*SubUDPListener) Close

func (listener *SubUDPListener) Close() error

Close close listener and destroy everything

type UDPConn

type UDPConn interface {
	// Read reads data from the connection.
	// Read can be made to time out and return an Error with Timeout() == true
	// after a fixed time limit; see SetDeadline and SetReadDeadline.
	Read(b []byte) (n int, err error)

	// Write writes data to the connection.
	// Write can be made to time out and return an Error with Timeout() == true
	// after a fixed time limit; see SetDeadline and SetWriteDeadline.
	Write(b []byte) (n int, err error)

	// Close closes the connection.
	// Any blocked Read or Write operations will be unblocked and return errors.
	Close() error

	// LocalAddr returns the local network address.
	LocalAddr() net.Addr

	// RemoteAddr returns the remote network address.
	RemoteAddr() net.Addr

	// SetDeadline sets the read and write deadlines associated
	// with the connection. It is equivalent to calling both
	// SetReadDeadline and SetWriteDeadline.
	//
	// A deadline is an absolute time after which I/O operations
	// fail with a timeout (see type Error) instead of
	// blocking. The deadline applies to all future and pending
	// I/O, not just the immediately following call to Read or
	// Write. After a deadline has been exceeded, the connection
	// can be refreshed by setting a deadline in the future.
	//
	// An idle timeout can be implemented by repeatedly extending
	// the deadline after successful Read or Write calls.
	//
	// A zero value for t means I/O operations will not time out.
	SetDeadline(t time.Time) error

	// SetReadDeadline sets the deadline for future Read calls
	// and any currently-blocked Read call.
	// A zero value for t means Read will not time out.
	SetReadDeadline(t time.Time) error

	// SetWriteDeadline sets the deadline for future Write calls
	// and any currently-blocked Write call.
	// Even if write times out, it may return n > 0, indicating that
	// some of the data was successfully written.
	// A zero value for t means Write will not time out.
	SetWriteDeadline(t time.Time) error

	// ReadFrom reads a packet from the connection,
	// copying the payload into b. It returns the number of
	// bytes copied into b and the return address that
	// was on the packet.
	// ReadFrom can be made to time out and return
	// an Error with Timeout() == true after a fixed time limit;
	// see SetDeadline and SetReadDeadline.
	ReadFrom(b []byte) (n int, addr net.Addr, err error)

	// WriteTo writes a packet with payload b to addr.
	// WriteTo can be made to time out and return
	// an Error with Timeout() == true after a fixed time limit;
	// see SetDeadline and SetWriteDeadline.
	// On packet-oriented connections, write timeouts are rare.
	WriteTo(b []byte, addr net.Addr) (n int, err error)
}

UDPConn is the union set of net.Conn and net.PacketConn

type UDPServerCtx

type UDPServerCtx struct {
	Mtu     int
	Expires int
	// contains filtered or unexported fields
}

UDPServerCtx is the control centor of the udp server

func (*UDPServerCtx) RunUDPServer

func (ctx *UDPServerCtx) RunUDPServer(conn net.PacketConn, create func(*SubConn) (net.Conn, net.Conn, error))

RunUDPServer runs the udp server

type UtilsConn

type UtilsConn struct {
	net.Conn
}

UtilsConn is a net.Conn that implement the interface Conn

func DialTCP

func DialTCP(network string, laddr, raddr *net.TCPAddr) (conn *UtilsConn, err error)

DialTCP calls net.DialTCP and returns *UtilsConn

func NewConn

func NewConn(conn net.Conn) *UtilsConn

NewConn returns *UtilsConn from net.Conn

func (*UtilsConn) GetTCPConn

func (conn *UtilsConn) GetTCPConn() (t *net.TCPConn, ok bool)

GetTCPConn try to get the underlying TCPConn

func (*UtilsConn) WriteBuffers

func (conn *UtilsConn) WriteBuffers(bufs [][]byte) (n int, err error)

WriteBuffers can send serveral buffers at a time

type XORCipherStream

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

func (*XORCipherStream) GetIV

func (b *XORCipherStream) GetIV() []byte

func (*XORCipherStream) Read

func (b *XORCipherStream) Read(p []byte) (n int, err error)

func (*XORCipherStream) Write

func (b *XORCipherStream) Write(p []byte) (n int, err error)

Jump to

Keyboard shortcuts

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