utils

package
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2021 License: Apache-2.0 Imports: 52 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AddressIPv4       = 1 // type is ipv4 address
	AddressDomainName = 3 // type is domain address
	AddressIPv6       = 4 // type is ipv6 address

)
View Source
const (
	AddrMask byte = 0xf
)
View Source
const DEFAULT_TIMEOUT = 86400
View Source
const (
	NORMAL_SCAN_DIR = "/etc/shadowsocks/:/tmp/_configs/"
)

Variables

View Source
var (
	ProxyAddr          = "127.0.0.1:1091"
	TestProxyAddr      = "127.0.0.1:40086"
	RouteIsBroken      = errors.New("Route is broken. can not connect to outer world!")
	SocksConnectBroken = errors.New("Socks5 connect Error!")
)
View Source
var (
	TODAY time.Time = time.Now()
	BOOK  Book      = Book{
			// contains filtered or unexported fields
	}
	HOME, _              = os.UserHomeDir()
	NORMAL_OPTIMISE_FILE = filepath.Join(HOME, "Desktop", "route.map.json")
	NORMAL_CONFIG_ROOT   = filepath.Join(HOME, "Desktop", "routes")
	SALT                 = "demo salt"
	CRY_LEN              = 4096
)
View Source
var AutoMap map[string][]ConfigSpeed
View Source
var BGCOLORS = []func(a ...interface{}) string{
	color.New(color.BgYellow, color.Bold).SprintFunc(),
	color.New(color.BgRed, color.Bold).SprintFunc(),
	color.New(color.BgGreen, color.Bold).SprintFunc(),
	color.New(color.BgBlue, color.Bold).SprintFunc(),
}
View Source
var (
	DEFAULT_RESOLEVER = DNSResolver{}
)
View Source
var END_BYTES = []byte{91, 91, 69, 79, 70, 93, 93}
View Source
var ErrUDPFragmentNoSupported = errors.New("")

ErrUDPFragmentNoSupported UDP fragments not supported error

View Source
var FGCOLORS = []func(a ...interface{}) string{
	color.New(color.FgYellow, color.Bold).SprintFunc(),
	color.New(color.FgRed, color.Bold).SprintFunc(),
	color.New(color.FgGreen, color.Bold).SprintFunc(),
	color.New(color.FgBlue, color.Bold).SprintFunc(),
}
View Source
var GloballeakyBuf = NewLeakyBu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UN2OE9WL0xhWApqL2FzdjRBUVlrSHVpWDM5N0JlUmdTd3V0RW1ZbkUwSm1PdG9IR3p5RHdLQmdDNTBtUDNVbzVYUmpYWlQzNnBsClU5SE51UzQ2OW8wcWNFd2d1b1JvUWxUWXp1MXJkT0M1WCtGbEpaWk5kcGczWVVUR0t6cXhGTVpLOVRjNzdnelMKRDV6VWVTQlBhamZiTVJmVHRsZkp2MmhBTEFBeEFWc3FMS3MzVkZPNDM2dGZyVFpQRlZNYWZpRU9OWkFLZ3VxaQpYcFY1OU5DTFdsN1RBUVFSWFRSZDdPNXIKLS0tLS1FTkQgUFJJVkFURSBLRVktLS0tLQpAMTI3LjAuMC4xOjEyMzQ1"
	PASWD = "" /* 4564-byte string literal not displayed */
)
View Source
var SpeedMsgCHANNEL = make(chan Statistic, 30)
View Source
var (
	Tmp = os.TempDir()
)

Functions

func ColorD

func ColorD(args interface{}, join ...string)

func ColorE

func ColorE(args ...interface{})

func ColorL

func ColorL(args ...interface{})

func ColorM

func ColorM(args ...interface{})

func Copy

func Copy(dst io.Writer, src io.Reader) (written int64, err error)

Memory optimized io.Copy function specified for this library

func CreateCertificate

func CreateCertificate(serverHost string, isCA bool) (configUri, base string)

func Credient

func Credient(username, password string) (routeDir string, err error)

will donwload file from your git://github.com/${name}/pro/config.en name : name/pro password will decrypt config

func DeepCopy

func DeepCopy(dst interface{}, src interface{})

func DialWithRawAddr

