Skip to content

Commit

Permalink
fix(dns): serve interface parser
Browse files Browse the repository at this point in the history
  • Loading branch information
wweir committed Oct 12, 2024
1 parent ea6c2a2 commit 9eaf27f
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions cmd/sower/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ var (

DNS struct {
Disable bool `default:"false" usage:"disable DNS proxy"`
Serve string `default:"127.0.0.1" usage:"dns server ip"`
Serve string `usage:"dns server ip"`
Serve6 string `usage:"dns server ipv6, eg: ::1"`
ServeIface string `usage:"use the IP in the net interface, if serve ip not setted. eg: eth0"`
Fallback string `default:"223.5.5.5" required:"true" usage:"fallback dns server"`
Expand Down Expand Up @@ -78,6 +78,16 @@ func init() {
if err := aconfig.LoaderFor(&conf, aconfig.Config{
AllowUnknownFields: true,
FileFlag: "f",
Files: []string{
"sower.hcl",
"sower.toml",
"sower.yaml",
"sower.yml",
"/etc/sower/sower.hcl",
"/etc/sower/sower.toml",
"/etc/sower/sower.yaml",
"/etc/sower/sower.yml",
},
FileDecoders: map[string]aconfig.FileDecoder{
".yml": aconfigyaml.New(),
".yaml": aconfigyaml.New(),
Expand All @@ -98,7 +108,7 @@ func init() {
for _, addr := range addrs {
ip, _, err := net.ParseCIDR(addr.String())
log.InfoFatal(err).Str("iface", conf.DNS.ServeIface).
Msg("parse iface addr: " + addr.String())
Msg("parse iface IP: " + ip.String())

if ip.To4() != nil { // ipv4
if conf.DNS.Serve == "" {
Expand Down

0 comments on commit 9eaf27f

Please sign in to comment.