Fix: crash when dns not set
This commit is contained in:
parent
42b8d46c0c
commit
794bbb87da
4 changed files with 19 additions and 10 deletions
18
README.md
18
README.md
|
@ -100,15 +100,15 @@ external-controller: 127.0.0.1:9090
|
||||||
# secret: ""
|
# secret: ""
|
||||||
|
|
||||||
dns:
|
dns:
|
||||||
enable: true # set true to enable dns
|
# enable: true # set true to enable dns (default is false)
|
||||||
ipv6: false # default is false
|
# ipv6: false # default is false
|
||||||
listen: 0.0.0.0:53
|
# listen: 0.0.0.0:53
|
||||||
enhanced-mode: redir-host
|
# enhanced-mode: redir-host
|
||||||
nameserver:
|
# nameserver:
|
||||||
- 114.114.114.114
|
# - 114.114.114.114
|
||||||
- tls://dns.rubyfish.cn:853 # dns over tls
|
# - tls://dns.rubyfish.cn:853 # dns over tls
|
||||||
fallback: # concurrent request with nameserver, fallback used when GEOIP country isn't CN
|
# fallback: # concurrent request with nameserver, fallback used when GEOIP country isn't CN
|
||||||
- 8.8.8.8
|
# - 8.8.8.8
|
||||||
|
|
||||||
Proxy:
|
Proxy:
|
||||||
|
|
||||||
|
|
|
@ -95,6 +95,9 @@ func readConfig(path string) (*rawConfig, error) {
|
||||||
Rule: []string{},
|
Rule: []string{},
|
||||||
Proxy: []map[string]interface{}{},
|
Proxy: []map[string]interface{}{},
|
||||||
ProxyGroup: []map[string]interface{}{},
|
ProxyGroup: []map[string]interface{}{},
|
||||||
|
DNS: &rawDNS{
|
||||||
|
Enable: false,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
err = yaml.Unmarshal([]byte(data), &rawConfig)
|
err = yaml.Unmarshal([]byte(data), &rawConfig)
|
||||||
return rawConfig, err
|
return rawConfig, err
|
||||||
|
|
|
@ -250,6 +250,8 @@ func New(config Config) *Resolver {
|
||||||
mmdb, _ = geoip2.Open(C.Path.MMDB())
|
mmdb, _ = geoip2.Open(C.Path.MMDB())
|
||||||
})
|
})
|
||||||
|
|
||||||
|
println(config.EnhancedMode)
|
||||||
|
|
||||||
r := &Resolver{
|
r := &Resolver{
|
||||||
main: transform(config.Main),
|
main: transform(config.Main),
|
||||||
ipv6: config.IPv6,
|
ipv6: config.IPv6,
|
||||||
|
|
|
@ -15,13 +15,15 @@ import (
|
||||||
var (
|
var (
|
||||||
// EnhancedModeMapping is a mapping for EnhancedMode enum
|
// EnhancedModeMapping is a mapping for EnhancedMode enum
|
||||||
EnhancedModeMapping = map[string]EnhancedMode{
|
EnhancedModeMapping = map[string]EnhancedMode{
|
||||||
|
NORMAL.String(): NORMAL,
|
||||||
FAKEIP.String(): FAKEIP,
|
FAKEIP.String(): FAKEIP,
|
||||||
MAPPING.String(): MAPPING,
|
MAPPING.String(): MAPPING,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
FAKEIP EnhancedMode = iota
|
NORMAL EnhancedMode = iota
|
||||||
|
FAKEIP
|
||||||
MAPPING
|
MAPPING
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -65,6 +67,8 @@ func (e EnhancedMode) MarshalJSON() ([]byte, error) {
|
||||||
|
|
||||||
func (e EnhancedMode) String() string {
|
func (e EnhancedMode) String() string {
|
||||||
switch e {
|
switch e {
|
||||||
|
case NORMAL:
|
||||||
|
return "normal"
|
||||||
case FAKEIP:
|
case FAKEIP:
|
||||||
return "fakeip"
|
return "fakeip"
|
||||||
case MAPPING:
|
case MAPPING:
|
||||||
|
|
Loading…
Reference in a new issue