common

package
v0.19.2 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2019 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CONN_DATA_SEQ     = "*#*" //Separator
	VERIFY_EER        = "vkey"
	VERIFY_SUCCESS    = "sucs"
	WORK_MAIN         = "main"
	WORK_CHAN         = "chan"
	WORK_CONFIG       = "conf"
	WORK_REGISTER     = "rgst"
	WORK_SECRET       = "sert"
	WORK_FILE         = "file"
	WORK_P2P          = "p2pm"
	WORK_P2P_VISITOR  = "p2pv"
	WORK_P2P_PROVIDER = "p2pp"
	WORK_STATUS       = "stus"
	RES_MSG           = "msg0"
	RES_CLOSE         = "clse"
	NEW_UDP_CONN      = "udpc" //p2p udp conn
	NEW_TASK          = "task"
	NEW_CONF          = "conf"
	NEW_HOST          = "host"
	CONN_TCP          = "tcp"
	CONN_UDP          = "udp"
	CONN_TEST         = "TST"
	UnauthorizedBytes = `HTTP/1.1 401 Unauthorized
Content-Type: text/plain; charset=utf-8
WWW-Authenticate: Basic realm="easyProxy"

401 Unauthorized`
	ConnectionFailBytes = `HTTP/1.1 404 Not Found

`
)

Variables

This section is empty.

Functions

func BinaryWrite

func BinaryWrite(raw *bytes.Buffer, v ...string)

Write length and individual byte data Length prevents sticking # Characters are used to separate data

func BytesToNum added in v0.18.2

func BytesToNum(b []byte) int

func ChangeHostAndHeader

func ChangeHostAndHeader(r *http.Request, host string, header string, addr string)

Change headers and host of request

func CheckAuth

func CheckAuth(r *http.Request, user, passwd string) bool

Check if the Request request is validated

func CopyBuffer added in v0.0.16

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

func DomainCheck

func DomainCheck(domain string) bool

Check the legality of domain

func FileExists

func FileExists(name string) bool

FileExists reports whether the named file or directory exists.

func FormatAddress added in v0.0.15

func FormatAddress(s string) string

func GetAppPath

func GetAppPath() string

Get the absolute path to the running directory

func GetBoolByStr

func GetBoolByStr(s string) bool

get bool by str

func GetEnvMap added in v0.18.1

func GetEnvMap() map[string]string

get env

func GetHostByName

func GetHostByName(hostname string) string

Get the corresponding IP address through domain name

func GetInstallPath

func GetInstallPath() string

Different systems get different installation paths

func GetIntNoErrByStr

func GetIntNoErrByStr(str string) int

int

func GetIpByAddr added in v0.0.15

func GetIpByAddr(addr string) string

func GetLocalUdpAddr added in v0.18.0

func GetLocalUdpAddr() (net.Conn, error)

send this ip forget to get a local udp port

func GetLogPath

func GetLogPath() string

interface log file path

func GetMapKeys added in v0.19.0

func GetMapKeys(m sync.Map) (keys []int)

func GetPorts added in v0.0.15

func GetPorts(p string) []int

format ports str to a int array

func GetRunPath

func GetRunPath() string

Get the currently selected configuration file directory For non-Windows systems, select the /etc/nps as config directory if exist, or select ./ windows system, select the C:\Program Files\nps as config directory if exist, or select ./

func GetStrByBool

func GetStrByBool(b bool) string

get str by bool

func GetTmpPath added in v0.0.15

func GetTmpPath() string

interface pid file path

func Getverifyval

func Getverifyval(vkey string) string

Get verify value

func InIntArr added in v0.0.15

func InIntArr(arr []int, val int) bool

inArray int interface

func InStrArr added in v0.0.16

func InStrArr(arr []string, val string) bool

inArray str interface

func IsArrContains added in v0.18.1

func IsArrContains(arr []string, val string) bool

func IsPort added in v0.0.15

func IsPort(p string) bool

func IsWindows

func IsWindows() bool

Determine whether the current system is a Windows system?

func ParseStr added in v0.18.1

func ParseStr(str string) (string, error)

func ReadAllFromFile

func ReadAllFromFile(filePath string) ([]byte, error)

Read file content by file path

func RemoveArrVal added in v0.18.1

func RemoveArrVal(arr []string, val string) []string

func TestTcpPort

func TestTcpPort(port int) bool

Judge whether the TCP port can open normally

func TestUdpPort

func TestUdpPort(port int) bool

Judge whether the UDP port can open normally

func TrimArr added in v0.18.1

func TrimArr(arr []string) []string

Types

This section is empty.

Jump to

Keyboard shortcuts

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