-
Notifications
You must be signed in to change notification settings - Fork 311
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Hello,
hosts-file-enabled uses cmd.decodableBool declared in internal/cmd/options.go:
dnsproxy/internal/cmd/options.go
Lines 26 to 43 in 25e110a
| // decodableBool is a boolean that can be unmarshaled from a flags. | |
| // | |
| // TODO(e.burkov): This is a workaround for go-flags, see | |
| // https://github.com/AdguardTeam/dnsproxy/issues/182. | |
| type decodableBool struct { | |
| value bool | |
| } | |
| // type check | |
| var _ goFlags.Unmarshaler = (*decodableBool)(nil) | |
| // UnmarshalFlag implements the [goFlags.Unmarshaler] interface for | |
| // *decodableBool. | |
| func (b *decodableBool) UnmarshalFlag(text string) (err error) { | |
| b.value, err = strconv.ParseBool(text) | |
| return err | |
| } |
While the option works as intended as a launch flag --hosts-file-enabled=false, setting it inside a YAML config (hosts-file-enabled: false) will not work:
Aug 20 16:22:47 hostname dnsproxy[738715]: dnsproxy config path: /etc/dnsproxy/config.yaml
Aug 20 16:22:47 hostname dnsproxy[738715]: parsing config file /etc/dnsproxy/config.yaml: unmarshalling file: yaml: unmarshal errors:
Aug 20 16:22:47 hostname dnsproxy[738715]: line 84: cannot unmarshal !!bool `false` into cmd.decodableBool
Setting it as a string (hosts-file-enabled: "false") also fails:
Aug 20 16:24:47 hostname dnsproxy[738747]: dnsproxy config path: /etc/dnsproxy/config.yaml
Aug 20 16:24:47 hostname dnsproxy[738747]: parsing config file /etc/dnsproxy/config.yaml: unmarshalling file: yaml: unmarshal errors:
Aug 20 16:24:47 hostname dnsproxy[738747]: line 84: cannot unmarshal !!str `false` into cmd.decodableBool
I don't understand why exactly this occurs (I'm not really proficient in Go), one might omit the YAML flag (seen below) and use it as a command line argument:
dnsproxy/internal/cmd/options.go
Lines 233 to 235 in 25e110a
| // HostsFileEnabled controls whether hosts files are used for resolving or | |
| // not. | |
| HostsFileEnabled decodableBool `yaml:"hosts-file-enabled" long:"hosts-file-enabled" description:"If specified, use hosts files for resolving" default:"true"` |
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working