dnsconfigs

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2022 License: BSD-3-Clause Imports: 9 Imported by: 1

Documentation

Index

Constants

View Source
const (
	NSDomainStatusNone     = "none"
	NSDomainStatusVerified = "verified"
)
View Source
const (
	DefaultMaxThreads    = 20000   // 单节点最大线程数
	DefaultMaxThreadsMin = 1000    // 单节点最大线程数最小值
	DefaultMaxThreadsMax = 100_000 // 单节点最大线程数最大值

	DefaultTCPMaxConnections      = 100_000 // 单节点TCP最大连接数
	DefaultTCPMaxConnectionsPerIP = 1000    // 单IP最大连接数
	DefaultTCPMinConnectionsPerIP = 5       // 单IP最小连接数

	DefaultTCPNewConnectionsMinutelyRate    = 500 // 单IP连接速率限制(按分钟)
	DefaultTCPNewConnectionsMinMinutelyRate = 3   // 单IP最小连接速率

	DefaultTCPNewConnectionsSecondlyRate    = 300 // 单IP连接速率限制(按秒)
	DefaultTCPNewConnectionsMinSecondlyRate = 3   // 单IP最小连接速率

	DefaultTCPLinger           = 3 // 单节点TCP Linger值
	DefaultTLSHandshakeTimeout = 3 // TLS握手超时时间
)
View Source
const DefaultRouteCode = "default"

Variables

View Source
var AllDefaultChinaProvinceRoutes = []*Route{
	{
		Name:       "北京市",
		Code:       "china:province:beijing",
		AliasNames: []string{"北京市", "北京"},
	},
	{
		Name:       "天津市",
		Code:       "china:province:tianjin",
		AliasNames: []string{"天津市", "天津"},
	},
	{
		Name:       "河北省",
		Code:       "china:province:heibei",
		AliasNames: []string{"河北省", "河北"},
	},
	{
		Name:       "山西省",
		Code:       "china:province:shanxi",
		AliasNames: []string{"山西省", "山西"},
	},
	{
		Name:       "内蒙古自治区",
		Code:       "china:province:neimenggu",
		AliasNames: []string{"内蒙古自治区", "内蒙古"},
	},
	{
		Name:       "辽宁省",
		Code:       "china:province:liaoning",
		AliasNames: []string{"辽宁省", "辽宁"},
	},
	{
		Name:       "吉林省",
		Code:       "china:jilin",
		AliasNames: []string{"吉林省", "吉林"},
	},
	{
		Name:       "黑龙江省",
		Code:       "china:province:heilongjiang",
		AliasNames: []string{"黑龙江省", "黑龙江"},
	},
	{
		Name:       "上海市",
		Code:       "china:province:shanghai",
		AliasNames: []string{"上海市", "上海"},
	},
	{
		Name:       "江苏省",
		Code:       "china:province:jiangsu",
		AliasNames: []string{"江苏省", "江苏"},
	},
	{
		Name:       "浙江省",
		Code:       "china:province:zhejiang",
		AliasNames: []string{"浙江省", "浙江"},
	},
	{
		Name:       "安徽省",
		Code:       "china:province:anhui",
		AliasNames: []string{"安徽省", "安徽"},
	},
	{
		Name:       "福建省",
		Code:       "china:province:fujian",
		AliasNames: []string{"福建省", "福建"},
	},
	{
		Name:       "江西省",
		Code:       "china:province:jiangxi",
		AliasNames: []string{"江西省", "江西"},
	},
	{
		Name:       "山东省",
		Code:       "china:province:shandong",
		AliasNames: []string{"山东省", "山东"},
	},
	{
		Name:       "河南省",
		Code:       "china:province:henan",
		AliasNames: []string{"河南省", "河南"},
	},
	{
		Name:       "湖北省",
		Code:       "china:province:hubei",
		AliasNames: []string{"湖北省", "湖北"},
	},
	{
		Name:       "湖南省",
		Code:       "china:province:hunan",
		AliasNames: []string{"湖南省", "湖南"},
	},
	{
		Name:       "广东省",
		Code:       "china:province:guangdong",
		AliasNames: []string{"广东省", "广东"},
	},
	{
		Name:       "广西壮族自治区",
		Code:       "china:province:guangxi",
		AliasNames: []string{"广西壮族自治区", "广西"},
	},
	{
		Name:       "海南省",
		Code:       "china:province:hainan",
		AliasNames: []string{"海南省", "海南"},
	},
	{
		Name:       "重庆市",
		Code:       "china:province:chongqing",
		AliasNames: []string{"重庆市", "重庆"},
	},
	{
		Name:       "四川省",
		Code:       "china:province:sichuan",
		AliasNames: []string{"四川省", "四川"},
	},
	{
		Name:       "贵州省",
		Code:       "china:province:guizhou",
		AliasNames: []string{"贵州省", "贵州"},
	},
	{
		Name:       "云南省",
		Code:       "china:province:yunnan",
		AliasNames: []string{"云南省", "云南"},
	},
	{
		Name:       "西藏自治区",
		Code:       "china:province:xizang",
		AliasNames: []string{"西藏自治区", "西藏"},
	},
	{
		Name:       "陕西省",
		Code:       "china:province:shaanxi",
		AliasNames: []string{"陕西省", "陕西"},
	},
	{
		Name:       "甘肃省",
		Code:       "china:province:gansu",
		AliasNames: []string{"甘肃省", "甘肃"},
	},
	{
		Name:       "青海省",
		Code:       "china:province:qinghai",
		AliasNames: []string{"青海省", "青海"},
	},
	{
		Name:       "宁夏回族自治区",
		Code:       "china:province:ningxia",
		AliasNames: []string{"宁夏回族自治区", "宁夏"},
	},
	{
		Name:       "新疆维吾尔自治区",
		Code:       "china:province:xinjiang",
		AliasNames: []string{"新疆维吾尔自治区", "新疆"},
	},
	{
		Name:       "香港特别行政区",
		Code:       ChinaProvinceCodeHK,
		AliasNames: []string{"香港特别行政区", "香港"},
	},
	{
		Name:       "澳门特别行政区",
		Code:       ChinaProvinceCodeMO,
		AliasNames: []string{"澳门特别行政区", "澳门"},
	},
	{
		Name:       "台湾省",
		Code:       ChinaProvinceCodeTW,
		AliasNames: []string{"台湾省", "台湾"},
	},
}

