Documentation
¶
Index ¶
- Constants
- Variables
- func BinaryWrite(raw *bytes.Buffer, v ...string)
- func BuildAddress(host string, port string) string
- func BuildUdpBindAddr(serverIP string, clientIP net.IP) (network string, addr *net.UDPAddr)
- func BytesToNum(b []byte) int
- func BytesToTimestamp(b []byte) int64
- func CalibrateTimeOffset(server string) (time.Duration, error)
- func CheckAuth(r *http.Request, user, passwd string, accountMap, authMap map[string]string) bool
- func CheckAuthWithAccountMap(u, p, user, passwd string, accountMap, authMap map[string]string) bool
- func ContainsFold(s, substr string) bool
- func CopyBuffer(dst io.Writer, src io.Reader, label ...string) (written int64, err error)
- func DealMultiUser(s string) map[string]string
- func DecodeIP(data []byte) net.IP
- func DomainCheck(domain string) bool
- func EncodeIP(ip net.IP) []byte
- func ExtendArrs(arrays ...*[]string) int
- func ExtractHost(input string) string
- func FetchExternalIp() string
- func FileExists(name string) bool
- func FormatAddress(s string) string
- func GetAppPath() string
- func GetBoolByStr(s string) bool
- func GetBufPoolCopy() []byte
- func GetCertContent(filePath, header string) (string, error)
- func GetCertType(s string) string
- func GetConfigPath() string
- func GetCustomDNS() string
- func GetEnvMap() map[string]string
- func GetExtFromPath(path string) string
- func GetExternalIp() string
- func GetFastAddr(addr string, testType string) (string, error)
- func GetHostByName(hostname string) string
- func GetInstallPath() string
- func GetIntNoErrByStr(str string) int
- func GetIntranetIp() string
- func GetIpByAddr(host string) string
- func GetLocalUdp4Addr() (net.Conn, error)
- func GetLocalUdp6Addr() (net.Conn, error)
- func GetLocalUdpAddr() (net.Conn, error)
- func GetLogPath() string
- func GetMatchingLocalAddr(remoteAddr, localAddr string) (string, error)
- func GetNpcLogPath() string
- func GetOutboundIP() net.IP
- func GetOutboundIPv6() net.IP
- func GetPath(filePath string) string
- func GetPort(value int) int
- func GetPortByAddr(addr string) int
- func GetPortStrByAddr(addr string) string
- func GetPorts(s string) []int
- func GetRunPath() string
- func GetRunSecs() int64
- func GetRunTime() string
- func GetServerIp(ip string) string
- func GetServerIpByClientIp(clientIp net.IP) string
- func GetSni(host string) string
- func GetStartTime() int64
- func GetStrByBool(b bool) string
- func GetSyncMapLen(m *sync.Map) int
- func GetTimeNoErrByStr(str string) time.Time
- func GetTmpPath() string
- func GetWriteStr(v ...string) []byte
- func HandleArrEmptyVal(list []string) []string
- func InIntArr(arr []int, val int) bool
- func InStrArr(arr []string, val string) bool
- func InitPProfByAddr(addr string)
- func IsArrContains(arr []string, val string) bool
- func IsBlackIp(ipPort, vkey string, blackIpList []string) bool
- func IsDomain(s string) bool
- func IsPort(p string) bool
- func IsPublicIP(IP net.IP) bool
- func IsSameIPType(addr1, addr2 string) bool
- func IsTrustedProxy(list, ipStr string) bool
- func IsValidIP(ip string) bool
- func IsWindows() bool
- func IsZeroIP(ip net.IP) bool
- func JoinHostPort(host string, port string) string
- func LoadCert(certFile, keyFile string) (tls.Certificate, bool)
- func LoadCertPair(certFile, keyFile string) (certContent, keyContent string, ok bool)
- func Max(values ...int) int
- func Min(values ...int) int
- func NormalizeIP(ip net.IP) net.IP
- func ParseStr(str string) (string, error)
- func PickEgressIPFor(dstIP net.IP) net.IP
- func PutBufPoolCopy(buf []byte)
- func PutBufPoolMax(buf []byte)
- func PutBufPoolUdp(buf []byte)
- func RandomBytes(maxLen int) ([]byte, error)
- func ReadAllFromFile(filePath string) ([]byte, error)
- func RemoveArrVal(arr []string, val string) []string
- func RemovePortFromHost(host string) string
- func ResolvePath(path string) string
- func SetCustomDNS(dnsAddr string)
- func SetNtpInterval(d time.Duration)
- func SetNtpServer(server string)
- func SetTimezone(tz string) error
- func SplitAddrAndHost(s string) (addr, host, sni string)
- func SplitServerAndPath(s string) (server, path string)
- func SyncTime()
- func TestLatency(addr string, testType string) (time.Duration, error)
- func TestTcpPort(port int) bool
- func TestUdpPort(port int) bool
- func TimeNow() time.Time
- func TimeOffset() time.Duration
- func TimestampToBytes(ts int64) []byte
- func TrimArr(arr []string) []string
- func ValidateAddr(s string) string
- func ValidatePoW(bits int, parts ...string) bool
- type Addr
- type NetPackager
- type UDPDatagram
- type UDPHeader
Constants ¶
const ( CONN_DATA_SEQ = "*#*" // Separator VERIFY_EER = "vkey" VERIFY_SUCCESS = "sucs" WORK_MAIN = "main" WORK_CHAN = "chan" WORK_VISITOR = "vstr" WORK_CONFIG = "conf" WORK_REGISTER = "rgst" WORK_SECRET = "sert" WORK_FILE = "file" WORK_P2P = "p2pm" WORK_P2P_VISITOR = "p2pv" WORK_P2P_PROVIDER = "p2pp" WORK_P2P_CONNECT = "p2pc" WORK_P2P_SUCCESS = "p2ps" WORK_P2P_END = "p2pe" WORK_P2P_LAST = "p2pl" 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_ALL = "all" CONN_TCP = "tcp" CONN_UDP = "udp" CONN_KCP = "kcp" CONN_TLS = "tls" CONN_QUIC = "quic" CONN_WEB = "web" CONN_WS = "ws" CONN_WSS = "wss" CONN_TEST = "TST" CONN_ACK = "ACK" PING = "ping" PONG = "pong" TEST = "test" TOTP_SEQ = "totp:" // TOTP Separator "Content-Type: text/plain; charset=utf-8\r\n" + "WWW-Authenticate: Basic realm=\"easyProxy\"\r\n" + "\r\n" + "401 Unauthorized" ProxyAuthRequiredBytes = "HTTP/1.1 407 Proxy Authentication Required\r\n" + "Proxy-Authenticate: Basic realm=\"Proxy\"\r\n" + "Content-Length: 0\r\n" + "Connection: close\r\n" + "\r\n" ConnectionFailBytes = "HTTP/1.1 404 Not Found\r\n" + "\r\n" )
const PoolSize = 64 << 10
const PoolSizeCopy = 32 << 10
const PoolSizeSmall = 100
const PoolSizeUdp = 1472 + 200
Variables ¶
var BufPoolCopy = sync.Pool{ New: func() interface{} { return make([]byte, PoolSizeCopy) }, }
var BufPoolMax = sync.Pool{ New: func() interface{} { return make([]byte, PoolSize) }, }
var BufPoolSmall = sync.Pool{ New: func() interface{} { return make([]byte, PoolSizeSmall) }, }
var BufPoolUdp = sync.Pool{ New: func() interface{} { return make([]byte, PoolSizeUdp) }, }
var ConfPath string
var CopyBuff = copyBufferPool{}
var DefaultPort = map[string]string{
"tcp": "8024",
"kcp": "8024",
"tls": "8025",
"quic": "8025",
"ws": "80",
"wss": "443",
}
var StartTime = time.Now()
Functions ¶
func BinaryWrite ¶
BinaryWrite Write length and individual byte data Length prevents sticking # Characters are used to separate data
func BuildAddress ¶ added in v0.26.51
func BuildUdpBindAddr ¶ added in v0.33.9
func BytesToTimestamp ¶ added in v0.27.0
BytesToTimestamp 8bit
func CalibrateTimeOffset ¶ added in v0.30.0
func CheckAuthWithAccountMap ¶
CheckAuthWithAccountMap u current login user p current login passwd user global user passwd global passwd accountMap enable multi user auth
func ContainsFold ¶ added in v0.26.45
func CopyBuffer ¶
func DealMultiUser ¶ added in v0.26.47
func ExtendArrs ¶ added in v0.26.48
func FetchExternalIp ¶ added in v0.26.46
func FetchExternalIp() string
func FileExists ¶
FileExists reports whether the named file or directory exists.
func FormatAddress ¶
FormatAddress if the s is just a port,return 127.0.0.1:s
func GetAppPath ¶
func GetAppPath() string
GetAppPath Get the absolute path to the running directory
func GetBufPoolCopy ¶
func GetBufPoolCopy() []byte
func GetCertContent ¶
func GetCertType ¶ added in v0.29.9
func GetCustomDNS ¶ added in v0.26.46
func GetCustomDNS() string
func GetExtFromPath ¶
func GetExternalIp ¶
func GetExternalIp() string
func GetHostByName ¶
GetHostByName Get the corresponding IP address through domain name
func GetInstallPath ¶
func GetInstallPath() string
GetInstallPath Different systems get different installation paths
func GetIntranetIp ¶
func GetIntranetIp() string
func GetLocalUdp4Addr ¶ added in v0.26.47
func GetLocalUdp6Addr ¶ added in v0.26.47
func GetLocalUdpAddr ¶
GetLocalUdpAddr send this ip forget to get a local udp port
func GetMatchingLocalAddr ¶ added in v0.30.4
func GetOutboundIP ¶ added in v0.26.46
func GetOutboundIPv6 ¶ added in v0.29.3
func GetPortStrByAddr ¶ added in v0.29.20
func GetRunPath ¶
func GetRunPath() string
GetRunPath 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 GetRunSecs ¶ added in v0.29.5
func GetRunSecs() int64
func GetRunTime ¶ added in v0.29.3
func GetRunTime() string
func GetServerIp ¶ added in v0.26.46
func GetServerIpByClientIp ¶
func GetStartTime ¶ added in v0.29.5
func GetStartTime() int64
func GetSyncMapLen ¶ added in v0.30.4
GetSyncMapLen get the length of the sync map
func HandleArrEmptyVal ¶ added in v0.26.48
func InitPProfByAddr ¶ added in v0.32.2
func InitPProfByAddr(addr string)
func IsArrContains ¶
func IsPublicIP ¶
func IsSameIPType ¶ added in v0.26.47
func IsTrustedProxy ¶ added in v0.33.3
func IsWindows ¶
func IsWindows() bool
IsWindows Determine whether the current system is a Windows system?
func JoinHostPort ¶ added in v0.29.3
func LoadCertPair ¶ added in v0.26.48
func PutBufPoolCopy ¶
func PutBufPoolCopy(buf []byte)
func PutBufPoolMax ¶
func PutBufPoolMax(buf []byte)
func PutBufPoolUdp ¶
func PutBufPoolUdp(buf []byte)
func RandomBytes ¶ added in v0.27.0
func ReadAllFromFile ¶
ReadAllFromFile Read file content by file path
func RemoveArrVal ¶
RemoveArrVal remove value from string array
func RemovePortFromHost ¶
RemovePortFromHost return "[2001:db8::1]"
func ResolvePath ¶ added in v0.29.11
func SetCustomDNS ¶ added in v0.26.45
func SetCustomDNS(dnsAddr string)
func SetNtpInterval ¶ added in v0.30.1
func SetNtpServer ¶ added in v0.30.0
func SetNtpServer(server string)
func SetTimezone ¶ added in v0.32.3
func SplitAddrAndHost ¶ added in v0.33.6
func SplitServerAndPath ¶ added in v0.27.0
func TestLatency ¶ added in v0.26.51
func TestTcpPort ¶
TestTcpPort Judge whether the TCP port can open normally
func TestUdpPort ¶
TestUdpPort Judge whether the UDP port can open normally
func TimeOffset ¶ added in v0.30.0
func TimestampToBytes ¶ added in v0.27.0
TimestampToBytes 8bit
func ValidateAddr ¶ added in v0.30.2
func ValidatePoW ¶ added in v0.29.30
Types ¶
type Addr ¶
func ToSocksAddr ¶
type NetPackager ¶
type UDPDatagram ¶
func NewUDPDatagram ¶
func NewUDPDatagram(header *UDPHeader, data []byte) *UDPDatagram
func ReadUDPDatagram ¶
func ReadUDPDatagram(r io.Reader) (*UDPDatagram, error)