Skip to content

Commit

Permalink
chore(all): drop qdm12/govalid dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
qdm12 committed Jun 14, 2023
1 parent 152c6f0 commit 55c6711
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 24 deletions.
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ require (
github.com/qdm12/gosettings v0.4.0-rc1
github.com/qdm12/gosplash v0.1.0
github.com/qdm12/gotree v0.0.0-20211231173558-a8b7dce9989e
github.com/qdm12/govalid v0.2.0-rc1
github.com/qdm12/log v0.1.0
github.com/stretchr/testify v1.8.3
golang.org/x/text v0.4.0
Expand Down
6 changes: 0 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -254,18 +254,12 @@ github.com/qdm12/golibs v0.0.0-20210915134941-19815c6f95fe h1:aXHAv+bR7+kqyhEhlj
github.com/qdm12/golibs v0.0.0-20210915134941-19815c6f95fe/go.mod h1:6aRbg4Z/bTbm9JfxsGXfWKHi7zsOvPfUTK1S5HuAFKg=
github.com/qdm12/goservices v0.1.0-rc2 h1:8tvjgKcp8Sf13d7IhHq3S+zbKVq2lCre09ASFRsRb4A=
github.com/qdm12/goservices v0.1.0-rc2/go.mod h1:EX1khwYx2pDcHolFowDfk2GmkZqq4gBwrN6qx2gls5Q=
github.com/qdm12/gosettings v0.3.0-rc6 h1:zsGXIIZ5FWsn9LeFBbr7s2/xgeodfvmWliVAFXHM9ZU=
github.com/qdm12/gosettings v0.3.0-rc6/go.mod h1:+hHzN8lsE63T01t6SruGzc6xkpvfsZFod/ooDs8FWnQ=
github.com/qdm12/gosettings v0.3.0 h1:YutcgQzVaOB3LuLj+Smtoy90JOH/5B5p2IH3BvV3ra4=
github.com/qdm12/gosettings v0.3.0/go.mod h1:JRV3opOpHvnKlIA29lKQMdYw1WSMVMfHYLLHPHol5ME=
github.com/qdm12/gosettings v0.4.0-rc1 h1:UYA92yyeDPbmZysIuG65yrpZVPtdIoRmtEHft/AyI38=
github.com/qdm12/gosettings v0.4.0-rc1/go.mod h1:JRV3opOpHvnKlIA29lKQMdYw1WSMVMfHYLLHPHol5ME=
github.com/qdm12/gosplash v0.1.0 h1:Sfl+zIjFZFP7b0iqf2l5UkmEY97XBnaKkH3FNY6Gf7g=
github.com/qdm12/gosplash v0.1.0/go.mod h1:+A3fWW4/rUeDXhY3ieBzwghKdnIPFJgD8K3qQkenJlw=
github.com/qdm12/gotree v0.0.0-20211231173558-a8b7dce9989e h1:L1zGR8xaYpbGFO9GjphGHmN91nIzwVp2EO6cauAtwoI=
github.com/qdm12/gotree v0.0.0-20211231173558-a8b7dce9989e/go.mod h1:1SdFaqKZuI46U1apbXIf25pDMNnrPuYLEqMF/qL4lY4=
github.com/qdm12/govalid v0.2.0-rc1 h1:4iYQvU4ibrASgzelsEgZX4JyKX3UTB/DcHObzQ7BXtw=
github.com/qdm12/govalid v0.2.0-rc1/go.mod h1:/uWzVWMuS71wmbsVnlUxpQiy6EAXqm8eQ2RbyA72roQ=
github.com/qdm12/log v0.1.0 h1:jYBd/xscHYpblzZAd2kjZp2YmuYHjAAfbTViJWxoPTw=
github.com/qdm12/log v0.1.0/go.mod h1:Vchi5M8uBvHfPNIblN4mjXn/oSbiWguQIbsgF1zdQPI=
github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4=
Expand Down
4 changes: 2 additions & 2 deletions internal/config/settings/prometheus.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"os"

"github.com/qdm12/gosettings"
"github.com/qdm12/gosettings/validate"
"github.com/qdm12/gotree"
"github.com/qdm12/govalid/address"
)

type Prometheus struct {
Expand All @@ -20,7 +20,7 @@ func (p *Prometheus) SetDefaults() {
}

func (p *Prometheus) Validate() (err error) {
err = address.Validate(p.ListeningAddress, address.OptionListening(os.Getuid()))
err = validate.ListeningAddress(p.ListeningAddress, os.Getuid())
if err != nil {
return fmt.Errorf("listening address: %w", err)
}
Expand Down
6 changes: 1 addition & 5 deletions internal/config/settings/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ import (
"github.com/qdm12/gosettings"
"github.com/qdm12/gosettings/validate"
"github.com/qdm12/gotree"
"github.com/qdm12/govalid/address"
"github.com/qdm12/govalid/port"
)

// Settings contain settings to configure the entire program
Expand Down Expand Up @@ -58,9 +56,7 @@ func (s *Settings) Validate() (err error) {
}

const privilegedAllowedPort = 53
portOption := port.OptionListeningPortPrivilegedAllowed(privilegedAllowedPort)
addressOption := address.OptionListening(os.Getuid(), portOption)
err = address.Validate(s.ListeningAddress, addressOption)
err = validate.ListeningAddress(s.ListeningAddress, os.Getuid(), privilegedAllowedPort)
if err != nil {
return fmt.Errorf("listening address: %w", err)
}
Expand Down
7 changes: 2 additions & 5 deletions pkg/doh/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@ import (
lognoop "github.com/qdm12/dns/v2/pkg/log/noop"
"github.com/qdm12/dns/v2/pkg/provider"
"github.com/qdm12/gosettings"
"github.com/qdm12/gosettings/validate"
"github.com/qdm12/gotree"
"github.com/qdm12/govalid/address"
"github.com/qdm12/govalid/port"
"golang.org/x/text/cases"
"golang.org/x/text/language"
)
Expand Down Expand Up @@ -105,9 +104,7 @@ func (s ServerSettings) Validate() (err error) {
}

const defaultUDPPort = 53
err = address.Validate(s.ListeningAddress,
address.OptionListening(
os.Getuid(), port.OptionListeningPortPrivilegedAllowed(defaultUDPPort)))
err = validate.ListeningAddress(s.ListeningAddress, os.Getuid(), defaultUDPPort)
if err != nil {
return fmt.Errorf("%w: %s", ErrListeningAddressNotValid, s.ListeningAddress)
}
Expand Down
7 changes: 2 additions & 5 deletions pkg/dot/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@ import (
lognoop "github.com/qdm12/dns/v2/pkg/log/noop"
"github.com/qdm12/dns/v2/pkg/provider"
"github.com/qdm12/gosettings"
"github.com/qdm12/gosettings/validate"
"github.com/qdm12/gotree"
"github.com/qdm12/govalid/address"
"github.com/qdm12/govalid/port"
"golang.org/x/text/cases"
"golang.org/x/text/language"
)
Expand Down Expand Up @@ -94,9 +93,7 @@ func (s ServerSettings) Validate() (err error) {
}

const defaultUDPPort = 53
err = address.Validate(s.ListeningAddress,
address.OptionListening(
os.Getuid(), port.OptionListeningPortPrivilegedAllowed(defaultUDPPort)))
err = validate.ListeningAddress(s.ListeningAddress, os.Getuid(), defaultUDPPort)
if err != nil {
return fmt.Errorf("%w: %s", ErrListeningAddressNotValid, s.ListeningAddress)
}
Expand Down

0 comments on commit 55c6711

Please sign in to comment.