func DialWithRawAddr(rawaddr []byte, server string) (conn net.Conn, err error)

DialWithRawAddr is intended for use by users implementing a local socks proxy. rawaddr shoud contain part of the data in socks request, starting from the ATYP field. (Refer to rfc1928 for more information.)

func DownloadFile

func DownloadFile(filepath string, url string) error

DownloadFile will download a url to a local file. It's efficient because it will write as it downloads and not load the whole file into memory.

func GbkToUtf8

func GbkToUtf8(s []byte) ([]byte, error)

func GenerateConfigJsons

func GenerateConfigJsons(dstRoot string) (err error)

func GetLocalRequest

func GetLocalRequest(conn *net.Conn) (rawaddr []byte, host string, isUdp bool, err error)

func GetLocalRequestUDP

func GetLocalRequestUDP(conn *net.Conn) (rawaddr []byte, host string, err error)

func GetMainDomain

func GetMainDomain(urlOrHost string) string

func GetOldSpeedMap

func GetOldSpeedMap(filepath string) (out map[string][]ConfigSpeed)

func GetSSServerRequest

func GetSSServerRequest(conn net.Conn) (host string, raw []byte, isUdp bool, err error)

func GetServerRequest

func GetServerRequest(conn net.Conn) (host string, raw []byte, isUdp bool, err error)

func HostToRaw

func HostToRaw(host string, port int) (raw []byte)
func SetRTimeout(c io.Reader) {
	if readTimeout != 0 {
		c.SetReadDeadline(time.Now().Add(readTimeout))
	}
}

func IsDir

func IsDir(path string) bool

func KillProcess

func KillProcess() (err error)

func LogCopy

func LogCopy(src, dst net.Conn)

Copy write by my self

func Md5Str

func Md5Str(buf []byte) string

func ParseUDPSocks5

func ParseUDPSocks5(buf []byte) (host string, rawaddr []byte, err error)

func PathExists

func PathExists(path string) bool

func Pipe

func Pipe(p1, p2 net.Conn) (err error)

func PipeThenClose

func PipeThenClose(src, dst CanCopy)

func SendSpeedMsg

func SendSpeedMsg(ip string, usage int64, speed float64)

func SetConfigS

func SetConfigS(config *Config, addr string) (err error)

func SetDebug

func SetDebug(d DebugLog)

SetDebug if ok

func SetKcpReadTimeout

func SetKcpReadTimeout(c *kcp.UDPSession)

func SetReadTimeout

func SetReadTimeout(c *net.Conn)

func SetStreamReadTimeout

func SetStreamReadTimeout(c *smux.Stream)

func Socks5HandShake

func Socks5HandShake(conn *net.Conn) (err error)

func SpeedShow

func SpeedShow()

func Stat

func Stat(cmd string, s bool)

func Sync

func Sync(configRoot string) (file string, err error)

func Tcp2Kcp

func Tcp2Kcp(src, dst io.ReadWriteCloser)

func Unzip

func Unzip(src string, dest string) ([]string, error)

Unzip will decompress a zip archive, moving all files and folders within the zip file (parameter 1) to an output directory (parameter 2).

func UpdateConfig

func UpdateConfig(old, new *Config)

UpdateConfig : Useful for command line to override options specified in config file Debug is not updated.

func Utf8ToGbk

func Utf8ToGbk(s []byte) ([]byte, error)

Types

type AddrSpec

type AddrSpec struct {
	FQDN string
	IP   net.IP
	Port int
}

AddrSpec is used to return the target AddrSpec which may be specified as IPv4, IPv6, or a FQDN

func (AddrSpec) Address

func (a AddrSpec) Address() string

Address returns a string suitable to dial; prefer returning IP-based address, fallback to FQDN

func (*AddrSpec) String

func (a *AddrSpec) String() string

type Book

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

func NewBook

func NewBook() *Book

func (*Book) Add

func (book *Book) Add(ssuri string) (s string, err error)

func (*Book) Books

func (book *Book) Books() (cons []Config)

func (*Book) Count

func (book *Book) Count() int

func (*Book) FlowGet

func (book *Book) FlowGet() (config *Config)

func (*Book) Get

func (book *Book) Get(server ...string) (config *Config)