AllDefaultChinaProvinceRoutes 中国地域线路

View Source
var AllDefaultISPRoutes = []*Route{
	{
		Name:       "电信",
		Code:       "isp:china_telecom",
		AliasNames: []string{"电信"},
	},
	{
		Name:       "联通",
		Code:       "isp:china_unicom",
		AliasNames: []string{"联通"},
	},
	{
		Name:       "移动",
		Code:       "isp:china_mobile",
		AliasNames: []string{"移动"},
	},
	{
		Name:       "鹏博士",
		Code:       "isp:china_drpeng",
		AliasNames: []string{"鹏博士"},
	},
	{
		Name:       "教育网",
		Code:       "isp:china_edu",
		AliasNames: []string{"教育网"},
	},
	{
		Name:       "歌华",
		Code:       "isp:china_gehua",
		AliasNames: []string{"歌华"},
	},
	{
		Name:       "铁通",
		Code:       "isp:china_tietong",
		AliasNames: []string{"铁通"},
	},
	{
		Name:       "阿里巴巴",
		Code:       "isp:alibaba",
		AliasNames: []string{"阿里巴巴"},
	},
	{
		Name:       "亚马逊",
		Code:       "isp:amazon",
		AliasNames: []string{"亚马逊"},
	},
	{
		Name:       "谷歌",
		Code:       "isp:google",
		AliasNames: []string{"谷歌"},
	},
	{
		Name:       "微软",
		Code:       "isp:microsoft",
		AliasNames: []string{"微软"},
	},
	{
		Name:       "腾讯",
		Code:       "isp:tencent",
		AliasNames: []string{"腾讯"},
	},
	{
		Name:       "阿里云",
		Code:       "isp:aliyun",
		AliasNames: []string{"阿里云"},
	},
}

