utils

package
v10.0.4+incompatible Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2019 License: GPL-3.0 Imports: 34 Imported by: 0

Documentation

Overview

Provides leaky buffer, based on the example in Effective Go.

Index

Constants

View Source
const LeakyBufSize = 2048 // data.len(2) + hmacsha1(10) + data(4096)

Variables

View Source
var LeakyBuffer = NewLeakyBuf(maxNBuf, LeakyBufSize)

Functions

func BuildBytesPacket

func BuildBytesPacket(packetType uint8, data ...[]byte) []byte

func BuildPacket

func BuildPacket(packetType uint8, data ...string) []byte

func BuildPacketBytes

func BuildPacketBytes(data ...[]byte) []byte

func BuildPacketData

func BuildPacketData(data ...string) []byte

func CloseConn

func CloseConn(conn *net.Conn)

func ConnectHost

func ConnectHost(hostAndPort string, timeout int) (conn net.Conn, err error)

func ConnectKCPHost

func ConnectKCPHost(hostAndPort string, config kcpcfg.KCPConfigArgs) (conn net.Conn, err error)

func GetAllInterfaceAddr

func GetAllInterfaceAddr() ([]net.IP, error)

func GetKCPBlock

func GetKCPBlock(method, key string) (block kcp.BlockCrypt)

func HTTPGet

func HTTPGet(URL string, timeout int) (err error)

func HttpGet

func HttpGet(URL string, timeout int, host ...string) (body []byte, code int, err error)

func InsertProxyHeaders

func InsertProxyHeaders(head []byte, headers string) []byte

func IoBind

func IoBind(dst io.ReadWriteCloser, src io.ReadWriteCloser, fn func(err interface{}), log *logger.Logger)

func IoBindNoClose

func IoBindNoClose(dst io.ReadWriteCloser, src io.ReadWriteCloser, fn func(err interface{}), log *logger.Logger)

func IsHTTP

func IsHTTP(head []byte) bool

func IsInternalIP

func IsInternalIP(domainOrIP string, always bool) bool

func IsNetClosedErr

func IsNetClosedErr(err error) bool

func IsNetDeadlineErr

func IsNetDeadlineErr(err error) bool

func IsNetRefusedErr

func IsNetRefusedErr(err error) bool

func IsNetSocketNotConnectedErr

func IsNetSocketNotConnectedErr(err error) bool

func IsNetTimeoutErr

func IsNetTimeoutErr(err error) bool

func IsSocks5

func IsSocks5(head []byte) bool

func LBMethod

func LBMethod(key string) int

func LookupIP

func LookupIP(host string) ([]net.IP, error)

func NewCompConn

func NewCompConn(conn net.Conn) net.Conn

func NewDefaultLogger

func NewDefaultLogger() *logger.Logger

func PathExists

func PathExists(_path string) bool

func RandInt

func RandInt(strLen int) int64

func RandString

func RandString(strlen int) string

func ReadBytes

func ReadBytes(r io.Reader) (data []byte, err error)

func ReadBytesPacket

func ReadBytesPacket(r io.Reader, packetType *uint8, data ...*[]byte) (err error)

typed packet with bytes

func ReadData

func ReadData(r io.Reader) (data string, err error)

func ReadPacket

func ReadPacket(r io.Reader, packetType *uint8, data ...*string) (err error)

typed packet with string

func ReadPacketBytes

func ReadPacketBytes(r io.Reader, data ...*[]byte) (err error)

non typed packet with Bytes

func ReadPacketData

func ReadPacketData(r io.Reader, data ...*string) (err error)

non typed packet with string

func ReadUDPPacket

func ReadUDPPacket(_reader io.Reader) (srcAddr string, packet []byte, err error)

func RemoveProxyHeaders

func RemoveProxyHeaders(head []byte) []byte

func SingleTlsConfig

func SingleTlsConfig(caCertBytes []byte) (conf *tls.Config, err error)

func SingleTlsConnect

func SingleTlsConnect(host string, port, timeout int, caCertBytes []byte) (conn tls.Conn, err error)

func SingleTlsConnectHost

func SingleTlsConnectHost(host string, timeout int, caCertBytes []byte) (conn tls.Conn, err error)

func SubBytes

func SubBytes(bytes []byte, start, end int) []byte

func SubStr

func SubStr(str string, start, end int) string

func TlsBytes

func TlsBytes(cert, key string) (certBytes, keyBytes []byte, err error)

func TlsConfig

func TlsConfig(certBytes, keyBytes, caCertBytes []byte) (conf *tls.Config, err error)

func TlsConnect

func TlsConnect(host string, port, timeout int, certBytes, keyBytes, caCertBytes []byte) (conn tls.Conn, err error)

func TlsConnectHost

func TlsConnectHost(host string, timeout int, certBytes, keyBytes, caCertBytes []byte) (conn tls.Conn, err error)

func UDPCopy

func UDPCopy(dst, src *net.UDPConn, dstAddr net.Addr, readTimeout time.Duration, beforeWriteFn func(data []byte) []byte, deferFn func(e interface{}))

func UDPPacket

func UDPPacket(srcAddr string, packet []byte) []byte

func Uniqueid

func Uniqueid() string

Types

type BasicAuth

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

func NewBasicAuth

func NewBasicAuth(dns *dnsx.DomainResolver, log *logger.Logger) BasicAuth

func (*BasicAuth) Add

func (ba *BasicAuth) Add(userpassArr []string) (n int)

func (*BasicAuth) AddFromFile

func (ba *BasicAuth) AddFromFile(file string) (n int, err error)

func (*BasicAuth) Check

func (ba *BasicAuth) Check(userpass string, userIP, localIP, target string) (ok bool)

func (*BasicAuth) CheckUserPass

func (ba *BasicAuth) CheckUserPass(user, pass, userIP, localIP, target string) (ok bool)

func (*BasicAuth) Delete

func (ba *BasicAuth) Delete(userArr []string)

func (*BasicAuth) SetAuthURL

func (ba *BasicAuth) SetAuthURL(URL string, code, timeout, retry int)

func (*BasicAuth) Total

func (ba *BasicAuth) Total() (n int)

type