utils

package
v0.0.0-...-10a0d72 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2023 License: AGPL-3.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MaxMindDBs []*maxminddb.Reader
View Source
var VerboseLevel = LTWarn

Functions

func DNSLookuper

func DNSLookuper(addr string, queryServers []string) []net.IP

queryServer = "8.8.8.8:53"

func DomainPreheating

func DomainPreheating(url string) net.IP

func Download

func Download(url string) (*http.Response, error)

func DownloadBytes

func DownloadBytes(url string) ([]byte, error)

func FindAndExtract

func FindAndExtract(gzipReader io.Reader, filters ...regexp.Regexp) (map[string][]byte, error)

func LoadMaxMindDB

func LoadMaxMindDB(pathList string) error

func LogTypeToStr

func LogTypeToStr(lt LogType) string

func LookupIPv46

func LookupIPv46(addr string, retry int, queryServers []string) *interfaces.IPStacks

func MakeSysChan

func MakeSysChan() chan os.Signal

func PrintLogUnit

func PrintLogUnit(lu *LogUnit)

func RandomUUID

func RandomUUID() string

func SignRequest

func SignRequest(token string, req *interfaces.SlaveRequest) string

func ToJSON

func ToJSON(a any) string

func WrapError

func WrapError(desc string, fn func() error, onError ...func(err error)) (err error)

func WrapErrorPure

func WrapErrorPure(desc string, erro any) (err error)

Types

type GlobalConfig

type GlobalConfig struct {
	Token            string
	Binder           string
	WhiteList        []string
	SpeedLimit       uint64
	PauseSecond      uint
	ConnTaskTreading uint
	MiaoKoSignedTLS  bool
	NoSpeedFlag      bool
	MaxmindDB        string
}
var GCFG GlobalConfig

func (*GlobalConfig) InWhiteList

func (gc *GlobalConfig) InWhiteList(invoker string) bool

func (*GlobalConfig) SignRequest

func (gc *GlobalConfig) SignRequest(req *interfaces.SlaveRequest) string

func (*GlobalConfig) VerifyRequest

func (gc *GlobalConfig) VerifyRequest(req *interfaces.SlaveRequest) bool

type LogType

type LogType int
const (
	LTDebug LogType = iota
	LTLog
	LTInfo
	LTWarn
	LTError
)

type LogUnit

type LogUnit struct {
	Type    LogType
	Data    string
	Time    int64
	TimeStr string
}

func DBase

func DBase(t LogType, a ...interface{}) *LogUnit

func DBasef

func DBasef(t LogType, format string, a ...interface{}) *LogUnit

func DBlackhole

func DBlackhole(a ...interface{}) *LogUnit

func DBlackholef

func DBlackholef(format string, a ...interface{}) *LogUnit

func DError

func DError(a ...interface{}) *LogUnit

func DErrorE

func DErrorE(err error, a ...interface{}) *LogUnit

func DErrorEf

func DErrorEf(err error, format string, a ...interface{}) *LogUnit

func DErrorf

func DErrorf(format string, a ...interface{}) *LogUnit

func DInfo

func DInfo(a ...interface{}) *LogUnit

func DInfof

func DInfof(format string, a ...interface{}) *LogUnit

func DLog

func DLog(a ...interface{}) *LogUnit

func DLogf

func DLogf(format string, a ...interface{}) *LogUnit

func DWarn

func DWarn(a ...interface{}) *LogUnit

func DWarnf

func DWarnf(format string, a ...interface{}) *LogUnit

func (*LogUnit) Error

func (l *LogUnit) Error() error

type MMDBResult

type MMDBResult struct {
	IP      string
	Reverse string
	Via     string

	ASN    int    `maxminddb:"autonomous_system_number"`
	ASNOrg string `maxminddb:"autonomous_system_organization"`

	City struct {
		GeoNameID int `maxminddb:"geoname_id"`
		Names     struct {
			EN string `maxminddb:"en"`
			JA string `maxminddb:"ja"`
			ZH string `maxminddb:"zh-CN"`
		} `maxminddb:"names"`
	} `maxminddb:"city"`

	Continent struct {
		Code      string `maxminddb:"code"`
		GeoNameID int    `maxminddb:"geoname_id"`
		Names     struct {
			EN string `maxminddb:"en"`
			JA string `maxminddb:"ja"`
			ZH string `maxminddb:"zh-CN"`
		} `maxminddb:"names"`
	} `maxminddb:"continent"`

	Country struct {
		ISOCode   string `maxminddb:"iso_code"`
		GeoNameID int    `maxminddb:"geoname_id"`
		Names     struct {
			EN string `maxminddb:"en"`
			JA string `maxminddb:"ja"`
			ZH string `maxminddb:"zh-CN"`
		} `maxminddb:"names"`
	} `maxminddb:"country"`

	RegisteredCountry struct {
		ISOCode   string `maxminddb:"iso_code"`
		GeoNameID int    `maxminddb:"geoname_id"`
		Names     struct {
			EN string `maxminddb:"en"`
			JA string `maxminddb:"ja"`
			ZH string `maxminddb:"zh-CN"`
		} `maxminddb:"names"`
	} `maxminddb:"registered_country"`

	Location struct {
		Accuracy  int     `maxminddb:"accuracy_radius"`
		Latitude  float32 `maxminddb:"latitude"`
		Longitude float32 `maxminddb:"longitude"`
		TimeZone  string  `maxminddb:"time_zone"`
	} `maxminddb:"location"`
}

func QueryMaxMindDB

func QueryMaxMindDB(rawIp string) *MMDBResult

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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