Compare commits
44 Commits
v0.108.0-b
...
5347-wildc
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b34a8c169c | ||
|
|
1f2ba07eae | ||
|
|
c77b2a0ce5 | ||
|
|
db52f7a3ac | ||
|
|
381f2f651d | ||
|
|
620b51e3ea | ||
|
|
757ddb06f8 | ||
|
|
d6043e2352 | ||
|
|
aeec9a86e2 | ||
|
|
584182e264 | ||
|
|
96cd512d32 | ||
|
|
11898a3f73 | ||
|
|
a91a257b15 | ||
|
|
76a74b271b | ||
|
|
1842f7d888 | ||
|
|
4afd39b22f | ||
|
|
e43ba17884 | ||
|
|
6d402dc86c | ||
|
|
18acdf9b09 | ||
|
|
5da7751463 | ||
|
|
7631ca4ab3 | ||
|
|
c6d4f2317e | ||
|
|
0ea224a9e4 | ||
|
|
d78a3edb22 | ||
|
|
bbbdea2635 | ||
|
|
6c8d89a4da | ||
|
|
f082312e49 | ||
|
|
ea03d1af93 | ||
|
|
67d8b7df90 | ||
|
|
b23ea0a690 | ||
|
|
a186b5c436 | ||
|
|
6da7392345 | ||
|
|
c1924a8b8a | ||
|
|
0376afb38e | ||
|
|
230d7b8c17 | ||
|
|
950ecb1f5e | ||
|
|
9e14d5f99f | ||
|
|
89bf3721b5 | ||
|
|
15bba281ee | ||
|
|
f9fe3172c4 | ||
|
|
5d5a729569 | ||
|
|
b1120221c7 | ||
|
|
f553eee842 | ||
|
|
61b4043775 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -21,7 +21,6 @@
|
|||||||
/snapcraft_login
|
/snapcraft_login
|
||||||
AdGuardHome*
|
AdGuardHome*
|
||||||
coverage.txt
|
coverage.txt
|
||||||
leases.db
|
|
||||||
node_modules/
|
node_modules/
|
||||||
|
|
||||||
!/build/gitkeep
|
!/build/gitkeep
|
||||||
|
|||||||
139
CHANGELOG.md
139
CHANGELOG.md
@@ -14,17 +14,79 @@ and this project adheres to
|
|||||||
<!--
|
<!--
|
||||||
## [v0.108.0] - TBA
|
## [v0.108.0] - TBA
|
||||||
|
|
||||||
## [v0.107.28] - 2023-04-12 (APPROX.)
|
## [v0.107.30] - 2023-04-26 (APPROX.)
|
||||||
|
|
||||||
See also the [v0.107.28 GitHub milestone][ms-v0.107.28].
|
See also the [v0.107.30 GitHub milestone][ms-v0.107.30].
|
||||||
|
|
||||||
[ms-v0.107.28]: https://github.com/AdguardTeam/AdGuardHome/milestone/64?closed=1
|
[ms-v0.107.30]: https://github.com/AdguardTeam/AdGuardHome/milestone/66?closed=1
|
||||||
|
|
||||||
NOTE: Add new changes BELOW THIS COMMENT.
|
NOTE: Add new changes BELOW THIS COMMENT.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Unquoted IPv6 bind hosts with trailing colons erroneously considered
|
||||||
|
unspecified addresses are now properly validated ([#5752]).
|
||||||
|
|
||||||
|
**NOTE:** the Docker healthcheck script now also doesn't interpret the `""`
|
||||||
|
value as unspecified address.
|
||||||
|
- Incorrect `Content-Type` header value in `POST /control/version.json` and `GET
|
||||||
|
/control/dhcp/interfaces` HTTP APIs ([#5716]).
|
||||||
|
- Provided bootstrap servers are now used to resolve the hostnames of plain
|
||||||
|
UDP/TCP upstream servers.
|
||||||
|
|
||||||
|
[#5716]: https://github.com/AdguardTeam/AdGuardHome/issues/5716
|
||||||
|
|
||||||
|
<!--
|
||||||
|
NOTE: Add new changes ABOVE THIS COMMENT.
|
||||||
|
-->
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## [v0.107.29] - 2023-04-18
|
||||||
|
|
||||||
|
See also the [v0.107.29 GitHub milestone][ms-v0.107.29].
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
||||||
|
- The ability to exclude client activity from the query log or statistics by
|
||||||
|
editing client's settings on the respective page in the UI ([#1717], [#4299]).
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Stored DHCP leases moved from `leases.db` to `data/leases.json`. The file
|
||||||
|
format has also been optimized.
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- The `github.com/mdlayher/raw` dependency has been temporarily returned to
|
||||||
|
support raw connections on Darwin ([#5712]).
|
||||||
|
- Incorrect recording of blocked results as “Blocked by CNAME or IP” in the
|
||||||
|
query log ([#5725]).
|
||||||
|
- All Safe Search services being unchecked by default.
|
||||||
|
- Panic when a DNSCrypt stamp is invalid ([#5721]).
|
||||||
|
|
||||||
|
[#5712]: https://github.com/AdguardTeam/AdGuardHome/issues/5712
|
||||||
|
[#5721]: https://github.com/AdguardTeam/AdGuardHome/issues/5721
|
||||||
|
[#5725]: https://github.com/AdguardTeam/AdGuardHome/issues/5725
|
||||||
|
[#5752]: https://github.com/AdguardTeam/AdGuardHome/issues/5752
|
||||||
|
|
||||||
|
[ms-v0.107.29]: https://github.com/AdguardTeam/AdGuardHome/milestone/65?closed=1
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## [v0.107.28] - 2023-04-12
|
||||||
|
|
||||||
|
See also the [v0.107.28 GitHub milestone][ms-v0.107.28].
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- The ability to exclude client activity from the query log or statistics by
|
||||||
|
using the new properties `ignore_querylog` and `ignore_statistics` of the
|
||||||
|
items of the `clients.persistent` array ([#1717], [#4299]). The UI changes
|
||||||
|
are coming in the upcoming releases.
|
||||||
|
- Better profiling information when `debug_pprof` is set to `true`.
|
||||||
|
- IPv6 support in Safe Search for some services.
|
||||||
- The ability to make bootstrap DNS lookups prefer IPv6 addresses to IPv4 ones
|
- The ability to make bootstrap DNS lookups prefer IPv6 addresses to IPv4 ones
|
||||||
using the new `dns.bootstrap_prefer_ipv6` configuration file property
|
using the new `dns.bootstrap_prefer_ipv6` configuration file property
|
||||||
([#4262]).
|
([#4262]).
|
||||||
@@ -32,20 +94,20 @@ NOTE: Add new changes BELOW THIS COMMENT.
|
|||||||
- The new HTTP API `POST /control/protection`, that updates protection state
|
- The new HTTP API `POST /control/protection`, that updates protection state
|
||||||
and adds an optional pause duration ([#1333]). The format of request body
|
and adds an optional pause duration ([#1333]). The format of request body
|
||||||
is described in `openapi/openapi.yaml`. The duration of this pause could
|
is described in `openapi/openapi.yaml`. The duration of this pause could
|
||||||
also be set with the config field `protection_disabled_until` in `dns`
|
also be set with the property `protection_disabled_until` in the `dns` object
|
||||||
section of the YAML configuration file.
|
of the YAML configuration file.
|
||||||
- The ability to create a static DHCP lease from a dynamic one more easily
|
- The ability to create a static DHCP lease from a dynamic one more easily
|
||||||
([#3459]).
|
([#3459]).
|
||||||
- Two new HTTP APIs, `PUT /control/stats/config/update` and `GET
|
- Two new HTTP APIs, `PUT /control/stats/config/update` and `GET
|
||||||
control/stats/config`, which can be used to set and receive the query log
|
control/stats/config`, which can be used to set and receive the query log
|
||||||
configuration. See openapi/openapi.yaml for the full description.
|
configuration. See `openapi/openapi.yaml` for the full description.
|
||||||
- Two new HTTP APIs, `PUT /control/querylog/config/update` and `GET
|
- Two new HTTP APIs, `PUT /control/querylog/config/update` and `GET
|
||||||
control/querylog/config`, which can be used to set and receive the statistics
|
control/querylog/config`, which can be used to set and receive the statistics
|
||||||
configuration. See openapi/openapi.yaml for the full description.
|
configuration. See `openapi/openapi.yaml` for the full description.
|
||||||
- The ability to set custom IP for EDNS Client Subnet by using the DNS-server
|
- The ability to set custom IP for EDNS Client Subnet by using the DNS-server
|
||||||
configuration section on the DNS settings page in the UI ([#1472]).
|
configuration section on the DNS settings page in the UI ([#1472]).
|
||||||
- The ability to manage safesearch for each service by using the new
|
- The ability to manage Safe Search for each service by using the new
|
||||||
`safe_search` field ([#1163]).
|
`safe_search` property ([#1163]).
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
@@ -74,9 +136,9 @@ In this release, the schema version has changed from 17 to 20.
|
|||||||
|
|
||||||
To rollback this change, convert the property back into days and change the
|
To rollback this change, convert the property back into days and change the
|
||||||
`schema_version` back to `19`.
|
`schema_version` back to `19`.
|
||||||
- The `dns.safesearch_enabled` field has been replaced with `safe_search`
|
- The `dns.safesearch_enabled` property has been replaced with `safe_search`
|
||||||
object containing per-service settings.
|
object containing per-service settings.
|
||||||
- The `clients.persistent.safesearch_enabled` field has been replaced with
|
- The `clients.persistent.safesearch_enabled` property has been replaced with
|
||||||
`safe_search` object containing per-service settings.
|
`safe_search` object containing per-service settings.
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
@@ -95,7 +157,7 @@ In this release, the schema version has changed from 17 to 20.
|
|||||||
```
|
```
|
||||||
|
|
||||||
To rollback this change, move the value of `dns.safe_search.enabled` into the
|
To rollback this change, move the value of `dns.safe_search.enabled` into the
|
||||||
`dns.safesearch_enabled`, then remove `dns.safe_search` field. Do the same
|
`dns.safesearch_enabled`, then remove `dns.safe_search` property. Do the same
|
||||||
client's specific `clients.persistent.safesearch` and then change the
|
client's specific `clients.persistent.safesearch` and then change the
|
||||||
`schema_version` back to `17`.
|
`schema_version` back to `17`.
|
||||||
|
|
||||||
@@ -105,7 +167,7 @@ In this release, the schema version has changed from 17 to 20.
|
|||||||
`PUT /control/safesearch/settings` API.
|
`PUT /control/safesearch/settings` API.
|
||||||
- The `POST /control/safesearch/disable` HTTP API is deprecated. Use the new
|
- The `POST /control/safesearch/disable` HTTP API is deprecated. Use the new
|
||||||
`PUT /control/safesearch/settings` API
|
`PUT /control/safesearch/settings` API
|
||||||
- The `safesearch_enabled` field is deprecated in the following HTTP APIs:
|
- The `safesearch_enabled` property is deprecated in the following HTTP APIs:
|
||||||
- `GET /control/clients`;
|
- `GET /control/clients`;
|
||||||
- `POST /control/clients/add`;
|
- `POST /control/clients/add`;
|
||||||
- `POST /control/clients/update`;
|
- `POST /control/clients/update`;
|
||||||
@@ -116,17 +178,21 @@ In this release, the schema version has changed from 17 to 20.
|
|||||||
/control/stats/config` API instead.
|
/control/stats/config` API instead.
|
||||||
|
|
||||||
**NOTE:** If interval is custom then it will be equal to `90` days for
|
**NOTE:** If interval is custom then it will be equal to `90` days for
|
||||||
compatibility reasons. See openapi/openapi.yaml and `openapi/CHANGELOG.md`.
|
compatibility reasons. See `openapi/openapi.yaml` and `openapi/CHANGELOG.md`.
|
||||||
- The `POST /control/stats_config` HTTP API; use the new `PUT
|
- The `POST /control/stats_config` HTTP API; use the new `PUT
|
||||||
/control/stats/config/update` API instead.
|
/control/stats/config/update` API instead.
|
||||||
- The `GET /control/querylog_info` HTTP API; use the new `GET
|
- The `GET /control/querylog_info` HTTP API; use the new `GET
|
||||||
/control/querylog/config` API instead.
|
/control/querylog/config` API instead.
|
||||||
|
|
||||||
**NOTE:** If interval is custom then it will be equal to `90` days for
|
**NOTE:** If interval is custom then it will be equal to `90` days for
|
||||||
compatibility reasons. See openapi/openapi.yaml and `openapi/CHANGELOG.md`.
|
compatibility reasons. See `openapi/openapi.yaml` and `openapi/CHANGELOG.md`.
|
||||||
- The `POST /control/querylog_config` HTTP API; use the new `PUT
|
- The `POST /control/querylog_config` HTTP API; use the new `PUT
|
||||||
/control/querylog/config/update` API instead.
|
/control/querylog/config/update` API instead.
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Logging of the client's IP address after failed login attempts ([#5701]).
|
||||||
|
|
||||||
[#1163]: https://github.com/AdguardTeam/AdGuardHome/issues/1163
|
[#1163]: https://github.com/AdguardTeam/AdGuardHome/issues/1163
|
||||||
[#1333]: https://github.com/AdguardTeam/AdGuardHome/issues/1333
|
[#1333]: https://github.com/AdguardTeam/AdGuardHome/issues/1333
|
||||||
[#1472]: https://github.com/AdguardTeam/AdGuardHome/issues/1472
|
[#1472]: https://github.com/AdguardTeam/AdGuardHome/issues/1472
|
||||||
@@ -134,12 +200,11 @@ In this release, the schema version has changed from 17 to 20.
|
|||||||
[#3459]: https://github.com/AdguardTeam/AdGuardHome/issues/3459
|
[#3459]: https://github.com/AdguardTeam/AdGuardHome/issues/3459
|
||||||
[#4262]: https://github.com/AdguardTeam/AdGuardHome/issues/4262
|
[#4262]: https://github.com/AdguardTeam/AdGuardHome/issues/4262
|
||||||
[#5567]: https://github.com/AdguardTeam/AdGuardHome/issues/5567
|
[#5567]: https://github.com/AdguardTeam/AdGuardHome/issues/5567
|
||||||
|
[#5701]: https://github.com/AdguardTeam/AdGuardHome/issues/5701
|
||||||
|
|
||||||
[rfc6761]: https://www.rfc-editor.org/rfc/rfc6761
|
[ms-v0.107.28]: https://github.com/AdguardTeam/AdGuardHome/milestone/64?closed=1
|
||||||
|
[rfc6761]: https://www.rfc-editor.org/rfc/rfc6761
|
||||||
|
|
||||||
<!--
|
|
||||||
NOTE: Add new changes ABOVE THIS COMMENT.
|
|
||||||
-->
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -183,7 +248,7 @@ See also the [v0.107.26 GitHub milestone][ms-v0.107.26].
|
|||||||
|
|
||||||
- The ability to set custom IP for EDNS Client Subnet by using the new
|
- The ability to set custom IP for EDNS Client Subnet by using the new
|
||||||
`dns.edns_client_subnet.use_custom` and `dns.edns_client_subnet.custom_ip`
|
`dns.edns_client_subnet.use_custom` and `dns.edns_client_subnet.custom_ip`
|
||||||
fields ([#1472]). The UI changes are coming in the upcoming releases.
|
properties ([#1472]). The UI changes are coming in the upcoming releases.
|
||||||
- The ability to use `dnstype` rules in the disallowed domains list ([#5468]).
|
- The ability to use `dnstype` rules in the disallowed domains list ([#5468]).
|
||||||
This allows dropping requests based on their question types.
|
This allows dropping requests based on their question types.
|
||||||
|
|
||||||
@@ -211,7 +276,7 @@ See also the [v0.107.26 GitHub milestone][ms-v0.107.26].
|
|||||||
```
|
```
|
||||||
|
|
||||||
To rollback this change, move the value of `dns.edns_client_subnet.enabled`
|
To rollback this change, move the value of `dns.edns_client_subnet.enabled`
|
||||||
into the `dns.edns_client_subnet`, remove the fields
|
into the `dns.edns_client_subnet`, remove the properties
|
||||||
`dns.edns_client_subnet.enabled`, `dns.edns_client_subnet.use_custom`,
|
`dns.edns_client_subnet.enabled`, `dns.edns_client_subnet.use_custom`,
|
||||||
`dns.edns_client_subnet.custom_ip`, and change the `schema_version` back to
|
`dns.edns_client_subnet.custom_ip`, and change the `schema_version` back to
|
||||||
`16`.
|
`16`.
|
||||||
@@ -271,11 +336,11 @@ See also the [v0.107.24 GitHub milestone][ms-v0.107.24].
|
|||||||
### Added
|
### Added
|
||||||
|
|
||||||
- The ability to disable statistics by using the new `statistics.enabled`
|
- The ability to disable statistics by using the new `statistics.enabled`
|
||||||
field. Previously it was necessary to set the `statistics_interval` to 0,
|
property. Previously it was necessary to set the `statistics_interval` to 0,
|
||||||
losing the previous value ([#1717], [#4299]).
|
losing the previous value ([#1717], [#4299]).
|
||||||
- The ability to exclude domain names from the query log or statistics by using
|
- The ability to exclude domain names from the query log or statistics by using
|
||||||
the new `querylog.ignored` or `statistics.ignored` fields ([#1717], [#4299]).
|
the new `querylog.ignored` or `statistics.ignored` properties ([#1717],
|
||||||
The UI changes are coming in the upcoming releases.
|
[#4299]). The UI changes are coming in the upcoming releases.
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
@@ -300,7 +365,7 @@ In this release, the schema version has changed from 14 to 16.
|
|||||||
|
|
||||||
To rollback this change, move the property back into the `dns` object and
|
To rollback this change, move the property back into the `dns` object and
|
||||||
change the `schema_version` back to `15`.
|
change the `schema_version` back to `15`.
|
||||||
- The fields `dns.querylog_enabled`, `dns.querylog_file_enabled`,
|
- The properties `dns.querylog_enabled`, `dns.querylog_file_enabled`,
|
||||||
`dns.querylog_interval`, and `dns.querylog_size_memory` have been moved to the
|
`dns.querylog_interval`, and `dns.querylog_size_memory` have been moved to the
|
||||||
new `querylog` object.
|
new `querylog` object.
|
||||||
|
|
||||||
@@ -358,8 +423,8 @@ See also the [v0.107.23 GitHub milestone][ms-v0.107.23].
|
|||||||
### Added
|
### Added
|
||||||
|
|
||||||
- DNS64 support ([#5117]). The function may be enabled with new `use_dns64`
|
- DNS64 support ([#5117]). The function may be enabled with new `use_dns64`
|
||||||
field under `dns` object in the configuration along with `dns64_prefixes`, the
|
property under `dns` object in the configuration along with `dns64_prefixes`,
|
||||||
set of exclusion prefixes to filter AAAA responses. The Well-Known Prefix
|
the set of exclusion prefixes to filter AAAA responses. The Well-Known Prefix
|
||||||
(`64:ff9b::/96`) is used if no custom prefixes are specified.
|
(`64:ff9b::/96`) is used if no custom prefixes are specified.
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
@@ -1017,7 +1082,7 @@ In this release, the schema version has changed from 12 to 14.
|
|||||||
hosts: true
|
hosts: true
|
||||||
```
|
```
|
||||||
|
|
||||||
The value for `clients.runtime_sources.rdns` field is taken from
|
The value for `clients.runtime_sources.rdns` property is taken from
|
||||||
`dns.resolve_clients` property. To rollback this change, remove the
|
`dns.resolve_clients` property. To rollback this change, remove the
|
||||||
`runtime_sources` property, move the contents of `persistent` into the
|
`runtime_sources` property, move the contents of `persistent` into the
|
||||||
`clients` itself, the value of `clients.runtime_sources.rdns` into the
|
`clients` itself, the value of `clients.runtime_sources.rdns` into the
|
||||||
@@ -1267,7 +1332,7 @@ See also the [v0.107.0 GitHub milestone][ms-v0.107.0].
|
|||||||
log entries concerning cached responses won't include that information.
|
log entries concerning cached responses won't include that information.
|
||||||
- Finnish and Ukrainian localizations.
|
- Finnish and Ukrainian localizations.
|
||||||
- Setting the timeout for IP address pinging in the "Fastest IP address" mode
|
- Setting the timeout for IP address pinging in the "Fastest IP address" mode
|
||||||
through the new `fastest_timeout` field in the configuration file ([#1992]).
|
through the new `fastest_timeout` property in the configuration file ([#1992]).
|
||||||
- Static IP address detection on FreeBSD ([#3289]).
|
- Static IP address detection on FreeBSD ([#3289]).
|
||||||
- Optimistic cache ([#2145]).
|
- Optimistic cache ([#2145]).
|
||||||
- New possible value of `6h` for `querylog_interval` property ([#2504]).
|
- New possible value of `6h` for `querylog_interval` property ([#2504]).
|
||||||
@@ -1683,7 +1748,7 @@ See also the [v0.105.2 GitHub milestone][ms-v0.105.2].
|
|||||||
- Inconsistent responses for messages with EDNS0 and AD when DNS caching is
|
- Inconsistent responses for messages with EDNS0 and AD when DNS caching is
|
||||||
enabled ([#2600]).
|
enabled ([#2600]).
|
||||||
- Incomplete OpenWrt detection ([#2757]).
|
- Incomplete OpenWrt detection ([#2757]).
|
||||||
- DHCP lease's `expired` field incorrect time format ([#2692]).
|
- DHCP lease's `expired` property incorrect time format ([#2692]).
|
||||||
- Incomplete DNS upstreams validation ([#2674]).
|
- Incomplete DNS upstreams validation ([#2674]).
|
||||||
- Wrong parsing of DHCP options of the `ip` type ([#2688]).
|
- Wrong parsing of DHCP options of the `ip` type ([#2688]).
|
||||||
|
|
||||||
@@ -1720,8 +1785,8 @@ See also the [v0.105.1 GitHub milestone][ms-v0.105.1].
|
|||||||
the machine has a static IP.
|
the machine has a static IP.
|
||||||
- Optical issue on custom rules ([#2641]).
|
- Optical issue on custom rules ([#2641]).
|
||||||
- Occasional crashes during startup.
|
- Occasional crashes during startup.
|
||||||
- The field `"range_start"` in the `GET /control/dhcp/status` HTTP API response
|
- The property `"range_start"` in the `GET /control/dhcp/status` HTTP API
|
||||||
is now correctly named again ([#2678]).
|
response is now correctly named again ([#2678]).
|
||||||
- DHCPv6 server's `ra_slaac_only` and `ra_allow_slaac` properties aren't reset
|
- DHCPv6 server's `ra_slaac_only` and `ra_allow_slaac` properties aren't reset
|
||||||
to `false` on update anymore ([#2653]).
|
to `false` on update anymore ([#2653]).
|
||||||
- The `Vary` header is now added along with `Access-Control-Allow-Origin` to
|
- The `Vary` header is now added along with `Access-Control-Allow-Origin` to
|
||||||
@@ -1791,7 +1856,7 @@ See also the [v0.105.0 GitHub milestone][ms-v0.105.0].
|
|||||||
|
|
||||||
- Go 1.14 support. v0.106.0 will require at least Go 1.15 to build.
|
- Go 1.14 support. v0.106.0 will require at least Go 1.15 to build.
|
||||||
- The `darwin/386` port. It will be removed in v0.106.0.
|
- The `darwin/386` port. It will be removed in v0.106.0.
|
||||||
- The `"rule"` and `"filter_id"` fields in `GET /filtering/check_host` and
|
- The `"rule"` and `"filter_id"` property in `GET /filtering/check_host` and
|
||||||
`GET /querylog` responses. They will be removed in v0.106.0 ([#2102]).
|
`GET /querylog` responses. They will be removed in v0.106.0 ([#2102]).
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
@@ -1899,11 +1964,13 @@ See also the [v0.104.2 GitHub milestone][ms-v0.104.2].
|
|||||||
|
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
[Unreleased]: https://github.com/AdguardTeam/AdGuardHome/compare/v0.107.28...HEAD
|
[Unreleased]: https://github.com/AdguardTeam/AdGuardHome/compare/v0.107.30...HEAD
|
||||||
[v0.107.28]: https://github.com/AdguardTeam/AdGuardHome/compare/v0.107.27...v0.107.28
|
[v0.107.30]: https://github.com/AdguardTeam/AdGuardHome/compare/v0.107.29...v0.107.30
|
||||||
-->
|
-->
|
||||||
|
|
||||||
[Unreleased]: https://github.com/AdguardTeam/AdGuardHome/compare/v0.107.27...HEAD
|
[Unreleased]: https://github.com/AdguardTeam/AdGuardHome/compare/v0.107.29...HEAD
|
||||||
|
[v0.107.29]: https://github.com/AdguardTeam/AdGuardHome/compare/v0.107.28...v0.107.29
|
||||||
|
[v0.107.28]: https://github.com/AdguardTeam/AdGuardHome/compare/v0.107.27...v0.107.28
|
||||||
[v0.107.27]: https://github.com/AdguardTeam/AdGuardHome/compare/v0.107.26...v0.107.27
|
[v0.107.27]: https://github.com/AdguardTeam/AdGuardHome/compare/v0.107.26...v0.107.27
|
||||||
[v0.107.26]: https://github.com/AdguardTeam/AdGuardHome/compare/v0.107.25...v0.107.26
|
[v0.107.26]: https://github.com/AdguardTeam/AdGuardHome/compare/v0.107.25...v0.107.26
|
||||||
[v0.107.25]: https://github.com/AdguardTeam/AdGuardHome/compare/v0.107.24...v0.107.25
|
[v0.107.25]: https://github.com/AdguardTeam/AdGuardHome/compare/v0.107.24...v0.107.25
|
||||||
|
|||||||
2
client/dev.eslintrc
vendored
2
client/dev.eslintrc
vendored
@@ -3,4 +3,4 @@
|
|||||||
"rules": {
|
"rules": {
|
||||||
"no-debugger":"warn",
|
"no-debugger":"warn",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,11 +12,40 @@
|
|||||||
<link rel="mask-icon" href="assets/safari-pinned-tab.svg" color="#67B279">
|
<link rel="mask-icon" href="assets/safari-pinned-tab.svg" color="#67B279">
|
||||||
<link rel="icon" type="image/png" href="assets/favicon.png" sizes="48x48">
|
<link rel="icon" type="image/png" href="assets/favicon.png" sizes="48x48">
|
||||||
<title>AdGuard Home</title>
|
<title>AdGuard Home</title>
|
||||||
|
<style>
|
||||||
|
.wrapper {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
min-height: 100vh;
|
||||||
|
}
|
||||||
|
|
||||||
|
[data-theme="DARK"] .wrapper {
|
||||||
|
background-color: #f5f7fb;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<noscript>
|
<noscript>
|
||||||
You need to enable JavaScript to run this app.
|
You need to enable JavaScript to run this app.
|
||||||
</noscript>
|
</noscript>
|
||||||
<div id="root"></div>
|
<div id="root">
|
||||||
|
<div class="wrapper"></div>
|
||||||
|
</div>
|
||||||
|
<script>
|
||||||
|
(function() {
|
||||||
|
var LOCAL_STORAGE_THEME_KEY = 'account_theme';
|
||||||
|
var theme = 'light';
|
||||||
|
|
||||||
|
try {
|
||||||
|
theme = window.localStorage.getItem(LOCAL_STORAGE_THEME_KEY);
|
||||||
|
} catch(e) {
|
||||||
|
console.error(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
document.body.dataset.theme = theme;
|
||||||
|
})();
|
||||||
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -17,5 +17,12 @@
|
|||||||
You need to enable JavaScript to run this app.
|
You need to enable JavaScript to run this app.
|
||||||
</noscript>
|
</noscript>
|
||||||
<div id="root"></div>
|
<div id="root"></div>
|
||||||
|
<script>
|
||||||
|
(function() {
|
||||||
|
var prefersDark = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches;
|
||||||
|
var currentTheme = prefersDark ? 'dark' : 'light';
|
||||||
|
document.body.dataset.theme = currentTheme;
|
||||||
|
})();
|
||||||
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -635,5 +635,6 @@
|
|||||||
"parental_control": "الرقابة الابويه",
|
"parental_control": "الرقابة الابويه",
|
||||||
"safe_browsing": "تصفح آمن",
|
"safe_browsing": "تصفح آمن",
|
||||||
"served_from_cache": "{{value}} <i>(يتم تقديمه من ذاكرة التخزين المؤقت)</i>",
|
"served_from_cache": "{{value}} <i>(يتم تقديمه من ذاكرة التخزين المؤقت)</i>",
|
||||||
"form_error_password_length": "يجب أن تتكون كلمة المرور من {{value}} من الأحرف على الأقل"
|
"form_error_password_length": "يجب أن تتكون كلمة المرور من {{value}} من الأحرف على الأقل",
|
||||||
|
"protection_section_label": "الحماية"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -642,5 +642,6 @@
|
|||||||
"anonymizer_notification": "<0>Заўвага:</0> Ананімізацыя IP уключана. Вы можаце адключыць яе ў <1>Агульных наладах</1>.",
|
"anonymizer_notification": "<0>Заўвага:</0> Ананімізацыя IP уключана. Вы можаце адключыць яе ў <1>Агульных наладах</1>.",
|
||||||
"confirm_dns_cache_clear": "Вы ўпэўнены, што хочаце ачысціць кэш DNS?",
|
"confirm_dns_cache_clear": "Вы ўпэўнены, што хочаце ачысціць кэш DNS?",
|
||||||
"cache_cleared": "Кэш DNS паспяхова ачышчаны",
|
"cache_cleared": "Кэш DNS паспяхова ачышчаны",
|
||||||
"clear_cache": "Ачысціць кэш"
|
"clear_cache": "Ачысціць кэш",
|
||||||
|
"protection_section_label": "Ахова"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -257,12 +257,12 @@
|
|||||||
"query_log_cleared": "Protokol dotazů byl úspěšně vymazán",
|
"query_log_cleared": "Protokol dotazů byl úspěšně vymazán",
|
||||||
"query_log_updated": "Protokol dotazů byl úspěšně aktualizován",
|
"query_log_updated": "Protokol dotazů byl úspěšně aktualizován",
|
||||||
"query_log_clear": "Vymazat protokoly dotazů",
|
"query_log_clear": "Vymazat protokoly dotazů",
|
||||||
"query_log_retention": "Uchování protokolů dotazů",
|
"query_log_retention": "Rotace protokolů dotazů",
|
||||||
"query_log_enable": "Povolit protokol",
|
"query_log_enable": "Povolit protokol",
|
||||||
"query_log_configuration": "Konfigurace protokolů",
|
"query_log_configuration": "Konfigurace protokolů",
|
||||||
"query_log_disabled": "Protokol dotazu je zakázán a lze jej nakonfigurovat v <0>nastavení</0>",
|
"query_log_disabled": "Protokol dotazu je zakázán a lze jej nakonfigurovat v <0>nastavení</0>",
|
||||||
"query_log_strict_search": "Pro striktní vyhledávání použijte dvojité uvozovky",
|
"query_log_strict_search": "Pro striktní vyhledávání použijte dvojité uvozovky",
|
||||||
"query_log_retention_confirm": "Opravdu chcete změnit uchovávání protokolu dotazů? Pokud snížíte hodnotu intervalu, některá data budou ztracena",
|
"query_log_retention_confirm": "Opravdu chcete změnit rotaci protokolu dotazů? Pokud snížíte hodnotu intervalu, některá data budou ztracena",
|
||||||
"anonymize_client_ip": "Anonymizovat IP klienta",
|
"anonymize_client_ip": "Anonymizovat IP klienta",
|
||||||
"anonymize_client_ip_desc": "Neukládat úplnou IP adresu klienta do protokolů a statistik",
|
"anonymize_client_ip_desc": "Neukládat úplnou IP adresu klienta do protokolů a statistik",
|
||||||
"dns_config": "Konfigurace DNS serveru",
|
"dns_config": "Konfigurace DNS serveru",
|
||||||
@@ -668,5 +668,11 @@
|
|||||||
"disable_notify_for_hours": "Vypnout ochranu na {{count}} hod.",
|
"disable_notify_for_hours": "Vypnout ochranu na {{count}} hod.",
|
||||||
"disable_notify_for_hours_plural": "Vypnout ochranu na {{count}} hod.",
|
"disable_notify_for_hours_plural": "Vypnout ochranu na {{count}} hod.",
|
||||||
"disable_notify_until_tomorrow": "Vypnout ochranu do zítřka",
|
"disable_notify_until_tomorrow": "Vypnout ochranu do zítřka",
|
||||||
"enable_protection_timer": "Ochrana bude zapnuta za {{time}}"
|
"enable_protection_timer": "Ochrana bude zapnuta za {{time}}",
|
||||||
|
"custom_retention_input": "Zadejte retenci v hodinách",
|
||||||
|
"custom_rotation_input": "Zadejte rotaci v hodinách",
|
||||||
|
"protection_section_label": "Ochrana",
|
||||||
|
"log_and_stats_section_label": "Protokol dotazů a statistiky",
|
||||||
|
"ignore_query_log": "Ignorovat tohoto klienta v protokolu dotazů",
|
||||||
|
"ignore_statistics": "Ignorovat tohoto klienta ve statistikách"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -257,12 +257,12 @@
|
|||||||
"query_log_cleared": "Forespørgselsloggen er blevet ryddet",
|
"query_log_cleared": "Forespørgselsloggen er blevet ryddet",
|
||||||
"query_log_updated": "Forespørgselsloggen er blevet opdateret",
|
"query_log_updated": "Forespørgselsloggen er blevet opdateret",
|
||||||
"query_log_clear": "Ryd forespørgselslogfiler",
|
"query_log_clear": "Ryd forespørgselslogfiler",
|
||||||
"query_log_retention": "Opbevar forespørgselslogger i",
|
"query_log_retention": "Rotation af forespørgselslog",
|
||||||
"query_log_enable": "Aktivér log",
|
"query_log_enable": "Aktivér log",
|
||||||
"query_log_configuration": "Opsætning af logger",
|
"query_log_configuration": "Opsætning af logger",
|
||||||
"query_log_disabled": "Forespørgselsloggen er deaktiveret og kan opsættes i <0>indstillingerne</0>",
|
"query_log_disabled": "Forespørgselsloggen er deaktiveret og kan opsættes i <0>indstillingerne</0>",
|
||||||
"query_log_strict_search": "Brug dobbelt anførselstegn til stringent søgning",
|
"query_log_strict_search": "Brug dobbelt anførselstegn til stringent søgning",
|
||||||
"query_log_retention_confirm": "Sikker på, at du vil ændre forespørgselsloggens opbevaringperiode? Mindskes intervalværdien, mistes data",
|
"query_log_retention_confirm": "Sikker på, at forespørgselsloggens rotationstid skal ændres? Mindskes intervalværdien, mistes nogle data",
|
||||||
"anonymize_client_ip": "Anonymisér klient-IP",
|
"anonymize_client_ip": "Anonymisér klient-IP",
|
||||||
"anonymize_client_ip_desc": "Gem ikke fuld klient IP-adresse i logfiler eller statistikker",
|
"anonymize_client_ip_desc": "Gem ikke fuld klient IP-adresse i logfiler eller statistikker",
|
||||||
"dns_config": "DNS-serveropsætning",
|
"dns_config": "DNS-serveropsætning",
|
||||||
@@ -668,5 +668,11 @@
|
|||||||
"disable_notify_for_hours": "Deaktivere beskyttelse i {{count}} time",
|
"disable_notify_for_hours": "Deaktivere beskyttelse i {{count}} time",
|
||||||
"disable_notify_for_hours_plural": "Deaktivere beskyttelse i {{count}} timer",
|
"disable_notify_for_hours_plural": "Deaktivere beskyttelse i {{count}} timer",
|
||||||
"disable_notify_until_tomorrow": "Deaktiver beskyttelse indtil i morgen",
|
"disable_notify_until_tomorrow": "Deaktiver beskyttelse indtil i morgen",
|
||||||
"enable_protection_timer": "Beskyttelse deaktiveres om {{time}}"
|
"enable_protection_timer": "Beskyttelse deaktiveres om {{time}}",
|
||||||
|
"custom_retention_input": "Angiv opbevaringstid i timer",
|
||||||
|
"custom_rotation_input": "Angiv rotationstid i timer",
|
||||||
|
"protection_section_label": "Beskyttelse",
|
||||||
|
"log_and_stats_section_label": "Forespørgselslog og statistik",
|
||||||
|
"ignore_query_log": "Ignorér denne klient i forespørgselslog",
|
||||||
|
"ignore_statistics": "Ignorér denne klient i statistik"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -257,12 +257,12 @@
|
|||||||
"query_log_cleared": "Das Abfrageprotokoll wurde erfolgreich gelöscht",
|
"query_log_cleared": "Das Abfrageprotokoll wurde erfolgreich gelöscht",
|
||||||
"query_log_updated": "Das Abfrageprotokoll wurde erfolgreich aktualisiert",
|
"query_log_updated": "Das Abfrageprotokoll wurde erfolgreich aktualisiert",
|
||||||
"query_log_clear": "Abfrageprotokolle leeren",
|
"query_log_clear": "Abfrageprotokolle leeren",
|
||||||
"query_log_retention": "Abfrageprotokolle aufbewahren",
|
"query_log_retention": "Rotation der Abfrageprotokolle",
|
||||||
"query_log_enable": "Protokoll aktivieren",
|
"query_log_enable": "Protokoll aktivieren",
|
||||||
"query_log_configuration": "Konfiguration der Protokolle",
|
"query_log_configuration": "Konfiguration der Protokolle",
|
||||||
"query_log_disabled": "Das Abfrageprotokoll ist deaktiviert und kann in den <0>Einstellungen</0> konfiguriert werden.",
|
"query_log_disabled": "Das Abfrageprotokoll ist deaktiviert und kann in den <0>Einstellungen</0> konfiguriert werden.",
|
||||||
"query_log_strict_search": "Doppelte Anführungszeichen für die strikte Suche verwenden",
|
"query_log_strict_search": "Doppelte Anführungszeichen für die strikte Suche verwenden",
|
||||||
"query_log_retention_confirm": "Möchten Sie die Aufbewahrung des Abfrageprotokolls wirklich ändern? Wenn Sie den Zeitabstand verringern, gehen einige Daten verloren.",
|
"query_log_retention_confirm": "Möchten Sie die Abfrageprotokollrotation wirklich ändern? Wenn Sie den Intervallwert verringern, gehen einige Daten verloren",
|
||||||
"anonymize_client_ip": "Client-IP anonymisieren",
|
"anonymize_client_ip": "Client-IP anonymisieren",
|
||||||
"anonymize_client_ip_desc": "Vollständige IP-Adresse des Clients nicht in Protokollen und Statistiken speichern",
|
"anonymize_client_ip_desc": "Vollständige IP-Adresse des Clients nicht in Protokollen und Statistiken speichern",
|
||||||
"dns_config": "DNS-Serverkonfiguration",
|
"dns_config": "DNS-Serverkonfiguration",
|
||||||
@@ -668,5 +668,11 @@
|
|||||||
"disable_notify_for_hours": "Schutz für {{count}} Stunde deaktivieren",
|
"disable_notify_for_hours": "Schutz für {{count}} Stunde deaktivieren",
|
||||||
"disable_notify_for_hours_plural": "Schutz für {{count}} Stunden deaktivieren",
|
"disable_notify_for_hours_plural": "Schutz für {{count}} Stunden deaktivieren",
|
||||||
"disable_notify_until_tomorrow": "Schutz bis morgen deaktivieren",
|
"disable_notify_until_tomorrow": "Schutz bis morgen deaktivieren",
|
||||||
"enable_protection_timer": "Der Schutz wird in {{time}} wieder aktiviert"
|
"enable_protection_timer": "Der Schutz wird in {{time}} wieder aktiviert",
|
||||||
|
"custom_retention_input": "Rückhaltezeit in Stunden eingeben",
|
||||||
|
"custom_rotation_input": "Rotation in Stunden eingeben",
|
||||||
|
"protection_section_label": "Schutz",
|
||||||
|
"log_and_stats_section_label": "Abfrageprotokoll und Statistik",
|
||||||
|
"ignore_query_log": "Diesen Client im Abfrageprotokoll ignorieren",
|
||||||
|
"ignore_statistics": "Diesen Client in der Statistik ignorieren"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -257,12 +257,12 @@
|
|||||||
"query_log_cleared": "The query log has been successfully cleared",
|
"query_log_cleared": "The query log has been successfully cleared",
|
||||||
"query_log_updated": "The query log has been successfully updated",
|
"query_log_updated": "The query log has been successfully updated",
|
||||||
"query_log_clear": "Clear query logs",
|
"query_log_clear": "Clear query logs",
|
||||||
"query_log_retention": "Query logs retention",
|
"query_log_retention": "Query logs rotation",
|
||||||
"query_log_enable": "Enable log",
|
"query_log_enable": "Enable log",
|
||||||
"query_log_configuration": "Logs configuration",
|
"query_log_configuration": "Logs configuration",
|
||||||
"query_log_disabled": "The query log is disabled and can be configured in the <0>settings</0>",
|
"query_log_disabled": "The query log is disabled and can be configured in the <0>settings</0>",
|
||||||
"query_log_strict_search": "Use double quotes for strict search",
|
"query_log_strict_search": "Use double quotes for strict search",
|
||||||
"query_log_retention_confirm": "Are you sure you want to change query log retention? If you decrease the interval value, some data will be lost",
|
"query_log_retention_confirm": "Are you sure you want to change query log rotation? If you decrease the interval value, some data will be lost",
|
||||||
"anonymize_client_ip": "Anonymize client IP",
|
"anonymize_client_ip": "Anonymize client IP",
|
||||||
"anonymize_client_ip_desc": "Don't save the client's full IP address to logs or statistics",
|
"anonymize_client_ip_desc": "Don't save the client's full IP address to logs or statistics",
|
||||||
"dns_config": "DNS server configuration",
|
"dns_config": "DNS server configuration",
|
||||||
@@ -668,5 +668,11 @@
|
|||||||
"disable_notify_for_hours": "Disable protection for {{count}} hour",
|
"disable_notify_for_hours": "Disable protection for {{count}} hour",
|
||||||
"disable_notify_for_hours_plural": "Disable protection for {{count}} hours",
|
"disable_notify_for_hours_plural": "Disable protection for {{count}} hours",
|
||||||
"disable_notify_until_tomorrow": "Disable protection until tomorrow",
|
"disable_notify_until_tomorrow": "Disable protection until tomorrow",
|
||||||
"enable_protection_timer": "Protection will be enabled in {{time}}"
|
"enable_protection_timer": "Protection will be enabled in {{time}}",
|
||||||
|
"custom_retention_input": "Enter retention in hours",
|
||||||
|
"custom_rotation_input": "Enter rotation in hours",
|
||||||
|
"protection_section_label": "Protection",
|
||||||
|
"log_and_stats_section_label": "Query log and statistics",
|
||||||
|
"ignore_query_log": "Ignore this client in query log",
|
||||||
|
"ignore_statistics": "Ignore this client in statistics"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -257,12 +257,12 @@
|
|||||||
"query_log_cleared": "El registro de consultas se ha borrado correctamente",
|
"query_log_cleared": "El registro de consultas se ha borrado correctamente",
|
||||||
"query_log_updated": "El registro de consultas se ha actualizado correctamente",
|
"query_log_updated": "El registro de consultas se ha actualizado correctamente",
|
||||||
"query_log_clear": "Borrar registros de consultas",
|
"query_log_clear": "Borrar registros de consultas",
|
||||||
"query_log_retention": "Retención de registros de consultas",
|
"query_log_retention": "Rotanción de registros de consultas",
|
||||||
"query_log_enable": "Habilitar registro",
|
"query_log_enable": "Habilitar registro",
|
||||||
"query_log_configuration": "Configuración de registros",
|
"query_log_configuration": "Configuración de registros",
|
||||||
"query_log_disabled": "El registro de consultas está deshabilitado y se puede configurar en la <0>configuración</0>",
|
"query_log_disabled": "El registro de consultas está deshabilitado y se puede configurar en la <0>configuración</0>",
|
||||||
"query_log_strict_search": "Usar comillas dobles para una búsqueda estricta",
|
"query_log_strict_search": "Usar comillas dobles para una búsqueda estricta",
|
||||||
"query_log_retention_confirm": "¿Estás seguro de que deseas cambiar la retención del registro de consultas? Si disminuye el valor del intervalo, se perderán algunos datos",
|
"query_log_retention_confirm": "¿Está seguro de que deseas cambiar la rotación del registro de consultas? Si reduces el valor del intervalo, se perderán algunos datos",
|
||||||
"anonymize_client_ip": "Anonimizar IP del cliente",
|
"anonymize_client_ip": "Anonimizar IP del cliente",
|
||||||
"anonymize_client_ip_desc": "No guarda la dirección IP completa del cliente en registros o estadísticas",
|
"anonymize_client_ip_desc": "No guarda la dirección IP completa del cliente en registros o estadísticas",
|
||||||
"dns_config": "Configuración del servidor DNS",
|
"dns_config": "Configuración del servidor DNS",
|
||||||
@@ -668,5 +668,11 @@
|
|||||||
"disable_notify_for_hours": "Desactivar la protección por {{count}} hora",
|
"disable_notify_for_hours": "Desactivar la protección por {{count}} hora",
|
||||||
"disable_notify_for_hours_plural": "Desactivar la protección por {{count}} horas",
|
"disable_notify_for_hours_plural": "Desactivar la protección por {{count}} horas",
|
||||||
"disable_notify_until_tomorrow": "Desactivar la protección hasta mañana",
|
"disable_notify_until_tomorrow": "Desactivar la protección hasta mañana",
|
||||||
"enable_protection_timer": "La protección se activará en {{time}}"
|
"enable_protection_timer": "La protección se activará en {{time}}",
|
||||||
|
"custom_retention_input": "Ingresa la retención en horas",
|
||||||
|
"custom_rotation_input": "Ingresa la rotación en horas",
|
||||||
|
"protection_section_label": "Protección",
|
||||||
|
"log_and_stats_section_label": "Registro de consultas y estadísticas",
|
||||||
|
"ignore_query_log": "Ignorar este cliente en el registro de consultas",
|
||||||
|
"ignore_statistics": "Ignorar este cliente en las estadísticas"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -257,12 +257,12 @@
|
|||||||
"query_log_cleared": "Pyyntöhistorian tyhjennys onnistui",
|
"query_log_cleared": "Pyyntöhistorian tyhjennys onnistui",
|
||||||
"query_log_updated": "Pyyntöhistorian päivitys onnistui",
|
"query_log_updated": "Pyyntöhistorian päivitys onnistui",
|
||||||
"query_log_clear": "Tyhjennä pyyntöhistoria",
|
"query_log_clear": "Tyhjennä pyyntöhistoria",
|
||||||
"query_log_retention": "Pyyntöhistorian säilytys",
|
"query_log_retention": "Kyselylokien kierto",
|
||||||
"query_log_enable": "Käytä historiaa",
|
"query_log_enable": "Käytä historiaa",
|
||||||
"query_log_configuration": "Historian määritys",
|
"query_log_configuration": "Historian määritys",
|
||||||
"query_log_disabled": "Pyyntöhistoria ei ole käytössä. Voit ottaa sen käyttöön <0>asetuksissa</0>",
|
"query_log_disabled": "Pyyntöhistoria ei ole käytössä. Voit ottaa sen käyttöön <0>asetuksissa</0>",
|
||||||
"query_log_strict_search": "Käytä tarkalle haulle lainausmerkkejä",
|
"query_log_strict_search": "Käytä tarkalle haulle lainausmerkkejä",
|
||||||
"query_log_retention_confirm": "Haluatko varmasti muuttaa pyyntöhistoriasi säilytysaikaa? Jos lyhennät aikaa, joitakin tietoja menetetään",
|
"query_log_retention_confirm": "Haluatko varmasti muuttaa kyselylokin kiertoa? Jos pienennät intervalliarvoa, osa tiedoista menetetään",
|
||||||
"anonymize_client_ip": "Piilota päätelaitteen IP-osoite",
|
"anonymize_client_ip": "Piilota päätelaitteen IP-osoite",
|
||||||
"anonymize_client_ip_desc": "Älä tallenna päätelaitteen täydellistä IP-osoitetta historiaan ja tilastoihin.",
|
"anonymize_client_ip_desc": "Älä tallenna päätelaitteen täydellistä IP-osoitetta historiaan ja tilastoihin.",
|
||||||
"dns_config": "DNS-palvelimen määritys",
|
"dns_config": "DNS-palvelimen määritys",
|
||||||
@@ -668,5 +668,11 @@
|
|||||||
"disable_notify_for_hours": "Poista suojaus käytöstä {{count}} tunniksi",
|
"disable_notify_for_hours": "Poista suojaus käytöstä {{count}} tunniksi",
|
||||||
"disable_notify_for_hours_plural": "Poista suojaus käytöstä {{count}} tunniksi",
|
"disable_notify_for_hours_plural": "Poista suojaus käytöstä {{count}} tunniksi",
|
||||||
"disable_notify_until_tomorrow": "Poista suojaus käytöstä huomiseen asti",
|
"disable_notify_until_tomorrow": "Poista suojaus käytöstä huomiseen asti",
|
||||||
"enable_protection_timer": "Suojaus otetaan käyttöön {{time}} kuluttua"
|
"enable_protection_timer": "Suojaus otetaan käyttöön {{time}} kuluttua",
|
||||||
|
"custom_retention_input": "Syötä säilytysaika tunteina",
|
||||||
|
"custom_rotation_input": "Syötä uudistusaika tunteina",
|
||||||
|
"protection_section_label": "Suojaus",
|
||||||
|
"log_and_stats_section_label": "Kyselyhistoria ja tilastot",
|
||||||
|
"ignore_query_log": "Älä huomioi tätä päätettä kyselyhistoriassa",
|
||||||
|
"ignore_statistics": "Älä huomioi tätä päätettä tilastoissa"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -257,12 +257,12 @@
|
|||||||
"query_log_cleared": "Le journal des requêtes a été effacé",
|
"query_log_cleared": "Le journal des requêtes a été effacé",
|
||||||
"query_log_updated": "Le journal des requêtes a été mis à jour",
|
"query_log_updated": "Le journal des requêtes a été mis à jour",
|
||||||
"query_log_clear": "Effacer journal des requêtes",
|
"query_log_clear": "Effacer journal des requêtes",
|
||||||
"query_log_retention": "Rétention du journal des requêtes",
|
"query_log_retention": "Rotation des journaux de requêtes",
|
||||||
"query_log_enable": "Activer le journal",
|
"query_log_enable": "Activer le journal",
|
||||||
"query_log_configuration": "Configuration du journal",
|
"query_log_configuration": "Configuration du journal",
|
||||||
"query_log_disabled": "Le journal des requêtes est désactivé et peut être configuré dans les <0>paramètres</0>",
|
"query_log_disabled": "Le journal des requêtes est désactivé et peut être configuré dans les <0>paramètres</0>",
|
||||||
"query_log_strict_search": "Utilisez les doubles guillemets pour une recherche stricte",
|
"query_log_strict_search": "Utilisez les doubles guillemets pour une recherche stricte",
|
||||||
"query_log_retention_confirm": "Êtes-vous sûr de vouloir modifier la rétention des journaux de requêtes ? Si vous diminuez la valeur de l'intervalle, certaines données seront perdues",
|
"query_log_retention_confirm": "Êtes-vous sûr de souhaiter modifier la rotation des journaux de requêtes ? Si vous diminuez la valeur de l'intervalle, certaines données seront perdues",
|
||||||
"anonymize_client_ip": "Anonymiser l’IP du client",
|
"anonymize_client_ip": "Anonymiser l’IP du client",
|
||||||
"anonymize_client_ip_desc": "Ne pas enregistrer l’adresse IP complète du client dans les journaux et statistiques",
|
"anonymize_client_ip_desc": "Ne pas enregistrer l’adresse IP complète du client dans les journaux et statistiques",
|
||||||
"dns_config": "Configuration du serveur DNS",
|
"dns_config": "Configuration du serveur DNS",
|
||||||
@@ -668,5 +668,11 @@
|
|||||||
"disable_notify_for_hours": "Désactiver la protection pendant {{count}} heure",
|
"disable_notify_for_hours": "Désactiver la protection pendant {{count}} heure",
|
||||||
"disable_notify_for_hours_plural": "Désactiver la protection pendant {{count}} heures",
|
"disable_notify_for_hours_plural": "Désactiver la protection pendant {{count}} heures",
|
||||||
"disable_notify_until_tomorrow": "Désactiver la protection jusqu'à demain",
|
"disable_notify_until_tomorrow": "Désactiver la protection jusqu'à demain",
|
||||||
"enable_protection_timer": "La protection sera activée dans {{time}}"
|
"enable_protection_timer": "La protection sera activée dans {{time}}",
|
||||||
|
"custom_retention_input": "Saisir la rétention en heures",
|
||||||
|
"custom_rotation_input": "Saisir la rotation en heures",
|
||||||
|
"protection_section_label": "Protection",
|
||||||
|
"log_and_stats_section_label": "Journal des requêtes et statistiques",
|
||||||
|
"ignore_query_log": "Ignorer ce client dans le journal des requêtes",
|
||||||
|
"ignore_statistics": "Ignorer ce client dans les statistiques"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -167,6 +167,7 @@
|
|||||||
"enabled_parental_toast": "Omogućen roditeljski nadzor",
|
"enabled_parental_toast": "Omogućen roditeljski nadzor",
|
||||||
"disabled_safe_search_toast": "Onemogućeno sigurno pretraživanje",
|
"disabled_safe_search_toast": "Onemogućeno sigurno pretraživanje",
|
||||||
"enabled_save_search_toast": "Omogućeno sigurno pretraživanje",
|
"enabled_save_search_toast": "Omogućeno sigurno pretraživanje",
|
||||||
|
"updated_save_search_toast": "Ažurirane postavke sigurnog pretraživanja",
|
||||||
"enabled_table_header": "Omogućeno",
|
"enabled_table_header": "Omogućeno",
|
||||||
"name_table_header": "Naziv",
|
"name_table_header": "Naziv",
|
||||||
"list_url_table_header": "URL popisa",
|
"list_url_table_header": "URL popisa",
|
||||||
@@ -256,12 +257,12 @@
|
|||||||
"query_log_cleared": "Zapisnik upita je uspješno uklonjen",
|
"query_log_cleared": "Zapisnik upita je uspješno uklonjen",
|
||||||
"query_log_updated": "Zapisnik upita je uspješno ažuriran",
|
"query_log_updated": "Zapisnik upita je uspješno ažuriran",
|
||||||
"query_log_clear": "Očisti zapisnik upita",
|
"query_log_clear": "Očisti zapisnik upita",
|
||||||
"query_log_retention": "Spremanje zapisnika upita",
|
"query_log_retention": "Rotacija dnevnika upita",
|
||||||
"query_log_enable": "Omogući zapise",
|
"query_log_enable": "Omogući zapise",
|
||||||
"query_log_configuration": "Postavke zapisa",
|
"query_log_configuration": "Postavke zapisa",
|
||||||
"query_log_disabled": "Zapisnik upita je onemogućen i može se postaviti u <0>postavkama</0>",
|
"query_log_disabled": "Zapisnik upita je onemogućen i može se postaviti u <0>postavkama</0>",
|
||||||
"query_log_strict_search": "Koristite dvostruke navodnike za strogo pretraživanje",
|
"query_log_strict_search": "Koristite dvostruke navodnike za strogo pretraživanje",
|
||||||
"query_log_retention_confirm": "Jeste li sigurni da želite promijeniti zadržavanje zapisnika upita? Ako smanjite vrijednost intervala, neki će podaci biti izgubljeni",
|
"query_log_retention_confirm": "Jeste li sigurni da želite promijeniti rotaciju dnevnika upita? Ako smanjite vrijednost intervala, neki će se podaci izgubiti",
|
||||||
"anonymize_client_ip": "Anonimiraj IP klijenta",
|
"anonymize_client_ip": "Anonimiraj IP klijenta",
|
||||||
"anonymize_client_ip_desc": "Ne spremajte cijelu IP adresu klijenta u zapisnike i statistike",
|
"anonymize_client_ip_desc": "Ne spremajte cijelu IP adresu klijenta u zapisnike i statistike",
|
||||||
"dns_config": "DNS postavke poslužitelja",
|
"dns_config": "DNS postavke poslužitelja",
|
||||||
@@ -290,6 +291,8 @@
|
|||||||
"rate_limit": "Ograničenje",
|
"rate_limit": "Ograničenje",
|
||||||
"edns_enable": "Omogući podmrežu klijenta EDNS-a",
|
"edns_enable": "Omogući podmrežu klijenta EDNS-a",
|
||||||
"edns_cs_desc": "Dodajte opciju EDNS klijentske podmreže (ECS) uzvodnim zahtjevima i zabilježite vrijednosti koje su klijenti poslali u dnevnik upita.",
|
"edns_cs_desc": "Dodajte opciju EDNS klijentske podmreže (ECS) uzvodnim zahtjevima i zabilježite vrijednosti koje su klijenti poslali u dnevnik upita.",
|
||||||
|
"edns_use_custom_ip": "Koristi prilagođeni IP za EDNS",
|
||||||
|
"edns_use_custom_ip_desc": "Dopusti korištenje prilagođenog IP-a za EDNS",
|
||||||
"rate_limit_desc": "Broj zahtjeva u sekundi koji su dopušteni po jednom klijentu. Postavljanje na 0 znači neograničeno.",
|
"rate_limit_desc": "Broj zahtjeva u sekundi koji su dopušteni po jednom klijentu. Postavljanje na 0 znači neograničeno.",
|
||||||
"blocking_ipv4_desc": "Povratna IP adresa za blokirane A zahtjeve",
|
"blocking_ipv4_desc": "Povratna IP adresa za blokirane A zahtjeve",
|
||||||
"blocking_ipv6_desc": "Povratna IP adresa za blokirane AAAA zahtjeve",
|
"blocking_ipv6_desc": "Povratna IP adresa za blokirane AAAA zahtjeve",
|
||||||
@@ -523,6 +526,10 @@
|
|||||||
"statistics_retention_confirm": "Jeste li sigurni da želite promijeniti zadržavanje statistike? Ako smanjite vrijednost intervala, neki će podaci biti izgubljeni",
|
"statistics_retention_confirm": "Jeste li sigurni da želite promijeniti zadržavanje statistike? Ako smanjite vrijednost intervala, neki će podaci biti izgubljeni",
|
||||||
"statistics_cleared": "Statistika je uspješno uklonjenja",
|
"statistics_cleared": "Statistika je uspješno uklonjenja",
|
||||||
"statistics_enable": "Omogući statistiku",
|
"statistics_enable": "Omogući statistiku",
|
||||||
|
"ignore_domains": "Zanemarene domene (odvojene novim retkom)",
|
||||||
|
"ignore_domains_title": "Zanemarene domene",
|
||||||
|
"ignore_domains_desc_stats": "Upiti za ove domene ne upisuju se u statistiku",
|
||||||
|
"ignore_domains_desc_query": "Upiti za te domene nisu zapisani u zapisnik upita",
|
||||||
"interval_hours": "{{count}} sata/i",
|
"interval_hours": "{{count}} sata/i",
|
||||||
"interval_hours_plural": "{{count}} sata/i",
|
"interval_hours_plural": "{{count}} sata/i",
|
||||||
"filters_configuration": "Postavke filtara",
|
"filters_configuration": "Postavke filtara",
|
||||||
@@ -642,5 +649,30 @@
|
|||||||
"anonymizer_notification": "<0>Napomena:</0>IP anonimizacija je omogućena. Možete ju onemogućiti u <1>općim postavkama</1>.",
|
"anonymizer_notification": "<0>Napomena:</0>IP anonimizacija je omogućena. Možete ju onemogućiti u <1>općim postavkama</1>.",
|
||||||
"confirm_dns_cache_clear": "Jeste li sigurni da želite očistiti DNS predmemoriju?",
|
"confirm_dns_cache_clear": "Jeste li sigurni da želite očistiti DNS predmemoriju?",
|
||||||
"cache_cleared": "DNS predmemorija je uspješno izbrisana",
|
"cache_cleared": "DNS predmemorija je uspješno izbrisana",
|
||||||
"clear_cache": "Očisti predmemoriju"
|
"clear_cache": "Očisti predmemoriju",
|
||||||
|
"make_static": "Učini statičnim",
|
||||||
|
"theme_auto_desc": "Automatski (na temelju sheme boja vašeg uređaja)",
|
||||||
|
"theme_dark_desc": "Tamna tema",
|
||||||
|
"theme_light_desc": "Svijetla tema",
|
||||||
|
"disable_for_seconds": "Za {{count}} sekundi",
|
||||||
|
"disable_for_seconds_plural": "Za {{count}} sekundi",
|
||||||
|
"disable_for_minutes": "Za {{count}} minuta",
|
||||||
|
"disable_for_minutes_plural": "Za {{count}} minuta",
|
||||||
|
"disable_for_hours": "Za {{count}} sati",
|
||||||
|
"disable_for_hours_plural": "Za {{count}} sati",
|
||||||
|
"disable_until_tomorrow": "Do sutra",
|
||||||
|
"disable_notify_for_seconds": "Isključi zaštitu na {{count}} sekundi",
|
||||||
|
"disable_notify_for_seconds_plural": "Onemogući zaštitu na {{count}} sekundi",
|
||||||
|
"disable_notify_for_minutes": "Isključi zaštitu na {{count}} minuta",
|
||||||
|
"disable_notify_for_minutes_plural": "Isključi zaštitu na {{count}} minuta",
|
||||||
|
"disable_notify_for_hours": "Isključi zaštitu na {{count}} sati",
|
||||||
|
"disable_notify_for_hours_plural": "Isključi zaštitu na {{count}} sati",
|
||||||
|
"disable_notify_until_tomorrow": "Isključi zaštitu do sutra",
|
||||||
|
"enable_protection_timer": "Zaštita će biti omogućena u {{time}}",
|
||||||
|
"custom_retention_input": "Unesite zadržavanje u satima",
|
||||||
|
"custom_rotation_input": "Unesite rotaciju u satima",
|
||||||
|
"protection_section_label": "Zaštita",
|
||||||
|
"log_and_stats_section_label": "Zapisnik upita i statistika",
|
||||||
|
"ignore_query_log": "Zanemari ovog klijenta u zapisniku upita",
|
||||||
|
"ignore_statistics": "Ignorirajte ovog klijenta u statistici"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -642,5 +642,6 @@
|
|||||||
"anonymizer_notification": "<0>Megjegyzés:</0> Az IP anonimizálás engedélyezve van. Az <1>Általános beállításoknál letilthatja</1> .",
|
"anonymizer_notification": "<0>Megjegyzés:</0> Az IP anonimizálás engedélyezve van. Az <1>Általános beállításoknál letilthatja</1> .",
|
||||||
"confirm_dns_cache_clear": "Biztos benne, hogy törölni szeretné a DNS-gyorsítótárat?",
|
"confirm_dns_cache_clear": "Biztos benne, hogy törölni szeretné a DNS-gyorsítótárat?",
|
||||||
"cache_cleared": "A DNS gyorsítótár sikeresen törlődött",
|
"cache_cleared": "A DNS gyorsítótár sikeresen törlődött",
|
||||||
"clear_cache": "Gyorsítótár törlése"
|
"clear_cache": "Gyorsítótár törlése",
|
||||||
|
"protection_section_label": "Védelem"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -641,5 +641,6 @@
|
|||||||
"anonymizer_notification": "<0>Catatan:</0> Anonimisasi IP diaktifkan. Anda dapat menonaktifkannya di <1>Pengaturan umum</1> .",
|
"anonymizer_notification": "<0>Catatan:</0> Anonimisasi IP diaktifkan. Anda dapat menonaktifkannya di <1>Pengaturan umum</1> .",
|
||||||
"confirm_dns_cache_clear": "Apakah Anda yakin ingin menghapus cache DNS?",
|
"confirm_dns_cache_clear": "Apakah Anda yakin ingin menghapus cache DNS?",
|
||||||
"cache_cleared": "Cache DNS berhasil dibersihkan",
|
"cache_cleared": "Cache DNS berhasil dibersihkan",
|
||||||
"clear_cache": "Hapus cache"
|
"clear_cache": "Hapus cache",
|
||||||
|
"protection_section_label": "Perlindungan"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -257,12 +257,12 @@
|
|||||||
"query_log_cleared": "Il registro richieste è stato correttamente cancellato",
|
"query_log_cleared": "Il registro richieste è stato correttamente cancellato",
|
||||||
"query_log_updated": "Il registro richieste è stato correttamente aggiornato",
|
"query_log_updated": "Il registro richieste è stato correttamente aggiornato",
|
||||||
"query_log_clear": "Cancella registri richieste",
|
"query_log_clear": "Cancella registri richieste",
|
||||||
"query_log_retention": "Conservazione dei registri richieste",
|
"query_log_retention": "Rotazione dei registri richieste",
|
||||||
"query_log_enable": "Attiva registro",
|
"query_log_enable": "Attiva registro",
|
||||||
"query_log_configuration": "Configurazione registri",
|
"query_log_configuration": "Configurazione registri",
|
||||||
"query_log_disabled": "Il registro richieste è stato disattivato e può essere configurata dalle <0>impostazioni</0>",
|
"query_log_disabled": "Il registro richieste è stato disattivato e può essere configurata dalle <0>impostazioni</0>",
|
||||||
"query_log_strict_search": "Utilizzare le doppie virgolette per una ricerca precisa",
|
"query_log_strict_search": "Utilizzare le doppie virgolette per una ricerca precisa",
|
||||||
"query_log_retention_confirm": "Sei sicuro di voler modificare il registro delle richieste? Se il valore di intervallo dovesse diminuire, alcuni dati andranno persi",
|
"query_log_retention_confirm": "Sei sicuro di voler modificare il registro delle richieste? Se si riduce il valore dell'intervallo, alcuni dati andranno persi",
|
||||||
"anonymize_client_ip": "Anonimizza client IP",
|
"anonymize_client_ip": "Anonimizza client IP",
|
||||||
"anonymize_client_ip_desc": "Non salvare l'indirizzo IP completo del client nel registro o nelle statistiche",
|
"anonymize_client_ip_desc": "Non salvare l'indirizzo IP completo del client nel registro o nelle statistiche",
|
||||||
"dns_config": "Configurazione server DNS",
|
"dns_config": "Configurazione server DNS",
|
||||||
@@ -668,5 +668,11 @@
|
|||||||
"disable_notify_for_hours": "Disattiva la protezione per {{count}} ora",
|
"disable_notify_for_hours": "Disattiva la protezione per {{count}} ora",
|
||||||
"disable_notify_for_hours_plural": "Disattiva la protezione per {{count}} ore",
|
"disable_notify_for_hours_plural": "Disattiva la protezione per {{count}} ore",
|
||||||
"disable_notify_until_tomorrow": "Disattiva la protezione fino a domani",
|
"disable_notify_until_tomorrow": "Disattiva la protezione fino a domani",
|
||||||
"enable_protection_timer": "La protezione verrà attivata in {{time}}"
|
"enable_protection_timer": "La protezione verrà attivata in {{time}}",
|
||||||
|
"custom_retention_input": "Inserisci la conservazione in ore",
|
||||||
|
"custom_rotation_input": "Inserisci la rotazione in ore",
|
||||||
|
"protection_section_label": "Protezione",
|
||||||
|
"log_and_stats_section_label": "Registro richieste e statistiche",
|
||||||
|
"ignore_query_log": "Ignora questo client nel registro delle richieste",
|
||||||
|
"ignore_statistics": "Ignora questo cliente nelle statistiche"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -257,12 +257,12 @@
|
|||||||
"query_log_cleared": "クエリ・ログの消去に成功しました",
|
"query_log_cleared": "クエリ・ログの消去に成功しました",
|
||||||
"query_log_updated": "クエリ・ログの更新が成功しました",
|
"query_log_updated": "クエリ・ログの更新が成功しました",
|
||||||
"query_log_clear": "クエリ・ログを消去する",
|
"query_log_clear": "クエリ・ログを消去する",
|
||||||
"query_log_retention": "クエリ・ログの保持",
|
"query_log_retention": "クエリ・ログのローテーション",
|
||||||
"query_log_enable": "ログを有効にする",
|
"query_log_enable": "ログを有効にする",
|
||||||
"query_log_configuration": "ログ設定",
|
"query_log_configuration": "ログ設定",
|
||||||
"query_log_disabled": "クエリ・ログは無効になっており、<0>設定</0>で構成できます",
|
"query_log_disabled": "クエリ・ログは無効になっており、<0>設定</0>で構成できます",
|
||||||
"query_log_strict_search": "完全一致検索には二重引用符を使用します",
|
"query_log_strict_search": "完全一致検索には二重引用符を使用します",
|
||||||
"query_log_retention_confirm": "クエリ・ログの保持を変更してもよろしいですか? 期間を短くすると、一部のデータが失われます",
|
"query_log_retention_confirm": "クエリ・ログのローテーションを変更してもよろしいですか? 間隔の値を減らすと、一部のデータが失われます",
|
||||||
"anonymize_client_ip": "クライアントIPを匿名化する",
|
"anonymize_client_ip": "クライアントIPを匿名化する",
|
||||||
"anonymize_client_ip_desc": "ログと統計にクライアントのフルIPアドレスを保存しないようにします。",
|
"anonymize_client_ip_desc": "ログと統計にクライアントのフルIPアドレスを保存しないようにします。",
|
||||||
"dns_config": "DNSサーバ設定",
|
"dns_config": "DNSサーバ設定",
|
||||||
@@ -668,5 +668,11 @@
|
|||||||
"disable_notify_for_hours": "保護を {{count}} 時間無効にする",
|
"disable_notify_for_hours": "保護を {{count}} 時間無効にする",
|
||||||
"disable_notify_for_hours_plural": "保護を {{count}} 時間無効にする",
|
"disable_notify_for_hours_plural": "保護を {{count}} 時間無効にする",
|
||||||
"disable_notify_until_tomorrow": "明日まで保護を無効にする",
|
"disable_notify_until_tomorrow": "明日まで保護を無効にする",
|
||||||
"enable_protection_timer": "保護は後 {{time}} で有効になります"
|
"enable_protection_timer": "保護は後 {{time}} で有効になります",
|
||||||
|
"custom_retention_input": "保持期間を入力してください(時間単位)",
|
||||||
|
"custom_rotation_input": "ローテーションを入力してください(時間単位)",
|
||||||
|
"protection_section_label": "AdGuardによる保護",
|
||||||
|
"log_and_stats_section_label": "クエリ・ログと統計情報",
|
||||||
|
"ignore_query_log": "クエリ・ログでこのクライアントを無視する",
|
||||||
|
"ignore_statistics": "統計でこのクライアントを無視する"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -257,12 +257,12 @@
|
|||||||
"query_log_cleared": "쿼리 로그를 성공적으로 초기화했습니다",
|
"query_log_cleared": "쿼리 로그를 성공적으로 초기화했습니다",
|
||||||
"query_log_updated": "질의 로그가 성공적으로 업데이트되었습니다",
|
"query_log_updated": "질의 로그가 성공적으로 업데이트되었습니다",
|
||||||
"query_log_clear": "쿼리 로그 비우기",
|
"query_log_clear": "쿼리 로그 비우기",
|
||||||
"query_log_retention": "쿼리 로그 저장 기간",
|
"query_log_retention": "쿼리 로그 로테이션",
|
||||||
"query_log_enable": "로그 활성화",
|
"query_log_enable": "로그 활성화",
|
||||||
"query_log_configuration": "로그 구성",
|
"query_log_configuration": "로그 구성",
|
||||||
"query_log_disabled": "쿼리 로그가 비활성화되어 있으며 <0>설정</0>에서 설정할 수 있습니다",
|
"query_log_disabled": "쿼리 로그가 비활성화되어 있으며 <0>설정</0>에서 설정할 수 있습니다",
|
||||||
"query_log_strict_search": "검색을 제한하려면 쌍따옴표를 사용해주세요",
|
"query_log_strict_search": "검색을 제한하려면 쌍따옴표를 사용해주세요",
|
||||||
"query_log_retention_confirm": "정말로 쿼리 로그 저장 기간을 변경하시겠습니까? 저장 주기를 낮출 경우, 일부 데이터가 손실됩니다",
|
"query_log_retention_confirm": "쿼리 로그 로테이션을 변경하시겠습니까? 간격 값을 줄이면 일부 데이터가 손실됩니다.",
|
||||||
"anonymize_client_ip": "클라이언트 IP 익명화",
|
"anonymize_client_ip": "클라이언트 IP 익명화",
|
||||||
"anonymize_client_ip_desc": "클라이언트의 전체 IP 주소를 로그와 통계에 저장하저장하지 마세요",
|
"anonymize_client_ip_desc": "클라이언트의 전체 IP 주소를 로그와 통계에 저장하저장하지 마세요",
|
||||||
"dns_config": "DNS 서버 설정",
|
"dns_config": "DNS 서버 설정",
|
||||||
@@ -668,5 +668,11 @@
|
|||||||
"disable_notify_for_hours": "{{count}}시간 동안 보호 기능 비활성화",
|
"disable_notify_for_hours": "{{count}}시간 동안 보호 기능 비활성화",
|
||||||
"disable_notify_for_hours_plural": "{{count}}시간 동안 보호 기능 비활성화",
|
"disable_notify_for_hours_plural": "{{count}}시간 동안 보호 기능 비활성화",
|
||||||
"disable_notify_until_tomorrow": "내일까지 보호 기능 비활성화",
|
"disable_notify_until_tomorrow": "내일까지 보호 기능 비활성화",
|
||||||
"enable_protection_timer": "{{time}}에 보호 기능이 활성화됩니다."
|
"enable_protection_timer": "{{time}}에 보호 기능이 활성화됩니다.",
|
||||||
|
"custom_retention_input": "시간 단위로 보존 기간 입력",
|
||||||
|
"custom_rotation_input": "시간 단위로 로테이션 입력",
|
||||||
|
"protection_section_label": "보호",
|
||||||
|
"log_and_stats_section_label": "쿼리 로그 및 통계",
|
||||||
|
"ignore_query_log": "쿼리 로그에서 이 클라이언트 무시",
|
||||||
|
"ignore_statistics": "통계에서 이 클라이언트 무시"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -257,12 +257,12 @@
|
|||||||
"query_log_cleared": "Het query logboek is succesvol geleegd",
|
"query_log_cleared": "Het query logboek is succesvol geleegd",
|
||||||
"query_log_updated": "Het query logboek is succesvol bijgewerkt",
|
"query_log_updated": "Het query logboek is succesvol bijgewerkt",
|
||||||
"query_log_clear": "Leeg query logs",
|
"query_log_clear": "Leeg query logs",
|
||||||
"query_log_retention": "Query logs bewaartermijn",
|
"query_log_retention": "Query logs rotatie",
|
||||||
"query_log_enable": "Log bestanden inschakelen",
|
"query_log_enable": "Log bestanden inschakelen",
|
||||||
"query_log_configuration": "Logbestanden instellingen",
|
"query_log_configuration": "Logbestanden instellingen",
|
||||||
"query_log_disabled": "Het query logboek is uitgeschakeld en kan worden geconfigureerd in de <0>instellingen</0>",
|
"query_log_disabled": "Het query logboek is uitgeschakeld en kan worden geconfigureerd in de <0>instellingen</0>",
|
||||||
"query_log_strict_search": "Gebruik dubbele aanhalingstekens voor strikt zoeken",
|
"query_log_strict_search": "Gebruik dubbele aanhalingstekens voor strikt zoeken",
|
||||||
"query_log_retention_confirm": "Weet u zeker dat u de bewaartermijn van het query logboek wilt wijzigen? Als u de intervalwaarde verlaagt, gaan sommige gegevens verloren",
|
"query_log_retention_confirm": "Weet u zeker dat u de rotatie van het querylogboek wilt wijzigen? Als u de intervalwaarde verlaagt, gaan sommige gegevens verloren",
|
||||||
"anonymize_client_ip": "Cliënt IP anonimiseren",
|
"anonymize_client_ip": "Cliënt IP anonimiseren",
|
||||||
"anonymize_client_ip_desc": "Het volledige IP-adres van de cliënt niet opnemen in logboeken en statistiekbestanden",
|
"anonymize_client_ip_desc": "Het volledige IP-adres van de cliënt niet opnemen in logboeken en statistiekbestanden",
|
||||||
"dns_config": "DNS-server configuratie",
|
"dns_config": "DNS-server configuratie",
|
||||||
@@ -668,5 +668,11 @@
|
|||||||
"disable_notify_for_hours": "Beveiliging uitschakelen voor {{count}} uur",
|
"disable_notify_for_hours": "Beveiliging uitschakelen voor {{count}} uur",
|
||||||
"disable_notify_for_hours_plural": "Beveiliging uitschakelen voor {{count}} uren",
|
"disable_notify_for_hours_plural": "Beveiliging uitschakelen voor {{count}} uren",
|
||||||
"disable_notify_until_tomorrow": "Beveiliging uitschakelen tot morgen",
|
"disable_notify_until_tomorrow": "Beveiliging uitschakelen tot morgen",
|
||||||
"enable_protection_timer": "Bescherming wordt ingeschakeld over {{time}}"
|
"enable_protection_timer": "Bescherming wordt ingeschakeld over {{time}}",
|
||||||
|
"custom_retention_input": "Voer retentie in uren in",
|
||||||
|
"custom_rotation_input": "Voer rotatie in uren in",
|
||||||
|
"protection_section_label": "Bescherming",
|
||||||
|
"log_and_stats_section_label": "Aanvragenlogboek en statistieken",
|
||||||
|
"ignore_query_log": "Deze client negeren in het aanvragenlogboek",
|
||||||
|
"ignore_statistics": "Deze client negeren in de statistieken"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -614,5 +614,6 @@
|
|||||||
"use_saved_key": "Bruk den tidligere lagrede nøkkelen",
|
"use_saved_key": "Bruk den tidligere lagrede nøkkelen",
|
||||||
"parental_control": "Foreldrekontroll",
|
"parental_control": "Foreldrekontroll",
|
||||||
"safe_browsing": "Sikker surfing",
|
"safe_browsing": "Sikker surfing",
|
||||||
"served_from_cache": "{{value}} <i>(formidlet fra mellomlageret)</i>"
|
"served_from_cache": "{{value}} <i>(formidlet fra mellomlageret)</i>",
|
||||||
|
"protection_section_label": "Beskyttelse"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -167,6 +167,7 @@
|
|||||||
"enabled_parental_toast": "Włączona Kontrola Rodzicielska",
|
"enabled_parental_toast": "Włączona Kontrola Rodzicielska",
|
||||||
"disabled_safe_search_toast": "Wyłączone bezpieczne wyszukiwanie",
|
"disabled_safe_search_toast": "Wyłączone bezpieczne wyszukiwanie",
|
||||||
"enabled_save_search_toast": "Włączone bezpieczne wyszukiwanie",
|
"enabled_save_search_toast": "Włączone bezpieczne wyszukiwanie",
|
||||||
|
"updated_save_search_toast": "Zaktualizowano ustawienia bezpiecznego wyszukiwania",
|
||||||
"enabled_table_header": "Włączone",
|
"enabled_table_header": "Włączone",
|
||||||
"name_table_header": "Nazwa",
|
"name_table_header": "Nazwa",
|
||||||
"list_url_table_header": "Adres URL listy",
|
"list_url_table_header": "Adres URL listy",
|
||||||
@@ -256,12 +257,12 @@
|
|||||||
"query_log_cleared": "Dziennik zapytań został pomyślnie wyczyszczony",
|
"query_log_cleared": "Dziennik zapytań został pomyślnie wyczyszczony",
|
||||||
"query_log_updated": "Dziennik zapytań został zaktualizowany",
|
"query_log_updated": "Dziennik zapytań został zaktualizowany",
|
||||||
"query_log_clear": "Wyczyść dzienniki zapytań",
|
"query_log_clear": "Wyczyść dzienniki zapytań",
|
||||||
"query_log_retention": "Przechowywanie dzienników zapytań",
|
"query_log_retention": "Rotacja dzienników zapytań",
|
||||||
"query_log_enable": "Włącz dziennik",
|
"query_log_enable": "Włącz dziennik",
|
||||||
"query_log_configuration": "Konfiguracja dzienników",
|
"query_log_configuration": "Konfiguracja dzienników",
|
||||||
"query_log_disabled": "Dziennik zapytań jest wyłączony i można go skonfigurować w <0>ustawieniach</0>",
|
"query_log_disabled": "Dziennik zapytań jest wyłączony i można go skonfigurować w <0>ustawieniach</0>",
|
||||||
"query_log_strict_search": "Używaj podwójnych cudzysłowów do ścisłego wyszukiwania",
|
"query_log_strict_search": "Używaj podwójnych cudzysłowów do ścisłego wyszukiwania",
|
||||||
"query_log_retention_confirm": "Czy na pewno chcesz zmienić sposób przechowywania dziennika zapytań? Jeśli zmniejszysz wartość interwału, niektóre dane zostaną utracone",
|
"query_log_retention_confirm": "Czy na pewno chcesz zmienić rotację dziennika zapytań? Jeśli zmniejszysz wartość interwału, niektóre dane zostaną utracone",
|
||||||
"anonymize_client_ip": "Anonimizuj adres IP klienta",
|
"anonymize_client_ip": "Anonimizuj adres IP klienta",
|
||||||
"anonymize_client_ip_desc": "Nie zapisuj pełnego adresu IP w dziennikach i statystykach",
|
"anonymize_client_ip_desc": "Nie zapisuj pełnego adresu IP w dziennikach i statystykach",
|
||||||
"dns_config": "Konfiguracja serwera DNS",
|
"dns_config": "Konfiguracja serwera DNS",
|
||||||
@@ -290,6 +291,8 @@
|
|||||||
"rate_limit": "Limit ilościowy",
|
"rate_limit": "Limit ilościowy",
|
||||||
"edns_enable": "Włącz podsieć klienta EDNS",
|
"edns_enable": "Włącz podsieć klienta EDNS",
|
||||||
"edns_cs_desc": "Dodaj opcję podsieci klienta EDNS (ECS) do żądań nadrzędnych i rejestruj wartości wysyłane przez klientów w dzienniku zapytań.",
|
"edns_cs_desc": "Dodaj opcję podsieci klienta EDNS (ECS) do żądań nadrzędnych i rejestruj wartości wysyłane przez klientów w dzienniku zapytań.",
|
||||||
|
"edns_use_custom_ip": "Użyj niestandardowego adresu IP dla EDNS",
|
||||||
|
"edns_use_custom_ip_desc": "Zezwól na użycie niestandardowego adresu IP dla EDNS",
|
||||||
"rate_limit_desc": "Liczba żądań na sekundę dozwolona na klienta. Ustawienie wartości 0 oznacza brak ograniczeń.",
|
"rate_limit_desc": "Liczba żądań na sekundę dozwolona na klienta. Ustawienie wartości 0 oznacza brak ograniczeń.",
|
||||||
"blocking_ipv4_desc": "Adres IP, który ma zostać zwrócony w przypadku zablokowanego żądania A",
|
"blocking_ipv4_desc": "Adres IP, który ma zostać zwrócony w przypadku zablokowanego żądania A",
|
||||||
"blocking_ipv6_desc": "Adres IP, który ma zostać zwrócony w przypadku zablokowanego żądania AAAA",
|
"blocking_ipv6_desc": "Adres IP, który ma zostać zwrócony w przypadku zablokowanego żądania AAAA",
|
||||||
@@ -523,6 +526,10 @@
|
|||||||
"statistics_retention_confirm": "Czy chcesz zmienić sposób przechowania statystyk? Jeżeli obniżysz wartość interwału, niektóre dane będą utracone",
|
"statistics_retention_confirm": "Czy chcesz zmienić sposób przechowania statystyk? Jeżeli obniżysz wartość interwału, niektóre dane będą utracone",
|
||||||
"statistics_cleared": "Statystyki zostały pomyślnie wyczyszczone",
|
"statistics_cleared": "Statystyki zostały pomyślnie wyczyszczone",
|
||||||
"statistics_enable": "Włącz statystyki",
|
"statistics_enable": "Włącz statystyki",
|
||||||
|
"ignore_domains": "Ignorowane domeny (każda w nowym wierszu)",
|
||||||
|
"ignore_domains_title": "Ignorowane domeny",
|
||||||
|
"ignore_domains_desc_stats": "Zapytania dla tych domen nie są zapisywane do statystyk",
|
||||||
|
"ignore_domains_desc_query": "Zapytania dla tych domen nie są zapisywane do dziennika",
|
||||||
"interval_hours": "{{count}} godzina",
|
"interval_hours": "{{count}} godzina",
|
||||||
"interval_hours_plural": "{{count}} godziny",
|
"interval_hours_plural": "{{count}} godziny",
|
||||||
"filters_configuration": "Konfiguracja filtrów",
|
"filters_configuration": "Konfiguracja filtrów",
|
||||||
@@ -642,5 +649,30 @@
|
|||||||
"anonymizer_notification": "<0>Uwaga:</0> Anonimizacja IP jest włączona. Możesz ją wyłączyć w <1>Ustawieniach ogólnych</1>.",
|
"anonymizer_notification": "<0>Uwaga:</0> Anonimizacja IP jest włączona. Możesz ją wyłączyć w <1>Ustawieniach ogólnych</1>.",
|
||||||
"confirm_dns_cache_clear": "Czy na pewno chcesz wyczyścić pamięć podręczną DNS?",
|
"confirm_dns_cache_clear": "Czy na pewno chcesz wyczyścić pamięć podręczną DNS?",
|
||||||
"cache_cleared": "Pamięć podręczna DNS została pomyślnie wyczyszczona",
|
"cache_cleared": "Pamięć podręczna DNS została pomyślnie wyczyszczona",
|
||||||
"clear_cache": "Wyczyść pamięć podręczną"
|
"clear_cache": "Wyczyść pamięć podręczną",
|
||||||
|
"make_static": "Ustaw adres statyczny",
|
||||||
|
"theme_auto_desc": "Automatycznie (na podstawie schematu kolorów Twojego urządzenia)",
|
||||||
|
"theme_dark_desc": "Ciemny motyw",
|
||||||
|
"theme_light_desc": "Jasny motyw",
|
||||||
|
"disable_for_seconds": "Na {{count}} sekundę",
|
||||||
|
"disable_for_seconds_plural": "Na {{count}} sekund",
|
||||||
|
"disable_for_minutes": "Na {{count}} minutę",
|
||||||
|
"disable_for_minutes_plural": "Na {{count}} minut",
|
||||||
|
"disable_for_hours": "Na {{count}} godzinę",
|
||||||
|
"disable_for_hours_plural": "Na {{count}} godziny",
|
||||||
|
"disable_until_tomorrow": "Do jutra",
|
||||||
|
"disable_notify_for_seconds": "Wyłącz ochronę na {{count}} sekundę",
|
||||||
|
"disable_notify_for_seconds_plural": "Wyłącz ochronę na {{count}} sekund",
|
||||||
|
"disable_notify_for_minutes": "Wyłącz ochronę na {{count}} minutę",
|
||||||
|
"disable_notify_for_minutes_plural": "Wyłącz ochronę na {{count}} minut",
|
||||||
|
"disable_notify_for_hours": "Wyłącz ochronę na {{count}} godzinę",
|
||||||
|
"disable_notify_for_hours_plural": "Wyłącz ochronę na {{count}} godziny",
|
||||||
|
"disable_notify_until_tomorrow": "Wyłącz ochronę do jutra",
|
||||||
|
"enable_protection_timer": "Ochrona zostanie włączona za {{time}}",
|
||||||
|
"custom_retention_input": "Wprowadź retencję w godzinach",
|
||||||
|
"custom_rotation_input": "Wprowadź rotację w godzinach",
|
||||||
|
"protection_section_label": "Ochrona",
|
||||||
|
"log_and_stats_section_label": "Dziennik zapytań i statystyki",
|
||||||
|
"ignore_query_log": "Zignoruj tego klienta w dzienniku zapytań",
|
||||||
|
"ignore_statistics": "Ignoruj tego klienta w statystykach"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -257,12 +257,12 @@
|
|||||||
"query_log_cleared": "O registro de consulta foi limpo com sucesso",
|
"query_log_cleared": "O registro de consulta foi limpo com sucesso",
|
||||||
"query_log_updated": "O registro da consulta foi atualizado com sucesso",
|
"query_log_updated": "O registro da consulta foi atualizado com sucesso",
|
||||||
"query_log_clear": "Limpar registros de consulta",
|
"query_log_clear": "Limpar registros de consulta",
|
||||||
"query_log_retention": "Arquivamento de registros de consultas",
|
"query_log_retention": "Rotação de registros de consulta",
|
||||||
"query_log_enable": "Ativar registro",
|
"query_log_enable": "Ativar registro",
|
||||||
"query_log_configuration": "Configuração de registros",
|
"query_log_configuration": "Configuração de registros",
|
||||||
"query_log_disabled": "O registro de consulta está desativado e pode ser configurado em <0>configurações</0>",
|
"query_log_disabled": "O registro de consulta está desativado e pode ser configurado em <0>configurações</0>",
|
||||||
"query_log_strict_search": "Use aspas duplas para uma pesquisa mais criteriosa",
|
"query_log_strict_search": "Use aspas duplas para uma pesquisa mais criteriosa",
|
||||||
"query_log_retention_confirm": "Você tem certeza de que deseja alterar o arquivamento do registro de consulta? Se diminuir o valor de intervalo, alguns dados serão perdidos",
|
"query_log_retention_confirm": "Tem a certeza de que quer alterar a rotação do registo de consulta? Se diminuir o valor do intervalo, alguns dados serão perdidos",
|
||||||
"anonymize_client_ip": "Tornar anônimo o IP do cliente",
|
"anonymize_client_ip": "Tornar anônimo o IP do cliente",
|
||||||
"anonymize_client_ip_desc": "Não salva o endereço de IP completo do cliente em registros ou estatísticas",
|
"anonymize_client_ip_desc": "Não salva o endereço de IP completo do cliente em registros ou estatísticas",
|
||||||
"dns_config": "Configuração do servidor DNS",
|
"dns_config": "Configuração do servidor DNS",
|
||||||
@@ -668,5 +668,11 @@
|
|||||||
"disable_notify_for_hours": "Desativar proteção por {{count}} hora",
|
"disable_notify_for_hours": "Desativar proteção por {{count}} hora",
|
||||||
"disable_notify_for_hours_plural": "Desativar proteção por {{count}} horas",
|
"disable_notify_for_hours_plural": "Desativar proteção por {{count}} horas",
|
||||||
"disable_notify_until_tomorrow": "Desativar a proteção até amanhã",
|
"disable_notify_until_tomorrow": "Desativar a proteção até amanhã",
|
||||||
"enable_protection_timer": "A proteção será ativada em {{time}}"
|
"enable_protection_timer": "A proteção será ativada em {{time}}",
|
||||||
|
"custom_retention_input": "Insira a retenção em horas",
|
||||||
|
"custom_rotation_input": "Insira a rotação em horas",
|
||||||
|
"protection_section_label": "Proteção",
|
||||||
|
"log_and_stats_section_label": "Registro de consultas e estatísticas",
|
||||||
|
"ignore_query_log": "Ignorar este cliente no registo de consultas",
|
||||||
|
"ignore_statistics": "Ignorar este cliente nas estatísticas"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -257,12 +257,12 @@
|
|||||||
"query_log_cleared": "O registo de consulta foi limpo com sucesso",
|
"query_log_cleared": "O registo de consulta foi limpo com sucesso",
|
||||||
"query_log_updated": "O registo da consulta foi atualizado com sucesso",
|
"query_log_updated": "O registo da consulta foi atualizado com sucesso",
|
||||||
"query_log_clear": "Limpar registos de consulta",
|
"query_log_clear": "Limpar registos de consulta",
|
||||||
"query_log_retention": "Retenção de registos de consulta",
|
"query_log_retention": "Rotação de registros de consulta",
|
||||||
"query_log_enable": "Ativar registo",
|
"query_log_enable": "Ativar registo",
|
||||||
"query_log_configuration": "Definições do registo",
|
"query_log_configuration": "Definições do registo",
|
||||||
"query_log_disabled": "O registo de consulta está desativado e pode ser configurado em <0>definições</0>",
|
"query_log_disabled": "O registo de consulta está desativado e pode ser configurado em <0>definições</0>",
|
||||||
"query_log_strict_search": "Usar aspas duplas para uma pesquisa rigorosa",
|
"query_log_strict_search": "Usar aspas duplas para uma pesquisa rigorosa",
|
||||||
"query_log_retention_confirm": "Tem a certeza de que deseja alterar a retenção do registo de consulta? Se diminuir o valor do intervalo, alguns dados serão perdidos",
|
"query_log_retention_confirm": "Tem a certeza de que quer alterar a rotação do registo de consulta? Se diminuir o valor do intervalo, alguns dados serão perdidos",
|
||||||
"anonymize_client_ip": "Tornar anónimo o IP do cliente",
|
"anonymize_client_ip": "Tornar anónimo o IP do cliente",
|
||||||
"anonymize_client_ip_desc": "Não gurda o endereço de IP completo do cliente em registo ou estatísticas",
|
"anonymize_client_ip_desc": "Não gurda o endereço de IP completo do cliente em registo ou estatísticas",
|
||||||
"dns_config": "Definição do servidor DNS",
|
"dns_config": "Definição do servidor DNS",
|
||||||
@@ -668,5 +668,11 @@
|
|||||||
"disable_notify_for_hours": "Desativar proteção por {{count}} hora",
|
"disable_notify_for_hours": "Desativar proteção por {{count}} hora",
|
||||||
"disable_notify_for_hours_plural": "Desativar proteção por {{count}} horas",
|
"disable_notify_for_hours_plural": "Desativar proteção por {{count}} horas",
|
||||||
"disable_notify_until_tomorrow": "Desativar a proteção até amanhã",
|
"disable_notify_until_tomorrow": "Desativar a proteção até amanhã",
|
||||||
"enable_protection_timer": "A proteção será habilitada em {{time}}"
|
"enable_protection_timer": "A proteção será habilitada em {{time}}",
|
||||||
|
"custom_retention_input": "Insira a retenção em horas",
|
||||||
|
"custom_rotation_input": "Insira a rotação em horas",
|
||||||
|
"protection_section_label": "Proteção",
|
||||||
|
"log_and_stats_section_label": "Log de consulta e estatísticas",
|
||||||
|
"ignore_query_log": "Ignorar este cliente no log de consulta",
|
||||||
|
"ignore_statistics": "Ignorar este cliente nas estatísticas"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -642,5 +642,6 @@
|
|||||||
"anonymizer_notification": "<0>Nota:</0> Anonimizarea IP este activată. Puteți să o dezactivați în <1>Setări generale</1>.",
|
"anonymizer_notification": "<0>Nota:</0> Anonimizarea IP este activată. Puteți să o dezactivați în <1>Setări generale</1>.",
|
||||||
"confirm_dns_cache_clear": "Sunteți sigur că doriți să ștergeți memoria cache DNS?",
|
"confirm_dns_cache_clear": "Sunteți sigur că doriți să ștergeți memoria cache DNS?",
|
||||||
"cache_cleared": "Cache-ul DNS a fost golit cu succes",
|
"cache_cleared": "Cache-ul DNS a fost golit cu succes",
|
||||||
"clear_cache": "Goliți memoria cache"
|
"clear_cache": "Goliți memoria cache",
|
||||||
|
"protection_section_label": "Protecție"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -257,12 +257,12 @@
|
|||||||
"query_log_cleared": "Журнал запросов успешно очищен",
|
"query_log_cleared": "Журнал запросов успешно очищен",
|
||||||
"query_log_updated": "Журнал запросов успешно обновлён",
|
"query_log_updated": "Журнал запросов успешно обновлён",
|
||||||
"query_log_clear": "Очистить журнал запросов",
|
"query_log_clear": "Очистить журнал запросов",
|
||||||
"query_log_retention": "Сохранение журнала запросов",
|
"query_log_retention": "Частота ротации журнала запросов",
|
||||||
"query_log_enable": "Включить журнал",
|
"query_log_enable": "Включить журнал",
|
||||||
"query_log_configuration": "Настройка журнала",
|
"query_log_configuration": "Настройка журнала",
|
||||||
"query_log_disabled": "Журнал запросов выключен, его можно включить в <0>настройках</0>",
|
"query_log_disabled": "Журнал запросов выключен, его можно включить в <0>настройках</0>",
|
||||||
"query_log_strict_search": "Используйте двойные кавычки для строгого поиска",
|
"query_log_strict_search": "Используйте двойные кавычки для строгого поиска",
|
||||||
"query_log_retention_confirm": "Вы уверены, что хотите изменить срок хранения запросов? При сокращении интервала данные могут быть утеряны",
|
"query_log_retention_confirm": "Вы уверены, что хотите изменить частоту ротации журнала запросов? При сокращении срока данные могут быть утеряны",
|
||||||
"anonymize_client_ip": "Анонимизировать IP-адрес клиента",
|
"anonymize_client_ip": "Анонимизировать IP-адрес клиента",
|
||||||
"anonymize_client_ip_desc": "Не сохранять полный IP-адрес клиента в журналах и статистике",
|
"anonymize_client_ip_desc": "Не сохранять полный IP-адрес клиента в журналах и статистике",
|
||||||
"dns_config": "Настройки DNS-сервера",
|
"dns_config": "Настройки DNS-сервера",
|
||||||
@@ -668,5 +668,11 @@
|
|||||||
"disable_notify_for_hours": "Отключить защиту на {{count}} час",
|
"disable_notify_for_hours": "Отключить защиту на {{count}} час",
|
||||||
"disable_notify_for_hours_plural": "Отключить защиту на {{count}} часов",
|
"disable_notify_for_hours_plural": "Отключить защиту на {{count}} часов",
|
||||||
"disable_notify_until_tomorrow": "Отключить защиту до завтра",
|
"disable_notify_until_tomorrow": "Отключить защиту до завтра",
|
||||||
"enable_protection_timer": "Защита будет включена в {{time}}"
|
"enable_protection_timer": "Защита будет включена в {{time}}",
|
||||||
|
"custom_retention_input": "Введите срок хранения в часах",
|
||||||
|
"custom_rotation_input": "Введите частоту ротации в часах",
|
||||||
|
"protection_section_label": "Защита",
|
||||||
|
"log_and_stats_section_label": "Журнал запросов и статистика",
|
||||||
|
"ignore_query_log": "Игнорировать этого клиента в журнале запросов",
|
||||||
|
"ignore_statistics": "Игнорировать этого клиента в статистике"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -257,12 +257,12 @@
|
|||||||
"query_log_cleared": "Denník dopytov bol úspešne vymazaný",
|
"query_log_cleared": "Denník dopytov bol úspešne vymazaný",
|
||||||
"query_log_updated": "Denník dopytov bol úspešne aktualizovaný",
|
"query_log_updated": "Denník dopytov bol úspešne aktualizovaný",
|
||||||
"query_log_clear": "Vymazať denníky dopytov",
|
"query_log_clear": "Vymazať denníky dopytov",
|
||||||
"query_log_retention": "Obdobie záznamu denníka dopytov",
|
"query_log_retention": "Rotácia denníkov dopytov",
|
||||||
"query_log_enable": "Zapnúť denník",
|
"query_log_enable": "Zapnúť denník",
|
||||||
"query_log_configuration": "Konfigurácia denníka",
|
"query_log_configuration": "Konfigurácia denníka",
|
||||||
"query_log_disabled": "Protokol dopytov je vypnutý a možno ho nakonfigurovať v <0>nastaveniach</0>",
|
"query_log_disabled": "Protokol dopytov je vypnutý a možno ho nakonfigurovať v <0>nastaveniach</0>",
|
||||||
"query_log_strict_search": "Na prísne vyhľadávanie použite dvojité úvodzovky",
|
"query_log_strict_search": "Na prísne vyhľadávanie použite dvojité úvodzovky",
|
||||||
"query_log_retention_confirm": "Naozaj chcete zmeniť uchovávanie denníku dopytov? Ak znížite hodnotu intervalu, niektoré údaje sa stratia",
|
"query_log_retention_confirm": "Naozaj chcete zmeniť rotáciu denníka dopytov? Ak znížite hodnotu intervalu, niektoré údaje sa stratia",
|
||||||
"anonymize_client_ip": "Anonymizujte IP klienta",
|
"anonymize_client_ip": "Anonymizujte IP klienta",
|
||||||
"anonymize_client_ip_desc": "Neukladať úplnú IP adresu klienta do protokolov a štatistík",
|
"anonymize_client_ip_desc": "Neukladať úplnú IP adresu klienta do protokolov a štatistík",
|
||||||
"dns_config": "Konfigurácia DNS servera",
|
"dns_config": "Konfigurácia DNS servera",
|
||||||
@@ -668,5 +668,11 @@
|
|||||||
"disable_notify_for_hours": "Vypnite ochranu na {{count}} hodinu",
|
"disable_notify_for_hours": "Vypnite ochranu na {{count}} hodinu",
|
||||||
"disable_notify_for_hours_plural": "Vypnite ochranu na {{count}} hodín",
|
"disable_notify_for_hours_plural": "Vypnite ochranu na {{count}} hodín",
|
||||||
"disable_notify_until_tomorrow": "Vypnúť ochranu do zajtra",
|
"disable_notify_until_tomorrow": "Vypnúť ochranu do zajtra",
|
||||||
"enable_protection_timer": "Ochrana bude zapnutá o {{time}}"
|
"enable_protection_timer": "Ochrana bude zapnutá o {{time}}",
|
||||||
|
"custom_retention_input": "Zadajte retenciu v hodinách",
|
||||||
|
"custom_rotation_input": "Zadajte rotáciu v hodinách",
|
||||||
|
"protection_section_label": "Ochrana",
|
||||||
|
"log_and_stats_section_label": "Protokol dopytov a štatistiky",
|
||||||
|
"ignore_query_log": "Ignorovať tohto klienta v denníku dopytov",
|
||||||
|
"ignore_statistics": "Ignorovanie tohto klienta v štatistikách"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -257,12 +257,12 @@
|
|||||||
"query_log_cleared": "Dnevnik poizvedb je uspešno izbrisan",
|
"query_log_cleared": "Dnevnik poizvedb je uspešno izbrisan",
|
||||||
"query_log_updated": "Dnevnik poizvedb je bil uspešno posodobljen",
|
"query_log_updated": "Dnevnik poizvedb je bil uspešno posodobljen",
|
||||||
"query_log_clear": "Počisti dnevnike poizvedb",
|
"query_log_clear": "Počisti dnevnike poizvedb",
|
||||||
"query_log_retention": "Zadrževanje dnevnikov poizvedb",
|
"query_log_retention": "Rotacija dnevnikov poizvedb",
|
||||||
"query_log_enable": "Omogoči dnevni",
|
"query_log_enable": "Omogoči dnevni",
|
||||||
"query_log_configuration": "Konfiguracija dnevnikov",
|
"query_log_configuration": "Konfiguracija dnevnikov",
|
||||||
"query_log_disabled": "Dnevnik poizvedb je onemogočen in ga je mogoče konfigurirati v <0>nastavitvah</0>",
|
"query_log_disabled": "Dnevnik poizvedb je onemogočen in ga je mogoče konfigurirati v <0>nastavitvah</0>",
|
||||||
"query_log_strict_search": "Za strogo iskanje uporabite dvojne narekovaje",
|
"query_log_strict_search": "Za strogo iskanje uporabite dvojne narekovaje",
|
||||||
"query_log_retention_confirm": "Ali ste prepričani, da želite spremeniti zadrževanje dnevnika poizvedb? Če zmanjšate vrednost intervala, bodo nekateri podatki izgubljeni",
|
"query_log_retention_confirm": "Ali ste prepričani, da želite spremeniti rotacijo dnevnika poizvedb? Če zmanjšate vrednost intervala, bodo nekateri podatki izgubljeni",
|
||||||
"anonymize_client_ip": "Anonimiziraj odjemalca IP",
|
"anonymize_client_ip": "Anonimiziraj odjemalca IP",
|
||||||
"anonymize_client_ip_desc": "Ne shrani celotnega naslova IP odjemalca v dnevnikih ali statistiki",
|
"anonymize_client_ip_desc": "Ne shrani celotnega naslova IP odjemalca v dnevnikih ali statistiki",
|
||||||
"dns_config": "Konfiguracija strežnika DNS",
|
"dns_config": "Konfiguracija strežnika DNS",
|
||||||
@@ -668,5 +668,11 @@
|
|||||||
"disable_notify_for_hours": "Onemogoči zaščito za {{count}} uro",
|
"disable_notify_for_hours": "Onemogoči zaščito za {{count}} uro",
|
||||||
"disable_notify_for_hours_plural": "Onemogoči zaščito za {{count}} ur",
|
"disable_notify_for_hours_plural": "Onemogoči zaščito za {{count}} ur",
|
||||||
"disable_notify_until_tomorrow": "Onemogoči zaščito do jutri",
|
"disable_notify_until_tomorrow": "Onemogoči zaščito do jutri",
|
||||||
"enable_protection_timer": "Zaščita bo omogočena ob {{time}}"
|
"enable_protection_timer": "Zaščita bo omogočena ob {{time}}",
|
||||||
|
"custom_retention_input": "Vnesite zadrževanje v urah",
|
||||||
|
"custom_rotation_input": "Vnesite rotacijo v urah",
|
||||||
|
"protection_section_label": "Zaščita",
|
||||||
|
"log_and_stats_section_label": "Dnevnik poizvedb in statistika",
|
||||||
|
"ignore_query_log": "Ignorirajte tega odjemalca v dnevniku poizvedb",
|
||||||
|
"ignore_statistics": "Ignoriranje tega odjemalca v statistiki"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -642,5 +642,6 @@
|
|||||||
"anonymizer_notification": "<0>Nota:</0> IP prepoznavanje je omogućeno. Možete ga onemogućiti u opštim <1>postavkama</1>.",
|
"anonymizer_notification": "<0>Nota:</0> IP prepoznavanje je omogućeno. Možete ga onemogućiti u opštim <1>postavkama</1>.",
|
||||||
"confirm_dns_cache_clear": "Želite li zaista da obrišite DNS keš?",
|
"confirm_dns_cache_clear": "Želite li zaista da obrišite DNS keš?",
|
||||||
"cache_cleared": "DNS keš je uspešno očišćen",
|
"cache_cleared": "DNS keš je uspešno očišćen",
|
||||||
"clear_cache": "Obriši keš memoriju"
|
"clear_cache": "Obriši keš memoriju",
|
||||||
|
"protection_section_label": "Zaštita"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -257,12 +257,12 @@
|
|||||||
"query_log_cleared": "Sorgu günlüğü başarıyla temizlendi",
|
"query_log_cleared": "Sorgu günlüğü başarıyla temizlendi",
|
||||||
"query_log_updated": "Sorgu günlüğü başarıyla güncellendi",
|
"query_log_updated": "Sorgu günlüğü başarıyla güncellendi",
|
||||||
"query_log_clear": "Sorgu günlüklerini temizle",
|
"query_log_clear": "Sorgu günlüklerini temizle",
|
||||||
"query_log_retention": "Sorgu günlüklerini sakla",
|
"query_log_retention": "Sorgu günlükleri rotasyonu",
|
||||||
"query_log_enable": "Günlüğü etkinleştir",
|
"query_log_enable": "Günlüğü etkinleştir",
|
||||||
"query_log_configuration": "Günlük yapılandırması",
|
"query_log_configuration": "Günlük yapılandırması",
|
||||||
"query_log_disabled": "Sorgu günlüğü devre dışı bırakıldı, bunu <0>ayarlar</0> kısmından yapılandırılabilirsiniz",
|
"query_log_disabled": "Sorgu günlüğü devre dışı bırakıldı, bunu <0>ayarlar</0> kısmından yapılandırılabilirsiniz",
|
||||||
"query_log_strict_search": "Tam arama için çift tırnak işareti kullanın",
|
"query_log_strict_search": "Tam arama için çift tırnak işareti kullanın",
|
||||||
"query_log_retention_confirm": "Sorgu günlüğü saklama süresini değiştirmek istediğinize emin misiniz? Aralık değerini azaltırsanız, bazı veriler kaybolacaktır",
|
"query_log_retention_confirm": "Sorgu günlüğü rotasyonunu değiştirmek istediğinizden emin misiniz? Aralık değerini düşürürseniz, bazı veriler kaybolacaktır.",
|
||||||
"anonymize_client_ip": "İstemcinin IP adresini gizle",
|
"anonymize_client_ip": "İstemcinin IP adresini gizle",
|
||||||
"anonymize_client_ip_desc": "İstemcinin tam IP adresini günlüklere veya istatistiklere kaydetmeyin",
|
"anonymize_client_ip_desc": "İstemcinin tam IP adresini günlüklere veya istatistiklere kaydetmeyin",
|
||||||
"dns_config": "DNS sunucu yapılandırması",
|
"dns_config": "DNS sunucu yapılandırması",
|
||||||
@@ -668,5 +668,11 @@
|
|||||||
"disable_notify_for_hours": "Korumayı {{count}} saatliğine devre dışı bırak",
|
"disable_notify_for_hours": "Korumayı {{count}} saatliğine devre dışı bırak",
|
||||||
"disable_notify_for_hours_plural": "Korumayı {{count}} saatliğine devre dışı bırak",
|
"disable_notify_for_hours_plural": "Korumayı {{count}} saatliğine devre dışı bırak",
|
||||||
"disable_notify_until_tomorrow": "Korumayı yarına kadar devre dışı bırak",
|
"disable_notify_until_tomorrow": "Korumayı yarına kadar devre dışı bırak",
|
||||||
"enable_protection_timer": "Koruma {{time}} içinde etkinleştirilecektir"
|
"enable_protection_timer": "Koruma {{time}} içinde etkinleştirilecektir",
|
||||||
|
"custom_retention_input": "Saklama süresini saat olarak girin",
|
||||||
|
"custom_rotation_input": "Rotasyonu saat cinsinden girin",
|
||||||
|
"protection_section_label": "Koruma",
|
||||||
|
"log_and_stats_section_label": "Sorgu günlüğü ve istatistikler",
|
||||||
|
"ignore_query_log": "Sorgu günlüğünde bu istemciyi yoksay",
|
||||||
|
"ignore_statistics": "İstatistiklerde bu istemciyi yoksay"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -642,5 +642,6 @@
|
|||||||
"anonymizer_notification": "<0>Примітка:</0> IP-анонімізацію ввімкнено. Ви можете вимкнути його в <1>Загальні налаштування</1> .",
|
"anonymizer_notification": "<0>Примітка:</0> IP-анонімізацію ввімкнено. Ви можете вимкнути його в <1>Загальні налаштування</1> .",
|
||||||
"confirm_dns_cache_clear": "Ви впевнені, що бажаєте очистити кеш DNS?",
|
"confirm_dns_cache_clear": "Ви впевнені, що бажаєте очистити кеш DNS?",
|
||||||
"cache_cleared": "Кеш DNS успішно очищено",
|
"cache_cleared": "Кеш DNS успішно очищено",
|
||||||
"clear_cache": "Очистити кеш"
|
"clear_cache": "Очистити кеш",
|
||||||
|
"protection_section_label": "Захист"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -642,5 +642,6 @@
|
|||||||
"anonymizer_notification": "<0> Lưu ý:</0> Tính năng ẩn danh IP được bật. Bạn có thể tắt nó trong <1> Cài đặt chung</1>.",
|
"anonymizer_notification": "<0> Lưu ý:</0> Tính năng ẩn danh IP được bật. Bạn có thể tắt nó trong <1> Cài đặt chung</1>.",
|
||||||
"confirm_dns_cache_clear": "Bạn có chắc chắn muốn xóa bộ đệm ẩn DNS không?",
|
"confirm_dns_cache_clear": "Bạn có chắc chắn muốn xóa bộ đệm ẩn DNS không?",
|
||||||
"cache_cleared": "Đã xóa thành công bộ đệm DNS",
|
"cache_cleared": "Đã xóa thành công bộ đệm DNS",
|
||||||
"clear_cache": "Xóa bộ nhớ cache"
|
"clear_cache": "Xóa bộ nhớ cache",
|
||||||
|
"protection_section_label": "Sự bảo vệ"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -257,12 +257,12 @@
|
|||||||
"query_log_cleared": "查询日志已成功清除",
|
"query_log_cleared": "查询日志已成功清除",
|
||||||
"query_log_updated": "已成功更新查询日志",
|
"query_log_updated": "已成功更新查询日志",
|
||||||
"query_log_clear": "清除查询日志",
|
"query_log_clear": "清除查询日志",
|
||||||
"query_log_retention": "查询记录保留时间",
|
"query_log_retention": "查询日志保留时间",
|
||||||
"query_log_enable": "启用日志",
|
"query_log_enable": "启用日志",
|
||||||
"query_log_configuration": "日志配置",
|
"query_log_configuration": "日志配置",
|
||||||
"query_log_disabled": "查询日志已禁用,在<0>这些设置</0>中能配置它们",
|
"query_log_disabled": "查询日志已禁用,在<0>这些设置</0>中能配置它们",
|
||||||
"query_log_strict_search": "使用双引号进行严谨搜索",
|
"query_log_strict_search": "使用双引号进行严谨搜索",
|
||||||
"query_log_retention_confirm": "您确定要更改查询记录保留时间吗? 如果您减少间隔时间的值, 某些数据可能会丢失。",
|
"query_log_retention_confirm": "您确定要更改查询记录保留时间吗?如果减少时间间隔数值,某些数据可能会丢失",
|
||||||
"anonymize_client_ip": "匿名化客户端IP",
|
"anonymize_client_ip": "匿名化客户端IP",
|
||||||
"anonymize_client_ip_desc": "不要在日志和统计信息中保存客户端的完整 IP 地址",
|
"anonymize_client_ip_desc": "不要在日志和统计信息中保存客户端的完整 IP 地址",
|
||||||
"dns_config": "DNS 服务配置",
|
"dns_config": "DNS 服务配置",
|
||||||
@@ -668,5 +668,11 @@
|
|||||||
"disable_notify_for_hours": "禁用保护 {{count}} 小时",
|
"disable_notify_for_hours": "禁用保护 {{count}} 小时",
|
||||||
"disable_notify_for_hours_plural": "禁用保护 {{count}} 小时",
|
"disable_notify_for_hours_plural": "禁用保护 {{count}} 小时",
|
||||||
"disable_notify_until_tomorrow": "禁用保护直到明天",
|
"disable_notify_until_tomorrow": "禁用保护直到明天",
|
||||||
"enable_protection_timer": "保护将于 {{time}} 启用"
|
"enable_protection_timer": "保护将于 {{time}} 启用",
|
||||||
|
"custom_retention_input": "输入保留时间(小时)",
|
||||||
|
"custom_rotation_input": "输入旋转时间(小时)",
|
||||||
|
"protection_section_label": "防护",
|
||||||
|
"log_and_stats_section_label": "查询日志和统计数据",
|
||||||
|
"ignore_query_log": "在查询日志中忽略此客户端",
|
||||||
|
"ignore_statistics": "在统计数据中忽略此客户端"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -257,12 +257,12 @@
|
|||||||
"query_log_cleared": "該查詢記錄已被成功地清除",
|
"query_log_cleared": "該查詢記錄已被成功地清除",
|
||||||
"query_log_updated": "該查詢記錄已被成功地更新",
|
"query_log_updated": "該查詢記錄已被成功地更新",
|
||||||
"query_log_clear": "清除查詢記錄",
|
"query_log_clear": "清除查詢記錄",
|
||||||
"query_log_retention": "查詢記錄保留",
|
"query_log_retention": "查詢記錄保留時間",
|
||||||
"query_log_enable": "啟用記錄",
|
"query_log_enable": "啟用記錄",
|
||||||
"query_log_configuration": "記錄配置",
|
"query_log_configuration": "記錄配置",
|
||||||
"query_log_disabled": "查詢記錄被禁用並可在<0>設定</0>中被配置",
|
"query_log_disabled": "查詢記錄被禁用並可在<0>設定</0>中被配置",
|
||||||
"query_log_strict_search": "使用雙引號於嚴謹的搜尋",
|
"query_log_strict_search": "使用雙引號於嚴謹的搜尋",
|
||||||
"query_log_retention_confirm": "您確定您想要更改查詢記錄保留嗎?如果您減少該間隔值,某些資料將被丟失",
|
"query_log_retention_confirm": "您確定要更改記錄檔保存期限嗎?如果您縮短期限部分資料可能將會遺失",
|
||||||
"anonymize_client_ip": "將用戶端 IP 匿名",
|
"anonymize_client_ip": "將用戶端 IP 匿名",
|
||||||
"anonymize_client_ip_desc": "不要儲存用戶端之完整的 IP 位址到記錄或統計資料裡",
|
"anonymize_client_ip_desc": "不要儲存用戶端之完整的 IP 位址到記錄或統計資料裡",
|
||||||
"dns_config": "DNS 伺服器配置",
|
"dns_config": "DNS 伺服器配置",
|
||||||
@@ -668,5 +668,11 @@
|
|||||||
"disable_notify_for_hours": "計 {{count}} 小時禁用防護",
|
"disable_notify_for_hours": "計 {{count}} 小時禁用防護",
|
||||||
"disable_notify_for_hours_plural": "計 {{count}} 小時禁用防護",
|
"disable_notify_for_hours_plural": "計 {{count}} 小時禁用防護",
|
||||||
"disable_notify_until_tomorrow": "禁用防護直到明天",
|
"disable_notify_until_tomorrow": "禁用防護直到明天",
|
||||||
"enable_protection_timer": "防護將於 {{time}} 被啟用"
|
"enable_protection_timer": "防護將於 {{time}} 被啟用",
|
||||||
|
"custom_retention_input": "輸入保留時間(小時)",
|
||||||
|
"custom_rotation_input": "輸入旋轉時間(小時)",
|
||||||
|
"protection_section_label": "防護",
|
||||||
|
"log_and_stats_section_label": "查詢記錄和統計資料",
|
||||||
|
"ignore_query_log": "在查詢記錄中忽略此用戶端",
|
||||||
|
"ignore_statistics": "在統計資料中忽略此用戶端"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,6 +49,9 @@ export const setTlsConfig = (config) => async (dispatch, getState) => {
|
|||||||
|
|
||||||
const dnsStatus = await apiClient.getGlobalStatus();
|
const dnsStatus = await apiClient.getGlobalStatus();
|
||||||
if (dnsStatus) {
|
if (dnsStatus) {
|
||||||
|
if (dnsStatus.protection_disabled_duration === 0) {
|
||||||
|
dnsStatus.protection_disabled_duration = null;
|
||||||
|
}
|
||||||
dispatch(dnsStatusSuccess(dnsStatus));
|
dispatch(dnsStatusSuccess(dnsStatus));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,21 +2,6 @@ import { createAction } from 'redux-actions';
|
|||||||
import apiClient from '../api/Api';
|
import apiClient from '../api/Api';
|
||||||
import { addErrorToast, addSuccessToast } from './toasts';
|
import { addErrorToast, addSuccessToast } from './toasts';
|
||||||
|
|
||||||
export const getBlockedServicesAvailableServicesRequest = createAction('GET_BLOCKED_SERVICES_AVAILABLE_SERVICES_REQUEST');
|
|
||||||
export const getBlockedServicesAvailableServicesFailure = createAction('GET_BLOCKED_SERVICES_AVAILABLE_SERVICES_FAILURE');
|
|
||||||
export const getBlockedServicesAvailableServicesSuccess = createAction('GET_BLOCKED_SERVICES_AVAILABLE_SERVICES_SUCCESS');
|
|
||||||
|
|
||||||
export const getBlockedServicesAvailableServices = () => async (dispatch) => {
|
|
||||||
dispatch(getBlockedServicesAvailableServicesRequest());
|
|
||||||
try {
|
|
||||||
const data = await apiClient.getBlockedServicesAvailableServices();
|
|
||||||
dispatch(getBlockedServicesAvailableServicesSuccess(data));
|
|
||||||
} catch (error) {
|
|
||||||
dispatch(addErrorToast({ error }));
|
|
||||||
dispatch(getBlockedServicesAvailableServicesFailure());
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
export const getBlockedServicesRequest = createAction('GET_BLOCKED_SERVICES_REQUEST');
|
export const getBlockedServicesRequest = createAction('GET_BLOCKED_SERVICES_REQUEST');
|
||||||
export const getBlockedServicesFailure = createAction('GET_BLOCKED_SERVICES_FAILURE');
|
export const getBlockedServicesFailure = createAction('GET_BLOCKED_SERVICES_FAILURE');
|
||||||
export const getBlockedServicesSuccess = createAction('GET_BLOCKED_SERVICES_SUCCESS');
|
export const getBlockedServicesSuccess = createAction('GET_BLOCKED_SERVICES_SUCCESS');
|
||||||
|
|||||||
@@ -479,19 +479,12 @@ class Api {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Blocked services
|
// Blocked services
|
||||||
BLOCKED_SERVICES_SERVICES = { path: 'blocked_services/services', method: 'GET' };
|
|
||||||
|
|
||||||
BLOCKED_SERVICES_LIST = { path: 'blocked_services/list', method: 'GET' };
|
BLOCKED_SERVICES_LIST = { path: 'blocked_services/list', method: 'GET' };
|
||||||
|
|
||||||
BLOCKED_SERVICES_SET = { path: 'blocked_services/set', method: 'POST' };
|
BLOCKED_SERVICES_SET = { path: 'blocked_services/set', method: 'POST' };
|
||||||
|
|
||||||
BLOCKED_SERVICES_ALL = { path: 'blocked_services/all', method: 'GET' };
|
BLOCKED_SERVICES_ALL = { path: 'blocked_services/all', method: 'GET' };
|
||||||
|
|
||||||
getBlockedServicesAvailableServices() {
|
|
||||||
const { path, method } = this.BLOCKED_SERVICES_SERVICES;
|
|
||||||
return this.makeRequest(path, method);
|
|
||||||
}
|
|
||||||
|
|
||||||
getAllBlockedServices() {
|
getAllBlockedServices() {
|
||||||
const { path, method } = this.BLOCKED_SERVICES_ALL;
|
const { path, method } = this.BLOCKED_SERVICES_ALL;
|
||||||
return this.makeRequest(path, method);
|
return this.makeRequest(path, method);
|
||||||
|
|||||||
@@ -165,8 +165,7 @@ const App = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const colorSchemeMedia = window.matchMedia('(prefers-color-scheme: dark)');
|
const colorSchemeMedia = window.matchMedia('(prefers-color-scheme: dark)');
|
||||||
const prefersDark = colorSchemeMedia.matches;
|
setUITheme(theme);
|
||||||
setUITheme(prefersDark ? THEMES.dark : THEMES.light);
|
|
||||||
|
|
||||||
if (colorSchemeMedia.addEventListener !== undefined) {
|
if (colorSchemeMedia.addEventListener !== undefined) {
|
||||||
colorSchemeMedia.addEventListener('change', (e) => {
|
colorSchemeMedia.addEventListener('change', (e) => {
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ import { MODAL_TYPE } from '../../helpers/constants';
|
|||||||
|
|
||||||
import {
|
import {
|
||||||
getCurrentFilter,
|
getCurrentFilter,
|
||||||
getObjDiff,
|
|
||||||
} from '../../helpers/helpers';
|
} from '../../helpers/helpers';
|
||||||
|
|
||||||
import filtersCatalog from '../../helpers/filters/filters';
|
import filtersCatalog from '../../helpers/filters/filters';
|
||||||
@@ -22,7 +21,7 @@ class DnsBlocklist extends Component {
|
|||||||
this.props.getFilteringStatus();
|
this.props.getFilteringStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
handleSubmit = (values, _, { initialValues }) => {
|
handleSubmit = (values) => {
|
||||||
const { modalFilterUrl, modalType } = this.props.filtering;
|
const { modalFilterUrl, modalType } = this.props.filtering;
|
||||||
|
|
||||||
switch (modalType) {
|
switch (modalType) {
|
||||||
@@ -35,7 +34,12 @@ class DnsBlocklist extends Component {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case MODAL_TYPE.CHOOSE_FILTERING_LIST: {
|
case MODAL_TYPE.CHOOSE_FILTERING_LIST: {
|
||||||
const changedValues = getObjDiff(initialValues, values);
|
const changedValues = Object.entries(values)?.reduce((acc, [key, value]) => {
|
||||||
|
if (value && key in filtersCatalog.filters) {
|
||||||
|
acc[key] = value;
|
||||||
|
}
|
||||||
|
return acc;
|
||||||
|
}, {});
|
||||||
|
|
||||||
Object.keys(changedValues)
|
Object.keys(changedValues)
|
||||||
.forEach((fieldName) => {
|
.forEach((fieldName) => {
|
||||||
|
|||||||
@@ -41,6 +41,17 @@ const settingsCheckboxes = [
|
|||||||
placeholder: 'use_adguard_parental',
|
placeholder: 'use_adguard_parental',
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const logAndStatsCheckboxes = [
|
||||||
|
{
|
||||||
|
name: 'ignore_querylog',
|
||||||
|
placeholder: 'ignore_query_log',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'ignore_statistics',
|
||||||
|
placeholder: 'ignore_statistics',
|
||||||
|
},
|
||||||
|
];
|
||||||
const validate = (values) => {
|
const validate = (values) => {
|
||||||
const errors = {};
|
const errors = {};
|
||||||
const { name, ids } = values;
|
const { name, ids } = values;
|
||||||
@@ -148,6 +159,9 @@ let Form = (props) => {
|
|||||||
settings: {
|
settings: {
|
||||||
title: 'settings',
|
title: 'settings',
|
||||||
component: <div label="settings" title={props.t('main_settings')}>
|
component: <div label="settings" title={props.t('main_settings')}>
|
||||||
|
<div className="form__label--bot form__label--bold">
|
||||||
|
{t('protection_section_label')}
|
||||||
|
</div>
|
||||||
{settingsCheckboxes.map((setting) => (
|
{settingsCheckboxes.map((setting) => (
|
||||||
<div className="form__group" key={setting.name}>
|
<div className="form__group" key={setting.name}>
|
||||||
<Field
|
<Field
|
||||||
@@ -185,6 +199,19 @@ let Form = (props) => {
|
|||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
|
<div className="form__label--bold form__label--top form__label--bot">
|
||||||
|
{t('log_and_stats_section_label')}
|
||||||
|
</div>
|
||||||
|
{logAndStatsCheckboxes.map((setting) => (
|
||||||
|
<div className="form__group" key={setting.name}>
|
||||||
|
<Field
|
||||||
|
name={setting.name}
|
||||||
|
type="checkbox"
|
||||||
|
component={CheckboxField}
|
||||||
|
placeholder={t(setting.placeholder)}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
</div>,
|
</div>,
|
||||||
},
|
},
|
||||||
block_services: {
|
block_services: {
|
||||||
|
|||||||
@@ -1,25 +1,37 @@
|
|||||||
import React from 'react';
|
import React, { useEffect } from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import { Field, reduxForm } from 'redux-form';
|
import {
|
||||||
|
change,
|
||||||
|
Field,
|
||||||
|
formValueSelector,
|
||||||
|
reduxForm,
|
||||||
|
} from 'redux-form';
|
||||||
|
import { connect } from 'react-redux';
|
||||||
import { Trans, withTranslation } from 'react-i18next';
|
import { Trans, withTranslation } from 'react-i18next';
|
||||||
import flow from 'lodash/flow';
|
import flow from 'lodash/flow';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
CheckboxField,
|
CheckboxField,
|
||||||
renderRadioField,
|
|
||||||
toFloatNumber,
|
toFloatNumber,
|
||||||
renderTextareaField,
|
renderTextareaField, renderInputField, renderRadioField,
|
||||||
} from '../../../helpers/form';
|
} from '../../../helpers/form';
|
||||||
import {
|
import {
|
||||||
FORM_NAME,
|
FORM_NAME,
|
||||||
QUERY_LOG_INTERVALS_DAYS,
|
QUERY_LOG_INTERVALS_DAYS,
|
||||||
HOUR,
|
HOUR,
|
||||||
DAY,
|
DAY,
|
||||||
|
RETENTION_CUSTOM,
|
||||||
|
RETENTION_CUSTOM_INPUT,
|
||||||
|
RETENTION_RANGE,
|
||||||
|
CUSTOM_INTERVAL,
|
||||||
} from '../../../helpers/constants';
|
} from '../../../helpers/constants';
|
||||||
import '../FormButton.css';
|
import '../FormButton.css';
|
||||||
|
|
||||||
|
|
||||||
const getIntervalTitle = (interval, t) => {
|
const getIntervalTitle = (interval, t) => {
|
||||||
switch (interval) {
|
switch (interval) {
|
||||||
|
case RETENTION_CUSTOM:
|
||||||
|
return t('settings_custom');
|
||||||
case 6 * HOUR:
|
case 6 * HOUR:
|
||||||
return t('interval_6_hour');
|
return t('interval_6_hour');
|
||||||
case DAY:
|
case DAY:
|
||||||
@@ -42,11 +54,26 @@ const getIntervalFields = (processing, t, toNumber) => QUERY_LOG_INTERVALS_DAYS.
|
|||||||
/>
|
/>
|
||||||
));
|
));
|
||||||
|
|
||||||
const Form = (props) => {
|
let Form = (props) => {
|
||||||
const {
|
const {
|
||||||
handleSubmit, submitting, invalid, processing, processingClear, handleClear, t,
|
handleSubmit,
|
||||||
|
submitting,
|
||||||
|
invalid,
|
||||||
|
processing,
|
||||||
|
processingClear,
|
||||||
|
handleClear,
|
||||||
|
t,
|
||||||
|
interval,
|
||||||
|
customInterval,
|
||||||
|
dispatch,
|
||||||
} = props;
|
} = props;
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (QUERY_LOG_INTERVALS_DAYS.includes(interval)) {
|
||||||
|
dispatch(change(FORM_NAME.LOG_CONFIG, CUSTOM_INTERVAL, null));
|
||||||
|
}
|
||||||
|
}, [interval]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<form onSubmit={handleSubmit}>
|
<form onSubmit={handleSubmit}>
|
||||||
<div className="form__group form__group--settings">
|
<div className="form__group form__group--settings">
|
||||||
@@ -73,6 +100,37 @@ const Form = (props) => {
|
|||||||
</label>
|
</label>
|
||||||
<div className="form__group form__group--settings">
|
<div className="form__group form__group--settings">
|
||||||
<div className="custom-controls-stacked">
|
<div className="custom-controls-stacked">
|
||||||
|
<Field
|
||||||
|
key={RETENTION_CUSTOM}
|
||||||
|
name="interval"
|
||||||
|
type="radio"
|
||||||
|
component={renderRadioField}
|
||||||
|
value={QUERY_LOG_INTERVALS_DAYS.includes(interval)
|
||||||
|
? RETENTION_CUSTOM
|
||||||
|
: interval
|
||||||
|
}
|
||||||
|
placeholder={getIntervalTitle(RETENTION_CUSTOM, t)}
|
||||||
|
normalize={toFloatNumber}
|
||||||
|
disabled={processing}
|
||||||
|
/>
|
||||||
|
{!QUERY_LOG_INTERVALS_DAYS.includes(interval) && (
|
||||||
|
<div className="form__group--input">
|
||||||
|
<div className="form__desc form__desc--top">
|
||||||
|
{t('custom_rotation_input')}
|
||||||
|
</div>
|
||||||
|
<Field
|
||||||
|
key={RETENTION_CUSTOM_INPUT}
|
||||||
|
name={CUSTOM_INTERVAL}
|
||||||
|
type="number"
|
||||||
|
className="form-control"
|
||||||
|
component={renderInputField}
|
||||||
|
disabled={processing}
|
||||||
|
normalize={toFloatNumber}
|
||||||
|
min={RETENTION_RANGE.MIN}
|
||||||
|
max={RETENTION_RANGE.MAX}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
{getIntervalFields(processing, t, toFloatNumber)}
|
{getIntervalFields(processing, t, toFloatNumber)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -96,7 +154,12 @@ const Form = (props) => {
|
|||||||
<button
|
<button
|
||||||
type="submit"
|
type="submit"
|
||||||
className="btn btn-success btn-standard btn-large"
|
className="btn btn-success btn-standard btn-large"
|
||||||
disabled={submitting || invalid || processing}
|
disabled={
|
||||||
|
submitting
|
||||||
|
|| invalid
|
||||||
|
|| processing
|
||||||
|
|| (!QUERY_LOG_INTERVALS_DAYS.includes(interval) && !customInterval)
|
||||||
|
}
|
||||||
>
|
>
|
||||||
<Trans>save_btn</Trans>
|
<Trans>save_btn</Trans>
|
||||||
</button>
|
</button>
|
||||||
@@ -121,8 +184,22 @@ Form.propTypes = {
|
|||||||
processing: PropTypes.bool.isRequired,
|
processing: PropTypes.bool.isRequired,
|
||||||
processingClear: PropTypes.bool.isRequired,
|
processingClear: PropTypes.bool.isRequired,
|
||||||
t: PropTypes.func.isRequired,
|
t: PropTypes.func.isRequired,
|
||||||
|
interval: PropTypes.number,
|
||||||
|
customInterval: PropTypes.number,
|
||||||
|
dispatch: PropTypes.func.isRequired,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const selector = formValueSelector(FORM_NAME.LOG_CONFIG);
|
||||||
|
|
||||||
|
Form = connect((state) => {
|
||||||
|
const interval = selector(state, 'interval');
|
||||||
|
const customInterval = selector(state, CUSTOM_INTERVAL);
|
||||||
|
return {
|
||||||
|
interval,
|
||||||
|
customInterval,
|
||||||
|
};
|
||||||
|
})(Form);
|
||||||
|
|
||||||
export default flow([
|
export default flow([
|
||||||
withTranslation(),
|
withTranslation(),
|
||||||
reduxForm({ form: FORM_NAME.LOG_CONFIG }),
|
reduxForm({ form: FORM_NAME.LOG_CONFIG }),
|
||||||
|
|||||||
@@ -4,15 +4,22 @@ import { withTranslation } from 'react-i18next';
|
|||||||
|
|
||||||
import Card from '../../ui/Card';
|
import Card from '../../ui/Card';
|
||||||
import Form from './Form';
|
import Form from './Form';
|
||||||
|
import { HOUR } from '../../../helpers/constants';
|
||||||
|
|
||||||
class LogsConfig extends Component {
|
class LogsConfig extends Component {
|
||||||
handleFormSubmit = (values) => {
|
handleFormSubmit = (values) => {
|
||||||
const { t, interval: prevInterval } = this.props;
|
const { t, interval: prevInterval } = this.props;
|
||||||
const { interval } = values;
|
const { interval, customInterval, ...rest } = values;
|
||||||
|
|
||||||
const data = { ...values, ignored: values.ignored ? values.ignored.split('\n') : [] };
|
const newInterval = customInterval ? customInterval * HOUR : interval;
|
||||||
|
|
||||||
if (interval !== prevInterval) {
|
const data = {
|
||||||
|
...rest,
|
||||||
|
ignored: values.ignored ? values.ignored.split('\n') : [],
|
||||||
|
interval: newInterval,
|
||||||
|
};
|
||||||
|
|
||||||
|
if (newInterval < prevInterval) {
|
||||||
// eslint-disable-next-line no-alert
|
// eslint-disable-next-line no-alert
|
||||||
if (window.confirm(t('query_log_retention_confirm'))) {
|
if (window.confirm(t('query_log_retention_confirm'))) {
|
||||||
this.props.setLogsConfig(data);
|
this.props.setLogsConfig(data);
|
||||||
@@ -32,7 +39,14 @@ class LogsConfig extends Component {
|
|||||||
|
|
||||||
render() {
|
render() {
|
||||||
const {
|
const {
|
||||||
t, enabled, interval, processing, processingClear, anonymize_client_ip, ignored,
|
t,
|
||||||
|
enabled,
|
||||||
|
interval,
|
||||||
|
processing,
|
||||||
|
processingClear,
|
||||||
|
anonymize_client_ip,
|
||||||
|
ignored,
|
||||||
|
customInterval,
|
||||||
} = this.props;
|
} = this.props;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -46,6 +60,7 @@ class LogsConfig extends Component {
|
|||||||
initialValues={{
|
initialValues={{
|
||||||
enabled,
|
enabled,
|
||||||
interval,
|
interval,
|
||||||
|
customInterval,
|
||||||
anonymize_client_ip,
|
anonymize_client_ip,
|
||||||
ignored: ignored.join('\n'),
|
ignored: ignored.join('\n'),
|
||||||
}}
|
}}
|
||||||
@@ -62,6 +77,7 @@ class LogsConfig extends Component {
|
|||||||
|
|
||||||
LogsConfig.propTypes = {
|
LogsConfig.propTypes = {
|
||||||
interval: PropTypes.number.isRequired,
|
interval: PropTypes.number.isRequired,
|
||||||
|
customInterval: PropTypes.number,
|
||||||
enabled: PropTypes.bool.isRequired,
|
enabled: PropTypes.bool.isRequired,
|
||||||
anonymize_client_ip: PropTypes.bool.isRequired,
|
anonymize_client_ip: PropTypes.bool.isRequired,
|
||||||
processing: PropTypes.bool.isRequired,
|
processing: PropTypes.bool.isRequired,
|
||||||
|
|||||||
@@ -18,6 +18,11 @@
|
|||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.form__group--input {
|
||||||
|
max-width: 300px;
|
||||||
|
margin: 0 1.5rem 10px;
|
||||||
|
}
|
||||||
|
|
||||||
.form__group--checkbox {
|
.form__group--checkbox {
|
||||||
margin-bottom: 25px;
|
margin-bottom: 25px;
|
||||||
}
|
}
|
||||||
@@ -100,6 +105,14 @@
|
|||||||
margin-bottom: 0;
|
margin-bottom: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.form__label--bot {
|
||||||
|
margin-bottom: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form__label--top {
|
||||||
|
margin-top: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
.form__status {
|
.form__status {
|
||||||
margin-top: 10px;
|
margin-top: 10px;
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
|
|||||||
@@ -1,32 +1,44 @@
|
|||||||
import React from 'react';
|
import React, { useEffect } from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import { Field, reduxForm } from 'redux-form';
|
import {
|
||||||
|
change, Field, formValueSelector, reduxForm,
|
||||||
|
} from 'redux-form';
|
||||||
import { Trans, withTranslation } from 'react-i18next';
|
import { Trans, withTranslation } from 'react-i18next';
|
||||||
import flow from 'lodash/flow';
|
import flow from 'lodash/flow';
|
||||||
|
import { connect } from 'react-redux';
|
||||||
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
renderRadioField,
|
renderRadioField,
|
||||||
toNumber,
|
toNumber,
|
||||||
CheckboxField,
|
CheckboxField,
|
||||||
renderTextareaField,
|
renderTextareaField,
|
||||||
|
toFloatNumber,
|
||||||
|
renderInputField,
|
||||||
} from '../../../helpers/form';
|
} from '../../../helpers/form';
|
||||||
import {
|
import {
|
||||||
FORM_NAME,
|
FORM_NAME,
|
||||||
STATS_INTERVALS_DAYS,
|
STATS_INTERVALS_DAYS,
|
||||||
DAY,
|
DAY,
|
||||||
|
RETENTION_CUSTOM,
|
||||||
|
RETENTION_CUSTOM_INPUT,
|
||||||
|
CUSTOM_INTERVAL,
|
||||||
|
RETENTION_RANGE,
|
||||||
} from '../../../helpers/constants';
|
} from '../../../helpers/constants';
|
||||||
import '../FormButton.css';
|
import '../FormButton.css';
|
||||||
|
|
||||||
const getIntervalTitle = (intervalMs, t) => {
|
const getIntervalTitle = (intervalMs, t) => {
|
||||||
switch (intervalMs / DAY) {
|
switch (intervalMs) {
|
||||||
case 1:
|
case RETENTION_CUSTOM:
|
||||||
|
return t('settings_custom');
|
||||||
|
case DAY:
|
||||||
return t('interval_24_hour');
|
return t('interval_24_hour');
|
||||||
default:
|
default:
|
||||||
return t('interval_days', { count: intervalMs / DAY });
|
return t('interval_days', { count: intervalMs / DAY });
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const Form = (props) => {
|
let Form = (props) => {
|
||||||
const {
|
const {
|
||||||
handleSubmit,
|
handleSubmit,
|
||||||
processing,
|
processing,
|
||||||
@@ -35,8 +47,17 @@ const Form = (props) => {
|
|||||||
handleReset,
|
handleReset,
|
||||||
processingReset,
|
processingReset,
|
||||||
t,
|
t,
|
||||||
|
interval,
|
||||||
|
customInterval,
|
||||||
|
dispatch,
|
||||||
} = props;
|
} = props;
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (STATS_INTERVALS_DAYS.includes(interval)) {
|
||||||
|
dispatch(change(FORM_NAME.STATS_CONFIG, CUSTOM_INTERVAL, null));
|
||||||
|
}
|
||||||
|
}, [interval]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<form onSubmit={handleSubmit}>
|
<form onSubmit={handleSubmit}>
|
||||||
<div className="form__group form__group--settings">
|
<div className="form__group form__group--settings">
|
||||||
@@ -56,6 +77,37 @@ const Form = (props) => {
|
|||||||
</div>
|
</div>
|
||||||
<div className="form__group form__group--settings mt-2">
|
<div className="form__group form__group--settings mt-2">
|
||||||
<div className="custom-controls-stacked">
|
<div className="custom-controls-stacked">
|
||||||
|
<Field
|
||||||
|
key={RETENTION_CUSTOM}
|
||||||
|
name="interval"
|
||||||
|
type="radio"
|
||||||
|
component={renderRadioField}
|
||||||
|
value={STATS_INTERVALS_DAYS.includes(interval)
|
||||||
|
? RETENTION_CUSTOM
|
||||||
|
: interval
|
||||||
|
}
|
||||||
|
placeholder={getIntervalTitle(RETENTION_CUSTOM, t)}
|
||||||
|
normalize={toFloatNumber}
|
||||||
|
disabled={processing}
|
||||||
|
/>
|
||||||
|
{!STATS_INTERVALS_DAYS.includes(interval) && (
|
||||||
|
<div className="form__group--input">
|
||||||
|
<div className="form__desc form__desc--top">
|
||||||
|
{t('custom_retention_input')}
|
||||||
|
</div>
|
||||||
|
<Field
|
||||||
|
key={RETENTION_CUSTOM_INPUT}
|
||||||
|
name={CUSTOM_INTERVAL}
|
||||||
|
type="number"
|
||||||
|
className="form-control"
|
||||||
|
component={renderInputField}
|
||||||
|
disabled={processing}
|
||||||
|
normalize={toFloatNumber}
|
||||||
|
min={RETENTION_RANGE.MIN}
|
||||||
|
max={RETENTION_RANGE.MAX}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
{STATS_INTERVALS_DAYS.map((interval) => (
|
{STATS_INTERVALS_DAYS.map((interval) => (
|
||||||
<Field
|
<Field
|
||||||
key={interval}
|
key={interval}
|
||||||
@@ -90,7 +142,12 @@ const Form = (props) => {
|
|||||||
<button
|
<button
|
||||||
type="submit"
|
type="submit"
|
||||||
className="btn btn-success btn-standard btn-large"
|
className="btn btn-success btn-standard btn-large"
|
||||||
disabled={submitting || invalid || processing}
|
disabled={
|
||||||
|
submitting
|
||||||
|
|| invalid
|
||||||
|
|| processing
|
||||||
|
|| (!STATS_INTERVALS_DAYS.includes(interval) && !customInterval)
|
||||||
|
}
|
||||||
>
|
>
|
||||||
<Trans>save_btn</Trans>
|
<Trans>save_btn</Trans>
|
||||||
</button>
|
</button>
|
||||||
@@ -116,8 +173,22 @@ Form.propTypes = {
|
|||||||
processing: PropTypes.bool.isRequired,
|
processing: PropTypes.bool.isRequired,
|
||||||
processingReset: PropTypes.bool.isRequired,
|
processingReset: PropTypes.bool.isRequired,
|
||||||
t: PropTypes.func.isRequired,
|
t: PropTypes.func.isRequired,
|
||||||
|
interval: PropTypes.number,
|
||||||
|
customInterval: PropTypes.number,
|
||||||
|
dispatch: PropTypes.func.isRequired,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const selector = formValueSelector(FORM_NAME.STATS_CONFIG);
|
||||||
|
|
||||||
|
Form = connect((state) => {
|
||||||
|
const interval = selector(state, 'interval');
|
||||||
|
const customInterval = selector(state, CUSTOM_INTERVAL);
|
||||||
|
return {
|
||||||
|
interval,
|
||||||
|
customInterval,
|
||||||
|
};
|
||||||
|
})(Form);
|
||||||
|
|
||||||
export default flow([
|
export default flow([
|
||||||
withTranslation(),
|
withTranslation(),
|
||||||
reduxForm({ form: FORM_NAME.STATS_CONFIG }),
|
reduxForm({ form: FORM_NAME.STATS_CONFIG }),
|
||||||
|
|||||||
@@ -4,13 +4,18 @@ import { withTranslation } from 'react-i18next';
|
|||||||
|
|
||||||
import Card from '../../ui/Card';
|
import Card from '../../ui/Card';
|
||||||
import Form from './Form';
|
import Form from './Form';
|
||||||
|
import { HOUR } from '../../../helpers/constants';
|
||||||
|
|
||||||
class StatsConfig extends Component {
|
class StatsConfig extends Component {
|
||||||
handleFormSubmit = ({ enabled, interval, ignored }) => {
|
handleFormSubmit = ({
|
||||||
|
enabled, interval, ignored, customInterval,
|
||||||
|
}) => {
|
||||||
const { t, interval: prevInterval } = this.props;
|
const { t, interval: prevInterval } = this.props;
|
||||||
|
const newInterval = customInterval ? customInterval * HOUR : interval;
|
||||||
|
|
||||||
const config = {
|
const config = {
|
||||||
enabled,
|
enabled,
|
||||||
interval,
|
interval: newInterval,
|
||||||
ignored: ignored ? ignored.split('\n') : [],
|
ignored: ignored ? ignored.split('\n') : [],
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -33,7 +38,13 @@ class StatsConfig extends Component {
|
|||||||
|
|
||||||
render() {
|
render() {
|
||||||
const {
|
const {
|
||||||
t, interval, processing, processingReset, ignored, enabled,
|
t,
|
||||||
|
interval,
|
||||||
|
customInterval,
|
||||||
|
processing,
|
||||||
|
processingReset,
|
||||||
|
ignored,
|
||||||
|
enabled,
|
||||||
} = this.props;
|
} = this.props;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -46,6 +57,7 @@ class StatsConfig extends Component {
|
|||||||
<Form
|
<Form
|
||||||
initialValues={{
|
initialValues={{
|
||||||
interval,
|
interval,
|
||||||
|
customInterval,
|
||||||
enabled,
|
enabled,
|
||||||
ignored: ignored.join('\n'),
|
ignored: ignored.join('\n'),
|
||||||
}}
|
}}
|
||||||
@@ -62,6 +74,7 @@ class StatsConfig extends Component {
|
|||||||
|
|
||||||
StatsConfig.propTypes = {
|
StatsConfig.propTypes = {
|
||||||
interval: PropTypes.number.isRequired,
|
interval: PropTypes.number.isRequired,
|
||||||
|
customInterval: PropTypes.number,
|
||||||
ignored: PropTypes.array.isRequired,
|
ignored: PropTypes.array.isRequired,
|
||||||
enabled: PropTypes.bool.isRequired,
|
enabled: PropTypes.bool.isRequired,
|
||||||
processing: PropTypes.bool.isRequired,
|
processing: PropTypes.bool.isRequired,
|
||||||
|
|||||||
@@ -124,6 +124,7 @@ class Settings extends Component {
|
|||||||
enabled={queryLogs.enabled}
|
enabled={queryLogs.enabled}
|
||||||
ignored={queryLogs.ignored}
|
ignored={queryLogs.ignored}
|
||||||
interval={queryLogs.interval}
|
interval={queryLogs.interval}
|
||||||
|
customInterval={queryLogs.customInterval}
|
||||||
anonymize_client_ip={queryLogs.anonymize_client_ip}
|
anonymize_client_ip={queryLogs.anonymize_client_ip}
|
||||||
processing={queryLogs.processingSetConfig}
|
processing={queryLogs.processingSetConfig}
|
||||||
processingClear={queryLogs.processingClear}
|
processingClear={queryLogs.processingClear}
|
||||||
@@ -134,6 +135,7 @@ class Settings extends Component {
|
|||||||
<div className="col-md-12">
|
<div className="col-md-12">
|
||||||
<StatsConfig
|
<StatsConfig
|
||||||
interval={stats.interval}
|
interval={stats.interval}
|
||||||
|
customInterval={stats.customInterval}
|
||||||
ignored={stats.ignored}
|
ignored={stats.ignored}
|
||||||
enabled={stats.enabled}
|
enabled={stats.enabled}
|
||||||
processing={stats.processingSetConfig}
|
processing={stats.processingSetConfig}
|
||||||
@@ -166,6 +168,7 @@ Settings.propTypes = {
|
|||||||
stats: PropTypes.shape({
|
stats: PropTypes.shape({
|
||||||
processingGetConfig: PropTypes.bool,
|
processingGetConfig: PropTypes.bool,
|
||||||
interval: PropTypes.number,
|
interval: PropTypes.number,
|
||||||
|
customInterval: PropTypes.number,
|
||||||
enabled: PropTypes.bool,
|
enabled: PropTypes.bool,
|
||||||
ignored: PropTypes.array,
|
ignored: PropTypes.array,
|
||||||
processingSetConfig: PropTypes.bool,
|
processingSetConfig: PropTypes.bool,
|
||||||
@@ -174,6 +177,7 @@ Settings.propTypes = {
|
|||||||
queryLogs: PropTypes.shape({
|
queryLogs: PropTypes.shape({
|
||||||
enabled: PropTypes.bool,
|
enabled: PropTypes.bool,
|
||||||
interval: PropTypes.number,
|
interval: PropTypes.number,
|
||||||
|
customInterval: PropTypes.number,
|
||||||
anonymize_client_ip: PropTypes.bool,
|
anonymize_client_ip: PropTypes.bool,
|
||||||
processingSetConfig: PropTypes.bool,
|
processingSetConfig: PropTypes.bool,
|
||||||
processingClear: PropTypes.bool,
|
processingClear: PropTypes.bool,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import React, { useState, useEffect } from 'react';
|
import React, { useState } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { useDispatch, useSelector } from 'react-redux';
|
import { useDispatch, useSelector } from 'react-redux';
|
||||||
import cn from 'classnames';
|
import cn from 'classnames';
|
||||||
@@ -33,16 +33,14 @@ const Footer = () => {
|
|||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
|
|
||||||
const currentTheme = useSelector((state) => (state.dashboard ? state.dashboard.theme : 'auto'));
|
const currentTheme = useSelector((state) => (
|
||||||
const profileName = useSelector((state) => (state.dashboard ? state.dashboard.name : ''));
|
state.dashboard ? state.dashboard.theme : THEMES.auto
|
||||||
|
));
|
||||||
|
const profileName = useSelector((state) => (
|
||||||
|
state.dashboard ? state.dashboard.name : ''
|
||||||
|
));
|
||||||
const isLoggedIn = profileName !== '';
|
const isLoggedIn = profileName !== '';
|
||||||
const [currentThemeLocal, setCurrentThemeLocal] = useState('auto');
|
const [currentThemeLocal, setCurrentThemeLocal] = useState(THEMES.auto);
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (!isLoggedIn) {
|
|
||||||
setUITheme(window.matchMedia('(prefers-color-scheme: dark)').matches ? THEMES.dark : THEMES.light);
|
|
||||||
}
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
const getYear = () => {
|
const getYear = () => {
|
||||||
const today = new Date();
|
const today = new Date();
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
font-size: 28px;
|
font-size: 28px;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
background-color: rgba(255, 255, 255, 0.8);
|
background-color: var(--rt-nodata-bgcolor);
|
||||||
}
|
}
|
||||||
|
|
||||||
.overlay--visible {
|
.overlay--visible {
|
||||||
|
|||||||
@@ -220,6 +220,12 @@ export const STATS_INTERVALS_DAYS = [DAY, DAY * 7, DAY * 30, DAY * 90];
|
|||||||
|
|
||||||
export const QUERY_LOG_INTERVALS_DAYS = [HOUR * 6, DAY, DAY * 7, DAY * 30, DAY * 90];
|
export const QUERY_LOG_INTERVALS_DAYS = [HOUR * 6, DAY, DAY * 7, DAY * 30, DAY * 90];
|
||||||
|
|
||||||
|
export const RETENTION_CUSTOM = 1;
|
||||||
|
|
||||||
|
export const RETENTION_CUSTOM_INPUT = 'custom_retention_input';
|
||||||
|
|
||||||
|
export const CUSTOM_INTERVAL = 'customInterval';
|
||||||
|
|
||||||
export const FILTERS_INTERVALS_HOURS = [0, 1, 12, 24, 72, 168];
|
export const FILTERS_INTERVALS_HOURS = [0, 1, 12, 24, 72, 168];
|
||||||
|
|
||||||
// Note that translation strings contain these modes (blocking_mode_CONSTANT)
|
// Note that translation strings contain these modes (blocking_mode_CONSTANT)
|
||||||
@@ -462,6 +468,11 @@ export const UINT32_RANGE = {
|
|||||||
MAX: 4294967295,
|
MAX: 4294967295,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const RETENTION_RANGE = {
|
||||||
|
MIN: 1,
|
||||||
|
MAX: 365 * 24,
|
||||||
|
};
|
||||||
|
|
||||||
export const DHCP_VALUES_PLACEHOLDERS = {
|
export const DHCP_VALUES_PLACEHOLDERS = {
|
||||||
ipv4: {
|
ipv4: {
|
||||||
subnet_mask: '255.255.255.0',
|
subnet_mask: '255.255.255.0',
|
||||||
@@ -537,3 +548,5 @@ export const DISABLE_PROTECTION_TIMINGS = {
|
|||||||
HOUR: 60 * 60 * 1000,
|
HOUR: 60 * 60 * 1000,
|
||||||
TOMORROW: 24 * 60 * 60 * 1000,
|
TOMORROW: 24 * 60 * 60 * 1000,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const LOCAL_STORAGE_THEME_KEY = 'account_theme';
|
||||||
|
|||||||
@@ -25,6 +25,8 @@ import {
|
|||||||
STANDARD_HTTPS_PORT,
|
STANDARD_HTTPS_PORT,
|
||||||
STANDARD_WEB_PORT,
|
STANDARD_WEB_PORT,
|
||||||
SPECIAL_FILTER_ID,
|
SPECIAL_FILTER_ID,
|
||||||
|
THEMES,
|
||||||
|
LOCAL_STORAGE_THEME_KEY,
|
||||||
} from './constants';
|
} from './constants';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -678,13 +680,61 @@ export const setHtmlLangAttr = (language) => {
|
|||||||
window.document.documentElement.lang = language;
|
window.document.documentElement.lang = language;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set local storage field
|
||||||
|
*
|
||||||
|
* @param {string} key
|
||||||
|
* @param {string} value
|
||||||
|
*/
|
||||||
|
|
||||||
|
export const setStorageItem = (key, value) => {
|
||||||
|
if (window.localStorage) {
|
||||||
|
window.localStorage.setItem(key, value);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get local storage field
|
||||||
|
*
|
||||||
|
* @param {string} key
|
||||||
|
*/
|
||||||
|
|
||||||
|
export const getStorageItem = (key) => (window.localStorage
|
||||||
|
? window.localStorage.getItem(key)
|
||||||
|
: null);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set local storage theme field
|
||||||
|
*
|
||||||
|
* @param {string} theme
|
||||||
|
*/
|
||||||
|
|
||||||
|
export const setTheme = (theme) => {
|
||||||
|
setStorageItem(LOCAL_STORAGE_THEME_KEY, theme);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get local storage theme field
|
||||||
|
*
|
||||||
|
* @returns {string}
|
||||||
|
*/
|
||||||
|
|
||||||
|
export const getTheme = () => getStorageItem(LOCAL_STORAGE_THEME_KEY) || THEMES.light;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets UI theme.
|
* Sets UI theme.
|
||||||
*
|
*
|
||||||
* @param theme
|
* @param theme
|
||||||
*/
|
*/
|
||||||
export const setUITheme = (theme) => {
|
export const setUITheme = (theme) => {
|
||||||
document.body.dataset.theme = theme;
|
let currentTheme = theme || getTheme();
|
||||||
|
|
||||||
|
if (currentTheme === THEMES.auto) {
|
||||||
|
const prefersDark = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches;
|
||||||
|
currentTheme = prefersDark ? THEMES.dark : THEMES.light;
|
||||||
|
}
|
||||||
|
setTheme(currentTheme);
|
||||||
|
document.body.dataset.theme = currentTheme;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"timeUpdated": "2023-03-29T00:10:35.167Z",
|
"timeUpdated": "2023-04-06T10:46:09.881Z",
|
||||||
"categories": {
|
"categories": {
|
||||||
"0": "audio_video_player",
|
"0": "audio_video_player",
|
||||||
"1": "comments",
|
"1": "comments",
|
||||||
@@ -24192,4 +24192,4 @@
|
|||||||
"3gppnetwork.org": "3gpp",
|
"3gppnetwork.org": "3gpp",
|
||||||
"3gpp.org": "3gpp"
|
"3gpp.org": "3gpp"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import * as actionCreators from '../../actions/login';
|
|||||||
import logo from '../../components/ui/svg/logo.svg';
|
import logo from '../../components/ui/svg/logo.svg';
|
||||||
import Toasts from '../../components/Toasts';
|
import Toasts from '../../components/Toasts';
|
||||||
import Footer from '../../components/ui/Footer';
|
import Footer from '../../components/ui/Footer';
|
||||||
|
import Icons from '../../components/ui/Icons';
|
||||||
import Form from './Form';
|
import Form from './Form';
|
||||||
|
|
||||||
import './Login.css';
|
import './Login.css';
|
||||||
@@ -69,6 +70,7 @@ class Login extends Component {
|
|||||||
</div>
|
</div>
|
||||||
<Footer />
|
<Footer />
|
||||||
<Toasts />
|
<Toasts />
|
||||||
|
<Icons />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -177,7 +177,7 @@ const dashboard = handleActions(
|
|||||||
autoClients: [],
|
autoClients: [],
|
||||||
supportedTags: [],
|
supportedTags: [],
|
||||||
name: '',
|
name: '',
|
||||||
theme: 'auto',
|
theme: undefined,
|
||||||
checkUpdateFlag: false,
|
checkUpdateFlag: false,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
import { handleActions } from 'redux-actions';
|
import { handleActions } from 'redux-actions';
|
||||||
|
|
||||||
import * as actions from '../actions/queryLogs';
|
import * as actions from '../actions/queryLogs';
|
||||||
import { DEFAULT_LOGS_FILTER, DAY } from '../helpers/constants';
|
import {
|
||||||
|
DEFAULT_LOGS_FILTER, DAY, QUERY_LOG_INTERVALS_DAYS, HOUR,
|
||||||
|
} from '../helpers/constants';
|
||||||
|
|
||||||
const queryLogs = handleActions(
|
const queryLogs = handleActions(
|
||||||
{
|
{
|
||||||
@@ -59,6 +61,9 @@ const queryLogs = handleActions(
|
|||||||
[actions.getLogsConfigSuccess]: (state, { payload }) => ({
|
[actions.getLogsConfigSuccess]: (state, { payload }) => ({
|
||||||
...state,
|
...state,
|
||||||
...payload,
|
...payload,
|
||||||
|
customInterval: !QUERY_LOG_INTERVALS_DAYS.includes(payload.interval)
|
||||||
|
? payload.interval / HOUR
|
||||||
|
: null,
|
||||||
processingGetConfig: false,
|
processingGetConfig: false,
|
||||||
}),
|
}),
|
||||||
|
|
||||||
@@ -95,6 +100,7 @@ const queryLogs = handleActions(
|
|||||||
anonymize_client_ip: false,
|
anonymize_client_ip: false,
|
||||||
isDetailed: true,
|
isDetailed: true,
|
||||||
isEntireLog: false,
|
isEntireLog: false,
|
||||||
|
customInterval: null,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { handleActions } from 'redux-actions';
|
import { handleActions } from 'redux-actions';
|
||||||
import { normalizeTopClients } from '../helpers/helpers';
|
import { normalizeTopClients } from '../helpers/helpers';
|
||||||
import { DAY } from '../helpers/constants';
|
import { DAY, HOUR, STATS_INTERVALS_DAYS } from '../helpers/constants';
|
||||||
|
|
||||||
import * as actions from '../actions/stats';
|
import * as actions from '../actions/stats';
|
||||||
|
|
||||||
@@ -27,6 +27,9 @@ const stats = handleActions(
|
|||||||
[actions.getStatsConfigSuccess]: (state, { payload }) => ({
|
[actions.getStatsConfigSuccess]: (state, { payload }) => ({
|
||||||
...state,
|
...state,
|
||||||
...payload,
|
...payload,
|
||||||
|
customInterval: !STATS_INTERVALS_DAYS.includes(payload.interval)
|
||||||
|
? payload.interval / HOUR
|
||||||
|
: null,
|
||||||
processingGetConfig: false,
|
processingGetConfig: false,
|
||||||
}),
|
}),
|
||||||
|
|
||||||
@@ -93,6 +96,7 @@ const stats = handleActions(
|
|||||||
processingStats: true,
|
processingStats: true,
|
||||||
processingReset: false,
|
processingReset: false,
|
||||||
interval: DAY,
|
interval: DAY,
|
||||||
|
customInterval: null,
|
||||||
...defaultStats,
|
...defaultStats,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -4,19 +4,26 @@
|
|||||||
|
|
||||||
/^[[:space:]]+- .+/ {
|
/^[[:space:]]+- .+/ {
|
||||||
if (FNR - prev_line == 1) {
|
if (FNR - prev_line == 1) {
|
||||||
addrs[addrsnum++] = $2
|
addrs[$2] = true
|
||||||
prev_line = FNR
|
prev_line = FNR
|
||||||
|
|
||||||
|
if ($2 == "0.0.0.0" || $2 == "'::'") {
|
||||||
|
# Drop all the other addresses.
|
||||||
|
delete addrs
|
||||||
|
addrs[""] = true
|
||||||
|
prev_line = -1
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/^[[:space:]]+port:/ { if (is_dns) port = $2 }
|
/^[[:space:]]+port:/ { if (is_dns) port = $2 }
|
||||||
|
|
||||||
END {
|
END {
|
||||||
for (i in addrs) {
|
for (addr in addrs) {
|
||||||
if (match(addrs[i], ":")) {
|
if (match(addr, ":")) {
|
||||||
print "[" addrs[i] "]:" port
|
print "[" addr "]:" port
|
||||||
} else {
|
} else {
|
||||||
print addrs[i] ":" port
|
print addr ":" port
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,8 +61,11 @@ then
|
|||||||
error_exit "no DNS bindings could be retrieved from $filename"
|
error_exit "no DNS bindings could be retrieved from $filename"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
first_dns="$( echo "$dns_hosts" | head -n 1 )"
|
||||||
|
readonly first_dns
|
||||||
|
|
||||||
# TODO(e.burkov): Deal with 0 port.
|
# TODO(e.burkov): Deal with 0 port.
|
||||||
case "$( echo "$dns_hosts" | head -n 1 )"
|
case "$first_dns"
|
||||||
in
|
in
|
||||||
(*':0')
|
(*':0')
|
||||||
error_exit '0 in DNS port is not supported by healthcheck'
|
error_exit '0 in DNS port is not supported by healthcheck'
|
||||||
@@ -82,8 +85,23 @@ esac
|
|||||||
# See https://github.com/AdguardTeam/AdGuardHome/issues/5642.
|
# See https://github.com/AdguardTeam/AdGuardHome/issues/5642.
|
||||||
wget --no-check-certificate "$web_url" -O /dev/null -q || exit 1
|
wget --no-check-certificate "$web_url" -O /dev/null -q || exit 1
|
||||||
|
|
||||||
echo "$dns_hosts" | while read -r host
|
test_fqdn="healthcheck.adguardhome.test."
|
||||||
do
|
readonly test_fqdn
|
||||||
nslookup -type=a healthcheck.adguardhome.test. "$host" > /dev/null ||\
|
|
||||||
|
# The awk script currently returns only port prefixed with colon in case of
|
||||||
|
# unspecified address.
|
||||||
|
case "$first_dns"
|
||||||
|
in
|
||||||
|
(':'*)
|
||||||
|
nslookup -type=a "$test_fqdn" "127.0.0.1${first_dns}" > /dev/null ||\
|
||||||
|
nslookup -type=a "$test_fqdn" "[::1]${first_dns}" > /dev/null ||\
|
||||||
error_exit "nslookup failed for $host"
|
error_exit "nslookup failed for $host"
|
||||||
done
|
;;
|
||||||
|
(*)
|
||||||
|
echo "$dns_hosts" | while read -r host
|
||||||
|
do
|
||||||
|
nslookup -type=a "$test_fqdn" "$host" > /dev/null ||\
|
||||||
|
error_exit "nslookup failed for $host"
|
||||||
|
done
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|||||||
@@ -10,4 +10,4 @@ END {
|
|||||||
} else {
|
} else {
|
||||||
print "http://" host ":" port
|
print "http://" host ":" port
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
30
go.mod
30
go.mod
@@ -3,11 +3,11 @@ module github.com/AdguardTeam/AdGuardHome
|
|||||||
go 1.19
|
go 1.19
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/AdguardTeam/dnsproxy v0.48.3
|
github.com/AdguardTeam/dnsproxy v0.49.1
|
||||||
github.com/AdguardTeam/golibs v0.13.1
|
github.com/AdguardTeam/golibs v0.13.2
|
||||||
github.com/AdguardTeam/urlfilter v0.16.1
|
github.com/AdguardTeam/urlfilter v0.16.1
|
||||||
github.com/NYTimes/gziphandler v1.1.1
|
github.com/NYTimes/gziphandler v1.1.1
|
||||||
github.com/ameshkov/dnscrypt/v2 v2.2.6
|
github.com/ameshkov/dnscrypt/v2 v2.2.7
|
||||||
github.com/digineo/go-ipset/v2 v2.2.1
|
github.com/digineo/go-ipset/v2 v2.2.1
|
||||||
github.com/dimfeld/httptreemux/v5 v5.5.0
|
github.com/dimfeld/httptreemux/v5 v5.5.0
|
||||||
github.com/fsnotify/fsnotify v1.6.0
|
github.com/fsnotify/fsnotify v1.6.0
|
||||||
@@ -17,19 +17,23 @@ require (
|
|||||||
github.com/google/renameio v1.0.1
|
github.com/google/renameio v1.0.1
|
||||||
github.com/google/uuid v1.3.0
|
github.com/google/uuid v1.3.0
|
||||||
github.com/insomniacslk/dhcp v0.0.0-20221215072855-de60144f33f8
|
github.com/insomniacslk/dhcp v0.0.0-20221215072855-de60144f33f8
|
||||||
|
github.com/josharian/native v1.1.1-0.20230202152459-5c7d0dd6ab86
|
||||||
github.com/kardianos/service v1.2.2
|
github.com/kardianos/service v1.2.2
|
||||||
github.com/mdlayher/ethernet v0.0.0-20220221185849-529eae5b6118
|
github.com/mdlayher/ethernet v0.0.0-20220221185849-529eae5b6118
|
||||||
github.com/mdlayher/netlink v1.7.1
|
github.com/mdlayher/netlink v1.7.1
|
||||||
github.com/mdlayher/packet v1.1.1
|
github.com/mdlayher/packet v1.1.1
|
||||||
|
// TODO(a.garipov): This package is deprecated; find a new one or use our
|
||||||
|
// own code for that. Perhaps, use gopacket.
|
||||||
|
github.com/mdlayher/raw v0.1.0
|
||||||
github.com/miekg/dns v1.1.53
|
github.com/miekg/dns v1.1.53
|
||||||
github.com/quic-go/quic-go v0.33.0
|
github.com/quic-go/quic-go v0.33.0
|
||||||
github.com/stretchr/testify v1.8.2
|
github.com/stretchr/testify v1.8.2
|
||||||
github.com/ti-mo/netfilter v0.5.0
|
github.com/ti-mo/netfilter v0.5.0
|
||||||
go.etcd.io/bbolt v1.3.7
|
go.etcd.io/bbolt v1.3.7
|
||||||
golang.org/x/crypto v0.7.0
|
golang.org/x/crypto v0.8.0
|
||||||
golang.org/x/exp v0.0.0-20230321023759-10a507213a29
|
golang.org/x/exp v0.0.0-20230321023759-10a507213a29
|
||||||
golang.org/x/net v0.8.0
|
golang.org/x/net v0.9.0
|
||||||
golang.org/x/sys v0.6.0
|
golang.org/x/sys v0.7.0
|
||||||
gopkg.in/natefinch/lumberjack.v2 v2.2.1
|
gopkg.in/natefinch/lumberjack.v2 v2.2.1
|
||||||
gopkg.in/yaml.v3 v3.0.1
|
gopkg.in/yaml.v3 v3.0.1
|
||||||
howett.net/plist v1.0.0
|
howett.net/plist v1.0.0
|
||||||
@@ -44,9 +48,7 @@ require (
|
|||||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||||
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect
|
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect
|
||||||
github.com/golang/mock v1.6.0 // indirect
|
github.com/golang/mock v1.6.0 // indirect
|
||||||
github.com/google/pprof v0.0.0-20230323073829-e72429f035bd // indirect
|
github.com/google/pprof v0.0.0-20230406165453-00490a63f317 // indirect
|
||||||
github.com/josharian/native v1.1.0 // indirect
|
|
||||||
github.com/mdlayher/raw v0.1.0 // indirect
|
|
||||||
github.com/mdlayher/socket v0.4.0 // indirect
|
github.com/mdlayher/socket v0.4.0 // indirect
|
||||||
github.com/onsi/ginkgo/v2 v2.9.2 // indirect
|
github.com/onsi/ginkgo/v2 v2.9.2 // indirect
|
||||||
github.com/patrickmn/go-cache v2.1.0+incompatible // indirect
|
github.com/patrickmn/go-cache v2.1.0+incompatible // indirect
|
||||||
@@ -54,11 +56,11 @@ require (
|
|||||||
github.com/pkg/errors v0.9.1 // indirect
|
github.com/pkg/errors v0.9.1 // indirect
|
||||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||||
github.com/quic-go/qpack v0.4.0 // indirect
|
github.com/quic-go/qpack v0.4.0 // indirect
|
||||||
github.com/quic-go/qtls-go1-19 v0.3.0 // indirect
|
github.com/quic-go/qtls-go1-19 v0.3.2 // indirect
|
||||||
github.com/quic-go/qtls-go1-20 v0.2.0 // indirect
|
github.com/quic-go/qtls-go1-20 v0.2.2 // indirect
|
||||||
github.com/u-root/uio v0.0.0-20230305220412-3e8cd9d6bf63 // indirect
|
github.com/u-root/uio v0.0.0-20230305220412-3e8cd9d6bf63 // indirect
|
||||||
golang.org/x/mod v0.9.0 // indirect
|
golang.org/x/mod v0.10.0 // indirect
|
||||||
golang.org/x/sync v0.1.0 // indirect
|
golang.org/x/sync v0.1.0 // indirect
|
||||||
golang.org/x/text v0.8.0 // indirect
|
golang.org/x/text v0.9.0 // indirect
|
||||||
golang.org/x/tools v0.7.0 // indirect
|
golang.org/x/tools v0.8.0 // indirect
|
||||||
)
|
)
|
||||||
|
|||||||
53
go.sum
53
go.sum
@@ -1,9 +1,9 @@
|
|||||||
github.com/AdguardTeam/dnsproxy v0.48.3 h1:h9xgDSmd1MqsPFNApyaPVXolmSTtzOWOcfWvPeDEP6s=
|
github.com/AdguardTeam/dnsproxy v0.49.1 h1:JpStBK05uCgA3ldleaNLRmIwE9V7vRg7/kVJQSdnQYg=
|
||||||
github.com/AdguardTeam/dnsproxy v0.48.3/go.mod h1:Y7g7jRTd/u7+KJ/QvnGI2PCE8vnisp6EsW47/Sz0DZw=
|
github.com/AdguardTeam/dnsproxy v0.49.1/go.mod h1:Y7g7jRTd/u7+KJ/QvnGI2PCE8vnisp6EsW47/Sz0DZw=
|
||||||
github.com/AdguardTeam/golibs v0.4.0/go.mod h1:skKsDKIBB7kkFflLJBpfGX+G8QFTx0WKUzB6TIgtUj4=
|
github.com/AdguardTeam/golibs v0.4.0/go.mod h1:skKsDKIBB7kkFflLJBpfGX+G8QFTx0WKUzB6TIgtUj4=
|
||||||
github.com/AdguardTeam/golibs v0.10.4/go.mod h1:rSfQRGHIdgfxriDDNgNJ7HmE5zRoURq8R+VdR81Zuzw=
|
github.com/AdguardTeam/golibs v0.10.4/go.mod h1:rSfQRGHIdgfxriDDNgNJ7HmE5zRoURq8R+VdR81Zuzw=
|
||||||
github.com/AdguardTeam/golibs v0.13.1 h1:x6ChoXk2jborbCWJ01TyBAEY3SilHts0SCG7yjnf6Sc=
|
github.com/AdguardTeam/golibs v0.13.2 h1:BPASsyQKmb+b8VnvsNOHp7bKfcZl9Z+Z2UhPjOiupSc=
|
||||||
github.com/AdguardTeam/golibs v0.13.1/go.mod h1:7ylQLv2Lqsc3UW3jHoITynYk6Y1tYtgEMkR09ppfsN8=
|
github.com/AdguardTeam/golibs v0.13.2/go.mod h1:7ylQLv2Lqsc3UW3jHoITynYk6Y1tYtgEMkR09ppfsN8=
|
||||||
github.com/AdguardTeam/gomitmproxy v0.2.0/go.mod h1:Qdv0Mktnzer5zpdpi5rAwixNJzW2FN91LjKJCkVbYGU=
|
github.com/AdguardTeam/gomitmproxy v0.2.0/go.mod h1:Qdv0Mktnzer5zpdpi5rAwixNJzW2FN91LjKJCkVbYGU=
|
||||||
github.com/AdguardTeam/urlfilter v0.16.1 h1:ZPi0rjqo8cQf2FVdzo6cqumNoHZx2KPXj2yZa1A5BBw=
|
github.com/AdguardTeam/urlfilter v0.16.1 h1:ZPi0rjqo8cQf2FVdzo6cqumNoHZx2KPXj2yZa1A5BBw=
|
||||||
github.com/AdguardTeam/urlfilter v0.16.1/go.mod h1:46YZDOV1+qtdRDuhZKVPSSp7JWWes0KayqHrKAFBdEI=
|
github.com/AdguardTeam/urlfilter v0.16.1/go.mod h1:46YZDOV1+qtdRDuhZKVPSSp7JWWes0KayqHrKAFBdEI=
|
||||||
@@ -15,8 +15,8 @@ github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da h1:KjTM2ks9d14ZYCvmH
|
|||||||
github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da/go.mod h1:eHEWzANqSiWQsof+nXEI9bUVUyV6F53Fp89EuCh2EAA=
|
github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da/go.mod h1:eHEWzANqSiWQsof+nXEI9bUVUyV6F53Fp89EuCh2EAA=
|
||||||
github.com/aead/poly1305 v0.0.0-20180717145839-3fee0db0b635 h1:52m0LGchQBBVqJRyYYufQuIbVqRawmubW3OFGqK1ekw=
|
github.com/aead/poly1305 v0.0.0-20180717145839-3fee0db0b635 h1:52m0LGchQBBVqJRyYYufQuIbVqRawmubW3OFGqK1ekw=
|
||||||
github.com/aead/poly1305 v0.0.0-20180717145839-3fee0db0b635/go.mod h1:lmLxL+FV291OopO93Bwf9fQLQeLyt33VJRUg5VJ30us=
|
github.com/aead/poly1305 v0.0.0-20180717145839-3fee0db0b635/go.mod h1:lmLxL+FV291OopO93Bwf9fQLQeLyt33VJRUg5VJ30us=
|
||||||
github.com/ameshkov/dnscrypt/v2 v2.2.6 h1:rE7AFbPWebq7me7RVS66Cipd1m7ef1yf2+C8QzjQXXE=
|
github.com/ameshkov/dnscrypt/v2 v2.2.7 h1:aEitLIR8HcxVodZ79mgRcCiC0A0I5kZPBuWGFwwulAw=
|
||||||
github.com/ameshkov/dnscrypt/v2 v2.2.6/go.mod h1:qPWhwz6FdSmuK7W4sMyvogrez4MWdtzosdqlr0Rg3ow=
|
github.com/ameshkov/dnscrypt/v2 v2.2.7/go.mod h1:qPWhwz6FdSmuK7W4sMyvogrez4MWdtzosdqlr0Rg3ow=
|
||||||
github.com/ameshkov/dnsstamps v1.0.3 h1:Srzik+J9mivH1alRACTbys2xOxs0lRH9qnTA7Y1OYVo=
|
github.com/ameshkov/dnsstamps v1.0.3 h1:Srzik+J9mivH1alRACTbys2xOxs0lRH9qnTA7Y1OYVo=
|
||||||
github.com/ameshkov/dnsstamps v1.0.3/go.mod h1:Ii3eUu73dx4Vw5O4wjzmT5+lkCwovjzaEZZ4gKyIH5A=
|
github.com/ameshkov/dnsstamps v1.0.3/go.mod h1:Ii3eUu73dx4Vw5O4wjzmT5+lkCwovjzaEZZ4gKyIH5A=
|
||||||
github.com/beefsack/go-rate v0.0.0-20220214233405-116f4ca011a0 h1:0b2vaepXIfMsG++IsjHiI2p4bxALD1Y2nQKGMR5zDQM=
|
github.com/beefsack/go-rate v0.0.0-20220214233405-116f4ca011a0 h1:0b2vaepXIfMsG++IsjHiI2p4bxALD1Y2nQKGMR5zDQM=
|
||||||
@@ -55,8 +55,8 @@ github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
|
|||||||
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||||
github.com/google/gopacket v1.1.19 h1:ves8RnFZPGiFnTS0uPQStjwru6uO6h+nlr9j6fL7kF8=
|
github.com/google/gopacket v1.1.19 h1:ves8RnFZPGiFnTS0uPQStjwru6uO6h+nlr9j6fL7kF8=
|
||||||
github.com/google/gopacket v1.1.19/go.mod h1:iJ8V8n6KS+z2U1A8pUwu8bW5SyEMkXJB8Yo/Vo+TKTo=
|
github.com/google/gopacket v1.1.19/go.mod h1:iJ8V8n6KS+z2U1A8pUwu8bW5SyEMkXJB8Yo/Vo+TKTo=
|
||||||
github.com/google/pprof v0.0.0-20230323073829-e72429f035bd h1:r8yyd+DJDmsUhGrRBxH5Pj7KeFK5l+Y3FsgT8keqKtk=
|
github.com/google/pprof v0.0.0-20230406165453-00490a63f317 h1:hFhpt7CTmR3DX+b4R19ydQFtofxT0Sv3QsKNMVQYTMQ=
|
||||||
github.com/google/pprof v0.0.0-20230323073829-e72429f035bd/go.mod h1:79YE0hCXdHag9sBkw2o+N/YnZtTkXi0UT9Nnixa5eYk=
|
github.com/google/pprof v0.0.0-20230406165453-00490a63f317/go.mod h1:79YE0hCXdHag9sBkw2o+N/YnZtTkXi0UT9Nnixa5eYk=
|
||||||
github.com/google/renameio v1.0.1 h1:Lh/jXZmvZxb0BBeSY5VKEfidcbcbenKjZFzM/q0fSeU=
|
github.com/google/renameio v1.0.1 h1:Lh/jXZmvZxb0BBeSY5VKEfidcbcbenKjZFzM/q0fSeU=
|
||||||
github.com/google/renameio v1.0.1/go.mod h1:t/HQoYBZSsWSNK35C6CO/TpPLDVWvxOHboWUAweKUpk=
|
github.com/google/renameio v1.0.1/go.mod h1:t/HQoYBZSsWSNK35C6CO/TpPLDVWvxOHboWUAweKUpk=
|
||||||
github.com/google/uuid v1.2.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
github.com/google/uuid v1.2.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||||
@@ -70,8 +70,8 @@ github.com/insomniacslk/dhcp v0.0.0-20221215072855-de60144f33f8/go.mod h1:m5WMe0
|
|||||||
github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
|
github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
|
||||||
github.com/josharian/native v1.0.0/go.mod h1:7X/raswPFr05uY3HiLlYeyQntB6OO7E/d2Cu7qoaN2w=
|
github.com/josharian/native v1.0.0/go.mod h1:7X/raswPFr05uY3HiLlYeyQntB6OO7E/d2Cu7qoaN2w=
|
||||||
github.com/josharian/native v1.0.1-0.20221213033349-c1e37c09b531/go.mod h1:7X/raswPFr05uY3HiLlYeyQntB6OO7E/d2Cu7qoaN2w=
|
github.com/josharian/native v1.0.1-0.20221213033349-c1e37c09b531/go.mod h1:7X/raswPFr05uY3HiLlYeyQntB6OO7E/d2Cu7qoaN2w=
|
||||||
github.com/josharian/native v1.1.0 h1:uuaP0hAbW7Y4l0ZRQ6C9zfb7Mg1mbFKry/xzDAfmtLA=
|
github.com/josharian/native v1.1.1-0.20230202152459-5c7d0dd6ab86 h1:elKwZS1OcdQ0WwEDBeqxKwb7WB62QX8bvZ/FJnVXIfk=
|
||||||
github.com/josharian/native v1.1.0/go.mod h1:7X/raswPFr05uY3HiLlYeyQntB6OO7E/d2Cu7qoaN2w=
|
github.com/josharian/native v1.1.1-0.20230202152459-5c7d0dd6ab86/go.mod h1:aFAMtuldEgx/4q7iSGazk22+IcgvtiC+HIimFO9XlS8=
|
||||||
github.com/jsimonetti/rtnetlink v0.0.0-20190606172950-9527aa82566a/go.mod h1:Oz+70psSo5OFh8DBl0Zv2ACw7Esh6pPUphlvZG9x7uw=
|
github.com/jsimonetti/rtnetlink v0.0.0-20190606172950-9527aa82566a/go.mod h1:Oz+70psSo5OFh8DBl0Zv2ACw7Esh6pPUphlvZG9x7uw=
|
||||||
github.com/jsimonetti/rtnetlink v0.0.0-20200117123717-f846d4f6c1f4/go.mod h1:WGuG/smIU4J/54PblvSbh+xvCZmpJnFgr3ds6Z55XMQ=
|
github.com/jsimonetti/rtnetlink v0.0.0-20200117123717-f846d4f6c1f4/go.mod h1:WGuG/smIU4J/54PblvSbh+xvCZmpJnFgr3ds6Z55XMQ=
|
||||||
github.com/jsimonetti/rtnetlink v0.0.0-20201009170750-9c6f07d100c1/go.mod h1:hqoO/u39cqLeBLebZ8fWdE96O7FxrAsRYhnVOdgHxok=
|
github.com/jsimonetti/rtnetlink v0.0.0-20201009170750-9c6f07d100c1/go.mod h1:hqoO/u39cqLeBLebZ8fWdE96O7FxrAsRYhnVOdgHxok=
|
||||||
@@ -123,10 +123,10 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
|
|||||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
github.com/quic-go/qpack v0.4.0 h1:Cr9BXA1sQS2SmDUWjSofMPNKmvF6IiIfDRmgU0w1ZCo=
|
github.com/quic-go/qpack v0.4.0 h1:Cr9BXA1sQS2SmDUWjSofMPNKmvF6IiIfDRmgU0w1ZCo=
|
||||||
github.com/quic-go/qpack v0.4.0/go.mod h1:UZVnYIfi5GRk+zI9UMaCPsmZ2xKJP7XBUvVyT1Knj9A=
|
github.com/quic-go/qpack v0.4.0/go.mod h1:UZVnYIfi5GRk+zI9UMaCPsmZ2xKJP7XBUvVyT1Knj9A=
|
||||||
github.com/quic-go/qtls-go1-19 v0.3.0 h1:aUBoQdpHzUWtPw5tQZbsD2GnrWCNu7/RIX1PtqGeLYY=
|
github.com/quic-go/qtls-go1-19 v0.3.2 h1:tFxjCFcTQzK+oMxG6Zcvp4Dq8dx4yD3dDiIiyc86Z5U=
|
||||||
github.com/quic-go/qtls-go1-19 v0.3.0/go.mod h1:ySOI96ew8lnoKPtSqx2BlI5wCpUVPT05RMAlajtnyOI=
|
github.com/quic-go/qtls-go1-19 v0.3.2/go.mod h1:ySOI96ew8lnoKPtSqx2BlI5wCpUVPT05RMAlajtnyOI=
|
||||||
github.com/quic-go/qtls-go1-20 v0.2.0 h1:jUHn+obJ6WI5JudqBO0Iy1ra5Vh5vsitQ1gXQvkmN+E=
|
github.com/quic-go/qtls-go1-20 v0.2.2 h1:WLOPx6OY/hxtTxKV1Zrq20FtXtDEkeY00CGQm8GEa3E=
|
||||||
github.com/quic-go/qtls-go1-20 v0.2.0/go.mod h1:JKtK6mjbAVcUTN/9jZpvLbGxvdWIKS8uT7EiStoU1SM=
|
github.com/quic-go/qtls-go1-20 v0.2.2/go.mod h1:JKtK6mjbAVcUTN/9jZpvLbGxvdWIKS8uT7EiStoU1SM=
|
||||||
github.com/quic-go/quic-go v0.33.0 h1:ItNoTDN/Fm/zBlq769lLJc8ECe9gYaW40veHCCco7y0=
|
github.com/quic-go/quic-go v0.33.0 h1:ItNoTDN/Fm/zBlq769lLJc8ECe9gYaW40veHCCco7y0=
|
||||||
github.com/quic-go/quic-go v0.33.0/go.mod h1:YMuhaAV9/jIu0XclDXwZPAsP/2Kgr5yMYhe9oxhhOFA=
|
github.com/quic-go/quic-go v0.33.0/go.mod h1:YMuhaAV9/jIu0XclDXwZPAsP/2Kgr5yMYhe9oxhhOFA=
|
||||||
github.com/shirou/gopsutil/v3 v3.21.8 h1:nKct+uP0TV8DjjNiHanKf8SAuub+GNsbrOtM9Nl9biA=
|
github.com/shirou/gopsutil/v3 v3.21.8 h1:nKct+uP0TV8DjjNiHanKf8SAuub+GNsbrOtM9Nl9biA=
|
||||||
@@ -161,15 +161,15 @@ go.etcd.io/bbolt v1.3.7/go.mod h1:N9Mkw9X8x5fupy0IKsmuqVtoGDyxsaDlbk4Rd05IAQw=
|
|||||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||||
golang.org/x/crypto v0.7.0 h1:AvwMYaRytfdeVt3u6mLaxYtErKYjxA2OXjJ1HHq6t3A=
|
golang.org/x/crypto v0.8.0 h1:pd9TJtTueMTVQXzk8E2XESSMQDj/U7OUu0PqJqPXQjQ=
|
||||||
golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU=
|
golang.org/x/crypto v0.8.0/go.mod h1:mRqEX+O9/h5TFCrQhkgjo2yKi0yYA+9ecGkdQoHrywE=
|
||||||
golang.org/x/exp v0.0.0-20230321023759-10a507213a29 h1:ooxPy7fPvB4kwsA2h+iBNHkAbp/4JxTSwCmvdjEYmug=
|
golang.org/x/exp v0.0.0-20230321023759-10a507213a29 h1:ooxPy7fPvB4kwsA2h+iBNHkAbp/4JxTSwCmvdjEYmug=
|
||||||
golang.org/x/exp v0.0.0-20230321023759-10a507213a29/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc=
|
golang.org/x/exp v0.0.0-20230321023759-10a507213a29/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc=
|
||||||
golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
|
golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
|
||||||
golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
|
golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
|
||||||
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||||
golang.org/x/mod v0.9.0 h1:KENHtAZL2y3NLMYZeHY9DW8HW8V+kQyJsY/V9JlKvCs=
|
golang.org/x/mod v0.10.0 h1:lFO9qtOdlre5W1jxS3r/4szv2/6iXxScdzjoBMXNhYk=
|
||||||
golang.org/x/mod v0.9.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
|
golang.org/x/mod v0.10.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
|
||||||
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||||
golang.org/x/net v0.0.0-20190419010253-1f3472d942ba/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
golang.org/x/net v0.0.0-20190419010253-1f3472d942ba/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||||
@@ -185,8 +185,8 @@ golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v
|
|||||||
golang.org/x/net v0.0.0-20210316092652-d523dce5a7f4/go.mod h1:RBQZq4jEuRlivfhVLdyRGr576XBO4/greRjx4P4O3yc=
|
golang.org/x/net v0.0.0-20210316092652-d523dce5a7f4/go.mod h1:RBQZq4jEuRlivfhVLdyRGr576XBO4/greRjx4P4O3yc=
|
||||||
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
|
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
|
||||||
golang.org/x/net v0.0.0-20210929193557-e81a3d93ecf6/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
golang.org/x/net v0.0.0-20210929193557-e81a3d93ecf6/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||||
golang.org/x/net v0.8.0 h1:Zrh2ngAOFYneWTAIAPethzeaQLuHwhuBkuV6ZiRnUaQ=
|
golang.org/x/net v0.9.0 h1:aWJ/m6xSmxWBx+V0XRHTlrYrPG56jKsLdTFmsSsCzOM=
|
||||||
golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc=
|
golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns=
|
||||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o=
|
golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o=
|
||||||
@@ -218,23 +218,24 @@ golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBc
|
|||||||
golang.org/x/sys v0.0.0-20220209214540-3681064d5158/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20220209214540-3681064d5158/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.0.0-20220622161953-175b2fd9d664/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20220622161953-175b2fd9d664/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ=
|
golang.org/x/sys v0.4.1-0.20230131160137-e7d7f63158de/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.7.0 h1:3jlCCIQZPdOYu1h8BkNvLz8Kgwtae2cagcG/VamtZRU=
|
||||||
|
golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
||||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||||
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||||
golang.org/x/text v0.8.0 h1:57P1ETyNKtuIjB4SRd15iJxuhj8Gc416Y78H3qgMh68=
|
golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE=
|
||||||
golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
|
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
|
||||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||||
golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||||
golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||||
golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
|
golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
|
||||||
golang.org/x/tools v0.7.0 h1:W4OVu8VVOaIO0yzWMNdepAulS7YfoS3Zabrm8DOXXU4=
|
golang.org/x/tools v0.8.0 h1:vSDcovVPld282ceKgDimkRSC8kpaH1dgyc9UMzlt84Y=
|
||||||
golang.org/x/tools v0.7.0/go.mod h1:4pg6aUX35JBAogB10C9AtvVL+qowtN4pT3CGSQex14s=
|
golang.org/x/tools v0.8.0/go.mod h1:JxBZ99ISMI5ViVkT1tr6tdNmXeTrcpVSD3vZ1RsRdN4=
|
||||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/AdguardTeam/AdGuardHome/internal/version"
|
"github.com/AdguardTeam/AdGuardHome/internal/version"
|
||||||
|
"github.com/AdguardTeam/golibs/httphdr"
|
||||||
"github.com/AdguardTeam/golibs/log"
|
"github.com/AdguardTeam/golibs/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -52,7 +53,7 @@ const textPlainDeprMsg = `using this api with the text/plain content-type is dep
|
|||||||
// deprecation and removal of a plain-text API if the request is made with the
|
// deprecation and removal of a plain-text API if the request is made with the
|
||||||
// "text/plain" content-type.
|
// "text/plain" content-type.
|
||||||
func WriteTextPlainDeprecated(w http.ResponseWriter, r *http.Request) (isPlainText bool) {
|
func WriteTextPlainDeprecated(w http.ResponseWriter, r *http.Request) (isPlainText bool) {
|
||||||
if r.Header.Get(HdrNameContentType) != HdrValTextPlain {
|
if r.Header.Get(httphdr.ContentType) != HdrValTextPlain {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -71,8 +72,8 @@ func WriteJSONResponse(w http.ResponseWriter, r *http.Request, resp any) (err er
|
|||||||
// WriteJSONResponseCode is like [WriteJSONResponse] but adds the ability to
|
// WriteJSONResponseCode is like [WriteJSONResponse] but adds the ability to
|
||||||
// redefine the status code.
|
// redefine the status code.
|
||||||
func WriteJSONResponseCode(w http.ResponseWriter, r *http.Request, code int, resp any) (err error) {
|
func WriteJSONResponseCode(w http.ResponseWriter, r *http.Request, code int, resp any) (err error) {
|
||||||
|
w.Header().Set(httphdr.ContentType, HdrValApplicationJSON)
|
||||||
w.WriteHeader(code)
|
w.WriteHeader(code)
|
||||||
w.Header().Set(HdrNameContentType, HdrValApplicationJSON)
|
|
||||||
err = json.NewEncoder(w).Encode(resp)
|
err = json.NewEncoder(w).Encode(resp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
Error(r, w, http.StatusInternalServerError, "encoding resp: %s", err)
|
Error(r, w, http.StatusInternalServerError, "encoding resp: %s", err)
|
||||||
|
|||||||
@@ -1,22 +1,6 @@
|
|||||||
package aghhttp
|
package aghhttp
|
||||||
|
|
||||||
// HTTP Headers
|
// HTTP headers
|
||||||
|
|
||||||
// HTTP header name constants.
|
|
||||||
//
|
|
||||||
// TODO(a.garipov): Remove unused.
|
|
||||||
const (
|
|
||||||
HdrNameAcceptEncoding = "Accept-Encoding"
|
|
||||||
HdrNameAccessControlAllowOrigin = "Access-Control-Allow-Origin"
|
|
||||||
HdrNameAltSvc = "Alt-Svc"
|
|
||||||
HdrNameContentEncoding = "Content-Encoding"
|
|
||||||
HdrNameContentType = "Content-Type"
|
|
||||||
HdrNameOrigin = "Origin"
|
|
||||||
HdrNameServer = "Server"
|
|
||||||
HdrNameTrailer = "Trailer"
|
|
||||||
HdrNameUserAgent = "User-Agent"
|
|
||||||
HdrNameVary = "Vary"
|
|
||||||
)
|
|
||||||
|
|
||||||
// HTTP header value constants.
|
// HTTP header value constants.
|
||||||
const (
|
const (
|
||||||
|
|||||||
2
internal/aghnet/testdata/etc_hosts
vendored
2
internal/aghnet/testdata/etc_hosts
vendored
@@ -35,4 +35,4 @@
|
|||||||
1.3.5.7 domain4 domain4.alias
|
1.3.5.7 domain4 domain4.alias
|
||||||
7.5.3.1 domain4.alias domain4
|
7.5.3.1 domain4.alias domain4
|
||||||
::13 domain6 domain6.alias
|
::13 domain6 domain6.alias
|
||||||
::31 domain6.alias domain6
|
::31 domain6.alias domain6
|
||||||
|
|||||||
2
internal/aghnet/testdata/ifaces
vendored
2
internal/aghnet/testdata/ifaces
vendored
@@ -1 +1 @@
|
|||||||
iface sample_name inet static
|
iface sample_name inet static
|
||||||
|
|||||||
2
internal/aghnet/testdata/include-subsources
vendored
2
internal/aghnet/testdata/include-subsources
vendored
@@ -2,4 +2,4 @@
|
|||||||
# parent directory. Real interface files usually contain only absolute paths.
|
# parent directory. Real interface files usually contain only absolute paths.
|
||||||
|
|
||||||
source ./testdata/ifaces
|
source ./testdata/ifaces
|
||||||
source ./testdata/*
|
source ./testdata/*
|
||||||
|
|||||||
2
internal/aghnet/testdata/proc_net_arp
vendored
2
internal/aghnet/testdata/proc_net_arp
vendored
@@ -3,4 +3,4 @@ IP address HW type Flags HW address Mask Device
|
|||||||
::ffff:ffff 0x1 0x0 ef:cd:ab:ef:cd:ab * br-lan
|
::ffff:ffff 0x1 0x0 ef:cd:ab:ef:cd:ab * br-lan
|
||||||
0.0.0.0 0x0 0x0 00:00:00:00:00:00 * unspec
|
0.0.0.0 0x0 0x0 00:00:00:00:00:00 * unspec
|
||||||
1.2.3.4.5 0x1 0x2 aa:bb:cc:dd:ee:ff * wan
|
1.2.3.4.5 0x1 0x2 aa:bb:cc:dd:ee:ff * wan
|
||||||
1.2.3.4 0x1 0x2 12:34:56:78:910 * wan
|
1.2.3.4 0x1 0x2 12:34:56:78:910 * wan
|
||||||
|
|||||||
@@ -1,10 +0,0 @@
|
|||||||
//go:build mips || mips64
|
|
||||||
|
|
||||||
// This file is an adapted version of github.com/josharian/native.
|
|
||||||
|
|
||||||
package aghos
|
|
||||||
|
|
||||||
import "encoding/binary"
|
|
||||||
|
|
||||||
// NativeEndian is the native endianness of this system.
|
|
||||||
var NativeEndian = binary.BigEndian
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
//go:build amd64 || 386 || arm || arm64 || mipsle || mips64le || ppc64le
|
|
||||||
|
|
||||||
// This file is an adapted version of github.com/josharian/native.
|
|
||||||
|
|
||||||
package aghos
|
|
||||||
|
|
||||||
import "encoding/binary"
|
|
||||||
|
|
||||||
// NativeEndian is the native endianness of this system.
|
|
||||||
var NativeEndian = binary.LittleEndian
|
|
||||||
6
internal/aghos/service.go
Normal file
6
internal/aghos/service.go
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
package aghos
|
||||||
|
|
||||||
|
// PreCheckActionStart performs the service start action pre-check.
|
||||||
|
func PreCheckActionStart() (err error) {
|
||||||
|
return preCheckActionStart()
|
||||||
|
}
|
||||||
32
internal/aghos/service_darwin.go
Normal file
32
internal/aghos/service_darwin.go
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
//go:build darwin
|
||||||
|
|
||||||
|
package aghos
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"github.com/AdguardTeam/golibs/log"
|
||||||
|
)
|
||||||
|
|
||||||
|
// preCheckActionStart performs the service start action pre-check. It warns
|
||||||
|
// user that the service should be installed into Applications directory.
|
||||||
|
func preCheckActionStart() (err error) {
|
||||||
|
exe, err := os.Executable()
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("getting executable path: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
exe, err = filepath.EvalSymlinks(exe)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("evaluating executable symlinks: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if !strings.HasPrefix(exe, "/Applications/") {
|
||||||
|
log.Info("warning: service must be started from within the /Applications directory")
|
||||||
|
}
|
||||||
|
|
||||||
|
return err
|
||||||
|
}
|
||||||
8
internal/aghos/service_others.go
Normal file
8
internal/aghos/service_others.go
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
//go:build !darwin
|
||||||
|
|
||||||
|
package aghos
|
||||||
|
|
||||||
|
// preCheckActionStart performs the service start action pre-check.
|
||||||
|
func preCheckActionStart() (err error) {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
@@ -31,8 +31,16 @@ type ServerConfig struct {
|
|||||||
Conf4 V4ServerConf `yaml:"dhcpv4"`
|
Conf4 V4ServerConf `yaml:"dhcpv4"`
|
||||||
Conf6 V6ServerConf `yaml:"dhcpv6"`
|
Conf6 V6ServerConf `yaml:"dhcpv6"`
|
||||||
|
|
||||||
WorkDir string `yaml:"-"`
|
// WorkDir is used to store DHCP leases.
|
||||||
DBFilePath string `yaml:"-"`
|
//
|
||||||
|
// Deprecated: Remove it when migration of DHCP leases will not be needed.
|
||||||
|
WorkDir string `yaml:"-"`
|
||||||
|
|
||||||
|
// DataDir is used to store DHCP leases.
|
||||||
|
DataDir string `yaml:"-"`
|
||||||
|
|
||||||
|
// dbFilePath is the path to the file with stored DHCP leases.
|
||||||
|
dbFilePath string `yaml:"-"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// DHCPServer - DHCP server interface
|
// DHCPServer - DHCP server interface
|
||||||
|
|||||||
293
internal/dhcpd/conn_darwin.go
Normal file
293
internal/dhcpd/conn_darwin.go
Normal file
@@ -0,0 +1,293 @@
|
|||||||
|
//go:build darwin
|
||||||
|
|
||||||
|
package dhcpd
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"net"
|
||||||
|
"os"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/AdguardTeam/golibs/errors"
|
||||||
|
"github.com/AdguardTeam/golibs/log"
|
||||||
|
"github.com/AdguardTeam/golibs/netutil"
|
||||||
|
"github.com/google/gopacket"
|
||||||
|
"github.com/google/gopacket/layers"
|
||||||
|
"github.com/insomniacslk/dhcp/dhcpv4"
|
||||||
|
"github.com/insomniacslk/dhcp/dhcpv4/server4"
|
||||||
|
"github.com/mdlayher/ethernet"
|
||||||
|
|
||||||
|
//lint:ignore SA1019 See the TODO in go.mod.
|
||||||
|
"github.com/mdlayher/raw"
|
||||||
|
)
|
||||||
|
|
||||||
|
// dhcpUnicastAddr is the combination of MAC and IP addresses for responding to
|
||||||
|
// the unconfigured host.
|
||||||
|
type dhcpUnicastAddr struct {
|
||||||
|
// raw.Addr is embedded here to make *dhcpUcastAddr a net.Addr without
|
||||||
|
// actually implementing all methods. It also contains the client's
|
||||||
|
// hardware address.
|
||||||
|
raw.Addr
|
||||||
|
|
||||||
|
// yiaddr is an IP address just allocated by server for the host.
|
||||||
|
yiaddr net.IP
|
||||||
|
}
|
||||||
|
|
||||||
|
// dhcpConn is the net.PacketConn capable of handling both net.UDPAddr and
|
||||||
|
// net.HardwareAddr.
|
||||||
|
type dhcpConn struct {
|
||||||
|
// udpConn is the connection for UDP addresses.
|
||||||
|
udpConn net.PacketConn
|
||||||
|
// bcastIP is the broadcast address specific for the configured
|
||||||
|
// interface's subnet.
|
||||||
|
bcastIP net.IP
|
||||||
|
|
||||||
|
// rawConn is the connection for MAC addresses.
|
||||||
|
rawConn net.PacketConn
|
||||||
|
// srcMAC is the hardware address of the configured network interface.
|
||||||
|
srcMAC net.HardwareAddr
|
||||||
|
// srcIP is the IP address of the configured network interface.
|
||||||
|
srcIP net.IP
|
||||||
|
}
|
||||||
|
|
||||||
|
// newDHCPConn creates the special connection for DHCP server.
|
||||||
|
func (s *v4Server) newDHCPConn(iface *net.Interface) (c net.PacketConn, err error) {
|
||||||
|
var ucast net.PacketConn
|
||||||
|
if ucast, err = raw.ListenPacket(iface, uint16(ethernet.EtherTypeIPv4), nil); err != nil {
|
||||||
|
return nil, fmt.Errorf("creating raw udp connection: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create the UDP connection.
|
||||||
|
var bcast net.PacketConn
|
||||||
|
bcast, err = server4.NewIPv4UDPConn(iface.Name, &net.UDPAddr{
|
||||||
|
// TODO(e.burkov): Listening on zeroes makes the server handle
|
||||||
|
// requests from all the interfaces. Inspect the ways to
|
||||||
|
// specify the interface-specific listening addresses.
|
||||||
|
//
|
||||||
|
// See https://github.com/AdguardTeam/AdGuardHome/issues/3539.
|
||||||
|
IP: net.IP{0, 0, 0, 0},
|
||||||
|
Port: dhcpv4.ServerPort,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("creating ipv4 udp connection: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return &dhcpConn{
|
||||||
|
udpConn: bcast,
|
||||||
|
bcastIP: s.conf.broadcastIP.AsSlice(),
|
||||||
|
rawConn: ucast,
|
||||||
|
srcMAC: iface.HardwareAddr,
|
||||||
|
srcIP: s.conf.dnsIPAddrs[0].AsSlice(),
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// wrapErrs is a helper to wrap the errors from two independent underlying
|
||||||
|
// connections.
|
||||||
|
func (*dhcpConn) wrapErrs(action string, udpConnErr, rawConnErr error) (err error) {
|
||||||
|
switch {
|
||||||
|
case udpConnErr != nil && rawConnErr != nil:
|
||||||
|
return errors.List(fmt.Sprintf("%s both connections", action), udpConnErr, rawConnErr)
|
||||||
|
case udpConnErr != nil:
|
||||||
|
return fmt.Errorf("%s udp connection: %w", action, udpConnErr)
|
||||||
|
case rawConnErr != nil:
|
||||||
|
return fmt.Errorf("%s raw connection: %w", action, rawConnErr)
|
||||||
|
default:
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// WriteTo implements net.PacketConn for *dhcpConn. It selects the underlying
|
||||||
|
// connection to write to based on the type of addr.
|
||||||
|
func (c *dhcpConn) WriteTo(p []byte, addr net.Addr) (n int, err error) {
|
||||||
|
switch addr := addr.(type) {
|
||||||
|
case *dhcpUnicastAddr:
|
||||||
|
// Unicast the message to the client's MAC address. Use the raw
|
||||||
|
// connection.
|
||||||
|
//
|
||||||
|
// Note: unicasting is performed on the only network interface
|
||||||
|
// that is configured. For now it may be not what users expect
|
||||||
|
// so additionally broadcast the message via UDP connection.
|
||||||
|
//
|
||||||
|
// See https://github.com/AdguardTeam/AdGuardHome/issues/3539.
|
||||||
|
var rerr error
|
||||||
|
n, rerr = c.unicast(p, addr)
|
||||||
|
|
||||||
|
_, uerr := c.broadcast(p, &net.UDPAddr{
|
||||||
|
IP: netutil.IPv4bcast(),
|
||||||
|
Port: dhcpv4.ClientPort,
|
||||||
|
})
|
||||||
|
|
||||||
|
return n, c.wrapErrs("writing to", uerr, rerr)
|
||||||
|
case *net.UDPAddr:
|
||||||
|
if addr.IP.Equal(net.IPv4bcast) {
|
||||||
|
// Broadcast the message for the client which supports
|
||||||
|
// it. Use the UDP connection.
|
||||||
|
return c.broadcast(p, addr)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Unicast the message to the client's IP address. Use the UDP
|
||||||
|
// connection.
|
||||||
|
return c.udpConn.WriteTo(p, addr)
|
||||||
|
default:
|
||||||
|
return 0, fmt.Errorf("addr has an unexpected type %T", addr)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ReadFrom implements net.PacketConn for *dhcpConn.
|
||||||
|
func (c *dhcpConn) ReadFrom(p []byte) (n int, addr net.Addr, err error) {
|
||||||
|
return c.udpConn.ReadFrom(p)
|
||||||
|
}
|
||||||
|
|
||||||
|
// unicast wraps respData with required frames and writes it to the peer.
|
||||||
|
func (c *dhcpConn) unicast(respData []byte, peer *dhcpUnicastAddr) (n int, err error) {
|
||||||
|
var data []byte
|
||||||
|
data, err = c.buildEtherPkt(respData, peer)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return c.rawConn.WriteTo(data, &peer.Addr)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Close implements net.PacketConn for *dhcpConn.
|
||||||
|
func (c *dhcpConn) Close() (err error) {
|
||||||
|
rerr := c.rawConn.Close()
|
||||||
|
if errors.Is(rerr, os.ErrClosed) {
|
||||||
|
// Ignore the error since the actual file is closed already.
|
||||||
|
rerr = nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return c.wrapErrs("closing", c.udpConn.Close(), rerr)
|
||||||
|
}
|
||||||
|
|
||||||
|
// LocalAddr implements net.PacketConn for *dhcpConn.
|
||||||
|
func (c *dhcpConn) LocalAddr() (a net.Addr) {
|
||||||
|
return c.udpConn.LocalAddr()
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetDeadline implements net.PacketConn for *dhcpConn.
|
||||||
|
func (c *dhcpConn) SetDeadline(t time.Time) (err error) {
|
||||||
|
return c.wrapErrs("setting deadline on", c.udpConn.SetDeadline(t), c.rawConn.SetDeadline(t))
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetReadDeadline implements net.PacketConn for *dhcpConn.
|
||||||
|
func (c *dhcpConn) SetReadDeadline(t time.Time) error {
|
||||||
|
return c.wrapErrs(
|
||||||
|
"setting reading deadline on",
|
||||||
|
c.udpConn.SetReadDeadline(t),
|
||||||
|
c.rawConn.SetReadDeadline(t),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetWriteDeadline implements net.PacketConn for *dhcpConn.
|
||||||
|
func (c *dhcpConn) SetWriteDeadline(t time.Time) error {
|
||||||
|
return c.wrapErrs(
|
||||||
|
"setting writing deadline on",
|
||||||
|
c.udpConn.SetWriteDeadline(t),
|
||||||
|
c.rawConn.SetWriteDeadline(t),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ipv4DefaultTTL is the default Time to Live value in seconds as recommended by
|
||||||
|
// RFC-1700.
|
||||||
|
//
|
||||||
|
// See https://datatracker.ietf.org/doc/html/rfc1700.
|
||||||
|
const ipv4DefaultTTL = 64
|
||||||
|
|
||||||
|
// buildEtherPkt wraps the payload with IPv4, UDP and Ethernet frames.
|
||||||
|
// Validation of the payload is a caller's responsibility.
|
||||||
|
func (c *dhcpConn) buildEtherPkt(payload []byte, peer *dhcpUnicastAddr) (pkt []byte, err error) {
|
||||||
|
udpLayer := &layers.UDP{
|
||||||
|
SrcPort: dhcpv4.ServerPort,
|
||||||
|
DstPort: dhcpv4.ClientPort,
|
||||||
|
}
|
||||||
|
|
||||||
|
ipv4Layer := &layers.IPv4{
|
||||||
|
Version: uint8(layers.IPProtocolIPv4),
|
||||||
|
Flags: layers.IPv4DontFragment,
|
||||||
|
TTL: ipv4DefaultTTL,
|
||||||
|
Protocol: layers.IPProtocolUDP,
|
||||||
|
SrcIP: c.srcIP,
|
||||||
|
DstIP: peer.yiaddr,
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ignore the error since it's only returned for invalid network layer's
|
||||||
|
// type.
|
||||||
|
_ = udpLayer.SetNetworkLayerForChecksum(ipv4Layer)
|
||||||
|
|
||||||
|
ethLayer := &layers.Ethernet{
|
||||||
|
SrcMAC: c.srcMAC,
|
||||||
|
DstMAC: peer.HardwareAddr,
|
||||||
|
EthernetType: layers.EthernetTypeIPv4,
|
||||||
|
}
|
||||||
|
|
||||||
|
buf := gopacket.NewSerializeBuffer()
|
||||||
|
setts := gopacket.SerializeOptions{
|
||||||
|
FixLengths: true,
|
||||||
|
ComputeChecksums: true,
|
||||||
|
}
|
||||||
|
|
||||||
|
err = gopacket.SerializeLayers(
|
||||||
|
buf,
|
||||||
|
setts,
|
||||||
|
ethLayer,
|
||||||
|
ipv4Layer,
|
||||||
|
udpLayer,
|
||||||
|
gopacket.Payload(payload),
|
||||||
|
)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("serializing layers: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return buf.Bytes(), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// send writes resp for peer to conn considering the req's parameters according
|
||||||
|
// to RFC-2131.
|
||||||
|
//
|
||||||
|
// See https://datatracker.ietf.org/doc/html/rfc2131#section-4.1.
|
||||||
|
func (s *v4Server) send(peer net.Addr, conn net.PacketConn, req, resp *dhcpv4.DHCPv4) {
|
||||||
|
switch giaddr, ciaddr, mtype := req.GatewayIPAddr, req.ClientIPAddr, resp.MessageType(); {
|
||||||
|
case giaddr != nil && !giaddr.IsUnspecified():
|
||||||
|
// Send any return messages to the server port on the BOOTP
|
||||||
|
// relay agent whose address appears in giaddr.
|
||||||
|
peer = &net.UDPAddr{
|
||||||
|
IP: giaddr,
|
||||||
|
Port: dhcpv4.ServerPort,
|
||||||
|
}
|
||||||
|
if mtype == dhcpv4.MessageTypeNak {
|
||||||
|
// Set the broadcast bit in the DHCPNAK, so that the relay agent
|
||||||
|
// broadcasts it to the client, because the client may not have
|
||||||
|
// a correct network address or subnet mask, and the client may not
|
||||||
|
// be answering ARP requests.
|
||||||
|
resp.SetBroadcast()
|
||||||
|
}
|
||||||
|
case mtype == dhcpv4.MessageTypeNak:
|
||||||
|
// Broadcast any DHCPNAK messages to 0xffffffff.
|
||||||
|
case ciaddr != nil && !ciaddr.IsUnspecified():
|
||||||
|
// Unicast DHCPOFFER and DHCPACK messages to the address in
|
||||||
|
// ciaddr.
|
||||||
|
peer = &net.UDPAddr{
|
||||||
|
IP: ciaddr,
|
||||||
|
Port: dhcpv4.ClientPort,
|
||||||
|
}
|
||||||
|
case !req.IsBroadcast() && req.ClientHWAddr != nil:
|
||||||
|
// Unicast DHCPOFFER and DHCPACK messages to the client's
|
||||||
|
// hardware address and yiaddr.
|
||||||
|
peer = &dhcpUnicastAddr{
|
||||||
|
Addr: raw.Addr{HardwareAddr: req.ClientHWAddr},
|
||||||
|
yiaddr: resp.YourIPAddr,
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
// Go on since peer is already set to broadcast.
|
||||||
|
}
|
||||||
|
|
||||||
|
pktData := resp.ToBytes()
|
||||||
|
|
||||||
|
log.Debug("dhcpv4: sending %d bytes to %s: %s", len(pktData), peer, resp.Summary())
|
||||||
|
|
||||||
|
_, err := conn.WriteTo(pktData, peer)
|
||||||
|
if err != nil {
|
||||||
|
log.Error("dhcpv4: conn.Write to %s failed: %s", peer, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
219
internal/dhcpd/conn_darwin_internal_test.go
Normal file
219
internal/dhcpd/conn_darwin_internal_test.go
Normal file
@@ -0,0 +1,219 @@
|
|||||||
|
//go:build darwin
|
||||||
|
|
||||||
|
package dhcpd
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/AdguardTeam/golibs/testutil"
|
||||||
|
"github.com/google/gopacket"
|
||||||
|
"github.com/google/gopacket/layers"
|
||||||
|
"github.com/insomniacslk/dhcp/dhcpv4"
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
|
//lint:ignore SA1019 See the TODO in go.mod.
|
||||||
|
"github.com/mdlayher/raw"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestDHCPConn_WriteTo_common(t *testing.T) {
|
||||||
|
respData := (&dhcpv4.DHCPv4{}).ToBytes()
|
||||||
|
udpAddr := &net.UDPAddr{
|
||||||
|
IP: net.IP{1, 2, 3, 4},
|
||||||
|
Port: dhcpv4.ClientPort,
|
||||||
|
}
|
||||||
|
|
||||||
|
t.Run("unicast_ip", func(t *testing.T) {
|
||||||
|
writeTo := func(_ []byte, addr net.Addr) (_ int, _ error) {
|
||||||
|
assert.Equal(t, udpAddr, addr)
|
||||||
|
|
||||||
|
return 0, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
conn := &dhcpConn{udpConn: &fakePacketConn{writeTo: writeTo}}
|
||||||
|
|
||||||
|
_, err := conn.WriteTo(respData, udpAddr)
|
||||||
|
assert.NoError(t, err)
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("unexpected_addr_type", func(t *testing.T) {
|
||||||
|
type unexpectedAddrType struct {
|
||||||
|
net.Addr
|
||||||
|
}
|
||||||
|
|
||||||
|
conn := &dhcpConn{}
|
||||||
|
n, err := conn.WriteTo(nil, &unexpectedAddrType{})
|
||||||
|
require.Error(t, err)
|
||||||
|
|
||||||
|
testutil.AssertErrorMsg(t, "addr has an unexpected type *dhcpd.unexpectedAddrType", err)
|
||||||
|
assert.Zero(t, n)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestBuildEtherPkt(t *testing.T) {
|
||||||
|
conn := &dhcpConn{
|
||||||
|
srcMAC: net.HardwareAddr{1, 2, 3, 4, 5, 6},
|
||||||
|
srcIP: net.IP{1, 2, 3, 4},
|
||||||
|
}
|
||||||
|
peer := &dhcpUnicastAddr{
|
||||||
|
Addr: raw.Addr{HardwareAddr: net.HardwareAddr{6, 5, 4, 3, 2, 1}},
|
||||||
|
yiaddr: net.IP{4, 3, 2, 1},
|
||||||
|
}
|
||||||
|
payload := (&dhcpv4.DHCPv4{}).ToBytes()
|
||||||
|
|
||||||
|
t.Run("success", func(t *testing.T) {
|
||||||
|
pkt, err := conn.buildEtherPkt(payload, peer)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
assert.NotEmpty(t, pkt)
|
||||||
|
|
||||||
|
actualPkt := gopacket.NewPacket(pkt, layers.LayerTypeEthernet, gopacket.DecodeOptions{
|
||||||
|
NoCopy: true,
|
||||||
|
})
|
||||||
|
require.NotNil(t, actualPkt)
|
||||||
|
|
||||||
|
wantTypes := []gopacket.LayerType{
|
||||||
|
layers.LayerTypeEthernet,
|
||||||
|
layers.LayerTypeIPv4,
|
||||||
|
layers.LayerTypeUDP,
|
||||||
|
layers.LayerTypeDHCPv4,
|
||||||
|
}
|
||||||
|
actualLayers := actualPkt.Layers()
|
||||||
|
require.Len(t, actualLayers, len(wantTypes))
|
||||||
|
|
||||||
|
for i, wantType := range wantTypes {
|
||||||
|
layer := actualLayers[i]
|
||||||
|
require.NotNil(t, layer)
|
||||||
|
|
||||||
|
assert.Equal(t, wantType, layer.LayerType())
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("bad_payload", func(t *testing.T) {
|
||||||
|
// Create an invalid DHCP packet.
|
||||||
|
invalidPayload := []byte{1, 2, 3, 4}
|
||||||
|
pkt, err := conn.buildEtherPkt(invalidPayload, peer)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
assert.NotEmpty(t, pkt)
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("serializing_error", func(t *testing.T) {
|
||||||
|
// Create a peer with invalid MAC.
|
||||||
|
badPeer := &dhcpUnicastAddr{
|
||||||
|
Addr: raw.Addr{HardwareAddr: net.HardwareAddr{5, 4, 3, 2, 1}},
|
||||||
|
yiaddr: net.IP{4, 3, 2, 1},
|
||||||
|
}
|
||||||
|
|
||||||
|
pkt, err := conn.buildEtherPkt(payload, badPeer)
|
||||||
|
require.Error(t, err)
|
||||||
|
|
||||||
|
assert.Empty(t, pkt)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestV4Server_Send(t *testing.T) {
|
||||||
|
s := &v4Server{}
|
||||||
|
|
||||||
|
var (
|
||||||
|
defaultIP = net.IP{99, 99, 99, 99}
|
||||||
|
knownIP = net.IP{4, 2, 4, 2}
|
||||||
|
knownMAC = net.HardwareAddr{6, 5, 4, 3, 2, 1}
|
||||||
|
)
|
||||||
|
|
||||||
|
defaultPeer := &net.UDPAddr{
|
||||||
|
IP: defaultIP,
|
||||||
|
// Use neither client nor server port to check it actually
|
||||||
|
// changed.
|
||||||
|
Port: dhcpv4.ClientPort + dhcpv4.ServerPort,
|
||||||
|
}
|
||||||
|
defaultResp := &dhcpv4.DHCPv4{}
|
||||||
|
|
||||||
|
testCases := []struct {
|
||||||
|
want net.Addr
|
||||||
|
req *dhcpv4.DHCPv4
|
||||||
|
resp *dhcpv4.DHCPv4
|
||||||
|
name string
|
||||||
|
}{{
|
||||||
|
name: "giaddr",
|
||||||
|
req: &dhcpv4.DHCPv4{GatewayIPAddr: knownIP},
|
||||||
|
resp: defaultResp,
|
||||||
|
want: &net.UDPAddr{
|
||||||
|
IP: knownIP,
|
||||||
|
Port: dhcpv4.ServerPort,
|
||||||
|
},
|
||||||
|
}, {
|
||||||
|
name: "nak",
|
||||||
|
req: &dhcpv4.DHCPv4{},
|
||||||
|
resp: &dhcpv4.DHCPv4{
|
||||||
|
Options: dhcpv4.OptionsFromList(
|
||||||
|
dhcpv4.OptMessageType(dhcpv4.MessageTypeNak),
|
||||||
|
),
|
||||||
|
},
|
||||||
|
want: defaultPeer,
|
||||||
|
}, {
|
||||||
|
name: "ciaddr",
|
||||||
|
req: &dhcpv4.DHCPv4{ClientIPAddr: knownIP},
|
||||||
|
resp: &dhcpv4.DHCPv4{},
|
||||||
|
want: &net.UDPAddr{
|
||||||
|
IP: knownIP,
|
||||||
|
Port: dhcpv4.ClientPort,
|
||||||
|
},
|
||||||
|
}, {
|
||||||
|
name: "chaddr",
|
||||||
|
req: &dhcpv4.DHCPv4{ClientHWAddr: knownMAC},
|
||||||
|
resp: &dhcpv4.DHCPv4{YourIPAddr: knownIP},
|
||||||
|
want: &dhcpUnicastAddr{
|
||||||
|
Addr: raw.Addr{HardwareAddr: knownMAC},
|
||||||
|
yiaddr: knownIP,
|
||||||
|
},
|
||||||
|
}, {
|
||||||
|
name: "who_are_you",
|
||||||
|
req: &dhcpv4.DHCPv4{},
|
||||||
|
resp: &dhcpv4.DHCPv4{},
|
||||||
|
want: defaultPeer,
|
||||||
|
}}
|
||||||
|
|
||||||
|
for _, tc := range testCases {
|
||||||
|
t.Run(tc.name, func(t *testing.T) {
|
||||||
|
conn := &fakePacketConn{
|
||||||
|
writeTo: func(_ []byte, addr net.Addr) (_ int, _ error) {
|
||||||
|
assert.Equal(t, tc.want, addr)
|
||||||
|
|
||||||
|
return 0, nil
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
s.send(cloneUDPAddr(defaultPeer), conn, tc.req, tc.resp)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
t.Run("giaddr_nak", func(t *testing.T) {
|
||||||
|
req := &dhcpv4.DHCPv4{
|
||||||
|
GatewayIPAddr: knownIP,
|
||||||
|
}
|
||||||
|
// Ensure the request is for unicast.
|
||||||
|
req.SetUnicast()
|
||||||
|
resp := &dhcpv4.DHCPv4{
|
||||||
|
Options: dhcpv4.OptionsFromList(
|
||||||
|
dhcpv4.OptMessageType(dhcpv4.MessageTypeNak),
|
||||||
|
),
|
||||||
|
}
|
||||||
|
want := &net.UDPAddr{
|
||||||
|
IP: req.GatewayIPAddr,
|
||||||
|
Port: dhcpv4.ServerPort,
|
||||||
|
}
|
||||||
|
|
||||||
|
conn := &fakePacketConn{
|
||||||
|
writeTo: func(_ []byte, addr net.Addr) (n int, err error) {
|
||||||
|
assert.Equal(t, want, addr)
|
||||||
|
|
||||||
|
return 0, nil
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
s.send(cloneUDPAddr(defaultPeer), conn, req, resp)
|
||||||
|
assert.True(t, resp.IsBroadcast())
|
||||||
|
})
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
//go:build darwin || freebsd || linux || openbsd
|
//go:build freebsd || linux || openbsd
|
||||||
|
|
||||||
package dhcpd
|
package dhcpd
|
||||||
|
|
||||||
@@ -9,6 +9,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/AdguardTeam/golibs/errors"
|
"github.com/AdguardTeam/golibs/errors"
|
||||||
|
"github.com/AdguardTeam/golibs/log"
|
||||||
"github.com/AdguardTeam/golibs/netutil"
|
"github.com/AdguardTeam/golibs/netutil"
|
||||||
"github.com/google/gopacket"
|
"github.com/google/gopacket"
|
||||||
"github.com/google/gopacket/layers"
|
"github.com/google/gopacket/layers"
|
||||||
@@ -238,3 +239,53 @@ func (c *dhcpConn) buildEtherPkt(payload []byte, peer *dhcpUnicastAddr) (pkt []b
|
|||||||
|
|
||||||
return buf.Bytes(), nil
|
return buf.Bytes(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// send writes resp for peer to conn considering the req's parameters according
|
||||||
|
// to RFC-2131.
|
||||||
|
//
|
||||||
|
// See https://datatracker.ietf.org/doc/html/rfc2131#section-4.1.
|
||||||
|
func (s *v4Server) send(peer net.Addr, conn net.PacketConn, req, resp *dhcpv4.DHCPv4) {
|
||||||
|
switch giaddr, ciaddr, mtype := req.GatewayIPAddr, req.ClientIPAddr, resp.MessageType(); {
|
||||||
|
case giaddr != nil && !giaddr.IsUnspecified():
|
||||||
|
// Send any return messages to the server port on the BOOTP
|
||||||
|
// relay agent whose address appears in giaddr.
|
||||||
|
peer = &net.UDPAddr{
|
||||||
|
IP: giaddr,
|
||||||
|
Port: dhcpv4.ServerPort,
|
||||||
|
}
|
||||||
|
if mtype == dhcpv4.MessageTypeNak {
|
||||||
|
// Set the broadcast bit in the DHCPNAK, so that the relay agent
|
||||||
|
// broadcasts it to the client, because the client may not have
|
||||||
|
// a correct network address or subnet mask, and the client may not
|
||||||
|
// be answering ARP requests.
|
||||||
|
resp.SetBroadcast()
|
||||||
|
}
|
||||||
|
case mtype == dhcpv4.MessageTypeNak:
|
||||||
|
// Broadcast any DHCPNAK messages to 0xffffffff.
|
||||||
|
case ciaddr != nil && !ciaddr.IsUnspecified():
|
||||||
|
// Unicast DHCPOFFER and DHCPACK messages to the address in
|
||||||
|
// ciaddr.
|
||||||
|
peer = &net.UDPAddr{
|
||||||
|
IP: ciaddr,
|
||||||
|
Port: dhcpv4.ClientPort,
|
||||||
|
}
|
||||||
|
case !req.IsBroadcast() && req.ClientHWAddr != nil:
|
||||||
|
// Unicast DHCPOFFER and DHCPACK messages to the client's
|
||||||
|
// hardware address and yiaddr.
|
||||||
|
peer = &dhcpUnicastAddr{
|
||||||
|
Addr: packet.Addr{HardwareAddr: req.ClientHWAddr},
|
||||||
|
yiaddr: resp.YourIPAddr,
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
// Go on since peer is already set to broadcast.
|
||||||
|
}
|
||||||
|
|
||||||
|
pktData := resp.ToBytes()
|
||||||
|
|
||||||
|
log.Debug("dhcpv4: sending %d bytes to %s: %s", len(pktData), peer, resp.Summary())
|
||||||
|
|
||||||
|
_, err := conn.WriteTo(pktData, peer)
|
||||||
|
if err != nil {
|
||||||
|
log.Error("dhcpv4: conn.Write to %s failed: %s", peer, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
//go:build darwin || freebsd || linux || openbsd
|
//go:build freebsd || linux || openbsd
|
||||||
|
|
||||||
package dhcpd
|
package dhcpd
|
||||||
|
|
||||||
@@ -110,3 +110,108 @@ func TestBuildEtherPkt(t *testing.T) {
|
|||||||
assert.Empty(t, pkt)
|
assert.Empty(t, pkt)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestV4Server_Send(t *testing.T) {
|
||||||
|
s := &v4Server{}
|
||||||
|
|
||||||
|
var (
|
||||||
|
defaultIP = net.IP{99, 99, 99, 99}
|
||||||
|
knownIP = net.IP{4, 2, 4, 2}
|
||||||
|
knownMAC = net.HardwareAddr{6, 5, 4, 3, 2, 1}
|
||||||
|
)
|
||||||
|
|
||||||
|
defaultPeer := &net.UDPAddr{
|
||||||
|
IP: defaultIP,
|
||||||
|
// Use neither client nor server port to check it actually
|
||||||
|
// changed.
|
||||||
|
Port: dhcpv4.ClientPort + dhcpv4.ServerPort,
|
||||||
|
}
|
||||||
|
defaultResp := &dhcpv4.DHCPv4{}
|
||||||
|
|
||||||
|
testCases := []struct {
|
||||||
|
want net.Addr
|
||||||
|
req *dhcpv4.DHCPv4
|
||||||
|
resp *dhcpv4.DHCPv4
|
||||||
|
name string
|
||||||
|
}{{
|
||||||
|
name: "giaddr",
|
||||||
|
req: &dhcpv4.DHCPv4{GatewayIPAddr: knownIP},
|
||||||
|
resp: defaultResp,
|
||||||
|
want: &net.UDPAddr{
|
||||||
|
IP: knownIP,
|
||||||
|
Port: dhcpv4.ServerPort,
|
||||||
|
},
|
||||||
|
}, {
|
||||||
|
name: "nak",
|
||||||
|
req: &dhcpv4.DHCPv4{},
|
||||||
|
resp: &dhcpv4.DHCPv4{
|
||||||
|
Options: dhcpv4.OptionsFromList(
|
||||||
|
dhcpv4.OptMessageType(dhcpv4.MessageTypeNak),
|
||||||
|
),
|
||||||
|
},
|
||||||
|
want: defaultPeer,
|
||||||
|
}, {
|
||||||
|
name: "ciaddr",
|
||||||
|
req: &dhcpv4.DHCPv4{ClientIPAddr: knownIP},
|
||||||
|
resp: &dhcpv4.DHCPv4{},
|
||||||
|
want: &net.UDPAddr{
|
||||||
|
IP: knownIP,
|
||||||
|
Port: dhcpv4.ClientPort,
|
||||||
|
},
|
||||||
|
}, {
|
||||||
|
name: "chaddr",
|
||||||
|
req: &dhcpv4.DHCPv4{ClientHWAddr: knownMAC},
|
||||||
|
resp: &dhcpv4.DHCPv4{YourIPAddr: knownIP},
|
||||||
|
want: &dhcpUnicastAddr{
|
||||||
|
Addr: packet.Addr{HardwareAddr: knownMAC},
|
||||||
|
yiaddr: knownIP,
|
||||||
|
},
|
||||||
|
}, {
|
||||||
|
name: "who_are_you",
|
||||||
|
req: &dhcpv4.DHCPv4{},
|
||||||
|
resp: &dhcpv4.DHCPv4{},
|
||||||
|
want: defaultPeer,
|
||||||
|
}}
|
||||||
|
|
||||||
|
for _, tc := range testCases {
|
||||||
|
t.Run(tc.name, func(t *testing.T) {
|
||||||
|
conn := &fakePacketConn{
|
||||||
|
writeTo: func(_ []byte, addr net.Addr) (_ int, _ error) {
|
||||||
|
assert.Equal(t, tc.want, addr)
|
||||||
|
|
||||||
|
return 0, nil
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
s.send(cloneUDPAddr(defaultPeer), conn, tc.req, tc.resp)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
t.Run("giaddr_nak", func(t *testing.T) {
|
||||||
|
req := &dhcpv4.DHCPv4{
|
||||||
|
GatewayIPAddr: knownIP,
|
||||||
|
}
|
||||||
|
// Ensure the request is for unicast.
|
||||||
|
req.SetUnicast()
|
||||||
|
resp := &dhcpv4.DHCPv4{
|
||||||
|
Options: dhcpv4.OptionsFromList(
|
||||||
|
dhcpv4.OptMessageType(dhcpv4.MessageTypeNak),
|
||||||
|
),
|
||||||
|
}
|
||||||
|
want := &net.UDPAddr{
|
||||||
|
IP: req.GatewayIPAddr,
|
||||||
|
Port: dhcpv4.ServerPort,
|
||||||
|
}
|
||||||
|
|
||||||
|
conn := &fakePacketConn{
|
||||||
|
writeTo: func(_ []byte, addr net.Addr) (n int, err error) {
|
||||||
|
assert.Equal(t, want, addr)
|
||||||
|
|
||||||
|
return 0, nil
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
s.send(cloneUDPAddr(defaultPeer), conn, req, resp)
|
||||||
|
assert.True(t, resp.IsBroadcast())
|
||||||
|
})
|
||||||
|
}
|
||||||
@@ -5,43 +5,34 @@ package dhcpd
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net"
|
|
||||||
"net/netip"
|
|
||||||
"os"
|
"os"
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/AdguardTeam/golibs/errors"
|
"github.com/AdguardTeam/golibs/errors"
|
||||||
"github.com/AdguardTeam/golibs/log"
|
"github.com/AdguardTeam/golibs/log"
|
||||||
"github.com/google/renameio/maybe"
|
"github.com/google/renameio/maybe"
|
||||||
|
"golang.org/x/exp/slices"
|
||||||
)
|
)
|
||||||
|
|
||||||
const dbFilename = "leases.db"
|
const (
|
||||||
|
// dataFilename contains saved leases.
|
||||||
|
dataFilename = "leases.json"
|
||||||
|
|
||||||
type leaseJSON struct {
|
// dataVersion is the current version of the stored DHCP leases structure.
|
||||||
HWAddr []byte `json:"mac"`
|
dataVersion = 1
|
||||||
IP []byte `json:"ip"`
|
)
|
||||||
Hostname string `json:"host"`
|
|
||||||
Expiry int64 `json:"exp"`
|
// dataLeases is the structure of the stored DHCP leases.
|
||||||
|
type dataLeases struct {
|
||||||
|
// Version is the current version of the structure.
|
||||||
|
Version int `json:"version"`
|
||||||
|
|
||||||
|
// Leases is the list containing stored DHCP leases.
|
||||||
|
Leases []*Lease `json:"leases"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func normalizeIP(ip net.IP) net.IP {
|
// dbLoad loads stored leases.
|
||||||
ip4 := ip.To4()
|
|
||||||
if ip4 != nil {
|
|
||||||
return ip4
|
|
||||||
}
|
|
||||||
return ip
|
|
||||||
}
|
|
||||||
|
|
||||||
// Load lease table from DB
|
|
||||||
//
|
|
||||||
// TODO(s.chzhen): Decrease complexity.
|
|
||||||
func (s *server) dbLoad() (err error) {
|
func (s *server) dbLoad() (err error) {
|
||||||
dynLeases := []*Lease{}
|
data, err := os.ReadFile(s.conf.dbFilePath)
|
||||||
staticLeases := []*Lease{}
|
|
||||||
v6StaticLeases := []*Lease{}
|
|
||||||
v6DynLeases := []*Lease{}
|
|
||||||
|
|
||||||
data, err := os.ReadFile(s.conf.DBFilePath)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if !errors.Is(err, os.ErrNotExist) {
|
if !errors.Is(err, os.ErrNotExist) {
|
||||||
return fmt.Errorf("reading db: %w", err)
|
return fmt.Errorf("reading db: %w", err)
|
||||||
@@ -50,51 +41,30 @@ func (s *server) dbLoad() (err error) {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
obj := []leaseJSON{}
|
dl := &dataLeases{}
|
||||||
err = json.Unmarshal(data, &obj)
|
err = json.Unmarshal(data, dl)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("decoding db: %w", err)
|
return fmt.Errorf("decoding db: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
numLeases := len(obj)
|
leases := dl.Leases
|
||||||
for i := range obj {
|
|
||||||
obj[i].IP = normalizeIP(obj[i].IP)
|
|
||||||
|
|
||||||
ip, ok := netip.AddrFromSlice(obj[i].IP)
|
leases4 := []*Lease{}
|
||||||
if !ok {
|
leases6 := []*Lease{}
|
||||||
log.Info("dhcp: invalid IP: %s", obj[i].IP)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
lease := Lease{
|
for _, l := range leases {
|
||||||
HWAddr: obj[i].HWAddr,
|
if l.IP.Is4() {
|
||||||
IP: ip,
|
leases4 = append(leases4, l)
|
||||||
Hostname: obj[i].Hostname,
|
|
||||||
Expiry: time.Unix(obj[i].Expiry, 0),
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(obj[i].IP) == 16 {
|
|
||||||
if obj[i].Expiry == leaseExpireStatic {
|
|
||||||
v6StaticLeases = append(v6StaticLeases, &lease)
|
|
||||||
} else {
|
|
||||||
v6DynLeases = append(v6DynLeases, &lease)
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if obj[i].Expiry == leaseExpireStatic {
|
leases6 = append(leases6, l)
|
||||||
staticLeases = append(staticLeases, &lease)
|
|
||||||
} else {
|
|
||||||
dynLeases = append(dynLeases, &lease)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
leases4 := normalizeLeases(staticLeases, dynLeases)
|
|
||||||
err = s.srv4.ResetLeases(leases4)
|
err = s.srv4.ResetLeases(leases4)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("resetting dhcpv4 leases: %w", err)
|
return fmt.Errorf("resetting dhcpv4 leases: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
leases6 := normalizeLeases(v6StaticLeases, v6DynLeases)
|
|
||||||
if s.srv6 != nil {
|
if s.srv6 != nil {
|
||||||
err = s.srv6.ResetLeases(leases6)
|
err = s.srv6.ResetLeases(leases6)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -103,90 +73,54 @@ func (s *server) dbLoad() (err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
log.Info("dhcp: loaded leases v4:%d v6:%d total-read:%d from DB",
|
log.Info("dhcp: loaded leases v4:%d v6:%d total-read:%d from DB",
|
||||||
len(leases4), len(leases6), numLeases)
|
len(leases4), len(leases6), len(leases))
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Skip duplicate leases
|
// dbStore stores DHCP leases.
|
||||||
// Static leases have a priority over dynamic leases
|
|
||||||
func normalizeLeases(staticLeases, dynLeases []*Lease) []*Lease {
|
|
||||||
leases := []*Lease{}
|
|
||||||
index := map[string]int{}
|
|
||||||
|
|
||||||
for i, lease := range staticLeases {
|
|
||||||
_, ok := index[lease.HWAddr.String()]
|
|
||||||
if ok {
|
|
||||||
continue // skip the lease with the same HW address
|
|
||||||
}
|
|
||||||
index[lease.HWAddr.String()] = i
|
|
||||||
leases = append(leases, lease)
|
|
||||||
}
|
|
||||||
|
|
||||||
for i, lease := range dynLeases {
|
|
||||||
_, ok := index[lease.HWAddr.String()]
|
|
||||||
if ok {
|
|
||||||
continue // skip the lease with the same HW address
|
|
||||||
}
|
|
||||||
index[lease.HWAddr.String()] = i
|
|
||||||
leases = append(leases, lease)
|
|
||||||
}
|
|
||||||
|
|
||||||
return leases
|
|
||||||
}
|
|
||||||
|
|
||||||
// Store lease table in DB
|
|
||||||
func (s *server) dbStore() (err error) {
|
func (s *server) dbStore() (err error) {
|
||||||
// Use an empty slice here as opposed to nil so that it doesn't write
|
// Use an empty slice here as opposed to nil so that it doesn't write
|
||||||
// "null" into the database file if leases are empty.
|
// "null" into the database file if leases are empty.
|
||||||
leases := []leaseJSON{}
|
leases := []*Lease{}
|
||||||
|
|
||||||
leases4 := s.srv4.getLeasesRef()
|
leases4 := s.srv4.getLeasesRef()
|
||||||
for _, l := range leases4 {
|
leases = append(leases, leases4...)
|
||||||
if l.Expiry.Unix() == 0 {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
lease := leaseJSON{
|
|
||||||
HWAddr: l.HWAddr,
|
|
||||||
IP: l.IP.AsSlice(),
|
|
||||||
Hostname: l.Hostname,
|
|
||||||
Expiry: l.Expiry.Unix(),
|
|
||||||
}
|
|
||||||
|
|
||||||
leases = append(leases, lease)
|
|
||||||
}
|
|
||||||
|
|
||||||
if s.srv6 != nil {
|
if s.srv6 != nil {
|
||||||
leases6 := s.srv6.getLeasesRef()
|
leases6 := s.srv6.getLeasesRef()
|
||||||
for _, l := range leases6 {
|
leases = append(leases, leases6...)
|
||||||
if l.Expiry.Unix() == 0 {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
lease := leaseJSON{
|
|
||||||
HWAddr: l.HWAddr,
|
|
||||||
IP: l.IP.AsSlice(),
|
|
||||||
Hostname: l.Hostname,
|
|
||||||
Expiry: l.Expiry.Unix(),
|
|
||||||
}
|
|
||||||
|
|
||||||
leases = append(leases, lease)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var data []byte
|
return writeDB(s.conf.dbFilePath, leases)
|
||||||
data, err = json.Marshal(leases)
|
}
|
||||||
|
|
||||||
|
// writeDB writes leases to file at path.
|
||||||
|
func writeDB(path string, leases []*Lease) (err error) {
|
||||||
|
defer func() { err = errors.Annotate(err, "writing db: %w") }()
|
||||||
|
|
||||||
|
slices.SortFunc(leases, func(a, b *Lease) bool {
|
||||||
|
return a.Hostname < b.Hostname
|
||||||
|
})
|
||||||
|
|
||||||
|
dl := &dataLeases{
|
||||||
|
Version: dataVersion,
|
||||||
|
Leases: leases,
|
||||||
|
}
|
||||||
|
|
||||||
|
buf, err := json.Marshal(dl)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("encoding db: %w", err)
|
// Don't wrap the error since it's informative enough as is.
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = maybe.WriteFile(s.conf.DBFilePath, data, 0o644)
|
err = maybe.WriteFile(path, buf, 0o644)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("writing db: %w", err)
|
// Don't wrap the error since it's informative enough as is.
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Info("dhcp: stored %d leases in db", len(leases))
|
log.Info("dhcp: stored %d leases in %q", len(leases), path)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,13 +15,6 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// leaseExpireStatic is used to define the Expiry field for static
|
|
||||||
// leases.
|
|
||||||
//
|
|
||||||
// TODO(e.burkov): Remove it when static leases determining mechanism
|
|
||||||
// will be improved.
|
|
||||||
leaseExpireStatic = 1
|
|
||||||
|
|
||||||
// DefaultDHCPLeaseTTL is the default time-to-live for leases.
|
// DefaultDHCPLeaseTTL is the default time-to-live for leases.
|
||||||
DefaultDHCPLeaseTTL = uint32(timeutil.Day / time.Second)
|
DefaultDHCPLeaseTTL = uint32(timeutil.Day / time.Second)
|
||||||
|
|
||||||
@@ -35,10 +28,10 @@ const (
|
|||||||
defaultBackoff time.Duration = 500 * time.Millisecond
|
defaultBackoff time.Duration = 500 * time.Millisecond
|
||||||
)
|
)
|
||||||
|
|
||||||
// Lease contains the necessary information about a DHCP lease
|
// Lease contains the necessary information about a DHCP lease. It's used in
|
||||||
|
// various places. So don't change it without good reason.
|
||||||
type Lease struct {
|
type Lease struct {
|
||||||
// Expiry is the expiration time of the lease. The unix timestamp value
|
// Expiry is the expiration time of the lease.
|
||||||
// of 1 means that this is a static lease.
|
|
||||||
Expiry time.Time `json:"expires"`
|
Expiry time.Time `json:"expires"`
|
||||||
|
|
||||||
// Hostname of the client.
|
// Hostname of the client.
|
||||||
@@ -51,6 +44,9 @@ type Lease struct {
|
|||||||
//
|
//
|
||||||
// TODO(a.garipov): Migrate leases.db.
|
// TODO(a.garipov): Migrate leases.db.
|
||||||
IP netip.Addr `json:"ip"`
|
IP netip.Addr `json:"ip"`
|
||||||
|
|
||||||
|
// IsStatic defines if the lease is static.
|
||||||
|
IsStatic bool `json:"static"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clone returns a deep copy of l.
|
// Clone returns a deep copy of l.
|
||||||
@@ -64,6 +60,7 @@ func (l *Lease) Clone() (clone *Lease) {
|
|||||||
Hostname: l.Hostname,
|
Hostname: l.Hostname,
|
||||||
HWAddr: slices.Clone(l.HWAddr),
|
HWAddr: slices.Clone(l.HWAddr),
|
||||||
IP: l.IP,
|
IP: l.IP,
|
||||||
|
IsStatic: l.IsStatic,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -84,17 +81,10 @@ func (l *Lease) IsBlocklisted() (ok bool) {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsStatic returns true if the lease is static.
|
|
||||||
//
|
|
||||||
// TODO(a.garipov): Just make it a boolean field.
|
|
||||||
func (l *Lease) IsStatic() (ok bool) {
|
|
||||||
return l != nil && l.Expiry.Unix() == leaseExpireStatic
|
|
||||||
}
|
|
||||||
|
|
||||||
// MarshalJSON implements the json.Marshaler interface for Lease.
|
// MarshalJSON implements the json.Marshaler interface for Lease.
|
||||||
func (l Lease) MarshalJSON() ([]byte, error) {
|
func (l Lease) MarshalJSON() ([]byte, error) {
|
||||||
var expiryStr string
|
var expiryStr string
|
||||||
if !l.IsStatic() {
|
if !l.IsStatic {
|
||||||
// The front-end is waiting for RFC 3999 format of the time
|
// The front-end is waiting for RFC 3999 format of the time
|
||||||
// value. It also shouldn't got an Expiry field for static
|
// value. It also shouldn't got an Expiry field for static
|
||||||
// leases.
|
// leases.
|
||||||
@@ -241,7 +231,7 @@ func Create(conf *ServerConfig) (s *server, err error) {
|
|||||||
|
|
||||||
LocalDomainName: conf.LocalDomainName,
|
LocalDomainName: conf.LocalDomainName,
|
||||||
|
|
||||||
DBFilePath: filepath.Join(conf.WorkDir, dbFilename),
|
dbFilePath: filepath.Join(conf.DataDir, dataFilename),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -282,6 +272,13 @@ func Create(conf *ServerConfig) (s *server, err error) {
|
|||||||
return nil, fmt.Errorf("neither dhcpv4 nor dhcpv6 srv is configured")
|
return nil, fmt.Errorf("neither dhcpv4 nor dhcpv6 srv is configured")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Migrate leases db if needed.
|
||||||
|
err = migrateDB(conf)
|
||||||
|
if err != nil {
|
||||||
|
// Don't wrap the error since it's informative enough as is.
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
// Don't delay database loading until the DHCP server is started,
|
// Don't delay database loading until the DHCP server is started,
|
||||||
// because we need static leases functionality available beforehand.
|
// because we need static leases functionality available beforehand.
|
||||||
err = s.dbLoad()
|
err = s.dbLoad()
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ package dhcpd
|
|||||||
import (
|
import (
|
||||||
"net"
|
"net"
|
||||||
"net/netip"
|
"net/netip"
|
||||||
"os"
|
"path/filepath"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -27,7 +27,7 @@ func TestDB(t *testing.T) {
|
|||||||
var err error
|
var err error
|
||||||
s := server{
|
s := server{
|
||||||
conf: &ServerConfig{
|
conf: &ServerConfig{
|
||||||
DBFilePath: dbFilename,
|
dbFilePath: filepath.Join(t.TempDir(), dataFilename),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,8 +67,6 @@ func TestDB(t *testing.T) {
|
|||||||
err = s.dbStore()
|
err = s.dbStore()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
testutil.CleanupAndRequireSuccess(t, func() (err error) { return os.Remove(dbFilename) })
|
|
||||||
|
|
||||||
err = s.srv4.ResetLeases(nil)
|
err = s.srv4.ResetLeases(nil)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
@@ -78,36 +76,13 @@ func TestDB(t *testing.T) {
|
|||||||
ll := s.srv4.GetLeases(LeasesAll)
|
ll := s.srv4.GetLeases(LeasesAll)
|
||||||
require.Len(t, ll, len(leases))
|
require.Len(t, ll, len(leases))
|
||||||
|
|
||||||
assert.Equal(t, leases[1].HWAddr, ll[0].HWAddr)
|
assert.Equal(t, leases[0].HWAddr, ll[0].HWAddr)
|
||||||
assert.Equal(t, leases[1].IP, ll[0].IP)
|
assert.Equal(t, leases[0].IP, ll[0].IP)
|
||||||
assert.True(t, ll[0].IsStatic())
|
assert.Equal(t, leases[0].Expiry.Unix(), ll[0].Expiry.Unix())
|
||||||
|
|
||||||
assert.Equal(t, leases[0].HWAddr, ll[1].HWAddr)
|
assert.Equal(t, leases[1].HWAddr, ll[1].HWAddr)
|
||||||
assert.Equal(t, leases[0].IP, ll[1].IP)
|
assert.Equal(t, leases[1].IP, ll[1].IP)
|
||||||
assert.Equal(t, leases[0].Expiry.Unix(), ll[1].Expiry.Unix())
|
assert.True(t, ll[1].IsStatic)
|
||||||
}
|
|
||||||
|
|
||||||
func TestNormalizeLeases(t *testing.T) {
|
|
||||||
dynLeases := []*Lease{{
|
|
||||||
HWAddr: net.HardwareAddr{1, 2, 3, 4},
|
|
||||||
}, {
|
|
||||||
HWAddr: net.HardwareAddr{1, 2, 3, 5},
|
|
||||||
}}
|
|
||||||
|
|
||||||
staticLeases := []*Lease{{
|
|
||||||
HWAddr: net.HardwareAddr{1, 2, 3, 4},
|
|
||||||
IP: netip.MustParseAddr("0.2.3.4"),
|
|
||||||
}, {
|
|
||||||
HWAddr: net.HardwareAddr{2, 2, 3, 4},
|
|
||||||
}}
|
|
||||||
|
|
||||||
leases := normalizeLeases(staticLeases, dynLeases)
|
|
||||||
require.Len(t, leases, 3)
|
|
||||||
|
|
||||||
assert.Equal(t, leases[0].HWAddr, dynLeases[0].HWAddr)
|
|
||||||
assert.Equal(t, leases[0].IP, staticLeases[0].IP)
|
|
||||||
assert.Equal(t, leases[1].HWAddr, staticLeases[1].HWAddr)
|
|
||||||
assert.Equal(t, leases[2].HWAddr, dynLeases[1].HWAddr)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestV4Server_badRange(t *testing.T) {
|
func TestV4Server_badRange(t *testing.T) {
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"net/netip"
|
"net/netip"
|
||||||
"os"
|
"os"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/AdguardTeam/AdGuardHome/internal/aghalg"
|
"github.com/AdguardTeam/AdGuardHome/internal/aghalg"
|
||||||
"github.com/AdguardTeam/AdGuardHome/internal/aghhttp"
|
"github.com/AdguardTeam/AdGuardHome/internal/aghhttp"
|
||||||
@@ -57,12 +58,77 @@ func v6JSONToServerConf(j *v6ServerConfJSON) V6ServerConf {
|
|||||||
|
|
||||||
// dhcpStatusResponse is the response for /control/dhcp/status endpoint.
|
// dhcpStatusResponse is the response for /control/dhcp/status endpoint.
|
||||||
type dhcpStatusResponse struct {
|
type dhcpStatusResponse struct {
|
||||||
IfaceName string `json:"interface_name"`
|
IfaceName string `json:"interface_name"`
|
||||||
V4 V4ServerConf `json:"v4"`
|
V4 V4ServerConf `json:"v4"`
|
||||||
V6 V6ServerConf `json:"v6"`
|
V6 V6ServerConf `json:"v6"`
|
||||||
Leases []*Lease `json:"leases"`
|
Leases []*leaseDynamic `json:"leases"`
|
||||||
StaticLeases []*Lease `json:"static_leases"`
|
StaticLeases []*leaseStatic `json:"static_leases"`
|
||||||
Enabled bool `json:"enabled"`
|
Enabled bool `json:"enabled"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// leaseStatic is the JSON form of static DHCP lease.
|
||||||
|
type leaseStatic struct {
|
||||||
|
HWAddr string `json:"mac"`
|
||||||
|
IP netip.Addr `json:"ip"`
|
||||||
|
Hostname string `json:"hostname"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// leasesToStatic converts list of leases to their JSON form.
|
||||||
|
func leasesToStatic(leases []*Lease) (static []*leaseStatic) {
|
||||||
|
static = make([]*leaseStatic, len(leases))
|
||||||
|
|
||||||
|
for i, l := range leases {
|
||||||
|
static[i] = &leaseStatic{
|
||||||
|
HWAddr: l.HWAddr.String(),
|
||||||
|
IP: l.IP,
|
||||||
|
Hostname: l.Hostname,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return static
|
||||||
|
}
|
||||||
|
|
||||||
|
// toLease converts leaseStatic to Lease or returns error.
|
||||||
|
func (l *leaseStatic) toLease() (lease *Lease, err error) {
|
||||||
|
addr, err := net.ParseMAC(l.HWAddr)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("couldn't parse MAC address: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return &Lease{
|
||||||
|
HWAddr: addr,
|
||||||
|
IP: l.IP,
|
||||||
|
Hostname: l.Hostname,
|
||||||
|
IsStatic: true,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// leaseDynamic is the JSON form of dynamic DHCP lease.
|
||||||
|
type leaseDynamic struct {
|
||||||
|
HWAddr string `json:"mac"`
|
||||||
|
IP netip.Addr `json:"ip"`
|
||||||
|
Hostname string `json:"hostname"`
|
||||||
|
Expiry string `json:"expires"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// leasesToDynamic converts list of leases to their JSON form.
|
||||||
|
func leasesToDynamic(leases []*Lease) (dynamic []*leaseDynamic) {
|
||||||
|
dynamic = make([]*leaseDynamic, len(leases))
|
||||||
|
|
||||||
|
for i, l := range leases {
|
||||||
|
dynamic[i] = &leaseDynamic{
|
||||||
|
HWAddr: l.HWAddr.String(),
|
||||||
|
IP: l.IP,
|
||||||
|
Hostname: l.Hostname,
|
||||||
|
// The front-end is waiting for RFC 3999 format of the time
|
||||||
|
// value.
|
||||||
|
//
|
||||||
|
// See https://github.com/AdguardTeam/AdGuardHome/issues/2692.
|
||||||
|
Expiry: l.Expiry.Format(time.RFC3339),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return dynamic
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *server) handleDHCPStatus(w http.ResponseWriter, r *http.Request) {
|
func (s *server) handleDHCPStatus(w http.ResponseWriter, r *http.Request) {
|
||||||
@@ -76,8 +142,8 @@ func (s *server) handleDHCPStatus(w http.ResponseWriter, r *http.Request) {
|
|||||||
s.srv4.WriteDiskConfig4(&status.V4)
|
s.srv4.WriteDiskConfig4(&status.V4)
|
||||||
s.srv6.WriteDiskConfig6(&status.V6)
|
s.srv6.WriteDiskConfig6(&status.V6)
|
||||||
|
|
||||||
status.Leases = s.Leases(LeasesDynamic)
|
status.Leases = leasesToDynamic(s.Leases(LeasesDynamic))
|
||||||
status.StaticLeases = s.Leases(LeasesStatic)
|
status.StaticLeases = leasesToStatic(s.Leases(LeasesStatic))
|
||||||
|
|
||||||
_ = aghhttp.WriteJSONResponse(w, r, status)
|
_ = aghhttp.WriteJSONResponse(w, r, status)
|
||||||
}
|
}
|
||||||
@@ -284,8 +350,10 @@ type netInterfaceJSON struct {
|
|||||||
Addrs6 []netip.Addr `json:"ipv6_addresses"`
|
Addrs6 []netip.Addr `json:"ipv6_addresses"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// handleDHCPInterfaces is the handler for the GET /control/dhcp/interfaces HTTP
|
||||||
|
// API.
|
||||||
func (s *server) handleDHCPInterfaces(w http.ResponseWriter, r *http.Request) {
|
func (s *server) handleDHCPInterfaces(w http.ResponseWriter, r *http.Request) {
|
||||||
response := map[string]netInterfaceJSON{}
|
resp := map[string]netInterfaceJSON{}
|
||||||
|
|
||||||
ifaces, err := net.Interfaces()
|
ifaces, err := net.Interfaces()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -358,20 +426,11 @@ func (s *server) handleDHCPInterfaces(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
if len(jsonIface.Addrs4)+len(jsonIface.Addrs6) != 0 {
|
if len(jsonIface.Addrs4)+len(jsonIface.Addrs6) != 0 {
|
||||||
jsonIface.GatewayIP = aghnet.GatewayIP(iface.Name)
|
jsonIface.GatewayIP = aghnet.GatewayIP(iface.Name)
|
||||||
response[iface.Name] = jsonIface
|
resp[iface.Name] = jsonIface
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
err = json.NewEncoder(w).Encode(response)
|
_ = aghhttp.WriteJSONResponse(w, r, resp)
|
||||||
if err != nil {
|
|
||||||
aghhttp.Error(
|
|
||||||
r,
|
|
||||||
w,
|
|
||||||
http.StatusInternalServerError,
|
|
||||||
"Failed to marshal json with available interfaces: %s",
|
|
||||||
err,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// dhcpSearchOtherResult contains information about other DHCP server for
|
// dhcpSearchOtherResult contains information about other DHCP server for
|
||||||
@@ -488,7 +547,7 @@ func setOtherDHCPResult(ifaceName string, result *dhcpSearchResult) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *server) handleDHCPAddStaticLease(w http.ResponseWriter, r *http.Request) {
|
func (s *server) handleDHCPAddStaticLease(w http.ResponseWriter, r *http.Request) {
|
||||||
l := &Lease{}
|
l := &leaseStatic{}
|
||||||
err := json.NewDecoder(r.Body).Decode(l)
|
err := json.NewDecoder(r.Body).Decode(l)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
aghhttp.Error(r, w, http.StatusBadRequest, "json.Decode: %s", err)
|
aghhttp.Error(r, w, http.StatusBadRequest, "json.Decode: %s", err)
|
||||||
@@ -511,7 +570,14 @@ func (s *server) handleDHCPAddStaticLease(w http.ResponseWriter, r *http.Request
|
|||||||
srv = s.srv6
|
srv = s.srv6
|
||||||
}
|
}
|
||||||
|
|
||||||
err = srv.AddStaticLease(l)
|
lease, err := l.toLease()
|
||||||
|
if err != nil {
|
||||||
|
aghhttp.Error(r, w, http.StatusBadRequest, "parsing: %s", err)
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
err = srv.AddStaticLease(lease)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
aghhttp.Error(r, w, http.StatusBadRequest, "%s", err)
|
aghhttp.Error(r, w, http.StatusBadRequest, "%s", err)
|
||||||
|
|
||||||
@@ -520,7 +586,7 @@ func (s *server) handleDHCPAddStaticLease(w http.ResponseWriter, r *http.Request
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *server) handleDHCPRemoveStaticLease(w http.ResponseWriter, r *http.Request) {
|
func (s *server) handleDHCPRemoveStaticLease(w http.ResponseWriter, r *http.Request) {
|
||||||
l := &Lease{}
|
l := &leaseStatic{}
|
||||||
err := json.NewDecoder(r.Body).Decode(l)
|
err := json.NewDecoder(r.Body).Decode(l)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
aghhttp.Error(r, w, http.StatusBadRequest, "json.Decode: %s", err)
|
aghhttp.Error(r, w, http.StatusBadRequest, "json.Decode: %s", err)
|
||||||
@@ -543,7 +609,14 @@ func (s *server) handleDHCPRemoveStaticLease(w http.ResponseWriter, r *http.Requ
|
|||||||
srv = s.srv6
|
srv = s.srv6
|
||||||
}
|
}
|
||||||
|
|
||||||
err = srv.RemoveStaticLease(l)
|
lease, err := l.toLease()
|
||||||
|
if err != nil {
|
||||||
|
aghhttp.Error(r, w, http.StatusBadRequest, "parsing: %s", err)
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
err = srv.RemoveStaticLease(lease)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
aghhttp.Error(r, w, http.StatusBadRequest, "%s", err)
|
aghhttp.Error(r, w, http.StatusBadRequest, "%s", err)
|
||||||
|
|
||||||
@@ -559,7 +632,7 @@ func (s *server) handleReset(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err = os.Remove(s.conf.DBFilePath)
|
err = os.Remove(s.conf.dbFilePath)
|
||||||
if err != nil && !errors.Is(err, os.ErrNotExist) {
|
if err != nil && !errors.Is(err, os.ErrNotExist) {
|
||||||
log.Error("dhcp: removing db: %s", err)
|
log.Error("dhcp: removing db: %s", err)
|
||||||
}
|
}
|
||||||
@@ -571,8 +644,8 @@ func (s *server) handleReset(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
LocalDomainName: s.conf.LocalDomainName,
|
LocalDomainName: s.conf.LocalDomainName,
|
||||||
|
|
||||||
WorkDir: s.conf.WorkDir,
|
DataDir: s.conf.DataDir,
|
||||||
DBFilePath: s.conf.DBFilePath,
|
dbFilePath: s.conf.dbFilePath,
|
||||||
}
|
}
|
||||||
|
|
||||||
v4conf := &V4ServerConf{
|
v4conf := &V4ServerConf{
|
||||||
|
|||||||
@@ -5,35 +5,33 @@ package dhcpd
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"net"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
"net/netip"
|
"net/netip"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestServer_handleDHCPStatus(t *testing.T) {
|
func TestServer_handleDHCPStatus(t *testing.T) {
|
||||||
const staticName = "static-client"
|
const (
|
||||||
|
staticName = "static-client"
|
||||||
|
staticMAC = "aa:aa:aa:aa:aa:aa"
|
||||||
|
)
|
||||||
|
|
||||||
staticIP := netip.MustParseAddr("192.168.10.10")
|
staticIP := netip.MustParseAddr("192.168.10.10")
|
||||||
staticMAC := net.HardwareAddr{0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA}
|
|
||||||
|
|
||||||
staticLease := &Lease{
|
staticLease := &leaseStatic{
|
||||||
Expiry: time.Unix(leaseExpireStatic, 0),
|
|
||||||
Hostname: staticName,
|
|
||||||
HWAddr: staticMAC,
|
HWAddr: staticMAC,
|
||||||
IP: staticIP,
|
IP: staticIP,
|
||||||
|
Hostname: staticName,
|
||||||
}
|
}
|
||||||
|
|
||||||
s, err := Create(&ServerConfig{
|
s, err := Create(&ServerConfig{
|
||||||
Enabled: true,
|
Enabled: true,
|
||||||
Conf4: *defaultV4ServerConf(),
|
Conf4: *defaultV4ServerConf(),
|
||||||
WorkDir: t.TempDir(),
|
DataDir: t.TempDir(),
|
||||||
DBFilePath: dbFilename,
|
|
||||||
ConfigModified: func() {},
|
ConfigModified: func() {},
|
||||||
})
|
})
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
@@ -65,8 +63,8 @@ func TestServer_handleDHCPStatus(t *testing.T) {
|
|||||||
resp := &dhcpStatusResponse{
|
resp := &dhcpStatusResponse{
|
||||||
V4: *conf4,
|
V4: *conf4,
|
||||||
V6: V6ServerConf{},
|
V6: V6ServerConf{},
|
||||||
Leases: []*Lease{},
|
Leases: []*leaseDynamic{},
|
||||||
StaticLeases: []*Lease{},
|
StaticLeases: []*leaseStatic{},
|
||||||
Enabled: true,
|
Enabled: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -95,7 +93,7 @@ func TestServer_handleDHCPStatus(t *testing.T) {
|
|||||||
assert.Equal(t, http.StatusOK, w.Code)
|
assert.Equal(t, http.StatusOK, w.Code)
|
||||||
|
|
||||||
resp := defaultResponse()
|
resp := defaultResponse()
|
||||||
resp.StaticLeases = []*Lease{staticLease}
|
resp.StaticLeases = []*leaseStatic{staticLease}
|
||||||
|
|
||||||
checkStatus(t, resp)
|
checkStatus(t, resp)
|
||||||
})
|
})
|
||||||
@@ -106,7 +104,7 @@ func TestServer_handleDHCPStatus(t *testing.T) {
|
|||||||
|
|
||||||
b := &bytes.Buffer{}
|
b := &bytes.Buffer{}
|
||||||
|
|
||||||
err = json.NewEncoder(b).Encode(&Lease{})
|
err = json.NewEncoder(b).Encode(&leaseStatic{})
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
var r *http.Request
|
var r *http.Request
|
||||||
|
|||||||
106
internal/dhcpd/migrate.go
Normal file
106
internal/dhcpd/migrate.go
Normal file
@@ -0,0 +1,106 @@
|
|||||||
|
package dhcpd
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"net"
|
||||||
|
"net/netip"
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/AdguardTeam/golibs/errors"
|
||||||
|
"github.com/AdguardTeam/golibs/log"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
// leaseExpireStatic is used to define the Expiry field for static
|
||||||
|
// leases.
|
||||||
|
//
|
||||||
|
// Deprecated: Remove it when migration of DHCP leases will be not needed.
|
||||||
|
leaseExpireStatic = 1
|
||||||
|
|
||||||
|
// dbFilename contains saved leases.
|
||||||
|
//
|
||||||
|
// Deprecated: Use dataFilename.
|
||||||
|
dbFilename = "leases.db"
|
||||||
|
)
|
||||||
|
|
||||||
|
// leaseJSON is the structure of stored lease.
|
||||||
|
//
|
||||||
|
// Deprecated: Use [Lease].
|
||||||
|
type leaseJSON struct {
|
||||||
|
HWAddr []byte `json:"mac"`
|
||||||
|
IP []byte `json:"ip"`
|
||||||
|
Hostname string `json:"host"`
|
||||||
|
Expiry int64 `json:"exp"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func normalizeIP(ip net.IP) net.IP {
|
||||||
|
ip4 := ip.To4()
|
||||||
|
if ip4 != nil {
|
||||||
|
return ip4
|
||||||
|
}
|
||||||
|
|
||||||
|
return ip
|
||||||
|
}
|
||||||
|
|
||||||
|
// migrateDB migrates stored leases if necessary.
|
||||||
|
func migrateDB(conf *ServerConfig) (err error) {
|
||||||
|
defer func() { err = errors.Annotate(err, "migrating db: %w") }()
|
||||||
|
|
||||||
|
oldLeasesPath := filepath.Join(conf.WorkDir, dbFilename)
|
||||||
|
dataDirPath := filepath.Join(conf.DataDir, dataFilename)
|
||||||
|
|
||||||
|
file, err := os.Open(oldLeasesPath)
|
||||||
|
if errors.Is(err, os.ErrNotExist) {
|
||||||
|
// Nothing to migrate.
|
||||||
|
return nil
|
||||||
|
} else if err != nil {
|
||||||
|
// Don't wrap the error since it's informative enough as is.
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
ljs := []leaseJSON{}
|
||||||
|
err = json.NewDecoder(file).Decode(&ljs)
|
||||||
|
if err != nil {
|
||||||
|
// Don't wrap the error since it's informative enough as is.
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = file.Close()
|
||||||
|
if err != nil {
|
||||||
|
// Don't wrap the error since it's informative enough as is.
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
leases := []*Lease{}
|
||||||
|
|
||||||
|
for _, lj := range ljs {
|
||||||
|
lj.IP = normalizeIP(lj.IP)
|
||||||
|
|
||||||
|
ip, ok := netip.AddrFromSlice(lj.IP)
|
||||||
|
if !ok {
|
||||||
|
log.Info("dhcp: invalid IP: %s", lj.IP)
|
||||||
|
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
lease := &Lease{
|
||||||
|
Expiry: time.Unix(lj.Expiry, 0),
|
||||||
|
Hostname: lj.Hostname,
|
||||||
|
HWAddr: lj.HWAddr,
|
||||||
|
IP: ip,
|
||||||
|
IsStatic: lj.Expiry == leaseExpireStatic,
|
||||||
|
}
|
||||||
|
|
||||||
|
leases = append(leases, lease)
|
||||||
|
}
|
||||||
|
|
||||||
|
err = writeDB(dataDirPath, leases)
|
||||||
|
if err != nil {
|
||||||
|
// Don't wrap the error since it's informative enough as is.
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return os.Remove(oldLeasesPath)
|
||||||
|
}
|
||||||
73
internal/dhcpd/migrate_internal_test.go
Normal file
73
internal/dhcpd/migrate_internal_test.go
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
package dhcpd
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"net"
|
||||||
|
"net/netip"
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
"testing"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
|
)
|
||||||
|
|
||||||
|
const testData = `[
|
||||||
|
{"mac":"ESIzRFVm","ip":"AQIDBA==","host":"test1","exp":1},
|
||||||
|
{"mac":"ZlVEMyIR","ip":"BAMCAQ==","host":"test2","exp":1231231231}
|
||||||
|
]`
|
||||||
|
|
||||||
|
func TestMigrateDB(t *testing.T) {
|
||||||
|
dir := t.TempDir()
|
||||||
|
|
||||||
|
oldLeasesPath := filepath.Join(dir, dbFilename)
|
||||||
|
dataDirPath := filepath.Join(dir, dataFilename)
|
||||||
|
|
||||||
|
err := os.WriteFile(oldLeasesPath, []byte(testData), 0o644)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
wantLeases := []*Lease{{
|
||||||
|
Expiry: time.Time{},
|
||||||
|
Hostname: "test1",
|
||||||
|
HWAddr: net.HardwareAddr{0x11, 0x22, 0x33, 0x44, 0x55, 0x66},
|
||||||
|
IP: netip.MustParseAddr("1.2.3.4"),
|
||||||
|
IsStatic: true,
|
||||||
|
}, {
|
||||||
|
Expiry: time.Unix(1231231231, 0),
|
||||||
|
Hostname: "test2",
|
||||||
|
HWAddr: net.HardwareAddr{0x66, 0x55, 0x44, 0x33, 0x22, 0x11},
|
||||||
|
IP: netip.MustParseAddr("4.3.2.1"),
|
||||||
|
IsStatic: false,
|
||||||
|
}}
|
||||||
|
|
||||||
|
conf := &ServerConfig{
|
||||||
|
WorkDir: dir,
|
||||||
|
DataDir: dir,
|
||||||
|
}
|
||||||
|
|
||||||
|
err = migrateDB(conf)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
_, err = os.Stat(oldLeasesPath)
|
||||||
|
require.ErrorIs(t, err, os.ErrNotExist)
|
||||||
|
|
||||||
|
var data []byte
|
||||||
|
data, err = os.ReadFile(dataDirPath)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
dl := &dataLeases{}
|
||||||
|
err = json.Unmarshal(data, dl)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
leases := dl.Leases
|
||||||
|
|
||||||
|
for i, wl := range wantLeases {
|
||||||
|
assert.Equal(t, wl.Hostname, leases[i].Hostname)
|
||||||
|
assert.Equal(t, wl.HWAddr, leases[i].HWAddr)
|
||||||
|
assert.Equal(t, wl.IP, leases[i].IP)
|
||||||
|
assert.Equal(t, wl.IsStatic, leases[i].IsStatic)
|
||||||
|
|
||||||
|
require.True(t, wl.Expiry.Equal(leases[i].Expiry))
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -20,7 +20,6 @@ import (
|
|||||||
"github.com/go-ping/ping"
|
"github.com/go-ping/ping"
|
||||||
"github.com/insomniacslk/dhcp/dhcpv4"
|
"github.com/insomniacslk/dhcp/dhcpv4"
|
||||||
"github.com/insomniacslk/dhcp/dhcpv4/server4"
|
"github.com/insomniacslk/dhcp/dhcpv4/server4"
|
||||||
"github.com/mdlayher/packet"
|
|
||||||
"golang.org/x/exp/slices"
|
"golang.org/x/exp/slices"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -128,7 +127,7 @@ func (s *v4Server) ResetLeases(leases []*Lease) (err error) {
|
|||||||
s.leases = nil
|
s.leases = nil
|
||||||
|
|
||||||
for _, l := range leases {
|
for _, l := range leases {
|
||||||
if !l.IsStatic() {
|
if !l.IsStatic {
|
||||||
l.Hostname = s.validHostnameForClient(l.Hostname, l.IP)
|
l.Hostname = s.validHostnameForClient(l.Hostname, l.IP)
|
||||||
}
|
}
|
||||||
err = s.addLease(l)
|
err = s.addLease(l)
|
||||||
@@ -190,7 +189,7 @@ func (s *v4Server) GetLeases(flags GetLeasesFlags) (leases []*Lease) {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if getStatic && l.IsStatic() {
|
if getStatic && l.IsStatic {
|
||||||
leases = append(leases, l.Clone())
|
leases = append(leases, l.Clone())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -211,7 +210,7 @@ func (s *v4Server) FindMACbyIP(ip netip.Addr) (mac net.HardwareAddr) {
|
|||||||
|
|
||||||
for _, l := range s.leases {
|
for _, l := range s.leases {
|
||||||
if l.IP == ip {
|
if l.IP == ip {
|
||||||
if l.Expiry.After(now) || l.IsStatic() {
|
if l.IsStatic || l.Expiry.After(now) {
|
||||||
return l.HWAddr
|
return l.HWAddr
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -257,9 +256,11 @@ func (s *v4Server) rmLeaseByIndex(i int) {
|
|||||||
|
|
||||||
// Remove a dynamic lease with the same properties
|
// Remove a dynamic lease with the same properties
|
||||||
// Return error if a static lease is found
|
// Return error if a static lease is found
|
||||||
|
//
|
||||||
|
// TODO(s.chzhen): Refactor the code.
|
||||||
func (s *v4Server) rmDynamicLease(lease *Lease) (err error) {
|
func (s *v4Server) rmDynamicLease(lease *Lease) (err error) {
|
||||||
for i, l := range s.leases {
|
for i, l := range s.leases {
|
||||||
isStatic := l.IsStatic()
|
isStatic := l.IsStatic
|
||||||
|
|
||||||
if bytes.Equal(l.HWAddr, lease.HWAddr) || l.IP == lease.IP {
|
if bytes.Equal(l.HWAddr, lease.HWAddr) || l.IP == lease.IP {
|
||||||
if isStatic {
|
if isStatic {
|
||||||
@@ -292,7 +293,7 @@ func (s *v4Server) addLease(l *Lease) (err error) {
|
|||||||
leaseIP := net.IP(l.IP.AsSlice())
|
leaseIP := net.IP(l.IP.AsSlice())
|
||||||
offset, inOffset := r.offset(leaseIP)
|
offset, inOffset := r.offset(leaseIP)
|
||||||
|
|
||||||
if l.IsStatic() {
|
if l.IsStatic {
|
||||||
// TODO(a.garipov, d.seregin): Subnet can be nil when dhcp server is
|
// TODO(a.garipov, d.seregin): Subnet can be nil when dhcp server is
|
||||||
// disabled.
|
// disabled.
|
||||||
if sn := s.conf.subnet; !sn.Contains(l.IP) {
|
if sn := s.conf.subnet; !sn.Contains(l.IP) {
|
||||||
@@ -358,7 +359,7 @@ func (s *v4Server) AddStaticLease(l *Lease) (err error) {
|
|||||||
return fmt.Errorf("can't assign the gateway IP %s to the lease", gwIP)
|
return fmt.Errorf("can't assign the gateway IP %s to the lease", gwIP)
|
||||||
}
|
}
|
||||||
|
|
||||||
l.Expiry = time.Unix(leaseExpireStatic, 0)
|
l.IsStatic = true
|
||||||
|
|
||||||
err = netutil.ValidateMAC(l.HWAddr)
|
err = netutil.ValidateMAC(l.HWAddr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -528,7 +529,7 @@ func (s *v4Server) nextIP() (ip net.IP) {
|
|||||||
func (s *v4Server) findExpiredLease() int {
|
func (s *v4Server) findExpiredLease() int {
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
for i, lease := range s.leases {
|
for i, lease := range s.leases {
|
||||||
if !lease.IsStatic() && lease.Expiry.Before(now) {
|
if !lease.IsStatic && lease.Expiry.Before(now) {
|
||||||
return i
|
return i
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -860,7 +861,7 @@ func (s *v4Server) handleRequest(req, resp *dhcpv4.DHCPv4) (lease *Lease, needsR
|
|||||||
s.leasesLock.Lock()
|
s.leasesLock.Lock()
|
||||||
defer s.leasesLock.Unlock()
|
defer s.leasesLock.Unlock()
|
||||||
|
|
||||||
if lease.IsStatic() {
|
if lease.IsStatic {
|
||||||
if lease.Hostname != "" {
|
if lease.Hostname != "" {
|
||||||
// TODO(e.burkov): This option is used to update the server's DNS
|
// TODO(e.burkov): This option is used to update the server's DNS
|
||||||
// mapping. The option should only be answered when it has been
|
// mapping. The option should only be answered when it has been
|
||||||
@@ -1131,56 +1132,6 @@ func (s *v4Server) packetHandler(conn net.PacketConn, peer net.Addr, req *dhcpv4
|
|||||||
s.send(peer, conn, req, resp)
|
s.send(peer, conn, req, resp)
|
||||||
}
|
}
|
||||||
|
|
||||||
// send writes resp for peer to conn considering the req's parameters according
|
|
||||||
// to RFC-2131.
|
|
||||||
//
|
|
||||||
// See https://datatracker.ietf.org/doc/html/rfc2131#section-4.1.
|
|
||||||
func (s *v4Server) send(peer net.Addr, conn net.PacketConn, req, resp *dhcpv4.DHCPv4) {
|
|
||||||
switch giaddr, ciaddr, mtype := req.GatewayIPAddr, req.ClientIPAddr, resp.MessageType(); {
|
|
||||||
case giaddr != nil && !giaddr.IsUnspecified():
|
|
||||||
// Send any return messages to the server port on the BOOTP
|
|
||||||
// relay agent whose address appears in giaddr.
|
|
||||||
peer = &net.UDPAddr{
|
|
||||||
IP: giaddr,
|
|
||||||
Port: dhcpv4.ServerPort,
|
|
||||||
}
|
|
||||||
if mtype == dhcpv4.MessageTypeNak {
|
|
||||||
// Set the broadcast bit in the DHCPNAK, so that the relay agent
|
|
||||||
// broadcasts it to the client, because the client may not have
|
|
||||||
// a correct network address or subnet mask, and the client may not
|
|
||||||
// be answering ARP requests.
|
|
||||||
resp.SetBroadcast()
|
|
||||||
}
|
|
||||||
case mtype == dhcpv4.MessageTypeNak:
|
|
||||||
// Broadcast any DHCPNAK messages to 0xffffffff.
|
|
||||||
case ciaddr != nil && !ciaddr.IsUnspecified():
|
|
||||||
// Unicast DHCPOFFER and DHCPACK messages to the address in
|
|
||||||
// ciaddr.
|
|
||||||
peer = &net.UDPAddr{
|
|
||||||
IP: ciaddr,
|
|
||||||
Port: dhcpv4.ClientPort,
|
|
||||||
}
|
|
||||||
case !req.IsBroadcast() && req.ClientHWAddr != nil:
|
|
||||||
// Unicast DHCPOFFER and DHCPACK messages to the client's
|
|
||||||
// hardware address and yiaddr.
|
|
||||||
peer = &dhcpUnicastAddr{
|
|
||||||
Addr: packet.Addr{HardwareAddr: req.ClientHWAddr},
|
|
||||||
yiaddr: resp.YourIPAddr,
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
// Go on since peer is already set to broadcast.
|
|
||||||
}
|
|
||||||
|
|
||||||
pktData := resp.ToBytes()
|
|
||||||
|
|
||||||
log.Debug("dhcpv4: sending %d bytes to %s: %s", len(pktData), peer, resp.Summary())
|
|
||||||
|
|
||||||
_, err := conn.WriteTo(pktData, peer)
|
|
||||||
if err != nil {
|
|
||||||
log.Error("dhcpv4: conn.Write to %s failed: %s", peer, err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Start starts the IPv4 DHCP server.
|
// Start starts the IPv4 DHCP server.
|
||||||
func (s *v4Server) Start() (err error) {
|
func (s *v4Server) Start() (err error) {
|
||||||
defer func() { err = errors.Annotate(err, "dhcpv4: %w") }()
|
defer func() { err = errors.Annotate(err, "dhcpv4: %w") }()
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ import (
|
|||||||
"github.com/AdguardTeam/golibs/stringutil"
|
"github.com/AdguardTeam/golibs/stringutil"
|
||||||
"github.com/AdguardTeam/golibs/testutil"
|
"github.com/AdguardTeam/golibs/testutil"
|
||||||
"github.com/insomniacslk/dhcp/dhcpv4"
|
"github.com/insomniacslk/dhcp/dhcpv4"
|
||||||
"github.com/mdlayher/packet"
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
@@ -69,19 +68,19 @@ func TestV4Server_leasing(t *testing.T) {
|
|||||||
|
|
||||||
t.Run("add_static", func(t *testing.T) {
|
t.Run("add_static", func(t *testing.T) {
|
||||||
err := s.AddStaticLease(&Lease{
|
err := s.AddStaticLease(&Lease{
|
||||||
Expiry: time.Unix(leaseExpireStatic, 0),
|
|
||||||
Hostname: staticName,
|
Hostname: staticName,
|
||||||
HWAddr: staticMAC,
|
HWAddr: staticMAC,
|
||||||
IP: staticIP,
|
IP: staticIP,
|
||||||
|
IsStatic: true,
|
||||||
})
|
})
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
t.Run("same_name", func(t *testing.T) {
|
t.Run("same_name", func(t *testing.T) {
|
||||||
err = s.AddStaticLease(&Lease{
|
err = s.AddStaticLease(&Lease{
|
||||||
Expiry: time.Unix(leaseExpireStatic, 0),
|
|
||||||
Hostname: staticName,
|
Hostname: staticName,
|
||||||
HWAddr: anotherMAC,
|
HWAddr: anotherMAC,
|
||||||
IP: anotherIP,
|
IP: anotherIP,
|
||||||
|
IsStatic: true,
|
||||||
})
|
})
|
||||||
assert.ErrorIs(t, err, ErrDupHostname)
|
assert.ErrorIs(t, err, ErrDupHostname)
|
||||||
})
|
})
|
||||||
@@ -92,10 +91,10 @@ func TestV4Server_leasing(t *testing.T) {
|
|||||||
" (" + staticMAC.String() + "): static lease already exists"
|
" (" + staticMAC.String() + "): static lease already exists"
|
||||||
|
|
||||||
err = s.AddStaticLease(&Lease{
|
err = s.AddStaticLease(&Lease{
|
||||||
Expiry: time.Unix(leaseExpireStatic, 0),
|
|
||||||
Hostname: anotherName,
|
Hostname: anotherName,
|
||||||
HWAddr: staticMAC,
|
HWAddr: staticMAC,
|
||||||
IP: anotherIP,
|
IP: anotherIP,
|
||||||
|
IsStatic: true,
|
||||||
})
|
})
|
||||||
testutil.AssertErrorMsg(t, wantErrMsg, err)
|
testutil.AssertErrorMsg(t, wantErrMsg, err)
|
||||||
})
|
})
|
||||||
@@ -106,10 +105,10 @@ func TestV4Server_leasing(t *testing.T) {
|
|||||||
" (" + anotherMAC.String() + "): static lease already exists"
|
" (" + anotherMAC.String() + "): static lease already exists"
|
||||||
|
|
||||||
err = s.AddStaticLease(&Lease{
|
err = s.AddStaticLease(&Lease{
|
||||||
Expiry: time.Unix(leaseExpireStatic, 0),
|
|
||||||
Hostname: anotherName,
|
Hostname: anotherName,
|
||||||
HWAddr: anotherMAC,
|
HWAddr: anotherMAC,
|
||||||
IP: staticIP,
|
IP: staticIP,
|
||||||
|
IsStatic: true,
|
||||||
})
|
})
|
||||||
testutil.AssertErrorMsg(t, wantErrMsg, err)
|
testutil.AssertErrorMsg(t, wantErrMsg, err)
|
||||||
})
|
})
|
||||||
@@ -326,7 +325,7 @@ func TestV4_AddReplace(t *testing.T) {
|
|||||||
for i, l := range ls {
|
for i, l := range ls {
|
||||||
assert.Equal(t, stLeases[i].IP, l.IP)
|
assert.Equal(t, stLeases[i].IP, l.IP)
|
||||||
assert.Equal(t, stLeases[i].HWAddr, l.HWAddr)
|
assert.Equal(t, stLeases[i].HWAddr, l.HWAddr)
|
||||||
assert.True(t, l.IsStatic())
|
assert.True(t, l.IsStatic)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -767,111 +766,6 @@ func (fc *fakePacketConn) WriteTo(p []byte, addr net.Addr) (n int, err error) {
|
|||||||
return fc.writeTo(p, addr)
|
return fc.writeTo(p, addr)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestV4Server_Send(t *testing.T) {
|
|
||||||
s := &v4Server{}
|
|
||||||
|
|
||||||
var (
|
|
||||||
defaultIP = net.IP{99, 99, 99, 99}
|
|
||||||
knownIP = net.IP{4, 2, 4, 2}
|
|
||||||
knownMAC = net.HardwareAddr{6, 5, 4, 3, 2, 1}
|
|
||||||
)
|
|
||||||
|
|
||||||
defaultPeer := &net.UDPAddr{
|
|
||||||
IP: defaultIP,
|
|
||||||
// Use neither client nor server port to check it actually
|
|
||||||
// changed.
|
|
||||||
Port: dhcpv4.ClientPort + dhcpv4.ServerPort,
|
|
||||||
}
|
|
||||||
defaultResp := &dhcpv4.DHCPv4{}
|
|
||||||
|
|
||||||
testCases := []struct {
|
|
||||||
want net.Addr
|
|
||||||
req *dhcpv4.DHCPv4
|
|
||||||
resp *dhcpv4.DHCPv4
|
|
||||||
name string
|
|
||||||
}{{
|
|
||||||
name: "giaddr",
|
|
||||||
req: &dhcpv4.DHCPv4{GatewayIPAddr: knownIP},
|
|
||||||
resp: defaultResp,
|
|
||||||
want: &net.UDPAddr{
|
|
||||||
IP: knownIP,
|
|
||||||
Port: dhcpv4.ServerPort,
|
|
||||||
},
|
|
||||||
}, {
|
|
||||||
name: "nak",
|
|
||||||
req: &dhcpv4.DHCPv4{},
|
|
||||||
resp: &dhcpv4.DHCPv4{
|
|
||||||
Options: dhcpv4.OptionsFromList(
|
|
||||||
dhcpv4.OptMessageType(dhcpv4.MessageTypeNak),
|
|
||||||
),
|
|
||||||
},
|
|
||||||
want: defaultPeer,
|
|
||||||
}, {
|
|
||||||
name: "ciaddr",
|
|
||||||
req: &dhcpv4.DHCPv4{ClientIPAddr: knownIP},
|
|
||||||
resp: &dhcpv4.DHCPv4{},
|
|
||||||
want: &net.UDPAddr{
|
|
||||||
IP: knownIP,
|
|
||||||
Port: dhcpv4.ClientPort,
|
|
||||||
},
|
|
||||||
}, {
|
|
||||||
name: "chaddr",
|
|
||||||
req: &dhcpv4.DHCPv4{ClientHWAddr: knownMAC},
|
|
||||||
resp: &dhcpv4.DHCPv4{YourIPAddr: knownIP},
|
|
||||||
want: &dhcpUnicastAddr{
|
|
||||||
Addr: packet.Addr{HardwareAddr: knownMAC},
|
|
||||||
yiaddr: knownIP,
|
|
||||||
},
|
|
||||||
}, {
|
|
||||||
name: "who_are_you",
|
|
||||||
req: &dhcpv4.DHCPv4{},
|
|
||||||
resp: &dhcpv4.DHCPv4{},
|
|
||||||
want: defaultPeer,
|
|
||||||
}}
|
|
||||||
|
|
||||||
for _, tc := range testCases {
|
|
||||||
t.Run(tc.name, func(t *testing.T) {
|
|
||||||
conn := &fakePacketConn{
|
|
||||||
writeTo: func(_ []byte, addr net.Addr) (_ int, _ error) {
|
|
||||||
assert.Equal(t, tc.want, addr)
|
|
||||||
|
|
||||||
return 0, nil
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
s.send(cloneUDPAddr(defaultPeer), conn, tc.req, tc.resp)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
t.Run("giaddr_nak", func(t *testing.T) {
|
|
||||||
req := &dhcpv4.DHCPv4{
|
|
||||||
GatewayIPAddr: knownIP,
|
|
||||||
}
|
|
||||||
// Ensure the request is for unicast.
|
|
||||||
req.SetUnicast()
|
|
||||||
resp := &dhcpv4.DHCPv4{
|
|
||||||
Options: dhcpv4.OptionsFromList(
|
|
||||||
dhcpv4.OptMessageType(dhcpv4.MessageTypeNak),
|
|
||||||
),
|
|
||||||
}
|
|
||||||
want := &net.UDPAddr{
|
|
||||||
IP: req.GatewayIPAddr,
|
|
||||||
Port: dhcpv4.ServerPort,
|
|
||||||
}
|
|
||||||
|
|
||||||
conn := &fakePacketConn{
|
|
||||||
writeTo: func(_ []byte, addr net.Addr) (n int, err error) {
|
|
||||||
assert.Equal(t, want, addr)
|
|
||||||
|
|
||||||
return 0, nil
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
s.send(cloneUDPAddr(defaultPeer), conn, req, resp)
|
|
||||||
assert.True(t, resp.IsBroadcast())
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestV4Server_FindMACbyIP(t *testing.T) {
|
func TestV4Server_FindMACbyIP(t *testing.T) {
|
||||||
const (
|
const (
|
||||||
staticName = "static-client"
|
staticName = "static-client"
|
||||||
@@ -886,10 +780,10 @@ func TestV4Server_FindMACbyIP(t *testing.T) {
|
|||||||
|
|
||||||
s := &v4Server{
|
s := &v4Server{
|
||||||
leases: []*Lease{{
|
leases: []*Lease{{
|
||||||
Expiry: time.Unix(leaseExpireStatic, 0),
|
|
||||||
Hostname: staticName,
|
Hostname: staticName,
|
||||||
HWAddr: staticMAC,
|
HWAddr: staticMAC,
|
||||||
IP: staticIP,
|
IP: staticIP,
|
||||||
|
IsStatic: true,
|
||||||
}, {
|
}, {
|
||||||
Expiry: time.Unix(10, 0),
|
Expiry: time.Unix(10, 0),
|
||||||
Hostname: anotherName,
|
Hostname: anotherName,
|
||||||
|
|||||||
@@ -66,8 +66,7 @@ func (s *v6Server) ResetLeases(leases []*Lease) (err error) {
|
|||||||
s.leases = nil
|
s.leases = nil
|
||||||
for _, l := range leases {
|
for _, l := range leases {
|
||||||
ip := net.IP(l.IP.AsSlice())
|
ip := net.IP(l.IP.AsSlice())
|
||||||
if l.Expiry.Unix() != leaseExpireStatic &&
|
if !l.IsStatic && !ip6InRange(s.conf.ipStart, ip) {
|
||||||
!ip6InRange(s.conf.ipStart, ip) {
|
|
||||||
|
|
||||||
log.Debug("dhcpv6: skipping a lease with IP %v: not within current IP range", l.IP)
|
log.Debug("dhcpv6: skipping a lease with IP %v: not within current IP range", l.IP)
|
||||||
|
|
||||||
@@ -89,7 +88,7 @@ func (s *v6Server) GetLeases(flags GetLeasesFlags) (leases []*Lease) {
|
|||||||
leases = []*Lease{}
|
leases = []*Lease{}
|
||||||
s.leasesLock.Lock()
|
s.leasesLock.Lock()
|
||||||
for _, l := range s.leases {
|
for _, l := range s.leases {
|
||||||
if l.Expiry.Unix() == leaseExpireStatic {
|
if l.IsStatic {
|
||||||
if (flags & LeasesStatic) != 0 {
|
if (flags & LeasesStatic) != 0 {
|
||||||
leases = append(leases, l.Clone())
|
leases = append(leases, l.Clone())
|
||||||
}
|
}
|
||||||
@@ -121,7 +120,7 @@ func (s *v6Server) FindMACbyIP(ip netip.Addr) (mac net.HardwareAddr) {
|
|||||||
|
|
||||||
for _, l := range s.leases {
|
for _, l := range s.leases {
|
||||||
if l.IP == ip {
|
if l.IP == ip {
|
||||||
if l.Expiry.After(now) || l.IsStatic() {
|
if l.IsStatic || l.Expiry.After(now) {
|
||||||
return l.HWAddr
|
return l.HWAddr
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -150,7 +149,7 @@ func (s *v6Server) rmDynamicLease(lease *Lease) (err error) {
|
|||||||
l := s.leases[i]
|
l := s.leases[i]
|
||||||
|
|
||||||
if bytes.Equal(l.HWAddr, lease.HWAddr) {
|
if bytes.Equal(l.HWAddr, lease.HWAddr) {
|
||||||
if l.Expiry.Unix() == leaseExpireStatic {
|
if l.IsStatic {
|
||||||
return fmt.Errorf("static lease already exists")
|
return fmt.Errorf("static lease already exists")
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -163,7 +162,7 @@ func (s *v6Server) rmDynamicLease(lease *Lease) (err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if l.IP == lease.IP {
|
if l.IP == lease.IP {
|
||||||
if l.Expiry.Unix() == leaseExpireStatic {
|
if l.IsStatic {
|
||||||
return fmt.Errorf("static lease already exists")
|
return fmt.Errorf("static lease already exists")
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -187,7 +186,7 @@ func (s *v6Server) AddStaticLease(l *Lease) (err error) {
|
|||||||
return fmt.Errorf("validating lease: %w", err)
|
return fmt.Errorf("validating lease: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
l.Expiry = time.Unix(leaseExpireStatic, 0)
|
l.IsStatic = true
|
||||||
|
|
||||||
s.leasesLock.Lock()
|
s.leasesLock.Lock()
|
||||||
err = s.rmDynamicLease(l)
|
err = s.rmDynamicLease(l)
|
||||||
@@ -274,8 +273,7 @@ func (s *v6Server) findLease(mac net.HardwareAddr) *Lease {
|
|||||||
func (s *v6Server) findExpiredLease() int {
|
func (s *v6Server) findExpiredLease() int {
|
||||||
now := time.Now().Unix()
|
now := time.Now().Unix()
|
||||||
for i, lease := range s.leases {
|
for i, lease := range s.leases {
|
||||||
if lease.Expiry.Unix() != leaseExpireStatic &&
|
if !lease.IsStatic && lease.Expiry.Unix() <= now {
|
||||||
lease.Expiry.Unix() <= now {
|
|
||||||
return i
|
return i
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -421,7 +419,7 @@ func (s *v6Server) commitLease(msg *dhcpv6.Message, lease *Lease) time.Duration
|
|||||||
dhcpv6.MessageTypeRenew,
|
dhcpv6.MessageTypeRenew,
|
||||||
dhcpv6.MessageTypeRebind:
|
dhcpv6.MessageTypeRebind:
|
||||||
|
|
||||||
if lease.Expiry.Unix() != leaseExpireStatic {
|
if !lease.IsStatic {
|
||||||
s.commitDynamicLease(lease)
|
s.commitDynamicLease(lease)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ func TestV6_AddRemove_static(t *testing.T) {
|
|||||||
|
|
||||||
assert.Equal(t, l.IP, ls[0].IP)
|
assert.Equal(t, l.IP, ls[0].IP)
|
||||||
assert.Equal(t, l.HWAddr, ls[0].HWAddr)
|
assert.Equal(t, l.HWAddr, ls[0].HWAddr)
|
||||||
assert.EqualValues(t, leaseExpireStatic, ls[0].Expiry.Unix())
|
assert.True(t, ls[0].IsStatic)
|
||||||
|
|
||||||
// Try to remove non-existent static lease.
|
// Try to remove non-existent static lease.
|
||||||
err = s.RemoveStaticLease(&Lease{
|
err = s.RemoveStaticLease(&Lease{
|
||||||
@@ -103,7 +103,7 @@ func TestV6_AddReplace(t *testing.T) {
|
|||||||
for i, l := range ls {
|
for i, l := range ls {
|
||||||
assert.Equal(t, stLeases[i].IP, l.IP)
|
assert.Equal(t, stLeases[i].IP, l.IP)
|
||||||
assert.Equal(t, stLeases[i].HWAddr, l.HWAddr)
|
assert.Equal(t, stLeases[i].HWAddr, l.HWAddr)
|
||||||
assert.EqualValues(t, leaseExpireStatic, l.Expiry.Unix())
|
assert.True(t, l.IsStatic)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -327,10 +327,10 @@ func TestV6_FindMACbyIP(t *testing.T) {
|
|||||||
|
|
||||||
s := &v6Server{
|
s := &v6Server{
|
||||||
leases: []*Lease{{
|
leases: []*Lease{{
|
||||||
Expiry: time.Unix(leaseExpireStatic, 0),
|
|
||||||
Hostname: staticName,
|
Hostname: staticName,
|
||||||
HWAddr: staticMAC,
|
HWAddr: staticMAC,
|
||||||
IP: staticIP,
|
IP: staticIP,
|
||||||
|
IsStatic: true,
|
||||||
}, {
|
}, {
|
||||||
Expiry: time.Unix(10, 0),
|
Expiry: time.Unix(10, 0),
|
||||||
Hostname: anotherName,
|
Hostname: anotherName,
|
||||||
@@ -340,10 +340,10 @@ func TestV6_FindMACbyIP(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
s.leases = []*Lease{{
|
s.leases = []*Lease{{
|
||||||
Expiry: time.Unix(leaseExpireStatic, 0),
|
|
||||||
Hostname: staticName,
|
Hostname: staticName,
|
||||||
HWAddr: staticMAC,
|
HWAddr: staticMAC,
|
||||||
IP: staticIP,
|
IP: staticIP,
|
||||||
|
IsStatic: true,
|
||||||
}, {
|
}, {
|
||||||
Expiry: time.Unix(10, 0),
|
Expiry: time.Unix(10, 0),
|
||||||
Hostname: anotherName,
|
Hostname: anotherName,
|
||||||
|
|||||||
@@ -587,11 +587,11 @@ func (s *Server) prepareTLS(proxyConfig *proxy.Config) (err error) {
|
|||||||
if s.conf.StrictSNICheck {
|
if s.conf.StrictSNICheck {
|
||||||
if len(cert.DNSNames) != 0 {
|
if len(cert.DNSNames) != 0 {
|
||||||
s.conf.dnsNames = cert.DNSNames
|
s.conf.dnsNames = cert.DNSNames
|
||||||
log.Debug("dnsforward: using certificate's SAN as DNS names: %v", cert.DNSNames)
|
log.Debug("dns: using certificate's SAN as DNS names: %v", cert.DNSNames)
|
||||||
slices.Sort(s.conf.dnsNames)
|
slices.Sort(s.conf.dnsNames)
|
||||||
} else {
|
} else {
|
||||||
s.conf.dnsNames = append(s.conf.dnsNames, cert.Subject.CommonName)
|
s.conf.dnsNames = append(s.conf.dnsNames, cert.Subject.CommonName)
|
||||||
log.Debug("dnsforward: using certificate's CN as DNS name: %s", cert.Subject.CommonName)
|
log.Debug("dns: using certificate's CN as DNS name: %s", cert.Subject.CommonName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -648,30 +648,46 @@ func (s *Server) onGetCertificate(ch *tls.ClientHelloInfo) (*tls.Certificate, er
|
|||||||
|
|
||||||
// UpdatedProtectionStatus updates protection state, if the protection was
|
// UpdatedProtectionStatus updates protection state, if the protection was
|
||||||
// disabled temporarily. Returns the updated state of protection.
|
// disabled temporarily. Returns the updated state of protection.
|
||||||
func (s *Server) UpdatedProtectionStatus() (enabled bool) {
|
func (s *Server) UpdatedProtectionStatus() (enabled bool, disabledUntil *time.Time) {
|
||||||
changed := false
|
s.serverLock.RLock()
|
||||||
defer func() {
|
defer s.serverLock.RUnlock()
|
||||||
if changed {
|
|
||||||
log.Info("dns: protection is restarted after pause")
|
disabledUntil = s.conf.ProtectionDisabledUntil
|
||||||
s.conf.ConfigModified()
|
if disabledUntil == nil {
|
||||||
}
|
return s.conf.ProtectionEnabled, nil
|
||||||
}()
|
}
|
||||||
|
|
||||||
|
if time.Now().Before(*disabledUntil) {
|
||||||
|
return false, disabledUntil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update the values in a separate goroutine, unless an update is already in
|
||||||
|
// progress. Since this method is called very often, and this update is a
|
||||||
|
// relatively rare situation, do not lock s.serverLock for writing, as that
|
||||||
|
// can lead to freezes.
|
||||||
|
//
|
||||||
|
// See https://github.com/AdguardTeam/AdGuardHome/issues/5661.
|
||||||
|
if s.protectionUpdateInProgress.CompareAndSwap(false, true) {
|
||||||
|
go s.enableProtectionAfterPause()
|
||||||
|
}
|
||||||
|
|
||||||
|
return true, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// enableProtectionAfterPause sets the protection configuration to enabled
|
||||||
|
// values. It is intended to be used as a goroutine.
|
||||||
|
func (s *Server) enableProtectionAfterPause() {
|
||||||
|
defer log.OnPanic("dns: enabling protection after pause")
|
||||||
|
|
||||||
|
defer s.protectionUpdateInProgress.Store(false)
|
||||||
|
|
||||||
|
defer s.conf.ConfigModified()
|
||||||
|
|
||||||
s.serverLock.Lock()
|
s.serverLock.Lock()
|
||||||
defer s.serverLock.Unlock()
|
defer s.serverLock.Unlock()
|
||||||
|
|
||||||
disabledUntil := s.conf.ProtectionDisabledUntil
|
|
||||||
if disabledUntil == nil {
|
|
||||||
return s.conf.ProtectionEnabled
|
|
||||||
}
|
|
||||||
|
|
||||||
if time.Now().Before(*disabledUntil) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
s.conf.ProtectionEnabled = true
|
s.conf.ProtectionEnabled = true
|
||||||
s.conf.ProtectionDisabledUntil = nil
|
s.conf.ProtectionDisabledUntil = nil
|
||||||
changed = true
|
|
||||||
|
|
||||||
return true
|
log.Info("dns: protection is restarted after pause")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ import (
|
|||||||
// To transfer information between modules
|
// To transfer information between modules
|
||||||
//
|
//
|
||||||
// TODO(s.chzhen): Add lowercased, non-FQDN version of the hostname from the
|
// TODO(s.chzhen): Add lowercased, non-FQDN version of the hostname from the
|
||||||
// question of the request.
|
// question of the request. Add persistent client.
|
||||||
type dnsContext struct {
|
type dnsContext struct {
|
||||||
proxyCtx *proxy.DNSContext
|
proxyCtx *proxy.DNSContext
|
||||||
|
|
||||||
@@ -206,7 +206,7 @@ func (s *Server) processInitial(dctx *dnsContext) (rc resultCode) {
|
|||||||
dctx.clientID = string(s.clientIDCache.Get(key[:]))
|
dctx.clientID = string(s.clientIDCache.Get(key[:]))
|
||||||
|
|
||||||
// Get the client-specific filtering settings.
|
// Get the client-specific filtering settings.
|
||||||
dctx.protectionEnabled = s.UpdatedProtectionStatus()
|
dctx.protectionEnabled, _ = s.UpdatedProtectionStatus()
|
||||||
dctx.setts = s.getClientRequestFilteringSettings(dctx)
|
dctx.setts = s.getClientRequestFilteringSettings(dctx)
|
||||||
|
|
||||||
return resultCodeSuccess
|
return resultCodeSuccess
|
||||||
@@ -460,7 +460,7 @@ func (s *Server) processDHCPHosts(dctx *dnsContext) (rc resultCode) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// indexFirstV4Label returns the index at which the reversed IPv4 address
|
// indexFirstV4Label returns the index at which the reversed IPv4 address
|
||||||
// starts, assuiming the domain is pre-validated ARPA domain having in-addr and
|
// starts, assuming the domain is pre-validated ARPA domain having in-addr and
|
||||||
// arpa labels removed.
|
// arpa labels removed.
|
||||||
func indexFirstV4Label(domain string) (idx int) {
|
func indexFirstV4Label(domain string) (idx int) {
|
||||||
idx = len(domain)
|
idx = len(domain)
|
||||||
@@ -478,7 +478,7 @@ func indexFirstV4Label(domain string) (idx int) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// indexFirstV6Label returns the index at which the reversed IPv6 address
|
// indexFirstV6Label returns the index at which the reversed IPv6 address
|
||||||
// starts, assuiming the domain is pre-validated ARPA domain having ip6 and arpa
|
// starts, assuming the domain is pre-validated ARPA domain having ip6 and arpa
|
||||||
// labels removed.
|
// labels removed.
|
||||||
func indexFirstV6Label(domain string) (idx int) {
|
func indexFirstV6Label(domain string) (idx int) {
|
||||||
idx = len(domain)
|
idx = len(domain)
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import (
|
|||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/AdguardTeam/AdGuardHome/internal/aghalg"
|
"github.com/AdguardTeam/AdGuardHome/internal/aghalg"
|
||||||
@@ -111,6 +112,10 @@ type Server struct {
|
|||||||
|
|
||||||
isRunning bool
|
isRunning bool
|
||||||
|
|
||||||
|
// protectionUpdateInProgress is used to make sure that only one goroutine
|
||||||
|
// updating the protection configuration after a pause is running at a time.
|
||||||
|
protectionUpdateInProgress atomic.Bool
|
||||||
|
|
||||||
conf ServerConfig
|
conf ServerConfig
|
||||||
// serverLock protects Server.
|
// serverLock protects Server.
|
||||||
serverLock sync.RWMutex
|
serverLock sync.RWMutex
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import (
|
|||||||
"github.com/AdguardTeam/AdGuardHome/internal/aghtest"
|
"github.com/AdguardTeam/AdGuardHome/internal/aghtest"
|
||||||
"github.com/AdguardTeam/AdGuardHome/internal/dhcpd"
|
"github.com/AdguardTeam/AdGuardHome/internal/dhcpd"
|
||||||
"github.com/AdguardTeam/AdGuardHome/internal/filtering"
|
"github.com/AdguardTeam/AdGuardHome/internal/filtering"
|
||||||
|
"github.com/AdguardTeam/AdGuardHome/internal/filtering/hashprefix"
|
||||||
"github.com/AdguardTeam/AdGuardHome/internal/filtering/safesearch"
|
"github.com/AdguardTeam/AdGuardHome/internal/filtering/safesearch"
|
||||||
"github.com/AdguardTeam/dnsproxy/proxy"
|
"github.com/AdguardTeam/dnsproxy/proxy"
|
||||||
"github.com/AdguardTeam/dnsproxy/upstream"
|
"github.com/AdguardTeam/dnsproxy/upstream"
|
||||||
@@ -453,8 +454,9 @@ func TestSafeSearch(t *testing.T) {
|
|||||||
SafeSearchCacheSize: 1000,
|
SafeSearchCacheSize: 1000,
|
||||||
CacheTime: 30,
|
CacheTime: 30,
|
||||||
}
|
}
|
||||||
safeSearch, err := safesearch.NewDefaultSafeSearch(
|
safeSearch, err := safesearch.NewDefault(
|
||||||
safeSearchConf,
|
safeSearchConf,
|
||||||
|
"",
|
||||||
filterConf.SafeSearchCacheSize,
|
filterConf.SafeSearchCacheSize,
|
||||||
time.Minute*time.Duration(filterConf.CacheTime),
|
time.Minute*time.Duration(filterConf.CacheTime),
|
||||||
)
|
)
|
||||||
@@ -914,13 +916,23 @@ func TestBlockedByHosts(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestBlockedBySafeBrowsing(t *testing.T) {
|
func TestBlockedBySafeBrowsing(t *testing.T) {
|
||||||
const hostname = "wmconvirus.narod.ru"
|
const (
|
||||||
|
hostname = "wmconvirus.narod.ru"
|
||||||
|
cacheTime = 10 * time.Minute
|
||||||
|
cacheSize = 10000
|
||||||
|
)
|
||||||
|
|
||||||
|
sbChecker := hashprefix.New(&hashprefix.Config{
|
||||||
|
CacheTime: cacheTime,
|
||||||
|
CacheSize: cacheSize,
|
||||||
|
Upstream: aghtest.NewBlockUpstream(hostname, true),
|
||||||
|
})
|
||||||
|
|
||||||
sbUps := aghtest.NewBlockUpstream(hostname, true)
|
|
||||||
ans4, _ := (&aghtest.TestResolver{}).HostToIPs(hostname)
|
ans4, _ := (&aghtest.TestResolver{}).HostToIPs(hostname)
|
||||||
|
|
||||||
filterConf := &filtering.Config{
|
filterConf := &filtering.Config{
|
||||||
SafeBrowsingEnabled: true,
|
SafeBrowsingEnabled: true,
|
||||||
|
SafeBrowsingChecker: sbChecker,
|
||||||
}
|
}
|
||||||
forwardConf := ServerConfig{
|
forwardConf := ServerConfig{
|
||||||
UDPListenAddrs: []*net.UDPAddr{{}},
|
UDPListenAddrs: []*net.UDPAddr{{}},
|
||||||
@@ -934,7 +946,6 @@ func TestBlockedBySafeBrowsing(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
s := createTestServer(t, filterConf, forwardConf, nil)
|
s := createTestServer(t, filterConf, forwardConf, nil)
|
||||||
s.dnsFilter.SetSafeBrowsingUpstream(sbUps)
|
|
||||||
startDeferStop(t, s)
|
startDeferStop(t, s)
|
||||||
addr := s.dnsProxy.Addr(proxy.ProtoUDP)
|
addr := s.dnsProxy.Addr(proxy.ProtoUDP)
|
||||||
|
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ type jsonDNSConfig struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *Server) getDNSConfig() (c *jsonDNSConfig) {
|
func (s *Server) getDNSConfig() (c *jsonDNSConfig) {
|
||||||
protectionEnabled := s.UpdatedProtectionStatus()
|
protectionEnabled, protectionDisabledUntil := s.UpdatedProtectionStatus()
|
||||||
|
|
||||||
s.serverLock.RLock()
|
s.serverLock.RLock()
|
||||||
defer s.serverLock.RUnlock()
|
defer s.serverLock.RUnlock()
|
||||||
@@ -128,12 +128,6 @@ func (s *Server) getDNSConfig() (c *jsonDNSConfig) {
|
|||||||
usePrivateRDNS := s.conf.UsePrivateRDNS
|
usePrivateRDNS := s.conf.UsePrivateRDNS
|
||||||
localPTRUpstreams := stringutil.CloneSliceOrEmpty(s.conf.LocalPTRResolvers)
|
localPTRUpstreams := stringutil.CloneSliceOrEmpty(s.conf.LocalPTRResolvers)
|
||||||
|
|
||||||
var disabledUntil *time.Time
|
|
||||||
if s.conf.ProtectionDisabledUntil != nil {
|
|
||||||
t := *s.conf.ProtectionDisabledUntil
|
|
||||||
disabledUntil = &t
|
|
||||||
}
|
|
||||||
|
|
||||||
var upstreamMode string
|
var upstreamMode string
|
||||||
if s.conf.FastestAddr {
|
if s.conf.FastestAddr {
|
||||||
upstreamMode = "fastest_addr"
|
upstreamMode = "fastest_addr"
|
||||||
@@ -169,7 +163,7 @@ func (s *Server) getDNSConfig() (c *jsonDNSConfig) {
|
|||||||
UsePrivateRDNS: &usePrivateRDNS,
|
UsePrivateRDNS: &usePrivateRDNS,
|
||||||
LocalPTRUpstreams: &localPTRUpstreams,
|
LocalPTRUpstreams: &localPTRUpstreams,
|
||||||
DefaultLocalPTRUpstreams: defLocalPTRUps,
|
DefaultLocalPTRUpstreams: defLocalPTRUps,
|
||||||
DisabledUntil: disabledUntil,
|
DisabledUntil: protectionDisabledUntil,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ import (
|
|||||||
"github.com/AdguardTeam/AdGuardHome/internal/aghhttp"
|
"github.com/AdguardTeam/AdGuardHome/internal/aghhttp"
|
||||||
"github.com/AdguardTeam/AdGuardHome/internal/aghnet"
|
"github.com/AdguardTeam/AdGuardHome/internal/aghnet"
|
||||||
"github.com/AdguardTeam/AdGuardHome/internal/filtering"
|
"github.com/AdguardTeam/AdGuardHome/internal/filtering"
|
||||||
|
"github.com/AdguardTeam/golibs/httphdr"
|
||||||
"github.com/AdguardTeam/golibs/netutil"
|
"github.com/AdguardTeam/golibs/netutil"
|
||||||
"github.com/AdguardTeam/golibs/testutil"
|
"github.com/AdguardTeam/golibs/testutil"
|
||||||
"github.com/miekg/dns"
|
"github.com/miekg/dns"
|
||||||
@@ -122,7 +123,7 @@ func TestDNSForwardHTTP_handleGetConfig(t *testing.T) {
|
|||||||
s.conf = tc.conf()
|
s.conf = tc.conf()
|
||||||
s.handleGetConfig(w, nil)
|
s.handleGetConfig(w, nil)
|
||||||
|
|
||||||
cType := w.Header().Get(aghhttp.HdrNameContentType)
|
cType := w.Header().Get(httphdr.ContentType)
|
||||||
assert.Equal(t, aghhttp.HdrValApplicationJSON, cType)
|
assert.Equal(t, aghhttp.HdrValApplicationJSON, cType)
|
||||||
assert.JSONEq(t, string(caseWant), w.Body.String())
|
assert.JSONEq(t, string(caseWant), w.Body.String())
|
||||||
})
|
})
|
||||||
@@ -204,8 +205,8 @@ func TestDNSForwardHTTP_handleSetConfig(t *testing.T) {
|
|||||||
wantSet: `validating upstream servers: validating upstream "!!!": not an ip:port`,
|
wantSet: `validating upstream servers: validating upstream "!!!": not an ip:port`,
|
||||||
}, {
|
}, {
|
||||||
name: "bootstraps_bad",
|
name: "bootstraps_bad",
|
||||||
wantSet: `checking bootstrap a: invalid address: ` +
|
wantSet: `checking bootstrap a: invalid address: bootstrap a:53: ` +
|
||||||
`Resolver a is not eligible to be a bootstrap DNS server`,
|
`ParseAddr("a"): unable to parse IP`,
|
||||||
}, {
|
}, {
|
||||||
name: "cache_bad_ttl",
|
name: "cache_bad_ttl",
|
||||||
wantSet: `cache_ttl_min must be less or equal than cache_ttl_max`,
|
wantSet: `cache_ttl_min must be less or equal than cache_ttl_max`,
|
||||||
|
|||||||
@@ -40,12 +40,17 @@ func (s *Server) processQueryLogsAndStats(dctx *dnsContext) (rc resultCode) {
|
|||||||
|
|
||||||
log.Debug("client ip: %s", ip)
|
log.Debug("client ip: %s", ip)
|
||||||
|
|
||||||
|
ipStr := ip.String()
|
||||||
|
ids := []string{ipStr, dctx.clientID}
|
||||||
|
|
||||||
// Synchronize access to s.queryLog and s.stats so they won't be suddenly
|
// Synchronize access to s.queryLog and s.stats so they won't be suddenly
|
||||||
// uninitialized while in use. This can happen after proxy server has been
|
// uninitialized while in use. This can happen after proxy server has been
|
||||||
// stopped, but its workers haven't yet exited.
|
// stopped, but its workers haven't yet exited.
|
||||||
if shouldLog &&
|
if shouldLog &&
|
||||||
s.queryLog != nil &&
|
s.queryLog != nil &&
|
||||||
s.queryLog.ShouldLog(host, q.Qtype, q.Qclass) {
|
// TODO(s.chzhen): Use dnsforward.dnsContext when it will start
|
||||||
|
// containing persistent client.
|
||||||
|
s.queryLog.ShouldLog(host, q.Qtype, q.Qclass, ids) {
|
||||||
s.logQuery(dctx, pctx, elapsed, ip)
|
s.logQuery(dctx, pctx, elapsed, ip)
|
||||||
} else {
|
} else {
|
||||||
log.Debug(
|
log.Debug(
|
||||||
@@ -56,8 +61,11 @@ func (s *Server) processQueryLogsAndStats(dctx *dnsContext) (rc resultCode) {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
if s.stats != nil && s.stats.ShouldCount(host, q.Qtype, q.Qclass) {
|
if s.stats != nil &&
|
||||||
s.updateStats(dctx, elapsed, *dctx.result, ip)
|
// TODO(s.chzhen): Use dnsforward.dnsContext when it will start
|
||||||
|
// containing persistent client.
|
||||||
|
s.stats.ShouldCount(host, q.Qtype, q.Qclass, ids) {
|
||||||
|
s.updateStats(dctx, elapsed, *dctx.result, ipStr)
|
||||||
}
|
}
|
||||||
|
|
||||||
return resultCodeSuccess
|
return resultCodeSuccess
|
||||||
@@ -110,7 +118,7 @@ func (s *Server) updateStats(
|
|||||||
ctx *dnsContext,
|
ctx *dnsContext,
|
||||||
elapsed time.Duration,
|
elapsed time.Duration,
|
||||||
res filtering.Result,
|
res filtering.Result,
|
||||||
clientIP net.IP,
|
clientIP string,
|
||||||
) {
|
) {
|
||||||
pctx := ctx.proxyCtx
|
pctx := ctx.proxyCtx
|
||||||
e := stats.Entry{}
|
e := stats.Entry{}
|
||||||
@@ -119,8 +127,8 @@ func (s *Server) updateStats(
|
|||||||
|
|
||||||
if clientID := ctx.clientID; clientID != "" {
|
if clientID := ctx.clientID; clientID != "" {
|
||||||
e.Client = clientID
|
e.Client = clientID
|
||||||
} else if clientIP != nil {
|
} else {
|
||||||
e.Client = clientIP.String()
|
e.Client = clientIP
|
||||||
}
|
}
|
||||||
|
|
||||||
e.Time = uint32(elapsed / 1000)
|
e.Time = uint32(elapsed / 1000)
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ func (l *testQueryLog) Add(p *querylog.AddParams) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ShouldLog implements the [querylog.QueryLog] interface for *testQueryLog.
|
// ShouldLog implements the [querylog.QueryLog] interface for *testQueryLog.
|
||||||
func (l *testQueryLog) ShouldLog(string, uint16, uint16) bool {
|
func (l *testQueryLog) ShouldLog(string, uint16, uint16, []string) bool {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -50,7 +50,7 @@ func (l *testStats) Update(e stats.Entry) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ShouldCount implements the [stats.Interface] interface for *testStats.
|
// ShouldCount implements the [stats.Interface] interface for *testStats.
|
||||||
func (l *testStats) ShouldCount(string, uint16, uint16) bool {
|
func (l *testStats) ShouldCount(string, uint16, uint16, []string) bool {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package filtering
|
|||||||
import (
|
import (
|
||||||
"github.com/AdguardTeam/urlfilter/rules"
|
"github.com/AdguardTeam/urlfilter/rules"
|
||||||
"github.com/miekg/dns"
|
"github.com/miekg/dns"
|
||||||
|
"golang.org/x/exp/slices"
|
||||||
)
|
)
|
||||||
|
|
||||||
// DNSRewriteResult is the result of application of $dnsrewrite rules.
|
// DNSRewriteResult is the result of application of $dnsrewrite rules.
|
||||||
@@ -24,7 +25,13 @@ func (d *DNSFilter) processDNSRewrites(dnsr []*rules.NetworkRule) (res Result) {
|
|||||||
Response: DNSRewriteResultResponse{},
|
Response: DNSRewriteResultResponse{},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, nr := range dnsr {
|
slices.SortFunc(dnsr, rewriteSortsBefore)
|
||||||
|
|
||||||
|
for i, nr := range dnsr {
|
||||||
|
if i > 0 && containsWildcard(nr) {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
dr := nr.DNSRewrite
|
dr := nr.DNSRewrite
|
||||||
if dr.NewCNAME != "" {
|
if dr.NewCNAME != "" {
|
||||||
// NewCNAME rules have a higher priority than other rules.
|
// NewCNAME rules have a higher priority than other rules.
|
||||||
@@ -73,3 +80,19 @@ func (d *DNSFilter) processDNSRewrites(dnsr []*rules.NetworkRule) (res Result) {
|
|||||||
Reason: RewrittenRule,
|
Reason: RewrittenRule,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func rewriteSortsBefore(a, b *rules.NetworkRule) (sortsBefore bool) {
|
||||||
|
return len(a.Shortcut) > len(b.Shortcut)
|
||||||
|
}
|
||||||
|
|
||||||
|
func containsWildcard(r *rules.NetworkRule) (ok bool) {
|
||||||
|
for _, c := range r.RuleText {
|
||||||
|
if c == '*' {
|
||||||
|
return true
|
||||||
|
} else if c == '^' {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import (
|
|||||||
"path"
|
"path"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/AdguardTeam/urlfilter"
|
||||||
"github.com/miekg/dns"
|
"github.com/miekg/dns"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
@@ -202,3 +203,32 @@ func TestDNSFilter_CheckHostRules_dnsrewrite(t *testing.T) {
|
|||||||
assert.Equal(t, "new-ptr-with-dot.", ptr)
|
assert.Equal(t, "new-ptr-with-dot.", ptr)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestDNSFilter_ProcessDNSRewrites(t *testing.T) {
|
||||||
|
const text = `
|
||||||
|
|www.example.com^$dnsrewrite=127.0.0.1
|
||||||
|
|*.example.com^$dnsrewrite=127.0.0.2
|
||||||
|
`
|
||||||
|
|
||||||
|
host := "www.example.com"
|
||||||
|
rrtype := dns.TypeA
|
||||||
|
|
||||||
|
f, _ := newForTest(t, nil, []Filter{{ID: 0, Data: []byte(text)}})
|
||||||
|
setts := &Settings{
|
||||||
|
FilteringEnabled: true,
|
||||||
|
}
|
||||||
|
|
||||||
|
ufReq := &urlfilter.DNSRequest{
|
||||||
|
Hostname: host,
|
||||||
|
SortedClientTags: setts.ClientTags,
|
||||||
|
ClientIP: setts.ClientIP.String(),
|
||||||
|
ClientName: setts.ClientName,
|
||||||
|
DNSType: rrtype,
|
||||||
|
}
|
||||||
|
|
||||||
|
dres, matched := f.filteringEngine.MatchRequest(ufReq)
|
||||||
|
require.False(t, matched)
|
||||||
|
|
||||||
|
res := f.processDNSResultRewrites(dres, host)
|
||||||
|
assert.Len(t, res.Rules, 1)
|
||||||
|
}
|
||||||
|
|||||||
@@ -18,8 +18,6 @@ import (
|
|||||||
|
|
||||||
"github.com/AdguardTeam/AdGuardHome/internal/aghhttp"
|
"github.com/AdguardTeam/AdGuardHome/internal/aghhttp"
|
||||||
"github.com/AdguardTeam/AdGuardHome/internal/aghnet"
|
"github.com/AdguardTeam/AdGuardHome/internal/aghnet"
|
||||||
"github.com/AdguardTeam/dnsproxy/upstream"
|
|
||||||
"github.com/AdguardTeam/golibs/cache"
|
|
||||||
"github.com/AdguardTeam/golibs/errors"
|
"github.com/AdguardTeam/golibs/errors"
|
||||||
"github.com/AdguardTeam/golibs/log"
|
"github.com/AdguardTeam/golibs/log"
|
||||||
"github.com/AdguardTeam/golibs/mathutil"
|
"github.com/AdguardTeam/golibs/mathutil"
|
||||||
@@ -75,6 +73,12 @@ type Resolver interface {
|
|||||||
|
|
||||||
// Config allows you to configure DNS filtering with New() or just change variables directly.
|
// Config allows you to configure DNS filtering with New() or just change variables directly.
|
||||||
type Config struct {
|
type Config struct {
|
||||||
|
// SafeBrowsingChecker is the safe browsing hash-prefix checker.
|
||||||
|
SafeBrowsingChecker Checker `yaml:"-"`
|
||||||
|
|
||||||
|
// ParentControl is the parental control hash-prefix checker.
|
||||||
|
ParentalControlChecker Checker `yaml:"-"`
|
||||||
|
|
||||||
// enabled is used to be returned within Settings.
|
// enabled is used to be returned within Settings.
|
||||||
//
|
//
|
||||||
// It is of type uint32 to be accessed by atomic.
|
// It is of type uint32 to be accessed by atomic.
|
||||||
@@ -158,8 +162,22 @@ type hostChecker struct {
|
|||||||
name string
|
name string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Checker is used for safe browsing or parental control hash-prefix filtering.
|
||||||
|
type Checker interface {
|
||||||
|
// Check returns true if request for the host should be blocked.
|
||||||
|
Check(host string) (block bool, err error)
|
||||||
|
}
|
||||||
|
|
||||||
// DNSFilter matches hostnames and DNS requests against filtering rules.
|
// DNSFilter matches hostnames and DNS requests against filtering rules.
|
||||||
type DNSFilter struct {
|
type DNSFilter struct {
|
||||||
|
safeSearch SafeSearch
|
||||||
|
|
||||||
|
// safeBrowsingChecker is the safe browsing hash-prefix checker.
|
||||||
|
safeBrowsingChecker Checker
|
||||||
|
|
||||||
|
// parentalControl is the parental control hash-prefix checker.
|
||||||
|
parentalControlChecker Checker
|
||||||
|
|
||||||
rulesStorage *filterlist.RuleStorage
|
rulesStorage *filterlist.RuleStorage
|
||||||
filteringEngine *urlfilter.DNSEngine
|
filteringEngine *urlfilter.DNSEngine
|
||||||
|
|
||||||
@@ -168,14 +186,6 @@ type DNSFilter struct {
|
|||||||
|
|
||||||
engineLock sync.RWMutex
|
engineLock sync.RWMutex
|
||||||
|
|
||||||
parentalServer string // access via methods
|
|
||||||
safeBrowsingServer string // access via methods
|
|
||||||
parentalUpstream upstream.Upstream
|
|
||||||
safeBrowsingUpstream upstream.Upstream
|
|
||||||
|
|
||||||
safebrowsingCache cache.Cache
|
|
||||||
parentalCache cache.Cache
|
|
||||||
|
|
||||||
Config // for direct access by library users, even a = assignment
|
Config // for direct access by library users, even a = assignment
|
||||||
// confLock protects Config.
|
// confLock protects Config.
|
||||||
confLock sync.RWMutex
|
confLock sync.RWMutex
|
||||||
@@ -192,7 +202,6 @@ type DNSFilter struct {
|
|||||||
// TODO(e.burkov): Don't use regexp for such a simple text processing task.
|
// TODO(e.burkov): Don't use regexp for such a simple text processing task.
|
||||||
filterTitleRegexp *regexp.Regexp
|
filterTitleRegexp *regexp.Regexp
|
||||||
|
|
||||||
safeSearch SafeSearch
|
|
||||||
hostCheckers []hostChecker
|
hostCheckers []hostChecker
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -940,19 +949,12 @@ func InitModule() {
|
|||||||
// be non-nil.
|
// be non-nil.
|
||||||
func New(c *Config, blockFilters []Filter) (d *DNSFilter, err error) {
|
func New(c *Config, blockFilters []Filter) (d *DNSFilter, err error) {
|
||||||
d = &DNSFilter{
|
d = &DNSFilter{
|
||||||
refreshLock: &sync.Mutex{},
|
refreshLock: &sync.Mutex{},
|
||||||
filterTitleRegexp: regexp.MustCompile(`^! Title: +(.*)$`),
|
filterTitleRegexp: regexp.MustCompile(`^! Title: +(.*)$`),
|
||||||
|
safeBrowsingChecker: c.SafeBrowsingChecker,
|
||||||
|
parentalControlChecker: c.ParentalControlChecker,
|
||||||
}
|
}
|
||||||
|
|
||||||
d.safebrowsingCache = cache.New(cache.Config{
|
|
||||||
EnableLRU: true,
|
|
||||||
MaxSize: c.SafeBrowsingCacheSize,
|
|
||||||
})
|
|
||||||
d.parentalCache = cache.New(cache.Config{
|
|
||||||
EnableLRU: true,
|
|
||||||
MaxSize: c.ParentalCacheSize,
|
|
||||||
})
|
|
||||||
|
|
||||||
d.safeSearch = c.SafeSearch
|
d.safeSearch = c.SafeSearch
|
||||||
|
|
||||||
d.hostCheckers = []hostChecker{{
|
d.hostCheckers = []hostChecker{{
|
||||||
@@ -977,11 +979,6 @@ func New(c *Config, blockFilters []Filter) (d *DNSFilter, err error) {
|
|||||||
|
|
||||||
defer func() { err = errors.Annotate(err, "filtering: %w") }()
|
defer func() { err = errors.Annotate(err, "filtering: %w") }()
|
||||||
|
|
||||||
err = d.initSecurityServices()
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("initializing services: %s", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
d.Config = *c
|
d.Config = *c
|
||||||
d.filtersMu = &sync.RWMutex{}
|
d.filtersMu = &sync.RWMutex{}
|
||||||
|
|
||||||
@@ -1038,3 +1035,69 @@ func (d *DNSFilter) Start() {
|
|||||||
// So for now we just start this periodic task from here.
|
// So for now we just start this periodic task from here.
|
||||||
go d.periodicallyRefreshFilters()
|
go d.periodicallyRefreshFilters()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Safe browsing and parental control methods.
|
||||||
|
|
||||||
|
// TODO(a.garipov): Unify with checkParental.
|
||||||
|
func (d *DNSFilter) checkSafeBrowsing(
|
||||||
|
host string,
|
||||||
|
_ uint16,
|
||||||
|
setts *Settings,
|
||||||
|
) (res Result, err error) {
|
||||||
|
if !setts.ProtectionEnabled || !setts.SafeBrowsingEnabled {
|
||||||
|
return Result{}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if log.GetLevel() >= log.DEBUG {
|
||||||
|
timer := log.StartTimer()
|
||||||
|
defer timer.LogElapsed("safebrowsing lookup for %q", host)
|
||||||
|
}
|
||||||
|
|
||||||
|
res = Result{
|
||||||
|
Rules: []*ResultRule{{
|
||||||
|
Text: "adguard-malware-shavar",
|
||||||
|
FilterListID: SafeBrowsingListID,
|
||||||
|
}},
|
||||||
|
Reason: FilteredSafeBrowsing,
|
||||||
|
IsFiltered: true,
|
||||||
|
}
|
||||||
|
|
||||||
|
block, err := d.safeBrowsingChecker.Check(host)
|
||||||
|
if !block || err != nil {
|
||||||
|
return Result{}, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return res, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO(a.garipov): Unify with checkSafeBrowsing.
|
||||||
|
func (d *DNSFilter) checkParental(
|
||||||
|
host string,
|
||||||
|
_ uint16,
|
||||||
|
setts *Settings,
|
||||||
|
) (res Result, err error) {
|
||||||
|
if !setts.ProtectionEnabled || !setts.ParentalEnabled {
|
||||||
|
return Result{}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if log.GetLevel() >= log.DEBUG {
|
||||||
|
timer := log.StartTimer()
|
||||||
|
defer timer.LogElapsed("parental lookup for %q", host)
|
||||||
|
}
|
||||||
|
|
||||||
|
res = Result{
|
||||||
|
Rules: []*ResultRule{{
|
||||||
|
Text: "parental CATEGORY_BLACKLISTED",
|
||||||
|
FilterListID: ParentalListID,
|
||||||
|
}},
|
||||||
|
Reason: FilteredParental,
|
||||||
|
IsFiltered: true,
|
||||||
|
}
|
||||||
|
|
||||||
|
block, err := d.parentalControlChecker.Check(host)
|
||||||
|
if !block || err != nil {
|
||||||
|
return Result{}, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return res, nil
|
||||||
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/AdguardTeam/AdGuardHome/internal/aghtest"
|
"github.com/AdguardTeam/AdGuardHome/internal/aghtest"
|
||||||
"github.com/AdguardTeam/golibs/cache"
|
"github.com/AdguardTeam/AdGuardHome/internal/filtering/hashprefix"
|
||||||
"github.com/AdguardTeam/golibs/log"
|
"github.com/AdguardTeam/golibs/log"
|
||||||
"github.com/AdguardTeam/golibs/testutil"
|
"github.com/AdguardTeam/golibs/testutil"
|
||||||
"github.com/AdguardTeam/urlfilter/rules"
|
"github.com/AdguardTeam/urlfilter/rules"
|
||||||
@@ -27,17 +27,6 @@ const (
|
|||||||
|
|
||||||
// Helpers.
|
// Helpers.
|
||||||
|
|
||||||
func purgeCaches(d *DNSFilter) {
|
|
||||||
for _, c := range []cache.Cache{
|
|
||||||
d.safebrowsingCache,
|
|
||||||
d.parentalCache,
|
|
||||||
} {
|
|
||||||
if c != nil {
|
|
||||||
c.Clear()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func newForTest(t testing.TB, c *Config, filters []Filter) (f *DNSFilter, setts *Settings) {
|
func newForTest(t testing.TB, c *Config, filters []Filter) (f *DNSFilter, setts *Settings) {
|
||||||
setts = &Settings{
|
setts = &Settings{
|
||||||
ProtectionEnabled: true,
|
ProtectionEnabled: true,
|
||||||
@@ -58,11 +47,17 @@ func newForTest(t testing.TB, c *Config, filters []Filter) (f *DNSFilter, setts
|
|||||||
f, err := New(c, filters)
|
f, err := New(c, filters)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
purgeCaches(f)
|
|
||||||
|
|
||||||
return f, setts
|
return f, setts
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func newChecker(host string) Checker {
|
||||||
|
return hashprefix.New(&hashprefix.Config{
|
||||||
|
CacheTime: 10,
|
||||||
|
CacheSize: 100000,
|
||||||
|
Upstream: aghtest.NewBlockUpstream(host, true),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
func (d *DNSFilter) checkMatch(t *testing.T, hostname string, setts *Settings) {
|
func (d *DNSFilter) checkMatch(t *testing.T, hostname string, setts *Settings) {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
|
|
||||||
@@ -175,10 +170,14 @@ func TestSafeBrowsing(t *testing.T) {
|
|||||||
aghtest.ReplaceLogWriter(t, logOutput)
|
aghtest.ReplaceLogWriter(t, logOutput)
|
||||||
aghtest.ReplaceLogLevel(t, log.DEBUG)
|
aghtest.ReplaceLogLevel(t, log.DEBUG)
|
||||||
|
|
||||||
d, setts := newForTest(t, &Config{SafeBrowsingEnabled: true}, nil)
|
sbChecker := newChecker(sbBlocked)
|
||||||
|
|
||||||
|
d, setts := newForTest(t, &Config{
|
||||||
|
SafeBrowsingEnabled: true,
|
||||||
|
SafeBrowsingChecker: sbChecker,
|
||||||
|
}, nil)
|
||||||
t.Cleanup(d.Close)
|
t.Cleanup(d.Close)
|
||||||
|
|
||||||
d.SetSafeBrowsingUpstream(aghtest.NewBlockUpstream(sbBlocked, true))
|
|
||||||
d.checkMatch(t, sbBlocked, setts)
|
d.checkMatch(t, sbBlocked, setts)
|
||||||
|
|
||||||
require.Contains(t, logOutput.String(), fmt.Sprintf("safebrowsing lookup for %q", sbBlocked))
|
require.Contains(t, logOutput.String(), fmt.Sprintf("safebrowsing lookup for %q", sbBlocked))
|
||||||
@@ -188,18 +187,17 @@ func TestSafeBrowsing(t *testing.T) {
|
|||||||
d.checkMatchEmpty(t, pcBlocked, setts)
|
d.checkMatchEmpty(t, pcBlocked, setts)
|
||||||
|
|
||||||
// Cached result.
|
// Cached result.
|
||||||
d.safeBrowsingServer = "127.0.0.1"
|
|
||||||
d.checkMatch(t, sbBlocked, setts)
|
d.checkMatch(t, sbBlocked, setts)
|
||||||
d.checkMatchEmpty(t, pcBlocked, setts)
|
d.checkMatchEmpty(t, pcBlocked, setts)
|
||||||
d.safeBrowsingServer = defaultSafebrowsingServer
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestParallelSB(t *testing.T) {
|
func TestParallelSB(t *testing.T) {
|
||||||
d, setts := newForTest(t, &Config{SafeBrowsingEnabled: true}, nil)
|
d, setts := newForTest(t, &Config{
|
||||||
|
SafeBrowsingEnabled: true,
|
||||||
|
SafeBrowsingChecker: newChecker(sbBlocked),
|
||||||
|
}, nil)
|
||||||
t.Cleanup(d.Close)
|
t.Cleanup(d.Close)
|
||||||
|
|
||||||
d.SetSafeBrowsingUpstream(aghtest.NewBlockUpstream(sbBlocked, true))
|
|
||||||
|
|
||||||
t.Run("group", func(t *testing.T) {
|
t.Run("group", func(t *testing.T) {
|
||||||
for i := 0; i < 100; i++ {
|
for i := 0; i < 100; i++ {
|
||||||
t.Run(fmt.Sprintf("aaa%d", i), func(t *testing.T) {
|
t.Run(fmt.Sprintf("aaa%d", i), func(t *testing.T) {
|
||||||
@@ -220,10 +218,12 @@ func TestParentalControl(t *testing.T) {
|
|||||||
aghtest.ReplaceLogWriter(t, logOutput)
|
aghtest.ReplaceLogWriter(t, logOutput)
|
||||||
aghtest.ReplaceLogLevel(t, log.DEBUG)
|
aghtest.ReplaceLogLevel(t, log.DEBUG)
|
||||||
|
|
||||||
d, setts := newForTest(t, &Config{ParentalEnabled: true}, nil)
|
d, setts := newForTest(t, &Config{
|
||||||
|
ParentalEnabled: true,
|
||||||
|
ParentalControlChecker: newChecker(pcBlocked),
|
||||||
|
}, nil)
|
||||||
t.Cleanup(d.Close)
|
t.Cleanup(d.Close)
|
||||||
|
|
||||||
d.SetParentalUpstream(aghtest.NewBlockUpstream(pcBlocked, true))
|
|
||||||
d.checkMatch(t, pcBlocked, setts)
|
d.checkMatch(t, pcBlocked, setts)
|
||||||
require.Contains(t, logOutput.String(), fmt.Sprintf("parental lookup for %q", pcBlocked))
|
require.Contains(t, logOutput.String(), fmt.Sprintf("parental lookup for %q", pcBlocked))
|
||||||
|
|
||||||
@@ -233,7 +233,6 @@ func TestParentalControl(t *testing.T) {
|
|||||||
d.checkMatchEmpty(t, "api.jquery.com", setts)
|
d.checkMatchEmpty(t, "api.jquery.com", setts)
|
||||||
|
|
||||||
// Test cached result.
|
// Test cached result.
|
||||||
d.parentalServer = "127.0.0.1"
|
|
||||||
d.checkMatch(t, pcBlocked, setts)
|
d.checkMatch(t, pcBlocked, setts)
|
||||||
d.checkMatchEmpty(t, "yandex.ru", setts)
|
d.checkMatchEmpty(t, "yandex.ru", setts)
|
||||||
}
|
}
|
||||||
@@ -593,8 +592,10 @@ func applyClientSettings(setts *Settings) {
|
|||||||
func TestClientSettings(t *testing.T) {
|
func TestClientSettings(t *testing.T) {
|
||||||
d, setts := newForTest(t,
|
d, setts := newForTest(t,
|
||||||
&Config{
|
&Config{
|
||||||
ParentalEnabled: true,
|
ParentalEnabled: true,
|
||||||
SafeBrowsingEnabled: false,
|
SafeBrowsingEnabled: false,
|
||||||
|
SafeBrowsingChecker: newChecker(sbBlocked),
|
||||||
|
ParentalControlChecker: newChecker(pcBlocked),
|
||||||
},
|
},
|
||||||
[]Filter{{
|
[]Filter{{
|
||||||
ID: 0, Data: []byte("||example.org^\n"),
|
ID: 0, Data: []byte("||example.org^\n"),
|
||||||
@@ -602,9 +603,6 @@ func TestClientSettings(t *testing.T) {
|
|||||||
)
|
)
|
||||||
t.Cleanup(d.Close)
|
t.Cleanup(d.Close)
|
||||||
|
|
||||||
d.SetParentalUpstream(aghtest.NewBlockUpstream(pcBlocked, true))
|
|
||||||
d.SetSafeBrowsingUpstream(aghtest.NewBlockUpstream(sbBlocked, true))
|
|
||||||
|
|
||||||
type testCase struct {
|
type testCase struct {
|
||||||
name string
|
name string
|
||||||
host string
|
host string
|
||||||
@@ -665,11 +663,12 @@ func TestClientSettings(t *testing.T) {
|
|||||||
// Benchmarks.
|
// Benchmarks.
|
||||||
|
|
||||||
func BenchmarkSafeBrowsing(b *testing.B) {
|
func BenchmarkSafeBrowsing(b *testing.B) {
|
||||||
d, setts := newForTest(b, &Config{SafeBrowsingEnabled: true}, nil)
|
d, setts := newForTest(b, &Config{
|
||||||
|
SafeBrowsingEnabled: true,
|
||||||
|
SafeBrowsingChecker: newChecker(sbBlocked),
|
||||||
|
}, nil)
|
||||||
b.Cleanup(d.Close)
|
b.Cleanup(d.Close)
|
||||||
|
|
||||||
d.SetSafeBrowsingUpstream(aghtest.NewBlockUpstream(sbBlocked, true))
|
|
||||||
|
|
||||||
for n := 0; n < b.N; n++ {
|
for n := 0; n < b.N; n++ {
|
||||||
res, err := d.CheckHost(sbBlocked, dns.TypeA, setts)
|
res, err := d.CheckHost(sbBlocked, dns.TypeA, setts)
|
||||||
require.NoError(b, err)
|
require.NoError(b, err)
|
||||||
@@ -679,11 +678,12 @@ func BenchmarkSafeBrowsing(b *testing.B) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func BenchmarkSafeBrowsingParallel(b *testing.B) {
|
func BenchmarkSafeBrowsingParallel(b *testing.B) {
|
||||||
d, setts := newForTest(b, &Config{SafeBrowsingEnabled: true}, nil)
|
d, setts := newForTest(b, &Config{
|
||||||
|
SafeBrowsingEnabled: true,
|
||||||
|
SafeBrowsingChecker: newChecker(sbBlocked),
|
||||||
|
}, nil)
|
||||||
b.Cleanup(d.Close)
|
b.Cleanup(d.Close)
|
||||||
|
|
||||||
d.SetSafeBrowsingUpstream(aghtest.NewBlockUpstream(sbBlocked, true))
|
|
||||||
|
|
||||||
b.RunParallel(func(pb *testing.PB) {
|
b.RunParallel(func(pb *testing.PB) {
|
||||||
for pb.Next() {
|
for pb.Next() {
|
||||||
res, err := d.CheckHost(sbBlocked, dns.TypeA, setts)
|
res, err := d.CheckHost(sbBlocked, dns.TypeA, setts)
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user