AllDefaultISPRoutes 运营商线路

View Source
var AllDefaultRoutes = []*Route{
	{
		Name:       "默认线路",
		Code:       DefaultRouteCode,
		AliasNames: []string{"默认线路"},
	},
}

AllDefaultRoutes 默认线路

View Source
var AllDefaultWorldRegionRoutes = []*Route{}/* 245 elements not displayed */

AllDefaultWorldRegionRoutes 世界地域线路 参考:https://zh.wikipedia.org/wiki/%E5%9C%8B%E5%AE%B6%E5%9C%B0%E5%8D%80%E4%BB%A3%E7%A2%BC

View Source
var DefaultConfigs = maps.Map{
	"tcpMaxConnections":                DefaultTCPMaxConnections,
	"tcpMaxConnectionsPerIP":           DefaultTCPMaxConnectionsPerIP,
	"tcpMinConnectionsPerIP":           DefaultTCPMinConnectionsPerIP,
	"tcpNewConnectionsMinutelyRate":    DefaultTCPNewConnectionsMinutelyRate,
	"tcpNewConnectionsMinMinutelyRate": DefaultTCPNewConnectionsMinMinutelyRate,
	"tcpNewConnectionsSecondlyRate":    DefaultTCPNewConnectionsSecondlyRate,
	"tcpNewConnectionsMinSecondlyRate": DefaultTCPNewConnectionsMinSecondlyRate,
}

Functions

func AllRouteRangeTypes added in v0.4.9

func AllRouteRangeTypes() []*shared.Definition

func FindKeyAlgorithmTypeName

func FindKeyAlgorithmTypeName(algoType KeyAlgorithmType) string

func FindKeySecretTypeName

func FindKeySecretTypeName(secretType NSKeySecretType) string

Types

type BaseRouteRange added in v0.4.9

type BaseRouteRange struct {
	IsReverse bool `json:"isReverse"`
	// contains filtered or unexported fields
}

func (*BaseRouteRange) IsExcluding added in v0.4.9

func (this *BaseRouteRange) IsExcluding() bool

func (*BaseRouteRange) SetRegionResolver added in v0.4.9

func (this *BaseRouteRange) SetRegionResolver(resolver RouteRegionResolver)

type ClusterDNSConfig

type ClusterDNSConfig struct {
	CNameRecords     []string `yaml:"cnameRecords" json:"cnameRecords"`         // 自动加入的CNAME
	TTL              int32    `yaml:"ttl" json:"ttl"`                           // 默认TTL,各个DNS服务商对记录的TTL的限制各有不同
	CNameAsDomain    bool     `yaml:"cnameAsDomain" json:"cnameAsDomain"`       // 是否可以像域名一样直接访问CNAME
	IncludingLnNodes bool     `yaml:"includingLnNodes" json:"includingLnNodes"` // 是否包含Ln节点

	NodesAutoSync   bool `yaml:"nodesAutoSync" json:"nodesAutoSync"`     // 是否自动同步节点状态
	ServersAutoSync bool `yaml:"serversAutoSync" json:"serversAutoSync"` // 是否自动同步服务状态
}

ClusterDNSConfig 集群的DNS设置

type DNSHost

type DNSHost struct {
	Host     string `json:"host"`
	Port     int    `json:"port"`
	Protocol string `json:"protocol"`
}

type KeyAlgorithmDefinition

type KeyAlgorithmDefinition struct {
	Name string `json:"name"`
	Code string `json:"code"`
}

func FindAllKeyAlgorithmTypes

func FindAllKeyAlgorithmTypes() []*KeyAlgorithmDefinition

type KeyAlgorithmType

