utils

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2021 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultLogMaxSize define the default log size per file, unit (M).
	DefaultLogMaxSize = 500
	// DefaultLogMaxBackups define the default log max-backup num.
	DefaultLogMaxBackups = 15
	// DefaultLogMaxAge define the max age of the log files.
	DefaultLogMaxAge = 30
	// DefaultLogCompress define whether the log need compress.
	DefaultLogCompress = true

	// DefaultWorkThread used to define the num of update dns-rules threads num.
	DefaultWorkThreads = 4

	DefaultRootDomain = "binddns.com"

	DefaultEnableHttpApi = false
	DefaultHttpApiPort   = ":5388"

	LabelZoneDnsRule = "binddns.k8s.io/zone"
	LabelTypeDnsRule = "binddns.k8s.io/type"
	LabelHostDnsRule = "binddns.k8s.io/host"
)

Variables

View Source
var (
	DnsType    = []string{"A", "MX", "CNAME", "NS", "PTR", "TXT", "AAAA", "SRV", "URL"}
	DnsTypeMap = map[string]string{
		"A":     "A",
		"MX":    "MX",
		"CNAME": "CNAME",
		"NS":    "NS",
		"PTR":   "PTR",
		"TXT":   "TXT",
		"AAAA":  "AAAA",
		"SRV":   "SRV",
		"URL":   "URL",
	}
	DomainRegexp   = regexp.MustCompile(`^(([a-zA-Z]{1})|([a-zA-Z]{1}[a-zA-Z]{1})|([a-zA-Z]{1}[0-9]{1})|([0-9]{1}[a-zA-Z]{1})|([a-zA-Z0-9][a-zA-Z0-9-_]{1,61}[a-zA-Z0-9]))\.([a-zA-Z]{2,6}|[a-zA-Z0-9-]{2,30}\.[a-zA-Z]{2,3})$`)
	IPRegexp       = regexp.MustCompile(`^((25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(25[0-5]|2[0-4]\d|[01]?\d\d?)$`)
	HostnameRegexp = regexp.MustCompile(`^[[:alnum:]][[:alnum:]\-]{0,61}[[:alnum:]]|[[:alpha:]]$`)
	// 详情见互斥关系图, 1 --互斥,0 --不互斥
	DnsRuleRelation = map[string]map[string]int{
		"A":     {"A": 0, "MX": 0, "CNAME": 1, "NS": 0, "TXT": 0, "AAAA": 0, "SRV": 0},
		"MX":    {"A": 0, "MX": 0, "CNAME": 1, "NS": 1, "TXT": 0, "AAAA": 0, "SRV": 0},
		"CNAME": {"A": 1, "MX": 1, "CNAME": 1, "NS": 1, "TXT": 1, "AAAA": 1, "SRV": 0},
		"NS":    {"A": 1, "MX": 1, "CNAME": 1, "NS": 0, "TXT": 1, "AAAA": 1, "SRV": 0},
		"TXT":   {"A": 0, "MX": 0, "CNAME": 1, "NS": 1, "TXT": 0, "AAAA": 0, "SRV": 0},
		"AAAA":  {"A": 0, "MX": 0, "CNAME": 1, "NS": 1, "TXT": 0, "AAAA": 0, "SRV": 0},
		"SRV":   {"A": 0, "MX": 0, "CNAME": 0, "NS": 0, "TXT": 0, "AAAA": 0, "SRV": 0},
	}
)
View Source
var (
	// DefaultLogFile define the default log output file.
	DefaultLogFile = "/var/log/%s.log"
)

Functions

func BytesToString

func BytesToString(b []byte) string

BytesToString convert []byte to string

func CalcAscII

func CalcAscII(str string) (result int)

func GetPodName

func GetPodName() (name string)

func SliceContain

func SliceContain(slice []string, target string) bool

func StringToBytes

func StringToBytes(s string) []byte

StringToBytes convert string to []byte

func SubString

func SubString(source string, start, end int) string

func TimeNow

func TimeNow() string

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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