Help us shape the future of Go! Take the 2026 Go Developer Survey

util

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ReservedPorts = map[int]bool{
	21:   true,
	22:   true,
	23:   true,
	25:   true,
	53:   true,
	80:   true,
	110:  true,
	143:  true,
	465:  true,
	587:  true,
	993:  true,
	995:  true,
	2048: true,
	3306: true,
	3389: true,
	5432: true,
	6379: true,
	9090: true,
}

Functions

func Error

func Error(format string, args ...any)

func GenerateECHKeyPair added in v0.0.6

func GenerateECHKeyPair(domain string) (echKey, echConfig string, err error)

func GeneratePort

func GeneratePort() int

func GenerateRealityKeyPair

func GenerateRealityKeyPair() (privateKey, publicKey string, err error)

生成 Reality 密钥对

func GenerateRealityTarget

func GenerateRealityTarget() string

func GenerateShortID

func GenerateShortID(bytes int) (string, error)

生成单个 ShortID,指定长度(字节数,输出为 2*n 位 hex)

func GenerateShortIDs

func GenerateShortIDs() ([]string, error)

生成8个 ShortID,第一个长度随机但不短于4字节(8位hex),其余完全随机

func GenerateString

func GenerateString(n int) string

func GenerateUUID

func GenerateUUID() (string, error)

生成 UUID

func GenerateWireguardKeyPair added in v0.0.3

func GenerateWireguardKeyPair() (privateKey, publicKey string, err error)

生成 WireGuard 密钥对

func GetPublicIPs

func GetPublicIPs() (ipv4, ipv6 string)

func GetPublicIPv4

func GetPublicIPv4() string

func GetPublicIPv6

func GetPublicIPv6() string

func Info

func Info(format string, args ...any)

func InitLog

func InitLog(path, level string, enable bool)

func SanitizeFileName added in v0.0.2

func SanitizeFileName(name string) string

SanitizeFileName 清除文件名中的非法字符

func ValidateDomain

func ValidateDomain(domain string) bool

func ValidateIPv4CIDR added in v0.0.3

func ValidateIPv4CIDR(addr string) bool

func ValidateIPv6CIDR added in v0.0.3

func ValidateIPv6CIDR(addr string) bool

func ValidatePort

func ValidatePort(port int, usedPorts []int) string

func ValidateTag added in v0.0.3

func ValidateTag(tag string) string

func Warn

func Warn(format string, args ...any)

Types

This section is empty.

Jump to

Keyboard shortcuts

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