type KeyAlgorithmType = string
const (
	KeyAlgorithmTypeHmacSHA1   KeyAlgorithmType = "hmac-sha1."
	KeyAlgorithmTypeHmacSHA224 KeyAlgorithmType = "hmac-sha224."
	KeyAlgorithmTypeHmacSHA256 KeyAlgorithmType = "hmac-sha256."
	KeyAlgorithmTypeHmacSHA384 KeyAlgorithmType = "hmac-sha384."
	KeyAlgorithmTypeHmacSHA512 KeyAlgorithmType = "hmac-sha512."
)

type NSAccessLogRef

type NSAccessLogRef struct {
	IsPrior           bool `yaml:"isPrior" json:"isPrior"`                     // 是否覆盖
	IsOn              bool `yaml:"isOn" json:"isOn"`                           // 是否启用
	LogMissingDomains bool `yaml:"logMissingDomains" json:"logMissingDomains"` // 是否记录找不到的域名
}

func (*NSAccessLogRef) Init

func (this *NSAccessLogRef) Init() error

type NSDomainStatus added in v0.5.0

type NSDomainStatus = string

type NSKeySecretType

type NSKeySecretType = string
const (
	NSKeySecretTypeClear  NSKeySecretType = "clear"
	NSKeySecretTypeBase64 NSKeySecretType = "base64"
)

type NSNodeConfig

type NSNodeConfig struct {
	Id              int64                         `yaml:"id" json:"id"`
	NodeId          string                        `yaml:"nodeId" json:"nodeId"`
	Secret          string                        `yaml:"secret" json:"secret"`
	ClusterId       int64                         `yaml:"clusterId" json:"clusterId"`
	AccessLogRef    *NSAccessLogRef               `yaml:"accessLogRef" json:"accessLogRef"`
	RecursionConfig *RecursionConfig              `yaml:"recursionConfig" json:"recursionConfig"`
	DDoSProtection  *ddosconfigs.ProtectionConfig `yaml:"ddosProtection" json:"ddosProtection"`
	AllowedIPs      []string                      `yaml:"allowedIPs" json:"allowedIPs"`

	TCP *serverconfigs.TCPProtocolConfig `yaml:"tcp" json:"tcp"` // TCP配置
	TLS *serverconfigs.TLSProtocolConfig `yaml:"tls" json:"tls"` // TLS配置
	UDP *serverconfigs.UDPProtocolConfig `yaml:"udp" json:"udp"` // UDP配置
	// contains filtered or unexported fields
}

func (*NSNodeConfig) Init

func (this *NSNodeConfig) Init() error

func (*NSNodeConfig) PaddedId

func (this *NSNodeConfig) PaddedId() string

type NSSetting

type NSSetting struct {
}

type RecordTTL

type RecordTTL struct {
	Name  string `json:"name"`
	Value int    `json:"value"`
}

func FindAllRecordTTL

func FindAllRecordTTL() []*RecordTTL

type RecordType

type RecordType = string
const (
	RecordTypeA     RecordType = "A"
	RecordTypeCNAME RecordType = "CNAME"
	RecordTypeAAAA  RecordType = "AAAA"
	RecordTypeNS    RecordType = "NS"
	RecordTypeMX    RecordType = "MX"
	RecordTypeSRV   RecordType = "SRV"
	RecordTypeTXT   RecordType = "TXT"
	RecordTypeCAA   RecordType = "CAA"
)

type RecordTypeDefinition

type RecordTypeDefinition struct {
	Type        RecordType `json:"type"`
	Description string     `json:"description"`
}

func FindAllRecordTypeDefinitions

func FindAllRecordTypeDefinitions() []*RecordTypeDefinition

type RecursionConfig

type RecursionConfig struct {
	IsOn          bool       `json:"isOn"`
	Hosts         []*DNSHost `json:"hosts"`
	UseLocalHosts bool       `json:"useLocalHosts"` // 自动从本机读取DNS
	AllowDomains  []string   `json:"allowDomains"`
	DenyDomains   []string   `json:"denyDomains"`
}

RecursionConfig 递归DNS设置

