Skip to content

Commit

Permalink
all: remove last conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
EugeneOne1 committed Jan 19, 2021
1 parent 88b63f1 commit d3ba6a6
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 13 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ and this project adheres to

- The undocumented ability to use hostnames as any of `bind_host` values in
configuration. Documentation requires them to be valid IP addresses, and now
the implementation makes sure that that is the case.
the implementation makes sure that that is the case ([#2508]).
- `Dockerfile` ([#2276]). Replaced with the script
`scripts/make/build-docker.sh` which uses `scripts/make/Dockerfile`.
- Support for pre-v0.99.3 format of query logs ([#2102]).
Expand Down
10 changes: 5 additions & 5 deletions internal/dnsfilter/dnsfilter.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ type RequestFilteringSettings struct {
ParentalEnabled bool

ClientName string
// TODO(e.burkov): Wait for urlfilter update to replace with net.IP.
ClientIP string
ClientIP net.IP
ClientTags []string

ServicesRules []ServiceEntry
Expand Down Expand Up @@ -677,9 +676,10 @@ func (d *DNSFilter) matchHost(host string, qtype uint16, setts RequestFilteringS
ureq := urlfilter.DNSRequest{
Hostname: host,
SortedClientTags: setts.ClientTags,
ClientIP: setts.ClientIP,
ClientName: setts.ClientName,
DNSType: qtype,
// TODO(e.burkov): Wait for urlfilter update to pass net.IP.
ClientIP: setts.ClientIP.String(),
ClientName: setts.ClientName,
DNSType: qtype,
}

if d.filteringEngineAllow != nil {
Expand Down
2 changes: 1 addition & 1 deletion internal/dnsforward/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ type FilteringConfig struct {
// --

// Filtering callback function
FilterHandler func(clientAddr string, settings *dnsfilter.RequestFilteringSettings) `yaml:"-"`
FilterHandler func(clientAddr net.IP, settings *dnsfilter.RequestFilteringSettings) `yaml:"-"`

// GetCustomUpstreamByClient - a callback function that returns upstreams configuration
// based on the client IP address. Returns nil if there are no custom upstreams for the client
Expand Down
2 changes: 1 addition & 1 deletion internal/dnsforward/dnsforward_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ func TestBlockCNAME(t *testing.T) {
func TestClientRulesForCNAMEMatching(t *testing.T) {
s := createTestServer(t)
testUpstm := &testUpstream{testCNAMEs, testIPv4, nil}
s.conf.FilterHandler = func(_ string, settings *dnsfilter.RequestFilteringSettings) {
s.conf.FilterHandler = func(_ net.IP, settings *dnsfilter.RequestFilteringSettings) {
settings.FilteringEnabled = false
}
err := s.startWithUpstream(testUpstm)
Expand Down
3 changes: 1 addition & 2 deletions internal/dnsforward/filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ func (s *Server) getClientRequestFilteringSettings(d *proxy.DNSContext) *dnsfilt
setts := s.dnsFilter.GetConfig()
setts.FilteringEnabled = true
if s.conf.FilterHandler != nil {
clientAddr := IPStringFromAddr(d.Addr)
s.conf.FilterHandler(clientAddr, &setts)
s.conf.FilterHandler(IPFromAddr(d.Addr), &setts)
}
return &setts
}
Expand Down
6 changes: 3 additions & 3 deletions internal/home/dns.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,15 +274,15 @@ func getDNSAddresses() []string {
}

// If a client has his own settings, apply them
func applyAdditionalFiltering(clientAddr string, setts *dnsfilter.RequestFilteringSettings) {
func applyAdditionalFiltering(clientAddr net.IP, setts *dnsfilter.RequestFilteringSettings) {
Context.dnsFilter.ApplyBlockedServices(setts, nil, true)

if len(clientAddr) == 0 {
if clientAddr == nil {
return
}
setts.ClientIP = clientAddr

c, ok := Context.clients.Find(net.ParseIP(clientAddr))
c, ok := Context.clients.Find(clientAddr)
if !ok {
return
}
Expand Down

0 comments on commit d3ba6a6

Please sign in to comment.