code_before
stringlengths
16
1.81M
edits
stringlengths
4
328k
next_edit
stringlengths
0
76.5k
code_after
stringlengths
3
49.9M
label_window
sequencelengths
4
1.81k
instruction
stringlengths
20
51.9k
html_url
stringlengths
74
116
file_name
stringlengths
3
311
// locally-served networks should be resolved via private PTR resolvers. UsePrivateRDNS bool // ServeHTTP3 defines if HTTP/3 is be allowed for incoming requests. ServeHTTP3 bool // UseHTTP3Upstreams defines if HTTP/3 is be allowed for DNS-over-HTTPS
</s> remove // isLocalClient shows if client's IP address is from locally-served </s> add // isLocalClient shows if client's IP address is from locally served </s> remove // assume that all the DHCP leases we give are locally-served or at least // don't need to be accessible externally. </s> add // assume that all the DHCP leases we give are locally served or at least // shouldn't be accessible externally.
// UseDNS64 defines if DNS64 is enabled for incoming requests. UseDNS64 bool
// locally-served networks should be resolved via private PTR resolvers. UsePrivateRDNS bool // UseDNS64 defines if DNS64 is enabled for incoming requests. UseDNS64 bool // ServeHTTP3 defines if HTTP/3 is be allowed for incoming requests. ServeHTTP3 bool // UseHTTP3Upstreams defines if HTTP/3 is be allowed for DNS-over-HTTPS
[ "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
Pull request: 5117-dns64 Merge in DNS/adguard-home from 5117-dns64 to master Updates #5117. Squashed commit of the following: commit 757d689134b85bdac9a6f5e43249866ec09ab7e3 Author: Eugene Burkov <[email protected]> Date: Mon Jan 23 19:06:18 2023 +0300 all: imp fmt commit b7a73c68c0b40bd3bda520c045c8110975c1827a Author: Eugene Burkov <[email protected]> Date: Mon Jan 23 17:49:21 2023 +0300 all: rm unused, imp code commit 548feb6bd27b9774a9453d0570d37cdf557d4c3a Merge: de3e84b5 54a141ab Author: Eugene Burkov <[email protected]> Date: Mon Jan 23 14:08:12 2023 +0300 Merge branch 'master' into 5117-dns64 commit de3e84b52b8dbff70df3ca0ac3315c3d33576334 Author: Eugene Burkov <[email protected]> Date: Mon Jan 23 12:04:48 2023 +0300 dnsforward: imp code commit a580e92119e3dbadc8b1a6572dbecc679f69db40 Author: Eugene Burkov <[email protected]> Date: Fri Jan 20 18:24:33 2023 +0400 dnsforward: try again commit 67b7a365194939fe15e4907a3dc2fee44b019d08 Author: Eugene Burkov <[email protected]> Date: Fri Jan 20 18:08:23 2023 +0400 dnsforward: fix test on linux commit ca83e4178a3383e326bf528d209d8766fb3c60d3 Author: Eugene Burkov <[email protected]> Date: Fri Jan 20 17:37:48 2023 +0400 dnsforward: imp naming commit c4e477c7a12af4966cbcd4e5f003a72966dc5d61 Merge: 42aa42a8 6e803375 Author: Eugene Burkov <[email protected]> Date: Fri Jan 20 17:30:03 2023 +0400 Merge branch 'master' into 5117-dns64 commit 42aa42a8149b6bb42eb0da6e88ede4b5065bbf2f Author: Eugene Burkov <[email protected]> Date: Fri Jan 20 17:26:54 2023 +0400 dnsforward: imp test commit 4e91c675703f1453456ef9eea08157009ce6237a Author: Eugene Burkov <[email protected]> Date: Wed Jan 18 12:32:55 2023 +0400 dnsforward: imp code, docs, add test commit 766ef757f61e7a555b8151b4783fa7aba5f566f7 Author: Eugene Burkov <[email protected]> Date: Tue Jan 17 16:36:35 2023 +0400 dnsforward: imp docs commit 6825f372389988597d1879cf66342c410f3cfd47 Author: Eugene Burkov <[email protected]> Date: Tue Jan 17 14:33:33 2023 +0400 internal: imp code, docs commit 1215316a338496b5bea2b20d697c7451bfbcc84b Author: Eugene Burkov <[email protected]> Date: Fri Jan 13 21:24:50 2023 +0400 all: add dns64 support
https://github.com/AdguardTeam/AdGuardHome/commit/2ecf2a4c42fbd7ea61573d35271ee65f335c7c4f
internal/dnsforward/config.go
// origResp is the response received from upstream. It is set when the // response is modified by filters. origResp *dns.Msg // unreversedReqIP stores an IP address obtained from PTR request if it // parsed successfully and belongs to one of locally-served IP ranges as per // RFC 6303. unreversedReqIP net.IP // err is the error returned from a processing function. err error
</s> remove // isLocalClient shows if client's IP address is from locally-served </s> add // isLocalClient shows if client's IP address is from locally served </s> remove // the server. </s> add // the server. It responds with a mapped IP address if the DNS64 is enabled and // the request is for AAAA. </s> remove // processDetermineLocal determines if the client's IP address is from // locally-served network and saves the result into the context. </s> add // processDetermineLocal determines if the client's IP address is from locally // served network and saves the result into the context. </s> remove // code is only executed when the request is for locally-served ARPA </s> add // code is only executed when the request is for locally served ARPA
// unreversedReqIP stores an IP address obtained from a PTR request if it // was parsed successfully and belongs to one of the locally served IP // ranges. It is also filled with unmapped version of the address if it's // within DNS64 prefixes.
// origResp is the response received from upstream. It is set when the // response is modified by filters. origResp *dns.Msg // unreversedReqIP stores an IP address obtained from a PTR request if it // was parsed successfully and belongs to one of the locally served IP // ranges. It is also filled with unmapped version of the address if it's // within DNS64 prefixes. // unreversedReqIP stores an IP address obtained from a PTR request if it // was parsed successfully and belongs to one of the locally served IP // ranges. It is also filled with unmapped version of the address if it's // within DNS64 prefixes. // unreversedReqIP stores an IP address obtained from a PTR request if it // was parsed successfully and belongs to one of the locally served IP // ranges. It is also filled with unmapped version of the address if it's // within DNS64 prefixes. unreversedReqIP net.IP // err is the error returned from a processing function. err error
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: 5117-dns64 Merge in DNS/adguard-home from 5117-dns64 to master Updates #5117. Squashed commit of the following: commit 757d689134b85bdac9a6f5e43249866ec09ab7e3 Author: Eugene Burkov <[email protected]> Date: Mon Jan 23 19:06:18 2023 +0300 all: imp fmt commit b7a73c68c0b40bd3bda520c045c8110975c1827a Author: Eugene Burkov <[email protected]> Date: Mon Jan 23 17:49:21 2023 +0300 all: rm unused, imp code commit 548feb6bd27b9774a9453d0570d37cdf557d4c3a Merge: de3e84b5 54a141ab Author: Eugene Burkov <[email protected]> Date: Mon Jan 23 14:08:12 2023 +0300 Merge branch 'master' into 5117-dns64 commit de3e84b52b8dbff70df3ca0ac3315c3d33576334 Author: Eugene Burkov <[email protected]> Date: Mon Jan 23 12:04:48 2023 +0300 dnsforward: imp code commit a580e92119e3dbadc8b1a6572dbecc679f69db40 Author: Eugene Burkov <[email protected]> Date: Fri Jan 20 18:24:33 2023 +0400 dnsforward: try again commit 67b7a365194939fe15e4907a3dc2fee44b019d08 Author: Eugene Burkov <[email protected]> Date: Fri Jan 20 18:08:23 2023 +0400 dnsforward: fix test on linux commit ca83e4178a3383e326bf528d209d8766fb3c60d3 Author: Eugene Burkov <[email protected]> Date: Fri Jan 20 17:37:48 2023 +0400 dnsforward: imp naming commit c4e477c7a12af4966cbcd4e5f003a72966dc5d61 Merge: 42aa42a8 6e803375 Author: Eugene Burkov <[email protected]> Date: Fri Jan 20 17:30:03 2023 +0400 Merge branch 'master' into 5117-dns64 commit 42aa42a8149b6bb42eb0da6e88ede4b5065bbf2f Author: Eugene Burkov <[email protected]> Date: Fri Jan 20 17:26:54 2023 +0400 dnsforward: imp test commit 4e91c675703f1453456ef9eea08157009ce6237a Author: Eugene Burkov <[email protected]> Date: Wed Jan 18 12:32:55 2023 +0400 dnsforward: imp code, docs, add test commit 766ef757f61e7a555b8151b4783fa7aba5f566f7 Author: Eugene Burkov <[email protected]> Date: Tue Jan 17 16:36:35 2023 +0400 dnsforward: imp docs commit 6825f372389988597d1879cf66342c410f3cfd47 Author: Eugene Burkov <[email protected]> Date: Tue Jan 17 14:33:33 2023 +0400 internal: imp code, docs commit 1215316a338496b5bea2b20d697c7451bfbcc84b Author: Eugene Burkov <[email protected]> Date: Fri Jan 13 21:24:50 2023 +0400 all: add dns64 support
https://github.com/AdguardTeam/AdGuardHome/commit/2ecf2a4c42fbd7ea61573d35271ee65f335c7c4f
internal/dnsforward/dns.go
// responseAD shows if the response had the AD bit set. responseAD bool // isLocalClient shows if client's IP address is from locally-served // network. isLocalClient bool } // resultCode is the result of a request processing function.
</s> remove // unreversedReqIP stores an IP address obtained from PTR request if it // parsed successfully and belongs to one of locally-served IP ranges as per // RFC 6303. </s> add // unreversedReqIP stores an IP address obtained from a PTR request if it // was parsed successfully and belongs to one of the locally served IP // ranges. It is also filled with unmapped version of the address if it's // within DNS64 prefixes. </s> remove // processDetermineLocal determines if the client's IP address is from // locally-served network and saves the result into the context. </s> add // processDetermineLocal determines if the client's IP address is from locally // served network and saves the result into the context. </s> remove // the server. </s> add // the server. It responds with a mapped IP address if the DNS64 is enabled and // the request is for AAAA.
// isLocalClient shows if client's IP address is from locally served
// responseAD shows if the response had the AD bit set. responseAD bool // isLocalClient shows if client's IP address is from locally served // network. isLocalClient bool } // resultCode is the result of a request processing function.
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: 5117-dns64 Merge in DNS/adguard-home from 5117-dns64 to master Updates #5117. Squashed commit of the following: commit 757d689134b85bdac9a6f5e43249866ec09ab7e3 Author: Eugene Burkov <[email protected]> Date: Mon Jan 23 19:06:18 2023 +0300 all: imp fmt commit b7a73c68c0b40bd3bda520c045c8110975c1827a Author: Eugene Burkov <[email protected]> Date: Mon Jan 23 17:49:21 2023 +0300 all: rm unused, imp code commit 548feb6bd27b9774a9453d0570d37cdf557d4c3a Merge: de3e84b5 54a141ab Author: Eugene Burkov <[email protected]> Date: Mon Jan 23 14:08:12 2023 +0300 Merge branch 'master' into 5117-dns64 commit de3e84b52b8dbff70df3ca0ac3315c3d33576334 Author: Eugene Burkov <[email protected]> Date: Mon Jan 23 12:04:48 2023 +0300 dnsforward: imp code commit a580e92119e3dbadc8b1a6572dbecc679f69db40 Author: Eugene Burkov <[email protected]> Date: Fri Jan 20 18:24:33 2023 +0400 dnsforward: try again commit 67b7a365194939fe15e4907a3dc2fee44b019d08 Author: Eugene Burkov <[email protected]> Date: Fri Jan 20 18:08:23 2023 +0400 dnsforward: fix test on linux commit ca83e4178a3383e326bf528d209d8766fb3c60d3 Author: Eugene Burkov <[email protected]> Date: Fri Jan 20 17:37:48 2023 +0400 dnsforward: imp naming commit c4e477c7a12af4966cbcd4e5f003a72966dc5d61 Merge: 42aa42a8 6e803375 Author: Eugene Burkov <[email protected]> Date: Fri Jan 20 17:30:03 2023 +0400 Merge branch 'master' into 5117-dns64 commit 42aa42a8149b6bb42eb0da6e88ede4b5065bbf2f Author: Eugene Burkov <[email protected]> Date: Fri Jan 20 17:26:54 2023 +0400 dnsforward: imp test commit 4e91c675703f1453456ef9eea08157009ce6237a Author: Eugene Burkov <[email protected]> Date: Wed Jan 18 12:32:55 2023 +0400 dnsforward: imp code, docs, add test commit 766ef757f61e7a555b8151b4783fa7aba5f566f7 Author: Eugene Burkov <[email protected]> Date: Tue Jan 17 16:36:35 2023 +0400 dnsforward: imp docs commit 6825f372389988597d1879cf66342c410f3cfd47 Author: Eugene Burkov <[email protected]> Date: Tue Jan 17 14:33:33 2023 +0400 internal: imp code, docs commit 1215316a338496b5bea2b20d697c7451bfbcc84b Author: Eugene Burkov <[email protected]> Date: Fri Jan 13 21:24:50 2023 +0400 all: add dns64 support
https://github.com/AdguardTeam/AdGuardHome/commit/2ecf2a4c42fbd7ea61573d35271ee65f335c7c4f
internal/dnsforward/dns.go
return nil } // processRecursion checks the incoming request and halts it's handling if s // have tried to resolve it recently. func (s *Server) processRecursion(dctx *dnsContext) (rc resultCode) { pctx := dctx.proxyCtx if msg := pctx.Req; msg != nil && s.recDetector.check(*msg) { log.Debug("recursion detected resolving %q", msg.Question[0].Name)
</s> remove // the server. </s> add // the server. It responds with a mapped IP address if the DNS64 is enabled and // the request is for AAAA. </s> remove // in locally-served network from external clients. </s> add // in locally served network from external clients. </s> remove // processDetermineLocal determines if the client's IP address is from // locally-served network and saves the result into the context. </s> add // processDetermineLocal determines if the client's IP address is from locally // served network and saves the result into the context. </s> remove if !webRegistered && s.conf.HTTPRegister != nil { webRegistered = true s.registerHandlers() </s> add s.registerHandlers() err = s.setupDNS64() if err != nil { return fmt.Errorf("preparing DNS64: %w", err) </s> remove if req.AuthenticatedData { origReqAD = true } else { </s> add origReqAD = req.AuthenticatedData if !req.AuthenticatedData {
// processRecursion checks the incoming request and halts its handling by // answering NXDOMAIN if s has tried to resolve it recently.
return nil } // processRecursion checks the incoming request and halts its handling by // answering NXDOMAIN if s has tried to resolve it recently. // processRecursion checks the incoming request and halts its handling by // answering NXDOMAIN if s has tried to resolve it recently. func (s *Server) processRecursion(dctx *dnsContext) (rc resultCode) { pctx := dctx.proxyCtx if msg := pctx.Req; msg != nil && s.recDetector.check(*msg) { log.Debug("recursion detected resolving %q", msg.Question[0].Name)
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: 5117-dns64 Merge in DNS/adguard-home from 5117-dns64 to master Updates #5117. Squashed commit of the following: commit 757d689134b85bdac9a6f5e43249866ec09ab7e3 Author: Eugene Burkov <[email protected]> Date: Mon Jan 23 19:06:18 2023 +0300 all: imp fmt commit b7a73c68c0b40bd3bda520c045c8110975c1827a Author: Eugene Burkov <[email protected]> Date: Mon Jan 23 17:49:21 2023 +0300 all: rm unused, imp code commit 548feb6bd27b9774a9453d0570d37cdf557d4c3a Merge: de3e84b5 54a141ab Author: Eugene Burkov <[email protected]> Date: Mon Jan 23 14:08:12 2023 +0300 Merge branch 'master' into 5117-dns64 commit de3e84b52b8dbff70df3ca0ac3315c3d33576334 Author: Eugene Burkov <[email protected]> Date: Mon Jan 23 12:04:48 2023 +0300 dnsforward: imp code commit a580e92119e3dbadc8b1a6572dbecc679f69db40 Author: Eugene Burkov <[email protected]> Date: Fri Jan 20 18:24:33 2023 +0400 dnsforward: try again commit 67b7a365194939fe15e4907a3dc2fee44b019d08 Author: Eugene Burkov <[email protected]> Date: Fri Jan 20 18:08:23 2023 +0400 dnsforward: fix test on linux commit ca83e4178a3383e326bf528d209d8766fb3c60d3 Author: Eugene Burkov <[email protected]> Date: Fri Jan 20 17:37:48 2023 +0400 dnsforward: imp naming commit c4e477c7a12af4966cbcd4e5f003a72966dc5d61 Merge: 42aa42a8 6e803375 Author: Eugene Burkov <[email protected]> Date: Fri Jan 20 17:30:03 2023 +0400 Merge branch 'master' into 5117-dns64 commit 42aa42a8149b6bb42eb0da6e88ede4b5065bbf2f Author: Eugene Burkov <[email protected]> Date: Fri Jan 20 17:26:54 2023 +0400 dnsforward: imp test commit 4e91c675703f1453456ef9eea08157009ce6237a Author: Eugene Burkov <[email protected]> Date: Wed Jan 18 12:32:55 2023 +0400 dnsforward: imp code, docs, add test commit 766ef757f61e7a555b8151b4783fa7aba5f566f7 Author: Eugene Burkov <[email protected]> Date: Tue Jan 17 16:36:35 2023 +0400 dnsforward: imp docs commit 6825f372389988597d1879cf66342c410f3cfd47 Author: Eugene Burkov <[email protected]> Date: Tue Jan 17 14:33:33 2023 +0400 internal: imp code, docs commit 1215316a338496b5bea2b20d697c7451bfbcc84b Author: Eugene Burkov <[email protected]> Date: Fri Jan 13 21:24:50 2023 +0400 all: add dns64 support
https://github.com/AdguardTeam/AdGuardHome/commit/2ecf2a4c42fbd7ea61573d35271ee65f335c7c4f
internal/dnsforward/dns.go
return resp } // processDetermineLocal determines if the client's IP address is from // locally-served network and saves the result into the context. func (s *Server) processDetermineLocal(dctx *dnsContext) (rc resultCode) { rc = resultCodeSuccess var ip net.IP if ip, _ = netutil.IPAndPortFromAddr(dctx.proxyCtx.Addr); ip == nil {
</s> remove // the server. </s> add // the server. It responds with a mapped IP address if the DNS64 is enabled and // the request is for AAAA. </s> remove // in locally-served network from external clients. </s> add // in locally served network from external clients. </s> remove // processRecursion checks the incoming request and halts it's handling if s // have tried to resolve it recently. </s> add // processRecursion checks the incoming request and halts its handling by // answering NXDOMAIN if s has tried to resolve it recently. </s> remove // isLocalClient shows if client's IP address is from locally-served </s> add // isLocalClient shows if client's IP address is from locally served </s> remove // TODO(a.garipov): Remove once we switch to netip.Addr more fully. </s> add // TODO(a.garipov): Remove once we switch to [netip.Addr] more fully.
// processDetermineLocal determines if the client's IP address is from locally // served network and saves the result into the context.
return resp } // processDetermineLocal determines if the client's IP address is from locally // served network and saves the result into the context. // processDetermineLocal determines if the client's IP address is from locally // served network and saves the result into the context. func (s *Server) processDetermineLocal(dctx *dnsContext) (rc resultCode) { rc = resultCodeSuccess var ip net.IP if ip, _ = netutil.IPAndPortFromAddr(dctx.proxyCtx.Addr); ip == nil {
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: 5117-dns64 Merge in DNS/adguard-home from 5117-dns64 to master Updates #5117. Squashed commit of the following: commit 757d689134b85bdac9a6f5e43249866ec09ab7e3 Author: Eugene Burkov <[email protected]> Date: Mon Jan 23 19:06:18 2023 +0300 all: imp fmt commit b7a73c68c0b40bd3bda520c045c8110975c1827a Author: Eugene Burkov <[email protected]> Date: Mon Jan 23 17:49:21 2023 +0300 all: rm unused, imp code commit 548feb6bd27b9774a9453d0570d37cdf557d4c3a Merge: de3e84b5 54a141ab Author: Eugene Burkov <[email protected]> Date: Mon Jan 23 14:08:12 2023 +0300 Merge branch 'master' into 5117-dns64 commit de3e84b52b8dbff70df3ca0ac3315c3d33576334 Author: Eugene Burkov <[email protected]> Date: Mon Jan 23 12:04:48 2023 +0300 dnsforward: imp code commit a580e92119e3dbadc8b1a6572dbecc679f69db40 Author: Eugene Burkov <[email protected]> Date: Fri Jan 20 18:24:33 2023 +0400 dnsforward: try again commit 67b7a365194939fe15e4907a3dc2fee44b019d08 Author: Eugene Burkov <[email protected]> Date: Fri Jan 20 18:08:23 2023 +0400 dnsforward: fix test on linux commit ca83e4178a3383e326bf528d209d8766fb3c60d3 Author: Eugene Burkov <[email protected]> Date: Fri Jan 20 17:37:48 2023 +0400 dnsforward: imp naming commit c4e477c7a12af4966cbcd4e5f003a72966dc5d61 Merge: 42aa42a8 6e803375 Author: Eugene Burkov <[email protected]> Date: Fri Jan 20 17:30:03 2023 +0400 Merge branch 'master' into 5117-dns64 commit 42aa42a8149b6bb42eb0da6e88ede4b5065bbf2f Author: Eugene Burkov <[email protected]> Date: Fri Jan 20 17:26:54 2023 +0400 dnsforward: imp test commit 4e91c675703f1453456ef9eea08157009ce6237a Author: Eugene Burkov <[email protected]> Date: Wed Jan 18 12:32:55 2023 +0400 dnsforward: imp code, docs, add test commit 766ef757f61e7a555b8151b4783fa7aba5f566f7 Author: Eugene Burkov <[email protected]> Date: Tue Jan 17 16:36:35 2023 +0400 dnsforward: imp docs commit 6825f372389988597d1879cf66342c410f3cfd47 Author: Eugene Burkov <[email protected]> Date: Tue Jan 17 14:33:33 2023 +0400 internal: imp code, docs commit 1215316a338496b5bea2b20d697c7451bfbcc84b Author: Eugene Burkov <[email protected]> Date: Fri Jan 13 21:24:50 2023 +0400 all: add dns64 support
https://github.com/AdguardTeam/AdGuardHome/commit/2ecf2a4c42fbd7ea61573d35271ee65f335c7c4f
internal/dnsforward/dns.go
return ip, ok } // processDHCPHosts respond to A requests if the target hostname is known to // the server. // // TODO(a.garipov): Adapt to AAAA as well. func (s *Server) processDHCPHosts(dctx *dnsContext) (rc resultCode) { pctx := dctx.proxyCtx req := pctx.Req
</s> remove // in locally-served network from external clients. </s> add // in locally served network from external clients. </s> remove // processRecursion checks the incoming request and halts it's handling if s // have tried to resolve it recently. </s> add // processRecursion checks the incoming request and halts its handling by // answering NXDOMAIN if s has tried to resolve it recently. </s> remove // processDetermineLocal determines if the client's IP address is from // locally-served network and saves the result into the context. </s> add // processDetermineLocal determines if the client's IP address is from locally // served network and saves the result into the context. </s> remove // TODO(a.garipov): Remove once we switch to netip.Addr more fully. </s> add // TODO(a.garipov): Remove once we switch to [netip.Addr] more fully.
// the server. It responds with a mapped IP address if the DNS64 is enabled and // the request is for AAAA.
return ip, ok } // processDHCPHosts respond to A requests if the target hostname is known to // the server. It responds with a mapped IP address if the DNS64 is enabled and // the request is for AAAA. // // TODO(a.garipov): Adapt to AAAA as well. func (s *Server) processDHCPHosts(dctx *dnsContext) (rc resultCode) { pctx := dctx.proxyCtx req := pctx.Req
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: 5117-dns64 Merge in DNS/adguard-home from 5117-dns64 to master Updates #5117. Squashed commit of the following: commit 757d689134b85bdac9a6f5e43249866ec09ab7e3 Author: Eugene Burkov <[email protected]> Date: Mon Jan 23 19:06:18 2023 +0300 all: imp fmt commit b7a73c68c0b40bd3bda520c045c8110975c1827a Author: Eugene Burkov <[email protected]> Date: Mon Jan 23 17:49:21 2023 +0300 all: rm unused, imp code commit 548feb6bd27b9774a9453d0570d37cdf557d4c3a Merge: de3e84b5 54a141ab Author: Eugene Burkov <[email protected]> Date: Mon Jan 23 14:08:12 2023 +0300 Merge branch 'master' into 5117-dns64 commit de3e84b52b8dbff70df3ca0ac3315c3d33576334 Author: Eugene Burkov <[email protected]> Date: Mon Jan 23 12:04:48 2023 +0300 dnsforward: imp code commit a580e92119e3dbadc8b1a6572dbecc679f69db40 Author: Eugene Burkov <[email protected]> Date: Fri Jan 20 18:24:33 2023 +0400 dnsforward: try again commit 67b7a365194939fe15e4907a3dc2fee44b019d08 Author: Eugene Burkov <[email protected]> Date: Fri Jan 20 18:08:23 2023 +0400 dnsforward: fix test on linux commit ca83e4178a3383e326bf528d209d8766fb3c60d3 Author: Eugene Burkov <[email protected]> Date: Fri Jan 20 17:37:48 2023 +0400 dnsforward: imp naming commit c4e477c7a12af4966cbcd4e5f003a72966dc5d61 Merge: 42aa42a8 6e803375 Author: Eugene Burkov <[email protected]> Date: Fri Jan 20 17:30:03 2023 +0400 Merge branch 'master' into 5117-dns64 commit 42aa42a8149b6bb42eb0da6e88ede4b5065bbf2f Author: Eugene Burkov <[email protected]> Date: Fri Jan 20 17:26:54 2023 +0400 dnsforward: imp test commit 4e91c675703f1453456ef9eea08157009ce6237a Author: Eugene Burkov <[email protected]> Date: Wed Jan 18 12:32:55 2023 +0400 dnsforward: imp code, docs, add test commit 766ef757f61e7a555b8151b4783fa7aba5f566f7 Author: Eugene Burkov <[email protected]> Date: Tue Jan 17 16:36:35 2023 +0400 dnsforward: imp docs commit 6825f372389988597d1879cf66342c410f3cfd47 Author: Eugene Burkov <[email protected]> Date: Tue Jan 17 14:33:33 2023 +0400 internal: imp code, docs commit 1215316a338496b5bea2b20d697c7451bfbcc84b Author: Eugene Burkov <[email protected]> Date: Fri Jan 13 21:24:50 2023 +0400 all: add dns64 support
https://github.com/AdguardTeam/AdGuardHome/commit/2ecf2a4c42fbd7ea61573d35271ee65f335c7c4f
internal/dnsforward/dns.go
log.Debug("dnsforward: dhcp record for %q is %s", reqHost, ip) resp := s.makeResponse(req) if q.Qtype == dns.TypeA { a := &dns.A{ Hdr: s.hdr(req, dns.TypeA), A: ip.AsSlice(), } resp.Answer = append(resp.Answer, a)
</s> remove // TODO(a.garipov): Remove once we switch to netip.Addr more fully. </s> add // TODO(a.garipov): Remove once we switch to [netip.Addr] more fully. </s> remove log.Debug("dnsforward: addr %s is not from locally-served network", ip) </s> add </s> remove // in locally-served network from external clients. </s> add // in locally served network from external clients.
switch q.Qtype { case dns.TypeA:
log.Debug("dnsforward: dhcp record for %q is %s", reqHost, ip) resp := s.makeResponse(req) switch q.Qtype { case dns.TypeA: a := &dns.A{ Hdr: s.hdr(req, dns.TypeA), A: ip.AsSlice(), } resp.Answer = append(resp.Answer, a)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: 5117-dns64 Merge in DNS/adguard-home from 5117-dns64 to master Updates #5117. Squashed commit of the following: commit 757d689134b85bdac9a6f5e43249866ec09ab7e3 Author: Eugene Burkov <[email protected]> Date: Mon Jan 23 19:06:18 2023 +0300 all: imp fmt commit b7a73c68c0b40bd3bda520c045c8110975c1827a Author: Eugene Burkov <[email protected]> Date: Mon Jan 23 17:49:21 2023 +0300 all: rm unused, imp code commit 548feb6bd27b9774a9453d0570d37cdf557d4c3a Merge: de3e84b5 54a141ab Author: Eugene Burkov <[email protected]> Date: Mon Jan 23 14:08:12 2023 +0300 Merge branch 'master' into 5117-dns64 commit de3e84b52b8dbff70df3ca0ac3315c3d33576334 Author: Eugene Burkov <[email protected]> Date: Mon Jan 23 12:04:48 2023 +0300 dnsforward: imp code commit a580e92119e3dbadc8b1a6572dbecc679f69db40 Author: Eugene Burkov <[email protected]> Date: Fri Jan 20 18:24:33 2023 +0400 dnsforward: try again commit 67b7a365194939fe15e4907a3dc2fee44b019d08 Author: Eugene Burkov <[email protected]> Date: Fri Jan 20 18:08:23 2023 +0400 dnsforward: fix test on linux commit ca83e4178a3383e326bf528d209d8766fb3c60d3 Author: Eugene Burkov <[email protected]> Date: Fri Jan 20 17:37:48 2023 +0400 dnsforward: imp naming commit c4e477c7a12af4966cbcd4e5f003a72966dc5d61 Merge: 42aa42a8 6e803375 Author: Eugene Burkov <[email protected]> Date: Fri Jan 20 17:30:03 2023 +0400 Merge branch 'master' into 5117-dns64 commit 42aa42a8149b6bb42eb0da6e88ede4b5065bbf2f Author: Eugene Burkov <[email protected]> Date: Fri Jan 20 17:26:54 2023 +0400 dnsforward: imp test commit 4e91c675703f1453456ef9eea08157009ce6237a Author: Eugene Burkov <[email protected]> Date: Wed Jan 18 12:32:55 2023 +0400 dnsforward: imp code, docs, add test commit 766ef757f61e7a555b8151b4783fa7aba5f566f7 Author: Eugene Burkov <[email protected]> Date: Tue Jan 17 16:36:35 2023 +0400 dnsforward: imp docs commit 6825f372389988597d1879cf66342c410f3cfd47 Author: Eugene Burkov <[email protected]> Date: Tue Jan 17 14:33:33 2023 +0400 internal: imp code, docs commit 1215316a338496b5bea2b20d697c7451bfbcc84b Author: Eugene Burkov <[email protected]> Date: Fri Jan 13 21:24:50 2023 +0400 all: add dns64 support
https://github.com/AdguardTeam/AdGuardHome/commit/2ecf2a4c42fbd7ea61573d35271ee65f335c7c4f
internal/dnsforward/dns.go
} resp.Answer = append(resp.Answer, a) } dctx.proxyCtx.Res = resp return resultCodeSuccess
</s> remove if q.Qtype == dns.TypeA { </s> add switch q.Qtype { case dns.TypeA: </s> remove // processDetermineLocal determines if the client's IP address is from // locally-served network and saves the result into the context. </s> add // processDetermineLocal determines if the client's IP address is from locally // served network and saves the result into the context. </s> remove if !s.privateNets.Contains(ip) { return resultCodeSuccess } </s> add </s> remove // assume that all the DHCP leases we give are locally-served or at least // don't need to be accessible externally. </s> add // assume that all the DHCP leases we give are locally served or at least // shouldn't be accessible externally.
case dns.TypeAAAA: if len(s.dns64Prefs) > 0 { // Respond with DNS64-mapped address for IPv4 host if DNS64 is // enabled. aaaa := &dns.AAAA{ Hdr: s.hdr(req, dns.TypeAAAA), AAAA: s.mapDNS64(ip), } resp.Answer = append(resp.Answer, aaaa) } default: // Go on.
} resp.Answer = append(resp.Answer, a) case dns.TypeAAAA: if len(s.dns64Prefs) > 0 { // Respond with DNS64-mapped address for IPv4 host if DNS64 is // enabled. aaaa := &dns.AAAA{ Hdr: s.hdr(req, dns.TypeAAAA), AAAA: s.mapDNS64(ip), } resp.Answer = append(resp.Answer, aaaa) } default: // Go on. } dctx.proxyCtx.Res = resp return resultCodeSuccess
[ "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
Pull request: 5117-dns64 Merge in DNS/adguard-home from 5117-dns64 to master Updates #5117. Squashed commit of the following: commit 757d689134b85bdac9a6f5e43249866ec09ab7e3 Author: Eugene Burkov <[email protected]> Date: Mon Jan 23 19:06:18 2023 +0300 all: imp fmt commit b7a73c68c0b40bd3bda520c045c8110975c1827a Author: Eugene Burkov <[email protected]> Date: Mon Jan 23 17:49:21 2023 +0300 all: rm unused, imp code commit 548feb6bd27b9774a9453d0570d37cdf557d4c3a Merge: de3e84b5 54a141ab Author: Eugene Burkov <[email protected]> Date: Mon Jan 23 14:08:12 2023 +0300 Merge branch 'master' into 5117-dns64 commit de3e84b52b8dbff70df3ca0ac3315c3d33576334 Author: Eugene Burkov <[email protected]> Date: Mon Jan 23 12:04:48 2023 +0300 dnsforward: imp code commit a580e92119e3dbadc8b1a6572dbecc679f69db40 Author: Eugene Burkov <[email protected]> Date: Fri Jan 20 18:24:33 2023 +0400 dnsforward: try again commit 67b7a365194939fe15e4907a3dc2fee44b019d08 Author: Eugene Burkov <[email protected]> Date: Fri Jan 20 18:08:23 2023 +0400 dnsforward: fix test on linux commit ca83e4178a3383e326bf528d209d8766fb3c60d3 Author: Eugene Burkov <[email protected]> Date: Fri Jan 20 17:37:48 2023 +0400 dnsforward: imp naming commit c4e477c7a12af4966cbcd4e5f003a72966dc5d61 Merge: 42aa42a8 6e803375 Author: Eugene Burkov <[email protected]> Date: Fri Jan 20 17:30:03 2023 +0400 Merge branch 'master' into 5117-dns64 commit 42aa42a8149b6bb42eb0da6e88ede4b5065bbf2f Author: Eugene Burkov <[email protected]> Date: Fri Jan 20 17:26:54 2023 +0400 dnsforward: imp test commit 4e91c675703f1453456ef9eea08157009ce6237a Author: Eugene Burkov <[email protected]> Date: Wed Jan 18 12:32:55 2023 +0400 dnsforward: imp code, docs, add test commit 766ef757f61e7a555b8151b4783fa7aba5f566f7 Author: Eugene Burkov <[email protected]> Date: Tue Jan 17 16:36:35 2023 +0400 dnsforward: imp docs commit 6825f372389988597d1879cf66342c410f3cfd47 Author: Eugene Burkov <[email protected]> Date: Tue Jan 17 14:33:33 2023 +0400 internal: imp code, docs commit 1215316a338496b5bea2b20d697c7451bfbcc84b Author: Eugene Burkov <[email protected]> Date: Fri Jan 13 21:24:50 2023 +0400 all: add dns64 support
https://github.com/AdguardTeam/AdGuardHome/commit/2ecf2a4c42fbd7ea61573d35271ee65f335c7c4f
internal/dnsforward/dns.go
return resultCodeSuccess } // processRestrictLocal responds with NXDOMAIN to PTR requests for IP addresses // in locally-served network from external clients. func (s *Server) processRestrictLocal(dctx *dnsContext) (rc resultCode) { pctx := dctx.proxyCtx req := pctx.Req q := req.Question[0] if q.Qtype != dns.TypePTR {
</s> remove // the server. </s> add // the server. It responds with a mapped IP address if the DNS64 is enabled and // the request is for AAAA. </s> remove // processRecursion checks the incoming request and halts it's handling if s // have tried to resolve it recently. </s> add // processRecursion checks the incoming request and halts its handling by // answering NXDOMAIN if s has tried to resolve it recently. </s> remove // processDetermineLocal determines if the client's IP address is from // locally-served network and saves the result into the context. </s> add // processDetermineLocal determines if the client's IP address is from locally // served network and saves the result into the context. </s> remove log.Debug("dnsforward: addr %s is not from locally-served network", ip) </s> add </s> remove // TODO(a.garipov): Remove once we switch to netip.Addr more fully. </s> add // TODO(a.garipov): Remove once we switch to [netip.Addr] more fully.
// in locally served network from external clients.
return resultCodeSuccess } // processRestrictLocal responds with NXDOMAIN to PTR requests for IP addresses // in locally served network from external clients. func (s *Server) processRestrictLocal(dctx *dnsContext) (rc resultCode) { pctx := dctx.proxyCtx req := pctx.Req q := req.Question[0] if q.Qtype != dns.TypePTR {
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: 5117-dns64 Merge in DNS/adguard-home from 5117-dns64 to master Updates #5117. Squashed commit of the following: commit 757d689134b85bdac9a6f5e43249866ec09ab7e3 Author: Eugene Burkov <[email protected]> Date: Mon Jan 23 19:06:18 2023 +0300 all: imp fmt commit b7a73c68c0b40bd3bda520c045c8110975c1827a Author: Eugene Burkov <[email protected]> Date: Mon Jan 23 17:49:21 2023 +0300 all: rm unused, imp code commit 548feb6bd27b9774a9453d0570d37cdf557d4c3a Merge: de3e84b5 54a141ab Author: Eugene Burkov <[email protected]> Date: Mon Jan 23 14:08:12 2023 +0300 Merge branch 'master' into 5117-dns64 commit de3e84b52b8dbff70df3ca0ac3315c3d33576334 Author: Eugene Burkov <[email protected]> Date: Mon Jan 23 12:04:48 2023 +0300 dnsforward: imp code commit a580e92119e3dbadc8b1a6572dbecc679f69db40 Author: Eugene Burkov <[email protected]> Date: Fri Jan 20 18:24:33 2023 +0400 dnsforward: try again commit 67b7a365194939fe15e4907a3dc2fee44b019d08 Author: Eugene Burkov <[email protected]> Date: Fri Jan 20 18:08:23 2023 +0400 dnsforward: fix test on linux commit ca83e4178a3383e326bf528d209d8766fb3c60d3 Author: Eugene Burkov <[email protected]> Date: Fri Jan 20 17:37:48 2023 +0400 dnsforward: imp naming commit c4e477c7a12af4966cbcd4e5f003a72966dc5d61 Merge: 42aa42a8 6e803375 Author: Eugene Burkov <[email protected]> Date: Fri Jan 20 17:30:03 2023 +0400 Merge branch 'master' into 5117-dns64 commit 42aa42a8149b6bb42eb0da6e88ede4b5065bbf2f Author: Eugene Burkov <[email protected]> Date: Fri Jan 20 17:26:54 2023 +0400 dnsforward: imp test commit 4e91c675703f1453456ef9eea08157009ce6237a Author: Eugene Burkov <[email protected]> Date: Wed Jan 18 12:32:55 2023 +0400 dnsforward: imp code, docs, add test commit 766ef757f61e7a555b8151b4783fa7aba5f566f7 Author: Eugene Burkov <[email protected]> Date: Tue Jan 17 16:36:35 2023 +0400 dnsforward: imp docs commit 6825f372389988597d1879cf66342c410f3cfd47 Author: Eugene Burkov <[email protected]> Date: Tue Jan 17 14:33:33 2023 +0400 internal: imp code, docs commit 1215316a338496b5bea2b20d697c7451bfbcc84b Author: Eugene Burkov <[email protected]> Date: Fri Jan 13 21:24:50 2023 +0400 all: add dns64 support
https://github.com/AdguardTeam/AdGuardHome/commit/2ecf2a4c42fbd7ea61573d35271ee65f335c7c4f
internal/dnsforward/dns.go
} // Restrict an access to local addresses for external clients. We also // assume that all the DHCP leases we give are locally served or at least // shouldn't be accessible externally. if !s.privateNets.Contains(ip) { return resultCodeSuccess }
</s> remove // assume that all the DHCP leases we give are locally-served or at least // don't need to be accessible externally. </s> add // assume that all the DHCP leases we give are locally served or at least // shouldn't be accessible externally. </s> remove log.Debug("dnsforward: addr %s is not from locally-served network", ip) </s> add </s> remove // in locally-served network from external clients. </s> add // in locally served network from external clients. </s> remove // TODO(a.garipov): Remove once we switch to netip.Addr more fully. </s> add // TODO(a.garipov): Remove once we switch to [netip.Addr] more fully. </s> remove // processDetermineLocal determines if the client's IP address is from // locally-served network and saves the result into the context. </s> add // processDetermineLocal determines if the client's IP address is from locally // served network and saves the result into the context.
if s.shouldStripDNS64(ip) { // Strip the prefix from the address to get the original IPv4. ip = ip[nat64PrefixLen:] // Treat a DNS64-prefixed address as a locally served one since those // queries should never be sent to the global DNS. dctx.unreversedReqIP = ip }
} if s.shouldStripDNS64(ip) { // Strip the prefix from the address to get the original IPv4. ip = ip[nat64PrefixLen:] // Treat a DNS64-prefixed address as a locally served one since those // queries should never be sent to the global DNS. dctx.unreversedReqIP = ip } // Restrict an access to local addresses for external clients. We also // assume that all the DHCP leases we give are locally served or at least // shouldn't be accessible externally. if !s.privateNets.Contains(ip) { return resultCodeSuccess }
[ "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
Pull request: 5117-dns64 Merge in DNS/adguard-home from 5117-dns64 to master Updates #5117. Squashed commit of the following: commit 757d689134b85bdac9a6f5e43249866ec09ab7e3 Author: Eugene Burkov <[email protected]> Date: Mon Jan 23 19:06:18 2023 +0300 all: imp fmt commit b7a73c68c0b40bd3bda520c045c8110975c1827a Author: Eugene Burkov <[email protected]> Date: Mon Jan 23 17:49:21 2023 +0300 all: rm unused, imp code commit 548feb6bd27b9774a9453d0570d37cdf557d4c3a Merge: de3e84b5 54a141ab Author: Eugene Burkov <[email protected]> Date: Mon Jan 23 14:08:12 2023 +0300 Merge branch 'master' into 5117-dns64 commit de3e84b52b8dbff70df3ca0ac3315c3d33576334 Author: Eugene Burkov <[email protected]> Date: Mon Jan 23 12:04:48 2023 +0300 dnsforward: imp code commit a580e92119e3dbadc8b1a6572dbecc679f69db40 Author: Eugene Burkov <[email protected]> Date: Fri Jan 20 18:24:33 2023 +0400 dnsforward: try again commit 67b7a365194939fe15e4907a3dc2fee44b019d08 Author: Eugene Burkov <[email protected]> Date: Fri Jan 20 18:08:23 2023 +0400 dnsforward: fix test on linux commit ca83e4178a3383e326bf528d209d8766fb3c60d3 Author: Eugene Burkov <[email protected]> Date: Fri Jan 20 17:37:48 2023 +0400 dnsforward: imp naming commit c4e477c7a12af4966cbcd4e5f003a72966dc5d61 Merge: 42aa42a8 6e803375 Author: Eugene Burkov <[email protected]> Date: Fri Jan 20 17:30:03 2023 +0400 Merge branch 'master' into 5117-dns64 commit 42aa42a8149b6bb42eb0da6e88ede4b5065bbf2f Author: Eugene Burkov <[email protected]> Date: Fri Jan 20 17:26:54 2023 +0400 dnsforward: imp test commit 4e91c675703f1453456ef9eea08157009ce6237a Author: Eugene Burkov <[email protected]> Date: Wed Jan 18 12:32:55 2023 +0400 dnsforward: imp code, docs, add test commit 766ef757f61e7a555b8151b4783fa7aba5f566f7 Author: Eugene Burkov <[email protected]> Date: Tue Jan 17 16:36:35 2023 +0400 dnsforward: imp docs commit 6825f372389988597d1879cf66342c410f3cfd47 Author: Eugene Burkov <[email protected]> Date: Tue Jan 17 14:33:33 2023 +0400 internal: imp code, docs commit 1215316a338496b5bea2b20d697c7451bfbcc84b Author: Eugene Burkov <[email protected]> Date: Fri Jan 13 21:24:50 2023 +0400 all: add dns64 support
https://github.com/AdguardTeam/AdGuardHome/commit/2ecf2a4c42fbd7ea61573d35271ee65f335c7c4f
internal/dnsforward/dns.go
return resultCodeSuccess } // Restrict an access to local addresses for external clients. We also // assume that all the DHCP leases we give are locally-served or at least // don't need to be accessible externally. if !s.privateNets.Contains(ip) { log.Debug("dnsforward: addr %s is not from locally-served network", ip) return resultCodeSuccess }
</s> remove log.Debug("dnsforward: addr %s is not from locally-served network", ip) </s> add </s> remove // in locally-served network from external clients. </s> add // in locally served network from external clients. </s> remove // TODO(a.garipov): Remove once we switch to netip.Addr more fully. </s> add // TODO(a.garipov): Remove once we switch to [netip.Addr] more fully.
// assume that all the DHCP leases we give are locally served or at least // shouldn't be accessible externally.
return resultCodeSuccess } // Restrict an access to local addresses for external clients. We also // assume that all the DHCP leases we give are locally served or at least // shouldn't be accessible externally. // assume that all the DHCP leases we give are locally served or at least // shouldn't be accessible externally. if !s.privateNets.Contains(ip) { log.Debug("dnsforward: addr %s is not from locally-served network", ip) return resultCodeSuccess }
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: 5117-dns64 Merge in DNS/adguard-home from 5117-dns64 to master Updates #5117. Squashed commit of the following: commit 757d689134b85bdac9a6f5e43249866ec09ab7e3 Author: Eugene Burkov <[email protected]> Date: Mon Jan 23 19:06:18 2023 +0300 all: imp fmt commit b7a73c68c0b40bd3bda520c045c8110975c1827a Author: Eugene Burkov <[email protected]> Date: Mon Jan 23 17:49:21 2023 +0300 all: rm unused, imp code commit 548feb6bd27b9774a9453d0570d37cdf557d4c3a Merge: de3e84b5 54a141ab Author: Eugene Burkov <[email protected]> Date: Mon Jan 23 14:08:12 2023 +0300 Merge branch 'master' into 5117-dns64 commit de3e84b52b8dbff70df3ca0ac3315c3d33576334 Author: Eugene Burkov <[email protected]> Date: Mon Jan 23 12:04:48 2023 +0300 dnsforward: imp code commit a580e92119e3dbadc8b1a6572dbecc679f69db40 Author: Eugene Burkov <[email protected]> Date: Fri Jan 20 18:24:33 2023 +0400 dnsforward: try again commit 67b7a365194939fe15e4907a3dc2fee44b019d08 Author: Eugene Burkov <[email protected]> Date: Fri Jan 20 18:08:23 2023 +0400 dnsforward: fix test on linux commit ca83e4178a3383e326bf528d209d8766fb3c60d3 Author: Eugene Burkov <[email protected]> Date: Fri Jan 20 17:37:48 2023 +0400 dnsforward: imp naming commit c4e477c7a12af4966cbcd4e5f003a72966dc5d61 Merge: 42aa42a8 6e803375 Author: Eugene Burkov <[email protected]> Date: Fri Jan 20 17:30:03 2023 +0400 Merge branch 'master' into 5117-dns64 commit 42aa42a8149b6bb42eb0da6e88ede4b5065bbf2f Author: Eugene Burkov <[email protected]> Date: Fri Jan 20 17:26:54 2023 +0400 dnsforward: imp test commit 4e91c675703f1453456ef9eea08157009ce6237a Author: Eugene Burkov <[email protected]> Date: Wed Jan 18 12:32:55 2023 +0400 dnsforward: imp code, docs, add test commit 766ef757f61e7a555b8151b4783fa7aba5f566f7 Author: Eugene Burkov <[email protected]> Date: Tue Jan 17 16:36:35 2023 +0400 dnsforward: imp docs commit 6825f372389988597d1879cf66342c410f3cfd47 Author: Eugene Burkov <[email protected]> Date: Tue Jan 17 14:33:33 2023 +0400 internal: imp code, docs commit 1215316a338496b5bea2b20d697c7451bfbcc84b Author: Eugene Burkov <[email protected]> Date: Fri Jan 13 21:24:50 2023 +0400 all: add dns64 support
https://github.com/AdguardTeam/AdGuardHome/commit/2ecf2a4c42fbd7ea61573d35271ee65f335c7c4f
internal/dnsforward/dns.go
// Restrict an access to local addresses for external clients. We also // assume that all the DHCP leases we give are locally-served or at least // don't need to be accessible externally. if !s.privateNets.Contains(ip) { log.Debug("dnsforward: addr %s is not from locally-served network", ip) return resultCodeSuccess } if !dctx.isLocalClient { log.Debug("dnsforward: %q requests an internal ip", pctx.Addr)
</s> remove // assume that all the DHCP leases we give are locally-served or at least // don't need to be accessible externally. </s> add // assume that all the DHCP leases we give are locally served or at least // shouldn't be accessible externally. </s> remove // in locally-served network from external clients. </s> add // in locally served network from external clients. </s> remove // TODO(a.garipov): Remove once we switch to netip.Addr more fully. </s> add // TODO(a.garipov): Remove once we switch to [netip.Addr] more fully.
// Restrict an access to local addresses for external clients. We also // assume that all the DHCP leases we give are locally-served or at least // don't need to be accessible externally. if !s.privateNets.Contains(ip) { return resultCodeSuccess } if !dctx.isLocalClient { log.Debug("dnsforward: %q requests an internal ip", pctx.Addr)
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: 5117-dns64 Merge in DNS/adguard-home from 5117-dns64 to master Updates #5117. Squashed commit of the following: commit 757d689134b85bdac9a6f5e43249866ec09ab7e3 Author: Eugene Burkov <[email protected]> Date: Mon Jan 23 19:06:18 2023 +0300 all: imp fmt commit b7a73c68c0b40bd3bda520c045c8110975c1827a Author: Eugene Burkov <[email protected]> Date: Mon Jan 23 17:49:21 2023 +0300 all: rm unused, imp code commit 548feb6bd27b9774a9453d0570d37cdf557d4c3a Merge: de3e84b5 54a141ab Author: Eugene Burkov <[email protected]> Date: Mon Jan 23 14:08:12 2023 +0300 Merge branch 'master' into 5117-dns64 commit de3e84b52b8dbff70df3ca0ac3315c3d33576334 Author: Eugene Burkov <[email protected]> Date: Mon Jan 23 12:04:48 2023 +0300 dnsforward: imp code commit a580e92119e3dbadc8b1a6572dbecc679f69db40 Author: Eugene Burkov <[email protected]> Date: Fri Jan 20 18:24:33 2023 +0400 dnsforward: try again commit 67b7a365194939fe15e4907a3dc2fee44b019d08 Author: Eugene Burkov <[email protected]> Date: Fri Jan 20 18:08:23 2023 +0400 dnsforward: fix test on linux commit ca83e4178a3383e326bf528d209d8766fb3c60d3 Author: Eugene Burkov <[email protected]> Date: Fri Jan 20 17:37:48 2023 +0400 dnsforward: imp naming commit c4e477c7a12af4966cbcd4e5f003a72966dc5d61 Merge: 42aa42a8 6e803375 Author: Eugene Burkov <[email protected]> Date: Fri Jan 20 17:30:03 2023 +0400 Merge branch 'master' into 5117-dns64 commit 42aa42a8149b6bb42eb0da6e88ede4b5065bbf2f Author: Eugene Burkov <[email protected]> Date: Fri Jan 20 17:26:54 2023 +0400 dnsforward: imp test commit 4e91c675703f1453456ef9eea08157009ce6237a Author: Eugene Burkov <[email protected]> Date: Wed Jan 18 12:32:55 2023 +0400 dnsforward: imp code, docs, add test commit 766ef757f61e7a555b8151b4783fa7aba5f566f7 Author: Eugene Burkov <[email protected]> Date: Tue Jan 17 16:36:35 2023 +0400 dnsforward: imp docs commit 6825f372389988597d1879cf66342c410f3cfd47 Author: Eugene Burkov <[email protected]> Date: Tue Jan 17 14:33:33 2023 +0400 internal: imp code, docs commit 1215316a338496b5bea2b20d697c7451bfbcc84b Author: Eugene Burkov <[email protected]> Date: Fri Jan 13 21:24:50 2023 +0400 all: add dns64 support
https://github.com/AdguardTeam/AdGuardHome/commit/2ecf2a4c42fbd7ea61573d35271ee65f335c7c4f
internal/dnsforward/dns.go
} if !dctx.isLocalClient { log.Debug("dnsforward: %q requests an internal ip", pctx.Addr) pctx.Res = s.genNXDomain(req)
</s> remove log.Debug("dnsforward: addr %s is not from locally-served network", ip) </s> add </s> remove if q.Qtype == dns.TypeA { </s> add switch q.Qtype { case dns.TypeA: </s> remove // assume that all the DHCP leases we give are locally-served or at least // don't need to be accessible externally. </s> add // assume that all the DHCP leases we give are locally served or at least // shouldn't be accessible externally. </s> remove // TODO(a.garipov): Remove once we switch to netip.Addr more fully. </s> add // TODO(a.garipov): Remove once we switch to [netip.Addr] more fully. </s> remove if req.AuthenticatedData { origReqAD = true } else { </s> add origReqAD = req.AuthenticatedData if !req.AuthenticatedData {
log.Debug("dnsforward: addr %s is from locally served network", ip)
} log.Debug("dnsforward: addr %s is from locally served network", ip) if !dctx.isLocalClient { log.Debug("dnsforward: %q requests an internal ip", pctx.Addr) pctx.Res = s.genNXDomain(req)
[ "keep", "add", "keep", "keep", "keep", "keep" ]
Pull request: 5117-dns64 Merge in DNS/adguard-home from 5117-dns64 to master Updates #5117. Squashed commit of the following: commit 757d689134b85bdac9a6f5e43249866ec09ab7e3 Author: Eugene Burkov <[email protected]> Date: Mon Jan 23 19:06:18 2023 +0300 all: imp fmt commit b7a73c68c0b40bd3bda520c045c8110975c1827a Author: Eugene Burkov <[email protected]> Date: Mon Jan 23 17:49:21 2023 +0300 all: rm unused, imp code commit 548feb6bd27b9774a9453d0570d37cdf557d4c3a Merge: de3e84b5 54a141ab Author: Eugene Burkov <[email protected]> Date: Mon Jan 23 14:08:12 2023 +0300 Merge branch 'master' into 5117-dns64 commit de3e84b52b8dbff70df3ca0ac3315c3d33576334 Author: Eugene Burkov <[email protected]> Date: Mon Jan 23 12:04:48 2023 +0300 dnsforward: imp code commit a580e92119e3dbadc8b1a6572dbecc679f69db40 Author: Eugene Burkov <[email protected]> Date: Fri Jan 20 18:24:33 2023 +0400 dnsforward: try again commit 67b7a365194939fe15e4907a3dc2fee44b019d08 Author: Eugene Burkov <[email protected]> Date: Fri Jan 20 18:08:23 2023 +0400 dnsforward: fix test on linux commit ca83e4178a3383e326bf528d209d8766fb3c60d3 Author: Eugene Burkov <[email protected]> Date: Fri Jan 20 17:37:48 2023 +0400 dnsforward: imp naming commit c4e477c7a12af4966cbcd4e5f003a72966dc5d61 Merge: 42aa42a8 6e803375 Author: Eugene Burkov <[email protected]> Date: Fri Jan 20 17:30:03 2023 +0400 Merge branch 'master' into 5117-dns64 commit 42aa42a8149b6bb42eb0da6e88ede4b5065bbf2f Author: Eugene Burkov <[email protected]> Date: Fri Jan 20 17:26:54 2023 +0400 dnsforward: imp test commit 4e91c675703f1453456ef9eea08157009ce6237a Author: Eugene Burkov <[email protected]> Date: Wed Jan 18 12:32:55 2023 +0400 dnsforward: imp code, docs, add test commit 766ef757f61e7a555b8151b4783fa7aba5f566f7 Author: Eugene Burkov <[email protected]> Date: Tue Jan 17 16:36:35 2023 +0400 dnsforward: imp docs commit 6825f372389988597d1879cf66342c410f3cfd47 Author: Eugene Burkov <[email protected]> Date: Tue Jan 17 14:33:33 2023 +0400 internal: imp code, docs commit 1215316a338496b5bea2b20d697c7451bfbcc84b Author: Eugene Burkov <[email protected]> Date: Fri Jan 13 21:24:50 2023 +0400 all: add dns64 support
https://github.com/AdguardTeam/AdGuardHome/commit/2ecf2a4c42fbd7ea61573d35271ee65f335c7c4f
internal/dnsforward/dns.go
// Do not perform unreversing ever again. dctx.unreversedReqIP = ip // There is no need to filter request from external addresses since this // code is only executed when the request is for locally-served ARPA // hostname so disable redundant filters. dctx.setts.ParentalEnabled = false dctx.setts.SafeBrowsingEnabled = false dctx.setts.SafeSearchEnabled = false dctx.setts.ServicesRules = nil
</s> remove if req.AuthenticatedData { origReqAD = true } else { </s> add origReqAD = req.AuthenticatedData if !req.AuthenticatedData { </s> remove // unreversedReqIP stores an IP address obtained from PTR request if it // parsed successfully and belongs to one of locally-served IP ranges as per // RFC 6303. </s> add // unreversedReqIP stores an IP address obtained from a PTR request if it // was parsed successfully and belongs to one of the locally served IP // ranges. It is also filled with unmapped version of the address if it's // within DNS64 prefixes. </s> remove // the server. </s> add // the server. It responds with a mapped IP address if the DNS64 is enabled and // the request is for AAAA.
// code is only executed when the request is for locally served ARPA
// Do not perform unreversing ever again. dctx.unreversedReqIP = ip // There is no need to filter request from external addresses since this // code is only executed when the request is for locally served ARPA // hostname so disable redundant filters. dctx.setts.ParentalEnabled = false dctx.setts.SafeBrowsingEnabled = false dctx.setts.SafeSearchEnabled = false dctx.setts.ServicesRules = nil
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: 5117-dns64 Merge in DNS/adguard-home from 5117-dns64 to master Updates #5117. Squashed commit of the following: commit 757d689134b85bdac9a6f5e43249866ec09ab7e3 Author: Eugene Burkov <[email protected]> Date: Mon Jan 23 19:06:18 2023 +0300 all: imp fmt commit b7a73c68c0b40bd3bda520c045c8110975c1827a Author: Eugene Burkov <[email protected]> Date: Mon Jan 23 17:49:21 2023 +0300 all: rm unused, imp code commit 548feb6bd27b9774a9453d0570d37cdf557d4c3a Merge: de3e84b5 54a141ab Author: Eugene Burkov <[email protected]> Date: Mon Jan 23 14:08:12 2023 +0300 Merge branch 'master' into 5117-dns64 commit de3e84b52b8dbff70df3ca0ac3315c3d33576334 Author: Eugene Burkov <[email protected]> Date: Mon Jan 23 12:04:48 2023 +0300 dnsforward: imp code commit a580e92119e3dbadc8b1a6572dbecc679f69db40 Author: Eugene Burkov <[email protected]> Date: Fri Jan 20 18:24:33 2023 +0400 dnsforward: try again commit 67b7a365194939fe15e4907a3dc2fee44b019d08 Author: Eugene Burkov <[email protected]> Date: Fri Jan 20 18:08:23 2023 +0400 dnsforward: fix test on linux commit ca83e4178a3383e326bf528d209d8766fb3c60d3 Author: Eugene Burkov <[email protected]> Date: Fri Jan 20 17:37:48 2023 +0400 dnsforward: imp naming commit c4e477c7a12af4966cbcd4e5f003a72966dc5d61 Merge: 42aa42a8 6e803375 Author: Eugene Burkov <[email protected]> Date: Fri Jan 20 17:30:03 2023 +0400 Merge branch 'master' into 5117-dns64 commit 42aa42a8149b6bb42eb0da6e88ede4b5065bbf2f Author: Eugene Burkov <[email protected]> Date: Fri Jan 20 17:26:54 2023 +0400 dnsforward: imp test commit 4e91c675703f1453456ef9eea08157009ce6237a Author: Eugene Burkov <[email protected]> Date: Wed Jan 18 12:32:55 2023 +0400 dnsforward: imp code, docs, add test commit 766ef757f61e7a555b8151b4783fa7aba5f566f7 Author: Eugene Burkov <[email protected]> Date: Tue Jan 17 16:36:35 2023 +0400 dnsforward: imp docs commit 6825f372389988597d1879cf66342c410f3cfd47 Author: Eugene Burkov <[email protected]> Date: Tue Jan 17 14:33:33 2023 +0400 internal: imp code, docs commit 1215316a338496b5bea2b20d697c7451bfbcc84b Author: Eugene Burkov <[email protected]> Date: Fri Jan 13 21:24:50 2023 +0400 all: add dns64 support
https://github.com/AdguardTeam/AdGuardHome/commit/2ecf2a4c42fbd7ea61573d35271ee65f335c7c4f
internal/dnsforward/dns.go
if ip == nil { return resultCodeSuccess } // TODO(a.garipov): Remove once we switch to netip.Addr more fully. ipAddr, err := netutil.IPToAddrNoMapped(ip) if err != nil { log.Debug("dnsforward: bad reverse ip %v from dhcp: %s", ip, err) return resultCodeSuccess
</s> remove if !webRegistered && s.conf.HTTPRegister != nil { webRegistered = true s.registerHandlers() </s> add s.registerHandlers() err = s.setupDNS64() if err != nil { return fmt.Errorf("preparing DNS64: %w", err) </s> remove if !s.privateNets.Contains(ip) { return resultCodeSuccess } </s> add </s> remove // processDetermineLocal determines if the client's IP address is from // locally-served network and saves the result into the context. </s> add // processDetermineLocal determines if the client's IP address is from locally // served network and saves the result into the context. </s> remove if q.Qtype == dns.TypeA { </s> add switch q.Qtype { case dns.TypeA:
// TODO(a.garipov): Remove once we switch to [netip.Addr] more fully.
if ip == nil { return resultCodeSuccess } // TODO(a.garipov): Remove once we switch to [netip.Addr] more fully. ipAddr, err := netutil.IPToAddrNoMapped(ip) if err != nil { log.Debug("dnsforward: bad reverse ip %v from dhcp: %s", ip, err) return resultCodeSuccess
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: 5117-dns64 Merge in DNS/adguard-home from 5117-dns64 to master Updates #5117. Squashed commit of the following: commit 757d689134b85bdac9a6f5e43249866ec09ab7e3 Author: Eugene Burkov <[email protected]> Date: Mon Jan 23 19:06:18 2023 +0300 all: imp fmt commit b7a73c68c0b40bd3bda520c045c8110975c1827a Author: Eugene Burkov <[email protected]> Date: Mon Jan 23 17:49:21 2023 +0300 all: rm unused, imp code commit 548feb6bd27b9774a9453d0570d37cdf557d4c3a Merge: de3e84b5 54a141ab Author: Eugene Burkov <[email protected]> Date: Mon Jan 23 14:08:12 2023 +0300 Merge branch 'master' into 5117-dns64 commit de3e84b52b8dbff70df3ca0ac3315c3d33576334 Author: Eugene Burkov <[email protected]> Date: Mon Jan 23 12:04:48 2023 +0300 dnsforward: imp code commit a580e92119e3dbadc8b1a6572dbecc679f69db40 Author: Eugene Burkov <[email protected]> Date: Fri Jan 20 18:24:33 2023 +0400 dnsforward: try again commit 67b7a365194939fe15e4907a3dc2fee44b019d08 Author: Eugene Burkov <[email protected]> Date: Fri Jan 20 18:08:23 2023 +0400 dnsforward: fix test on linux commit ca83e4178a3383e326bf528d209d8766fb3c60d3 Author: Eugene Burkov <[email protected]> Date: Fri Jan 20 17:37:48 2023 +0400 dnsforward: imp naming commit c4e477c7a12af4966cbcd4e5f003a72966dc5d61 Merge: 42aa42a8 6e803375 Author: Eugene Burkov <[email protected]> Date: Fri Jan 20 17:30:03 2023 +0400 Merge branch 'master' into 5117-dns64 commit 42aa42a8149b6bb42eb0da6e88ede4b5065bbf2f Author: Eugene Burkov <[email protected]> Date: Fri Jan 20 17:26:54 2023 +0400 dnsforward: imp test commit 4e91c675703f1453456ef9eea08157009ce6237a Author: Eugene Burkov <[email protected]> Date: Wed Jan 18 12:32:55 2023 +0400 dnsforward: imp code, docs, add test commit 766ef757f61e7a555b8151b4783fa7aba5f566f7 Author: Eugene Burkov <[email protected]> Date: Tue Jan 17 16:36:35 2023 +0400 dnsforward: imp docs commit 6825f372389988597d1879cf66342c410f3cfd47 Author: Eugene Burkov <[email protected]> Date: Tue Jan 17 14:33:33 2023 +0400 internal: imp code, docs commit 1215316a338496b5bea2b20d697c7451bfbcc84b Author: Eugene Burkov <[email protected]> Date: Fri Jan 13 21:24:50 2023 +0400 all: add dns64 support
https://github.com/AdguardTeam/AdGuardHome/commit/2ecf2a4c42fbd7ea61573d35271ee65f335c7c4f
internal/dnsforward/dns.go
s.serverLock.RLock() defer s.serverLock.RUnlock() if !s.privateNets.Contains(ip) { return resultCodeSuccess } if s.conf.UsePrivateRDNS { s.recDetector.add(*pctx.Req) if err := s.localResolvers.Resolve(pctx); err != nil { dctx.err = err
</s> remove if !webRegistered && s.conf.HTTPRegister != nil { webRegistered = true s.registerHandlers() </s> add s.registerHandlers() err = s.setupDNS64() if err != nil { return fmt.Errorf("preparing DNS64: %w", err) </s> remove // TODO(a.garipov): Remove once we switch to netip.Addr more fully. </s> add // TODO(a.garipov): Remove once we switch to [netip.Addr] more fully. </s> remove // processRecursion checks the incoming request and halts it's handling if s // have tried to resolve it recently. </s> add // processRecursion checks the incoming request and halts its handling by // answering NXDOMAIN if s has tried to resolve it recently. </s> remove // in locally-served network from external clients. </s> add // in locally served network from external clients. </s> remove if req.AuthenticatedData { origReqAD = true } else { </s> add origReqAD = req.AuthenticatedData if !req.AuthenticatedData {
s.serverLock.RLock() defer s.serverLock.RUnlock() if s.conf.UsePrivateRDNS { s.recDetector.add(*pctx.Req) if err := s.localResolvers.Resolve(pctx); err != nil { dctx.err = err
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: 5117-dns64 Merge in DNS/adguard-home from 5117-dns64 to master Updates #5117. Squashed commit of the following: commit 757d689134b85bdac9a6f5e43249866ec09ab7e3 Author: Eugene Burkov <[email protected]> Date: Mon Jan 23 19:06:18 2023 +0300 all: imp fmt commit b7a73c68c0b40bd3bda520c045c8110975c1827a Author: Eugene Burkov <[email protected]> Date: Mon Jan 23 17:49:21 2023 +0300 all: rm unused, imp code commit 548feb6bd27b9774a9453d0570d37cdf557d4c3a Merge: de3e84b5 54a141ab Author: Eugene Burkov <[email protected]> Date: Mon Jan 23 14:08:12 2023 +0300 Merge branch 'master' into 5117-dns64 commit de3e84b52b8dbff70df3ca0ac3315c3d33576334 Author: Eugene Burkov <[email protected]> Date: Mon Jan 23 12:04:48 2023 +0300 dnsforward: imp code commit a580e92119e3dbadc8b1a6572dbecc679f69db40 Author: Eugene Burkov <[email protected]> Date: Fri Jan 20 18:24:33 2023 +0400 dnsforward: try again commit 67b7a365194939fe15e4907a3dc2fee44b019d08 Author: Eugene Burkov <[email protected]> Date: Fri Jan 20 18:08:23 2023 +0400 dnsforward: fix test on linux commit ca83e4178a3383e326bf528d209d8766fb3c60d3 Author: Eugene Burkov <[email protected]> Date: Fri Jan 20 17:37:48 2023 +0400 dnsforward: imp naming commit c4e477c7a12af4966cbcd4e5f003a72966dc5d61 Merge: 42aa42a8 6e803375 Author: Eugene Burkov <[email protected]> Date: Fri Jan 20 17:30:03 2023 +0400 Merge branch 'master' into 5117-dns64 commit 42aa42a8149b6bb42eb0da6e88ede4b5065bbf2f Author: Eugene Burkov <[email protected]> Date: Fri Jan 20 17:26:54 2023 +0400 dnsforward: imp test commit 4e91c675703f1453456ef9eea08157009ce6237a Author: Eugene Burkov <[email protected]> Date: Wed Jan 18 12:32:55 2023 +0400 dnsforward: imp code, docs, add test commit 766ef757f61e7a555b8151b4783fa7aba5f566f7 Author: Eugene Burkov <[email protected]> Date: Tue Jan 17 16:36:35 2023 +0400 dnsforward: imp docs commit 6825f372389988597d1879cf66342c410f3cfd47 Author: Eugene Burkov <[email protected]> Date: Tue Jan 17 14:33:33 2023 +0400 internal: imp code, docs commit 1215316a338496b5bea2b20d697c7451bfbcc84b Author: Eugene Burkov <[email protected]> Date: Fri Jan 13 21:24:50 2023 +0400 all: add dns64 support
https://github.com/AdguardTeam/AdGuardHome/commit/2ecf2a4c42fbd7ea61573d35271ee65f335c7c4f
internal/dnsforward/dns.go
s.setCustomUpstream(pctx, dctx.clientID) origReqAD := false if s.conf.EnableDNSSEC { if req.AuthenticatedData { origReqAD = true } else { req.AuthenticatedData = true } } // Process the request further since it wasn't filtered.
</s> remove // processRecursion checks the incoming request and halts it's handling if s // have tried to resolve it recently. </s> add // processRecursion checks the incoming request and halts its handling by // answering NXDOMAIN if s has tried to resolve it recently. </s> remove if !webRegistered && s.conf.HTTPRegister != nil { webRegistered = true s.registerHandlers() </s> add s.registerHandlers() err = s.setupDNS64() if err != nil { return fmt.Errorf("preparing DNS64: %w", err) </s> remove if !s.privateNets.Contains(ip) { return resultCodeSuccess } </s> add
origReqAD = req.AuthenticatedData if !req.AuthenticatedData {
s.setCustomUpstream(pctx, dctx.clientID) origReqAD := false if s.conf.EnableDNSSEC { origReqAD = req.AuthenticatedData if !req.AuthenticatedData { origReqAD = req.AuthenticatedData if !req.AuthenticatedData { origReqAD = req.AuthenticatedData if !req.AuthenticatedData { req.AuthenticatedData = true } } // Process the request further since it wasn't filtered.
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: 5117-dns64 Merge in DNS/adguard-home from 5117-dns64 to master Updates #5117. Squashed commit of the following: commit 757d689134b85bdac9a6f5e43249866ec09ab7e3 Author: Eugene Burkov <[email protected]> Date: Mon Jan 23 19:06:18 2023 +0300 all: imp fmt commit b7a73c68c0b40bd3bda520c045c8110975c1827a Author: Eugene Burkov <[email protected]> Date: Mon Jan 23 17:49:21 2023 +0300 all: rm unused, imp code commit 548feb6bd27b9774a9453d0570d37cdf557d4c3a Merge: de3e84b5 54a141ab Author: Eugene Burkov <[email protected]> Date: Mon Jan 23 14:08:12 2023 +0300 Merge branch 'master' into 5117-dns64 commit de3e84b52b8dbff70df3ca0ac3315c3d33576334 Author: Eugene Burkov <[email protected]> Date: Mon Jan 23 12:04:48 2023 +0300 dnsforward: imp code commit a580e92119e3dbadc8b1a6572dbecc679f69db40 Author: Eugene Burkov <[email protected]> Date: Fri Jan 20 18:24:33 2023 +0400 dnsforward: try again commit 67b7a365194939fe15e4907a3dc2fee44b019d08 Author: Eugene Burkov <[email protected]> Date: Fri Jan 20 18:08:23 2023 +0400 dnsforward: fix test on linux commit ca83e4178a3383e326bf528d209d8766fb3c60d3 Author: Eugene Burkov <[email protected]> Date: Fri Jan 20 17:37:48 2023 +0400 dnsforward: imp naming commit c4e477c7a12af4966cbcd4e5f003a72966dc5d61 Merge: 42aa42a8 6e803375 Author: Eugene Burkov <[email protected]> Date: Fri Jan 20 17:30:03 2023 +0400 Merge branch 'master' into 5117-dns64 commit 42aa42a8149b6bb42eb0da6e88ede4b5065bbf2f Author: Eugene Burkov <[email protected]> Date: Fri Jan 20 17:26:54 2023 +0400 dnsforward: imp test commit 4e91c675703f1453456ef9eea08157009ce6237a Author: Eugene Burkov <[email protected]> Date: Wed Jan 18 12:32:55 2023 +0400 dnsforward: imp code, docs, add test commit 766ef757f61e7a555b8151b4783fa7aba5f566f7 Author: Eugene Burkov <[email protected]> Date: Tue Jan 17 16:36:35 2023 +0400 dnsforward: imp docs commit 6825f372389988597d1879cf66342c410f3cfd47 Author: Eugene Burkov <[email protected]> Date: Tue Jan 17 14:33:33 2023 +0400 internal: imp code, docs commit 1215316a338496b5bea2b20d697c7451bfbcc84b Author: Eugene Burkov <[email protected]> Date: Fri Jan 13 21:24:50 2023 +0400 all: add dns64 support
https://github.com/AdguardTeam/AdGuardHome/commit/2ecf2a4c42fbd7ea61573d35271ee65f335c7c4f
internal/dnsforward/dns.go
return resultCodeError } dctx.responseFromUpstream = true dctx.responseAD = pctx.Res.AuthenticatedData if s.conf.EnableDNSSEC && !origReqAD {
</s> remove if req.AuthenticatedData { origReqAD = true } else { </s> add origReqAD = req.AuthenticatedData if !req.AuthenticatedData { </s> remove if !webRegistered && s.conf.HTTPRegister != nil { webRegistered = true s.registerHandlers() </s> add s.registerHandlers() err = s.setupDNS64() if err != nil { return fmt.Errorf("preparing DNS64: %w", err) </s> remove // processRecursion checks the incoming request and halts it's handling if s // have tried to resolve it recently. </s> add // processRecursion checks the incoming request and halts its handling by // answering NXDOMAIN if s has tried to resolve it recently. </s> remove if !s.privateNets.Contains(ip) { return resultCodeSuccess } </s> add
if s.performDNS64(prx, dctx) == resultCodeError { return resultCodeError }
return resultCodeError } if s.performDNS64(prx, dctx) == resultCodeError { return resultCodeError } dctx.responseFromUpstream = true dctx.responseAD = pctx.Res.AuthenticatedData if s.conf.EnableDNSSEC && !origReqAD {
[ "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
Pull request: 5117-dns64 Merge in DNS/adguard-home from 5117-dns64 to master Updates #5117. Squashed commit of the following: commit 757d689134b85bdac9a6f5e43249866ec09ab7e3 Author: Eugene Burkov <[email protected]> Date: Mon Jan 23 19:06:18 2023 +0300 all: imp fmt commit b7a73c68c0b40bd3bda520c045c8110975c1827a Author: Eugene Burkov <[email protected]> Date: Mon Jan 23 17:49:21 2023 +0300 all: rm unused, imp code commit 548feb6bd27b9774a9453d0570d37cdf557d4c3a Merge: de3e84b5 54a141ab Author: Eugene Burkov <[email protected]> Date: Mon Jan 23 14:08:12 2023 +0300 Merge branch 'master' into 5117-dns64 commit de3e84b52b8dbff70df3ca0ac3315c3d33576334 Author: Eugene Burkov <[email protected]> Date: Mon Jan 23 12:04:48 2023 +0300 dnsforward: imp code commit a580e92119e3dbadc8b1a6572dbecc679f69db40 Author: Eugene Burkov <[email protected]> Date: Fri Jan 20 18:24:33 2023 +0400 dnsforward: try again commit 67b7a365194939fe15e4907a3dc2fee44b019d08 Author: Eugene Burkov <[email protected]> Date: Fri Jan 20 18:08:23 2023 +0400 dnsforward: fix test on linux commit ca83e4178a3383e326bf528d209d8766fb3c60d3 Author: Eugene Burkov <[email protected]> Date: Fri Jan 20 17:37:48 2023 +0400 dnsforward: imp naming commit c4e477c7a12af4966cbcd4e5f003a72966dc5d61 Merge: 42aa42a8 6e803375 Author: Eugene Burkov <[email protected]> Date: Fri Jan 20 17:30:03 2023 +0400 Merge branch 'master' into 5117-dns64 commit 42aa42a8149b6bb42eb0da6e88ede4b5065bbf2f Author: Eugene Burkov <[email protected]> Date: Fri Jan 20 17:26:54 2023 +0400 dnsforward: imp test commit 4e91c675703f1453456ef9eea08157009ce6237a Author: Eugene Burkov <[email protected]> Date: Wed Jan 18 12:32:55 2023 +0400 dnsforward: imp code, docs, add test commit 766ef757f61e7a555b8151b4783fa7aba5f566f7 Author: Eugene Burkov <[email protected]> Date: Tue Jan 17 16:36:35 2023 +0400 dnsforward: imp docs commit 6825f372389988597d1879cf66342c410f3cfd47 Author: Eugene Burkov <[email protected]> Date: Tue Jan 17 14:33:33 2023 +0400 internal: imp code, docs commit 1215316a338496b5bea2b20d697c7451bfbcc84b Author: Eugene Burkov <[email protected]> Date: Fri Jan 13 21:24:50 2023 +0400 all: add dns64 support
https://github.com/AdguardTeam/AdGuardHome/commit/2ecf2a4c42fbd7ea61573d35271ee65f335c7c4f
internal/dnsforward/dns.go
localResolvers *proxy.Proxy sysResolvers aghnet.SystemResolvers recDetector *recursionDetector // anonymizer masks the client's IP addresses if needed. anonymizer *aghnet.IPMut tableHostToIP hostToIPTable
</s> remove // isLocalClient shows if client's IP address is from locally-served </s> add // isLocalClient shows if client's IP address is from locally served </s> remove // processDetermineLocal determines if the client's IP address is from // locally-served network and saves the result into the context. </s> add // processDetermineLocal determines if the client's IP address is from locally // served network and saves the result into the context. </s> remove // unreversedReqIP stores an IP address obtained from PTR request if it // parsed successfully and belongs to one of locally-served IP ranges as per // RFC 6303. </s> add // unreversedReqIP stores an IP address obtained from a PTR request if it // was parsed successfully and belongs to one of the locally served IP // ranges. It is also filled with unmapped version of the address if it's // within DNS64 prefixes. </s> remove // the server. </s> add // the server. It responds with a mapped IP address if the DNS64 is enabled and // the request is for AAAA.
// dns64Prefix is the set of NAT64 prefixes used for DNS64 handling. dns64Prefs []netip.Prefix
localResolvers *proxy.Proxy sysResolvers aghnet.SystemResolvers recDetector *recursionDetector // dns64Prefix is the set of NAT64 prefixes used for DNS64 handling. dns64Prefs []netip.Prefix // anonymizer masks the client's IP addresses if needed. anonymizer *aghnet.IPMut tableHostToIP hostToIPTable
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
Pull request: 5117-dns64 Merge in DNS/adguard-home from 5117-dns64 to master Updates #5117. Squashed commit of the following: commit 757d689134b85bdac9a6f5e43249866ec09ab7e3 Author: Eugene Burkov <[email protected]> Date: Mon Jan 23 19:06:18 2023 +0300 all: imp fmt commit b7a73c68c0b40bd3bda520c045c8110975c1827a Author: Eugene Burkov <[email protected]> Date: Mon Jan 23 17:49:21 2023 +0300 all: rm unused, imp code commit 548feb6bd27b9774a9453d0570d37cdf557d4c3a Merge: de3e84b5 54a141ab Author: Eugene Burkov <[email protected]> Date: Mon Jan 23 14:08:12 2023 +0300 Merge branch 'master' into 5117-dns64 commit de3e84b52b8dbff70df3ca0ac3315c3d33576334 Author: Eugene Burkov <[email protected]> Date: Mon Jan 23 12:04:48 2023 +0300 dnsforward: imp code commit a580e92119e3dbadc8b1a6572dbecc679f69db40 Author: Eugene Burkov <[email protected]> Date: Fri Jan 20 18:24:33 2023 +0400 dnsforward: try again commit 67b7a365194939fe15e4907a3dc2fee44b019d08 Author: Eugene Burkov <[email protected]> Date: Fri Jan 20 18:08:23 2023 +0400 dnsforward: fix test on linux commit ca83e4178a3383e326bf528d209d8766fb3c60d3 Author: Eugene Burkov <[email protected]> Date: Fri Jan 20 17:37:48 2023 +0400 dnsforward: imp naming commit c4e477c7a12af4966cbcd4e5f003a72966dc5d61 Merge: 42aa42a8 6e803375 Author: Eugene Burkov <[email protected]> Date: Fri Jan 20 17:30:03 2023 +0400 Merge branch 'master' into 5117-dns64 commit 42aa42a8149b6bb42eb0da6e88ede4b5065bbf2f Author: Eugene Burkov <[email protected]> Date: Fri Jan 20 17:26:54 2023 +0400 dnsforward: imp test commit 4e91c675703f1453456ef9eea08157009ce6237a Author: Eugene Burkov <[email protected]> Date: Wed Jan 18 12:32:55 2023 +0400 dnsforward: imp code, docs, add test commit 766ef757f61e7a555b8151b4783fa7aba5f566f7 Author: Eugene Burkov <[email protected]> Date: Tue Jan 17 16:36:35 2023 +0400 dnsforward: imp docs commit 6825f372389988597d1879cf66342c410f3cfd47 Author: Eugene Burkov <[email protected]> Date: Tue Jan 17 14:33:33 2023 +0400 internal: imp code, docs commit 1215316a338496b5bea2b20d697c7451bfbcc84b Author: Eugene Burkov <[email protected]> Date: Fri Jan 13 21:24:50 2023 +0400 all: add dns64 support
https://github.com/AdguardTeam/AdGuardHome/commit/2ecf2a4c42fbd7ea61573d35271ee65f335c7c4f
internal/dnsforward/dnsforward.go
if err != nil { return fmt.Errorf("preparing access: %w", err) } if !webRegistered && s.conf.HTTPRegister != nil { webRegistered = true s.registerHandlers() } s.dnsProxy = &proxy.Proxy{Config: proxyConfig} err = s.setupResolvers(s.conf.LocalPTRResolvers)
</s> remove if !s.privateNets.Contains(ip) { return resultCodeSuccess } </s> add </s> remove // TODO(a.garipov): Remove once we switch to netip.Addr more fully. </s> add // TODO(a.garipov): Remove once we switch to [netip.Addr] more fully. </s> remove // processRecursion checks the incoming request and halts it's handling if s // have tried to resolve it recently. </s> add // processRecursion checks the incoming request and halts its handling by // answering NXDOMAIN if s has tried to resolve it recently.
s.registerHandlers() err = s.setupDNS64() if err != nil { return fmt.Errorf("preparing DNS64: %w", err)
if err != nil { return fmt.Errorf("preparing access: %w", err) } s.registerHandlers() err = s.setupDNS64() if err != nil { return fmt.Errorf("preparing DNS64: %w", err) s.registerHandlers() err = s.setupDNS64() if err != nil { return fmt.Errorf("preparing DNS64: %w", err) s.registerHandlers() err = s.setupDNS64() if err != nil { return fmt.Errorf("preparing DNS64: %w", err) } s.dnsProxy = &proxy.Proxy{Config: proxyConfig} err = s.setupResolvers(s.conf.LocalPTRResolvers)
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: 5117-dns64 Merge in DNS/adguard-home from 5117-dns64 to master Updates #5117. Squashed commit of the following: commit 757d689134b85bdac9a6f5e43249866ec09ab7e3 Author: Eugene Burkov <[email protected]> Date: Mon Jan 23 19:06:18 2023 +0300 all: imp fmt commit b7a73c68c0b40bd3bda520c045c8110975c1827a Author: Eugene Burkov <[email protected]> Date: Mon Jan 23 17:49:21 2023 +0300 all: rm unused, imp code commit 548feb6bd27b9774a9453d0570d37cdf557d4c3a Merge: de3e84b5 54a141ab Author: Eugene Burkov <[email protected]> Date: Mon Jan 23 14:08:12 2023 +0300 Merge branch 'master' into 5117-dns64 commit de3e84b52b8dbff70df3ca0ac3315c3d33576334 Author: Eugene Burkov <[email protected]> Date: Mon Jan 23 12:04:48 2023 +0300 dnsforward: imp code commit a580e92119e3dbadc8b1a6572dbecc679f69db40 Author: Eugene Burkov <[email protected]> Date: Fri Jan 20 18:24:33 2023 +0400 dnsforward: try again commit 67b7a365194939fe15e4907a3dc2fee44b019d08 Author: Eugene Burkov <[email protected]> Date: Fri Jan 20 18:08:23 2023 +0400 dnsforward: fix test on linux commit ca83e4178a3383e326bf528d209d8766fb3c60d3 Author: Eugene Burkov <[email protected]> Date: Fri Jan 20 17:37:48 2023 +0400 dnsforward: imp naming commit c4e477c7a12af4966cbcd4e5f003a72966dc5d61 Merge: 42aa42a8 6e803375 Author: Eugene Burkov <[email protected]> Date: Fri Jan 20 17:30:03 2023 +0400 Merge branch 'master' into 5117-dns64 commit 42aa42a8149b6bb42eb0da6e88ede4b5065bbf2f Author: Eugene Burkov <[email protected]> Date: Fri Jan 20 17:26:54 2023 +0400 dnsforward: imp test commit 4e91c675703f1453456ef9eea08157009ce6237a Author: Eugene Burkov <[email protected]> Date: Wed Jan 18 12:32:55 2023 +0400 dnsforward: imp code, docs, add test commit 766ef757f61e7a555b8151b4783fa7aba5f566f7 Author: Eugene Burkov <[email protected]> Date: Tue Jan 17 16:36:35 2023 +0400 dnsforward: imp docs commit 6825f372389988597d1879cf66342c410f3cfd47 Author: Eugene Burkov <[email protected]> Date: Tue Jan 17 14:33:33 2023 +0400 internal: imp code, docs commit 1215316a338496b5bea2b20d697c7451bfbcc84b Author: Eugene Burkov <[email protected]> Date: Fri Jan 13 21:24:50 2023 +0400 all: add dns64 support
https://github.com/AdguardTeam/AdGuardHome/commit/2ecf2a4c42fbd7ea61573d35271ee65f335c7c4f
internal/dnsforward/dnsforward.go
s.ServeHTTP(w, r) } func (s *Server) registerHandlers() { s.conf.HTTPRegister(http.MethodGet, "/control/dns_info", s.handleGetConfig) s.conf.HTTPRegister(http.MethodPost, "/control/dns_config", s.handleSetConfig) s.conf.HTTPRegister(http.MethodPost, "/control/test_upstream_dns", s.handleTestUpstreamDNS) s.conf.HTTPRegister(http.MethodGet, "/control/access/list", s.handleAccessList) s.conf.HTTPRegister(http.MethodPost, "/control/access/set", s.handleAccessSet)
</s> remove // in locally-served network from external clients. </s> add // in locally served network from external clients. </s> remove // processDetermineLocal determines if the client's IP address is from // locally-served network and saves the result into the context. </s> add // processDetermineLocal determines if the client's IP address is from locally // served network and saves the result into the context. </s> remove // processRecursion checks the incoming request and halts it's handling if s // have tried to resolve it recently. </s> add // processRecursion checks the incoming request and halts its handling by // answering NXDOMAIN if s has tried to resolve it recently. </s> remove // the server. </s> add // the server. It responds with a mapped IP address if the DNS64 is enabled and // the request is for AAAA. </s> remove if req.AuthenticatedData { origReqAD = true } else { </s> add origReqAD = req.AuthenticatedData if !req.AuthenticatedData {
if webRegistered || s.conf.HTTPRegister == nil { return }
s.ServeHTTP(w, r) } func (s *Server) registerHandlers() { if webRegistered || s.conf.HTTPRegister == nil { return } s.conf.HTTPRegister(http.MethodGet, "/control/dns_info", s.handleGetConfig) s.conf.HTTPRegister(http.MethodPost, "/control/dns_config", s.handleSetConfig) s.conf.HTTPRegister(http.MethodPost, "/control/test_upstream_dns", s.handleTestUpstreamDNS) s.conf.HTTPRegister(http.MethodGet, "/control/access/list", s.handleAccessList) s.conf.HTTPRegister(http.MethodPost, "/control/access/set", s.handleAccessSet)
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
Pull request: 5117-dns64 Merge in DNS/adguard-home from 5117-dns64 to master Updates #5117. Squashed commit of the following: commit 757d689134b85bdac9a6f5e43249866ec09ab7e3 Author: Eugene Burkov <[email protected]> Date: Mon Jan 23 19:06:18 2023 +0300 all: imp fmt commit b7a73c68c0b40bd3bda520c045c8110975c1827a Author: Eugene Burkov <[email protected]> Date: Mon Jan 23 17:49:21 2023 +0300 all: rm unused, imp code commit 548feb6bd27b9774a9453d0570d37cdf557d4c3a Merge: de3e84b5 54a141ab Author: Eugene Burkov <[email protected]> Date: Mon Jan 23 14:08:12 2023 +0300 Merge branch 'master' into 5117-dns64 commit de3e84b52b8dbff70df3ca0ac3315c3d33576334 Author: Eugene Burkov <[email protected]> Date: Mon Jan 23 12:04:48 2023 +0300 dnsforward: imp code commit a580e92119e3dbadc8b1a6572dbecc679f69db40 Author: Eugene Burkov <[email protected]> Date: Fri Jan 20 18:24:33 2023 +0400 dnsforward: try again commit 67b7a365194939fe15e4907a3dc2fee44b019d08 Author: Eugene Burkov <[email protected]> Date: Fri Jan 20 18:08:23 2023 +0400 dnsforward: fix test on linux commit ca83e4178a3383e326bf528d209d8766fb3c60d3 Author: Eugene Burkov <[email protected]> Date: Fri Jan 20 17:37:48 2023 +0400 dnsforward: imp naming commit c4e477c7a12af4966cbcd4e5f003a72966dc5d61 Merge: 42aa42a8 6e803375 Author: Eugene Burkov <[email protected]> Date: Fri Jan 20 17:30:03 2023 +0400 Merge branch 'master' into 5117-dns64 commit 42aa42a8149b6bb42eb0da6e88ede4b5065bbf2f Author: Eugene Burkov <[email protected]> Date: Fri Jan 20 17:26:54 2023 +0400 dnsforward: imp test commit 4e91c675703f1453456ef9eea08157009ce6237a Author: Eugene Burkov <[email protected]> Date: Wed Jan 18 12:32:55 2023 +0400 dnsforward: imp code, docs, add test commit 766ef757f61e7a555b8151b4783fa7aba5f566f7 Author: Eugene Burkov <[email protected]> Date: Tue Jan 17 16:36:35 2023 +0400 dnsforward: imp docs commit 6825f372389988597d1879cf66342c410f3cfd47 Author: Eugene Burkov <[email protected]> Date: Tue Jan 17 14:33:33 2023 +0400 internal: imp code, docs commit 1215316a338496b5bea2b20d697c7451bfbcc84b Author: Eugene Burkov <[email protected]> Date: Fri Jan 13 21:24:50 2023 +0400 all: add dns64 support
https://github.com/AdguardTeam/AdGuardHome/commit/2ecf2a4c42fbd7ea61573d35271ee65f335c7c4f
internal/dnsforward/http.go
// See also https://github.com/AdguardTeam/AdGuardHome/issues/2628. s.conf.HTTPRegister("", "/dns-query", s.handleDoH) s.conf.HTTPRegister("", "/dns-query/", s.handleDoH) }
</s> remove // assume that all the DHCP leases we give are locally-served or at least // don't need to be accessible externally. </s> add // assume that all the DHCP leases we give are locally served or at least // shouldn't be accessible externally. </s> remove log.Debug("dnsforward: addr %s is not from locally-served network", ip) </s> add </s> remove // unreversedReqIP stores an IP address obtained from PTR request if it // parsed successfully and belongs to one of locally-served IP ranges as per // RFC 6303. </s> add // unreversedReqIP stores an IP address obtained from a PTR request if it // was parsed successfully and belongs to one of the locally served IP // ranges. It is also filled with unmapped version of the address if it's // within DNS64 prefixes.
webRegistered = true
// See also https://github.com/AdguardTeam/AdGuardHome/issues/2628. s.conf.HTTPRegister("", "/dns-query", s.handleDoH) s.conf.HTTPRegister("", "/dns-query/", s.handleDoH) webRegistered = true }
[ "keep", "keep", "add", "keep" ]
Pull request: 5117-dns64 Merge in DNS/adguard-home from 5117-dns64 to master Updates #5117. Squashed commit of the following: commit 757d689134b85bdac9a6f5e43249866ec09ab7e3 Author: Eugene Burkov <[email protected]> Date: Mon Jan 23 19:06:18 2023 +0300 all: imp fmt commit b7a73c68c0b40bd3bda520c045c8110975c1827a Author: Eugene Burkov <[email protected]> Date: Mon Jan 23 17:49:21 2023 +0300 all: rm unused, imp code commit 548feb6bd27b9774a9453d0570d37cdf557d4c3a Merge: de3e84b5 54a141ab Author: Eugene Burkov <[email protected]> Date: Mon Jan 23 14:08:12 2023 +0300 Merge branch 'master' into 5117-dns64 commit de3e84b52b8dbff70df3ca0ac3315c3d33576334 Author: Eugene Burkov <[email protected]> Date: Mon Jan 23 12:04:48 2023 +0300 dnsforward: imp code commit a580e92119e3dbadc8b1a6572dbecc679f69db40 Author: Eugene Burkov <[email protected]> Date: Fri Jan 20 18:24:33 2023 +0400 dnsforward: try again commit 67b7a365194939fe15e4907a3dc2fee44b019d08 Author: Eugene Burkov <[email protected]> Date: Fri Jan 20 18:08:23 2023 +0400 dnsforward: fix test on linux commit ca83e4178a3383e326bf528d209d8766fb3c60d3 Author: Eugene Burkov <[email protected]> Date: Fri Jan 20 17:37:48 2023 +0400 dnsforward: imp naming commit c4e477c7a12af4966cbcd4e5f003a72966dc5d61 Merge: 42aa42a8 6e803375 Author: Eugene Burkov <[email protected]> Date: Fri Jan 20 17:30:03 2023 +0400 Merge branch 'master' into 5117-dns64 commit 42aa42a8149b6bb42eb0da6e88ede4b5065bbf2f Author: Eugene Burkov <[email protected]> Date: Fri Jan 20 17:26:54 2023 +0400 dnsforward: imp test commit 4e91c675703f1453456ef9eea08157009ce6237a Author: Eugene Burkov <[email protected]> Date: Wed Jan 18 12:32:55 2023 +0400 dnsforward: imp code, docs, add test commit 766ef757f61e7a555b8151b4783fa7aba5f566f7 Author: Eugene Burkov <[email protected]> Date: Tue Jan 17 16:36:35 2023 +0400 dnsforward: imp docs commit 6825f372389988597d1879cf66342c410f3cfd47 Author: Eugene Burkov <[email protected]> Date: Tue Jan 17 14:33:33 2023 +0400 internal: imp code, docs commit 1215316a338496b5bea2b20d697c7451bfbcc84b Author: Eugene Burkov <[email protected]> Date: Fri Jan 13 21:24:50 2023 +0400 all: add dns64 support
https://github.com/AdguardTeam/AdGuardHome/commit/2ecf2a4c42fbd7ea61573d35271ee65f335c7c4f
internal/dnsforward/http.go
// LocalPTRResolvers is the slice of addresses to be used as upstreams // for PTR queries for locally-served networks. LocalPTRResolvers []string `yaml:"local_ptr_upstreams"` // ServeHTTP3 defines if HTTP/3 is be allowed for incoming requests. // // TODO(a.garipov): Add to the UI when HTTP/3 support is no longer // experimental. ServeHTTP3 bool `yaml:"serve_http3"`
</s> remove // unreversedReqIP stores an IP address obtained from PTR request if it // parsed successfully and belongs to one of locally-served IP ranges as per // RFC 6303. </s> add // unreversedReqIP stores an IP address obtained from a PTR request if it // was parsed successfully and belongs to one of the locally served IP // ranges. It is also filled with unmapped version of the address if it's // within DNS64 prefixes. </s> remove // code is only executed when the request is for locally-served ARPA </s> add // code is only executed when the request is for locally served ARPA </s> remove // isLocalClient shows if client's IP address is from locally-served </s> add // isLocalClient shows if client's IP address is from locally served
// UseDNS64 defines if DNS64 should be used for incoming requests. UseDNS64 bool `yaml:"use_dns64"` // DNS64Prefixes is the list of NAT64 prefixes to be used for DNS64. DNS64Prefixes []string `yaml:"dns64_prefixes"`
// LocalPTRResolvers is the slice of addresses to be used as upstreams // for PTR queries for locally-served networks. LocalPTRResolvers []string `yaml:"local_ptr_upstreams"` // UseDNS64 defines if DNS64 should be used for incoming requests. UseDNS64 bool `yaml:"use_dns64"` // DNS64Prefixes is the list of NAT64 prefixes to be used for DNS64. DNS64Prefixes []string `yaml:"dns64_prefixes"` // ServeHTTP3 defines if HTTP/3 is be allowed for incoming requests. // // TODO(a.garipov): Add to the UI when HTTP/3 support is no longer // experimental. ServeHTTP3 bool `yaml:"serve_http3"`
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
Pull request: 5117-dns64 Merge in DNS/adguard-home from 5117-dns64 to master Updates #5117. Squashed commit of the following: commit 757d689134b85bdac9a6f5e43249866ec09ab7e3 Author: Eugene Burkov <[email protected]> Date: Mon Jan 23 19:06:18 2023 +0300 all: imp fmt commit b7a73c68c0b40bd3bda520c045c8110975c1827a Author: Eugene Burkov <[email protected]> Date: Mon Jan 23 17:49:21 2023 +0300 all: rm unused, imp code commit 548feb6bd27b9774a9453d0570d37cdf557d4c3a Merge: de3e84b5 54a141ab Author: Eugene Burkov <[email protected]> Date: Mon Jan 23 14:08:12 2023 +0300 Merge branch 'master' into 5117-dns64 commit de3e84b52b8dbff70df3ca0ac3315c3d33576334 Author: Eugene Burkov <[email protected]> Date: Mon Jan 23 12:04:48 2023 +0300 dnsforward: imp code commit a580e92119e3dbadc8b1a6572dbecc679f69db40 Author: Eugene Burkov <[email protected]> Date: Fri Jan 20 18:24:33 2023 +0400 dnsforward: try again commit 67b7a365194939fe15e4907a3dc2fee44b019d08 Author: Eugene Burkov <[email protected]> Date: Fri Jan 20 18:08:23 2023 +0400 dnsforward: fix test on linux commit ca83e4178a3383e326bf528d209d8766fb3c60d3 Author: Eugene Burkov <[email protected]> Date: Fri Jan 20 17:37:48 2023 +0400 dnsforward: imp naming commit c4e477c7a12af4966cbcd4e5f003a72966dc5d61 Merge: 42aa42a8 6e803375 Author: Eugene Burkov <[email protected]> Date: Fri Jan 20 17:30:03 2023 +0400 Merge branch 'master' into 5117-dns64 commit 42aa42a8149b6bb42eb0da6e88ede4b5065bbf2f Author: Eugene Burkov <[email protected]> Date: Fri Jan 20 17:26:54 2023 +0400 dnsforward: imp test commit 4e91c675703f1453456ef9eea08157009ce6237a Author: Eugene Burkov <[email protected]> Date: Wed Jan 18 12:32:55 2023 +0400 dnsforward: imp code, docs, add test commit 766ef757f61e7a555b8151b4783fa7aba5f566f7 Author: Eugene Burkov <[email protected]> Date: Tue Jan 17 16:36:35 2023 +0400 dnsforward: imp docs commit 6825f372389988597d1879cf66342c410f3cfd47 Author: Eugene Burkov <[email protected]> Date: Tue Jan 17 14:33:33 2023 +0400 internal: imp code, docs commit 1215316a338496b5bea2b20d697c7451bfbcc84b Author: Eugene Burkov <[email protected]> Date: Fri Jan 13 21:24:50 2023 +0400 all: add dns64 support
https://github.com/AdguardTeam/AdGuardHome/commit/2ecf2a4c42fbd7ea61573d35271ee65f335c7c4f
internal/home/config.go
HTTPRegister: httpReg, OnDNSRequest: onDNSRequest, } if tlsConf.Enabled { newConf.TLSConfig = tlsConf.TLSConfig newConf.TLSConfig.ServerName = tlsConf.ServerName
</s> remove if req.AuthenticatedData { origReqAD = true } else { </s> add origReqAD = req.AuthenticatedData if !req.AuthenticatedData { </s> remove if !s.privateNets.Contains(ip) { return resultCodeSuccess } </s> add </s> remove if !webRegistered && s.conf.HTTPRegister != nil { webRegistered = true s.registerHandlers() </s> add s.registerHandlers() err = s.setupDNS64() if err != nil { return fmt.Errorf("preparing DNS64: %w", err)
UseDNS64: config.DNS.UseDNS64, DNS64Prefixes: config.DNS.DNS64Prefixes,
HTTPRegister: httpReg, OnDNSRequest: onDNSRequest, UseDNS64: config.DNS.UseDNS64, DNS64Prefixes: config.DNS.DNS64Prefixes, } if tlsConf.Enabled { newConf.TLSConfig = tlsConf.TLSConfig newConf.TLSConfig.ServerName = tlsConf.ServerName
[ "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
Pull request: 5117-dns64 Merge in DNS/adguard-home from 5117-dns64 to master Updates #5117. Squashed commit of the following: commit 757d689134b85bdac9a6f5e43249866ec09ab7e3 Author: Eugene Burkov <[email protected]> Date: Mon Jan 23 19:06:18 2023 +0300 all: imp fmt commit b7a73c68c0b40bd3bda520c045c8110975c1827a Author: Eugene Burkov <[email protected]> Date: Mon Jan 23 17:49:21 2023 +0300 all: rm unused, imp code commit 548feb6bd27b9774a9453d0570d37cdf557d4c3a Merge: de3e84b5 54a141ab Author: Eugene Burkov <[email protected]> Date: Mon Jan 23 14:08:12 2023 +0300 Merge branch 'master' into 5117-dns64 commit de3e84b52b8dbff70df3ca0ac3315c3d33576334 Author: Eugene Burkov <[email protected]> Date: Mon Jan 23 12:04:48 2023 +0300 dnsforward: imp code commit a580e92119e3dbadc8b1a6572dbecc679f69db40 Author: Eugene Burkov <[email protected]> Date: Fri Jan 20 18:24:33 2023 +0400 dnsforward: try again commit 67b7a365194939fe15e4907a3dc2fee44b019d08 Author: Eugene Burkov <[email protected]> Date: Fri Jan 20 18:08:23 2023 +0400 dnsforward: fix test on linux commit ca83e4178a3383e326bf528d209d8766fb3c60d3 Author: Eugene Burkov <[email protected]> Date: Fri Jan 20 17:37:48 2023 +0400 dnsforward: imp naming commit c4e477c7a12af4966cbcd4e5f003a72966dc5d61 Merge: 42aa42a8 6e803375 Author: Eugene Burkov <[email protected]> Date: Fri Jan 20 17:30:03 2023 +0400 Merge branch 'master' into 5117-dns64 commit 42aa42a8149b6bb42eb0da6e88ede4b5065bbf2f Author: Eugene Burkov <[email protected]> Date: Fri Jan 20 17:26:54 2023 +0400 dnsforward: imp test commit 4e91c675703f1453456ef9eea08157009ce6237a Author: Eugene Burkov <[email protected]> Date: Wed Jan 18 12:32:55 2023 +0400 dnsforward: imp code, docs, add test commit 766ef757f61e7a555b8151b4783fa7aba5f566f7 Author: Eugene Burkov <[email protected]> Date: Tue Jan 17 16:36:35 2023 +0400 dnsforward: imp docs commit 6825f372389988597d1879cf66342c410f3cfd47 Author: Eugene Burkov <[email protected]> Date: Tue Jan 17 14:33:33 2023 +0400 internal: imp code, docs commit 1215316a338496b5bea2b20d697c7451bfbcc84b Author: Eugene Burkov <[email protected]> Date: Fri Jan 13 21:24:50 2023 +0400 all: add dns64 support
https://github.com/AdguardTeam/AdGuardHome/commit/2ecf2a4c42fbd7ea61573d35271ee65f335c7c4f
internal/home/dns.go
// The syntax of the ipsetConf is: // // DOMAIN[,DOMAIN].../IPSET_NAME[,IPSET_NAME]... // // The error is of type *aghos.UnsupportedError if the OS is not supported. func NewIpsetManager(ipsetConf []string) (mgr IpsetManager, err error) { return newIpsetMgr(ipsetConf) }
</s> remove dial := func(pf netfilter.ProtoFamily, conf *netlink.Config) (conn ipsetConn, err error) { return ipset.Dial(pf, conf) </s> add return newIpsetMgrWithDialer(ipsetConf, defaultDial) } // defaultDial is the default netfilter dialing function. func defaultDial(pf netfilter.ProtoFamily, conf *netlink.Config) (conn ipsetConn, err error) { conn, err = ipset.Dial(pf, conf) if err != nil { return nil, err </s> remove return newIpsetMgrWithDialer(ipsetConf, dial) </s> add return conn, nil </s> remove // ipset cannot currently be initialized if the server was // installed from Snap or when the user or the binary doesn't // have the required permissions, or when the kernel doesn't // support netfilter. </s> add // ipset cannot currently be initialized if the server was installed // from Snap or when the user or the binary doesn't have the required // permissions, or when the kernel doesn't support netfilter.
// If ipsetConf is empty, msg and err are nil. The error is of type // *aghos.UnsupportedError if the OS is not supported.
// The syntax of the ipsetConf is: // // DOMAIN[,DOMAIN].../IPSET_NAME[,IPSET_NAME]... // // If ipsetConf is empty, msg and err are nil. The error is of type // *aghos.UnsupportedError if the OS is not supported. func NewIpsetManager(ipsetConf []string) (mgr IpsetManager, err error) { return newIpsetMgr(ipsetConf) }
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep" ]
Pull request: aghnet: fix ipset init errors Updates #4027. Squashed commit of the following: commit 9ac0cc27ca94e630cc321c90b60b271499af4d9b Author: Ainar Garipov <[email protected]> Date: Mon Dec 27 20:26:22 2021 +0300 aghnet: fix ipset init errors
https://github.com/AdguardTeam/AdGuardHome/commit/2ed1f939b59591335447d8b445c9d3832c772f09
internal/aghnet/ipset.go
// *aghos.UnsupportedError if the OS is not supported. func NewIpsetManager(ipsetConf []string) (mgr IpsetManager, err error) { return newIpsetMgr(ipsetConf) }
</s> remove // The error is of type *aghos.UnsupportedError if the OS is not supported. </s> add // If ipsetConf is empty, msg and err are nil. The error is of type // *aghos.UnsupportedError if the OS is not supported. </s> remove dial := func(pf netfilter.ProtoFamily, conf *netlink.Config) (conn ipsetConn, err error) { return ipset.Dial(pf, conf) </s> add return newIpsetMgrWithDialer(ipsetConf, defaultDial) } // defaultDial is the default netfilter dialing function. func defaultDial(pf netfilter.ProtoFamily, conf *netlink.Config) (conn ipsetConn, err error) { conn, err = ipset.Dial(pf, conf) if err != nil { return nil, err </s> remove return newIpsetMgrWithDialer(ipsetConf, dial) </s> add return conn, nil </s> remove // TODO(a.garipov): Perhaps we can ditch package ipset altogether and // just use packages netfilter and netlink. </s> add // TODO(a.garipov): Perhaps we can ditch package ipset altogether and just // use packages netfilter and netlink.
if len(ipsetConf) == 0 { return nil, nil }
// *aghos.UnsupportedError if the OS is not supported. func NewIpsetManager(ipsetConf []string) (mgr IpsetManager, err error) { if len(ipsetConf) == 0 { return nil, nil } return newIpsetMgr(ipsetConf) }
[ "keep", "add", "keep", "keep" ]
Pull request: aghnet: fix ipset init errors Updates #4027. Squashed commit of the following: commit 9ac0cc27ca94e630cc321c90b60b271499af4d9b Author: Ainar Garipov <[email protected]> Date: Mon Dec 27 20:26:22 2021 +0300 aghnet: fix ipset init errors
https://github.com/AdguardTeam/AdGuardHome/commit/2ed1f939b59591335447d8b445c9d3832c772f09
internal/aghnet/ipset.go
"github.com/digineo/go-ipset/v2" "github.com/mdlayher/netlink" "github.com/ti-mo/netfilter" ) // How to test on a real Linux machine: // // 1. Run:
</s> remove dial := func(pf netfilter.ProtoFamily, conf *netlink.Config) (conn ipsetConn, err error) { return ipset.Dial(pf, conf) </s> add return newIpsetMgrWithDialer(ipsetConf, defaultDial) } // defaultDial is the default netfilter dialing function. func defaultDial(pf netfilter.ProtoFamily, conf *netlink.Config) (conn ipsetConn, err error) { conn, err = ipset.Dial(pf, conf) if err != nil { return nil, err </s> remove // ipset cannot currently be initialized if the server was // installed from Snap or when the user or the binary doesn't // have the required permissions, or when the kernel doesn't // support netfilter. </s> add // ipset cannot currently be initialized if the server was installed // from Snap or when the user or the binary doesn't have the required // permissions, or when the kernel doesn't support netfilter. </s> remove // The error is of type *aghos.UnsupportedError if the OS is not supported. </s> add // If ipsetConf is empty, msg and err are nil. The error is of type // *aghos.UnsupportedError if the OS is not supported. </s> remove // TODO(a.garipov): The Snap problem can probably be solved if // we add the netlink-connector interface plug. log.Info("warning: cannot initialize ipset: %s", err) </s> add // TODO(a.garipov): The Snap problem can probably be solved if we add // the netlink-connector interface plug. log.Info("ipset: warning: cannot initialize: %s", err) </s> remove // TODO(a.garipov): Perhaps we can ditch package ipset altogether and // just use packages netfilter and netlink. </s> add // TODO(a.garipov): Perhaps we can ditch package ipset altogether and just // use packages netfilter and netlink.
"golang.org/x/sys/unix"
"github.com/digineo/go-ipset/v2" "github.com/mdlayher/netlink" "github.com/ti-mo/netfilter" "golang.org/x/sys/unix" ) // How to test on a real Linux machine: // // 1. Run:
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
Pull request: aghnet: fix ipset init errors Updates #4027. Squashed commit of the following: commit 9ac0cc27ca94e630cc321c90b60b271499af4d9b Author: Ainar Garipov <[email protected]> Date: Mon Dec 27 20:26:22 2021 +0300 aghnet: fix ipset init errors
https://github.com/AdguardTeam/AdGuardHome/commit/2ed1f939b59591335447d8b445c9d3832c772f09
internal/aghnet/ipset_linux.go
// The Members field should contain the resolved IP addresses. // newIpsetMgr returns a new Linux ipset manager. func newIpsetMgr(ipsetConf []string) (set IpsetManager, err error) { dial := func(pf netfilter.ProtoFamily, conf *netlink.Config) (conn ipsetConn, err error) { return ipset.Dial(pf, conf) } return newIpsetMgrWithDialer(ipsetConf, dial) }
</s> remove return newIpsetMgrWithDialer(ipsetConf, dial) </s> add return conn, nil </s> remove // The error is of type *aghos.UnsupportedError if the OS is not supported. </s> add // If ipsetConf is empty, msg and err are nil. The error is of type // *aghos.UnsupportedError if the OS is not supported. </s> remove // TODO(a.garipov): Perhaps we can ditch package ipset altogether and // just use packages netfilter and netlink. </s> add // TODO(a.garipov): Perhaps we can ditch package ipset altogether and just // use packages netfilter and netlink.
return newIpsetMgrWithDialer(ipsetConf, defaultDial) } // defaultDial is the default netfilter dialing function. func defaultDial(pf netfilter.ProtoFamily, conf *netlink.Config) (conn ipsetConn, err error) { conn, err = ipset.Dial(pf, conf) if err != nil { return nil, err
// The Members field should contain the resolved IP addresses. // newIpsetMgr returns a new Linux ipset manager. func newIpsetMgr(ipsetConf []string) (set IpsetManager, err error) { return newIpsetMgrWithDialer(ipsetConf, defaultDial) } // defaultDial is the default netfilter dialing function. func defaultDial(pf netfilter.ProtoFamily, conf *netlink.Config) (conn ipsetConn, err error) { conn, err = ipset.Dial(pf, conf) if err != nil { return nil, err return newIpsetMgrWithDialer(ipsetConf, defaultDial) } // defaultDial is the default netfilter dialing function. func defaultDial(pf netfilter.ProtoFamily, conf *netlink.Config) (conn ipsetConn, err error) { conn, err = ipset.Dial(pf, conf) if err != nil { return nil, err } return newIpsetMgrWithDialer(ipsetConf, dial) }
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: aghnet: fix ipset init errors Updates #4027. Squashed commit of the following: commit 9ac0cc27ca94e630cc321c90b60b271499af4d9b Author: Ainar Garipov <[email protected]> Date: Mon Dec 27 20:26:22 2021 +0300 aghnet: fix ipset init errors
https://github.com/AdguardTeam/AdGuardHome/commit/2ed1f939b59591335447d8b445c9d3832c772f09
internal/aghnet/ipset_linux.go
dial := func(pf netfilter.ProtoFamily, conf *netlink.Config) (conn ipsetConn, err error) { return ipset.Dial(pf, conf) } return newIpsetMgrWithDialer(ipsetConf, dial) } // ipsetConn is the ipset conn interface. type ipsetConn interface { Add(name string, entries ...*ipset.Entry) (err error)
</s> remove dial := func(pf netfilter.ProtoFamily, conf *netlink.Config) (conn ipsetConn, err error) { return ipset.Dial(pf, conf) </s> add return newIpsetMgrWithDialer(ipsetConf, defaultDial) } // defaultDial is the default netfilter dialing function. func defaultDial(pf netfilter.ProtoFamily, conf *netlink.Config) (conn ipsetConn, err error) { conn, err = ipset.Dial(pf, conf) if err != nil { return nil, err </s> remove // The error is of type *aghos.UnsupportedError if the OS is not supported. </s> add // If ipsetConf is empty, msg and err are nil. The error is of type // *aghos.UnsupportedError if the OS is not supported. </s> remove // TODO(a.garipov): Perhaps we can ditch package ipset altogether and // just use packages netfilter and netlink. </s> add // TODO(a.garipov): Perhaps we can ditch package ipset altogether and just // use packages netfilter and netlink. </s> remove // ipset cannot currently be initialized if the server was // installed from Snap or when the user or the binary doesn't // have the required permissions, or when the kernel doesn't // support netfilter. </s> add // ipset cannot currently be initialized if the server was installed // from Snap or when the user or the binary doesn't have the required // permissions, or when the kernel doesn't support netfilter.
return conn, nil
dial := func(pf netfilter.ProtoFamily, conf *netlink.Config) (conn ipsetConn, err error) { return ipset.Dial(pf, conf) } return conn, nil } // ipsetConn is the ipset conn interface. type ipsetConn interface { Add(name string, entries ...*ipset.Entry) (err error)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: aghnet: fix ipset init errors Updates #4027. Squashed commit of the following: commit 9ac0cc27ca94e630cc321c90b60b271499af4d9b Author: Ainar Garipov <[email protected]> Date: Mon Dec 27 20:26:22 2021 +0300 aghnet: fix ipset init errors
https://github.com/AdguardTeam/AdGuardHome/commit/2ed1f939b59591335447d8b445c9d3832c772f09
internal/aghnet/ipset_linux.go
func (m *ipsetMgr) dialNetfilter(conf *netlink.Config) (err error) { // The kernel API does not actually require two sockets but package // github.com/digineo/go-ipset does. // // TODO(a.garipov): Perhaps we can ditch package ipset altogether and // just use packages netfilter and netlink. m.ipv4Conn, err = m.dial(netfilter.ProtoIPv4, conf) if err != nil { return fmt.Errorf("dialing v4: %w", err) }
</s> remove dial := func(pf netfilter.ProtoFamily, conf *netlink.Config) (conn ipsetConn, err error) { return ipset.Dial(pf, conf) </s> add return newIpsetMgrWithDialer(ipsetConf, defaultDial) } // defaultDial is the default netfilter dialing function. func defaultDial(pf netfilter.ProtoFamily, conf *netlink.Config) (conn ipsetConn, err error) { conn, err = ipset.Dial(pf, conf) if err != nil { return nil, err </s> remove // ipset cannot currently be initialized if the server was // installed from Snap or when the user or the binary doesn't // have the required permissions, or when the kernel doesn't // support netfilter. </s> add // ipset cannot currently be initialized if the server was installed // from Snap or when the user or the binary doesn't have the required // permissions, or when the kernel doesn't support netfilter. </s> remove // TODO(a.garipov): The Snap problem can probably be solved if // we add the netlink-connector interface plug. log.Info("warning: cannot initialize ipset: %s", err) </s> add // TODO(a.garipov): The Snap problem can probably be solved if we add // the netlink-connector interface plug. log.Info("ipset: warning: cannot initialize: %s", err) </s> remove return newIpsetMgrWithDialer(ipsetConf, dial) </s> add return conn, nil
// TODO(a.garipov): Perhaps we can ditch package ipset altogether and just // use packages netfilter and netlink.
func (m *ipsetMgr) dialNetfilter(conf *netlink.Config) (err error) { // The kernel API does not actually require two sockets but package // github.com/digineo/go-ipset does. // // TODO(a.garipov): Perhaps we can ditch package ipset altogether and just // use packages netfilter and netlink. // TODO(a.garipov): Perhaps we can ditch package ipset altogether and just // use packages netfilter and netlink. m.ipv4Conn, err = m.dial(netfilter.ProtoIPv4, conf) if err != nil { return fmt.Errorf("dialing v4: %w", err) }
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: aghnet: fix ipset init errors Updates #4027. Squashed commit of the following: commit 9ac0cc27ca94e630cc321c90b60b271499af4d9b Author: Ainar Garipov <[email protected]> Date: Mon Dec 27 20:26:22 2021 +0300 aghnet: fix ipset init errors
https://github.com/AdguardTeam/AdGuardHome/commit/2ed1f939b59591335447d8b445c9d3832c772f09
internal/aghnet/ipset_linux.go
err = m.dialNetfilter(&netlink.Config{}) if err != nil { return nil, fmt.Errorf("dialing netfilter: %w", err) } for i, confStr := range ipsetConf { var hosts, ipsetNames []string
</s> remove log.Info("warning: %s", err) </s> add log.Info("ipset: warning: %s", err) </s> remove // TODO(a.garipov): Perhaps we can ditch package ipset altogether and // just use packages netfilter and netlink. </s> add // TODO(a.garipov): Perhaps we can ditch package ipset altogether and just // use packages netfilter and netlink. </s> remove dial := func(pf netfilter.ProtoFamily, conf *netlink.Config) (conn ipsetConn, err error) { return ipset.Dial(pf, conf) </s> add return newIpsetMgrWithDialer(ipsetConf, defaultDial) } // defaultDial is the default netfilter dialing function. func defaultDial(pf netfilter.ProtoFamily, conf *netlink.Config) (conn ipsetConn, err error) { conn, err = ipset.Dial(pf, conf) if err != nil { return nil, err </s> remove // The error is of type *aghos.UnsupportedError if the OS is not supported. </s> add // If ipsetConf is empty, msg and err are nil. The error is of type // *aghos.UnsupportedError if the OS is not supported.
if errors.Is(err, unix.EPROTONOSUPPORT) { // The implementation doesn't support this protocol version. Just // issue a warning. log.Info("ipset: dialing netfilter: warning: %s", err) return nil, nil }
err = m.dialNetfilter(&netlink.Config{}) if err != nil { if errors.Is(err, unix.EPROTONOSUPPORT) { // The implementation doesn't support this protocol version. Just // issue a warning. log.Info("ipset: dialing netfilter: warning: %s", err) return nil, nil } return nil, fmt.Errorf("dialing netfilter: %w", err) } for i, confStr := range ipsetConf { var hosts, ipsetNames []string
[ "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
Pull request: aghnet: fix ipset init errors Updates #4027. Squashed commit of the following: commit 9ac0cc27ca94e630cc321c90b60b271499af4d9b Author: Ainar Garipov <[email protected]> Date: Mon Dec 27 20:26:22 2021 +0300 aghnet: fix ipset init errors
https://github.com/AdguardTeam/AdGuardHome/commit/2ed1f939b59591335447d8b445c9d3832c772f09
internal/aghnet/ipset_linux.go
// TODO(a.garipov): Rewrite into a simple constructor? func (c *ipsetCtx) init(ipsetConf []string) (err error) { c.ipsetMgr, err = aghnet.NewIpsetManager(ipsetConf) if errors.Is(err, os.ErrInvalid) || errors.Is(err, os.ErrPermission) { // ipset cannot currently be initialized if the server was // installed from Snap or when the user or the binary doesn't // have the required permissions, or when the kernel doesn't // support netfilter. // // Log and go on. // // TODO(a.garipov): The Snap problem can probably be solved if // we add the netlink-connector interface plug.
</s> remove // TODO(a.garipov): The Snap problem can probably be solved if // we add the netlink-connector interface plug. log.Info("warning: cannot initialize ipset: %s", err) </s> add // TODO(a.garipov): The Snap problem can probably be solved if we add // the netlink-connector interface plug. log.Info("ipset: warning: cannot initialize: %s", err) </s> remove // TODO(a.garipov): Perhaps we can ditch package ipset altogether and // just use packages netfilter and netlink. </s> add // TODO(a.garipov): Perhaps we can ditch package ipset altogether and just // use packages netfilter and netlink. </s> remove // The error is of type *aghos.UnsupportedError if the OS is not supported. </s> add // If ipsetConf is empty, msg and err are nil. The error is of type // *aghos.UnsupportedError if the OS is not supported. </s> remove dial := func(pf netfilter.ProtoFamily, conf *netlink.Config) (conn ipsetConn, err error) { return ipset.Dial(pf, conf) </s> add return newIpsetMgrWithDialer(ipsetConf, defaultDial) } // defaultDial is the default netfilter dialing function. func defaultDial(pf netfilter.ProtoFamily, conf *netlink.Config) (conn ipsetConn, err error) { conn, err = ipset.Dial(pf, conf) if err != nil { return nil, err
// ipset cannot currently be initialized if the server was installed // from Snap or when the user or the binary doesn't have the required // permissions, or when the kernel doesn't support netfilter.
// TODO(a.garipov): Rewrite into a simple constructor? func (c *ipsetCtx) init(ipsetConf []string) (err error) { c.ipsetMgr, err = aghnet.NewIpsetManager(ipsetConf) if errors.Is(err, os.ErrInvalid) || errors.Is(err, os.ErrPermission) { // ipset cannot currently be initialized if the server was installed // from Snap or when the user or the binary doesn't have the required // permissions, or when the kernel doesn't support netfilter. // ipset cannot currently be initialized if the server was installed // from Snap or when the user or the binary doesn't have the required // permissions, or when the kernel doesn't support netfilter. // ipset cannot currently be initialized if the server was installed // from Snap or when the user or the binary doesn't have the required // permissions, or when the kernel doesn't support netfilter. // ipset cannot currently be initialized if the server was installed // from Snap or when the user or the binary doesn't have the required // permissions, or when the kernel doesn't support netfilter. // // Log and go on. // // TODO(a.garipov): The Snap problem can probably be solved if // we add the netlink-connector interface plug.
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: aghnet: fix ipset init errors Updates #4027. Squashed commit of the following: commit 9ac0cc27ca94e630cc321c90b60b271499af4d9b Author: Ainar Garipov <[email protected]> Date: Mon Dec 27 20:26:22 2021 +0300 aghnet: fix ipset init errors
https://github.com/AdguardTeam/AdGuardHome/commit/2ed1f939b59591335447d8b445c9d3832c772f09
internal/dnsforward/ipset.go
// support netfilter. // // Log and go on. // // TODO(a.garipov): The Snap problem can probably be solved if // we add the netlink-connector interface plug. log.Info("warning: cannot initialize ipset: %s", err) return nil } else if unsupErr := (&aghos.UnsupportedError{}); errors.As(err, &unsupErr) { log.Info("warning: %s", err)
</s> remove log.Info("warning: %s", err) </s> add log.Info("ipset: warning: %s", err) </s> remove // ipset cannot currently be initialized if the server was // installed from Snap or when the user or the binary doesn't // have the required permissions, or when the kernel doesn't // support netfilter. </s> add // ipset cannot currently be initialized if the server was installed // from Snap or when the user or the binary doesn't have the required // permissions, or when the kernel doesn't support netfilter. </s> remove // TODO(a.garipov): Perhaps we can ditch package ipset altogether and // just use packages netfilter and netlink. </s> add // TODO(a.garipov): Perhaps we can ditch package ipset altogether and just // use packages netfilter and netlink. </s> remove // The error is of type *aghos.UnsupportedError if the OS is not supported. </s> add // If ipsetConf is empty, msg and err are nil. The error is of type // *aghos.UnsupportedError if the OS is not supported.
// TODO(a.garipov): The Snap problem can probably be solved if we add // the netlink-connector interface plug. log.Info("ipset: warning: cannot initialize: %s", err)
// support netfilter. // // Log and go on. // // TODO(a.garipov): The Snap problem can probably be solved if we add // the netlink-connector interface plug. log.Info("ipset: warning: cannot initialize: %s", err) // TODO(a.garipov): The Snap problem can probably be solved if we add // the netlink-connector interface plug. log.Info("ipset: warning: cannot initialize: %s", err) // TODO(a.garipov): The Snap problem can probably be solved if we add // the netlink-connector interface plug. log.Info("ipset: warning: cannot initialize: %s", err) return nil } else if unsupErr := (&aghos.UnsupportedError{}); errors.As(err, &unsupErr) { log.Info("warning: %s", err)
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: aghnet: fix ipset init errors Updates #4027. Squashed commit of the following: commit 9ac0cc27ca94e630cc321c90b60b271499af4d9b Author: Ainar Garipov <[email protected]> Date: Mon Dec 27 20:26:22 2021 +0300 aghnet: fix ipset init errors
https://github.com/AdguardTeam/AdGuardHome/commit/2ed1f939b59591335447d8b445c9d3832c772f09
internal/dnsforward/ipset.go
log.Info("warning: cannot initialize ipset: %s", err) return nil } else if unsupErr := (&aghos.UnsupportedError{}); errors.As(err, &unsupErr) { log.Info("warning: %s", err) return nil } else if err != nil { return fmt.Errorf("initializing ipset: %w", err) }
</s> remove // TODO(a.garipov): The Snap problem can probably be solved if // we add the netlink-connector interface plug. log.Info("warning: cannot initialize ipset: %s", err) </s> add // TODO(a.garipov): The Snap problem can probably be solved if we add // the netlink-connector interface plug. log.Info("ipset: warning: cannot initialize: %s", err) </s> remove dial := func(pf netfilter.ProtoFamily, conf *netlink.Config) (conn ipsetConn, err error) { return ipset.Dial(pf, conf) </s> add return newIpsetMgrWithDialer(ipsetConf, defaultDial) } // defaultDial is the default netfilter dialing function. func defaultDial(pf netfilter.ProtoFamily, conf *netlink.Config) (conn ipsetConn, err error) { conn, err = ipset.Dial(pf, conf) if err != nil { return nil, err </s> remove // TODO(a.garipov): Perhaps we can ditch package ipset altogether and // just use packages netfilter and netlink. </s> add // TODO(a.garipov): Perhaps we can ditch package ipset altogether and just // use packages netfilter and netlink.
log.Info("ipset: warning: %s", err)
log.Info("warning: cannot initialize ipset: %s", err) return nil } else if unsupErr := (&aghos.UnsupportedError{}); errors.As(err, &unsupErr) { log.Info("ipset: warning: %s", err) return nil } else if err != nil { return fmt.Errorf("initializing ipset: %w", err) }
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: aghnet: fix ipset init errors Updates #4027. Squashed commit of the following: commit 9ac0cc27ca94e630cc321c90b60b271499af4d9b Author: Ainar Garipov <[email protected]> Date: Mon Dec 27 20:26:22 2021 +0300 aghnet: fix ipset init errors
https://github.com/AdguardTeam/AdGuardHome/commit/2ed1f939b59591335447d8b445c9d3832c772f09
internal/dnsforward/ipset.go
logBufferCap = 5000 // maximum capacity of buffer before it's flushed to disk queryLogFileName = "querylog.json" // .gz added during compression getDataLimit = 500 // GetData(): maximum log entries to return // maximum data chunks to parse when filtering entries maxFilteringChunks = 10 ) // queryLog is a structure that writes and reads the DNS query log type queryLog struct { conf Config
</s> remove func (r *Reader) BeginRead(olderThan time.Time, count uint64) { </s> add func (r *Reader) BeginRead(olderThan time.Time, count uint64, search *getDataParams) { </s> remove func (l *queryLog) getData(params getDataParams) []map[string]interface{} { </s> add func (l *queryLog) getData(params getDataParams) map[string]interface{} { </s> remove if len(params.Domain) != 0 && params.StrictMatchDomain { params.Domain = params.Domain + "." } </s> add var oldest time.Time </s> remove log.Debug("QueryLog: Failed to decode: %s", err) </s> add log.Debug("QueryLog: failed to decode")
// maximum entries to parse when searching maxSearchEntries = 50000
logBufferCap = 5000 // maximum capacity of buffer before it's flushed to disk queryLogFileName = "querylog.json" // .gz added during compression getDataLimit = 500 // GetData(): maximum log entries to return // maximum entries to parse when searching maxSearchEntries = 50000 // maximum entries to parse when searching maxSearchEntries = 50000 ) // queryLog is a structure that writes and reads the DNS query log type queryLog struct { conf Config
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
* querylog: major refactor: change on-disk format and API speed up decoding speed up search compatible with previous format (when not searching)
https://github.com/AdguardTeam/AdGuardHome/commit/2f5d6593f2d9841f9c18b9ac60a554af60a34a6b
querylog/qlog.go
log.Debug("Query log: cleared") } type logEntry struct { Question []byte Answer []byte `json:",omitempty"` // sometimes empty answers happen like binerdunt.top or rev2.globalrootservers.net Result dnsfilter.Result Time time.Time Elapsed time.Duration IP string
</s> remove Time time.Time </s> add </s> remove IP string </s> add </s> remove QuestionType uint16 // filter by question type </s> add QuestionType string // filter by question type </s> remove return entries, total </s> add return entries, oldest, int(total) </s> remove var q []byte var a []byte var err error ip := getIPString(addr) if question == nil { </s> add if question == nil || len(question.Question) != 1 || len(question.Question[0].Name) == 0 || ip == nil {
IP string `json:"IP"` Time time.Time `json:"T"` QHost string `json:"QH"` QType string `json:"QT"` QClass string `json:"QC"`
log.Debug("Query log: cleared") } type logEntry struct { IP string `json:"IP"` Time time.Time `json:"T"` QHost string `json:"QH"` QType string `json:"QT"` QClass string `json:"QC"` Answer []byte `json:",omitempty"` // sometimes empty answers happen like binerdunt.top or rev2.globalrootservers.net Result dnsfilter.Result Time time.Time Elapsed time.Duration IP string
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
* querylog: major refactor: change on-disk format and API speed up decoding speed up search compatible with previous format (when not searching)
https://github.com/AdguardTeam/AdGuardHome/commit/2f5d6593f2d9841f9c18b9ac60a554af60a34a6b
querylog/qlog.go
type logEntry struct { Question []byte Answer []byte `json:",omitempty"` // sometimes empty answers happen like binerdunt.top or rev2.globalrootservers.net Result dnsfilter.Result Time time.Time Elapsed time.Duration IP string Upstream string `json:",omitempty"` // if empty, means it was cached }
</s> remove IP string </s> add </s> remove Question []byte </s> add IP string `json:"IP"` Time time.Time `json:"T"` QHost string `json:"QH"` QType string `json:"QT"` QClass string `json:"QC"` </s> remove QuestionType uint16 // filter by question type </s> add QuestionType string // filter by question type </s> remove var q []byte var a []byte var err error ip := getIPString(addr) if question == nil { </s> add if question == nil || len(question.Question) != 1 || len(question.Question[0].Name) == 0 || ip == nil { </s> remove return entries, total </s> add return entries, oldest, int(total)
type logEntry struct { Question []byte Answer []byte `json:",omitempty"` // sometimes empty answers happen like binerdunt.top or rev2.globalrootservers.net Result dnsfilter.Result Elapsed time.Duration IP string Upstream string `json:",omitempty"` // if empty, means it was cached }
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
* querylog: major refactor: change on-disk format and API speed up decoding speed up search compatible with previous format (when not searching)
https://github.com/AdguardTeam/AdGuardHome/commit/2f5d6593f2d9841f9c18b9ac60a554af60a34a6b
querylog/qlog.go
Answer []byte `json:",omitempty"` // sometimes empty answers happen like binerdunt.top or rev2.globalrootservers.net Result dnsfilter.Result Time time.Time Elapsed time.Duration IP string Upstream string `json:",omitempty"` // if empty, means it was cached } // getIPString is a helper function that extracts IP address from net.Addr func getIPString(addr net.Addr) string {
</s> remove Time time.Time </s> add </s> remove Question []byte </s> add IP string `json:"IP"` Time time.Time `json:"T"` QHost string `json:"QH"` QType string `json:"QT"` QClass string `json:"QC"` </s> remove QuestionType uint16 // filter by question type </s> add QuestionType string // filter by question type </s> remove var q []byte var a []byte var err error ip := getIPString(addr) if question == nil { </s> add if question == nil || len(question.Question) != 1 || len(question.Question[0].Name) == 0 || ip == nil { </s> remove if len(params.Domain) != 0 && params.StrictMatchDomain { params.Domain = params.Domain + "." } </s> add var oldest time.Time
Answer []byte `json:",omitempty"` // sometimes empty answers happen like binerdunt.top or rev2.globalrootservers.net Result dnsfilter.Result Time time.Time Elapsed time.Duration Upstream string `json:",omitempty"` // if empty, means it was cached } // getIPString is a helper function that extracts IP address from net.Addr func getIPString(addr net.Addr) string {
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
* querylog: major refactor: change on-disk format and API speed up decoding speed up search compatible with previous format (when not searching)
https://github.com/AdguardTeam/AdGuardHome/commit/2f5d6593f2d9841f9c18b9ac60a554af60a34a6b
querylog/qlog.go
if !l.conf.Enabled { return } var q []byte var a []byte var err error ip := getIPString(addr) if question == nil { return } q, err = question.Pack() if err != nil {
</s> remove q, err = question.Pack() if err != nil { log.Printf("failed to pack question for querylog: %s", err) return } </s> add var a []byte var err error ip := getIPString(addr) </s> remove if len(entry.Question) == 0 { continue } q = new(dns.Msg) if err := q.Unpack(entry.Question); err != nil { log.Tracef("q.Unpack(): %s", err) continue } if len(q.Question) != 1 { log.Tracef("len(q.Question) != 1") continue } </s> add </s> remove strReader := strings.NewReader(string(b)) jd := json.NewDecoder(strReader) </s> add str := string(b) </s> remove log.Debug("QueryLog: Failed to decode: %s", err) </s> add log.Debug("QueryLog: failed to decode") </s> remove // read data var entry logEntry err = jd.Decode(&entry) </s> add val := readJSONValue(str, "T") if len(val) == 0 { val = readJSONValue(str, "Time") } if len(val) == 0 { log.Debug("QueryLog: failed to decode") continue } tm, err := time.Parse(time.RFC3339, val)
if question == nil || len(question.Question) != 1 || len(question.Question[0].Name) == 0 || ip == nil {
if !l.conf.Enabled { return } if question == nil || len(question.Question) != 1 || len(question.Question[0].Name) == 0 || ip == nil { if question == nil || len(question.Question) != 1 || len(question.Question[0].Name) == 0 || ip == nil { if question == nil || len(question.Question) != 1 || len(question.Question[0].Name) == 0 || ip == nil { if question == nil || len(question.Question) != 1 || len(question.Question[0].Name) == 0 || ip == nil { if question == nil || len(question.Question) != 1 || len(question.Question[0].Name) == 0 || ip == nil { if question == nil || len(question.Question) != 1 || len(question.Question[0].Name) == 0 || ip == nil { return } q, err = question.Pack() if err != nil {
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
* querylog: major refactor: change on-disk format and API speed up decoding speed up search compatible with previous format (when not searching)
https://github.com/AdguardTeam/AdGuardHome/commit/2f5d6593f2d9841f9c18b9ac60a554af60a34a6b
querylog/qlog.go
if question == nil { return } q, err = question.Pack() if err != nil { log.Printf("failed to pack question for querylog: %s", err) return } if answer != nil { a, err = answer.Pack() if err != nil { log.Printf("failed to pack answer for querylog: %s", err)
</s> remove var q []byte var a []byte var err error ip := getIPString(addr) if question == nil { </s> add if question == nil || len(question.Question) != 1 || len(question.Question[0].Name) == 0 || ip == nil { </s> remove if len(entry.Question) == 0 { continue } q = new(dns.Msg) if err := q.Unpack(entry.Question); err != nil { log.Tracef("q.Unpack(): %s", err) continue } if len(q.Question) != 1 { log.Tracef("len(q.Question) != 1") continue } </s> add </s> remove log.Debug("Failed to unpack dns message answer: %s", err) </s> add log.Debug("Failed to unpack dns message answer: %s: %s", err, string(entry.Answer)) </s> remove log.Debug("QueryLog: Failed to decode: %s", err) </s> add log.Debug("QueryLog: failed to decode") </s> remove // read data var entry logEntry err = jd.Decode(&entry) </s> add val := readJSONValue(str, "T") if len(val) == 0 { val = readJSONValue(str, "Time") } if len(val) == 0 { log.Debug("QueryLog: failed to decode") continue } tm, err := time.Parse(time.RFC3339, val)
var a []byte var err error ip := getIPString(addr)
if question == nil { return } var a []byte var err error ip := getIPString(addr) var a []byte var err error ip := getIPString(addr) var a []byte var err error ip := getIPString(addr) var a []byte var err error ip := getIPString(addr) var a []byte var err error ip := getIPString(addr) if answer != nil { a, err = answer.Pack() if err != nil { log.Printf("failed to pack answer for querylog: %s", err)
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
* querylog: major refactor: change on-disk format and API speed up decoding speed up search compatible with previous format (when not searching)
https://github.com/AdguardTeam/AdGuardHome/commit/2f5d6593f2d9841f9c18b9ac60a554af60a34a6b
querylog/qlog.go
} now := time.Now() entry := logEntry{ Question: q, Answer: a, Result: *result, Time: now, Elapsed: elapsed, IP: ip,
</s> remove Time: now, </s> add </s> remove IP: ip, </s> add </s> remove if len(params.Domain) != 0 && params.StrictMatchDomain { params.Domain = params.Domain + "." } </s> add var oldest time.Time </s> remove q, err = question.Pack() if err != nil { log.Printf("failed to pack question for querylog: %s", err) return } </s> add var a []byte var err error ip := getIPString(addr)
IP: ip, Time: now,
} now := time.Now() entry := logEntry{ IP: ip, Time: now, Answer: a, Result: *result, Time: now, Elapsed: elapsed, IP: ip,
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
* querylog: major refactor: change on-disk format and API speed up decoding speed up search compatible with previous format (when not searching)
https://github.com/AdguardTeam/AdGuardHome/commit/2f5d6593f2d9841f9c18b9ac60a554af60a34a6b
querylog/qlog.go
entry := logEntry{ Question: q, Answer: a, Result: *result, Time: now, Elapsed: elapsed, IP: ip, Upstream: upstream, }
</s> remove Question: q, </s> add IP: ip, Time: now, </s> remove IP: ip, </s> add </s> remove q, err = question.Pack() if err != nil { log.Printf("failed to pack question for querylog: %s", err) return } </s> add var a []byte var err error ip := getIPString(addr) </s> remove log.Debug("querylog: read %d entries in %v, %v/entry, seek-reqs:%d", r.count, elapsed, perunit, r.nSeekRequests) </s> add log.Debug("querylog: read %d entries in %v, %v/entry, seek-reqs:%d time:%dus (%d%%)", r.count, elapsed, perunit, r.nSeekRequests, r.timecnt/1000, r.timecnt*100/uint64(elapsed.Nanoseconds()))
entry := logEntry{ Question: q, Answer: a, Result: *result, Elapsed: elapsed, IP: ip, Upstream: upstream, }
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
* querylog: major refactor: change on-disk format and API speed up decoding speed up search compatible with previous format (when not searching)
https://github.com/AdguardTeam/AdGuardHome/commit/2f5d6593f2d9841f9c18b9ac60a554af60a34a6b
querylog/qlog.go
Answer: a, Result: *result, Time: now, Elapsed: elapsed, IP: ip, Upstream: upstream, } l.bufferLock.Lock() l.buffer = append(l.buffer, &entry)
</s> remove Time: now, </s> add </s> remove Question: q, </s> add IP: ip, Time: now, </s> remove log.Debug("querylog: read %d entries in %v, %v/entry, seek-reqs:%d", r.count, elapsed, perunit, r.nSeekRequests) </s> add log.Debug("querylog: read %d entries in %v, %v/entry, seek-reqs:%d time:%dus (%d%%)", r.count, elapsed, perunit, r.nSeekRequests, r.timecnt/1000, r.timecnt*100/uint64(elapsed.Nanoseconds())) </s> remove q, err = question.Pack() if err != nil { log.Printf("failed to pack question for querylog: %s", err) return } </s> add var a []byte var err error ip := getIPString(addr)
Answer: a, Result: *result, Time: now, Elapsed: elapsed, Upstream: upstream, } l.bufferLock.Lock() l.buffer = append(l.buffer, &entry)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
* querylog: major refactor: change on-disk format and API speed up decoding speed up search compatible with previous format (when not searching)
https://github.com/AdguardTeam/AdGuardHome/commit/2f5d6593f2d9841f9c18b9ac60a554af60a34a6b
querylog/qlog.go
Result: *result, Elapsed: elapsed, Upstream: upstream, } l.bufferLock.Lock() l.buffer = append(l.buffer, &entry) needFlush := false if !l.flushPending { needFlush = len(l.buffer) >= logBufferCap
</s> remove IP: ip, </s> add </s> remove Time: now, </s> add </s> remove Question: q, </s> add IP: ip, Time: now, </s> remove r.searching = false </s> add r.seeking = false
q := question.Question[0] entry.QHost = strings.ToLower(q.Name[:len(q.Name)-1]) // remove the last dot entry.QType = dns.Type(q.Qtype).String() entry.QClass = dns.Class(q.Qclass).String()
Result: *result, Elapsed: elapsed, Upstream: upstream, } q := question.Question[0] entry.QHost = strings.ToLower(q.Name[:len(q.Name)-1]) // remove the last dot entry.QType = dns.Type(q.Qtype).String() entry.QClass = dns.Class(q.Qclass).String() l.bufferLock.Lock() l.buffer = append(l.buffer, &entry) needFlush := false if !l.flushPending { needFlush = len(l.buffer) >= logBufferCap
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
* querylog: major refactor: change on-disk format and API speed up decoding speed up search compatible with previous format (when not searching)
https://github.com/AdguardTeam/AdGuardHome/commit/2f5d6593f2d9841f9c18b9ac60a554af60a34a6b
querylog/qlog.go
if params.ResponseStatus == responseStatusFiltered && !entry.Result.IsFiltered { return false } if len(params.Domain) != 0 || params.QuestionType != 0 { m := dns.Msg{} _ = m.Unpack(entry.Question) if params.QuestionType != 0 { if m.Question[0].Qtype != params.QuestionType { return false } } if len(params.Domain) != 0 && params.StrictMatchDomain { if m.Question[0].Name != params.Domain { return false } } else if len(params.Domain) != 0 { if strings.Index(m.Question[0].Name, params.Domain) == -1 { return false } } } if len(params.Client) != 0 && params.StrictMatchClient { if entry.IP != params.Client {
</s> remove if len(params.Client) != 0 && params.StrictMatchClient { if entry.IP != params.Client { </s> add if len(params.Domain) != 0 { if (params.StrictMatchDomain && entry.QHost != params.Domain) || (!params.StrictMatchDomain && strings.Index(entry.QHost, params.Domain) == -1) { </s> remove } else if len(params.Client) != 0 { if strings.Index(entry.IP, params.Client) == -1 { </s> add } if len(params.Client) != 0 { if (params.StrictMatchClient && entry.IP != params.Client) || (!params.StrictMatchClient && strings.Index(entry.IP, params.Client) == -1) { </s> remove params.QuestionType = qtype </s> add params.QuestionType = req.filterQuestionType </s> remove func (l *queryLog) getData(params getDataParams) []map[string]interface{} { </s> add func (l *queryLog) getData(params getDataParams) map[string]interface{} { </s> remove qtype, ok := dns.StringToType[req.filterQuestionType] </s> add _, ok := dns.StringToType[req.filterQuestionType]
if len(params.QuestionType) != 0 { if entry.QType != params.QuestionType { return false
if params.ResponseStatus == responseStatusFiltered && !entry.Result.IsFiltered { return false } if len(params.QuestionType) != 0 { if entry.QType != params.QuestionType { return false if len(params.QuestionType) != 0 { if entry.QType != params.QuestionType { return false if len(params.QuestionType) != 0 { if entry.QType != params.QuestionType { return false if len(params.QuestionType) != 0 { if entry.QType != params.QuestionType { return false if len(params.QuestionType) != 0 { if entry.QType != params.QuestionType { return false if len(params.QuestionType) != 0 { if entry.QType != params.QuestionType { return false if len(params.QuestionType) != 0 { if entry.QType != params.QuestionType { return false if len(params.QuestionType) != 0 { if entry.QType != params.QuestionType { return false if len(params.QuestionType) != 0 { if entry.QType != params.QuestionType { return false if len(params.QuestionType) != 0 { if entry.QType != params.QuestionType { return false if len(params.QuestionType) != 0 { if entry.QType != params.QuestionType { return false if len(params.QuestionType) != 0 { if entry.QType != params.QuestionType { return false if len(params.QuestionType) != 0 { if entry.QType != params.QuestionType { return false if len(params.QuestionType) != 0 { if entry.QType != params.QuestionType { return false if len(params.QuestionType) != 0 { if entry.QType != params.QuestionType { return false if len(params.QuestionType) != 0 { if entry.QType != params.QuestionType { return false if len(params.QuestionType) != 0 { if entry.QType != params.QuestionType { return false if len(params.QuestionType) != 0 { if entry.QType != params.QuestionType { return false } } if len(params.Client) != 0 && params.StrictMatchClient { if entry.IP != params.Client {
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
* querylog: major refactor: change on-disk format and API speed up decoding speed up search compatible with previous format (when not searching)
https://github.com/AdguardTeam/AdGuardHome/commit/2f5d6593f2d9841f9c18b9ac60a554af60a34a6b
querylog/qlog.go
} } } if len(params.Client) != 0 && params.StrictMatchClient { if entry.IP != params.Client { return false } } else if len(params.Client) != 0 { if strings.Index(entry.IP, params.Client) == -1 { return false
</s> remove } else if len(params.Client) != 0 { if strings.Index(entry.IP, params.Client) == -1 { </s> add } if len(params.Client) != 0 { if (params.StrictMatchClient && entry.IP != params.Client) || (!params.StrictMatchClient && strings.Index(entry.IP, params.Client) == -1) { </s> remove if len(params.Domain) != 0 || params.QuestionType != 0 { m := dns.Msg{} _ = m.Unpack(entry.Question) if params.QuestionType != 0 { if m.Question[0].Qtype != params.QuestionType { return false } } if len(params.Domain) != 0 && params.StrictMatchDomain { if m.Question[0].Name != params.Domain { return false } } else if len(params.Domain) != 0 { if strings.Index(m.Question[0].Name, params.Domain) == -1 { return false } </s> add if len(params.QuestionType) != 0 { if entry.QType != params.QuestionType { return false </s> remove qtype, ok := dns.StringToType[req.filterQuestionType] </s> add _, ok := dns.StringToType[req.filterQuestionType] </s> remove total++ if first { first = false olderThan = entry.Time } </s> add </s> remove var q []byte var a []byte var err error ip := getIPString(addr) if question == nil { </s> add if question == nil || len(question.Question) != 1 || len(question.Question[0].Name) == 0 || ip == nil {
if len(params.Domain) != 0 { if (params.StrictMatchDomain && entry.QHost != params.Domain) || (!params.StrictMatchDomain && strings.Index(entry.QHost, params.Domain) == -1) {
} } } if len(params.Domain) != 0 { if (params.StrictMatchDomain && entry.QHost != params.Domain) || (!params.StrictMatchDomain && strings.Index(entry.QHost, params.Domain) == -1) { if len(params.Domain) != 0 { if (params.StrictMatchDomain && entry.QHost != params.Domain) || (!params.StrictMatchDomain && strings.Index(entry.QHost, params.Domain) == -1) { return false } } else if len(params.Client) != 0 { if strings.Index(entry.IP, params.Client) == -1 { return false
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
* querylog: major refactor: change on-disk format and API speed up decoding speed up search compatible with previous format (when not searching)
https://github.com/AdguardTeam/AdGuardHome/commit/2f5d6593f2d9841f9c18b9ac60a554af60a34a6b
querylog/qlog.go
if len(params.Client) != 0 && params.StrictMatchClient { if entry.IP != params.Client { return false } } else if len(params.Client) != 0 { if strings.Index(entry.IP, params.Client) == -1 { return false } } return true
</s> remove if len(params.Client) != 0 && params.StrictMatchClient { if entry.IP != params.Client { </s> add if len(params.Domain) != 0 { if (params.StrictMatchDomain && entry.QHost != params.Domain) || (!params.StrictMatchDomain && strings.Index(entry.QHost, params.Domain) == -1) { </s> remove if len(params.Domain) != 0 || params.QuestionType != 0 { m := dns.Msg{} _ = m.Unpack(entry.Question) if params.QuestionType != 0 { if m.Question[0].Qtype != params.QuestionType { return false } } if len(params.Domain) != 0 && params.StrictMatchDomain { if m.Question[0].Name != params.Domain { return false } } else if len(params.Domain) != 0 { if strings.Index(m.Question[0].Name, params.Domain) == -1 { return false } </s> add if len(params.QuestionType) != 0 { if entry.QType != params.QuestionType { return false </s> remove qtype, ok := dns.StringToType[req.filterQuestionType] </s> add _, ok := dns.StringToType[req.filterQuestionType] </s> remove var q []byte var a []byte var err error ip := getIPString(addr) if question == nil { </s> add if question == nil || len(question.Question) != 1 || len(question.Question[0].Name) == 0 || ip == nil { </s> remove total++ if first { first = false olderThan = entry.Time } </s> add
} if len(params.Client) != 0 { if (params.StrictMatchClient && entry.IP != params.Client) || (!params.StrictMatchClient && strings.Index(entry.IP, params.Client) == -1) {
if len(params.Client) != 0 && params.StrictMatchClient { if entry.IP != params.Client { return false } } if len(params.Client) != 0 { if (params.StrictMatchClient && entry.IP != params.Client) || (!params.StrictMatchClient && strings.Index(entry.IP, params.Client) == -1) { } if len(params.Client) != 0 { if (params.StrictMatchClient && entry.IP != params.Client) || (!params.StrictMatchClient && strings.Index(entry.IP, params.Client) == -1) { return false } } return true
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
* querylog: major refactor: change on-disk format and API speed up decoding speed up search compatible with previous format (when not searching)
https://github.com/AdguardTeam/AdGuardHome/commit/2f5d6593f2d9841f9c18b9ac60a554af60a34a6b
querylog/qlog.go
return true } func (l *queryLog) readFromFile(params getDataParams) ([]*logEntry, int) { entries := []*logEntry{} olderThan := params.OlderThan totalChunks := 0 total := 0
</s> remove olderThan := params.OlderThan totalChunks := 0 total := 0 </s> add oldest := time.Time{} </s> remove func (l *queryLog) getData(params getDataParams) []map[string]interface{} { </s> add func (l *queryLog) getData(params getDataParams) map[string]interface{} { </s> remove if len(params.Domain) != 0 && params.StrictMatchDomain { params.Domain = params.Domain + "." } </s> add var oldest time.Time </s> remove entries, total = l.readFromFile(params) </s> add entries, oldest, total = l.readFromFile(params) </s> remove return entries, 0 </s> add return entries, time.Time{}, 0
func (l *queryLog) readFromFile(params getDataParams) ([]*logEntry, time.Time, int) {
return true } func (l *queryLog) readFromFile(params getDataParams) ([]*logEntry, time.Time, int) { entries := []*logEntry{} olderThan := params.OlderThan totalChunks := 0 total := 0
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
* querylog: major refactor: change on-disk format and API speed up decoding speed up search compatible with previous format (when not searching)
https://github.com/AdguardTeam/AdGuardHome/commit/2f5d6593f2d9841f9c18b9ac60a554af60a34a6b
querylog/qlog.go
} func (l *queryLog) readFromFile(params getDataParams) ([]*logEntry, int) { entries := []*logEntry{} olderThan := params.OlderThan totalChunks := 0 total := 0 r := l.OpenReader() if r == nil { return entries, 0 }
</s> remove func (l *queryLog) readFromFile(params getDataParams) ([]*logEntry, int) { </s> add func (l *queryLog) readFromFile(params getDataParams) ([]*logEntry, time.Time, int) { </s> remove return entries, 0 </s> add return entries, time.Time{}, 0 </s> remove r.BeginRead(olderThan, getDataLimit) for totalChunks < maxFilteringChunks { first := true </s> add r.BeginRead(params.OlderThan, getDataLimit, &params) total := uint64(0) for total <= maxSearchEntries { </s> remove func (l *queryLog) getData(params getDataParams) []map[string]interface{} { </s> add func (l *queryLog) getData(params getDataParams) map[string]interface{} { </s> remove entries, total = l.readFromFile(params) </s> add entries, oldest, total = l.readFromFile(params)
oldest := time.Time{}
} func (l *queryLog) readFromFile(params getDataParams) ([]*logEntry, int) { entries := []*logEntry{} oldest := time.Time{} oldest := time.Time{} oldest := time.Time{} r := l.OpenReader() if r == nil { return entries, 0 }
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
* querylog: major refactor: change on-disk format and API speed up decoding speed up search compatible with previous format (when not searching)
https://github.com/AdguardTeam/AdGuardHome/commit/2f5d6593f2d9841f9c18b9ac60a554af60a34a6b
querylog/qlog.go
total := 0 r := l.OpenReader() if r == nil { return entries, 0 } r.BeginRead(olderThan, getDataLimit) for totalChunks < maxFilteringChunks { first := true newEntries := []*logEntry{}
</s> remove r.BeginRead(olderThan, getDataLimit) for totalChunks < maxFilteringChunks { first := true </s> add r.BeginRead(params.OlderThan, getDataLimit, &params) total := uint64(0) for total <= maxSearchEntries { </s> remove olderThan := params.OlderThan totalChunks := 0 total := 0 </s> add oldest := time.Time{} </s> remove totalChunks++ r.BeginReadPrev(olderThan, getDataLimit) </s> add total += r.Total() oldest = r.Oldest() r.BeginReadPrev(getDataLimit) </s> remove func (l *queryLog) readFromFile(params getDataParams) ([]*logEntry, int) { </s> add func (l *queryLog) readFromFile(params getDataParams) ([]*logEntry, time.Time, int) { </s> remove entries, total = l.readFromFile(params) </s> add entries, oldest, total = l.readFromFile(params)
return entries, time.Time{}, 0
total := 0 r := l.OpenReader() if r == nil { return entries, time.Time{}, 0 } r.BeginRead(olderThan, getDataLimit) for totalChunks < maxFilteringChunks { first := true newEntries := []*logEntry{}
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
* querylog: major refactor: change on-disk format and API speed up decoding speed up search compatible with previous format (when not searching)
https://github.com/AdguardTeam/AdGuardHome/commit/2f5d6593f2d9841f9c18b9ac60a554af60a34a6b
querylog/qlog.go
r := l.OpenReader() if r == nil { return entries, 0 } r.BeginRead(olderThan, getDataLimit) for totalChunks < maxFilteringChunks { first := true newEntries := []*logEntry{} for { entry := r.Next() if entry == nil { break
</s> remove return entries, 0 </s> add return entries, time.Time{}, 0 </s> remove olderThan := params.OlderThan totalChunks := 0 total := 0 </s> add oldest := time.Time{} </s> remove total++ if first { first = false olderThan = entry.Time } </s> add </s> remove if first || len(entries) == getDataLimit { </s> add if r.Total() == 0 || len(entries) == getDataLimit { </s> remove totalChunks++ r.BeginReadPrev(olderThan, getDataLimit) </s> add total += r.Total() oldest = r.Oldest() r.BeginReadPrev(getDataLimit)
r.BeginRead(params.OlderThan, getDataLimit, &params) total := uint64(0) for total <= maxSearchEntries {
r := l.OpenReader() if r == nil { return entries, 0 } r.BeginRead(params.OlderThan, getDataLimit, &params) total := uint64(0) for total <= maxSearchEntries { r.BeginRead(params.OlderThan, getDataLimit, &params) total := uint64(0) for total <= maxSearchEntries { r.BeginRead(params.OlderThan, getDataLimit, &params) total := uint64(0) for total <= maxSearchEntries { newEntries := []*logEntry{} for { entry := r.Next() if entry == nil { break
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
* querylog: major refactor: change on-disk format and API speed up decoding speed up search compatible with previous format (when not searching)
https://github.com/AdguardTeam/AdGuardHome/commit/2f5d6593f2d9841f9c18b9ac60a554af60a34a6b
querylog/qlog.go
entry := r.Next() if entry == nil { break } total++ if first { first = false olderThan = entry.Time } if !isNeeded(entry, params) { continue } if len(newEntries) == getDataLimit {
</s> remove if first || len(entries) == getDataLimit { </s> add if r.Total() == 0 || len(entries) == getDataLimit { </s> remove r.BeginRead(olderThan, getDataLimit) for totalChunks < maxFilteringChunks { first := true </s> add r.BeginRead(params.OlderThan, getDataLimit, &params) total := uint64(0) for total <= maxSearchEntries { </s> remove totalChunks++ r.BeginReadPrev(olderThan, getDataLimit) </s> add total += r.Total() oldest = r.Oldest() r.BeginReadPrev(getDataLimit) </s> remove if len(entry.Question) == 0 { continue } q = new(dns.Msg) if err := q.Unpack(entry.Question); err != nil { log.Tracef("q.Unpack(): %s", err) continue } if len(q.Question) != 1 { log.Tracef("len(q.Question) != 1") continue } </s> add </s> remove // read data var entry logEntry err = jd.Decode(&entry) </s> add val := readJSONValue(str, "T") if len(val) == 0 { val = readJSONValue(str, "Time") } if len(val) == 0 { log.Debug("QueryLog: failed to decode") continue } tm, err := time.Parse(time.RFC3339, val)
entry := r.Next() if entry == nil { break } if !isNeeded(entry, params) { continue } if len(newEntries) == getDataLimit {
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
* querylog: major refactor: change on-disk format and API speed up decoding speed up search compatible with previous format (when not searching)
https://github.com/AdguardTeam/AdGuardHome/commit/2f5d6593f2d9841f9c18b9ac60a554af60a34a6b
querylog/qlog.go
} newEntries = append(newEntries, entry) } log.Debug("entries: +%d (%d) older-than:%s", len(newEntries), len(entries), olderThan) entries = append(newEntries, entries...) if len(entries) > getDataLimit { toremove := len(entries) - getDataLimit entries = entries[toremove:]
</s> remove if first || len(entries) == getDataLimit { </s> add if r.Total() == 0 || len(entries) == getDataLimit { </s> remove return data </s> add var result = map[string]interface{}{} if len(entries) == getDataLimit { oldest = entries[0].Time } result["oldest"] = "" if !oldest.IsZero() { result["oldest"] = oldest.Format(time.RFC3339Nano) } result["data"] = data return result </s> remove totalChunks++ r.BeginReadPrev(olderThan, getDataLimit) </s> add total += r.Total() oldest = r.Oldest() r.BeginReadPrev(getDataLimit) </s> remove total++ if first { first = false olderThan = entry.Time } </s> add </s> remove log.Debug("querylog: read %d entries in %v, %v/entry, seek-reqs:%d", r.count, elapsed, perunit, r.nSeekRequests) </s> add log.Debug("querylog: read %d entries in %v, %v/entry, seek-reqs:%d time:%dus (%d%%)", r.count, elapsed, perunit, r.nSeekRequests, r.timecnt/1000, r.timecnt*100/uint64(elapsed.Nanoseconds()))
log.Debug("entries: +%d (%d) [%d]", len(newEntries), len(entries), r.Total())
} newEntries = append(newEntries, entry) } log.Debug("entries: +%d (%d) [%d]", len(newEntries), len(entries), r.Total()) entries = append(newEntries, entries...) if len(entries) > getDataLimit { toremove := len(entries) - getDataLimit entries = entries[toremove:]
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
* querylog: major refactor: change on-disk format and API speed up decoding speed up search compatible with previous format (when not searching)
https://github.com/AdguardTeam/AdGuardHome/commit/2f5d6593f2d9841f9c18b9ac60a554af60a34a6b
querylog/qlog.go
toremove := len(entries) - getDataLimit entries = entries[toremove:] break } if first || len(entries) == getDataLimit { break } totalChunks++ r.BeginReadPrev(olderThan, getDataLimit) }
</s> remove totalChunks++ r.BeginReadPrev(olderThan, getDataLimit) </s> add total += r.Total() oldest = r.Oldest() r.BeginReadPrev(getDataLimit) </s> remove log.Debug("entries: +%d (%d) older-than:%s", len(newEntries), len(entries), olderThan) </s> add log.Debug("entries: +%d (%d) [%d]", len(newEntries), len(entries), r.Total()) </s> remove total++ if first { first = false olderThan = entry.Time } </s> add </s> remove return data </s> add var result = map[string]interface{}{} if len(entries) == getDataLimit { oldest = entries[0].Time } result["oldest"] = "" if !oldest.IsZero() { result["oldest"] = oldest.Format(time.RFC3339Nano) } result["data"] = data return result </s> remove r.BeginRead(olderThan, getDataLimit) for totalChunks < maxFilteringChunks { first := true </s> add r.BeginRead(params.OlderThan, getDataLimit, &params) total := uint64(0) for total <= maxSearchEntries {
if r.Total() == 0 || len(entries) == getDataLimit {
toremove := len(entries) - getDataLimit entries = entries[toremove:] break } if r.Total() == 0 || len(entries) == getDataLimit { break } totalChunks++ r.BeginReadPrev(olderThan, getDataLimit) }
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
* querylog: major refactor: change on-disk format and API speed up decoding speed up search compatible with previous format (when not searching)
https://github.com/AdguardTeam/AdGuardHome/commit/2f5d6593f2d9841f9c18b9ac60a554af60a34a6b
querylog/qlog.go
} if first || len(entries) == getDataLimit { break } totalChunks++ r.BeginReadPrev(olderThan, getDataLimit) } r.Close() return entries, total }
</s> remove if first || len(entries) == getDataLimit { </s> add if r.Total() == 0 || len(entries) == getDataLimit { </s> remove return entries, total </s> add return entries, oldest, int(total) </s> remove total++ if first { first = false olderThan = entry.Time } </s> add </s> remove r.BeginRead(olderThan, getDataLimit) for totalChunks < maxFilteringChunks { first := true </s> add r.BeginRead(params.OlderThan, getDataLimit, &params) total := uint64(0) for total <= maxSearchEntries { </s> remove return entries, 0 </s> add return entries, time.Time{}, 0
total += r.Total() oldest = r.Oldest() r.BeginReadPrev(getDataLimit)
} if first || len(entries) == getDataLimit { break } total += r.Total() oldest = r.Oldest() r.BeginReadPrev(getDataLimit) total += r.Total() oldest = r.Oldest() r.BeginReadPrev(getDataLimit) } r.Close() return entries, total }
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
* querylog: major refactor: change on-disk format and API speed up decoding speed up search compatible with previous format (when not searching)
https://github.com/AdguardTeam/AdGuardHome/commit/2f5d6593f2d9841f9c18b9ac60a554af60a34a6b
querylog/qlog.go
r.BeginReadPrev(olderThan, getDataLimit) } r.Close() return entries, total } // Parameters for getData() type getDataParams struct { OlderThan time.Time // return entries that are older than this value
</s> remove QuestionType uint16 // filter by question type </s> add QuestionType string // filter by question type </s> remove totalChunks++ r.BeginReadPrev(olderThan, getDataLimit) </s> add total += r.Total() oldest = r.Oldest() r.BeginReadPrev(getDataLimit) </s> remove return entries, 0 </s> add return entries, time.Time{}, 0 </s> remove r.BeginRead(olderThan, getDataLimit) for totalChunks < maxFilteringChunks { first := true </s> add r.BeginRead(params.OlderThan, getDataLimit, &params) total := uint64(0) for total <= maxSearchEntries {
return entries, oldest, int(total)
r.BeginReadPrev(olderThan, getDataLimit) } r.Close() return entries, oldest, int(total) } // Parameters for getData() type getDataParams struct { OlderThan time.Time // return entries that are older than this value
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
* querylog: major refactor: change on-disk format and API speed up decoding speed up search compatible with previous format (when not searching)
https://github.com/AdguardTeam/AdGuardHome/commit/2f5d6593f2d9841f9c18b9ac60a554af60a34a6b
querylog/qlog.go
type getDataParams struct { OlderThan time.Time // return entries that are older than this value Domain string // filter by domain name in question Client string // filter by client IP QuestionType uint16 // filter by question type ResponseStatus responseStatusType // filter by response status StrictMatchDomain bool // if Domain value must be matched strictly StrictMatchClient bool // if Client value must be matched strictly }
</s> remove return entries, total </s> add return entries, oldest, int(total) </s> remove Question []byte </s> add IP string `json:"IP"` Time time.Time `json:"T"` QHost string `json:"QH"` QType string `json:"QT"` QClass string `json:"QC"` </s> remove ql *queryLog </s> add ql *queryLog search *getDataParams </s> remove Time time.Time </s> add
QuestionType string // filter by question type
type getDataParams struct { OlderThan time.Time // return entries that are older than this value Domain string // filter by domain name in question Client string // filter by client IP QuestionType string // filter by question type ResponseStatus responseStatusType // filter by response status StrictMatchDomain bool // if Domain value must be matched strictly StrictMatchClient bool // if Client value must be matched strictly }
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
* querylog: major refactor: change on-disk format and API speed up decoding speed up search compatible with previous format (when not searching)
https://github.com/AdguardTeam/AdGuardHome/commit/2f5d6593f2d9841f9c18b9ac60a554af60a34a6b
querylog/qlog.go
responseStatusFiltered ) // Get log entries func (l *queryLog) getData(params getDataParams) []map[string]interface{} { var data = []map[string]interface{}{} if len(params.Domain) != 0 && params.StrictMatchDomain { params.Domain = params.Domain + "." }
</s> remove if len(params.Domain) != 0 && params.StrictMatchDomain { params.Domain = params.Domain + "." } </s> add var oldest time.Time </s> remove if len(params.Domain) != 0 || params.QuestionType != 0 { m := dns.Msg{} _ = m.Unpack(entry.Question) if params.QuestionType != 0 { if m.Question[0].Qtype != params.QuestionType { return false } } if len(params.Domain) != 0 && params.StrictMatchDomain { if m.Question[0].Name != params.Domain { return false } } else if len(params.Domain) != 0 { if strings.Index(m.Question[0].Name, params.Domain) == -1 { return false } </s> add if len(params.QuestionType) != 0 { if entry.QType != params.QuestionType { return false </s> remove func (l *queryLog) readFromFile(params getDataParams) ([]*logEntry, int) { </s> add func (l *queryLog) readFromFile(params getDataParams) ([]*logEntry, time.Time, int) { </s> remove olderThan := params.OlderThan totalChunks := 0 total := 0 </s> add oldest := time.Time{} </s> remove return data </s> add var result = map[string]interface{}{} if len(entries) == getDataLimit { oldest = entries[0].Time } result["oldest"] = "" if !oldest.IsZero() { result["oldest"] = oldest.Format(time.RFC3339Nano) } result["data"] = data return result
func (l *queryLog) getData(params getDataParams) map[string]interface{} {
responseStatusFiltered ) // Get log entries func (l *queryLog) getData(params getDataParams) map[string]interface{} { var data = []map[string]interface{}{} if len(params.Domain) != 0 && params.StrictMatchDomain { params.Domain = params.Domain + "." }
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
* querylog: major refactor: change on-disk format and API speed up decoding speed up search compatible with previous format (when not searching)
https://github.com/AdguardTeam/AdGuardHome/commit/2f5d6593f2d9841f9c18b9ac60a554af60a34a6b
querylog/qlog.go
// Get log entries func (l *queryLog) getData(params getDataParams) []map[string]interface{} { var data = []map[string]interface{}{} if len(params.Domain) != 0 && params.StrictMatchDomain { params.Domain = params.Domain + "." } now := time.Now() entries := []*logEntry{} total := 0 // add from file
</s> remove func (l *queryLog) getData(params getDataParams) []map[string]interface{} { </s> add func (l *queryLog) getData(params getDataParams) map[string]interface{} { </s> remove entries, total = l.readFromFile(params) </s> add entries, oldest, total = l.readFromFile(params) </s> remove func (l *queryLog) readFromFile(params getDataParams) ([]*logEntry, int) { </s> add func (l *queryLog) readFromFile(params getDataParams) ([]*logEntry, time.Time, int) { </s> remove if len(params.Domain) != 0 || params.QuestionType != 0 { m := dns.Msg{} _ = m.Unpack(entry.Question) if params.QuestionType != 0 { if m.Question[0].Qtype != params.QuestionType { return false } } if len(params.Domain) != 0 && params.StrictMatchDomain { if m.Question[0].Name != params.Domain { return false } } else if len(params.Domain) != 0 { if strings.Index(m.Question[0].Name, params.Domain) == -1 { return false } </s> add if len(params.QuestionType) != 0 { if entry.QType != params.QuestionType { return false </s> remove olderThan := params.OlderThan totalChunks := 0 total := 0 </s> add oldest := time.Time{}
var oldest time.Time
// Get log entries func (l *queryLog) getData(params getDataParams) []map[string]interface{} { var data = []map[string]interface{}{} var oldest time.Time var oldest time.Time var oldest time.Time var oldest time.Time now := time.Now() entries := []*logEntry{} total := 0 // add from file
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
* querylog: major refactor: change on-disk format and API speed up decoding speed up search compatible with previous format (when not searching)
https://github.com/AdguardTeam/AdGuardHome/commit/2f5d6593f2d9841f9c18b9ac60a554af60a34a6b
querylog/qlog.go
entries := []*logEntry{} total := 0 // add from file entries, total = l.readFromFile(params) if params.OlderThan.IsZero() { params.OlderThan = now }
</s> remove if len(params.Domain) != 0 && params.StrictMatchDomain { params.Domain = params.Domain + "." } </s> add var oldest time.Time </s> remove olderThan := params.OlderThan totalChunks := 0 total := 0 </s> add oldest := time.Time{} </s> remove totalChunks++ r.BeginReadPrev(olderThan, getDataLimit) </s> add total += r.Total() oldest = r.Oldest() r.BeginReadPrev(getDataLimit) </s> remove func (l *queryLog) readFromFile(params getDataParams) ([]*logEntry, int) { </s> add func (l *queryLog) readFromFile(params getDataParams) ([]*logEntry, time.Time, int) { </s> remove return entries, 0 </s> add return entries, time.Time{}, 0
entries, oldest, total = l.readFromFile(params)
entries := []*logEntry{} total := 0 // add from file entries, oldest, total = l.readFromFile(params) if params.OlderThan.IsZero() { params.OlderThan = now }
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
* querylog: major refactor: change on-disk format and API speed up decoding speed up search compatible with previous format (when not searching)
https://github.com/AdguardTeam/AdGuardHome/commit/2f5d6593f2d9841f9c18b9ac60a554af60a34a6b
querylog/qlog.go
// process the elements from latest to oldest for i := len(entries) - 1; i >= 0; i-- { entry := entries[i] var q *dns.Msg var a *dns.Msg if len(entry.Question) == 0 { continue }
</s> remove if len(entry.Question) == 0 { continue } q = new(dns.Msg) if err := q.Unpack(entry.Question); err != nil { log.Tracef("q.Unpack(): %s", err) continue } if len(q.Question) != 1 { log.Tracef("len(q.Question) != 1") continue } </s> add </s> remove var q []byte var a []byte var err error ip := getIPString(addr) if question == nil { </s> add if question == nil || len(question.Question) != 1 || len(question.Question[0].Name) == 0 || ip == nil { </s> remove q, err = question.Pack() if err != nil { log.Printf("failed to pack question for querylog: %s", err) return } </s> add var a []byte var err error ip := getIPString(addr) </s> remove // read data var entry logEntry err = jd.Decode(&entry) </s> add val := readJSONValue(str, "T") if len(val) == 0 { val = readJSONValue(str, "Time") } if len(val) == 0 { log.Debug("QueryLog: failed to decode") continue } tm, err := time.Parse(time.RFC3339, val) </s> remove return data </s> add var result = map[string]interface{}{} if len(entries) == getDataLimit { oldest = entries[0].Time } result["oldest"] = "" if !oldest.IsZero() { result["oldest"] = oldest.Format(time.RFC3339Nano) } result["data"] = data return result
// process the elements from latest to oldest for i := len(entries) - 1; i >= 0; i-- { entry := entries[i] var a *dns.Msg if len(entry.Question) == 0 { continue }
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
* querylog: major refactor: change on-disk format and API speed up decoding speed up search compatible with previous format (when not searching)
https://github.com/AdguardTeam/AdGuardHome/commit/2f5d6593f2d9841f9c18b9ac60a554af60a34a6b
querylog/qlog.go
entry := entries[i] var q *dns.Msg var a *dns.Msg if len(entry.Question) == 0 { continue } q = new(dns.Msg) if err := q.Unpack(entry.Question); err != nil { log.Tracef("q.Unpack(): %s", err) continue } if len(q.Question) != 1 { log.Tracef("len(q.Question) != 1") continue } if len(entry.Answer) > 0 { a = new(dns.Msg) if err := a.Unpack(entry.Answer); err != nil { log.Debug("Failed to unpack dns message answer: %s", err) a = nil
</s> remove log.Debug("Failed to unpack dns message answer: %s", err) </s> add log.Debug("Failed to unpack dns message answer: %s: %s", err, string(entry.Answer)) </s> remove q, err = question.Pack() if err != nil { log.Printf("failed to pack question for querylog: %s", err) return } </s> add var a []byte var err error ip := getIPString(addr) </s> remove var q []byte var a []byte var err error ip := getIPString(addr) if question == nil { </s> add if question == nil || len(question.Question) != 1 || len(question.Question[0].Name) == 0 || ip == nil { </s> remove log.Debug("QueryLog: Failed to decode: %s", err) </s> add log.Debug("QueryLog: failed to decode") </s> remove // read data var entry logEntry err = jd.Decode(&entry) </s> add val := readJSONValue(str, "T") if len(val) == 0 { val = readJSONValue(str, "Time") } if len(val) == 0 { log.Debug("QueryLog: failed to decode") continue } tm, err := time.Parse(time.RFC3339, val)
entry := entries[i] var q *dns.Msg var a *dns.Msg if len(entry.Answer) > 0 { a = new(dns.Msg) if err := a.Unpack(entry.Answer); err != nil { log.Debug("Failed to unpack dns message answer: %s", err) a = nil
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
* querylog: major refactor: change on-disk format and API speed up decoding speed up search compatible with previous format (when not searching)
https://github.com/AdguardTeam/AdGuardHome/commit/2f5d6593f2d9841f9c18b9ac60a554af60a34a6b
querylog/qlog.go
if len(entry.Answer) > 0 { a = new(dns.Msg) if err := a.Unpack(entry.Answer); err != nil { log.Debug("Failed to unpack dns message answer: %s", err) a = nil } } jsonEntry := map[string]interface{}{
</s> remove if len(entry.Question) == 0 { continue } q = new(dns.Msg) if err := q.Unpack(entry.Question); err != nil { log.Tracef("q.Unpack(): %s", err) continue } if len(q.Question) != 1 { log.Tracef("len(q.Question) != 1") continue } </s> add </s> remove q, err = question.Pack() if err != nil { log.Printf("failed to pack question for querylog: %s", err) return } </s> add var a []byte var err error ip := getIPString(addr) </s> remove log.Debug("QueryLog: Failed to decode: %s", err) </s> add log.Debug("QueryLog: failed to decode") </s> remove // read data var entry logEntry err = jd.Decode(&entry) </s> add val := readJSONValue(str, "T") if len(val) == 0 { val = readJSONValue(str, "Time") } if len(val) == 0 { log.Debug("QueryLog: failed to decode") continue } tm, err := time.Parse(time.RFC3339, val) </s> remove var q []byte var a []byte var err error ip := getIPString(addr) if question == nil { </s> add if question == nil || len(question.Question) != 1 || len(question.Question[0].Name) == 0 || ip == nil {
log.Debug("Failed to unpack dns message answer: %s: %s", err, string(entry.Answer))
if len(entry.Answer) > 0 { a = new(dns.Msg) if err := a.Unpack(entry.Answer); err != nil { log.Debug("Failed to unpack dns message answer: %s: %s", err, string(entry.Answer)) a = nil } } jsonEntry := map[string]interface{}{
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
* querylog: major refactor: change on-disk format and API speed up decoding speed up search compatible with previous format (when not searching)
https://github.com/AdguardTeam/AdGuardHome/commit/2f5d6593f2d9841f9c18b9ac60a554af60a34a6b
querylog/qlog.go
"time": entry.Time.Format(time.RFC3339Nano), "client": entry.IP, } jsonEntry["question"] = map[string]interface{}{ "host": strings.ToLower(strings.TrimSuffix(q.Question[0].Name, ".")), "type": dns.Type(q.Question[0].Qtype).String(), "class": dns.Class(q.Question[0].Qclass).String(), } if a != nil { jsonEntry["status"] = dns.RcodeToString[a.Rcode] }
</s> remove log.Debug("Failed to unpack dns message answer: %s", err) </s> add log.Debug("Failed to unpack dns message answer: %s: %s", err, string(entry.Answer)) </s> remove if len(entry.Question) == 0 { continue } q = new(dns.Msg) if err := q.Unpack(entry.Question); err != nil { log.Tracef("q.Unpack(): %s", err) continue } if len(q.Question) != 1 { log.Tracef("len(q.Question) != 1") continue } </s> add </s> remove q, err = question.Pack() if err != nil { log.Printf("failed to pack question for querylog: %s", err) return } </s> add var a []byte var err error ip := getIPString(addr) </s> remove return data </s> add var result = map[string]interface{}{} if len(entries) == getDataLimit { oldest = entries[0].Time } result["oldest"] = "" if !oldest.IsZero() { result["oldest"] = oldest.Format(time.RFC3339Nano) } result["data"] = data return result </s> remove var q []byte var a []byte var err error ip := getIPString(addr) if question == nil { </s> add if question == nil || len(question.Question) != 1 || len(question.Question[0].Name) == 0 || ip == nil {
"host": entry.QHost, "type": entry.QType, "class": entry.QClass,
"time": entry.Time.Format(time.RFC3339Nano), "client": entry.IP, } jsonEntry["question"] = map[string]interface{}{ "host": entry.QHost, "type": entry.QType, "class": entry.QClass, "host": entry.QHost, "type": entry.QType, "class": entry.QClass, "host": entry.QHost, "type": entry.QType, "class": entry.QClass, } if a != nil { jsonEntry["status"] = dns.RcodeToString[a.Rcode] }
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
* querylog: major refactor: change on-disk format and API speed up decoding speed up search compatible with previous format (when not searching)
https://github.com/AdguardTeam/AdGuardHome/commit/2f5d6593f2d9841f9c18b9ac60a554af60a34a6b
querylog/qlog.go
} log.Debug("QueryLog: prepared data (%d/%d) older than %s in %s", len(entries), total, params.OlderThan, time.Since(now)) return data } func answerToMap(a *dns.Msg) []map[string]interface{} { if a == nil || len(a.Answer) == 0 { return nil
</s> remove var q []byte var a []byte var err error ip := getIPString(addr) if question == nil { </s> add if question == nil || len(question.Question) != 1 || len(question.Question[0].Name) == 0 || ip == nil { </s> remove // read data var entry logEntry err = jd.Decode(&entry) </s> add val := readJSONValue(str, "T") if len(val) == 0 { val = readJSONValue(str, "Time") } if len(val) == 0 { log.Debug("QueryLog: failed to decode") continue } tm, err := time.Parse(time.RFC3339, val) </s> remove log.Debug("QueryLog: Failed to decode: %s", err) </s> add log.Debug("QueryLog: failed to decode") </s> remove if len(entry.Question) == 0 { continue } q = new(dns.Msg) if err := q.Unpack(entry.Question); err != nil { log.Tracef("q.Unpack(): %s", err) continue } if len(q.Question) != 1 { log.Tracef("len(q.Question) != 1") continue } </s> add </s> remove q, err = question.Pack() if err != nil { log.Printf("failed to pack question for querylog: %s", err) return } </s> add var a []byte var err error ip := getIPString(addr)
var result = map[string]interface{}{} if len(entries) == getDataLimit { oldest = entries[0].Time } result["oldest"] = "" if !oldest.IsZero() { result["oldest"] = oldest.Format(time.RFC3339Nano) } result["data"] = data return result
} log.Debug("QueryLog: prepared data (%d/%d) older than %s in %s", len(entries), total, params.OlderThan, time.Since(now)) var result = map[string]interface{}{} if len(entries) == getDataLimit { oldest = entries[0].Time } result["oldest"] = "" if !oldest.IsZero() { result["oldest"] = oldest.Format(time.RFC3339Nano) } result["data"] = data return result } func answerToMap(a *dns.Msg) []map[string]interface{} { if a == nil || len(a.Answer) == 0 { return nil
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
* querylog: major refactor: change on-disk format and API speed up decoding speed up search compatible with previous format (when not searching)
https://github.com/AdguardTeam/AdGuardHome/commit/2f5d6593f2d9841f9c18b9ac60a554af60a34a6b
querylog/qlog.go
params.StrictMatchClient = true } if len(req.filterQuestionType) != 0 { qtype, ok := dns.StringToType[req.filterQuestionType] if !ok { httpError(r, w, http.StatusBadRequest, "invalid question_type") return } params.QuestionType = qtype
</s> remove params.QuestionType = qtype </s> add params.QuestionType = req.filterQuestionType </s> remove if len(params.Domain) != 0 || params.QuestionType != 0 { m := dns.Msg{} _ = m.Unpack(entry.Question) if params.QuestionType != 0 { if m.Question[0].Qtype != params.QuestionType { return false } } if len(params.Domain) != 0 && params.StrictMatchDomain { if m.Question[0].Name != params.Domain { return false } } else if len(params.Domain) != 0 { if strings.Index(m.Question[0].Name, params.Domain) == -1 { return false } </s> add if len(params.QuestionType) != 0 { if entry.QType != params.QuestionType { return false </s> remove } else if len(params.Client) != 0 { if strings.Index(entry.IP, params.Client) == -1 { </s> add } if len(params.Client) != 0 { if (params.StrictMatchClient && entry.IP != params.Client) || (!params.StrictMatchClient && strings.Index(entry.IP, params.Client) == -1) { </s> remove if len(params.Client) != 0 && params.StrictMatchClient { if entry.IP != params.Client { </s> add if len(params.Domain) != 0 { if (params.StrictMatchDomain && entry.QHost != params.Domain) || (!params.StrictMatchDomain && strings.Index(entry.QHost, params.Domain) == -1) { </s> remove // open decoder </s> add
_, ok := dns.StringToType[req.filterQuestionType]
params.StrictMatchClient = true } if len(req.filterQuestionType) != 0 { _, ok := dns.StringToType[req.filterQuestionType] if !ok { httpError(r, w, http.StatusBadRequest, "invalid question_type") return } params.QuestionType = qtype
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
* querylog: major refactor: change on-disk format and API speed up decoding speed up search compatible with previous format (when not searching)
https://github.com/AdguardTeam/AdGuardHome/commit/2f5d6593f2d9841f9c18b9ac60a554af60a34a6b
querylog/qlog_http.go
if !ok { httpError(r, w, http.StatusBadRequest, "invalid question_type") return } params.QuestionType = qtype } if len(req.filterResponseStatus) != 0 { switch req.filterResponseStatus { case "filtered":
</s> remove qtype, ok := dns.StringToType[req.filterQuestionType] </s> add _, ok := dns.StringToType[req.filterQuestionType] </s> remove if len(params.Domain) != 0 || params.QuestionType != 0 { m := dns.Msg{} _ = m.Unpack(entry.Question) if params.QuestionType != 0 { if m.Question[0].Qtype != params.QuestionType { return false } } if len(params.Domain) != 0 && params.StrictMatchDomain { if m.Question[0].Name != params.Domain { return false } } else if len(params.Domain) != 0 { if strings.Index(m.Question[0].Name, params.Domain) == -1 { return false } </s> add if len(params.QuestionType) != 0 { if entry.QType != params.QuestionType { return false </s> remove if len(params.Client) != 0 && params.StrictMatchClient { if entry.IP != params.Client { </s> add if len(params.Domain) != 0 { if (params.StrictMatchDomain && entry.QHost != params.Domain) || (!params.StrictMatchDomain && strings.Index(entry.QHost, params.Domain) == -1) { </s> remove } else if len(params.Client) != 0 { if strings.Index(entry.IP, params.Client) == -1 { </s> add } if len(params.Client) != 0 { if (params.StrictMatchClient && entry.IP != params.Client) || (!params.StrictMatchClient && strings.Index(entry.IP, params.Client) == -1) { </s> remove if len(entry.Question) == 0 { continue } q = new(dns.Msg) if err := q.Unpack(entry.Question); err != nil { log.Tracef("q.Unpack(): %s", err) continue } if len(q.Question) != 1 { log.Tracef("len(q.Question) != 1") continue } </s> add
params.QuestionType = req.filterQuestionType
if !ok { httpError(r, w, http.StatusBadRequest, "invalid question_type") return } params.QuestionType = req.filterQuestionType } if len(req.filterResponseStatus) != 0 { switch req.filterResponseStatus { case "filtered":
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
* querylog: major refactor: change on-disk format and API speed up decoding speed up search compatible with previous format (when not searching)
https://github.com/AdguardTeam/AdGuardHome/commit/2f5d6593f2d9841f9c18b9ac60a554af60a34a6b
querylog/qlog_http.go
"bufio" "bytes" "compress/gzip" "encoding/json" "io" "os" "strconv" "strings" "time"
</s> remove m := d[0] </s> add mdata := d["data"].([]map[string]interface{}) m := mdata[0] </s> remove return entries, 0 </s> add return entries, time.Time{}, 0 </s> remove entries, total = l.readFromFile(params) </s> add entries, oldest, total = l.readFromFile(params)
"encoding/base64"
"bufio" "bytes" "compress/gzip" "encoding/base64" "encoding/json" "io" "os" "strconv" "strings" "time"
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
* querylog: major refactor: change on-disk format and API speed up decoding speed up search compatible with previous format (when not searching)
https://github.com/AdguardTeam/AdGuardHome/commit/2f5d6593f2d9841f9c18b9ac60a554af60a34a6b
querylog/querylog_file.go
"encoding/base64" "encoding/json" "io" "os" "strings" "time" "github.com/AdguardTeam/AdGuardHome/dnsfilter"
</s> remove m := d[0] </s> add mdata := d["data"].([]map[string]interface{}) m := mdata[0] </s> remove if len(entry.Question) == 0 { continue } q = new(dns.Msg) if err := q.Unpack(entry.Question); err != nil { log.Tracef("q.Unpack(): %s", err) continue } if len(q.Question) != 1 { log.Tracef("len(q.Question) != 1") continue } </s> add
"strconv"
"encoding/base64" "encoding/json" "io" "os" "strconv" "strings" "time" "github.com/AdguardTeam/AdGuardHome/dnsfilter"
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
* querylog: major refactor: change on-disk format and API speed up decoding speed up search compatible with previous format (when not searching)
https://github.com/AdguardTeam/AdGuardHome/commit/2f5d6593f2d9841f9c18b9ac60a554af60a34a6b
querylog/querylog_file.go
"time" "github.com/AdguardTeam/golibs/log" "github.com/miekg/dns" ) const enableGzip = false const maxEntrySize = 1000
</s> remove r.searching = false </s> add r.seeking = false </s> remove if r.latest { r.olderThan = r.now.UnixNano() } </s> add r.count = 0 </s> remove r.searching = false </s> add r.seeking = false </s> remove func (l *queryLog) getData(params getDataParams) []map[string]interface{} { </s> add func (l *queryLog) getData(params getDataParams) map[string]interface{} {
"github.com/AdguardTeam/AdGuardHome/dnsfilter"
"time" "github.com/AdguardTeam/AdGuardHome/dnsfilter" "github.com/AdguardTeam/golibs/log" "github.com/miekg/dns" ) const enableGzip = false const maxEntrySize = 1000
[ "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
* querylog: major refactor: change on-disk format and API speed up decoding speed up search compatible with previous format (when not searching)
https://github.com/AdguardTeam/AdGuardHome/commit/2f5d6593f2d9841f9c18b9ac60a554af60a34a6b
querylog/querylog_file.go
"github.com/AdguardTeam/AdGuardHome/dnsfilter" "github.com/AdguardTeam/golibs/log" ) const enableGzip = false const maxEntrySize = 1000
</s> remove r.searching = false </s> add r.seeking = false </s> remove if r.latest { r.olderThan = r.now.UnixNano() } </s> add r.count = 0 </s> remove r.searching = false </s> add r.seeking = false </s> remove func (l *queryLog) getData(params getDataParams) []map[string]interface{} { </s> add func (l *queryLog) getData(params getDataParams) map[string]interface{} {
"github.com/miekg/dns"
"github.com/AdguardTeam/AdGuardHome/dnsfilter" "github.com/AdguardTeam/golibs/log" "github.com/miekg/dns" ) const enableGzip = false const maxEntrySize = 1000
[ "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
* querylog: major refactor: change on-disk format and API speed up decoding speed up search compatible with previous format (when not searching)
https://github.com/AdguardTeam/AdGuardHome/commit/2f5d6593f2d9841f9c18b9ac60a554af60a34a6b
querylog/querylog_file.go
} // Reader is the DB reader context type Reader struct { ql *queryLog f *os.File reader *bufio.Reader // reads file line by line now time.Time validFrom int64 // UNIX time (ns)
</s> remove QuestionType uint16 // filter by question type </s> add QuestionType string // filter by question type </s> remove searching bool // we're seaching for an entry with exact time stamp </s> add seeking bool // we're seaching for an entry with exact time stamp </s> remove // maximum data chunks to parse when filtering entries maxFilteringChunks = 10 </s> add // maximum entries to parse when searching maxSearchEntries = 50000
ql *queryLog search *getDataParams
} // Reader is the DB reader context type Reader struct { ql *queryLog search *getDataParams f *os.File reader *bufio.Reader // reads file line by line now time.Time validFrom int64 // UNIX time (ns)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
* querylog: major refactor: change on-disk format and API speed up decoding speed up search compatible with previous format (when not searching)
https://github.com/AdguardTeam/AdGuardHome/commit/2f5d6593f2d9841f9c18b9ac60a554af60a34a6b
querylog/querylog_file.go
now time.Time validFrom int64 // UNIX time (ns) olderThan int64 // UNIX time (ns) files []string ifile int
</s> remove ql *queryLog </s> add ql *queryLog search *getDataParams </s> remove // Total returns the total number of items func (r *Reader) Total() int { return 0 </s> add // Total returns the total number of processed items func (r *Reader) Total() uint64 { return r.count } // Oldest returns the time of the oldest processed entry func (r *Reader) Oldest() time.Time { return r.oldest </s> remove searching bool // we're seaching for an entry with exact time stamp </s> add seeking bool // we're seaching for an entry with exact time stamp </s> remove func (r *Reader) BeginRead(olderThan time.Time, count uint64) { </s> add func (r *Reader) BeginRead(olderThan time.Time, count uint64, search *getDataParams) { </s> remove if len(params.Domain) != 0 && params.StrictMatchDomain { params.Domain = params.Domain + "." } </s> add var oldest time.Time
oldest time.Time
now time.Time validFrom int64 // UNIX time (ns) olderThan int64 // UNIX time (ns) oldest time.Time files []string ifile int
[ "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
* querylog: major refactor: change on-disk format and API speed up decoding speed up search compatible with previous format (when not searching)
https://github.com/AdguardTeam/AdGuardHome/commit/2f5d6593f2d9841f9c18b9ac60a554af60a34a6b
querylog/querylog_file.go
count uint64 // counter for returned elements latest bool // return the latest entries filePrepared bool searching bool // we're seaching for an entry with exact time stamp fseeker fileSeeker // file seeker object fpos uint64 // current file offset nSeekRequests uint32 // number of Seek() requests made (finding a new line doesn't count) }
</s> remove var q *dns.Msg </s> add </s> remove // Total returns the total number of items func (r *Reader) Total() int { return 0 </s> add // Total returns the total number of processed items func (r *Reader) Total() uint64 { return r.count } // Oldest returns the time of the oldest processed entry func (r *Reader) Oldest() time.Time { return r.oldest </s> remove func (r *Reader) BeginRead(olderThan time.Time, count uint64) { </s> add func (r *Reader) BeginRead(olderThan time.Time, count uint64, search *getDataParams) { </s> remove ql *queryLog </s> add ql *queryLog search *getDataParams
seeking bool // we're seaching for an entry with exact time stamp
count uint64 // counter for returned elements latest bool // return the latest entries filePrepared bool seeking bool // we're seaching for an entry with exact time stamp fseeker fileSeeker // file seeker object fpos uint64 // current file offset nSeekRequests uint32 // number of Seek() requests made (finding a new line doesn't count) }
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
* querylog: major refactor: change on-disk format and API speed up decoding speed up search compatible with previous format (when not searching)
https://github.com/AdguardTeam/AdGuardHome/commit/2f5d6593f2d9841f9c18b9ac60a554af60a34a6b
querylog/querylog_file.go
fpos uint64 // current file offset nSeekRequests uint32 // number of Seek() requests made (finding a new line doesn't count) } type fileSeeker struct { target uint64 // target value pos uint64 // current offset, may be adjusted by user for increased accuracy
</s> remove searching bool // we're seaching for an entry with exact time stamp </s> add seeking bool // we're seaching for an entry with exact time stamp </s> remove QuestionType uint16 // filter by question type </s> add QuestionType string // filter by question type </s> remove ql *queryLog </s> add ql *queryLog search *getDataParams </s> remove // Total returns the total number of items func (r *Reader) Total() int { return 0 </s> add // Total returns the total number of processed items func (r *Reader) Total() uint64 { return r.count } // Oldest returns the time of the oldest processed entry func (r *Reader) Oldest() time.Time { return r.oldest </s> remove return entries, total </s> add return entries, oldest, int(total)
timecnt uint64
fpos uint64 // current file offset nSeekRequests uint32 // number of Seek() requests made (finding a new line doesn't count) timecnt uint64 } type fileSeeker struct { target uint64 // target value pos uint64 // current offset, may be adjusted by user for increased accuracy
[ "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
* querylog: major refactor: change on-disk format and API speed up decoding speed up search compatible with previous format (when not searching)
https://github.com/AdguardTeam/AdGuardHome/commit/2f5d6593f2d9841f9c18b9ac60a554af60a34a6b
querylog/querylog_file.go
var perunit time.Duration if r.count > 0 { perunit = elapsed / time.Duration(r.count) } log.Debug("querylog: read %d entries in %v, %v/entry, seek-reqs:%d", r.count, elapsed, perunit, r.nSeekRequests) if r.f != nil { r.f.Close() } }
</s> remove if len(entry.Question) == 0 { continue } q = new(dns.Msg) if err := q.Unpack(entry.Question); err != nil { log.Tracef("q.Unpack(): %s", err) continue } if len(q.Question) != 1 { log.Tracef("len(q.Question) != 1") continue } </s> add </s> remove return data </s> add var result = map[string]interface{}{} if len(entries) == getDataLimit { oldest = entries[0].Time } result["oldest"] = "" if !oldest.IsZero() { result["oldest"] = oldest.Format(time.RFC3339Nano) } result["data"] = data return result </s> remove strReader := strings.NewReader(string(b)) jd := json.NewDecoder(strReader) </s> add str := string(b) </s> remove // read data var entry logEntry err = jd.Decode(&entry) </s> add val := readJSONValue(str, "T") if len(val) == 0 { val = readJSONValue(str, "Time") } if len(val) == 0 { log.Debug("QueryLog: failed to decode") continue } tm, err := time.Parse(time.RFC3339, val) </s> remove var q []byte var a []byte var err error ip := getIPString(addr) if question == nil { </s> add if question == nil || len(question.Question) != 1 || len(question.Question[0].Name) == 0 || ip == nil {
log.Debug("querylog: read %d entries in %v, %v/entry, seek-reqs:%d time:%dus (%d%%)", r.count, elapsed, perunit, r.nSeekRequests, r.timecnt/1000, r.timecnt*100/uint64(elapsed.Nanoseconds()))
var perunit time.Duration if r.count > 0 { perunit = elapsed / time.Duration(r.count) } log.Debug("querylog: read %d entries in %v, %v/entry, seek-reqs:%d time:%dus (%d%%)", r.count, elapsed, perunit, r.nSeekRequests, r.timecnt/1000, r.timecnt*100/uint64(elapsed.Nanoseconds())) log.Debug("querylog: read %d entries in %v, %v/entry, seek-reqs:%d time:%dus (%d%%)", r.count, elapsed, perunit, r.nSeekRequests, r.timecnt/1000, r.timecnt*100/uint64(elapsed.Nanoseconds())) if r.f != nil { r.f.Close() } }
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
* querylog: major refactor: change on-disk format and API speed up decoding speed up search compatible with previous format (when not searching)
https://github.com/AdguardTeam/AdGuardHome/commit/2f5d6593f2d9841f9c18b9ac60a554af60a34a6b
querylog/querylog_file.go
// BeginRead - start reading // olderThan: stop returning entries when an entry with this time is reached // count: minimum number of entries to return func (r *Reader) BeginRead(olderThan time.Time, count uint64) { r.olderThan = olderThan.UnixNano() r.latest = olderThan.IsZero() r.limit = count if r.latest { r.olderThan = r.now.UnixNano()
</s> remove func (r *Reader) BeginReadPrev(olderThan time.Time, count uint64) { r.olderThan = olderThan.UnixNano() r.latest = olderThan.IsZero() </s> add func (r *Reader) BeginReadPrev(count uint64) { r.olderThan = r.oldest.UnixNano() r.oldest = time.Time{} r.latest = false </s> remove if r.latest { r.olderThan = r.now.UnixNano() } </s> add r.count = 0 </s> remove r.searching = false </s> add r.seeking = false </s> remove searching bool // we're seaching for an entry with exact time stamp </s> add seeking bool // we're seaching for an entry with exact time stamp
func (r *Reader) BeginRead(olderThan time.Time, count uint64, search *getDataParams) {
// BeginRead - start reading // olderThan: stop returning entries when an entry with this time is reached // count: minimum number of entries to return func (r *Reader) BeginRead(olderThan time.Time, count uint64, search *getDataParams) { r.olderThan = olderThan.UnixNano() r.latest = olderThan.IsZero() r.limit = count if r.latest { r.olderThan = r.now.UnixNano()
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
* querylog: major refactor: change on-disk format and API speed up decoding speed up search compatible with previous format (when not searching)
https://github.com/AdguardTeam/AdGuardHome/commit/2f5d6593f2d9841f9c18b9ac60a554af60a34a6b
querylog/querylog_file.go
// count: minimum number of entries to return func (r *Reader) BeginRead(olderThan time.Time, count uint64, search *getDataParams) { r.olderThan = olderThan.UnixNano() r.latest = olderThan.IsZero() r.limit = count if r.latest { r.olderThan = r.now.UnixNano() } r.filePrepared = false
</s> remove func (r *Reader) BeginRead(olderThan time.Time, count uint64) { </s> add func (r *Reader) BeginRead(olderThan time.Time, count uint64, search *getDataParams) { </s> remove func (r *Reader) BeginReadPrev(olderThan time.Time, count uint64) { r.olderThan = olderThan.UnixNano() r.latest = olderThan.IsZero() </s> add func (r *Reader) BeginReadPrev(count uint64) { r.olderThan = r.oldest.UnixNano() r.oldest = time.Time{} r.latest = false </s> remove if r.latest { r.olderThan = r.now.UnixNano() } </s> add r.count = 0 </s> remove r.searching = false </s> add r.seeking = false </s> remove // Total returns the total number of items func (r *Reader) Total() int { return 0 </s> add // Total returns the total number of processed items func (r *Reader) Total() uint64 { return r.count } // Oldest returns the time of the oldest processed entry func (r *Reader) Oldest() time.Time { return r.oldest
r.oldest = time.Time{} r.search = search
// count: minimum number of entries to return func (r *Reader) BeginRead(olderThan time.Time, count uint64, search *getDataParams) { r.olderThan = olderThan.UnixNano() r.latest = olderThan.IsZero() r.oldest = time.Time{} r.search = search r.limit = count if r.latest { r.olderThan = r.now.UnixNano() } r.filePrepared = false
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
* querylog: major refactor: change on-disk format and API speed up decoding speed up search compatible with previous format (when not searching)
https://github.com/AdguardTeam/AdGuardHome/commit/2f5d6593f2d9841f9c18b9ac60a554af60a34a6b
querylog/querylog_file.go
if r.latest { r.olderThan = r.now.UnixNano() } r.filePrepared = false r.searching = false } // BeginReadPrev - start reading the previous data chunk func (r *Reader) BeginReadPrev(olderThan time.Time, count uint64) { r.olderThan = olderThan.UnixNano()
</s> remove func (r *Reader) BeginReadPrev(olderThan time.Time, count uint64) { r.olderThan = olderThan.UnixNano() r.latest = olderThan.IsZero() </s> add func (r *Reader) BeginReadPrev(count uint64) { r.olderThan = r.oldest.UnixNano() r.oldest = time.Time{} r.latest = false </s> remove if r.latest { r.olderThan = r.now.UnixNano() } </s> add r.count = 0 </s> remove func (r *Reader) BeginRead(olderThan time.Time, count uint64) { </s> add func (r *Reader) BeginRead(olderThan time.Time, count uint64, search *getDataParams) { </s> remove r.searching = false </s> add r.seeking = false
r.seeking = false
if r.latest { r.olderThan = r.now.UnixNano() } r.filePrepared = false r.seeking = false } // BeginReadPrev - start reading the previous data chunk func (r *Reader) BeginReadPrev(olderThan time.Time, count uint64) { r.olderThan = olderThan.UnixNano()
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
* querylog: major refactor: change on-disk format and API speed up decoding speed up search compatible with previous format (when not searching)
https://github.com/AdguardTeam/AdGuardHome/commit/2f5d6593f2d9841f9c18b9ac60a554af60a34a6b
querylog/querylog_file.go
r.searching = false } // BeginReadPrev - start reading the previous data chunk func (r *Reader) BeginReadPrev(olderThan time.Time, count uint64) { r.olderThan = olderThan.UnixNano() r.latest = olderThan.IsZero() r.limit = count if r.latest { r.olderThan = r.now.UnixNano() }
</s> remove r.searching = false </s> add r.seeking = false </s> remove if r.latest { r.olderThan = r.now.UnixNano() } </s> add r.count = 0 </s> remove func (r *Reader) BeginRead(olderThan time.Time, count uint64) { </s> add func (r *Reader) BeginRead(olderThan time.Time, count uint64, search *getDataParams) { </s> remove r.searching = false </s> add r.seeking = false
func (r *Reader) BeginReadPrev(count uint64) { r.olderThan = r.oldest.UnixNano() r.oldest = time.Time{} r.latest = false
r.searching = false } // BeginReadPrev - start reading the previous data chunk func (r *Reader) BeginReadPrev(count uint64) { r.olderThan = r.oldest.UnixNano() r.oldest = time.Time{} r.latest = false func (r *Reader) BeginReadPrev(count uint64) { r.olderThan = r.oldest.UnixNano() r.oldest = time.Time{} r.latest = false func (r *Reader) BeginReadPrev(count uint64) { r.olderThan = r.oldest.UnixNano() r.oldest = time.Time{} r.latest = false r.limit = count if r.latest { r.olderThan = r.now.UnixNano() }
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
* querylog: major refactor: change on-disk format and API speed up decoding speed up search compatible with previous format (when not searching)
https://github.com/AdguardTeam/AdGuardHome/commit/2f5d6593f2d9841f9c18b9ac60a554af60a34a6b
querylog/querylog_file.go
func (r *Reader) BeginReadPrev(olderThan time.Time, count uint64) { r.olderThan = olderThan.UnixNano() r.latest = olderThan.IsZero() r.limit = count if r.latest { r.olderThan = r.now.UnixNano() } off := r.fpos - maxEntrySize*(r.limit+1) if int64(off) < maxEntrySize { off = 0 }
</s> remove func (r *Reader) BeginReadPrev(olderThan time.Time, count uint64) { r.olderThan = olderThan.UnixNano() r.latest = olderThan.IsZero() </s> add func (r *Reader) BeginReadPrev(count uint64) { r.olderThan = r.oldest.UnixNano() r.oldest = time.Time{} r.latest = false </s> remove r.searching = false </s> add r.seeking = false </s> remove func (r *Reader) BeginRead(olderThan time.Time, count uint64) { </s> add func (r *Reader) BeginRead(olderThan time.Time, count uint64, search *getDataParams) { </s> remove r.searching = false </s> add r.seeking = false
r.count = 0
func (r *Reader) BeginReadPrev(olderThan time.Time, count uint64) { r.olderThan = olderThan.UnixNano() r.latest = olderThan.IsZero() r.limit = count r.count = 0 r.count = 0 r.count = 0 off := r.fpos - maxEntrySize*(r.limit+1) if int64(off) < maxEntrySize { off = 0 }
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
* querylog: major refactor: change on-disk format and API speed up decoding speed up search compatible with previous format (when not searching)
https://github.com/AdguardTeam/AdGuardHome/commit/2f5d6593f2d9841f9c18b9ac60a554af60a34a6b
querylog/querylog_file.go
r.seekToNewLine() r.fseeker.pos = r.fpos r.filePrepared = true r.searching = false } // Perform binary seek // Return 0: success; 1: seek reqiured; -1: error func (fs *fileSeeker) seekBinary(cur uint64) int32 {
</s> remove r.searching = false </s> add r.seeking = false </s> remove r.searching = true </s> add r.seeking = true </s> remove func (r *Reader) BeginReadPrev(olderThan time.Time, count uint64) { r.olderThan = olderThan.UnixNano() r.latest = olderThan.IsZero() </s> add func (r *Reader) BeginReadPrev(count uint64) { r.olderThan = r.oldest.UnixNano() r.oldest = time.Time{} r.latest = false </s> remove t := entry.Time.UnixNano() if r.searching { </s> add if r.seeking { </s> remove if r.latest { r.olderThan = r.now.UnixNano() } </s> add r.count = 0
r.seeking = false
r.seekToNewLine() r.fseeker.pos = r.fpos r.filePrepared = true r.seeking = false } // Perform binary seek // Return 0: success; 1: seek reqiured; -1: error func (fs *fileSeeker) seekBinary(cur uint64) int32 {
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
* querylog: major refactor: change on-disk format and API speed up decoding speed up search compatible with previous format (when not searching)
https://github.com/AdguardTeam/AdGuardHome/commit/2f5d6593f2d9841f9c18b9ac60a554af60a34a6b
querylog/querylog_file.go
return false } } else { // start searching in file: we'll read the first chunk of data from the middle of file r.searching = true r.fseeker = fileSeeker{} r.fseeker.target = uint64(r.olderThan) r.fseeker.hi = fsize rc := r.fseeker.seekBinary(0) r.fpos = r.fseeker.pos
</s> remove r.searching = false </s> add r.seeking = false </s> remove r.searching = false </s> add r.seeking = false </s> remove func (r *Reader) BeginReadPrev(olderThan time.Time, count uint64) { r.olderThan = olderThan.UnixNano() r.latest = olderThan.IsZero() </s> add func (r *Reader) BeginReadPrev(count uint64) { r.olderThan = r.oldest.UnixNano() r.oldest = time.Time{} r.latest = false </s> remove r.searching = false </s> add r.seeking = false </s> remove t := entry.Time.UnixNano() if r.searching { </s> add if r.seeking {
r.seeking = true
return false } } else { // start searching in file: we'll read the first chunk of data from the middle of file r.seeking = true r.fseeker = fileSeeker{} r.fseeker.target = uint64(r.olderThan) r.fseeker.hi = fsize rc := r.fseeker.seekBinary(0) r.fpos = r.fseeker.pos
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
* querylog: major refactor: change on-disk format and API speed up decoding speed up search compatible with previous format (when not searching)
https://github.com/AdguardTeam/AdGuardHome/commit/2f5d6593f2d9841f9c18b9ac60a554af60a34a6b
querylog/querylog_file.go
} r.filePrepared = true } // open decoder b, err := r.reader.ReadBytes('\n') if err != nil { return nil } strReader := strings.NewReader(string(b))
</s> remove strReader := strings.NewReader(string(b)) jd := json.NewDecoder(strReader) </s> add str := string(b) </s> remove // read data var entry logEntry err = jd.Decode(&entry) </s> add val := readJSONValue(str, "T") if len(val) == 0 { val = readJSONValue(str, "Time") } if len(val) == 0 { log.Debug("QueryLog: failed to decode") continue } tm, err := time.Parse(time.RFC3339, val) </s> remove q, err = question.Pack() if err != nil { log.Printf("failed to pack question for querylog: %s", err) return } </s> add var a []byte var err error ip := getIPString(addr) </s> remove if len(entry.Question) == 0 { continue } q = new(dns.Msg) if err := q.Unpack(entry.Question); err != nil { log.Tracef("q.Unpack(): %s", err) continue } if len(q.Question) != 1 { log.Tracef("len(q.Question) != 1") continue } </s> add </s> remove var q []byte var a []byte var err error ip := getIPString(addr) if question == nil { </s> add if question == nil || len(question.Question) != 1 || len(question.Question[0].Name) == 0 || ip == nil {
} r.filePrepared = true } b, err := r.reader.ReadBytes('\n') if err != nil { return nil } strReader := strings.NewReader(string(b))
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
* querylog: major refactor: change on-disk format and API speed up decoding speed up search compatible with previous format (when not searching)
https://github.com/AdguardTeam/AdGuardHome/commit/2f5d6593f2d9841f9c18b9ac60a554af60a34a6b
querylog/querylog_file.go
b, err := r.reader.ReadBytes('\n') if err != nil { return nil } strReader := strings.NewReader(string(b)) jd := json.NewDecoder(strReader) // read data var entry logEntry err = jd.Decode(&entry) if err != nil {
</s> remove // read data var entry logEntry err = jd.Decode(&entry) </s> add val := readJSONValue(str, "T") if len(val) == 0 { val = readJSONValue(str, "Time") } if len(val) == 0 { log.Debug("QueryLog: failed to decode") continue } tm, err := time.Parse(time.RFC3339, val) </s> remove // open decoder </s> add </s> remove log.Debug("QueryLog: Failed to decode: %s", err) </s> add log.Debug("QueryLog: failed to decode") </s> remove q, err = question.Pack() if err != nil { log.Printf("failed to pack question for querylog: %s", err) return } </s> add var a []byte var err error ip := getIPString(addr) </s> remove if len(entry.Question) == 0 { continue } q = new(dns.Msg) if err := q.Unpack(entry.Question); err != nil { log.Tracef("q.Unpack(): %s", err) continue } if len(q.Question) != 1 { log.Tracef("len(q.Question) != 1") continue } </s> add
str := string(b)
b, err := r.reader.ReadBytes('\n') if err != nil { return nil } str := string(b) str := string(b) // read data var entry logEntry err = jd.Decode(&entry) if err != nil {
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
* querylog: major refactor: change on-disk format and API speed up decoding speed up search compatible with previous format (when not searching)
https://github.com/AdguardTeam/AdGuardHome/commit/2f5d6593f2d9841f9c18b9ac60a554af60a34a6b
querylog/querylog_file.go
} strReader := strings.NewReader(string(b)) jd := json.NewDecoder(strReader) // read data var entry logEntry err = jd.Decode(&entry) if err != nil { log.Debug("QueryLog: Failed to decode: %s", err) continue }
</s> remove log.Debug("QueryLog: Failed to decode: %s", err) </s> add log.Debug("QueryLog: failed to decode") </s> remove strReader := strings.NewReader(string(b)) jd := json.NewDecoder(strReader) </s> add str := string(b) </s> remove if len(entry.Question) == 0 { continue } q = new(dns.Msg) if err := q.Unpack(entry.Question); err != nil { log.Tracef("q.Unpack(): %s", err) continue } if len(q.Question) != 1 { log.Tracef("len(q.Question) != 1") continue } </s> add </s> remove t := entry.Time.UnixNano() if r.searching { </s> add if r.seeking { </s> remove q, err = question.Pack() if err != nil { log.Printf("failed to pack question for querylog: %s", err) return } </s> add var a []byte var err error ip := getIPString(addr)
val := readJSONValue(str, "T") if len(val) == 0 { val = readJSONValue(str, "Time") } if len(val) == 0 { log.Debug("QueryLog: failed to decode") continue } tm, err := time.Parse(time.RFC3339, val)
} strReader := strings.NewReader(string(b)) jd := json.NewDecoder(strReader) val := readJSONValue(str, "T") if len(val) == 0 { val = readJSONValue(str, "Time") } if len(val) == 0 { log.Debug("QueryLog: failed to decode") continue } tm, err := time.Parse(time.RFC3339, val) val := readJSONValue(str, "T") if len(val) == 0 { val = readJSONValue(str, "Time") } if len(val) == 0 { log.Debug("QueryLog: failed to decode") continue } tm, err := time.Parse(time.RFC3339, val) val := readJSONValue(str, "T") if len(val) == 0 { val = readJSONValue(str, "Time") } if len(val) == 0 { log.Debug("QueryLog: failed to decode") continue } tm, err := time.Parse(time.RFC3339, val) if err != nil { log.Debug("QueryLog: Failed to decode: %s", err) continue }
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
* querylog: major refactor: change on-disk format and API speed up decoding speed up search compatible with previous format (when not searching)
https://github.com/AdguardTeam/AdGuardHome/commit/2f5d6593f2d9841f9c18b9ac60a554af60a34a6b
querylog/querylog_file.go
// read data var entry logEntry err = jd.Decode(&entry) if err != nil { log.Debug("QueryLog: Failed to decode: %s", err) continue } t := entry.Time.UnixNano() if r.searching {
</s> remove // read data var entry logEntry err = jd.Decode(&entry) </s> add val := readJSONValue(str, "T") if len(val) == 0 { val = readJSONValue(str, "Time") } if len(val) == 0 { log.Debug("QueryLog: failed to decode") continue } tm, err := time.Parse(time.RFC3339, val) </s> remove t := entry.Time.UnixNano() if r.searching { </s> add if r.seeking { </s> remove strReader := strings.NewReader(string(b)) jd := json.NewDecoder(strReader) </s> add str := string(b) </s> remove if len(entry.Question) == 0 { continue } q = new(dns.Msg) if err := q.Unpack(entry.Question); err != nil { log.Tracef("q.Unpack(): %s", err) continue } if len(q.Question) != 1 { log.Tracef("len(q.Question) != 1") continue } </s> add </s> remove q, err = question.Pack() if err != nil { log.Printf("failed to pack question for querylog: %s", err) return } </s> add var a []byte var err error ip := getIPString(addr)
log.Debug("QueryLog: failed to decode")
// read data var entry logEntry err = jd.Decode(&entry) if err != nil { log.Debug("QueryLog: failed to decode") continue } t := entry.Time.UnixNano() if r.searching {
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
* querylog: major refactor: change on-disk format and API speed up decoding speed up search compatible with previous format (when not searching)
https://github.com/AdguardTeam/AdGuardHome/commit/2f5d6593f2d9841f9c18b9ac60a554af60a34a6b
querylog/querylog_file.go
log.Debug("QueryLog: failed to decode") continue } if r.seeking { r.reader = nil
</s> remove log.Debug("QueryLog: Failed to decode: %s", err) </s> add log.Debug("QueryLog: failed to decode") </s> remove t := entry.Time.UnixNano() if r.searching { </s> add if r.seeking { </s> remove // read data var entry logEntry err = jd.Decode(&entry) </s> add val := readJSONValue(str, "T") if len(val) == 0 { val = readJSONValue(str, "Time") } if len(val) == 0 { log.Debug("QueryLog: failed to decode") continue } tm, err := time.Parse(time.RFC3339, val) </s> remove if len(entry.Question) == 0 { continue } q = new(dns.Msg) if err := q.Unpack(entry.Question); err != nil { log.Tracef("q.Unpack(): %s", err) continue } if len(q.Question) != 1 { log.Tracef("len(q.Question) != 1") continue } </s> add
t := tm.UnixNano()
log.Debug("QueryLog: failed to decode") continue } t := tm.UnixNano() if r.seeking { r.reader = nil
[ "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
* querylog: major refactor: change on-disk format and API speed up decoding speed up search compatible with previous format (when not searching)
https://github.com/AdguardTeam/AdGuardHome/commit/2f5d6593f2d9841f9c18b9ac60a554af60a34a6b
querylog/querylog_file.go
log.Debug("QueryLog: Failed to decode: %s", err) continue } t := entry.Time.UnixNano() if r.searching { r.reader = nil rr := r.fseeker.seekBinary(uint64(t)) r.fpos = r.fseeker.pos if rr < 0 {
</s> remove log.Debug("QueryLog: Failed to decode: %s", err) </s> add log.Debug("QueryLog: failed to decode") </s> remove // read data var entry logEntry err = jd.Decode(&entry) </s> add val := readJSONValue(str, "T") if len(val) == 0 { val = readJSONValue(str, "Time") } if len(val) == 0 { log.Debug("QueryLog: failed to decode") continue } tm, err := time.Parse(time.RFC3339, val) </s> remove r.searching = false </s> add r.seeking = false
if r.seeking {
log.Debug("QueryLog: Failed to decode: %s", err) continue } if r.seeking { if r.seeking { r.reader = nil rr := r.fseeker.seekBinary(uint64(t)) r.fpos = r.fseeker.pos if rr < 0 {
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
* querylog: major refactor: change on-disk format and API speed up decoding speed up search compatible with previous format (when not searching)
https://github.com/AdguardTeam/AdGuardHome/commit/2f5d6593f2d9841f9c18b9ac60a554af60a34a6b
querylog/querylog_file.go
return nil } else if rr == 0 { // We found the target entry. // We'll start reading the previous chunk of data. r.searching = false off := r.fpos - (maxEntrySize * (r.limit + 1)) if int64(off) < maxEntrySize { off = 0 }
</s> remove if r.latest { r.olderThan = r.now.UnixNano() } </s> add r.count = 0 </s> remove r.searching = false </s> add r.seeking = false </s> remove func (r *Reader) BeginReadPrev(olderThan time.Time, count uint64) { r.olderThan = olderThan.UnixNano() r.latest = olderThan.IsZero() </s> add func (r *Reader) BeginReadPrev(count uint64) { r.olderThan = r.oldest.UnixNano() r.oldest = time.Time{} r.latest = false </s> remove r.searching = true </s> add r.seeking = true </s> remove t := entry.Time.UnixNano() if r.searching { </s> add if r.seeking {
r.seeking = false
return nil } else if rr == 0 { // We found the target entry. // We'll start reading the previous chunk of data. r.seeking = false off := r.fpos - (maxEntrySize * (r.limit + 1)) if int64(off) < maxEntrySize { off = 0 }
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
* querylog: major refactor: change on-disk format and API speed up decoding speed up search compatible with previous format (when not searching)
https://github.com/AdguardTeam/AdGuardHome/commit/2f5d6593f2d9841f9c18b9ac60a554af60a34a6b
querylog/querylog_file.go
} if t < r.validFrom { continue } if t >= r.olderThan { return nil }
</s> remove t := entry.Time.UnixNano() if r.searching { </s> add if r.seeking { </s> remove log.Debug("QueryLog: Failed to decode: %s", err) </s> add log.Debug("QueryLog: failed to decode") </s> remove if r.latest { r.olderThan = r.now.UnixNano() } </s> add r.count = 0 </s> remove total++ if first { first = false olderThan = entry.Time } </s> add
if r.oldest.IsZero() { r.oldest = tm }
} if r.oldest.IsZero() { r.oldest = tm } if t < r.validFrom { continue } if t >= r.olderThan { return nil }
[ "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
* querylog: major refactor: change on-disk format and API speed up decoding speed up search compatible with previous format (when not searching)
https://github.com/AdguardTeam/AdGuardHome/commit/2f5d6593f2d9841f9c18b9ac60a554af60a34a6b
querylog/querylog_file.go
return nil } r.count++ return &entry } } // Total returns the total number of items func (r *Reader) Total() int {
</s> remove // Total returns the total number of items func (r *Reader) Total() int { return 0 </s> add // Total returns the total number of processed items func (r *Reader) Total() uint64 { return r.count } // Oldest returns the time of the oldest processed entry func (r *Reader) Oldest() time.Time { return r.oldest </s> remove func (r *Reader) BeginReadPrev(olderThan time.Time, count uint64) { r.olderThan = olderThan.UnixNano() r.latest = olderThan.IsZero() </s> add func (r *Reader) BeginReadPrev(count uint64) { r.olderThan = r.oldest.UnixNano() r.oldest = time.Time{} r.latest = false </s> remove r.searching = false </s> add r.seeking = false </s> remove func (r *Reader) BeginRead(olderThan time.Time, count uint64) { </s> add func (r *Reader) BeginRead(olderThan time.Time, count uint64, search *getDataParams) {
if !r.applySearch(str) { continue } st := time.Now() var ent logEntry decode(&ent, str) r.timecnt += uint64(time.Now().Sub(st).Nanoseconds()) return &ent
return nil } r.count++ if !r.applySearch(str) { continue } st := time.Now() var ent logEntry decode(&ent, str) r.timecnt += uint64(time.Now().Sub(st).Nanoseconds()) return &ent } } // Total returns the total number of items func (r *Reader) Total() int {
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
* querylog: major refactor: change on-disk format and API speed up decoding speed up search compatible with previous format (when not searching)
https://github.com/AdguardTeam/AdGuardHome/commit/2f5d6593f2d9841f9c18b9ac60a554af60a34a6b
querylog/querylog_file.go
return &entry } } // Total returns the total number of items func (r *Reader) Total() int { return 0 }
</s> remove return &entry </s> add if !r.applySearch(str) { continue } st := time.Now() var ent logEntry decode(&ent, str) r.timecnt += uint64(time.Now().Sub(st).Nanoseconds()) return &ent </s> remove func (r *Reader) BeginReadPrev(olderThan time.Time, count uint64) { r.olderThan = olderThan.UnixNano() r.latest = olderThan.IsZero() </s> add func (r *Reader) BeginReadPrev(count uint64) { r.olderThan = r.oldest.UnixNano() r.oldest = time.Time{} r.latest = false </s> remove r.searching = false </s> add r.seeking = false </s> remove func (r *Reader) BeginRead(olderThan time.Time, count uint64) { </s> add func (r *Reader) BeginRead(olderThan time.Time, count uint64, search *getDataParams) {
// Total returns the total number of processed items func (r *Reader) Total() uint64 { return r.count } // Oldest returns the time of the oldest processed entry func (r *Reader) Oldest() time.Time { return r.oldest
return &entry } } // Total returns the total number of processed items func (r *Reader) Total() uint64 { return r.count } // Oldest returns the time of the oldest processed entry func (r *Reader) Oldest() time.Time { return r.oldest // Total returns the total number of processed items func (r *Reader) Total() uint64 { return r.count } // Oldest returns the time of the oldest processed entry func (r *Reader) Oldest() time.Time { return r.oldest // Total returns the total number of processed items func (r *Reader) Total() uint64 { return r.count } // Oldest returns the time of the oldest processed entry func (r *Reader) Oldest() time.Time { return r.oldest }
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep" ]
* querylog: major refactor: change on-disk format and API speed up decoding speed up search compatible with previous format (when not searching)
https://github.com/AdguardTeam/AdGuardHome/commit/2f5d6593f2d9841f9c18b9ac60a554af60a34a6b
querylog/querylog_file.go
params := getDataParams{ OlderThan: time.Now(), } d := l.getData(params) m := d[0] mq := m["question"].(map[string]interface{}) assert.True(t, mq["host"].(string) == "example.org") }
</s> remove if len(params.Domain) != 0 || params.QuestionType != 0 { m := dns.Msg{} _ = m.Unpack(entry.Question) if params.QuestionType != 0 { if m.Question[0].Qtype != params.QuestionType { return false } } if len(params.Domain) != 0 && params.StrictMatchDomain { if m.Question[0].Name != params.Domain { return false } } else if len(params.Domain) != 0 { if strings.Index(m.Question[0].Name, params.Domain) == -1 { return false } </s> add if len(params.QuestionType) != 0 { if entry.QType != params.QuestionType { return false </s> remove if first || len(entries) == getDataLimit { </s> add if r.Total() == 0 || len(entries) == getDataLimit { </s> remove totalChunks++ r.BeginReadPrev(olderThan, getDataLimit) </s> add total += r.Total() oldest = r.Oldest() r.BeginReadPrev(getDataLimit) </s> remove total++ if first { first = false olderThan = entry.Time } </s> add </s> remove if len(params.Client) != 0 && params.StrictMatchClient { if entry.IP != params.Client { </s> add if len(params.Domain) != 0 { if (params.StrictMatchDomain && entry.QHost != params.Domain) || (!params.StrictMatchDomain && strings.Index(entry.QHost, params.Domain) == -1) {
mdata := d["data"].([]map[string]interface{}) m := mdata[0]
params := getDataParams{ OlderThan: time.Now(), } d := l.getData(params) mdata := d["data"].([]map[string]interface{}) m := mdata[0] mq := m["question"].(map[string]interface{}) assert.True(t, mq["host"].(string) == "example.org") }
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep" ]
* querylog: major refactor: change on-disk format and API speed up decoding speed up search compatible with previous format (when not searching)
https://github.com/AdguardTeam/AdGuardHome/commit/2f5d6593f2d9841f9c18b9ac60a554af60a34a6b
querylog/querylog_test.go
go 1.16 require ( github.com/AdguardTeam/dnsproxy v0.38.3 github.com/AdguardTeam/golibs v0.8.0 github.com/AdguardTeam/urlfilter v0.14.6 github.com/NYTimes/gziphandler v1.1.1 github.com/ameshkov/dnscrypt/v2 v2.1.3 github.com/digineo/go-ipset/v2 v2.2.1
</s>
github.com/AdguardTeam/dnsproxy v0.39.0
go 1.16 require ( github.com/AdguardTeam/dnsproxy v0.39.0 github.com/AdguardTeam/golibs v0.8.0 github.com/AdguardTeam/urlfilter v0.14.6 github.com/NYTimes/gziphandler v1.1.1 github.com/ameshkov/dnscrypt/v2 v2.1.3 github.com/digineo/go-ipset/v2 v2.2.1
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: 2799 trusted proxy Merge in DNS/adguard-home from 2799-trusted-proxy to master Updates #2799. Squashed commit of the following: commit 708a06b30116126a575767ea70865a6de90de774 Author: Eugene Burkov <[email protected]> Date: Fri Jul 23 18:56:16 2021 +0300 all: add trusted proxy mechanism
https://github.com/AdguardTeam/AdGuardHome/commit/2f661df88cf4a11a86c1fbfb8dae9b2cd79ada09
go.mod
github.com/AdguardTeam/dhcp v0.0.0-20210519141215-51808c73c0bf h1:gc042VRSIRSUzZ+Px6xQCRWNJZTaPkomisDfUZmoFNk= github.com/AdguardTeam/dhcp v0.0.0-20210519141215-51808c73c0bf/go.mod h1:TKl4jN3Voofo4UJIicyNhWGp/nlQqQkFxmwIFTvBkKI= github.com/AdguardTeam/dnsproxy v0.38.3 h1:DvycTEOn2wuHmY+HE5XL4EnCV2EVbpREpbgZB06IJ0I= github.com/AdguardTeam/dnsproxy v0.38.3/go.mod h1:aNXKNdTyKfgAG2OS712SYSaGIM9AasZsZxfiY4YiR/0= github.com/AdguardTeam/golibs v0.4.0/go.mod h1:skKsDKIBB7kkFflLJBpfGX+G8QFTx0WKUzB6TIgtUj4= github.com/AdguardTeam/golibs v0.4.2/go.mod h1:skKsDKIBB7kkFflLJBpfGX+G8QFTx0WKUzB6TIgtUj4= github.com/AdguardTeam/golibs v0.8.0 h1:rHo+yIgT2fivFG0yW2Cwk/DPc2+t/Aw6QvzPpiIFre0= github.com/AdguardTeam/golibs v0.8.0/go.mod h1:skKsDKIBB7kkFflLJBpfGX+G8QFTx0WKUzB6TIgtUj4= github.com/AdguardTeam/gomitmproxy v0.2.0/go.mod h1:Qdv0Mktnzer5zpdpi5rAwixNJzW2FN91LjKJCkVbYGU=
</s> remove github.com/AdguardTeam/dnsproxy v0.38.3 </s> add github.com/AdguardTeam/dnsproxy v0.39.0
github.com/AdguardTeam/dnsproxy v0.39.0 h1:5/PN2mpUeCTWtvqXUbSPTMJSOad4lJscPzm+C2f4jB4= github.com/AdguardTeam/dnsproxy v0.39.0/go.mod h1:aNXKNdTyKfgAG2OS712SYSaGIM9AasZsZxfiY4YiR/0=
github.com/AdguardTeam/dhcp v0.0.0-20210519141215-51808c73c0bf h1:gc042VRSIRSUzZ+Px6xQCRWNJZTaPkomisDfUZmoFNk= github.com/AdguardTeam/dhcp v0.0.0-20210519141215-51808c73c0bf/go.mod h1:TKl4jN3Voofo4UJIicyNhWGp/nlQqQkFxmwIFTvBkKI= github.com/AdguardTeam/dnsproxy v0.38.3 h1:DvycTEOn2wuHmY+HE5XL4EnCV2EVbpREpbgZB06IJ0I= github.com/AdguardTeam/dnsproxy v0.38.3/go.mod h1:aNXKNdTyKfgAG2OS712SYSaGIM9AasZsZxfiY4YiR/0= github.com/AdguardTeam/dnsproxy v0.39.0 h1:5/PN2mpUeCTWtvqXUbSPTMJSOad4lJscPzm+C2f4jB4= github.com/AdguardTeam/dnsproxy v0.39.0/go.mod h1:aNXKNdTyKfgAG2OS712SYSaGIM9AasZsZxfiY4YiR/0= github.com/AdguardTeam/golibs v0.4.0/go.mod h1:skKsDKIBB7kkFflLJBpfGX+G8QFTx0WKUzB6TIgtUj4= github.com/AdguardTeam/golibs v0.4.2/go.mod h1:skKsDKIBB7kkFflLJBpfGX+G8QFTx0WKUzB6TIgtUj4= github.com/AdguardTeam/golibs v0.8.0 h1:rHo+yIgT2fivFG0yW2Cwk/DPc2+t/Aw6QvzPpiIFre0= github.com/AdguardTeam/golibs v0.8.0/go.mod h1:skKsDKIBB7kkFflLJBpfGX+G8QFTx0WKUzB6TIgtUj4= github.com/AdguardTeam/gomitmproxy v0.2.0/go.mod h1:Qdv0Mktnzer5zpdpi5rAwixNJzW2FN91LjKJCkVbYGU=
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
Pull request: 2799 trusted proxy Merge in DNS/adguard-home from 2799-trusted-proxy to master Updates #2799. Squashed commit of the following: commit 708a06b30116126a575767ea70865a6de90de774 Author: Eugene Burkov <[email protected]> Date: Fri Jul 23 18:56:16 2021 +0300 all: add trusted proxy mechanism
https://github.com/AdguardTeam/AdGuardHome/commit/2f661df88cf4a11a86c1fbfb8dae9b2cd79ada09
go.sum
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/hugelgupf/socketpair v0.0.0-20190730060125-05d35a94e714 h1:/jC7qQFrv8CrSJVmaolDVOxTfS9kc36uB6H40kdbQq8= github.com/hugelgupf/socketpair v0.0.0-20190730060125-05d35a94e714/go.mod h1:2Goc3h8EklBH5mspfHFxBnEoURQCGzQQH1ga9Myjvis= github.com/jellevandenhooff/dkim v0.0.0-20150330215556-f50fe3d243e1/go.mod h1:E0B/fFc00Y+Rasa88328GlI/XbtyysCtTHZS8h7IrBU= github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= github.com/joomcode/errorx v1.0.1/go.mod h1:kgco15ekB6cs+4Xjzo7SPeXzx38PbJzBwbnu9qfVNHQ= github.com/joomcode/errorx v1.0.3 h1:3e1mi0u7/HTPNdg6d6DYyKGBhA5l9XpsfuVE29NxnWw= github.com/joomcode/errorx v1.0.3/go.mod h1:eQzdtdlNyN7etw6YCS4W4+lu442waxZYw5yvz0ULrRo= github.com/josharian/native v0.0.0-20200817173448-b6b71def0850 h1:uhL5Gw7BINiiPAo24A2sxkcDI0Jt/sqp1v5xQCniEFA=
</s>
github.com/jessevdk/go-flags v1.4.0 h1:4IU2WS7AumrZ/40jfhf4QVDMsQwqA7VEHozFRrGARJA=
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/hugelgupf/socketpair v0.0.0-20190730060125-05d35a94e714 h1:/jC7qQFrv8CrSJVmaolDVOxTfS9kc36uB6H40kdbQq8= github.com/hugelgupf/socketpair v0.0.0-20190730060125-05d35a94e714/go.mod h1:2Goc3h8EklBH5mspfHFxBnEoURQCGzQQH1ga9Myjvis= github.com/jellevandenhooff/dkim v0.0.0-20150330215556-f50fe3d243e1/go.mod h1:E0B/fFc00Y+Rasa88328GlI/XbtyysCtTHZS8h7IrBU= github.com/jessevdk/go-flags v1.4.0 h1:4IU2WS7AumrZ/40jfhf4QVDMsQwqA7VEHozFRrGARJA= github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= github.com/joomcode/errorx v1.0.1/go.mod h1:kgco15ekB6cs+4Xjzo7SPeXzx38PbJzBwbnu9qfVNHQ= github.com/joomcode/errorx v1.0.3 h1:3e1mi0u7/HTPNdg6d6DYyKGBhA5l9XpsfuVE29NxnWw= github.com/joomcode/errorx v1.0.3/go.mod h1:eQzdtdlNyN7etw6YCS4W4+lu442waxZYw5yvz0ULrRo= github.com/josharian/native v0.0.0-20200817173448-b6b71def0850 h1:uhL5Gw7BINiiPAo24A2sxkcDI0Jt/sqp1v5xQCniEFA=
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
Pull request: 2799 trusted proxy Merge in DNS/adguard-home from 2799-trusted-proxy to master Updates #2799. Squashed commit of the following: commit 708a06b30116126a575767ea70865a6de90de774 Author: Eugene Burkov <[email protected]> Date: Fri Jul 23 18:56:16 2021 +0300 all: add trusted proxy mechanism
https://github.com/AdguardTeam/AdGuardHome/commit/2f661df88cf4a11a86c1fbfb8dae9b2cd79ada09
go.sum
DisallowedClients []string `yaml:"disallowed_clients"` // IP addresses of clients that should be blocked BlockedHosts []string `yaml:"blocked_hosts"` // hosts that should be blocked // DNS cache settings // -- CacheSize uint32 `yaml:"cache_size"` // DNS cache size (in bytes)
</s>
// TrustedProxies is the list of IP addresses and CIDR networks to // detect proxy servers addresses the DoH requests from which should be // handled. The value of nil or an empty slice for this field makes // Proxy not trust any address. TrustedProxies []string `yaml:"trusted_proxies"`
DisallowedClients []string `yaml:"disallowed_clients"` // IP addresses of clients that should be blocked BlockedHosts []string `yaml:"blocked_hosts"` // hosts that should be blocked // TrustedProxies is the list of IP addresses and CIDR networks to // detect proxy servers addresses the DoH requests from which should be // handled. The value of nil or an empty slice for this field makes // Proxy not trust any address. TrustedProxies []string `yaml:"trusted_proxies"` // DNS cache settings // -- CacheSize uint32 `yaml:"cache_size"` // DNS cache size (in bytes)
[ "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
Pull request: 2799 trusted proxy Merge in DNS/adguard-home from 2799-trusted-proxy to master Updates #2799. Squashed commit of the following: commit 708a06b30116126a575767ea70865a6de90de774 Author: Eugene Burkov <[email protected]> Date: Fri Jul 23 18:56:16 2021 +0300 all: add trusted proxy mechanism
https://github.com/AdguardTeam/AdGuardHome/commit/2f661df88cf4a11a86c1fbfb8dae9b2cd79ada09
internal/dnsforward/config.go
RatelimitWhitelist: s.conf.RatelimitWhitelist, RefuseAny: s.conf.RefuseAny, CacheMinTTL: s.conf.CacheMinTTL, CacheMaxTTL: s.conf.CacheMaxTTL, CacheOptimistic: s.conf.CacheOptimistic, UpstreamConfig: s.conf.UpstreamConfig,
</s>
TrustedProxies: s.conf.TrustedProxies,
RatelimitWhitelist: s.conf.RatelimitWhitelist, RefuseAny: s.conf.RefuseAny, TrustedProxies: s.conf.TrustedProxies, CacheMinTTL: s.conf.CacheMinTTL, CacheMaxTTL: s.conf.CacheMaxTTL, CacheOptimistic: s.conf.CacheOptimistic, UpstreamConfig: s.conf.UpstreamConfig,
[ "keep", "add", "keep", "keep", "keep", "keep" ]
Pull request: 2799 trusted proxy Merge in DNS/adguard-home from 2799-trusted-proxy to master Updates #2799. Squashed commit of the following: commit 708a06b30116126a575767ea70865a6de90de774 Author: Eugene Burkov <[email protected]> Date: Fri Jul 23 18:56:16 2021 +0300 all: add trusted proxy mechanism
https://github.com/AdguardTeam/AdGuardHome/commit/2f661df88cf4a11a86c1fbfb8dae9b2cd79ada09
internal/dnsforward/config.go
c.BootstrapDNS = aghstrings.CloneSlice(sc.BootstrapDNS) c.AllowedClients = aghstrings.CloneSlice(sc.AllowedClients) c.DisallowedClients = aghstrings.CloneSlice(sc.DisallowedClients) c.BlockedHosts = aghstrings.CloneSlice(sc.BlockedHosts) c.UpstreamDNS = aghstrings.CloneSlice(sc.UpstreamDNS) } // RDNSSettings returns the copy of actual RDNS configuration. func (s *Server) RDNSSettings() (localPTRResolvers []string, resolveClients, resolvePTR bool) {
</s>
c.TrustedProxies = aghstrings.CloneSlice(sc.TrustedProxies)
c.BootstrapDNS = aghstrings.CloneSlice(sc.BootstrapDNS) c.AllowedClients = aghstrings.CloneSlice(sc.AllowedClients) c.DisallowedClients = aghstrings.CloneSlice(sc.DisallowedClients) c.BlockedHosts = aghstrings.CloneSlice(sc.BlockedHosts) c.TrustedProxies = aghstrings.CloneSlice(sc.TrustedProxies) c.UpstreamDNS = aghstrings.CloneSlice(sc.UpstreamDNS) } // RDNSSettings returns the copy of actual RDNS configuration. func (s *Server) RDNSSettings() (localPTRResolvers []string, resolveClients, resolvePTR bool) {
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
Pull request: 2799 trusted proxy Merge in DNS/adguard-home from 2799-trusted-proxy to master Updates #2799. Squashed commit of the following: commit 708a06b30116126a575767ea70865a6de90de774 Author: Eugene Burkov <[email protected]> Date: Fri Jul 23 18:56:16 2021 +0300 all: add trusted proxy mechanism
https://github.com/AdguardTeam/AdGuardHome/commit/2f661df88cf4a11a86c1fbfb8dae9b2cd79ada09
internal/dnsforward/dnsforward.go