func (*Book) GetServers

func (book *Book) GetServers() (s []string)

func (*Book) Info

func (book *Book) Info() (cs []string, err error)

func (*Book) Ls

func (book *Book) Ls() (cs []string, err error)

func (*Book) RandGet

func (book *Book) RandGet(server ...string) (config *Config)

func (*Book) Scan

func (book *Book) Scan(dirs ...string) (dirErr error)

Scan config in dir try to found correct json files

type CanCopy

type CanCopy interface {
	io.Reader
	io.Writer
	io.Closer
}

type CanDeadLine

type CanDeadLine interface {
	SetReadDeadline(t time.Time) error
}

type Config

type Config struct {
	Server       interface{} `json:"server"`
	ServerPort   int         `json:"server_port"`
	LocalPort    int         `json:"local_port"`
	LocalAddress string      `json:"local_address"`
	Password     string      `json:"password"`
	Method       string      `json:"method"` // encryption method

	// following options are only used by server
	PortPassword map[string]string `json:"port_password"`
	Timeout      int               `json:"timeout"`

	// The order of servers in the client config is significant, so use array
	// instead of map to preserve the order.
	ServerPassword string `json:"server_password"`

	// shadowsocks options
	SSPassword string `json:"ss_password"`
	OldSSPwd   string `json:"ss_old"`
	SSMethod   string `json:"ss_method"`
	SALT       string `json:"salt"`
	EBUFLEN    int    `json:"buflen"`
}

Config can use file to load

func ParseConfig

func ParseConfig(path string) (config *Config, err error)

ParseConfig parse path to json

func ParseURI

func ParseURI(u string) (config *Config)

func (*Config) GeneratePassword

func (config *Config) GeneratePassword(plugin ...string) (en kcp.BlockCrypt)

GeneratePassword by config

func (*Config) GetBook

func (config *Config) GetBook(key string) (book *Config)

GetBook reutrn book

func (*Config) GetBookByID

func (config *Config) GetBookByID(id uint16) (book *Config)

GetBookByID return a book from BOOK

func (*Config) GetServerArray

func (config *Config) GetServerArray() []string

GetServerArray get server

func (*Config) ToFile

func (config *Config) ToFile(dst string) (err error)

func (*Config) ToJson

func (config *Config) ToJson() string

func (*Config) ToString

func (config *Config) ToString() string

func (*Config) ToTlsConfig

func (config *Config) ToTlsConfig() (tlsConfig *TlsConfig, err error)

func (*Config) ToUri

func (config *Config) ToUri() string

type ConfigSpeed

type ConfigSpeed struct {
	Server string
	Url    string
	Used   float32
}

func TestURLUsedTime

func TestURLUsedTime(requrl, host string) ConfigSpeed

type DNSResolver

type DNSResolver struct{}

DNSResolver uses the system DNS to resolve host names

func (DNSResolver) Resolve

func (d DNSResolver) Resolve(ctx context.Context, name string) (context.Context, net.IP, error)

Resolve ...

type DebugLog

type DebugLog bool
var Debug DebugLog

func (DebugLog) Printf

func (d DebugLog) Printf(format string, args ...interface{})

func (DebugLog) Println

func (d DebugLog) Println(args ...interface{})

type KcpBase

type KcpBase struct {
	Numconn int

	IsHeartBeat bool
	Role        string
	Messages    chan string
	IfCompress  bool
	Plugin      string

	RedirectBooks map[string]*Route
	// contains filtered or unexported fields
}

func (*KcpBase) Activate

func (kcpBase *KcpBase) Activate(do_some func() error) error

func (*KcpBase) AddAlive

func (kcpBase *KcpBase) AddAlive()

func (*KcpBase) AddReverseCon

func (kcpBase *KcpBase) AddReverseCon()

func (*KcpBase) DelReverseCon

func (kcpBase *KcpBase) DelReverseCon()

func (*KcpBase) GetActivateConn

func (kcpBase *KcpBase) GetActivateConn() int

func (*KcpBase) GetAliveNum

func (kcpBase *KcpBase) GetAliveNum() int

func (*KcpBase) GetAliveReverseCon

func (kcpBase *KcpBase) GetAliveReverseCon() int

