mirror of
				https://github.com/TeaOSLab/EdgeCommon.git
				synced 2025-11-04 05:00:24 +08:00 
			
		
		
		
	优化代码
This commit is contained in:
		@@ -14,7 +14,7 @@ type NSNodeConfig struct {
 | 
				
			|||||||
	Secret          string                        `yaml:"secret" json:"secret"`
 | 
						Secret          string                        `yaml:"secret" json:"secret"`
 | 
				
			||||||
	ClusterId       int64                         `yaml:"clusterId" json:"clusterId"`
 | 
						ClusterId       int64                         `yaml:"clusterId" json:"clusterId"`
 | 
				
			||||||
	AccessLogRef    *NSAccessLogRef               `yaml:"accessLogRef" json:"accessLogRef"`
 | 
						AccessLogRef    *NSAccessLogRef               `yaml:"accessLogRef" json:"accessLogRef"`
 | 
				
			||||||
	RecursionConfig *RecursionConfig              `yaml:"recursionConfig" json:"recursionConfig"`
 | 
						RecursionConfig *NSRecursionConfig            `yaml:"recursionConfig" json:"recursionConfig"`
 | 
				
			||||||
	DDoSProtection  *ddosconfigs.ProtectionConfig `yaml:"ddosProtection" json:"ddosProtection"`
 | 
						DDoSProtection  *ddosconfigs.ProtectionConfig `yaml:"ddosProtection" json:"ddosProtection"`
 | 
				
			||||||
	AllowedIPs      []string                      `yaml:"allowedIPs" json:"allowedIPs"`
 | 
						AllowedIPs      []string                      `yaml:"allowedIPs" json:"allowedIPs"`
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										14
									
								
								pkg/dnsconfigs/ns_plans.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								pkg/dnsconfigs/ns_plans.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,14 @@
 | 
				
			|||||||
 | 
					// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn .
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					package dnsconfigs
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type NSPlanConfig struct {
 | 
				
			||||||
 | 
						SupportCountryRoutes       bool  `json:"supportCountryRoutes"`       // 支持全球国家/地区线路
 | 
				
			||||||
 | 
						SupportChinaProvinceRoutes bool  `json:"supportChinaProvinceRoutes"` // 支持国内省份线路
 | 
				
			||||||
 | 
						SupportISPRoutes           bool  `json:"supportISPRoutes"`           // 支持ISP运营商线路
 | 
				
			||||||
 | 
						CountCustomRoutes          int   `json:"countCustomRoutes"`          // 自定义的线路数量
 | 
				
			||||||
 | 
						CountLoadBalanceRecords    bool  `json:"countLoadBalanceRecords"`    // 负载均衡条数
 | 
				
			||||||
 | 
						MinTTL                     int32 `json:"minTTL"`                     // 最小TTL
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						SupportAPI bool `json:"supportAPI"` // 是否支持API操作
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										22
									
								
								pkg/dnsconfigs/ns_recursion_config.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								pkg/dnsconfigs/ns_recursion_config.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,22 @@
 | 
				
			|||||||
 | 
					// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					package dnsconfigs
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type NSDNSHost struct {
 | 
				
			||||||
 | 
						Host     string `json:"host"`
 | 
				
			||||||
 | 
						Port     int    `json:"port"`
 | 
				
			||||||
 | 
						Protocol string `json:"protocol"`
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// NSRecursionConfig 递归DNS设置
 | 
				
			||||||
 | 
					type NSRecursionConfig struct {
 | 
				
			||||||
 | 
						IsOn          bool         `json:"isOn"`
 | 
				
			||||||
 | 
						Hosts         []*NSDNSHost `json:"hosts"`
 | 
				
			||||||
 | 
						UseLocalHosts bool         `json:"useLocalHosts"` // 自动从本机读取DNS
 | 
				
			||||||
 | 
						AllowDomains  []string     `json:"allowDomains"`
 | 
				
			||||||
 | 
						DenyDomains   []string     `json:"denyDomains"`
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (this *NSRecursionConfig) Init() error {
 | 
				
			||||||
 | 
						return nil
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -11,38 +11,38 @@ import (
 | 
				
			|||||||
	"net"
 | 
						"net"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type RouteRangeType = string
 | 
					type NSRouteRangeType = string
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const (
 | 
					const (
 | 
				
			||||||
	RouteRangeTypeIP     RouteRangeType = "ipRange" // IP范围
 | 
						NSRouteRangeTypeIP     NSRouteRangeType = "ipRange" // IP范围
 | 
				
			||||||
	RouteRangeTypeCIDR   RouteRangeType = "cidr"    // CIDR
 | 
						NSRouteRangeTypeCIDR   NSRouteRangeType = "cidr"    // CIDR
 | 
				
			||||||
	RouteRangeTypeRegion RouteRangeType = "region"  // 区域
 | 
						NSRouteRangeTypeRegion NSRouteRangeType = "region"  // 区域
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func AllRouteRangeTypes() []*shared.Definition {
 | 
					func AllNSRouteRangeTypes() []*shared.Definition {
 | 
				
			||||||
	return []*shared.Definition{
 | 
						return []*shared.Definition{
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			Name: "IP范围",
 | 
								Name: "IP范围",
 | 
				
			||||||
			Code: RouteRangeTypeIP,
 | 
								Code: NSRouteRangeTypeIP,
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			Name: "CIDR",
 | 
								Name: "CIDR",
 | 
				
			||||||
			Code: RouteRangeTypeCIDR,
 | 
								Code: NSRouteRangeTypeCIDR,
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			Name: "区域",
 | 
								Name: "区域",
 | 
				
			||||||
			Code: RouteRangeTypeRegion,
 | 
								Code: NSRouteRangeTypeRegion,
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// RouteRegionResolver 解析IP接口
 | 
					// NSRouteRegionResolver 解析IP接口
 | 
				
			||||||
type RouteRegionResolver interface {
 | 
					type NSRouteRegionResolver interface {
 | 
				
			||||||
	Resolve(ip net.IP) (countryId int64, provinceId int64, cityId int64, providerId int64)
 | 
						Resolve(ip net.IP) (countryId int64, provinceId int64, cityId int64, providerId int64)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// RouteRangeInterface 线路范围接口
 | 
					// NSRouteRangeInterface 线路范围接口
 | 
				
			||||||
type RouteRangeInterface interface {
 | 
					type NSRouteRangeInterface interface {
 | 
				
			||||||
	// Init 初始化
 | 
						// Init 初始化
 | 
				
			||||||
	Init() error
 | 
						Init() error
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -50,30 +50,30 @@ type RouteRangeInterface interface {
 | 
				
			|||||||
	Contains(ip net.IP) bool
 | 
						Contains(ip net.IP) bool
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// SetRegionResolver 设置IP解析接口
 | 
						// SetRegionResolver 设置IP解析接口
 | 
				
			||||||
	SetRegionResolver(resolver RouteRegionResolver)
 | 
						SetRegionResolver(resolver NSRouteRegionResolver)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// IsExcluding 是否为排除
 | 
						// IsExcluding 是否为排除
 | 
				
			||||||
	IsExcluding() bool
 | 
						IsExcluding() bool
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type BaseRouteRange struct {
 | 
					type NSBaseRouteRange struct {
 | 
				
			||||||
	IsReverse bool `json:"isReverse"`
 | 
						IsReverse bool `json:"isReverse"`
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	routeRegionResolver RouteRegionResolver
 | 
						routeRegionResolver NSRouteRegionResolver
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (this *BaseRouteRange) SetRegionResolver(resolver RouteRegionResolver) {
 | 
					func (this *NSBaseRouteRange) SetRegionResolver(resolver NSRouteRegionResolver) {
 | 
				
			||||||
	this.routeRegionResolver = resolver
 | 
						this.routeRegionResolver = resolver
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (this *BaseRouteRange) IsExcluding() bool {
 | 
					func (this *NSBaseRouteRange) IsExcluding() bool {
 | 
				
			||||||
	return this.IsReverse
 | 
						return this.IsReverse
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// RouteRangeIPRange IP范围配置
 | 
					// NSRouteRangeIPRange IP范围配置
 | 
				
			||||||
// IPv4和IPv6不能混用
 | 
					// IPv4和IPv6不能混用
 | 
				
			||||||
type RouteRangeIPRange struct {
 | 
					type NSRouteRangeIPRange struct {
 | 
				
			||||||
	BaseRouteRange
 | 
						NSBaseRouteRange
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	IPFrom string `json:"ipFrom"`
 | 
						IPFrom string `json:"ipFrom"`
 | 
				
			||||||
	IPTo   string `json:"ipTo"`
 | 
						IPTo   string `json:"ipTo"`
 | 
				
			||||||
@@ -84,7 +84,7 @@ type RouteRangeIPRange struct {
 | 
				
			|||||||
	ipVersion int // 4|6
 | 
						ipVersion int // 4|6
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (this *RouteRangeIPRange) Init() error {
 | 
					func (this *NSRouteRangeIPRange) Init() error {
 | 
				
			||||||
	var ipFrom = net.ParseIP(this.IPFrom)
 | 
						var ipFrom = net.ParseIP(this.IPFrom)
 | 
				
			||||||
	var ipTo = net.ParseIP(this.IPTo)
 | 
						var ipTo = net.ParseIP(this.IPTo)
 | 
				
			||||||
	if ipFrom == nil {
 | 
						if ipFrom == nil {
 | 
				
			||||||
@@ -111,7 +111,7 @@ func (this *RouteRangeIPRange) Init() error {
 | 
				
			|||||||
	return nil
 | 
						return nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (this *RouteRangeIPRange) Contains(netIP net.IP) bool {
 | 
					func (this *NSRouteRangeIPRange) Contains(netIP net.IP) bool {
 | 
				
			||||||
	if len(netIP) == 0 {
 | 
						if len(netIP) == 0 {
 | 
				
			||||||
		return false
 | 
							return false
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
@@ -125,16 +125,16 @@ func (this *RouteRangeIPRange) Contains(netIP net.IP) bool {
 | 
				
			|||||||
	return ipLong >= this.ipFromLong && ipLong <= this.ipToLong
 | 
						return ipLong >= this.ipFromLong && ipLong <= this.ipToLong
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// RouteRangeCIDR CIDR范围配置
 | 
					// NSRouteRangeCIDR CIDR范围配置
 | 
				
			||||||
type RouteRangeCIDR struct {
 | 
					type NSRouteRangeCIDR struct {
 | 
				
			||||||
	BaseRouteRange
 | 
						NSBaseRouteRange
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	CIDR string `json:"cidr"`
 | 
						CIDR string `json:"cidr"`
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	cidr *net.IPNet
 | 
						cidr *net.IPNet
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (this *RouteRangeCIDR) Init() error {
 | 
					func (this *NSRouteRangeCIDR) Init() error {
 | 
				
			||||||
	_, ipNet, err := net.ParseCIDR(this.CIDR)
 | 
						_, ipNet, err := net.ParseCIDR(this.CIDR)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return errors.New("parse cidr failed: " + err.Error())
 | 
							return errors.New("parse cidr failed: " + err.Error())
 | 
				
			||||||
@@ -145,7 +145,7 @@ func (this *RouteRangeCIDR) Init() error {
 | 
				
			|||||||
	return nil
 | 
						return nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (this *RouteRangeCIDR) Contains(netIP net.IP) bool {
 | 
					func (this *NSRouteRangeCIDR) Contains(netIP net.IP) bool {
 | 
				
			||||||
	if netIP == nil {
 | 
						if netIP == nil {
 | 
				
			||||||
		return false
 | 
							return false
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
@@ -157,19 +157,19 @@ func (this *RouteRangeCIDR) Contains(netIP net.IP) bool {
 | 
				
			|||||||
	return this.cidr.Contains(netIP)
 | 
						return this.cidr.Contains(netIP)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// RouteRangeRegion 区域范围
 | 
					// NSRouteRangeRegion 区域范围
 | 
				
			||||||
// country:ID, province:ID, city:ID, isp:ID
 | 
					// country:ID, province:ID, city:ID, isp:ID
 | 
				
			||||||
type RouteRangeRegion struct {
 | 
					type NSRouteRangeRegion struct {
 | 
				
			||||||
	BaseRouteRange
 | 
						NSBaseRouteRange
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	Regions []*routeRegion `json:"regions"`
 | 
						Regions []*routeRegion `json:"regions"`
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (this *RouteRangeRegion) Init() error {
 | 
					func (this *NSRouteRangeRegion) Init() error {
 | 
				
			||||||
	return nil
 | 
						return nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (this *RouteRangeRegion) Contains(netIP net.IP) bool {
 | 
					func (this *NSRouteRangeRegion) Contains(netIP net.IP) bool {
 | 
				
			||||||
	if this.routeRegionResolver == nil {
 | 
						if this.routeRegionResolver == nil {
 | 
				
			||||||
		return false
 | 
							return false
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
@@ -217,8 +217,8 @@ type routeRegion struct {
 | 
				
			|||||||
	Name string `json:"name"`
 | 
						Name string `json:"name"`
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// InitRangesFromJSON 从JSON中初始化线路范围
 | 
					// InitNSRangesFromJSON 从JSON中初始化线路范围
 | 
				
			||||||
func InitRangesFromJSON(rangesJSON []byte) (ranges []RouteRangeInterface, err error) {
 | 
					func InitNSRangesFromJSON(rangesJSON []byte) (ranges []NSRouteRangeInterface, err error) {
 | 
				
			||||||
	if len(rangesJSON) == 0 {
 | 
						if len(rangesJSON) == 0 {
 | 
				
			||||||
		return
 | 
							return
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
@@ -235,15 +235,15 @@ func InitRangesFromJSON(rangesJSON []byte) (ranges []RouteRangeInterface, err er
 | 
				
			|||||||
			return nil, err
 | 
								return nil, err
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		var r RouteRangeInterface
 | 
							var r NSRouteRangeInterface
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		switch rangeType {
 | 
							switch rangeType {
 | 
				
			||||||
		case RouteRangeTypeIP:
 | 
							case NSRouteRangeTypeIP:
 | 
				
			||||||
			r = &RouteRangeIPRange{}
 | 
								r = &NSRouteRangeIPRange{}
 | 
				
			||||||
		case RouteRangeTypeCIDR:
 | 
							case NSRouteRangeTypeCIDR:
 | 
				
			||||||
			r = &RouteRangeCIDR{}
 | 
								r = &NSRouteRangeCIDR{}
 | 
				
			||||||
		case RouteRangeTypeRegion:
 | 
							case NSRouteRangeTypeRegion:
 | 
				
			||||||
			r = &RouteRangeRegion{}
 | 
								r = &NSRouteRangeRegion{}
 | 
				
			||||||
		default:
 | 
							default:
 | 
				
			||||||
			return nil, errors.New("invalid route line type '" + rangeType + "'")
 | 
								return nil, errors.New("invalid route line type '" + rangeType + "'")
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
@@ -8,12 +8,12 @@ import (
 | 
				
			|||||||
	"testing"
 | 
						"testing"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func TestRouteRangeIPRange_Contains(t *testing.T) {
 | 
					func TestNSRouteRangeIPRange_Contains(t *testing.T) {
 | 
				
			||||||
	var a = assert.NewAssertion(t)
 | 
						var a = assert.NewAssertion(t)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// ipv4
 | 
						// ipv4
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		var r = &RouteRangeIPRange{
 | 
							var r = &NSRouteRangeIPRange{
 | 
				
			||||||
			IPFrom: "192.168.1.100",
 | 
								IPFrom: "192.168.1.100",
 | 
				
			||||||
			IPTo:   "192.168.3.200",
 | 
								IPTo:   "192.168.3.200",
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
@@ -31,7 +31,7 @@ func TestRouteRangeIPRange_Contains(t *testing.T) {
 | 
				
			|||||||
	// ipv6
 | 
						// ipv6
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		var prefix = "1:2:3:4:5:6"
 | 
							var prefix = "1:2:3:4:5:6"
 | 
				
			||||||
		var r = &RouteRangeIPRange{
 | 
							var r = &NSRouteRangeIPRange{
 | 
				
			||||||
			IPFrom: prefix + ":1:8",
 | 
								IPFrom: prefix + ":1:8",
 | 
				
			||||||
			IPTo:   prefix + ":5:10",
 | 
								IPTo:   prefix + ":5:10",
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
@@ -48,7 +48,7 @@ func TestRouteRangeIPRange_Contains(t *testing.T) {
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		var r = &RouteRangeCIDR{
 | 
							var r = &NSRouteRangeCIDR{
 | 
				
			||||||
			CIDR: "192.168.2.1/24",
 | 
								CIDR: "192.168.2.1/24",
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		err := r.Init()
 | 
							err := r.Init()
 | 
				
			||||||
@@ -65,7 +65,7 @@ func TestRouteRangeIPRange_Contains(t *testing.T) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	// reverse ipv4
 | 
						// reverse ipv4
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		var r = &RouteRangeIPRange{
 | 
							var r = &NSRouteRangeIPRange{
 | 
				
			||||||
			IPFrom: "192.168.1.100",
 | 
								IPFrom: "192.168.1.100",
 | 
				
			||||||
			IPTo:   "192.168.3.200",
 | 
								IPTo:   "192.168.3.200",
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
@@ -81,7 +81,7 @@ func TestRouteRangeIPRange_Contains(t *testing.T) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	// reverse cidr
 | 
						// reverse cidr
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		var r = &RouteRangeCIDR{
 | 
							var r = &NSRouteRangeCIDR{
 | 
				
			||||||
			CIDR: "192.168.2.1/24",
 | 
								CIDR: "192.168.2.1/24",
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		err := r.Init()
 | 
							err := r.Init()
 | 
				
			||||||
@@ -2,7 +2,7 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
package dnsconfigs
 | 
					package dnsconfigs
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// TSIGConfig 配置
 | 
					// NSTSIGConfig 配置
 | 
				
			||||||
type TSIGConfig struct {
 | 
					type NSTSIGConfig struct {
 | 
				
			||||||
	IsOn bool `yaml:"isOn" json:"isOn"`
 | 
						IsOn bool `yaml:"isOn" json:"isOn"`
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -1,22 +0,0 @@
 | 
				
			|||||||
// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
package dnsconfigs
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
type DNSHost struct {
 | 
					 | 
				
			||||||
	Host     string `json:"host"`
 | 
					 | 
				
			||||||
	Port     int    `json:"port"`
 | 
					 | 
				
			||||||
	Protocol string `json:"protocol"`
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// RecursionConfig 递归DNS设置
 | 
					 | 
				
			||||||
type RecursionConfig struct {
 | 
					 | 
				
			||||||
	IsOn          bool       `json:"isOn"`
 | 
					 | 
				
			||||||
	Hosts         []*DNSHost `json:"hosts"`
 | 
					 | 
				
			||||||
	UseLocalHosts bool       `json:"useLocalHosts"` // 自动从本机读取DNS
 | 
					 | 
				
			||||||
	AllowDomains  []string   `json:"allowDomains"`
 | 
					 | 
				
			||||||
	DenyDomains   []string   `json:"denyDomains"`
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
func (this *RecursionConfig) Init() error {
 | 
					 | 
				
			||||||
	return nil
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
		Reference in New Issue
	
	Block a user