Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore/fix: config marshaller #212

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
2 changes: 1 addition & 1 deletion config/marshal.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 3 additions & 3 deletions control/dns_control.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const (
minFirefoxCacheTtl = 120
)

type IpVersionPrefer int
type IpVersionPrefer uint8

const (
IpVersionPrefer_No IpVersionPrefer = 0
Expand All @@ -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
}

Expand All @@ -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
Expand Down