func (*KcpBase) GetConfig

func (kcpBase *KcpBase) GetConfig() *Config

func (*KcpBase) GetKcpConfig

func (kcpBase *KcpBase) GetKcpConfig() *KcpConfig

func (*KcpBase) GetRefreshRate

func (kcpBase *KcpBase) GetRefreshRate() time.Duration

func (*KcpBase) GetSession

func (kcpBase *KcpBase) GetSession(idx uint16) (session *smux.Session)

func (*KcpBase) GetSmuxConfig

func (kcpBase *KcpBase) GetSmuxConfig() *smux.Config

func (*KcpBase) HandleUDP

func (s *KcpBase) HandleUDP(udpConn *net.UDPConn)

func (*KcpBase) HeartBeatC

func (kcpBase *KcpBase) HeartBeatC(stream net.Conn)

func (*KcpBase) HeartBeatS

func (kcpBase *KcpBase) HeartBeatS(stream net.Conn, fromHost string, clearAfter func(h string))

func (*KcpBase) HiddenConnListener

func (kcp *KcpBase) HiddenConnListener()

func (*KcpBase) HiidenConfig

func (kcp *KcpBase) HiidenConfig(con net.Conn)

func (*KcpBase) Init

func (kcpBase *KcpBase) Init(config *Config)

func (*KcpBase) ListenUDP

func (serv *KcpBase) ListenUDP(ip string, port int)

func (*KcpBase) Pipe

func (kcpBase *KcpBase) Pipe(p1, p2 net.Conn)

func (*KcpBase) ReConnection

func (kcpBase *KcpBase) ReConnection() (session *smux.Session, err error)

func (*KcpBase) RecvMsg

func (kcpBase *KcpBase) RecvMsg(filter ...string) (pre string, content string)

func (*KcpBase) SendMsg

func (kcpBase *KcpBase) SendMsg(pre string, content string)

func (*KcpBase) SetConfig

func (kcpBase *KcpBase) SetConfig(config *Config)

func (*KcpBase) SetKcpConfig

func (kcpBase *KcpBase) SetKcpConfig(config *KcpConfig)

func (*KcpBase) SetRedirectIRC

func (kcp *KcpBase) SetRedirectIRC(man *remote.ApiServerMan, ip string)

func (*KcpBase) SetRefreshRate

func (kcpBase *KcpBase) SetRefreshRate(interval int)

func (*KcpBase) SetTunnelNum

func (kcpBase *KcpBase) SetTunnelNum(n int) int

func (*KcpBase) ShowConfig

func (kcpBase *KcpBase) ShowConfig()

func (*KcpBase) UpdateConfig

func (kcpBase *KcpBase) UpdateConfig(uri string)

func (*KcpBase) UpdateKcpConfig

func (kcpBase *KcpBase) UpdateKcpConfig(kcpconn *kcp.UDPSession)

func (*KcpBase) WaitConn

func (kcpBase *KcpBase) WaitConn(config *Config) *smux.Session

func (*KcpBase) WithSession

func (kcpBase *KcpBase) WithSession(config *Config, id ...uint16) (session *smux.Session)

func (*KcpBase) WithTestSession

func (kcpBase *KcpBase) WithTestSession(config *Config, howTo func(sess *smux.Session))

type KcpConfig

type KcpConfig struct {
	Mode         string `json:"mode"`
	NoDelay      int    `json:"nodelay"`
	Interval     int    `json:"interval"`
	Resend       int    `json:"resend"`
	NoCongestion int    `json:"nocongeestion"`
	AutoExpire   int    `json:"autoexpire"`
	ScavengeTTL  int    `json:"scavengettl"`
	MTU          int    `json:"mtu"`
	SndWnd       int    `json:"sndwnd"`
	RcvWnd       int    `json:"rcvwnd"`
	DataShard    int    `json:"datashard"`
	ParityShard  int    `json:"parityshard"`
	KeepAlive    int    `json:"keepalive"`
	SmuxBuf      int    `json:"smuxbuf"`
	StreamBuf    int    `json:"streambuf"`
	AckNodelay   bool   `json:"acknodelay"`
	SocketBuf    int    `json:"socketbuf"`
}

func (*KcpConfig) GenerateConfig

