fix: config marshaller

This commit is contained in:
mzz2017
2023-07-13 21:01:59 +08:00
parent 6dad0a2d86
commit 8bde2f6d45
3 changed files with 5 additions and 5 deletions

View File

@ -88,7 +88,7 @@ type DnsRouting struct {
}
type KeyableString string
type Dns struct {
IpVersionPrefer int `mapstructure:"ipversion_prefer"`
IpVersionPrefer uint8 `mapstructure:"ipversion_prefer"`
FixedDomainTtl []KeyableString `mapstructure:"fixed_domain_ttl"`
Upstream []KeyableString `mapstructure:"upstream"`
Routing DnsRouting `mapstructure:"routing"`

View File

@ -180,7 +180,7 @@ func (m *Marshaller) marshalLeaf(key string, from reflect.Value, depth int) (err
case fmt.Stringer, string,
uint8, uint16, uint32, uint64,
int8, int16, int32, int64,
float32, float64,
float32, float64, int,
bool:
m.writeLine(depth, key+":"+strconv.Quote(fmt.Sprintf("%v", val)))
case *config_parser.Function:

View File

@ -38,7 +38,7 @@ const (
minFirefoxCacheTtl = 120
)
type IpVersionPrefer int
type IpVersionPrefer uint8
const (
IpVersionPrefer_No IpVersionPrefer = 0
@ -61,7 +61,7 @@ type DnsControllerOption struct {
CacheRemoveCallback func(cache *DnsCache) (err error)
NewCache func(fqdn string, answers []dnsmessage.RR, deadline time.Time) (cache *DnsCache, err error)
BestDialerChooser func(req *udpRequest, upstream *dns.Upstream) (*dialArgument, error)
IpVersionPrefer int
IpVersionPrefer uint8
FixedDomainTtl map[string]int
}
@ -83,7 +83,7 @@ type DnsController struct {
dnsCache map[string]*DnsCache
}
func parseIpVersionPreference(prefer int) (uint16, error) {
func parseIpVersionPreference(prefer uint8) (uint16, error) {
switch prefer := IpVersionPrefer(prefer); prefer {
case IpVersionPrefer_No:
return 0, nil