Skip to content

Commit

Permalink
Pull request: all: use "ClientID" consistently
Browse files Browse the repository at this point in the history
Closes AdguardTeam#4242.
Updates AdguardTeam#4244.

Squashed commit of the following:

commit 3a2296a
Author: Ainar Garipov <[email protected]>
Date:   Wed Feb 9 21:23:43 2022 +0300

    client: imp more

commit 3aacc86
Merge: b28a120 2a5b5f1
Author: Ainar Garipov <[email protected]>
Date:   Wed Feb 9 21:21:59 2022 +0300

    Merge branch 'master' into 4244-imp-i18n

commit b28a120
Author: Ainar Garipov <[email protected]>
Date:   Wed Feb 9 14:49:49 2022 +0300

    client: imp texts more

commit c1fa6ca
Author: Ainar Garipov <[email protected]>
Date:   Tue Feb 8 21:12:15 2022 +0300

    all: use "ClientID" consistently
  • Loading branch information
ainar-g committed Feb 10, 2022
1 parent 2a5b5f1 commit f53f48c
Show file tree
Hide file tree
Showing 21 changed files with 141 additions and 142 deletions.
8 changes: 4 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ See also the [v0.107.0 GitHub milestone][ms-v0.107.0].
- Static IP address detection on FreeBSD ([#3289]).
- Optimistic cache ([#2145]).
- New possible value of `6h` for `querylog_interval` setting ([#2504]).
- Blocking access using client IDs ([#2624], [#3162]).
- Blocking access using ClientIDs ([#2624], [#3162]).
- `source` directives support in `/etc/network/interfaces` on Linux ([#3257]).
- RFC 9000 support in DNS-over-QUIC.
- Completely disabling statistics by setting the statistics interval to zero
Expand Down Expand Up @@ -317,7 +317,7 @@ In this release, the schema version has changed from 10 to 12.
- Occasional panics when reading old statistics databases ([#3506]).
- `reload` service action on macOS and FreeBSD ([#3457]).
- Inaccurate using of service actions in the installation script ([#3450]).
- Client ID checking ([#3437]).
- ClientID checking ([#3437]).
- Discovering other DHCP servers on `darwin` and `freebsd` ([#3417]).
- Switching listening address to unspecified one when bound to a single
specified IPv4 address on Darwin (macOS) ([#2807]).
Expand All @@ -334,7 +334,7 @@ In this release, the schema version has changed from 10 to 12.
- Redundant hostname generating while loading static leases with empty hostname
([#3166]).
- Domain name case in responses ([#3194]).
- Custom upstreams selection for clients with client IDs in DNS-over-TLS and
- Custom upstreams selection for clients with ClientIDs in DNS-over-TLS and
DNS-over-HTTP ([#3186]).
- Incorrect client-based filtering applying logic ([#2875]).

Expand Down Expand Up @@ -668,7 +668,7 @@ See also the [v0.105.0 GitHub milestone][ms-v0.105.0].

- Added more services to the "Blocked services" list ([#2224], [#2401]).
- `ipset` subdomain matching, just like `dnsmasq` does ([#2179]).
- Client ID support for DNS-over-HTTPS, DNS-over-QUIC, and DNS-over-TLS
- ClientID support for DNS-over-HTTPS, DNS-over-QUIC, and DNS-over-TLS
([#1383]).
- `$dnsrewrite` modifier for filters ([#2102]).
- The host checking API and the query logs API can now return multiple matched
Expand Down
97 changes: 48 additions & 49 deletions client/src/__locales/en.json

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions client/src/components/Filters/Examples.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,27 @@ const Examples = () => (
<Trans>examples_title</Trans>:
<ol className="leading-loose">
<li>
<code>||example.org^</code> –&nbsp;
<code>||example.org^</code>:
<Trans>example_meaning_filter_block</Trans>
</li>
<li>
<code> @@||example.org^</code> –&nbsp;
<code> @@||example.org^</code>:
<Trans>example_meaning_filter_whitelist</Trans>
</li>
<li>
<code>127.0.0.1 example.org</code> –&nbsp;
<code>127.0.0.1 example.org</code>:
<Trans>example_meaning_host_block</Trans>
</li>
<li>
<code><Trans>example_comment</Trans></code> –&nbsp;
<code><Trans>example_comment</Trans></code>:
<Trans>example_comment_meaning</Trans>
</li>
<li>
<code><Trans>example_comment_hash</Trans></code> –&nbsp;
<code><Trans>example_comment_hash</Trans></code>:
<Trans>example_comment_meaning</Trans>
</li>
<li>
<code>/REGEX/</code> –&nbsp;
<code>/REGEX/</code>:
<Trans>example_regex_meaning</Trans>
</li>
</ol>
Expand Down
10 changes: 5 additions & 5 deletions client/src/components/Settings/Clients/Form.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
renderServiceField,
} from '../../../helpers/form';
import { validateClientId, validateRequiredValue } from '../../../helpers/validators';
import { FORM_NAME, SERVICES } from '../../../helpers/constants';
import { CLIENT_ID_LINK, FORM_NAME, SERVICES } from '../../../helpers/constants';
import './Service.css';

const settingsCheckboxes = [
Expand Down Expand Up @@ -281,11 +281,11 @@ let Form = (props) => {
</div>
<div className="form__desc mt-0">
<Trans
components={[
<a href="https://github.com/AdguardTeam/AdGuardHome/wiki/Clients#idclient" key="0" target="_blank" rel="noopener noreferrer">
link
components={{
a: <a href={CLIENT_ID_LINK} target="_blank" rel="noopener noreferrer">
text
</a>,
]}
}}
>
client_identifier_desc
</Trans>
Expand Down
4 changes: 2 additions & 2 deletions client/src/components/Settings/Dns/Access/Form.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
trimMultilineString,
removeEmptyLines,
} from '../../../../helpers/helpers';
import { FORM_NAME } from '../../../../helpers/constants';
import { CLIENT_ID_LINK, FORM_NAME } from '../../../../helpers/constants';

const fields = [
{
Expand Down Expand Up @@ -48,7 +48,7 @@ let Form = (props) => {
</>}
</label>
<div className="form__desc form__desc--top">
<Trans>{subtitle}</Trans>
<Trans components={{ a: <a href={CLIENT_ID_LINK} target="_blank" rel="noopener noreferrer">text</a> }}>{subtitle}</Trans>
</div>
<Field
id={id}
Expand Down
18 changes: 8 additions & 10 deletions client/src/components/Settings/Dns/Upstream/Examples.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ const Examples = (props) => (
<Trans>examples_title</Trans>:
<ol className="leading-loose">
<li>
<code>94.140.14.140</code> - {props.t('example_upstream_regular')}
<code>94.140.14.140</code>: {props.t('example_upstream_regular')}
</li>
<li>
<code>tls://dns-unfiltered.adguard.com</code> –&nbsp;
<code>tls://dns-unfiltered.adguard.com</code>:
<span>
<Trans
components={[
Expand All @@ -30,7 +30,7 @@ const Examples = (props) => (
</span>
</li>
<li>
<code>https://dns-unfiltered.adguard.com/dns-query</code> –&nbsp;
<code>https://dns-unfiltered.adguard.com/dns-query</code>:
<span>
<Trans
components={[
Expand All @@ -49,7 +49,7 @@ const Examples = (props) => (
</span>
</li>
<li>
<code>quic://dns-unfiltered.adguard.com:784</code> –&nbsp;
<code>quic://dns-unfiltered.adguard.com:784</code>:
<span>
<Trans
components={[
Expand All @@ -65,15 +65,13 @@ const Examples = (props) => (
>
example_upstream_doq
</Trans>
&nbsp;
<span className="text-lowercase">(<Trans>experimental</Trans>)</span>
</span>
</li>
<li>
<code>tcp://94.140.14.140</code> <Trans>example_upstream_tcp</Trans>
<code>tcp://94.140.14.140</code>: <Trans>example_upstream_tcp</Trans>
</li>
<li>
<code>sdns://...</code> –&nbsp;
<code>sdns://...</code>:
<span>
<Trans
components={[
Expand Down Expand Up @@ -108,7 +106,7 @@ const Examples = (props) => (
</span>
</li>
<li>
<code>[/example.local/]94.140.14.140</code> –&nbsp;
<code>[/example.local/]94.140.14.140</code>:
<span>
<Trans
components={[
Expand All @@ -127,7 +125,7 @@ const Examples = (props) => (
</span>
</li>
<li>
<code>{COMMENT_LINE_DEFAULT_TOKEN} comment</code> –&nbsp;
<code>{COMMENT_LINE_DEFAULT_TOKEN} comment</code>:
<span>
<Trans>example_upstream_comment</Trans>
</span>
Expand Down
2 changes: 0 additions & 2 deletions client/src/components/Settings/Encryption/Form.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,6 @@ let Form = (props) => {
<div className="form__group form__group--settings">
<label className="form__label" htmlFor="port_dns_over_quic">
<Trans>encryption_doq</Trans>
&nbsp;
<span className="text-lowercase">(<Trans>experimental</Trans>)</span>
</label>
<Field
id="port_dns_over_quic"
Expand Down
9 changes: 7 additions & 2 deletions client/src/components/ui/Guide/MobileConfigForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@ import i18next from 'i18next';
import cn from 'classnames';

import { getPathWithQueryString } from '../../../helpers/helpers';
import { FORM_NAME, MOBILE_CONFIG_LINKS, STANDARD_HTTPS_PORT } from '../../../helpers/constants';
import {
CLIENT_ID_LINK,
FORM_NAME,
MOBILE_CONFIG_LINKS,
STANDARD_HTTPS_PORT,
} from '../../../helpers/constants';
import {
renderInputField,
renderSelectField,
Expand Down Expand Up @@ -62,7 +67,7 @@ const MobileConfigForm = ({ invalid }) => {

const githubLink = (
<a
href="https://github.com/AdguardTeam/AdGuardHome/wiki/Clients#idclient"
href={CLIENT_ID_LINK}
target="_blank"
rel="noopener noreferrer"
>
Expand Down
5 changes: 3 additions & 2 deletions client/src/helpers/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,11 @@ export const REPOSITORY = {
ISSUES: 'https://github.com/AdguardTeam/AdGuardHome/issues/new/choose',
};

export const PRIVACY_POLICY_LINK = 'https://adguard.com/privacy/home.html';
export const CLIENT_ID_LINK = 'https://github.com/AdguardTeam/AdGuardHome/wiki/Clients#clientid';
export const MANUAL_UPDATE_LINK = 'https://github.com/AdguardTeam/AdGuardHome/wiki/FAQ#manual-update';
export const PORT_53_FAQ_LINK = 'https://github.com/AdguardTeam/AdGuardHome/wiki/FAQ#bindinuse';
export const PRIVACY_POLICY_LINK = 'https://adguard.com/privacy/home.html';
export const UPSTREAM_CONFIGURATION_WIKI_LINK = 'https://github.com/AdguardTeam/AdGuardHome/wiki/Configuration#upstreams';
export const MANUAL_UPDATE_LINK = 'https://github.com/AdguardTeam/AdGuardHome/wiki/FAQ#manual-update';

export const FILTERS_RELATIVE_LINK = '#filters';

Expand Down
4 changes: 2 additions & 2 deletions internal/dnsforward/access.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ func (a *accessCtx) allowlistMode() (ok bool) {
func (a *accessCtx) isBlockedClientID(id string) (ok bool) {
allowlistMode := a.allowlistMode()
if id == "" {
// In allowlist mode, consider requests without client IDs
// blocked by default.
// In allowlist mode, consider requests without ClientIDs blocked by
// default.
return allowlistMode
}

Expand Down
20 changes: 10 additions & 10 deletions internal/dnsforward/clientid.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ import (
"github.com/lucas-clemente/quic-go"
)

// ValidateClientID returns an error if clientID is not a valid client ID.
func ValidateClientID(clientID string) (err error) {
err = netutil.ValidateDomainNameLabel(clientID)
// ValidateClientID returns an error if id is not a valid ClientID.
func ValidateClientID(id string) (err error) {
err = netutil.ValidateDomainNameLabel(id)
if err != nil {
// Replace the domain name label wrapper with our own.
return fmt.Errorf("invalid client id %q: %w", clientID, errors.Unwrap(err))
return fmt.Errorf("invalid clientid %q: %w", id, errors.Unwrap(err))
}

return nil
Expand All @@ -33,7 +33,7 @@ func hasLabelSuffix(s, suffix string) (ok bool) {
return strings.HasSuffix(s, suffix) && s[len(s)-len(suffix)-1] == '.'
}

// clientIDFromClientServerName extracts and validates a client ID. hostSrvName
// clientIDFromClientServerName extracts and validates a ClientID. hostSrvName
// is the server name of the host. cliSrvName is the server name as sent by the
// client. When strict is true, and client and host server name don't match,
// clientIDFromClientServerName will return an error.
Expand Down Expand Up @@ -86,22 +86,22 @@ func clientIDFromDNSContextHTTPS(pctx *proxy.DNSContext) (clientID string, err e
}

if len(parts) == 0 || parts[0] != "dns-query" {
return "", fmt.Errorf("client id check: invalid path %q", origPath)
return "", fmt.Errorf("clientid check: invalid path %q", origPath)
}

switch len(parts) {
case 1:
// Just /dns-query, no client ID.
// Just /dns-query, no ClientID.
return "", nil
case 2:
clientID = parts[1]
default:
return "", fmt.Errorf("client id check: invalid path %q: extra parts", origPath)
return "", fmt.Errorf("clientid check: invalid path %q: extra parts", origPath)
}

err = ValidateClientID(clientID)
if err != nil {
return "", fmt.Errorf("client id check: %w", err)
return "", fmt.Errorf("clientid check: %w", err)
}

return clientID, nil
Expand Down Expand Up @@ -166,7 +166,7 @@ func (s *Server) clientIDFromDNSContext(pctx *proxy.DNSContext) (clientID string
s.conf.StrictSNICheck,
)
if err != nil {
return "", fmt.Errorf("client id check: %w", err)
return "", fmt.Errorf("clientid check: %w", err)
}

return clientID, nil
Expand Down
Loading

0 comments on commit f53f48c

Please sign in to comment.