func (kconfig *KcpConfig) GenerateConfig() *smux.Config

func (*KcpConfig) SetAsDefault

func (kconfig *KcpConfig) SetAsDefault()

func (*KcpConfig) UpdateMode

func (kconfig *KcpConfig) UpdateMode()

type LeakyBuf

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

func NewLeakyBuf

func NewLeakyBuf(n, bufSize int) *LeakyBuf

NewLeakyBuf creates a leaky buffer which can hold at most n buffer, each with bufSize bytes.

func (*LeakyBuf) Get

func (lb *LeakyBuf) Get() (b []byte)

Get returns a buffer from the leaky buffer or create a new buffer.

func (*LeakyBuf) Put

func (lb *LeakyBuf) Put(b []byte)

Put add the buffer into the free buffer pool for reuse. Panic if the buffer size is not the same with the leaky buffer's. This is intended to expose error usage of leaky buffer.

type NameResolver

type NameResolver interface {
	Resolve(ctx context.Context, name string) (context.Context, net.IP, error)
}

NameResolver is used to implement custom name resolution

type Route

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

func NewRoute

func NewRoute(cmd string) (route *Route, err error)

func (*Route) GetConfig

func (route *Route) GetConfig() *Config

func (*Route) Host

func (route *Route) Host() string

func (*Route) IfNoExpired

func (route *Route) IfNoExpired() bool

func (*Route) Left

func (route *Route) Left() int

func (*Route) Mode

func (route *Route) Mode() string

func (*Route) SetConfig

func (route *Route) SetConfig(config *Config)

func (*Route) SetExireTime

func (route *Route) SetExireTime(sec int)

func (*Route) SetMode

func (route *Route) SetMode(mode string)

type SpeedBar

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

type SpeedTest

type SpeedTest struct {
	SortResults map[string][]ConfigSpeed
	// contains filtered or unexported fields
}

func NewSpeedTest

func NewSpeedTest() (tester *SpeedTest)

func (*SpeedTest) FlowMode

func (test *SpeedTest) FlowMode() (output string, err error)

func (*SpeedTest) GetHistoryUrls

func (test *SpeedTest) GetHistoryUrls() (history []string, err error)

GetHistoryUrls s GetHistoryUrls s

func (*SpeedTest) GetNow

func (test *SpeedTest) GetNow() (out map[string]string, err error)

func (*SpeedTest) LsConfig

func (test *SpeedTest) LsConfig() (output map[string]string, err error)

func (*SpeedTest) LsRoute

func (test *SpeedTest) LsRoute() (out string, err error)

func (*SpeedTest) LsStop

func (test *SpeedTest) LsStop() (out string, err error)

func (*SpeedTest) SetConfig

func (test *SpeedTest) SetConfig(config *Config) (err error)

func (*SpeedTest) SetRoute

func (test *SpeedTest) SetRoute(uri ...string) (output string, err error)

func (*SpeedTest) ShowConfig

func (test *SpeedTest) ShowConfig(ip string) (output string, err error)

func (*SpeedTest) TestAllConfigs

func (test *SpeedTest) TestAllConfigs(howTest func(proaxyaddr string, config Config))

func (*SpeedTest) TestOneConfig

func (test *SpeedTest) TestOneConfig(config *Config, addr string)

func (*SpeedTest) TestSpeed

func (test *SpeedTest) TestSpeed(urls []string, dirs ...string) (out map[string][]ConfigSpeed)

type Statistic

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

type TlsConfig

type TlsConfig struct {
	Ca     x509.CertPool
	Cert   tls.Certificate
	Server string
	// contains filtered or unexported fields
}

func UseDefaultTlsConfig

func UseDefaultTlsConfig(addr string) (tlsConfig *TlsConfig)

func (*TlsConfig) GenerateConfig

func (tlsConfig *TlsConfig) GenerateConfig() (config tls.Config)

func (*TlsConfig) WithConn

func (tlsConfig *TlsConfig) WithConn() (conn *tls.Conn, err error)

func (*TlsConfig) WithTlsListener

func (tlsConfig *TlsConfig) WithTlsListener() (listenr net.Listener, err error)

type UrlSpeed

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

Jump to

Keyboard shortcuts

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