func (*RecursionConfig) Init added in v0.5.0

func (this *RecursionConfig) Init() error

type Route

type Route struct {
	Name       string   `json:"name"`
	Code       string   `json:"code"`
	AliasNames []string `json:"aliasNames"`
}

func FindDefaultRoute

func FindDefaultRoute(code string) *Route

FindDefaultRoute 根据代号查找线路

type RouteCode added in v0.5.0

type RouteCode = string
const (
	ChinaProvinceCodeHK RouteCode = "china:province:hk"
	ChinaProvinceCodeMO RouteCode = "china:province:mo"
	ChinaProvinceCodeTW RouteCode = "china:province:tw"
)
const (
	WorldRegionCodeChina         RouteCode = "world:CN"
	WorldRegionCodeHK            RouteCode = "world:CN:hk"
	WorldRegionCodeMO            RouteCode = "world:CN:mo"
	WorldRegionCodeTW            RouteCode = "world:CN:tw"
	WorldRegionCodeChinaMainland RouteCode = "world:CN:mainland"
	WorldRegionCodeChinaAbroad   RouteCode = "world:CN:abroad"
)

type RouteRangeCIDR added in v0.4.9

type RouteRangeCIDR struct {
	BaseRouteRange

	CIDR string `json:"cidr"`
	// contains filtered or unexported fields
}

RouteRangeCIDR CIDR范围配置

func (*RouteRangeCIDR) Contains added in v0.4.9

func (this *RouteRangeCIDR) Contains(netIP net.IP) bool

func (*RouteRangeCIDR) Init added in v0.4.9

func (this *RouteRangeCIDR) Init() error

type RouteRangeIPRange

type RouteRangeIPRange struct {
	BaseRouteRange

	IPFrom string `json:"ipFrom"`
	IPTo   string `json:"ipTo"`
	// contains filtered or unexported fields
}

RouteRangeIPRange IP范围配置 IPv4和IPv6不能混用

func (*RouteRangeIPRange) Contains

func (this *RouteRangeIPRange) Contains(netIP net.IP) bool

func (*RouteRangeIPRange) Init

func (this *RouteRangeIPRange) Init() error

type RouteRangeInterface

type RouteRangeInterface interface {
	// Init 初始化
	Init() error

	// Contains 判断是否包含
	Contains(ip net.IP) bool

	// SetRegionResolver 设置IP解析接口
	SetRegionResolver(resolver RouteRegionResolver)

	// IsExcluding 是否为排除
	IsExcluding() bool
}

RouteRangeInterface 线路范围接口

func InitRangesFromJSON added in v0.4.9

func InitRangesFromJSON(rangesJSON []byte) (ranges []RouteRangeInterface, err error)

InitRangesFromJSON 从JSON中初始化线路范围

type RouteRangeRegion added in v0.4.9

type RouteRangeRegion struct {
	BaseRouteRange

	Regions []*routeRegion `json:"regions"`
}

RouteRangeRegion 区域范围 country:ID, province:ID, city:ID, isp:ID

func (*RouteRangeRegion) Contains added in v0.4.9

func (this *RouteRangeRegion) Contains(netIP net.IP) bool

func (*RouteRangeRegion) Init added in v0.4.9

func (this *RouteRangeRegion) Init() error

type RouteRangeType

type RouteRangeType = string
const (
	RouteRangeTypeIP     RouteRangeType = "ipRange" // IP范围
	RouteRangeTypeCIDR   RouteRangeType = "cidr"    // CIDR
	RouteRangeTypeRegion RouteRangeType = "region"  // 区域
)

type RouteRegionResolver added in v0.4.9

type RouteRegionResolver interface {
	Resolve(ip net.IP) (countryId int64, provinceId int64, cityId int64, providerId int64)
}

RouteRegionResolver 解析IP接口

type TSIGConfig

type TSIGConfig struct {
	IsOn bool `yaml:"isOn" json:"isOn"`
}

TSIGConfig 配置

Jump to

Keyboard shortcuts

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