docstring_tokens
stringlengths
0
76.5k
code_tokens
stringlengths
75
1.81M
label_window
sequencelengths
4
2.12k
html_url
stringlengths
74
116
file_name
stringlengths
3
311
TrustedProxies: []string{"127.0.0.0/8", "::1/128"},
<mask> Ratelimit: 20, <mask> RefuseAny: true, <mask> AllServers: false, <mask> <mask> // set default maximum concurrent queries to 300 <mask> // we introduced a default limit due to this: <mask> // https://github.com/AdguardTeam/AdGuardHome/issues/2015#issuecomment-674041912 <mask> // was later increased to 300 due to https://github.com/AdguardTeam/AdGuardHome/issues/2257 <mask> MaxGoroutines: 300, <mask> }, </s> Pull request: 2799 trusted proxy Merge in DNS/adguard-home from 2799-trusted-proxy to master Updates #2799. Squashed commit of the following: commit 708a06b30116126a575767ea70865a6de90de774 Author: Eugene Burkov <[email protected]> Date: Fri Jul 23 18:56:16 2021 +0300 all: add trusted proxy mechanism
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/2f661df88cf4a11a86c1fbfb8dae9b2cd79ada09
internal/home/config.go
import { getIpMatchListStatus, sortIp } from '../helpers/helpers';
<mask> import { getIpMatchListStatus } from '../helpers/helpers'; <mask> import { IP_MATCH_LIST_STATUS } from '../helpers/constants'; <mask> <mask> describe('getIpMatchListStatus', () => { <mask> describe('IPv4', () => { <mask> test('should return EXACT on find the exact ip match', () => { </s> Pull request 734: + client: 1778 Add ip sort function, write unit tests Close #1778 Squashed commit of the following: commit ba63e147311799b17deaa97d7a12c2e0ec44a2ed Merge: 143ba427 705a9d90 Author: ArtemBaskal <[email protected]> Date: Thu Aug 13 12:00:10 2020 +0300 Merge branch 'master' into feature/1778 commit 143ba42707da3d7eece9f3e137a8b245f7f7888f Merge: 483d2ff9 97df1989 Author: ArtemBaskal <[email protected]> Date: Thu Aug 13 11:16:46 2020 +0300 Merge branch 'master' into feature/1778 commit 483d2ff9fa3de706d94a647701f1d26a3bcbb217 Author: ArtemBaskal <[email protected]> Date: Wed Aug 12 13:34:21 2020 +0300 Always put ipv4 before ipv6 in sort, add invalid input unit tests commit 26eb41b313785fe7ffaf98a7573cc5eef0dca14f Author: ArtemBaskal <[email protected]> Date: Wed Aug 12 11:27:46 2020 +0300 Rewrite tests: replace ipv4-mapped adresses commit 4ecf287fd46945effe9ff11cfc9ae49217b9c796 Author: ArtemBaskal <[email protected]> Date: Tue Aug 11 19:05:15 2020 +0300 Minor fix commit 3e5e2a6bb1f2f166619da54e5ade0904fe22a20d Author: ArtemBaskal <[email protected]> Date: Tue Aug 11 19:01:26 2020 +0300 + client: 1778 Add ip sort function, write unit tests </s> remove import { getPercent, getIpMatchListStatus } from '../../helpers/helpers'; </s> add import { getPercent, getIpMatchListStatus, sortIp } from '../../helpers/helpers'; </s> remove </s> add import { sortIp } from '../../../../helpers/helpers'; </s> remove sortMethod: (a, b) => parseInt(a.replace(/\./g, ''), 10) - parseInt(b.replace(/\./g, ''), 10), </s> add sortMethod: sortIp,
[ "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/2f8e34e73b75a18cba70ae81e455c9e979642f52
client/src/__tests__/helpers.test.js
import { getPercent, getIpMatchListStatus, sortIp } from '../../helpers/helpers';
<mask> <mask> import Card from '../ui/Card'; <mask> import Cell from '../ui/Cell'; <mask> <mask> import { getPercent, getIpMatchListStatus } from '../../helpers/helpers'; <mask> import { IP_MATCH_LIST_STATUS, STATUS_COLORS } from '../../helpers/constants'; <mask> import { formatClientCell } from '../../helpers/formatClientCell'; <mask> <mask> const getClientsPercentColor = (percent) => { <mask> if (percent > 50) { </s> Pull request 734: + client: 1778 Add ip sort function, write unit tests Close #1778 Squashed commit of the following: commit ba63e147311799b17deaa97d7a12c2e0ec44a2ed Merge: 143ba427 705a9d90 Author: ArtemBaskal <[email protected]> Date: Thu Aug 13 12:00:10 2020 +0300 Merge branch 'master' into feature/1778 commit 143ba42707da3d7eece9f3e137a8b245f7f7888f Merge: 483d2ff9 97df1989 Author: ArtemBaskal <[email protected]> Date: Thu Aug 13 11:16:46 2020 +0300 Merge branch 'master' into feature/1778 commit 483d2ff9fa3de706d94a647701f1d26a3bcbb217 Author: ArtemBaskal <[email protected]> Date: Wed Aug 12 13:34:21 2020 +0300 Always put ipv4 before ipv6 in sort, add invalid input unit tests commit 26eb41b313785fe7ffaf98a7573cc5eef0dca14f Author: ArtemBaskal <[email protected]> Date: Wed Aug 12 11:27:46 2020 +0300 Rewrite tests: replace ipv4-mapped adresses commit 4ecf287fd46945effe9ff11cfc9ae49217b9c796 Author: ArtemBaskal <[email protected]> Date: Tue Aug 11 19:05:15 2020 +0300 Minor fix commit 3e5e2a6bb1f2f166619da54e5ade0904fe22a20d Author: ArtemBaskal <[email protected]> Date: Tue Aug 11 19:01:26 2020 +0300 + client: 1778 Add ip sort function, write unit tests </s> remove import { getIpMatchListStatus } from '../helpers/helpers'; </s> add import { getIpMatchListStatus, sortIp } from '../helpers/helpers'; </s> remove </s> add import { sortIp } from '../../../../helpers/helpers';
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/2f8e34e73b75a18cba70ae81e455c9e979642f52
client/src/components/Dashboard/Clients.js
sortMethod: sortIp,
<mask> columns={[ <mask> { <mask> Header: 'IP', <mask> accessor: 'ip', <mask> sortMethod: (a, b) => parseInt(a.replace(/\./g, ''), 10) - parseInt(b.replace(/\./g, ''), 10), <mask> Cell: clientCell(t, toggleClientStatus, processingAccessSet, disallowedClients), <mask> }, <mask> { <mask> Header: <Trans>requests_count</Trans>, <mask> accessor: 'count', </s> Pull request 734: + client: 1778 Add ip sort function, write unit tests Close #1778 Squashed commit of the following: commit ba63e147311799b17deaa97d7a12c2e0ec44a2ed Merge: 143ba427 705a9d90 Author: ArtemBaskal <[email protected]> Date: Thu Aug 13 12:00:10 2020 +0300 Merge branch 'master' into feature/1778 commit 143ba42707da3d7eece9f3e137a8b245f7f7888f Merge: 483d2ff9 97df1989 Author: ArtemBaskal <[email protected]> Date: Thu Aug 13 11:16:46 2020 +0300 Merge branch 'master' into feature/1778 commit 483d2ff9fa3de706d94a647701f1d26a3bcbb217 Author: ArtemBaskal <[email protected]> Date: Wed Aug 12 13:34:21 2020 +0300 Always put ipv4 before ipv6 in sort, add invalid input unit tests commit 26eb41b313785fe7ffaf98a7573cc5eef0dca14f Author: ArtemBaskal <[email protected]> Date: Wed Aug 12 11:27:46 2020 +0300 Rewrite tests: replace ipv4-mapped adresses commit 4ecf287fd46945effe9ff11cfc9ae49217b9c796 Author: ArtemBaskal <[email protected]> Date: Tue Aug 11 19:05:15 2020 +0300 Minor fix commit 3e5e2a6bb1f2f166619da54e5ade0904fe22a20d Author: ArtemBaskal <[email protected]> Date: Tue Aug 11 19:01:26 2020 +0300 + client: 1778 Add ip sort function, write unit tests </s> remove import { getIpMatchListStatus } from '../helpers/helpers'; </s> add import { getIpMatchListStatus, sortIp } from '../helpers/helpers'; </s> remove import { getPercent, getIpMatchListStatus } from '../../helpers/helpers'; </s> add import { getPercent, getIpMatchListStatus, sortIp } from '../../helpers/helpers';
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/2f8e34e73b75a18cba70ae81e455c9e979642f52
client/src/components/Dashboard/Clients.js
import { sortIp } from '../../../helpers/helpers';
<mask> import whoisCell from './whoisCell'; <mask> import LogsSearchLink from '../../ui/LogsSearchLink'; <mask> <mask> const COLUMN_MIN_WIDTH = 200; <mask> <mask> class AutoClients extends Component { </s> Pull request 734: + client: 1778 Add ip sort function, write unit tests Close #1778 Squashed commit of the following: commit ba63e147311799b17deaa97d7a12c2e0ec44a2ed Merge: 143ba427 705a9d90 Author: ArtemBaskal <[email protected]> Date: Thu Aug 13 12:00:10 2020 +0300 Merge branch 'master' into feature/1778 commit 143ba42707da3d7eece9f3e137a8b245f7f7888f Merge: 483d2ff9 97df1989 Author: ArtemBaskal <[email protected]> Date: Thu Aug 13 11:16:46 2020 +0300 Merge branch 'master' into feature/1778 commit 483d2ff9fa3de706d94a647701f1d26a3bcbb217 Author: ArtemBaskal <[email protected]> Date: Wed Aug 12 13:34:21 2020 +0300 Always put ipv4 before ipv6 in sort, add invalid input unit tests commit 26eb41b313785fe7ffaf98a7573cc5eef0dca14f Author: ArtemBaskal <[email protected]> Date: Wed Aug 12 11:27:46 2020 +0300 Rewrite tests: replace ipv4-mapped adresses commit 4ecf287fd46945effe9ff11cfc9ae49217b9c796 Author: ArtemBaskal <[email protected]> Date: Tue Aug 11 19:05:15 2020 +0300 Minor fix commit 3e5e2a6bb1f2f166619da54e5ade0904fe22a20d Author: ArtemBaskal <[email protected]> Date: Tue Aug 11 19:01:26 2020 +0300 + client: 1778 Add ip sort function, write unit tests </s> remove </s> add import { sortIp } from '../../../../helpers/helpers'; </s> remove import { getPercent, getIpMatchListStatus } from '../../helpers/helpers'; </s> add import { getPercent, getIpMatchListStatus, sortIp } from '../../helpers/helpers'; </s> remove import { getIpMatchListStatus } from '../helpers/helpers'; </s> add import { getIpMatchListStatus, sortIp } from '../helpers/helpers';
[ "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/2f8e34e73b75a18cba70ae81e455c9e979642f52
client/src/components/Settings/Clients/AutoClients.js
sortMethod: sortIp,
<mask> accessor: 'ip', <mask> minWidth: COLUMN_MIN_WIDTH, <mask> Cell: CellWrap, <mask> }, <mask> { <mask> Header: this.props.t('table_name'), <mask> accessor: 'name', </s> Pull request 734: + client: 1778 Add ip sort function, write unit tests Close #1778 Squashed commit of the following: commit ba63e147311799b17deaa97d7a12c2e0ec44a2ed Merge: 143ba427 705a9d90 Author: ArtemBaskal <[email protected]> Date: Thu Aug 13 12:00:10 2020 +0300 Merge branch 'master' into feature/1778 commit 143ba42707da3d7eece9f3e137a8b245f7f7888f Merge: 483d2ff9 97df1989 Author: ArtemBaskal <[email protected]> Date: Thu Aug 13 11:16:46 2020 +0300 Merge branch 'master' into feature/1778 commit 483d2ff9fa3de706d94a647701f1d26a3bcbb217 Author: ArtemBaskal <[email protected]> Date: Wed Aug 12 13:34:21 2020 +0300 Always put ipv4 before ipv6 in sort, add invalid input unit tests commit 26eb41b313785fe7ffaf98a7573cc5eef0dca14f Author: ArtemBaskal <[email protected]> Date: Wed Aug 12 11:27:46 2020 +0300 Rewrite tests: replace ipv4-mapped adresses commit 4ecf287fd46945effe9ff11cfc9ae49217b9c796 Author: ArtemBaskal <[email protected]> Date: Tue Aug 11 19:05:15 2020 +0300 Minor fix commit 3e5e2a6bb1f2f166619da54e5ade0904fe22a20d Author: ArtemBaskal <[email protected]> Date: Tue Aug 11 19:01:26 2020 +0300 + client: 1778 Add ip sort function, write unit tests </s> remove sortMethod: (a, b) => parseInt(a.replace(/\./g, ''), 10) - parseInt(b.replace(/\./g, ''), 10), </s> add sortMethod: sortIp, </s> remove import { getIpMatchListStatus } from '../helpers/helpers'; </s> add import { getIpMatchListStatus, sortIp } from '../helpers/helpers'; </s> remove import { getPercent, getIpMatchListStatus } from '../../helpers/helpers'; </s> add import { getPercent, getIpMatchListStatus, sortIp } from '../../helpers/helpers';
[ "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/2f8e34e73b75a18cba70ae81e455c9e979642f52
client/src/components/Settings/Clients/AutoClients.js
import { sortIp } from '../../../helpers/helpers';
<mask> import ReactTable from 'react-table'; <mask> import { Trans, withTranslation } from 'react-i18next'; <mask> import { LEASES_TABLE_DEFAULT_PAGE_SIZE } from '../../../helpers/constants'; <mask> <mask> class Leases extends Component { <mask> cellWrap = ({ value }) => ( <mask> <div className="logs__row o-hidden"> <mask> <span className="logs__text" title={value}> <mask> {value} </s> Pull request 734: + client: 1778 Add ip sort function, write unit tests Close #1778 Squashed commit of the following: commit ba63e147311799b17deaa97d7a12c2e0ec44a2ed Merge: 143ba427 705a9d90 Author: ArtemBaskal <[email protected]> Date: Thu Aug 13 12:00:10 2020 +0300 Merge branch 'master' into feature/1778 commit 143ba42707da3d7eece9f3e137a8b245f7f7888f Merge: 483d2ff9 97df1989 Author: ArtemBaskal <[email protected]> Date: Thu Aug 13 11:16:46 2020 +0300 Merge branch 'master' into feature/1778 commit 483d2ff9fa3de706d94a647701f1d26a3bcbb217 Author: ArtemBaskal <[email protected]> Date: Wed Aug 12 13:34:21 2020 +0300 Always put ipv4 before ipv6 in sort, add invalid input unit tests commit 26eb41b313785fe7ffaf98a7573cc5eef0dca14f Author: ArtemBaskal <[email protected]> Date: Wed Aug 12 11:27:46 2020 +0300 Rewrite tests: replace ipv4-mapped adresses commit 4ecf287fd46945effe9ff11cfc9ae49217b9c796 Author: ArtemBaskal <[email protected]> Date: Tue Aug 11 19:05:15 2020 +0300 Minor fix commit 3e5e2a6bb1f2f166619da54e5ade0904fe22a20d Author: ArtemBaskal <[email protected]> Date: Tue Aug 11 19:01:26 2020 +0300 + client: 1778 Add ip sort function, write unit tests </s> remove </s> add import { sortIp } from '../../../../helpers/helpers'; </s> remove import { getPercent, getIpMatchListStatus } from '../../helpers/helpers'; </s> add import { getPercent, getIpMatchListStatus, sortIp } from '../../helpers/helpers'; </s> remove import { getIpMatchListStatus } from '../helpers/helpers'; </s> add import { getIpMatchListStatus, sortIp } from '../helpers/helpers'; </s> remove sortMethod: (a, b) => parseInt(a.replace(/\./g, ''), 10) - parseInt(b.replace(/\./g, ''), 10), </s> add sortMethod: sortIp,
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/2f8e34e73b75a18cba70ae81e455c9e979642f52
client/src/components/Settings/Dhcp/Leases.js
sortMethod: sortIp,
<mask> Header: 'IP', <mask> accessor: 'ip', <mask> Cell: this.cellWrap, <mask> }, { <mask> Header: <Trans>dhcp_table_hostname</Trans>, <mask> accessor: 'hostname', <mask> Cell: this.cellWrap, <mask> }, { </s> Pull request 734: + client: 1778 Add ip sort function, write unit tests Close #1778 Squashed commit of the following: commit ba63e147311799b17deaa97d7a12c2e0ec44a2ed Merge: 143ba427 705a9d90 Author: ArtemBaskal <[email protected]> Date: Thu Aug 13 12:00:10 2020 +0300 Merge branch 'master' into feature/1778 commit 143ba42707da3d7eece9f3e137a8b245f7f7888f Merge: 483d2ff9 97df1989 Author: ArtemBaskal <[email protected]> Date: Thu Aug 13 11:16:46 2020 +0300 Merge branch 'master' into feature/1778 commit 483d2ff9fa3de706d94a647701f1d26a3bcbb217 Author: ArtemBaskal <[email protected]> Date: Wed Aug 12 13:34:21 2020 +0300 Always put ipv4 before ipv6 in sort, add invalid input unit tests commit 26eb41b313785fe7ffaf98a7573cc5eef0dca14f Author: ArtemBaskal <[email protected]> Date: Wed Aug 12 11:27:46 2020 +0300 Rewrite tests: replace ipv4-mapped adresses commit 4ecf287fd46945effe9ff11cfc9ae49217b9c796 Author: ArtemBaskal <[email protected]> Date: Tue Aug 11 19:05:15 2020 +0300 Minor fix commit 3e5e2a6bb1f2f166619da54e5ade0904fe22a20d Author: ArtemBaskal <[email protected]> Date: Tue Aug 11 19:01:26 2020 +0300 + client: 1778 Add ip sort function, write unit tests </s> remove sortMethod: (a, b) => parseInt(a.replace(/\./g, ''), 10) - parseInt(b.replace(/\./g, ''), 10), </s> add sortMethod: sortIp, </s> remove import { getIpMatchListStatus } from '../helpers/helpers'; </s> add import { getIpMatchListStatus, sortIp } from '../helpers/helpers'; </s> remove import { getPercent, getIpMatchListStatus } from '../../helpers/helpers'; </s> add import { getPercent, getIpMatchListStatus, sortIp } from '../../helpers/helpers';
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/2f8e34e73b75a18cba70ae81e455c9e979642f52
client/src/components/Settings/Dhcp/Leases.js
import { sortIp } from '../../../../helpers/helpers';
<mask> import PropTypes from 'prop-types'; <mask> import ReactTable from 'react-table'; <mask> import { Trans, withTranslation } from 'react-i18next'; <mask> import { LEASES_TABLE_DEFAULT_PAGE_SIZE } from '../../../../helpers/constants'; <mask> <mask> import Modal from './Modal'; <mask> <mask> class StaticLeases extends Component { <mask> cellWrap = ({ value }) => ( <mask> <div className="logs__row o-hidden"> </s> Pull request 734: + client: 1778 Add ip sort function, write unit tests Close #1778 Squashed commit of the following: commit ba63e147311799b17deaa97d7a12c2e0ec44a2ed Merge: 143ba427 705a9d90 Author: ArtemBaskal <[email protected]> Date: Thu Aug 13 12:00:10 2020 +0300 Merge branch 'master' into feature/1778 commit 143ba42707da3d7eece9f3e137a8b245f7f7888f Merge: 483d2ff9 97df1989 Author: ArtemBaskal <[email protected]> Date: Thu Aug 13 11:16:46 2020 +0300 Merge branch 'master' into feature/1778 commit 483d2ff9fa3de706d94a647701f1d26a3bcbb217 Author: ArtemBaskal <[email protected]> Date: Wed Aug 12 13:34:21 2020 +0300 Always put ipv4 before ipv6 in sort, add invalid input unit tests commit 26eb41b313785fe7ffaf98a7573cc5eef0dca14f Author: ArtemBaskal <[email protected]> Date: Wed Aug 12 11:27:46 2020 +0300 Rewrite tests: replace ipv4-mapped adresses commit 4ecf287fd46945effe9ff11cfc9ae49217b9c796 Author: ArtemBaskal <[email protected]> Date: Tue Aug 11 19:05:15 2020 +0300 Minor fix commit 3e5e2a6bb1f2f166619da54e5ade0904fe22a20d Author: ArtemBaskal <[email protected]> Date: Tue Aug 11 19:01:26 2020 +0300 + client: 1778 Add ip sort function, write unit tests </s> remove import { getPercent, getIpMatchListStatus } from '../../helpers/helpers'; </s> add import { getPercent, getIpMatchListStatus, sortIp } from '../../helpers/helpers'; </s> remove import { getIpMatchListStatus } from '../helpers/helpers'; </s> add import { getIpMatchListStatus, sortIp } from '../helpers/helpers'; </s> remove sortMethod: (a, b) => parseInt(a.replace(/\./g, ''), 10) - parseInt(b.replace(/\./g, ''), 10), </s> add sortMethod: sortIp,
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/2f8e34e73b75a18cba70ae81e455c9e979642f52
client/src/components/Settings/Dhcp/StaticLeases/index.js
sortMethod: sortIp,
<mask> Header: 'IP', <mask> accessor: 'ip', <mask> Cell: this.cellWrap, <mask> }, <mask> { <mask> Header: <Trans>dhcp_table_hostname</Trans>, <mask> accessor: 'hostname', </s> Pull request 734: + client: 1778 Add ip sort function, write unit tests Close #1778 Squashed commit of the following: commit ba63e147311799b17deaa97d7a12c2e0ec44a2ed Merge: 143ba427 705a9d90 Author: ArtemBaskal <[email protected]> Date: Thu Aug 13 12:00:10 2020 +0300 Merge branch 'master' into feature/1778 commit 143ba42707da3d7eece9f3e137a8b245f7f7888f Merge: 483d2ff9 97df1989 Author: ArtemBaskal <[email protected]> Date: Thu Aug 13 11:16:46 2020 +0300 Merge branch 'master' into feature/1778 commit 483d2ff9fa3de706d94a647701f1d26a3bcbb217 Author: ArtemBaskal <[email protected]> Date: Wed Aug 12 13:34:21 2020 +0300 Always put ipv4 before ipv6 in sort, add invalid input unit tests commit 26eb41b313785fe7ffaf98a7573cc5eef0dca14f Author: ArtemBaskal <[email protected]> Date: Wed Aug 12 11:27:46 2020 +0300 Rewrite tests: replace ipv4-mapped adresses commit 4ecf287fd46945effe9ff11cfc9ae49217b9c796 Author: ArtemBaskal <[email protected]> Date: Tue Aug 11 19:05:15 2020 +0300 Minor fix commit 3e5e2a6bb1f2f166619da54e5ade0904fe22a20d Author: ArtemBaskal <[email protected]> Date: Tue Aug 11 19:01:26 2020 +0300 + client: 1778 Add ip sort function, write unit tests </s> remove sortMethod: (a, b) => parseInt(a.replace(/\./g, ''), 10) - parseInt(b.replace(/\./g, ''), 10), </s> add sortMethod: sortIp, </s> remove import { getIpMatchListStatus } from '../helpers/helpers'; </s> add import { getIpMatchListStatus, sortIp } from '../helpers/helpers'; </s> remove import { getPercent, getIpMatchListStatus } from '../../helpers/helpers'; </s> add import { getPercent, getIpMatchListStatus, sortIp } from '../../helpers/helpers';
[ "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/2f8e34e73b75a18cba70ae81e455c9e979642f52
client/src/components/Settings/Dhcp/StaticLeases/index.js
TLSListenAddr *net.TCPAddr `yaml:"-" json:"-"` StrictSNICheck bool `yaml:"strict_sni_check" json:"-"` // Reject connection if the client uses server name (in SNI) that doesn't match the certificate CertificateChain string `yaml:"certificate_chain" json:"certificate_chain"` // PEM-encoded certificates chain PrivateKey string `yaml:"private_key" json:"private_key"` // PEM-encoded private key
<mask> } <mask> <mask> // TLSConfig is the TLS configuration for HTTPS, DNS-over-HTTPS, and DNS-over-TLS <mask> type TLSConfig struct { <mask> TLSListenAddr *net.TCPAddr `yaml:"-" json:"-"` <mask> StrictSNICheck bool `yaml:"strict_sni_check" json:"-"` // Reject connection if the client uses server name (in SNI) that doesn't match the certificate <mask> CertificateChain string `yaml:"certificate_chain" json:"certificate_chain"` // PEM-encoded certificates chain <mask> PrivateKey string `yaml:"private_key" json:"private_key"` // PEM-encoded private key <mask> <mask> CertificatePath string `yaml:"certificate_path" json:"certificate_path"` // certificate file name <mask> PrivateKeyPath string `yaml:"private_key_path" json:"private_key_path"` // private key file name <mask> <mask> CertificateChainData []byte `yaml:"-" json:"-"` </s> *(home): fix TLS module initialization Continue to work even when TLS cert-key pair is invalid Closes: https://github.com/AdguardTeam/AdGuardHome/issues/1677 </s> remove address = net.JoinHostPort(config.BindHost, strconv.Itoa(config.BindPort)) </s> add address = net.JoinHostPort(config.BindHost, port) </s> remove log.Error(data.WarningValidation) </s> add log.Error("failed to validate certificate: %s", data.WarningValidation) </s> remove return nil </s> add // Something is not valid - return an empty TLS config return &TLSMod{conf: tlsConfigSettings{ Enabled: conf.Enabled, ServerName: conf.ServerName, PortHTTPS: conf.PortHTTPS, PortDNSOverTLS: conf.PortDNSOverTLS, AllowUnencryptedDOH: conf.AllowUnencryptedDOH, }} </s> remove address = net.JoinHostPort(config.BindHost, strconv.Itoa(config.BindPort)) </s> add address = net.JoinHostPort(config.BindHost, port) </s> remove log.Printf("Go to https://%s:%d", tlsConf.ServerName, tlsConf.PortHTTPS) </s> add log.Printf("Go to https://%s:%s", tlsConf.ServerName, port)
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/2fca419c7f2356026c1a9d8bd2ac2be9e9f2f240
dnsforward/config.go
port := strconv.Itoa(config.BindPort) if proto == "https" { port = strconv.Itoa(tlsConf.PortHTTPS) }
<mask> Context.tls.WriteDiskConfig(&tlsConf) <mask> } <mask> if proto == "https" && tlsConf.ServerName != "" { <mask> if tlsConf.PortHTTPS == 443 { <mask> log.Printf("Go to https://%s", tlsConf.ServerName) <mask> } else { <mask> log.Printf("Go to https://%s:%s", tlsConf.ServerName, port) </s> *(home): fix TLS module initialization Continue to work even when TLS cert-key pair is invalid Closes: https://github.com/AdguardTeam/AdGuardHome/issues/1677 </s> remove log.Printf("Go to https://%s:%d", tlsConf.ServerName, tlsConf.PortHTTPS) </s> add log.Printf("Go to https://%s:%s", tlsConf.ServerName, port) </s> remove address = net.JoinHostPort(iface.Addresses[0], strconv.Itoa(config.BindPort)) </s> add address = net.JoinHostPort(iface.Addresses[0], port) </s> remove address = net.JoinHostPort(config.BindHost, strconv.Itoa(config.BindPort)) </s> add address = net.JoinHostPort(config.BindHost, port) </s> remove address = net.JoinHostPort(config.BindHost, strconv.Itoa(config.BindPort)) </s> add address = net.JoinHostPort(config.BindHost, port) </s> remove log.Error(data.WarningValidation) </s> add log.Error("failed to validate certificate: %s", data.WarningValidation)
[ "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/2fca419c7f2356026c1a9d8bd2ac2be9e9f2f240
home/home.go
log.Printf("Go to https://%s:%s", tlsConf.ServerName, port)
<mask> if proto == "https" && tlsConf.ServerName != "" { <mask> if tlsConf.PortHTTPS == 443 { <mask> log.Printf("Go to https://%s", tlsConf.ServerName) <mask> } else { <mask> log.Printf("Go to https://%s:%d", tlsConf.ServerName, tlsConf.PortHTTPS) <mask> } <mask> } else if config.BindHost == "0.0.0.0" { <mask> log.Println("AdGuard Home is available on the following addresses:") <mask> ifaces, err := util.GetValidNetInterfacesForWeb() <mask> if err != nil { </s> *(home): fix TLS module initialization Continue to work even when TLS cert-key pair is invalid Closes: https://github.com/AdguardTeam/AdGuardHome/issues/1677 </s> remove address = net.JoinHostPort(config.BindHost, strconv.Itoa(config.BindPort)) </s> add address = net.JoinHostPort(config.BindHost, port) </s> remove return nil </s> add // Something is not valid - return an empty TLS config return &TLSMod{conf: tlsConfigSettings{ Enabled: conf.Enabled, ServerName: conf.ServerName, PortHTTPS: conf.PortHTTPS, PortDNSOverTLS: conf.PortDNSOverTLS, AllowUnencryptedDOH: conf.AllowUnencryptedDOH, }} </s> remove address = net.JoinHostPort(iface.Addresses[0], strconv.Itoa(config.BindPort)) </s> add address = net.JoinHostPort(iface.Addresses[0], port) </s> remove address = net.JoinHostPort(config.BindHost, strconv.Itoa(config.BindPort)) </s> add address = net.JoinHostPort(config.BindHost, port)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/2fca419c7f2356026c1a9d8bd2ac2be9e9f2f240
home/home.go
address = net.JoinHostPort(config.BindHost, port)
<mask> log.Println("AdGuard Home is available on the following addresses:") <mask> ifaces, err := util.GetValidNetInterfacesForWeb() <mask> if err != nil { <mask> // That's weird, but we'll ignore it <mask> address = net.JoinHostPort(config.BindHost, strconv.Itoa(config.BindPort)) <mask> log.Printf("Go to %s://%s", proto, address) <mask> return <mask> } <mask> <mask> for _, iface := range ifaces { </s> *(home): fix TLS module initialization Continue to work even when TLS cert-key pair is invalid Closes: https://github.com/AdguardTeam/AdGuardHome/issues/1677 </s> remove log.Printf("Go to https://%s:%d", tlsConf.ServerName, tlsConf.PortHTTPS) </s> add log.Printf("Go to https://%s:%s", tlsConf.ServerName, port) </s> remove address = net.JoinHostPort(iface.Addresses[0], strconv.Itoa(config.BindPort)) </s> add address = net.JoinHostPort(iface.Addresses[0], port) </s> remove address = net.JoinHostPort(config.BindHost, strconv.Itoa(config.BindPort)) </s> add address = net.JoinHostPort(config.BindHost, port) </s> remove return nil </s> add // Something is not valid - return an empty TLS config return &TLSMod{conf: tlsConfigSettings{ Enabled: conf.Enabled, ServerName: conf.ServerName, PortHTTPS: conf.PortHTTPS, PortDNSOverTLS: conf.PortDNSOverTLS, AllowUnencryptedDOH: conf.AllowUnencryptedDOH, }}
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/2fca419c7f2356026c1a9d8bd2ac2be9e9f2f240
home/home.go
address = net.JoinHostPort(iface.Addresses[0], port)
<mask> return <mask> } <mask> <mask> for _, iface := range ifaces { <mask> address = net.JoinHostPort(iface.Addresses[0], strconv.Itoa(config.BindPort)) <mask> log.Printf("Go to %s://%s", proto, address) <mask> } <mask> } else { <mask> address = net.JoinHostPort(config.BindHost, strconv.Itoa(config.BindPort)) <mask> log.Printf("Go to %s://%s", proto, address) </s> *(home): fix TLS module initialization Continue to work even when TLS cert-key pair is invalid Closes: https://github.com/AdguardTeam/AdGuardHome/issues/1677 </s> remove address = net.JoinHostPort(config.BindHost, strconv.Itoa(config.BindPort)) </s> add address = net.JoinHostPort(config.BindHost, port) </s> remove address = net.JoinHostPort(config.BindHost, strconv.Itoa(config.BindPort)) </s> add address = net.JoinHostPort(config.BindHost, port) </s> remove log.Printf("Go to https://%s:%d", tlsConf.ServerName, tlsConf.PortHTTPS) </s> add log.Printf("Go to https://%s:%s", tlsConf.ServerName, port) </s> remove log.Error(data.WarningValidation) </s> add log.Error("failed to validate certificate: %s", data.WarningValidation)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/2fca419c7f2356026c1a9d8bd2ac2be9e9f2f240
home/home.go
address = net.JoinHostPort(config.BindHost, port)
<mask> address = net.JoinHostPort(iface.Addresses[0], strconv.Itoa(config.BindPort)) <mask> log.Printf("Go to %s://%s", proto, address) <mask> } <mask> } else { <mask> address = net.JoinHostPort(config.BindHost, strconv.Itoa(config.BindPort)) <mask> log.Printf("Go to %s://%s", proto, address) <mask> } <mask> } <mask> <mask> // ------------------- </s> *(home): fix TLS module initialization Continue to work even when TLS cert-key pair is invalid Closes: https://github.com/AdguardTeam/AdGuardHome/issues/1677 </s> remove address = net.JoinHostPort(iface.Addresses[0], strconv.Itoa(config.BindPort)) </s> add address = net.JoinHostPort(iface.Addresses[0], port) </s> remove address = net.JoinHostPort(config.BindHost, strconv.Itoa(config.BindPort)) </s> add address = net.JoinHostPort(config.BindHost, port) </s> remove log.Printf("Go to https://%s:%d", tlsConf.ServerName, tlsConf.PortHTTPS) </s> add log.Printf("Go to https://%s:%s", tlsConf.ServerName, port) </s> remove log.Error(data.WarningValidation) </s> add log.Error("failed to validate certificate: %s", data.WarningValidation)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/2fca419c7f2356026c1a9d8bd2ac2be9e9f2f240
home/home.go
// Something is not valid - return an empty TLS config return &TLSMod{conf: tlsConfigSettings{ Enabled: conf.Enabled, ServerName: conf.ServerName, PortHTTPS: conf.PortHTTPS, PortDNSOverTLS: conf.PortDNSOverTLS, AllowUnencryptedDOH: conf.AllowUnencryptedDOH, }}
<mask> t := &TLSMod{} <mask> t.conf = conf <mask> if t.conf.Enabled { <mask> if !t.load() { <mask> return nil <mask> } <mask> t.setCertFileTime() <mask> } <mask> return t <mask> } </s> *(home): fix TLS module initialization Continue to work even when TLS cert-key pair is invalid Closes: https://github.com/AdguardTeam/AdGuardHome/issues/1677 </s> remove log.Printf("Go to https://%s:%d", tlsConf.ServerName, tlsConf.PortHTTPS) </s> add log.Printf("Go to https://%s:%s", tlsConf.ServerName, port) </s> remove address = net.JoinHostPort(config.BindHost, strconv.Itoa(config.BindPort)) </s> add address = net.JoinHostPort(config.BindHost, port) </s> remove address = net.JoinHostPort(iface.Addresses[0], strconv.Itoa(config.BindPort)) </s> add address = net.JoinHostPort(iface.Addresses[0], port) </s> remove log.Error(data.WarningValidation) </s> add log.Error("failed to validate certificate: %s", data.WarningValidation)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/2fca419c7f2356026c1a9d8bd2ac2be9e9f2f240
home/tls.go
log.Error("failed to validate certificate: %s", data.WarningValidation)
<mask> <mask> // validate current TLS config and update warnings (it could have been loaded from file) <mask> data := validateCertificates(string(t.conf.CertificateChainData), string(t.conf.PrivateKeyData), t.conf.ServerName) <mask> if !data.ValidPair { <mask> log.Error(data.WarningValidation) <mask> return false <mask> } <mask> t.status = data <mask> return true <mask> } </s> *(home): fix TLS module initialization Continue to work even when TLS cert-key pair is invalid Closes: https://github.com/AdguardTeam/AdGuardHome/issues/1677 </s> remove return nil </s> add // Something is not valid - return an empty TLS config return &TLSMod{conf: tlsConfigSettings{ Enabled: conf.Enabled, ServerName: conf.ServerName, PortHTTPS: conf.PortHTTPS, PortDNSOverTLS: conf.PortDNSOverTLS, AllowUnencryptedDOH: conf.AllowUnencryptedDOH, }} </s> remove address = net.JoinHostPort(config.BindHost, strconv.Itoa(config.BindPort)) </s> add address = net.JoinHostPort(config.BindHost, port) </s> remove address = net.JoinHostPort(config.BindHost, strconv.Itoa(config.BindPort)) </s> add address = net.JoinHostPort(config.BindHost, port) </s> remove address = net.JoinHostPort(iface.Addresses[0], strconv.Itoa(config.BindPort)) </s> add address = net.JoinHostPort(iface.Addresses[0], port)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/2fca419c7f2356026c1a9d8bd2ac2be9e9f2f240
home/tls.go
import { splitByNewLine, countClientsStatistics, sortIp } from '../../../helpers/helpers';
<mask> import { Trans, withTranslation } from 'react-i18next'; <mask> import ReactTable from 'react-table'; <mask> <mask> import { MODAL_TYPE } from '../../../helpers/constants'; <mask> import { splitByNewLine, countClientsStatistics } from '../../../helpers/helpers'; <mask> import Card from '../../ui/Card'; <mask> import Modal from './Modal'; <mask> import CellWrap from '../../ui/CellWrap'; <mask> import LogsSearchLink from '../../ui/LogsSearchLink'; <mask> </s> Pull request: 4143 sort client ids Merge in DNS/adguard-home from 4143-clients-sort to master Updates #4143. Squashed commit of the following: commit a4b547eb46a54bdfdc7d342fab5f8ecfa54f5d06 Merge: d369c11c d82b2902 Author: Ildar Kamalov <[email protected]> Date: Thu Jan 20 11:58:42 2022 +0300 Merge branch 'master' into 4143-clients-sort commit d369c11c69665510043f63e0283e1ca1b2974289 Author: Ildar Kamalov <[email protected]> Date: Wed Jan 19 16:53:39 2022 +0300 client: fix sort ip method commit d767a1199c37ad9df7f3bc2d362d840b0226d836 Author: Ildar Kamalov <[email protected]> Date: Wed Jan 19 16:23:23 2022 +0300 client: sort client ids </s> remove const comparisonBytesA = getAddressesComparisonBytes(a); const comparisonBytesB = getAddressesComparisonBytes(b); </s> add const comparisonBytesA = Array.isArray(a) ? getAddressesComparisonBytes(a[0]) : getAddressesComparisonBytes(a); const comparisonBytesB = Array.isArray(b) ? getAddressesComparisonBytes(b[0]) : getAddressesComparisonBytes(b);
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/2fdda8a22cb46f76c8f92ac2bdcbd9b25acd3e21
client/src/components/Settings/Clients/ClientsTable.js
sortMethod: sortIp,
<mask> </div> <mask> ); <mask> }, <mask> }, <mask> { <mask> Header: this.props.t('table_name'), <mask> accessor: 'name', </s> Pull request: 4143 sort client ids Merge in DNS/adguard-home from 4143-clients-sort to master Updates #4143. Squashed commit of the following: commit a4b547eb46a54bdfdc7d342fab5f8ecfa54f5d06 Merge: d369c11c d82b2902 Author: Ildar Kamalov <[email protected]> Date: Thu Jan 20 11:58:42 2022 +0300 Merge branch 'master' into 4143-clients-sort commit d369c11c69665510043f63e0283e1ca1b2974289 Author: Ildar Kamalov <[email protected]> Date: Wed Jan 19 16:53:39 2022 +0300 client: fix sort ip method commit d767a1199c37ad9df7f3bc2d362d840b0226d836 Author: Ildar Kamalov <[email protected]> Date: Wed Jan 19 16:23:23 2022 +0300 client: sort client ids </s> remove import { splitByNewLine, countClientsStatistics } from '../../../helpers/helpers'; </s> add import { splitByNewLine, countClientsStatistics, sortIp } from '../../../helpers/helpers'; </s> remove const comparisonBytesA = getAddressesComparisonBytes(a); const comparisonBytesB = getAddressesComparisonBytes(b); </s> add const comparisonBytesA = Array.isArray(a) ? getAddressesComparisonBytes(a[0]) : getAddressesComparisonBytes(a); const comparisonBytesB = Array.isArray(b) ? getAddressesComparisonBytes(b[0]) : getAddressesComparisonBytes(b);
[ "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/2fdda8a22cb46f76c8f92ac2bdcbd9b25acd3e21
client/src/components/Settings/Clients/ClientsTable.js
const comparisonBytesA = Array.isArray(a) ? getAddressesComparisonBytes(a[0]) : getAddressesComparisonBytes(a); const comparisonBytesB = Array.isArray(b) ? getAddressesComparisonBytes(b[0]) : getAddressesComparisonBytes(b);
<mask> * @returns {number} -1 | 0 | 1 <mask> */ <mask> export const sortIp = (a, b) => { <mask> try { <mask> const comparisonBytesA = getAddressesComparisonBytes(a); <mask> const comparisonBytesB = getAddressesComparisonBytes(b); <mask> <mask> for (let i = 0; i < comparisonBytesA.length; i += 1) { <mask> const byteA = comparisonBytesA[i]; <mask> const byteB = comparisonBytesB[i]; <mask> </s> Pull request: 4143 sort client ids Merge in DNS/adguard-home from 4143-clients-sort to master Updates #4143. Squashed commit of the following: commit a4b547eb46a54bdfdc7d342fab5f8ecfa54f5d06 Merge: d369c11c d82b2902 Author: Ildar Kamalov <[email protected]> Date: Thu Jan 20 11:58:42 2022 +0300 Merge branch 'master' into 4143-clients-sort commit d369c11c69665510043f63e0283e1ca1b2974289 Author: Ildar Kamalov <[email protected]> Date: Wed Jan 19 16:53:39 2022 +0300 client: fix sort ip method commit d767a1199c37ad9df7f3bc2d362d840b0226d836 Author: Ildar Kamalov <[email protected]> Date: Wed Jan 19 16:23:23 2022 +0300 client: sort client ids </s> remove import { splitByNewLine, countClientsStatistics } from '../../../helpers/helpers'; </s> add import { splitByNewLine, countClientsStatistics, sortIp } from '../../../helpers/helpers';
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/2fdda8a22cb46f76c8f92ac2bdcbd9b25acd3e21
client/src/helpers/helpers.js
"client_settings": "Client settings",
<mask> { <mask> "example_upstream_reserved": "you can specify DNS upstream <0>for a specific domain(s)<\/0>", <mask> "upstream_parallel": "Use parallel queries to speed up resolving by simultaneously querying all upstream servers", <mask> "bootstrap_dns": "Bootstrap DNS servers", <mask> "bootstrap_dns_desc": "Bootstrap DNS servers are used to resolve IP addresses of the DoH\/DoT resolvers you specify as upstreams.", <mask> "url_added_successfully": "URL added successfully", </s> - client: fix update now button and notification </s> remove "client_settings": "Client settings", </s> add </s> remove dispatch(addSuccessToast('updates_checked')); </s> add const { dnsVersion } = getState().dashboard; const currentVersion = dnsVersion === 'undefined' ? 0 : dnsVersion; if (data && versionCompare(currentVersion, data.new_version) === -1) { dispatch(addSuccessToast('updates_checked')); } else { dispatch(addSuccessToast('updates_version_equal')); } </s> remove const newVersion = await apiClient.getGlobalVersion({ recheck_now: recheck }); dispatch(getVersionSuccess(newVersion)); </s> add const data = await apiClient.getGlobalVersion({ recheck_now: recheck }); dispatch(getVersionSuccess(data)); </s> remove export const getVersion = (recheck = false) => async (dispatch) => { </s> add export const getVersion = (recheck = false) => async (dispatch, getState) => {
[ "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/2fe9819150f3a6d5eeeee632879eb85dc632559f
client/src/__locales/en.json
"version": "Version",
<mask> "settings": "Settings", <mask> "filters": "Filters", <mask> "query_log": "Query Log", <mask> "faq": "FAQ", <mask> "version": "version", <mask> "address": "address", <mask> "on": "ON", <mask> "off": "OFF", <mask> "copyright": "Copyright", <mask> "homepage": "Homepage", </s> - client: fix update now button and notification </s> remove return state; </s> add return { ...state, processingVersion: false, }; </s> remove dispatch(addSuccessToast('updates_checked')); </s> add const { dnsVersion } = getState().dashboard; const currentVersion = dnsVersion === 'undefined' ? 0 : dnsVersion; if (data && versionCompare(currentVersion, data.new_version) === -1) { dispatch(addSuccessToast('updates_checked')); } else { dispatch(addSuccessToast('updates_version_equal')); } </s> remove const newVersion = await apiClient.getGlobalVersion({ recheck_now: recheck }); dispatch(getVersionSuccess(newVersion)); </s> add const data = await apiClient.getGlobalVersion({ recheck_now: recheck }); dispatch(getVersionSuccess(data)); </s> remove export const getVersion = (recheck = false) => async (dispatch) => { </s> add export const getVersion = (recheck = false) => async (dispatch, getState) => {
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/2fe9819150f3a6d5eeeee632879eb85dc632559f
client/src/__locales/en.json
<mask> "general_settings": "General settings", <mask> "dns_settings": "DNS settings", <mask> "encryption_settings": "Encryption settings", <mask> "dhcp_settings": "DHCP settings", <mask> "client_settings": "Client settings", <mask> "upstream_dns": "Upstream DNS servers", <mask> "upstream_dns_hint": "If you keep this field empty, AdGuard Home will use <a href='https:\/\/1.1.1.1\/' target='_blank'>Cloudflare DNS<\/a> as an upstream.", <mask> "test_upstream_btn": "Test upstreams", <mask> "apply_btn": "Apply", <mask> "disabled_filtering_toast": "Disabled filtering", </s> - client: fix update now button and notification </s> remove return state; </s> add return { ...state, processingVersion: false, }; </s> remove dispatch(addSuccessToast('updates_checked')); </s> add const { dnsVersion } = getState().dashboard; const currentVersion = dnsVersion === 'undefined' ? 0 : dnsVersion; if (data && versionCompare(currentVersion, data.new_version) === -1) { dispatch(addSuccessToast('updates_checked')); } else { dispatch(addSuccessToast('updates_version_equal')); } </s> remove const newVersion = await apiClient.getGlobalVersion({ recheck_now: recheck }); dispatch(getVersionSuccess(newVersion)); </s> add const data = await apiClient.getGlobalVersion({ recheck_now: recheck }); dispatch(getVersionSuccess(data));
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/2fe9819150f3a6d5eeeee632879eb85dc632559f
client/src/__locales/en.json
"updates_version_equal": "AdGuard Home is up-to-date",
<mask> "access_settings_saved": "Access settings successfully saved", <mask> "updates_checked": "Updates successfully checked", <mask> "check_updates_now": "Check for updates now", <mask> "dns_privacy": "DNS Privacy", <mask> "setup_dns_privacy_1": "<0>DNS-over-TLS:</0> Use <1>{{address}}</1> string.", <mask> "setup_dns_privacy_2": "<0>DNS-over-HTTPS:</0> Use <1>{{address}}</1> string.", </s> - client: fix update now button and notification </s> remove "client_settings": "Client settings", </s> add </s> remove return state; </s> add return { ...state, processingVersion: false, }; </s> remove dispatch(addSuccessToast('updates_checked')); </s> add const { dnsVersion } = getState().dashboard; const currentVersion = dnsVersion === 'undefined' ? 0 : dnsVersion; if (data && versionCompare(currentVersion, data.new_version) === -1) { dispatch(addSuccessToast('updates_checked')); } else { dispatch(addSuccessToast('updates_version_equal')); } </s> remove const newVersion = await apiClient.getGlobalVersion({ recheck_now: recheck }); dispatch(getVersionSuccess(newVersion)); </s> add const data = await apiClient.getGlobalVersion({ recheck_now: recheck }); dispatch(getVersionSuccess(data)); </s> remove export const getVersion = (recheck = false) => async (dispatch) => { </s> add export const getVersion = (recheck = false) => async (dispatch, getState) => {
[ "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/2fe9819150f3a6d5eeeee632879eb85dc632559f
client/src/__locales/en.json
import versionCompare from '../helpers/versionCompare';
<mask> import axios from 'axios'; <mask> <mask> import { normalizeHistory, normalizeFilteringStatus, normalizeLogs, normalizeTextarea, sortClients } from '../helpers/helpers'; <mask> import { SETTINGS_NAMES, CHECK_TIMEOUT } from '../helpers/constants'; <mask> import { getTlsStatus } from './encryption'; <mask> import Api from '../api/Api'; <mask> <mask> const apiClient = new Api(); </s> - client: fix update now button and notification </s> remove dispatch(addSuccessToast('updates_checked')); </s> add const { dnsVersion } = getState().dashboard; const currentVersion = dnsVersion === 'undefined' ? 0 : dnsVersion; if (data && versionCompare(currentVersion, data.new_version) === -1) { dispatch(addSuccessToast('updates_checked')); } else { dispatch(addSuccessToast('updates_version_equal')); } </s> remove const newVersion = await apiClient.getGlobalVersion({ recheck_now: recheck }); dispatch(getVersionSuccess(newVersion)); </s> add const data = await apiClient.getGlobalVersion({ recheck_now: recheck }); dispatch(getVersionSuccess(data)); </s> remove export const getVersion = (recheck = false) => async (dispatch) => { </s> add export const getVersion = (recheck = false) => async (dispatch, getState) => { </s> remove return state; </s> add return { ...state, processingVersion: false, };
[ "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/2fe9819150f3a6d5eeeee632879eb85dc632559f
client/src/actions/index.js
export const getVersion = (recheck = false) => async (dispatch, getState) => {
<mask> export const getVersionRequest = createAction('GET_VERSION_REQUEST'); <mask> export const getVersionFailure = createAction('GET_VERSION_FAILURE'); <mask> export const getVersionSuccess = createAction('GET_VERSION_SUCCESS'); <mask> <mask> export const getVersion = (recheck = false) => async (dispatch) => { <mask> dispatch(getVersionRequest()); <mask> try { <mask> const newVersion = await apiClient.getGlobalVersion({ recheck_now: recheck }); <mask> dispatch(getVersionSuccess(newVersion)); <mask> if (recheck) { </s> - client: fix update now button and notification </s> remove const newVersion = await apiClient.getGlobalVersion({ recheck_now: recheck }); dispatch(getVersionSuccess(newVersion)); </s> add const data = await apiClient.getGlobalVersion({ recheck_now: recheck }); dispatch(getVersionSuccess(data)); </s> remove dispatch(addSuccessToast('updates_checked')); </s> add const { dnsVersion } = getState().dashboard; const currentVersion = dnsVersion === 'undefined' ? 0 : dnsVersion; if (data && versionCompare(currentVersion, data.new_version) === -1) { dispatch(addSuccessToast('updates_checked')); } else { dispatch(addSuccessToast('updates_version_equal')); } </s> remove return state; </s> add return { ...state, processingVersion: false, };
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/2fe9819150f3a6d5eeeee632879eb85dc632559f
client/src/actions/index.js
const data = await apiClient.getGlobalVersion({ recheck_now: recheck }); dispatch(getVersionSuccess(data));
<mask> <mask> export const getVersion = (recheck = false) => async (dispatch) => { <mask> dispatch(getVersionRequest()); <mask> try { <mask> const newVersion = await apiClient.getGlobalVersion({ recheck_now: recheck }); <mask> dispatch(getVersionSuccess(newVersion)); <mask> if (recheck) { <mask> dispatch(addSuccessToast('updates_checked')); <mask> } <mask> } catch (error) { <mask> dispatch(addErrorToast({ error })); </s> - client: fix update now button and notification </s> remove export const getVersion = (recheck = false) => async (dispatch) => { </s> add export const getVersion = (recheck = false) => async (dispatch, getState) => { </s> remove dispatch(addSuccessToast('updates_checked')); </s> add const { dnsVersion } = getState().dashboard; const currentVersion = dnsVersion === 'undefined' ? 0 : dnsVersion; if (data && versionCompare(currentVersion, data.new_version) === -1) { dispatch(addSuccessToast('updates_checked')); } else { dispatch(addSuccessToast('updates_version_equal')); } </s> remove return state; </s> add return { ...state, processingVersion: false, };
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/2fe9819150f3a6d5eeeee632879eb85dc632559f
client/src/actions/index.js
const { dnsVersion } = getState().dashboard; const currentVersion = dnsVersion === 'undefined' ? 0 : dnsVersion; if (data && versionCompare(currentVersion, data.new_version) === -1) { dispatch(addSuccessToast('updates_checked')); } else { dispatch(addSuccessToast('updates_version_equal')); }
<mask> try { <mask> const newVersion = await apiClient.getGlobalVersion({ recheck_now: recheck }); <mask> dispatch(getVersionSuccess(newVersion)); <mask> if (recheck) { <mask> dispatch(addSuccessToast('updates_checked')); <mask> } <mask> } catch (error) { <mask> dispatch(addErrorToast({ error })); <mask> dispatch(getVersionFailure()); <mask> } </s> - client: fix update now button and notification </s> remove const newVersion = await apiClient.getGlobalVersion({ recheck_now: recheck }); dispatch(getVersionSuccess(newVersion)); </s> add const data = await apiClient.getGlobalVersion({ recheck_now: recheck }); dispatch(getVersionSuccess(data)); </s> remove export const getVersion = (recheck = false) => async (dispatch) => { </s> add export const getVersion = (recheck = false) => async (dispatch, getState) => { </s> remove return state; </s> add return { ...state, processingVersion: false, };
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/2fe9819150f3a6d5eeeee632879eb85dc632559f
client/src/actions/index.js
return { ...state, processingVersion: false, };
<mask> }; <mask> return newState; <mask> } <mask> <mask> return state; <mask> }, <mask> <mask> [actions.getUpdateRequest]: state => ({ ...state, processingUpdate: true }), <mask> [actions.getUpdateFailure]: state => ({ ...state, processingUpdate: false }), <mask> [actions.getUpdateSuccess]: (state) => { </s> - client: fix update now button and notification </s> remove export const getVersion = (recheck = false) => async (dispatch) => { </s> add export const getVersion = (recheck = false) => async (dispatch, getState) => { </s> remove const newVersion = await apiClient.getGlobalVersion({ recheck_now: recheck }); dispatch(getVersionSuccess(newVersion)); </s> add const data = await apiClient.getGlobalVersion({ recheck_now: recheck }); dispatch(getVersionSuccess(data)); </s> remove dispatch(addSuccessToast('updates_checked')); </s> add const { dnsVersion } = getState().dashboard; const currentVersion = dnsVersion === 'undefined' ? 0 : dnsVersion; if (data && versionCompare(currentVersion, data.new_version) === -1) { dispatch(addSuccessToast('updates_checked')); } else { dispatch(addSuccessToast('updates_version_equal')); }
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/2fe9819150f3a6d5eeeee632879eb85dc632559f
client/src/reducers/index.js
<mask> package main <mask> <mask> import ( <mask> "bufio" <mask> "fmt" <mask> stdlog "log" <mask> "net" <mask> "net/http" <mask> "os" </s> Initial implementation of welcome/firstrun/installer page in go backend </s> remove "net" </s> add </s> remove data := struct { Web ipport `json:"web"` DNS ipport `json:"dns"` }{} </s> add </s> remove "golang.org/x/crypto/ssh/terminal" </s> add
[ "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/302c3a767a4d296d1f8cf5d895be8af2477113ce
app.go
<mask> <mask> "github.com/gobuffalo/packr" <mask> <mask> "github.com/hmage/golibs/log" <mask> "golang.org/x/crypto/ssh/terminal" <mask> ) <mask> <mask> // VersionString will be set through ldflags, contains current version <mask> var VersionString = "undefined" <mask> </s> Initial implementation of welcome/firstrun/installer page in go backend </s> remove // TODO: replace mockup with actual data data.Web.IP = "192.168.104.104" data.Web.Port = 3000 data.DNS.IP = "192.168.104.104" data.DNS.Port = 53 </s> add // find an interface with an ipv4 address addr := findIPv4IfaceAddr(ifaces) if len(addr) == 0 { httpError(w, http.StatusServiceUnavailable, "Couldn't find any interface with IPv4, plase try again later") return } data.Web.IP = addr data.DNS.IP = addr data.Web.Port = 3000 // TODO: find out if port 80 is available -- if not, fall back to 3000 data.DNS.Port = 53 // TODO: find out if port 53 is available -- if not, show a big warning </s> remove func promptAndGet(prompt string) (string, error) { for { fmt.Print(prompt) input, err := getInput() if err != nil { log.Printf("Failed to get input, aborting: %s", err) return "", err } if len(input) != 0 { return input, nil } // try again } } func promptAndGetPassword(prompt string) (string, error) { for { fmt.Print(prompt) password, err := terminal.ReadPassword(int(os.Stdin.Fd())) fmt.Print("\n") if err != nil { log.Printf("Failed to get input, aborting: %s", err) return "", err } if len(password) != 0 { return string(password), nil } // try again } } func askUsernamePasswordIfPossible() error { configFile := config.getConfigFilename() _, err := os.Stat(configFile) if !os.IsNotExist(err) { // do nothing, file exists return nil } if !terminal.IsTerminal(int(os.Stdin.Fd())) { return nil // do nothing } if !terminal.IsTerminal(int(os.Stdout.Fd())) { return nil // do nothing } fmt.Printf("Would you like to set user/password for the web interface authentication (yes/no)?\n") yesno, err := promptAndGet("Please type 'yes' or 'no': ") if err != nil { return err } if yesno[0] != 'y' && yesno[0] != 'Y' { return nil } username, err := promptAndGet("Please enter the username: ") if err != nil { return err } password, err := promptAndGetPassword("Please enter the password: ") if err != nil { return err } password2, err := promptAndGetPassword("Please enter password again: ") if err != nil { return err } if password2 != password { fmt.Printf("Passwords do not match! Aborting\n") os.Exit(1) } config.AuthName = username config.AuthPass = password return nil } </s> add </s> remove err = upgradeConfig() </s> add err := upgradeConfig()
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/302c3a767a4d296d1f8cf5d895be8af2477113ce
app.go
config.firstRun = detectFirstRun()
<mask> if args.runningAsService { <mask> log.Printf("AdGuard Home is running as a service") <mask> } <mask> <mask> err := askUsernamePasswordIfPossible() <mask> if err != nil { <mask> log.Fatal(err) <mask> } <mask> <mask> // Do the upgrade if necessary <mask> err = upgradeConfig() <mask> if err != nil { <mask> log.Fatal(err) </s> Initial implementation of welcome/firstrun/installer page in go backend </s> remove err = upgradeConfig() </s> add err := upgradeConfig() </s> remove func promptAndGet(prompt string) (string, error) { for { fmt.Print(prompt) input, err := getInput() if err != nil { log.Printf("Failed to get input, aborting: %s", err) return "", err } if len(input) != 0 { return input, nil } // try again } } func promptAndGetPassword(prompt string) (string, error) { for { fmt.Print(prompt) password, err := terminal.ReadPassword(int(os.Stdin.Fd())) fmt.Print("\n") if err != nil { log.Printf("Failed to get input, aborting: %s", err) return "", err } if len(password) != 0 { return string(password), nil } // try again } } func askUsernamePasswordIfPossible() error { configFile := config.getConfigFilename() _, err := os.Stat(configFile) if !os.IsNotExist(err) { // do nothing, file exists return nil } if !terminal.IsTerminal(int(os.Stdin.Fd())) { return nil // do nothing } if !terminal.IsTerminal(int(os.Stdout.Fd())) { return nil // do nothing } fmt.Printf("Would you like to set user/password for the web interface authentication (yes/no)?\n") yesno, err := promptAndGet("Please type 'yes' or 'no': ") if err != nil { return err } if yesno[0] != 'y' && yesno[0] != 'Y' { return nil } username, err := promptAndGet("Please enter the username: ") if err != nil { return err } password, err := promptAndGetPassword("Please enter the password: ") if err != nil { return err } password2, err := promptAndGetPassword("Please enter password again: ") if err != nil { return err } if password2 != password { fmt.Printf("Passwords do not match! Aborting\n") os.Exit(1) } config.AuthName = username config.AuthPass = password return nil } </s> add </s> remove if ifaces[i].Flags&net.FlagLoopback != 0 { // it's a loopback, skip it continue } if ifaces[i].Flags&net.FlagBroadcast == 0 { // this interface doesn't support broadcast, skip it continue } if ifaces[i].Flags&net.FlagPointToPoint != 0 { // this interface is ppp, don't do dhcp over it continue } iface := responseInterface{ Name: ifaces[i].Name, MTU: ifaces[i].MTU, HardwareAddr: ifaces[i].HardwareAddr.String(), } addrs, errAddrs := ifaces[i].Addrs() if errAddrs != nil { httpError(w, http.StatusInternalServerError, "Failed to get addresses for interface %v: %s", ifaces[i].Name, errAddrs) return } for _, addr := range addrs { iface.Addresses = append(iface.Addresses, addr.String()) } if len(iface.Addresses) == 0 { // this interface has no addresses, skip it continue } response[ifaces[i].Name] = iface </s> add response[ifaces[i].Name] = ifaces[i] </s> remove // TODO: replace mockup with actual data data.Web.IP = "192.168.104.104" data.Web.Port = 3000 data.DNS.IP = "192.168.104.104" data.DNS.Port = 53 </s> add // find an interface with an ipv4 address addr := findIPv4IfaceAddr(ifaces) if len(addr) == 0 { httpError(w, http.StatusServiceUnavailable, "Couldn't find any interface with IPv4, plase try again later") return } data.Web.IP = addr data.DNS.IP = addr data.Web.Port = 3000 // TODO: find out if port 80 is available -- if not, fall back to 3000 data.DNS.Port = 53 // TODO: find out if port 53 is available -- if not, show a big warning </s> remove type responseInterface struct { Name string `json:"name"` MTU int `json:"mtu"` HardwareAddr string `json:"hardware_address"` Addresses []string `json:"ip_addresses"` } </s> add
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/302c3a767a4d296d1f8cf5d895be8af2477113ce
app.go
err := upgradeConfig()
<mask> log.Fatal(err) <mask> } <mask> <mask> // Do the upgrade if necessary <mask> err = upgradeConfig() <mask> if err != nil { <mask> log.Fatal(err) <mask> } <mask> <mask> // parse from config file </s> Initial implementation of welcome/firstrun/installer page in go backend </s> remove err := askUsernamePasswordIfPossible() if err != nil { log.Fatal(err) } </s> add config.firstRun = detectFirstRun() </s> remove func promptAndGet(prompt string) (string, error) { for { fmt.Print(prompt) input, err := getInput() if err != nil { log.Printf("Failed to get input, aborting: %s", err) return "", err } if len(input) != 0 { return input, nil } // try again } } func promptAndGetPassword(prompt string) (string, error) { for { fmt.Print(prompt) password, err := terminal.ReadPassword(int(os.Stdin.Fd())) fmt.Print("\n") if err != nil { log.Printf("Failed to get input, aborting: %s", err) return "", err } if len(password) != 0 { return string(password), nil } // try again } } func askUsernamePasswordIfPossible() error { configFile := config.getConfigFilename() _, err := os.Stat(configFile) if !os.IsNotExist(err) { // do nothing, file exists return nil } if !terminal.IsTerminal(int(os.Stdin.Fd())) { return nil // do nothing } if !terminal.IsTerminal(int(os.Stdout.Fd())) { return nil // do nothing } fmt.Printf("Would you like to set user/password for the web interface authentication (yes/no)?\n") yesno, err := promptAndGet("Please type 'yes' or 'no': ") if err != nil { return err } if yesno[0] != 'y' && yesno[0] != 'Y' { return nil } username, err := promptAndGet("Please enter the username: ") if err != nil { return err } password, err := promptAndGetPassword("Please enter the password: ") if err != nil { return err } password2, err := promptAndGetPassword("Please enter password again: ") if err != nil { return err } if password2 != password { fmt.Printf("Passwords do not match! Aborting\n") os.Exit(1) } config.AuthName = username config.AuthPass = password return nil } </s> add </s> remove newSettings := map[string]interface{}{} </s> add newSettings := firstRunData{} </s> remove func getInput() (string, error) { scanner := bufio.NewScanner(os.Stdin) scanner.Scan() text := scanner.Text() err := scanner.Err() return text, err } </s> add </s> remove if ifaces[i].Flags&net.FlagLoopback != 0 { // it's a loopback, skip it continue } if ifaces[i].Flags&net.FlagBroadcast == 0 { // this interface doesn't support broadcast, skip it continue } if ifaces[i].Flags&net.FlagPointToPoint != 0 { // this interface is ppp, don't do dhcp over it continue } iface := responseInterface{ Name: ifaces[i].Name, MTU: ifaces[i].MTU, HardwareAddr: ifaces[i].HardwareAddr.String(), } addrs, errAddrs := ifaces[i].Addrs() if errAddrs != nil { httpError(w, http.StatusInternalServerError, "Failed to get addresses for interface %v: %s", ifaces[i].Name, errAddrs) return } for _, addr := range addrs { iface.Addresses = append(iface.Addresses, addr.String()) } if len(iface.Addresses) == 0 { // this interface has no addresses, skip it continue } response[ifaces[i].Name] = iface </s> add response[ifaces[i].Name] = ifaces[i]
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/302c3a767a4d296d1f8cf5d895be8af2477113ce
app.go
// if not configured, redirect / to /install.html, otherwise redirect /install.html to / http.Handle("/", postInstallHandler(optionalAuthHandler(http.FileServer(box)))) http.Handle("/install.html", preInstallHandler(http.FileServer(box)))
<mask> go periodicallyRefreshFilters() <mask> <mask> // Initialize and run the admin Web interface <mask> box := packr.NewBox("build/static") <mask> http.Handle("/", optionalAuthHandler(http.FileServer(box))) <mask> registerControlHandlers() <mask> <mask> address := net.JoinHostPort(config.BindHost, strconv.Itoa(config.BindPort)) <mask> URL := fmt.Sprintf("http://%s", address) <mask> log.Println("Go to " + URL) </s> Initial implementation of welcome/firstrun/installer page in go backend </s> remove func getInput() (string, error) { scanner := bufio.NewScanner(os.Stdin) scanner.Scan() text := scanner.Text() err := scanner.Err() return text, err } </s> add </s> remove // TODO: replace mockup with actual data data.Web.IP = "192.168.104.104" data.Web.Port = 3000 data.DNS.IP = "192.168.104.104" data.DNS.Port = 53 </s> add // find an interface with an ipv4 address addr := findIPv4IfaceAddr(ifaces) if len(addr) == 0 { httpError(w, http.StatusServiceUnavailable, "Couldn't find any interface with IPv4, plase try again later") return } data.Web.IP = addr data.DNS.IP = addr data.Web.Port = 3000 // TODO: find out if port 80 is available -- if not, fall back to 3000 data.DNS.Port = 53 // TODO: find out if port 53 is available -- if not, show a big warning </s> remove if ifaces[i].Flags&net.FlagLoopback != 0 { // it's a loopback, skip it continue } if ifaces[i].Flags&net.FlagBroadcast == 0 { // this interface doesn't support broadcast, skip it continue } if ifaces[i].Flags&net.FlagPointToPoint != 0 { // this interface is ppp, don't do dhcp over it continue } iface := responseInterface{ Name: ifaces[i].Name, MTU: ifaces[i].MTU, HardwareAddr: ifaces[i].HardwareAddr.String(), } addrs, errAddrs := ifaces[i].Addrs() if errAddrs != nil { httpError(w, http.StatusInternalServerError, "Failed to get addresses for interface %v: %s", ifaces[i].Name, errAddrs) return } for _, addr := range addrs { iface.Addresses = append(iface.Addresses, addr.String()) } if len(iface.Addresses) == 0 { // this interface has no addresses, skip it continue } response[ifaces[i].Name] = iface </s> add response[ifaces[i].Name] = ifaces[i] </s> remove func promptAndGet(prompt string) (string, error) { for { fmt.Print(prompt) input, err := getInput() if err != nil { log.Printf("Failed to get input, aborting: %s", err) return "", err } if len(input) != 0 { return input, nil } // try again } } func promptAndGetPassword(prompt string) (string, error) { for { fmt.Print(prompt) password, err := terminal.ReadPassword(int(os.Stdin.Fd())) fmt.Print("\n") if err != nil { log.Printf("Failed to get input, aborting: %s", err) return "", err } if len(password) != 0 { return string(password), nil } // try again } } func askUsernamePasswordIfPossible() error { configFile := config.getConfigFilename() _, err := os.Stat(configFile) if !os.IsNotExist(err) { // do nothing, file exists return nil } if !terminal.IsTerminal(int(os.Stdin.Fd())) { return nil // do nothing } if !terminal.IsTerminal(int(os.Stdout.Fd())) { return nil // do nothing } fmt.Printf("Would you like to set user/password for the web interface authentication (yes/no)?\n") yesno, err := promptAndGet("Please type 'yes' or 'no': ") if err != nil { return err } if yesno[0] != 'y' && yesno[0] != 'Y' { return nil } username, err := promptAndGet("Please enter the username: ") if err != nil { return err } password, err := promptAndGetPassword("Please enter the password: ") if err != nil { return err } password2, err := promptAndGetPassword("Please enter password again: ") if err != nil { return err } if password2 != password { fmt.Printf("Passwords do not match! Aborting\n") os.Exit(1) } config.AuthName = username config.AuthPass = password return nil } </s> add
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/302c3a767a4d296d1f8cf5d895be8af2477113ce
app.go
<mask> log.Printf("Couldn't stop DHCP server: %s", err) <mask> } <mask> } <mask> <mask> func getInput() (string, error) { <mask> scanner := bufio.NewScanner(os.Stdin) <mask> scanner.Scan() <mask> text := scanner.Text() <mask> err := scanner.Err() <mask> return text, err <mask> } <mask> <mask> // command-line arguments <mask> type options struct { <mask> verbose bool // is verbose logging enabled <mask> configFilename string // path to the config file <mask> bindHost string // host address to bind HTTP server on </s> Initial implementation of welcome/firstrun/installer page in go backend </s> remove func promptAndGet(prompt string) (string, error) { for { fmt.Print(prompt) input, err := getInput() if err != nil { log.Printf("Failed to get input, aborting: %s", err) return "", err } if len(input) != 0 { return input, nil } // try again } } func promptAndGetPassword(prompt string) (string, error) { for { fmt.Print(prompt) password, err := terminal.ReadPassword(int(os.Stdin.Fd())) fmt.Print("\n") if err != nil { log.Printf("Failed to get input, aborting: %s", err) return "", err } if len(password) != 0 { return string(password), nil } // try again } } func askUsernamePasswordIfPossible() error { configFile := config.getConfigFilename() _, err := os.Stat(configFile) if !os.IsNotExist(err) { // do nothing, file exists return nil } if !terminal.IsTerminal(int(os.Stdin.Fd())) { return nil // do nothing } if !terminal.IsTerminal(int(os.Stdout.Fd())) { return nil // do nothing } fmt.Printf("Would you like to set user/password for the web interface authentication (yes/no)?\n") yesno, err := promptAndGet("Please type 'yes' or 'no': ") if err != nil { return err } if yesno[0] != 'y' && yesno[0] != 'Y' { return nil } username, err := promptAndGet("Please enter the username: ") if err != nil { return err } password, err := promptAndGetPassword("Please enter the password: ") if err != nil { return err } password2, err := promptAndGetPassword("Please enter password again: ") if err != nil { return err } if password2 != password { fmt.Printf("Passwords do not match! Aborting\n") os.Exit(1) } config.AuthName = username config.AuthPass = password return nil } </s> add </s> remove err = upgradeConfig() </s> add err := upgradeConfig() </s> remove newSettings := map[string]interface{}{} </s> add newSettings := firstRunData{} </s> remove type responseInterface struct { Name string `json:"name"` MTU int `json:"mtu"` HardwareAddr string `json:"hardware_address"` Addresses []string `json:"ip_addresses"` } </s> add
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/302c3a767a4d296d1f8cf5d895be8af2477113ce
app.go
<mask> } <mask> <mask> return o <mask> } <mask> <mask> func promptAndGet(prompt string) (string, error) { <mask> for { <mask> fmt.Print(prompt) <mask> input, err := getInput() <mask> if err != nil { <mask> log.Printf("Failed to get input, aborting: %s", err) <mask> return "", err <mask> } <mask> if len(input) != 0 { <mask> return input, nil <mask> } <mask> // try again <mask> } <mask> } <mask> <mask> func promptAndGetPassword(prompt string) (string, error) { <mask> for { <mask> fmt.Print(prompt) <mask> password, err := terminal.ReadPassword(int(os.Stdin.Fd())) <mask> fmt.Print("\n") <mask> if err != nil { <mask> log.Printf("Failed to get input, aborting: %s", err) <mask> return "", err <mask> } <mask> if len(password) != 0 { <mask> return string(password), nil <mask> } <mask> // try again <mask> } <mask> } <mask> <mask> func askUsernamePasswordIfPossible() error { <mask> configFile := config.getConfigFilename() <mask> _, err := os.Stat(configFile) <mask> if !os.IsNotExist(err) { <mask> // do nothing, file exists <mask> return nil <mask> } <mask> if !terminal.IsTerminal(int(os.Stdin.Fd())) { <mask> return nil // do nothing <mask> } <mask> if !terminal.IsTerminal(int(os.Stdout.Fd())) { <mask> return nil // do nothing <mask> } <mask> fmt.Printf("Would you like to set user/password for the web interface authentication (yes/no)?\n") <mask> yesno, err := promptAndGet("Please type 'yes' or 'no': ") <mask> if err != nil { <mask> return err <mask> } <mask> if yesno[0] != 'y' && yesno[0] != 'Y' { <mask> return nil <mask> } <mask> username, err := promptAndGet("Please enter the username: ") <mask> if err != nil { <mask> return err <mask> } <mask> <mask> password, err := promptAndGetPassword("Please enter the password: ") <mask> if err != nil { <mask> return err <mask> } <mask> <mask> password2, err := promptAndGetPassword("Please enter password again: ") <mask> if err != nil { <mask> return err <mask> } <mask> if password2 != password { <mask> fmt.Printf("Passwords do not match! Aborting\n") <mask> os.Exit(1) <mask> } <mask> <mask> config.AuthName = username <mask> config.AuthPass = password <mask> return nil <mask> } </s> Initial implementation of welcome/firstrun/installer page in go backend </s> remove if ifaces[i].Flags&net.FlagLoopback != 0 { // it's a loopback, skip it continue } if ifaces[i].Flags&net.FlagBroadcast == 0 { // this interface doesn't support broadcast, skip it continue } if ifaces[i].Flags&net.FlagPointToPoint != 0 { // this interface is ppp, don't do dhcp over it continue } iface := responseInterface{ Name: ifaces[i].Name, MTU: ifaces[i].MTU, HardwareAddr: ifaces[i].HardwareAddr.String(), } addrs, errAddrs := ifaces[i].Addrs() if errAddrs != nil { httpError(w, http.StatusInternalServerError, "Failed to get addresses for interface %v: %s", ifaces[i].Name, errAddrs) return } for _, addr := range addrs { iface.Addresses = append(iface.Addresses, addr.String()) } if len(iface.Addresses) == 0 { // this interface has no addresses, skip it continue } response[ifaces[i].Name] = iface </s> add response[ifaces[i].Name] = ifaces[i] </s> remove err := askUsernamePasswordIfPossible() if err != nil { log.Fatal(err) } </s> add config.firstRun = detectFirstRun() </s> remove type ipport struct { IP string `json:"ip"` Port int `json:"port"` </s> add data := firstRunData{} ifaces, err := getValidNetInterfaces() if err != nil { httpError(w, http.StatusInternalServerError, "Couldn't get interfaces: %s", err) return } if len(ifaces) == 0 { httpError(w, http.StatusServiceUnavailable, "Couldn't find any legible interface, plase try again later") return </s> remove err = upgradeConfig() </s> add err := upgradeConfig() </s> remove newSettings := map[string]interface{}{} </s> add newSettings := firstRunData{}
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace" ]
https://github.com/AdguardTeam/AdGuardHome/commit/302c3a767a4d296d1f8cf5d895be8af2477113ce
app.go
firstRun bool // if set to true, don't run any services except HTTP web inteface, and serve only first-run html
<mask> // field ordering is important -- yaml fields will mirror ordering from here <mask> type configuration struct { <mask> ourConfigFilename string // Config filename (can be overridden via the command line arguments) <mask> ourBinaryDir string // Location of our directory, used to protect against CWD being somewhere else <mask> <mask> BindHost string `yaml:"bind_host"` <mask> BindPort int `yaml:"bind_port"` <mask> AuthName string `yaml:"auth_name"` <mask> AuthPass string `yaml:"auth_pass"` <mask> Language string `yaml:"language"` // two-letter ISO 639-1 language code </s> Initial implementation of welcome/firstrun/installer page in go backend </s> remove func getInput() (string, error) { scanner := bufio.NewScanner(os.Stdin) scanner.Scan() text := scanner.Text() err := scanner.Err() return text, err } </s> add </s> remove type responseInterface struct { Name string `json:"name"` MTU int `json:"mtu"` HardwareAddr string `json:"hardware_address"` Addresses []string `json:"ip_addresses"` } </s> add </s> remove data := struct { Web ipport `json:"web"` DNS ipport `json:"dns"` }{} </s> add </s> remove httpError(w, http.StatusInternalServerError, "Couldn't get list of interfaces: %s", err) </s> add httpError(w, http.StatusInternalServerError, "Couldn't get interfaces: %s", err)
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/302c3a767a4d296d1f8cf5d895be8af2477113ce
config.go
if config.firstRun { log.Tracef("Silently refusing to write config because first run and not configured yet") return nil }
<mask> c.Lock() <mask> defer c.Unlock() <mask> configFile := config.getConfigFilename() <mask> log.Printf("Writing YAML file: %s", configFile) <mask> yamlText, err := yaml.Marshal(&config) <mask> if err != nil { <mask> log.Printf("Couldn't generate YAML file: %s", err) </s> Initial implementation of welcome/firstrun/installer page in go backend </s> remove func promptAndGet(prompt string) (string, error) { for { fmt.Print(prompt) input, err := getInput() if err != nil { log.Printf("Failed to get input, aborting: %s", err) return "", err } if len(input) != 0 { return input, nil } // try again } } func promptAndGetPassword(prompt string) (string, error) { for { fmt.Print(prompt) password, err := terminal.ReadPassword(int(os.Stdin.Fd())) fmt.Print("\n") if err != nil { log.Printf("Failed to get input, aborting: %s", err) return "", err } if len(password) != 0 { return string(password), nil } // try again } } func askUsernamePasswordIfPossible() error { configFile := config.getConfigFilename() _, err := os.Stat(configFile) if !os.IsNotExist(err) { // do nothing, file exists return nil } if !terminal.IsTerminal(int(os.Stdin.Fd())) { return nil // do nothing } if !terminal.IsTerminal(int(os.Stdout.Fd())) { return nil // do nothing } fmt.Printf("Would you like to set user/password for the web interface authentication (yes/no)?\n") yesno, err := promptAndGet("Please type 'yes' or 'no': ") if err != nil { return err } if yesno[0] != 'y' && yesno[0] != 'Y' { return nil } username, err := promptAndGet("Please enter the username: ") if err != nil { return err } password, err := promptAndGetPassword("Please enter the password: ") if err != nil { return err } password2, err := promptAndGetPassword("Please enter password again: ") if err != nil { return err } if password2 != password { fmt.Printf("Passwords do not match! Aborting\n") os.Exit(1) } config.AuthName = username config.AuthPass = password return nil } </s> add </s> remove ifaces, err := net.Interfaces() </s> add ifaces, err := getValidNetInterfaces() </s> remove newSettings := map[string]interface{}{} </s> add newSettings := firstRunData{} </s> remove httpError(w, http.StatusInternalServerError, "Couldn't get list of interfaces: %s", err) </s> add httpError(w, http.StatusInternalServerError, "Couldn't get interfaces: %s", err) </s> remove func getInput() (string, error) { scanner := bufio.NewScanner(os.Stdin) scanner.Scan() text := scanner.Text() err := scanner.Err() return text, err } </s> add
[ "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/302c3a767a4d296d1f8cf5d895be8af2477113ce
config.go
type ipport struct { IP string `json:"ip"` Port int `json:"port"` } type firstRunData struct { Web ipport `json:"web"` DNS ipport `json:"dns"` Username string `json:"username,omitempty"` Password string `json:"password,omitempty"` }
<mask> } <mask> } <mask> <mask> func handleGetDefaultAddresses(w http.ResponseWriter, r *http.Request) { <mask> data := firstRunData{} <mask> ifaces, err := getValidNetInterfaces() <mask> if err != nil { <mask> httpError(w, http.StatusInternalServerError, "Couldn't get interfaces: %s", err) <mask> return </s> Initial implementation of welcome/firstrun/installer page in go backend </s> remove type ipport struct { IP string `json:"ip"` Port int `json:"port"` </s> add data := firstRunData{} ifaces, err := getValidNetInterfaces() if err != nil { httpError(w, http.StatusInternalServerError, "Couldn't get interfaces: %s", err) return } if len(ifaces) == 0 { httpError(w, http.StatusServiceUnavailable, "Couldn't find any legible interface, plase try again later") return </s> remove ifaces, err := net.Interfaces() </s> add ifaces, err := getValidNetInterfaces() </s> remove newSettings := map[string]interface{}{} </s> add newSettings := firstRunData{} </s> remove httpError(w, http.StatusInternalServerError, "Couldn't get list of interfaces: %s", err) </s> add httpError(w, http.StatusInternalServerError, "Couldn't get interfaces: %s", err) </s> remove type responseInterface struct { Name string `json:"name"` MTU int `json:"mtu"` HardwareAddr string `json:"hardware_address"` Addresses []string `json:"ip_addresses"` } </s> add
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/302c3a767a4d296d1f8cf5d895be8af2477113ce
control.go
data := firstRunData{} ifaces, err := getValidNetInterfaces() if err != nil { httpError(w, http.StatusInternalServerError, "Couldn't get interfaces: %s", err) return } if len(ifaces) == 0 { httpError(w, http.StatusServiceUnavailable, "Couldn't find any legible interface, plase try again later") return
<mask> } <mask> } <mask> <mask> func handleGetDefaultAddresses(w http.ResponseWriter, r *http.Request) { <mask> type ipport struct { <mask> IP string `json:"ip"` <mask> Port int `json:"port"` <mask> } <mask> data := struct { <mask> Web ipport `json:"web"` <mask> DNS ipport `json:"dns"` <mask> }{} </s> Initial implementation of welcome/firstrun/installer page in go backend </s> remove data := struct { Web ipport `json:"web"` DNS ipport `json:"dns"` }{} </s> add </s> remove // TODO: replace mockup with actual data data.Web.IP = "192.168.104.104" data.Web.Port = 3000 data.DNS.IP = "192.168.104.104" data.DNS.Port = 53 </s> add // find an interface with an ipv4 address addr := findIPv4IfaceAddr(ifaces) if len(addr) == 0 { httpError(w, http.StatusServiceUnavailable, "Couldn't find any interface with IPv4, plase try again later") return } data.Web.IP = addr data.DNS.IP = addr data.Web.Port = 3000 // TODO: find out if port 80 is available -- if not, fall back to 3000 data.DNS.Port = 53 // TODO: find out if port 53 is available -- if not, show a big warning </s> remove newSettings := map[string]interface{}{} </s> add newSettings := firstRunData{} </s> remove type responseInterface struct { Name string `json:"name"` MTU int `json:"mtu"` HardwareAddr string `json:"hardware_address"` Addresses []string `json:"ip_addresses"` } </s> add
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/302c3a767a4d296d1f8cf5d895be8af2477113ce
control.go
<mask> type ipport struct { <mask> IP string `json:"ip"` <mask> Port int `json:"port"` <mask> } <mask> data := struct { <mask> Web ipport `json:"web"` <mask> DNS ipport `json:"dns"` <mask> }{} <mask> <mask> // TODO: replace mockup with actual data <mask> data.Web.IP = "192.168.104.104" <mask> data.Web.Port = 3000 <mask> data.DNS.IP = "192.168.104.104" </s> Initial implementation of welcome/firstrun/installer page in go backend </s> remove // TODO: replace mockup with actual data data.Web.IP = "192.168.104.104" data.Web.Port = 3000 data.DNS.IP = "192.168.104.104" data.DNS.Port = 53 </s> add // find an interface with an ipv4 address addr := findIPv4IfaceAddr(ifaces) if len(addr) == 0 { httpError(w, http.StatusServiceUnavailable, "Couldn't find any interface with IPv4, plase try again later") return } data.Web.IP = addr data.DNS.IP = addr data.Web.Port = 3000 // TODO: find out if port 80 is available -- if not, fall back to 3000 data.DNS.Port = 53 // TODO: find out if port 53 is available -- if not, show a big warning </s> remove type ipport struct { IP string `json:"ip"` Port int `json:"port"` </s> add data := firstRunData{} ifaces, err := getValidNetInterfaces() if err != nil { httpError(w, http.StatusInternalServerError, "Couldn't get interfaces: %s", err) return } if len(ifaces) == 0 { httpError(w, http.StatusServiceUnavailable, "Couldn't find any legible interface, plase try again later") return </s> remove err := json.NewEncoder(w).Encode(data) </s> add err = json.NewEncoder(w).Encode(data) </s> remove type responseInterface struct { Name string `json:"name"` MTU int `json:"mtu"` HardwareAddr string `json:"hardware_address"` Addresses []string `json:"ip_addresses"` } </s> add
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/302c3a767a4d296d1f8cf5d895be8af2477113ce
control.go
// find an interface with an ipv4 address addr := findIPv4IfaceAddr(ifaces) if len(addr) == 0 { httpError(w, http.StatusServiceUnavailable, "Couldn't find any interface with IPv4, plase try again later") return } data.Web.IP = addr data.DNS.IP = addr data.Web.Port = 3000 // TODO: find out if port 80 is available -- if not, fall back to 3000 data.DNS.Port = 53 // TODO: find out if port 53 is available -- if not, show a big warning
<mask> Web ipport `json:"web"` <mask> DNS ipport `json:"dns"` <mask> }{} <mask> <mask> // TODO: replace mockup with actual data <mask> data.Web.IP = "192.168.104.104" <mask> data.Web.Port = 3000 <mask> data.DNS.IP = "192.168.104.104" <mask> data.DNS.Port = 53 <mask> <mask> w.Header().Set("Content-Type", "application/json") <mask> err := json.NewEncoder(w).Encode(data) <mask> if err != nil { <mask> httpError(w, http.StatusInternalServerError, "Unable to marshal default addresses to json: %s", err) </s> Initial implementation of welcome/firstrun/installer page in go backend </s> remove data := struct { Web ipport `json:"web"` DNS ipport `json:"dns"` }{} </s> add </s> remove err := json.NewEncoder(w).Encode(data) </s> add err = json.NewEncoder(w).Encode(data) </s> remove type ipport struct { IP string `json:"ip"` Port int `json:"port"` </s> add data := firstRunData{} ifaces, err := getValidNetInterfaces() if err != nil { httpError(w, http.StatusInternalServerError, "Couldn't get interfaces: %s", err) return } if len(ifaces) == 0 { httpError(w, http.StatusServiceUnavailable, "Couldn't find any legible interface, plase try again later") return </s> remove if ifaces[i].Flags&net.FlagLoopback != 0 { // it's a loopback, skip it continue } if ifaces[i].Flags&net.FlagBroadcast == 0 { // this interface doesn't support broadcast, skip it continue } if ifaces[i].Flags&net.FlagPointToPoint != 0 { // this interface is ppp, don't do dhcp over it continue } iface := responseInterface{ Name: ifaces[i].Name, MTU: ifaces[i].MTU, HardwareAddr: ifaces[i].HardwareAddr.String(), } addrs, errAddrs := ifaces[i].Addrs() if errAddrs != nil { httpError(w, http.StatusInternalServerError, "Failed to get addresses for interface %v: %s", ifaces[i].Name, errAddrs) return } for _, addr := range addrs { iface.Addresses = append(iface.Addresses, addr.String()) } if len(iface.Addresses) == 0 { // this interface has no addresses, skip it continue } response[ifaces[i].Name] = iface </s> add response[ifaces[i].Name] = ifaces[i]
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/302c3a767a4d296d1f8cf5d895be8af2477113ce
control.go
err = json.NewEncoder(w).Encode(data)
<mask> data.DNS.IP = "192.168.104.104" <mask> data.DNS.Port = 53 <mask> <mask> w.Header().Set("Content-Type", "application/json") <mask> err := json.NewEncoder(w).Encode(data) <mask> if err != nil { <mask> httpError(w, http.StatusInternalServerError, "Unable to marshal default addresses to json: %s", err) <mask> return <mask> } <mask> } </s> Initial implementation of welcome/firstrun/installer page in go backend </s> remove // TODO: replace mockup with actual data data.Web.IP = "192.168.104.104" data.Web.Port = 3000 data.DNS.IP = "192.168.104.104" data.DNS.Port = 53 </s> add // find an interface with an ipv4 address addr := findIPv4IfaceAddr(ifaces) if len(addr) == 0 { httpError(w, http.StatusServiceUnavailable, "Couldn't find any interface with IPv4, plase try again later") return } data.Web.IP = addr data.DNS.IP = addr data.Web.Port = 3000 // TODO: find out if port 80 is available -- if not, fall back to 3000 data.DNS.Port = 53 // TODO: find out if port 53 is available -- if not, show a big warning </s> remove if ifaces[i].Flags&net.FlagLoopback != 0 { // it's a loopback, skip it continue } if ifaces[i].Flags&net.FlagBroadcast == 0 { // this interface doesn't support broadcast, skip it continue } if ifaces[i].Flags&net.FlagPointToPoint != 0 { // this interface is ppp, don't do dhcp over it continue } iface := responseInterface{ Name: ifaces[i].Name, MTU: ifaces[i].MTU, HardwareAddr: ifaces[i].HardwareAddr.String(), } addrs, errAddrs := ifaces[i].Addrs() if errAddrs != nil { httpError(w, http.StatusInternalServerError, "Failed to get addresses for interface %v: %s", ifaces[i].Name, errAddrs) return } for _, addr := range addrs { iface.Addresses = append(iface.Addresses, addr.String()) } if len(iface.Addresses) == 0 { // this interface has no addresses, skip it continue } response[ifaces[i].Name] = iface </s> add response[ifaces[i].Name] = ifaces[i] </s> remove newSettings := map[string]interface{}{} </s> add newSettings := firstRunData{} </s> remove data := struct { Web ipport `json:"web"` DNS ipport `json:"dns"` }{} </s> add </s> remove func promptAndGet(prompt string) (string, error) { for { fmt.Print(prompt) input, err := getInput() if err != nil { log.Printf("Failed to get input, aborting: %s", err) return "", err } if len(input) != 0 { return input, nil } // try again } } func promptAndGetPassword(prompt string) (string, error) { for { fmt.Print(prompt) password, err := terminal.ReadPassword(int(os.Stdin.Fd())) fmt.Print("\n") if err != nil { log.Printf("Failed to get input, aborting: %s", err) return "", err } if len(password) != 0 { return string(password), nil } // try again } } func askUsernamePasswordIfPossible() error { configFile := config.getConfigFilename() _, err := os.Stat(configFile) if !os.IsNotExist(err) { // do nothing, file exists return nil } if !terminal.IsTerminal(int(os.Stdin.Fd())) { return nil // do nothing } if !terminal.IsTerminal(int(os.Stdout.Fd())) { return nil // do nothing } fmt.Printf("Would you like to set user/password for the web interface authentication (yes/no)?\n") yesno, err := promptAndGet("Please type 'yes' or 'no': ") if err != nil { return err } if yesno[0] != 'y' && yesno[0] != 'Y' { return nil } username, err := promptAndGet("Please enter the username: ") if err != nil { return err } password, err := promptAndGetPassword("Please enter the password: ") if err != nil { return err } password2, err := promptAndGetPassword("Please enter password again: ") if err != nil { return err } if password2 != password { fmt.Printf("Passwords do not match! Aborting\n") os.Exit(1) } config.AuthName = username config.AuthPass = password return nil } </s> add
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/302c3a767a4d296d1f8cf5d895be8af2477113ce
control.go
newSettings := firstRunData{}
<mask> } <mask> } <mask> <mask> func handleSetAllSettings(w http.ResponseWriter, r *http.Request) { <mask> newSettings := map[string]interface{}{} <mask> err := json.NewDecoder(r.Body).Decode(&newSettings) <mask> if err != nil { <mask> httpError(w, http.StatusBadRequest, "Failed to parse new DHCP config json: %s", err) <mask> return <mask> } </s> Initial implementation of welcome/firstrun/installer page in go backend </s> remove ifaces, err := net.Interfaces() </s> add ifaces, err := getValidNetInterfaces() </s> remove type ipport struct { IP string `json:"ip"` Port int `json:"port"` </s> add data := firstRunData{} ifaces, err := getValidNetInterfaces() if err != nil { httpError(w, http.StatusInternalServerError, "Couldn't get interfaces: %s", err) return } if len(ifaces) == 0 { httpError(w, http.StatusServiceUnavailable, "Couldn't find any legible interface, plase try again later") return </s> remove err = upgradeConfig() </s> add err := upgradeConfig() </s> remove if config.AuthName == "" || config.AuthPass == "" { a.handler.ServeHTTP(w, r) return } user, pass, ok := r.BasicAuth() if !ok || user != config.AuthName || pass != config.AuthPass { w.Header().Set("WWW-Authenticate", `Basic realm="dnsfilter"`) w.WriteHeader(http.StatusUnauthorized) w.Write([]byte("Unauthorised.\n")) return } a.handler.ServeHTTP(w, r) </s> add optionalAuth(a.handler.ServeHTTP)(w, r)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/302c3a767a4d296d1f8cf5d895be8af2477113ce
control.go
config.firstRun = false config.BindHost = newSettings.Web.IP config.BindPort = newSettings.Web.Port config.DNS.BindHost = newSettings.DNS.IP config.DNS.Port = newSettings.DNS.Port config.AuthName = newSettings.Username config.AuthPass = newSettings.Password httpUpdateConfigReloadDNSReturnOK(w, r)
<mask> } <mask> <mask> spew.Dump(newSettings) <mask> } <mask> <mask> func registerControlHandlers() { <mask> http.HandleFunc("/control/status", postInstall(optionalAuth(ensureGET(handleStatus)))) </s> Initial implementation of welcome/firstrun/installer page in go backend </s> remove http.HandleFunc("/control/status", optionalAuth(ensureGET(handleStatus))) http.HandleFunc("/control/enable_protection", optionalAuth(ensurePOST(handleProtectionEnable))) http.HandleFunc("/control/disable_protection", optionalAuth(ensurePOST(handleProtectionDisable))) http.HandleFunc("/control/querylog", optionalAuth(ensureGET(dnsforward.HandleQueryLog))) http.HandleFunc("/control/querylog_enable", optionalAuth(ensurePOST(handleQueryLogEnable))) http.HandleFunc("/control/querylog_disable", optionalAuth(ensurePOST(handleQueryLogDisable))) http.HandleFunc("/control/set_upstream_dns", optionalAuth(ensurePOST(handleSetUpstreamDNS))) http.HandleFunc("/control/test_upstream_dns", optionalAuth(ensurePOST(handleTestUpstreamDNS))) http.HandleFunc("/control/i18n/change_language", optionalAuth(ensurePOST(handleI18nChangeLanguage))) http.HandleFunc("/control/i18n/current_language", optionalAuth(ensureGET(handleI18nCurrentLanguage))) http.HandleFunc("/control/stats_top", optionalAuth(ensureGET(dnsforward.HandleStatsTop))) http.HandleFunc("/control/stats", optionalAuth(ensureGET(dnsforward.HandleStats))) http.HandleFunc("/control/stats_history", optionalAuth(ensureGET(dnsforward.HandleStatsHistory))) http.HandleFunc("/control/stats_reset", optionalAuth(ensurePOST(dnsforward.HandleStatsReset))) http.HandleFunc("/control/version.json", optionalAuth(handleGetVersionJSON)) http.HandleFunc("/control/filtering/enable", optionalAuth(ensurePOST(handleFilteringEnable))) http.HandleFunc("/control/filtering/disable", optionalAuth(ensurePOST(handleFilteringDisable))) http.HandleFunc("/control/filtering/add_url", optionalAuth(ensurePUT(handleFilteringAddURL))) http.HandleFunc("/control/filtering/remove_url", optionalAuth(ensureDELETE(handleFilteringRemoveURL))) http.HandleFunc("/control/filtering/enable_url", optionalAuth(ensurePOST(handleFilteringEnableURL))) http.HandleFunc("/control/filtering/disable_url", optionalAuth(ensurePOST(handleFilteringDisableURL))) http.HandleFunc("/control/filtering/refresh", optionalAuth(ensurePOST(handleFilteringRefresh))) http.HandleFunc("/control/filtering/status", optionalAuth(ensureGET(handleFilteringStatus))) http.HandleFunc("/control/filtering/set_rules", optionalAuth(ensurePUT(handleFilteringSetRules))) http.HandleFunc("/control/safebrowsing/enable", optionalAuth(ensurePOST(handleSafeBrowsingEnable))) http.HandleFunc("/control/safebrowsing/disable", optionalAuth(ensurePOST(handleSafeBrowsingDisable))) http.HandleFunc("/control/safebrowsing/status", optionalAuth(ensureGET(handleSafeBrowsingStatus))) http.HandleFunc("/control/parental/enable", optionalAuth(ensurePOST(handleParentalEnable))) http.HandleFunc("/control/parental/disable", optionalAuth(ensurePOST(handleParentalDisable))) http.HandleFunc("/control/parental/status", optionalAuth(ensureGET(handleParentalStatus))) http.HandleFunc("/control/safesearch/enable", optionalAuth(ensurePOST(handleSafeSearchEnable))) http.HandleFunc("/control/safesearch/disable", optionalAuth(ensurePOST(handleSafeSearchDisable))) http.HandleFunc("/control/safesearch/status", optionalAuth(ensureGET(handleSafeSearchStatus))) http.HandleFunc("/control/dhcp/status", optionalAuth(ensureGET(handleDHCPStatus))) http.HandleFunc("/control/dhcp/interfaces", optionalAuth(ensureGET(handleDHCPInterfaces))) http.HandleFunc("/control/dhcp/set_config", optionalAuth(ensurePOST(handleDHCPSetConfig))) http.HandleFunc("/control/dhcp/find_active_dhcp", optionalAuth(ensurePOST(handleDHCPFindActiveServer))) </s> add http.HandleFunc("/control/status", postInstall(optionalAuth(ensureGET(handleStatus)))) http.HandleFunc("/control/enable_protection", postInstall(optionalAuth(ensurePOST(handleProtectionEnable)))) http.HandleFunc("/control/disable_protection", postInstall(optionalAuth(ensurePOST(handleProtectionDisable)))) http.HandleFunc("/control/querylog", postInstall(optionalAuth(ensureGET(dnsforward.HandleQueryLog)))) http.HandleFunc("/control/querylog_enable", postInstall(optionalAuth(ensurePOST(handleQueryLogEnable)))) http.HandleFunc("/control/querylog_disable", postInstall(optionalAuth(ensurePOST(handleQueryLogDisable)))) http.HandleFunc("/control/set_upstream_dns", postInstall(optionalAuth(ensurePOST(handleSetUpstreamDNS)))) http.HandleFunc("/control/test_upstream_dns", postInstall(optionalAuth(ensurePOST(handleTestUpstreamDNS)))) http.HandleFunc("/control/i18n/change_language", postInstall(optionalAuth(ensurePOST(handleI18nChangeLanguage)))) http.HandleFunc("/control/i18n/current_language", postInstall(optionalAuth(ensureGET(handleI18nCurrentLanguage)))) http.HandleFunc("/control/stats_top", postInstall(optionalAuth(ensureGET(dnsforward.HandleStatsTop)))) http.HandleFunc("/control/stats", postInstall(optionalAuth(ensureGET(dnsforward.HandleStats)))) http.HandleFunc("/control/stats_history", postInstall(optionalAuth(ensureGET(dnsforward.HandleStatsHistory)))) http.HandleFunc("/control/stats_reset", postInstall(optionalAuth(ensurePOST(dnsforward.HandleStatsReset)))) http.HandleFunc("/control/version.json", postInstall(optionalAuth(handleGetVersionJSON))) http.HandleFunc("/control/filtering/enable", postInstall(optionalAuth(ensurePOST(handleFilteringEnable)))) http.HandleFunc("/control/filtering/disable", postInstall(optionalAuth(ensurePOST(handleFilteringDisable)))) http.HandleFunc("/control/filtering/add_url", postInstall(optionalAuth(ensurePUT(handleFilteringAddURL)))) http.HandleFunc("/control/filtering/remove_url", postInstall(optionalAuth(ensureDELETE(handleFilteringRemoveURL)))) http.HandleFunc("/control/filtering/enable_url", postInstall(optionalAuth(ensurePOST(handleFilteringEnableURL)))) http.HandleFunc("/control/filtering/disable_url", postInstall(optionalAuth(ensurePOST(handleFilteringDisableURL)))) http.HandleFunc("/control/filtering/refresh", postInstall(optionalAuth(ensurePOST(handleFilteringRefresh)))) http.HandleFunc("/control/filtering/status", postInstall(optionalAuth(ensureGET(handleFilteringStatus)))) http.HandleFunc("/control/filtering/set_rules", postInstall(optionalAuth(ensurePUT(handleFilteringSetRules)))) http.HandleFunc("/control/safebrowsing/enable", postInstall(optionalAuth(ensurePOST(handleSafeBrowsingEnable)))) http.HandleFunc("/control/safebrowsing/disable", postInstall(optionalAuth(ensurePOST(handleSafeBrowsingDisable)))) http.HandleFunc("/control/safebrowsing/status", postInstall(optionalAuth(ensureGET(handleSafeBrowsingStatus)))) http.HandleFunc("/control/parental/enable", postInstall(optionalAuth(ensurePOST(handleParentalEnable)))) http.HandleFunc("/control/parental/disable", postInstall(optionalAuth(ensurePOST(handleParentalDisable)))) http.HandleFunc("/control/parental/status", postInstall(optionalAuth(ensureGET(handleParentalStatus)))) http.HandleFunc("/control/safesearch/enable", postInstall(optionalAuth(ensurePOST(handleSafeSearchEnable)))) http.HandleFunc("/control/safesearch/disable", postInstall(optionalAuth(ensurePOST(handleSafeSearchDisable)))) http.HandleFunc("/control/safesearch/status", postInstall(optionalAuth(ensureGET(handleSafeSearchStatus)))) http.HandleFunc("/control/dhcp/status", postInstall(optionalAuth(ensureGET(handleDHCPStatus)))) http.HandleFunc("/control/dhcp/interfaces", postInstall(optionalAuth(ensureGET(handleDHCPInterfaces)))) http.HandleFunc("/control/dhcp/set_config", postInstall(optionalAuth(ensurePOST(handleDHCPSetConfig)))) http.HandleFunc("/control/dhcp/find_active_dhcp", postInstall(optionalAuth(ensurePOST(handleDHCPFindActiveServer)))) </s> remove if config.AuthName == "" || config.AuthPass == "" { a.handler.ServeHTTP(w, r) return } user, pass, ok := r.BasicAuth() if !ok || user != config.AuthName || pass != config.AuthPass { w.Header().Set("WWW-Authenticate", `Basic realm="dnsfilter"`) w.WriteHeader(http.StatusUnauthorized) w.Write([]byte("Unauthorised.\n")) return } a.handler.ServeHTTP(w, r) </s> add optionalAuth(a.handler.ServeHTTP)(w, r) </s> remove func promptAndGet(prompt string) (string, error) { for { fmt.Print(prompt) input, err := getInput() if err != nil { log.Printf("Failed to get input, aborting: %s", err) return "", err } if len(input) != 0 { return input, nil } // try again } } func promptAndGetPassword(prompt string) (string, error) { for { fmt.Print(prompt) password, err := terminal.ReadPassword(int(os.Stdin.Fd())) fmt.Print("\n") if err != nil { log.Printf("Failed to get input, aborting: %s", err) return "", err } if len(password) != 0 { return string(password), nil } // try again } } func askUsernamePasswordIfPossible() error { configFile := config.getConfigFilename() _, err := os.Stat(configFile) if !os.IsNotExist(err) { // do nothing, file exists return nil } if !terminal.IsTerminal(int(os.Stdin.Fd())) { return nil // do nothing } if !terminal.IsTerminal(int(os.Stdout.Fd())) { return nil // do nothing } fmt.Printf("Would you like to set user/password for the web interface authentication (yes/no)?\n") yesno, err := promptAndGet("Please type 'yes' or 'no': ") if err != nil { return err } if yesno[0] != 'y' && yesno[0] != 'Y' { return nil } username, err := promptAndGet("Please enter the username: ") if err != nil { return err } password, err := promptAndGetPassword("Please enter the password: ") if err != nil { return err } password2, err := promptAndGetPassword("Please enter password again: ") if err != nil { return err } if password2 != password { fmt.Printf("Passwords do not match! Aborting\n") os.Exit(1) } config.AuthName = username config.AuthPass = password return nil } </s> add </s> remove newSettings := map[string]interface{}{} </s> add newSettings := firstRunData{}
[ "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/302c3a767a4d296d1f8cf5d895be8af2477113ce
control.go
http.HandleFunc("/control/status", postInstall(optionalAuth(ensureGET(handleStatus)))) http.HandleFunc("/control/enable_protection", postInstall(optionalAuth(ensurePOST(handleProtectionEnable)))) http.HandleFunc("/control/disable_protection", postInstall(optionalAuth(ensurePOST(handleProtectionDisable)))) http.HandleFunc("/control/querylog", postInstall(optionalAuth(ensureGET(dnsforward.HandleQueryLog)))) http.HandleFunc("/control/querylog_enable", postInstall(optionalAuth(ensurePOST(handleQueryLogEnable)))) http.HandleFunc("/control/querylog_disable", postInstall(optionalAuth(ensurePOST(handleQueryLogDisable)))) http.HandleFunc("/control/set_upstream_dns", postInstall(optionalAuth(ensurePOST(handleSetUpstreamDNS)))) http.HandleFunc("/control/test_upstream_dns", postInstall(optionalAuth(ensurePOST(handleTestUpstreamDNS)))) http.HandleFunc("/control/i18n/change_language", postInstall(optionalAuth(ensurePOST(handleI18nChangeLanguage)))) http.HandleFunc("/control/i18n/current_language", postInstall(optionalAuth(ensureGET(handleI18nCurrentLanguage)))) http.HandleFunc("/control/stats_top", postInstall(optionalAuth(ensureGET(dnsforward.HandleStatsTop)))) http.HandleFunc("/control/stats", postInstall(optionalAuth(ensureGET(dnsforward.HandleStats)))) http.HandleFunc("/control/stats_history", postInstall(optionalAuth(ensureGET(dnsforward.HandleStatsHistory)))) http.HandleFunc("/control/stats_reset", postInstall(optionalAuth(ensurePOST(dnsforward.HandleStatsReset)))) http.HandleFunc("/control/version.json", postInstall(optionalAuth(handleGetVersionJSON))) http.HandleFunc("/control/filtering/enable", postInstall(optionalAuth(ensurePOST(handleFilteringEnable)))) http.HandleFunc("/control/filtering/disable", postInstall(optionalAuth(ensurePOST(handleFilteringDisable)))) http.HandleFunc("/control/filtering/add_url", postInstall(optionalAuth(ensurePUT(handleFilteringAddURL)))) http.HandleFunc("/control/filtering/remove_url", postInstall(optionalAuth(ensureDELETE(handleFilteringRemoveURL)))) http.HandleFunc("/control/filtering/enable_url", postInstall(optionalAuth(ensurePOST(handleFilteringEnableURL)))) http.HandleFunc("/control/filtering/disable_url", postInstall(optionalAuth(ensurePOST(handleFilteringDisableURL)))) http.HandleFunc("/control/filtering/refresh", postInstall(optionalAuth(ensurePOST(handleFilteringRefresh)))) http.HandleFunc("/control/filtering/status", postInstall(optionalAuth(ensureGET(handleFilteringStatus)))) http.HandleFunc("/control/filtering/set_rules", postInstall(optionalAuth(ensurePUT(handleFilteringSetRules)))) http.HandleFunc("/control/safebrowsing/enable", postInstall(optionalAuth(ensurePOST(handleSafeBrowsingEnable)))) http.HandleFunc("/control/safebrowsing/disable", postInstall(optionalAuth(ensurePOST(handleSafeBrowsingDisable)))) http.HandleFunc("/control/safebrowsing/status", postInstall(optionalAuth(ensureGET(handleSafeBrowsingStatus)))) http.HandleFunc("/control/parental/enable", postInstall(optionalAuth(ensurePOST(handleParentalEnable)))) http.HandleFunc("/control/parental/disable", postInstall(optionalAuth(ensurePOST(handleParentalDisable)))) http.HandleFunc("/control/parental/status", postInstall(optionalAuth(ensureGET(handleParentalStatus)))) http.HandleFunc("/control/safesearch/enable", postInstall(optionalAuth(ensurePOST(handleSafeSearchEnable)))) http.HandleFunc("/control/safesearch/disable", postInstall(optionalAuth(ensurePOST(handleSafeSearchDisable)))) http.HandleFunc("/control/safesearch/status", postInstall(optionalAuth(ensureGET(handleSafeSearchStatus)))) http.HandleFunc("/control/dhcp/status", postInstall(optionalAuth(ensureGET(handleDHCPStatus)))) http.HandleFunc("/control/dhcp/interfaces", postInstall(optionalAuth(ensureGET(handleDHCPInterfaces)))) http.HandleFunc("/control/dhcp/set_config", postInstall(optionalAuth(ensurePOST(handleDHCPSetConfig)))) http.HandleFunc("/control/dhcp/find_active_dhcp", postInstall(optionalAuth(ensurePOST(handleDHCPFindActiveServer))))
<mask> spew.Dump(newSettings) <mask> } <mask> <mask> func registerControlHandlers() { <mask> http.HandleFunc("/control/status", optionalAuth(ensureGET(handleStatus))) <mask> http.HandleFunc("/control/enable_protection", optionalAuth(ensurePOST(handleProtectionEnable))) <mask> http.HandleFunc("/control/disable_protection", optionalAuth(ensurePOST(handleProtectionDisable))) <mask> http.HandleFunc("/control/querylog", optionalAuth(ensureGET(dnsforward.HandleQueryLog))) <mask> http.HandleFunc("/control/querylog_enable", optionalAuth(ensurePOST(handleQueryLogEnable))) <mask> http.HandleFunc("/control/querylog_disable", optionalAuth(ensurePOST(handleQueryLogDisable))) <mask> http.HandleFunc("/control/set_upstream_dns", optionalAuth(ensurePOST(handleSetUpstreamDNS))) <mask> http.HandleFunc("/control/test_upstream_dns", optionalAuth(ensurePOST(handleTestUpstreamDNS))) <mask> http.HandleFunc("/control/i18n/change_language", optionalAuth(ensurePOST(handleI18nChangeLanguage))) <mask> http.HandleFunc("/control/i18n/current_language", optionalAuth(ensureGET(handleI18nCurrentLanguage))) <mask> http.HandleFunc("/control/stats_top", optionalAuth(ensureGET(dnsforward.HandleStatsTop))) <mask> http.HandleFunc("/control/stats", optionalAuth(ensureGET(dnsforward.HandleStats))) <mask> http.HandleFunc("/control/stats_history", optionalAuth(ensureGET(dnsforward.HandleStatsHistory))) <mask> http.HandleFunc("/control/stats_reset", optionalAuth(ensurePOST(dnsforward.HandleStatsReset))) <mask> http.HandleFunc("/control/version.json", optionalAuth(handleGetVersionJSON)) <mask> http.HandleFunc("/control/filtering/enable", optionalAuth(ensurePOST(handleFilteringEnable))) <mask> http.HandleFunc("/control/filtering/disable", optionalAuth(ensurePOST(handleFilteringDisable))) <mask> http.HandleFunc("/control/filtering/add_url", optionalAuth(ensurePUT(handleFilteringAddURL))) <mask> http.HandleFunc("/control/filtering/remove_url", optionalAuth(ensureDELETE(handleFilteringRemoveURL))) <mask> http.HandleFunc("/control/filtering/enable_url", optionalAuth(ensurePOST(handleFilteringEnableURL))) <mask> http.HandleFunc("/control/filtering/disable_url", optionalAuth(ensurePOST(handleFilteringDisableURL))) <mask> http.HandleFunc("/control/filtering/refresh", optionalAuth(ensurePOST(handleFilteringRefresh))) <mask> http.HandleFunc("/control/filtering/status", optionalAuth(ensureGET(handleFilteringStatus))) <mask> http.HandleFunc("/control/filtering/set_rules", optionalAuth(ensurePUT(handleFilteringSetRules))) <mask> http.HandleFunc("/control/safebrowsing/enable", optionalAuth(ensurePOST(handleSafeBrowsingEnable))) <mask> http.HandleFunc("/control/safebrowsing/disable", optionalAuth(ensurePOST(handleSafeBrowsingDisable))) <mask> http.HandleFunc("/control/safebrowsing/status", optionalAuth(ensureGET(handleSafeBrowsingStatus))) <mask> http.HandleFunc("/control/parental/enable", optionalAuth(ensurePOST(handleParentalEnable))) <mask> http.HandleFunc("/control/parental/disable", optionalAuth(ensurePOST(handleParentalDisable))) <mask> http.HandleFunc("/control/parental/status", optionalAuth(ensureGET(handleParentalStatus))) <mask> http.HandleFunc("/control/safesearch/enable", optionalAuth(ensurePOST(handleSafeSearchEnable))) <mask> http.HandleFunc("/control/safesearch/disable", optionalAuth(ensurePOST(handleSafeSearchDisable))) <mask> http.HandleFunc("/control/safesearch/status", optionalAuth(ensureGET(handleSafeSearchStatus))) <mask> http.HandleFunc("/control/dhcp/status", optionalAuth(ensureGET(handleDHCPStatus))) <mask> http.HandleFunc("/control/dhcp/interfaces", optionalAuth(ensureGET(handleDHCPInterfaces))) <mask> http.HandleFunc("/control/dhcp/set_config", optionalAuth(ensurePOST(handleDHCPSetConfig))) <mask> http.HandleFunc("/control/dhcp/find_active_dhcp", optionalAuth(ensurePOST(handleDHCPFindActiveServer))) <mask> <mask> // TODO: move to registerInstallHandlers() <mask> http.HandleFunc("/control/install/get_default_addresses", ensureGET(handleGetDefaultAddresses)) <mask> http.HandleFunc("/control/install/set_all_settings", ensurePOST(handleSetAllSettings)) <mask> } </s> Initial implementation of welcome/firstrun/installer page in go backend </s> remove http.HandleFunc("/control/install/get_default_addresses", ensureGET(handleGetDefaultAddresses)) http.HandleFunc("/control/install/set_all_settings", ensurePOST(handleSetAllSettings)) </s> add http.HandleFunc("/control/install/get_default_addresses", preInstall(ensureGET(handleGetDefaultAddresses))) http.HandleFunc("/control/install/set_all_settings", preInstall(ensurePOST(handleSetAllSettings))) </s> remove func promptAndGet(prompt string) (string, error) { for { fmt.Print(prompt) input, err := getInput() if err != nil { log.Printf("Failed to get input, aborting: %s", err) return "", err } if len(input) != 0 { return input, nil } // try again } } func promptAndGetPassword(prompt string) (string, error) { for { fmt.Print(prompt) password, err := terminal.ReadPassword(int(os.Stdin.Fd())) fmt.Print("\n") if err != nil { log.Printf("Failed to get input, aborting: %s", err) return "", err } if len(password) != 0 { return string(password), nil } // try again } } func askUsernamePasswordIfPossible() error { configFile := config.getConfigFilename() _, err := os.Stat(configFile) if !os.IsNotExist(err) { // do nothing, file exists return nil } if !terminal.IsTerminal(int(os.Stdin.Fd())) { return nil // do nothing } if !terminal.IsTerminal(int(os.Stdout.Fd())) { return nil // do nothing } fmt.Printf("Would you like to set user/password for the web interface authentication (yes/no)?\n") yesno, err := promptAndGet("Please type 'yes' or 'no': ") if err != nil { return err } if yesno[0] != 'y' && yesno[0] != 'Y' { return nil } username, err := promptAndGet("Please enter the username: ") if err != nil { return err } password, err := promptAndGetPassword("Please enter the password: ") if err != nil { return err } password2, err := promptAndGetPassword("Please enter password again: ") if err != nil { return err } if password2 != password { fmt.Printf("Passwords do not match! Aborting\n") os.Exit(1) } config.AuthName = username config.AuthPass = password return nil } </s> add </s> remove func getInput() (string, error) { scanner := bufio.NewScanner(os.Stdin) scanner.Scan() text := scanner.Text() err := scanner.Err() return text, err } </s> add </s> remove data := struct { Web ipport `json:"web"` DNS ipport `json:"dns"` }{} </s> add
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/302c3a767a4d296d1f8cf5d895be8af2477113ce
control.go
http.HandleFunc("/control/install/get_default_addresses", preInstall(ensureGET(handleGetDefaultAddresses))) http.HandleFunc("/control/install/set_all_settings", preInstall(ensurePOST(handleSetAllSettings)))
<mask> http.HandleFunc("/control/dhcp/set_config", optionalAuth(ensurePOST(handleDHCPSetConfig))) <mask> http.HandleFunc("/control/dhcp/find_active_dhcp", optionalAuth(ensurePOST(handleDHCPFindActiveServer))) <mask> <mask> // TODO: move to registerInstallHandlers() <mask> http.HandleFunc("/control/install/get_default_addresses", ensureGET(handleGetDefaultAddresses)) <mask> http.HandleFunc("/control/install/set_all_settings", ensurePOST(handleSetAllSettings)) <mask> } </s> Initial implementation of welcome/firstrun/installer page in go backend </s> remove http.HandleFunc("/control/status", optionalAuth(ensureGET(handleStatus))) http.HandleFunc("/control/enable_protection", optionalAuth(ensurePOST(handleProtectionEnable))) http.HandleFunc("/control/disable_protection", optionalAuth(ensurePOST(handleProtectionDisable))) http.HandleFunc("/control/querylog", optionalAuth(ensureGET(dnsforward.HandleQueryLog))) http.HandleFunc("/control/querylog_enable", optionalAuth(ensurePOST(handleQueryLogEnable))) http.HandleFunc("/control/querylog_disable", optionalAuth(ensurePOST(handleQueryLogDisable))) http.HandleFunc("/control/set_upstream_dns", optionalAuth(ensurePOST(handleSetUpstreamDNS))) http.HandleFunc("/control/test_upstream_dns", optionalAuth(ensurePOST(handleTestUpstreamDNS))) http.HandleFunc("/control/i18n/change_language", optionalAuth(ensurePOST(handleI18nChangeLanguage))) http.HandleFunc("/control/i18n/current_language", optionalAuth(ensureGET(handleI18nCurrentLanguage))) http.HandleFunc("/control/stats_top", optionalAuth(ensureGET(dnsforward.HandleStatsTop))) http.HandleFunc("/control/stats", optionalAuth(ensureGET(dnsforward.HandleStats))) http.HandleFunc("/control/stats_history", optionalAuth(ensureGET(dnsforward.HandleStatsHistory))) http.HandleFunc("/control/stats_reset", optionalAuth(ensurePOST(dnsforward.HandleStatsReset))) http.HandleFunc("/control/version.json", optionalAuth(handleGetVersionJSON)) http.HandleFunc("/control/filtering/enable", optionalAuth(ensurePOST(handleFilteringEnable))) http.HandleFunc("/control/filtering/disable", optionalAuth(ensurePOST(handleFilteringDisable))) http.HandleFunc("/control/filtering/add_url", optionalAuth(ensurePUT(handleFilteringAddURL))) http.HandleFunc("/control/filtering/remove_url", optionalAuth(ensureDELETE(handleFilteringRemoveURL))) http.HandleFunc("/control/filtering/enable_url", optionalAuth(ensurePOST(handleFilteringEnableURL))) http.HandleFunc("/control/filtering/disable_url", optionalAuth(ensurePOST(handleFilteringDisableURL))) http.HandleFunc("/control/filtering/refresh", optionalAuth(ensurePOST(handleFilteringRefresh))) http.HandleFunc("/control/filtering/status", optionalAuth(ensureGET(handleFilteringStatus))) http.HandleFunc("/control/filtering/set_rules", optionalAuth(ensurePUT(handleFilteringSetRules))) http.HandleFunc("/control/safebrowsing/enable", optionalAuth(ensurePOST(handleSafeBrowsingEnable))) http.HandleFunc("/control/safebrowsing/disable", optionalAuth(ensurePOST(handleSafeBrowsingDisable))) http.HandleFunc("/control/safebrowsing/status", optionalAuth(ensureGET(handleSafeBrowsingStatus))) http.HandleFunc("/control/parental/enable", optionalAuth(ensurePOST(handleParentalEnable))) http.HandleFunc("/control/parental/disable", optionalAuth(ensurePOST(handleParentalDisable))) http.HandleFunc("/control/parental/status", optionalAuth(ensureGET(handleParentalStatus))) http.HandleFunc("/control/safesearch/enable", optionalAuth(ensurePOST(handleSafeSearchEnable))) http.HandleFunc("/control/safesearch/disable", optionalAuth(ensurePOST(handleSafeSearchDisable))) http.HandleFunc("/control/safesearch/status", optionalAuth(ensureGET(handleSafeSearchStatus))) http.HandleFunc("/control/dhcp/status", optionalAuth(ensureGET(handleDHCPStatus))) http.HandleFunc("/control/dhcp/interfaces", optionalAuth(ensureGET(handleDHCPInterfaces))) http.HandleFunc("/control/dhcp/set_config", optionalAuth(ensurePOST(handleDHCPSetConfig))) http.HandleFunc("/control/dhcp/find_active_dhcp", optionalAuth(ensurePOST(handleDHCPFindActiveServer))) </s> add http.HandleFunc("/control/status", postInstall(optionalAuth(ensureGET(handleStatus)))) http.HandleFunc("/control/enable_protection", postInstall(optionalAuth(ensurePOST(handleProtectionEnable)))) http.HandleFunc("/control/disable_protection", postInstall(optionalAuth(ensurePOST(handleProtectionDisable)))) http.HandleFunc("/control/querylog", postInstall(optionalAuth(ensureGET(dnsforward.HandleQueryLog)))) http.HandleFunc("/control/querylog_enable", postInstall(optionalAuth(ensurePOST(handleQueryLogEnable)))) http.HandleFunc("/control/querylog_disable", postInstall(optionalAuth(ensurePOST(handleQueryLogDisable)))) http.HandleFunc("/control/set_upstream_dns", postInstall(optionalAuth(ensurePOST(handleSetUpstreamDNS)))) http.HandleFunc("/control/test_upstream_dns", postInstall(optionalAuth(ensurePOST(handleTestUpstreamDNS)))) http.HandleFunc("/control/i18n/change_language", postInstall(optionalAuth(ensurePOST(handleI18nChangeLanguage)))) http.HandleFunc("/control/i18n/current_language", postInstall(optionalAuth(ensureGET(handleI18nCurrentLanguage)))) http.HandleFunc("/control/stats_top", postInstall(optionalAuth(ensureGET(dnsforward.HandleStatsTop)))) http.HandleFunc("/control/stats", postInstall(optionalAuth(ensureGET(dnsforward.HandleStats)))) http.HandleFunc("/control/stats_history", postInstall(optionalAuth(ensureGET(dnsforward.HandleStatsHistory)))) http.HandleFunc("/control/stats_reset", postInstall(optionalAuth(ensurePOST(dnsforward.HandleStatsReset)))) http.HandleFunc("/control/version.json", postInstall(optionalAuth(handleGetVersionJSON))) http.HandleFunc("/control/filtering/enable", postInstall(optionalAuth(ensurePOST(handleFilteringEnable)))) http.HandleFunc("/control/filtering/disable", postInstall(optionalAuth(ensurePOST(handleFilteringDisable)))) http.HandleFunc("/control/filtering/add_url", postInstall(optionalAuth(ensurePUT(handleFilteringAddURL)))) http.HandleFunc("/control/filtering/remove_url", postInstall(optionalAuth(ensureDELETE(handleFilteringRemoveURL)))) http.HandleFunc("/control/filtering/enable_url", postInstall(optionalAuth(ensurePOST(handleFilteringEnableURL)))) http.HandleFunc("/control/filtering/disable_url", postInstall(optionalAuth(ensurePOST(handleFilteringDisableURL)))) http.HandleFunc("/control/filtering/refresh", postInstall(optionalAuth(ensurePOST(handleFilteringRefresh)))) http.HandleFunc("/control/filtering/status", postInstall(optionalAuth(ensureGET(handleFilteringStatus)))) http.HandleFunc("/control/filtering/set_rules", postInstall(optionalAuth(ensurePUT(handleFilteringSetRules)))) http.HandleFunc("/control/safebrowsing/enable", postInstall(optionalAuth(ensurePOST(handleSafeBrowsingEnable)))) http.HandleFunc("/control/safebrowsing/disable", postInstall(optionalAuth(ensurePOST(handleSafeBrowsingDisable)))) http.HandleFunc("/control/safebrowsing/status", postInstall(optionalAuth(ensureGET(handleSafeBrowsingStatus)))) http.HandleFunc("/control/parental/enable", postInstall(optionalAuth(ensurePOST(handleParentalEnable)))) http.HandleFunc("/control/parental/disable", postInstall(optionalAuth(ensurePOST(handleParentalDisable)))) http.HandleFunc("/control/parental/status", postInstall(optionalAuth(ensureGET(handleParentalStatus)))) http.HandleFunc("/control/safesearch/enable", postInstall(optionalAuth(ensurePOST(handleSafeSearchEnable)))) http.HandleFunc("/control/safesearch/disable", postInstall(optionalAuth(ensurePOST(handleSafeSearchDisable)))) http.HandleFunc("/control/safesearch/status", postInstall(optionalAuth(ensureGET(handleSafeSearchStatus)))) http.HandleFunc("/control/dhcp/status", postInstall(optionalAuth(ensureGET(handleDHCPStatus)))) http.HandleFunc("/control/dhcp/interfaces", postInstall(optionalAuth(ensureGET(handleDHCPInterfaces)))) http.HandleFunc("/control/dhcp/set_config", postInstall(optionalAuth(ensurePOST(handleDHCPSetConfig)))) http.HandleFunc("/control/dhcp/find_active_dhcp", postInstall(optionalAuth(ensurePOST(handleDHCPFindActiveServer)))) </s> remove // TODO: replace mockup with actual data data.Web.IP = "192.168.104.104" data.Web.Port = 3000 data.DNS.IP = "192.168.104.104" data.DNS.Port = 53 </s> add // find an interface with an ipv4 address addr := findIPv4IfaceAddr(ifaces) if len(addr) == 0 { httpError(w, http.StatusServiceUnavailable, "Couldn't find any interface with IPv4, plase try again later") return } data.Web.IP = addr data.DNS.IP = addr data.Web.Port = 3000 // TODO: find out if port 80 is available -- if not, fall back to 3000 data.DNS.Port = 53 // TODO: find out if port 53 is available -- if not, show a big warning </s> remove data := struct { Web ipport `json:"web"` DNS ipport `json:"dns"` }{} </s> add </s> remove func getInput() (string, error) { scanner := bufio.NewScanner(os.Stdin) scanner.Scan() text := scanner.Text() err := scanner.Err() return text, err } </s> add </s> remove if ifaces[i].Flags&net.FlagLoopback != 0 { // it's a loopback, skip it continue } if ifaces[i].Flags&net.FlagBroadcast == 0 { // this interface doesn't support broadcast, skip it continue } if ifaces[i].Flags&net.FlagPointToPoint != 0 { // this interface is ppp, don't do dhcp over it continue } iface := responseInterface{ Name: ifaces[i].Name, MTU: ifaces[i].MTU, HardwareAddr: ifaces[i].HardwareAddr.String(), } addrs, errAddrs := ifaces[i].Addrs() if errAddrs != nil { httpError(w, http.StatusInternalServerError, "Failed to get addresses for interface %v: %s", ifaces[i].Name, errAddrs) return } for _, addr := range addrs { iface.Addresses = append(iface.Addresses, addr.String()) } if len(iface.Addresses) == 0 { // this interface has no addresses, skip it continue } response[ifaces[i].Name] = iface </s> add response[ifaces[i].Name] = ifaces[i]
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/302c3a767a4d296d1f8cf5d895be8af2477113ce
control.go
<mask> import ( <mask> "encoding/json" <mask> "fmt" <mask> "io/ioutil" <mask> "net" <mask> "net/http" <mask> "strings" <mask> "time" <mask> <mask> "github.com/AdguardTeam/AdGuardHome/dhcpd" </s> Initial implementation of welcome/firstrun/installer page in go backend </s> remove "bufio" </s> add </s> remove type ipport struct { IP string `json:"ip"` Port int `json:"port"` </s> add data := firstRunData{} ifaces, err := getValidNetInterfaces() if err != nil { httpError(w, http.StatusInternalServerError, "Couldn't get interfaces: %s", err) return } if len(ifaces) == 0 { httpError(w, http.StatusServiceUnavailable, "Couldn't find any legible interface, plase try again later") return
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/302c3a767a4d296d1f8cf5d895be8af2477113ce
dhcp.go
ifaces, err := getValidNetInterfaces()
<mask> <mask> func handleDHCPInterfaces(w http.ResponseWriter, r *http.Request) { <mask> response := map[string]interface{}{} <mask> <mask> ifaces, err := net.Interfaces() <mask> if err != nil { <mask> httpError(w, http.StatusInternalServerError, "Couldn't get list of interfaces: %s", err) <mask> return <mask> } <mask> </s> Initial implementation of welcome/firstrun/installer page in go backend </s> remove httpError(w, http.StatusInternalServerError, "Couldn't get list of interfaces: %s", err) </s> add httpError(w, http.StatusInternalServerError, "Couldn't get interfaces: %s", err) </s> remove type ipport struct { IP string `json:"ip"` Port int `json:"port"` </s> add data := firstRunData{} ifaces, err := getValidNetInterfaces() if err != nil { httpError(w, http.StatusInternalServerError, "Couldn't get interfaces: %s", err) return } if len(ifaces) == 0 { httpError(w, http.StatusServiceUnavailable, "Couldn't find any legible interface, plase try again later") return </s> remove newSettings := map[string]interface{}{} </s> add newSettings := firstRunData{} </s> remove type responseInterface struct { Name string `json:"name"` MTU int `json:"mtu"` HardwareAddr string `json:"hardware_address"` Addresses []string `json:"ip_addresses"` } </s> add
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/302c3a767a4d296d1f8cf5d895be8af2477113ce
dhcp.go
httpError(w, http.StatusInternalServerError, "Couldn't get interfaces: %s", err)
<mask> response := map[string]interface{}{} <mask> <mask> ifaces, err := net.Interfaces() <mask> if err != nil { <mask> httpError(w, http.StatusInternalServerError, "Couldn't get list of interfaces: %s", err) <mask> return <mask> } <mask> <mask> type responseInterface struct { <mask> Name string `json:"name"` </s> Initial implementation of welcome/firstrun/installer page in go backend </s> remove ifaces, err := net.Interfaces() </s> add ifaces, err := getValidNetInterfaces() </s> remove type responseInterface struct { Name string `json:"name"` MTU int `json:"mtu"` HardwareAddr string `json:"hardware_address"` Addresses []string `json:"ip_addresses"` } </s> add </s> remove type ipport struct { IP string `json:"ip"` Port int `json:"port"` </s> add data := firstRunData{} ifaces, err := getValidNetInterfaces() if err != nil { httpError(w, http.StatusInternalServerError, "Couldn't get interfaces: %s", err) return } if len(ifaces) == 0 { httpError(w, http.StatusServiceUnavailable, "Couldn't find any legible interface, plase try again later") return </s> remove newSettings := map[string]interface{}{} </s> add newSettings := firstRunData{}
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/302c3a767a4d296d1f8cf5d895be8af2477113ce
dhcp.go
<mask> httpError(w, http.StatusInternalServerError, "Couldn't get list of interfaces: %s", err) <mask> return <mask> } <mask> <mask> type responseInterface struct { <mask> Name string `json:"name"` <mask> MTU int `json:"mtu"` <mask> HardwareAddr string `json:"hardware_address"` <mask> Addresses []string `json:"ip_addresses"` <mask> } <mask> <mask> for i := range ifaces { <mask> if ifaces[i].Flags&net.FlagLoopback != 0 { <mask> // it's a loopback, skip it <mask> continue <mask> } </s> Initial implementation of welcome/firstrun/installer page in go backend </s> remove if ifaces[i].Flags&net.FlagLoopback != 0 { // it's a loopback, skip it continue } if ifaces[i].Flags&net.FlagBroadcast == 0 { // this interface doesn't support broadcast, skip it continue } if ifaces[i].Flags&net.FlagPointToPoint != 0 { // this interface is ppp, don't do dhcp over it continue } iface := responseInterface{ Name: ifaces[i].Name, MTU: ifaces[i].MTU, HardwareAddr: ifaces[i].HardwareAddr.String(), } addrs, errAddrs := ifaces[i].Addrs() if errAddrs != nil { httpError(w, http.StatusInternalServerError, "Failed to get addresses for interface %v: %s", ifaces[i].Name, errAddrs) return } for _, addr := range addrs { iface.Addresses = append(iface.Addresses, addr.String()) } if len(iface.Addresses) == 0 { // this interface has no addresses, skip it continue } response[ifaces[i].Name] = iface </s> add response[ifaces[i].Name] = ifaces[i] </s> remove httpError(w, http.StatusInternalServerError, "Couldn't get list of interfaces: %s", err) </s> add httpError(w, http.StatusInternalServerError, "Couldn't get interfaces: %s", err) </s> remove type ipport struct { IP string `json:"ip"` Port int `json:"port"` </s> add data := firstRunData{} ifaces, err := getValidNetInterfaces() if err != nil { httpError(w, http.StatusInternalServerError, "Couldn't get interfaces: %s", err) return } if len(ifaces) == 0 { httpError(w, http.StatusServiceUnavailable, "Couldn't find any legible interface, plase try again later") return </s> remove ifaces, err := net.Interfaces() </s> add ifaces, err := getValidNetInterfaces()
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/302c3a767a4d296d1f8cf5d895be8af2477113ce
dhcp.go
response[ifaces[i].Name] = ifaces[i]
<mask> Addresses []string `json:"ip_addresses"` <mask> } <mask> <mask> for i := range ifaces { <mask> if ifaces[i].Flags&net.FlagLoopback != 0 { <mask> // it's a loopback, skip it <mask> continue <mask> } <mask> if ifaces[i].Flags&net.FlagBroadcast == 0 { <mask> // this interface doesn't support broadcast, skip it <mask> continue <mask> } <mask> if ifaces[i].Flags&net.FlagPointToPoint != 0 { <mask> // this interface is ppp, don't do dhcp over it <mask> continue <mask> } <mask> iface := responseInterface{ <mask> Name: ifaces[i].Name, <mask> MTU: ifaces[i].MTU, <mask> HardwareAddr: ifaces[i].HardwareAddr.String(), <mask> } <mask> addrs, errAddrs := ifaces[i].Addrs() <mask> if errAddrs != nil { <mask> httpError(w, http.StatusInternalServerError, "Failed to get addresses for interface %v: %s", ifaces[i].Name, errAddrs) <mask> return <mask> } <mask> for _, addr := range addrs { <mask> iface.Addresses = append(iface.Addresses, addr.String()) <mask> } <mask> if len(iface.Addresses) == 0 { <mask> // this interface has no addresses, skip it <mask> continue <mask> } <mask> response[ifaces[i].Name] = iface <mask> } <mask> <mask> err = json.NewEncoder(w).Encode(response) <mask> if err != nil { <mask> httpError(w, http.StatusInternalServerError, "Failed to marshal json with available interfaces: %s", err) </s> Initial implementation of welcome/firstrun/installer page in go backend </s> remove type responseInterface struct { Name string `json:"name"` MTU int `json:"mtu"` HardwareAddr string `json:"hardware_address"` Addresses []string `json:"ip_addresses"` } </s> add </s> remove func promptAndGet(prompt string) (string, error) { for { fmt.Print(prompt) input, err := getInput() if err != nil { log.Printf("Failed to get input, aborting: %s", err) return "", err } if len(input) != 0 { return input, nil } // try again } } func promptAndGetPassword(prompt string) (string, error) { for { fmt.Print(prompt) password, err := terminal.ReadPassword(int(os.Stdin.Fd())) fmt.Print("\n") if err != nil { log.Printf("Failed to get input, aborting: %s", err) return "", err } if len(password) != 0 { return string(password), nil } // try again } } func askUsernamePasswordIfPossible() error { configFile := config.getConfigFilename() _, err := os.Stat(configFile) if !os.IsNotExist(err) { // do nothing, file exists return nil } if !terminal.IsTerminal(int(os.Stdin.Fd())) { return nil // do nothing } if !terminal.IsTerminal(int(os.Stdout.Fd())) { return nil // do nothing } fmt.Printf("Would you like to set user/password for the web interface authentication (yes/no)?\n") yesno, err := promptAndGet("Please type 'yes' or 'no': ") if err != nil { return err } if yesno[0] != 'y' && yesno[0] != 'Y' { return nil } username, err := promptAndGet("Please enter the username: ") if err != nil { return err } password, err := promptAndGetPassword("Please enter the password: ") if err != nil { return err } password2, err := promptAndGetPassword("Please enter password again: ") if err != nil { return err } if password2 != password { fmt.Printf("Passwords do not match! Aborting\n") os.Exit(1) } config.AuthName = username config.AuthPass = password return nil } </s> add </s> remove // TODO: replace mockup with actual data data.Web.IP = "192.168.104.104" data.Web.Port = 3000 data.DNS.IP = "192.168.104.104" data.DNS.Port = 53 </s> add // find an interface with an ipv4 address addr := findIPv4IfaceAddr(ifaces) if len(addr) == 0 { httpError(w, http.StatusServiceUnavailable, "Couldn't find any interface with IPv4, plase try again later") return } data.Web.IP = addr data.DNS.IP = addr data.Web.Port = 3000 // TODO: find out if port 80 is available -- if not, fall back to 3000 data.DNS.Port = 53 // TODO: find out if port 53 is available -- if not, show a big warning </s> remove type ipport struct { IP string `json:"ip"` Port int `json:"port"` </s> add data := firstRunData{} ifaces, err := getValidNetInterfaces() if err != nil { httpError(w, http.StatusInternalServerError, "Couldn't get interfaces: %s", err) return } if len(ifaces) == 0 { httpError(w, http.StatusServiceUnavailable, "Couldn't find any legible interface, plase try again later") return </s> remove err := askUsernamePasswordIfPossible() if err != nil { log.Fatal(err) } </s> add config.firstRun = detectFirstRun()
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/302c3a767a4d296d1f8cf5d895be8af2477113ce
dhcp.go
"fmt"
<mask> import ( <mask> "bufio" <mask> "errors" <mask> "io" <mask> "io/ioutil" <mask> "net" <mask> "net/http" <mask> "os" </s> Initial implementation of welcome/firstrun/installer page in go backend </s> remove "bufio" </s> add </s> remove "net" </s> add </s> remove data := struct { Web ipport `json:"web"` DNS ipport `json:"dns"` }{} </s> add </s> remove "golang.org/x/crypto/ssh/terminal" </s> add
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/302c3a767a4d296d1f8cf5d895be8af2477113ce
helpers.go
"net"
<mask> "errors" <mask> "fmt" <mask> "io" <mask> "io/ioutil" <mask> "net/http" <mask> "os" <mask> "path" <mask> "path/filepath" <mask> "runtime" <mask> "strings" </s> Initial implementation of welcome/firstrun/installer page in go backend </s> remove "net" </s> add </s> remove "bufio" </s> add </s> remove type ipport struct { IP string `json:"ip"` Port int `json:"port"` </s> add data := firstRunData{} ifaces, err := getValidNetInterfaces() if err != nil { httpError(w, http.StatusInternalServerError, "Couldn't get interfaces: %s", err) return } if len(ifaces) == 0 { httpError(w, http.StatusServiceUnavailable, "Couldn't find any legible interface, plase try again later") return
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/302c3a767a4d296d1f8cf5d895be8af2477113ce
helpers.go
"github.com/hmage/golibs/log"
<mask> "path" <mask> "path/filepath" <mask> "runtime" <mask> "strings" <mask> ) <mask> <mask> // ---------------------------------- <mask> // helper functions for working with files </s> Initial implementation of welcome/firstrun/installer page in go backend </s> remove "golang.org/x/crypto/ssh/terminal" </s> add </s> remove if ifaces[i].Flags&net.FlagLoopback != 0 { // it's a loopback, skip it continue } if ifaces[i].Flags&net.FlagBroadcast == 0 { // this interface doesn't support broadcast, skip it continue } if ifaces[i].Flags&net.FlagPointToPoint != 0 { // this interface is ppp, don't do dhcp over it continue } iface := responseInterface{ Name: ifaces[i].Name, MTU: ifaces[i].MTU, HardwareAddr: ifaces[i].HardwareAddr.String(), } addrs, errAddrs := ifaces[i].Addrs() if errAddrs != nil { httpError(w, http.StatusInternalServerError, "Failed to get addresses for interface %v: %s", ifaces[i].Name, errAddrs) return } for _, addr := range addrs { iface.Addresses = append(iface.Addresses, addr.String()) } if len(iface.Addresses) == 0 { // this interface has no addresses, skip it continue } response[ifaces[i].Name] = iface </s> add response[ifaces[i].Name] = ifaces[i] </s> remove // TODO: replace mockup with actual data data.Web.IP = "192.168.104.104" data.Web.Port = 3000 data.DNS.IP = "192.168.104.104" data.DNS.Port = 53 </s> add // find an interface with an ipv4 address addr := findIPv4IfaceAddr(ifaces) if len(addr) == 0 { httpError(w, http.StatusServiceUnavailable, "Couldn't find any interface with IPv4, plase try again later") return } data.Web.IP = addr data.DNS.IP = addr data.Web.Port = 3000 // TODO: find out if port 80 is available -- if not, fall back to 3000 data.DNS.Port = 53 // TODO: find out if port 53 is available -- if not, show a big warning </s> remove data := struct { Web ipport `json:"web"` DNS ipport `json:"dns"` }{} </s> add
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/302c3a767a4d296d1f8cf5d895be8af2477113ce
helpers.go
optionalAuth(a.handler.ServeHTTP)(w, r)
<mask> handler http.Handler <mask> } <mask> <mask> func (a *authHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { <mask> if config.AuthName == "" || config.AuthPass == "" { <mask> a.handler.ServeHTTP(w, r) <mask> return <mask> } <mask> user, pass, ok := r.BasicAuth() <mask> if !ok || user != config.AuthName || pass != config.AuthPass { <mask> w.Header().Set("WWW-Authenticate", `Basic realm="dnsfilter"`) <mask> w.WriteHeader(http.StatusUnauthorized) <mask> w.Write([]byte("Unauthorised.\n")) <mask> return <mask> } <mask> a.handler.ServeHTTP(w, r) <mask> } <mask> <mask> func optionalAuthHandler(handler http.Handler) http.Handler { <mask> return &authHandler{handler} <mask> } </s> Initial implementation of welcome/firstrun/installer page in go backend </s> remove type ipport struct { IP string `json:"ip"` Port int `json:"port"` </s> add data := firstRunData{} ifaces, err := getValidNetInterfaces() if err != nil { httpError(w, http.StatusInternalServerError, "Couldn't get interfaces: %s", err) return } if len(ifaces) == 0 { httpError(w, http.StatusServiceUnavailable, "Couldn't find any legible interface, plase try again later") return </s> remove func promptAndGet(prompt string) (string, error) { for { fmt.Print(prompt) input, err := getInput() if err != nil { log.Printf("Failed to get input, aborting: %s", err) return "", err } if len(input) != 0 { return input, nil } // try again } } func promptAndGetPassword(prompt string) (string, error) { for { fmt.Print(prompt) password, err := terminal.ReadPassword(int(os.Stdin.Fd())) fmt.Print("\n") if err != nil { log.Printf("Failed to get input, aborting: %s", err) return "", err } if len(password) != 0 { return string(password), nil } // try again } } func askUsernamePasswordIfPossible() error { configFile := config.getConfigFilename() _, err := os.Stat(configFile) if !os.IsNotExist(err) { // do nothing, file exists return nil } if !terminal.IsTerminal(int(os.Stdin.Fd())) { return nil // do nothing } if !terminal.IsTerminal(int(os.Stdout.Fd())) { return nil // do nothing } fmt.Printf("Would you like to set user/password for the web interface authentication (yes/no)?\n") yesno, err := promptAndGet("Please type 'yes' or 'no': ") if err != nil { return err } if yesno[0] != 'y' && yesno[0] != 'Y' { return nil } username, err := promptAndGet("Please enter the username: ") if err != nil { return err } password, err := promptAndGetPassword("Please enter the password: ") if err != nil { return err } password2, err := promptAndGetPassword("Please enter password again: ") if err != nil { return err } if password2 != password { fmt.Printf("Passwords do not match! Aborting\n") os.Exit(1) } config.AuthName = username config.AuthPass = password return nil } </s> add </s> remove newSettings := map[string]interface{}{} </s> add newSettings := firstRunData{}
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/302c3a767a4d296d1f8cf5d895be8af2477113ce
helpers.go
<mask> - errcheck <mask> - govet <mask> - ineffassign <mask> - staticcheck <mask> - structcheck <mask> - unused <mask> - varcheck <mask> - bodyclose <mask> - depguard <mask> - dupl </s> Pull request: 2271 handle nolint Merge in DNS/adguard-home from 2271-handle-nolint to master Closes #2271. Squashed commit of the following: commit fde5c8795ac79e1f7d02ba8c8e369b5a724a000e Merge: fc2acd898 642dcd647 Author: Eugene Burkov <[email protected]> Date: Fri Nov 20 17:12:28 2020 +0300 Merge branch 'master' into 2271-handle-nolint commit fc2acd89871de08c39e80ace9e5bb8a7acb7afba Author: Eugene Burkov <[email protected]> Date: Tue Nov 17 11:55:29 2020 +0300 dnsforward: fix test output strings commit c4ebae6ea9c293bad239519c44ca5a6c576bb921 Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 22:43:20 2020 +0300 dnsfilter: make package pass tests commit f2d98c6acabd8977f3b1b361987eaa31eb6eb9ad Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 20:05:00 2020 +0300 querylog: make decoding pass tests commit ab5850d24c50d53b8393f2de448cc340241351d7 Merge: 6ed2066bf 8a9c6e8a0 Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 19:48:31 2020 +0300 Merge branch 'master' into 2271-handle-nolint commit 6ed2066bf567e13dd14cfa16fc7b109b59fa39ef Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 18:13:45 2020 +0300 home: fix tests naming commit af691081fb02b7500a746b16492f01f7f9befe9a Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 12:15:49 2020 +0300 home: impove code quality commit 2914cd3cd23ef2a1964116baab9187d89b377f86 Author: Eugene Burkov <[email protected]> Date: Wed Nov 11 15:46:39 2020 +0300 * querylog: remove useless check commit 9996840650e784ccc76d1f29964560435ba27dc7 Author: Eugene Burkov <[email protected]> Date: Wed Nov 11 13:18:34 2020 +0300 * all: fix noticed defects commit 2b15293e59337f70302fbc0db81ebb26bee0bed2 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 20:15:53 2020 +0300 * stats: remove last nolint directive commit b2e1ddf7b58196a2fdbf879f084edb41ca1aa1eb Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 18:35:41 2020 +0300 * all: remove another nolint directive commit c6fc5cfcc9c95ab9e570a95ab41c3e5c0125e62e Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 18:11:28 2020 +0300 * querylog: remove nolint directive commit 226ddbf2c92f737f085b44a4ddf6daec7b602153 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 16:35:26 2020 +0300 * home: remove nolint directive commit 2ea3086ad41e9003282add7e996ae722d72d878b Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 16:13:57 2020 +0300 * home: reduce cyclomatic complexity of run function commit f479b480c48e0bb832ddef8f57586f56b8a55bab Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 15:35:46 2020 +0300 * home: use crypto/rand instead of math/rand commit a28d4a53e3b930136b036606fc7e78404f1d208b Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 14:11:07 2020 +0300 * dnsforward: remove gocyclo nolint directive commit 64a0a324cc2b20614ceec3ccc6505e960fe526e9 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 11:45:49 2020 +0300 all *: remove some nolint directives Updates #2271. </s> remove // nolint (gocyclo) </s> add </s> remove // nolint(gocyclo) - we need to check each JSON field separately </s> add </s> remove a := []uint64{} if timeUnit == Hours { for _, u := range units { a = append(a, u.NTotal) } } else { var sum uint64 id := firstDayID nextDayID := firstDayID + 24 for i := firstDayID - firstID; int(i) != len(units); i++ { sum += units[i].NTotal if id == nextDayID { a = append(a, sum) sum = 0 nextDayID += 24 </s> add statsCollector := func(numsGetter func(u *unitDB) (num uint64)) (nums []uint64) { if timeUnit == Hours { for _, u := range units { nums = append(nums, numsGetter(u)) </s> remove req := dnsConfigJSON{} js, err := jsonutil.DecodeObject(&req, r.Body) if err != nil { httpError(r, w, http.StatusBadRequest, "json.Decode: %s", err) </s> add req := dnsConfig{} dec := json.NewDecoder(r.Body) if err := dec.Decode(&req); err != nil { httpError(r, w, http.StatusBadRequest, "json Encode: %s", err)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/3045da1742ee0e75392de1623900d7d88b08f0b4
.golangci.yml
// In returns true if reasons include r. func (r Reason) In(reasons ...Reason) bool { for _, reason := range reasons { if r == reason { return true } } return false }
<mask> } <mask> <mask> // GetConfig - get configuration <mask> func (d *Dnsfilter) GetConfig() RequestFilteringSettings { <mask> c := RequestFilteringSettings{} <mask> // d.confLock.RLock() </s> Pull request: 2271 handle nolint Merge in DNS/adguard-home from 2271-handle-nolint to master Closes #2271. Squashed commit of the following: commit fde5c8795ac79e1f7d02ba8c8e369b5a724a000e Merge: fc2acd898 642dcd647 Author: Eugene Burkov <[email protected]> Date: Fri Nov 20 17:12:28 2020 +0300 Merge branch 'master' into 2271-handle-nolint commit fc2acd89871de08c39e80ace9e5bb8a7acb7afba Author: Eugene Burkov <[email protected]> Date: Tue Nov 17 11:55:29 2020 +0300 dnsforward: fix test output strings commit c4ebae6ea9c293bad239519c44ca5a6c576bb921 Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 22:43:20 2020 +0300 dnsfilter: make package pass tests commit f2d98c6acabd8977f3b1b361987eaa31eb6eb9ad Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 20:05:00 2020 +0300 querylog: make decoding pass tests commit ab5850d24c50d53b8393f2de448cc340241351d7 Merge: 6ed2066bf 8a9c6e8a0 Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 19:48:31 2020 +0300 Merge branch 'master' into 2271-handle-nolint commit 6ed2066bf567e13dd14cfa16fc7b109b59fa39ef Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 18:13:45 2020 +0300 home: fix tests naming commit af691081fb02b7500a746b16492f01f7f9befe9a Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 12:15:49 2020 +0300 home: impove code quality commit 2914cd3cd23ef2a1964116baab9187d89b377f86 Author: Eugene Burkov <[email protected]> Date: Wed Nov 11 15:46:39 2020 +0300 * querylog: remove useless check commit 9996840650e784ccc76d1f29964560435ba27dc7 Author: Eugene Burkov <[email protected]> Date: Wed Nov 11 13:18:34 2020 +0300 * all: fix noticed defects commit 2b15293e59337f70302fbc0db81ebb26bee0bed2 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 20:15:53 2020 +0300 * stats: remove last nolint directive commit b2e1ddf7b58196a2fdbf879f084edb41ca1aa1eb Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 18:35:41 2020 +0300 * all: remove another nolint directive commit c6fc5cfcc9c95ab9e570a95ab41c3e5c0125e62e Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 18:11:28 2020 +0300 * querylog: remove nolint directive commit 226ddbf2c92f737f085b44a4ddf6daec7b602153 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 16:35:26 2020 +0300 * home: remove nolint directive commit 2ea3086ad41e9003282add7e996ae722d72d878b Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 16:13:57 2020 +0300 * home: reduce cyclomatic complexity of run function commit f479b480c48e0bb832ddef8f57586f56b8a55bab Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 15:35:46 2020 +0300 * home: use crypto/rand instead of math/rand commit a28d4a53e3b930136b036606fc7e78404f1d208b Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 14:11:07 2020 +0300 * dnsforward: remove gocyclo nolint directive commit 64a0a324cc2b20614ceec3ccc6505e960fe526e9 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 11:45:49 2020 +0300 all *: remove some nolint directives Updates #2271. </s> remove // Disabling "dupl": the algorithm of SB/PC is similar, but it uses different data // nolint:dupl func (d *Dnsfilter) checkParental(host string) (Result, error) { </s> add func (d *Dnsfilter) checkSafeBrowsing(host string) (Result, error) { </s> remove defer timer.LogElapsed("Parental lookup for %s", host) </s> add defer timer.LogElapsed("SafeBrowsing lookup for %s", host) </s> remove // Disabling "dupl": the algorithm of SB/PC is similar, but it uses different data // nolint:dupl func (d *Dnsfilter) checkSafeBrowsing(host string) (Result, error) { if log.GetLevel() >= log.DEBUG { timer := log.StartTimer() defer timer.LogElapsed("SafeBrowsing lookup for %s", host) } result := Result{} hashes := hostnameToHashes(host) c := &sbCtx{ host: host, svc: "SafeBrowsing", hashToHost: hashes, cache: gctx.safebrowsingCache, cacheTime: d.Config.CacheTime, } // check cache match := c.getCached() if match < 0 { return result, nil } else if match > 0 { result.IsFiltered = true result.Reason = FilteredSafeBrowsing result.Rule = "adguard-malware-shavar" return result, nil </s> add func check(c *sbCtx, r Result, u upstream.Upstream) (Result, error) { c.hashToHost = hostnameToHashes(c.host) switch c.getCached() { case -1: return Result{}, nil case 1: return r, nil </s> remove return result, nil </s> add return Result{}, nil
[ "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/3045da1742ee0e75392de1623900d7d88b08f0b4
internal/dnsfilter/dnsfilter.go
// findInHash returns 32-byte hash if it's found in hashToHost. func (c *sbCtx) findInHash(val []byte) (hash32 [32]byte, found bool) { for i := 4; i < len(val); i += 32 { hash := val[i : i+32] copy(hash32[:], hash[0:32]) _, found = c.hashToHost[hash32] if found { return hash32, found } } return [32]byte{}, false }
<mask> } <mask> <mask> func (c *sbCtx) getCached() int { <mask> now := time.Now().Unix() <mask> hashesToRequest := map[[32]byte]string{} <mask> for k, v := range c.hashToHost { </s> Pull request: 2271 handle nolint Merge in DNS/adguard-home from 2271-handle-nolint to master Closes #2271. Squashed commit of the following: commit fde5c8795ac79e1f7d02ba8c8e369b5a724a000e Merge: fc2acd898 642dcd647 Author: Eugene Burkov <[email protected]> Date: Fri Nov 20 17:12:28 2020 +0300 Merge branch 'master' into 2271-handle-nolint commit fc2acd89871de08c39e80ace9e5bb8a7acb7afba Author: Eugene Burkov <[email protected]> Date: Tue Nov 17 11:55:29 2020 +0300 dnsforward: fix test output strings commit c4ebae6ea9c293bad239519c44ca5a6c576bb921 Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 22:43:20 2020 +0300 dnsfilter: make package pass tests commit f2d98c6acabd8977f3b1b361987eaa31eb6eb9ad Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 20:05:00 2020 +0300 querylog: make decoding pass tests commit ab5850d24c50d53b8393f2de448cc340241351d7 Merge: 6ed2066bf 8a9c6e8a0 Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 19:48:31 2020 +0300 Merge branch 'master' into 2271-handle-nolint commit 6ed2066bf567e13dd14cfa16fc7b109b59fa39ef Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 18:13:45 2020 +0300 home: fix tests naming commit af691081fb02b7500a746b16492f01f7f9befe9a Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 12:15:49 2020 +0300 home: impove code quality commit 2914cd3cd23ef2a1964116baab9187d89b377f86 Author: Eugene Burkov <[email protected]> Date: Wed Nov 11 15:46:39 2020 +0300 * querylog: remove useless check commit 9996840650e784ccc76d1f29964560435ba27dc7 Author: Eugene Burkov <[email protected]> Date: Wed Nov 11 13:18:34 2020 +0300 * all: fix noticed defects commit 2b15293e59337f70302fbc0db81ebb26bee0bed2 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 20:15:53 2020 +0300 * stats: remove last nolint directive commit b2e1ddf7b58196a2fdbf879f084edb41ca1aa1eb Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 18:35:41 2020 +0300 * all: remove another nolint directive commit c6fc5cfcc9c95ab9e570a95ab41c3e5c0125e62e Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 18:11:28 2020 +0300 * querylog: remove nolint directive commit 226ddbf2c92f737f085b44a4ddf6daec7b602153 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 16:35:26 2020 +0300 * home: remove nolint directive commit 2ea3086ad41e9003282add7e996ae722d72d878b Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 16:13:57 2020 +0300 * home: reduce cyclomatic complexity of run function commit f479b480c48e0bb832ddef8f57586f56b8a55bab Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 15:35:46 2020 +0300 * home: use crypto/rand instead of math/rand commit a28d4a53e3b930136b036606fc7e78404f1d208b Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 14:11:07 2020 +0300 * dnsforward: remove gocyclo nolint directive commit 64a0a324cc2b20614ceec3ccc6505e960fe526e9 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 11:45:49 2020 +0300 all *: remove some nolint directives Updates #2271. </s> remove if val != nil { expire := binary.BigEndian.Uint32(val) if now >= int64(expire) { val = nil } else { for i := 4; i < len(val); i += 32 { hash := val[i : i+32] var hash32 [32]byte copy(hash32[:], hash[0:32]) _, found := c.hashToHost[hash32] if found { log.Debug("%s: found in cache: %s: blocked by %v", c.svc, c.host, hash32) return 1 } } } } if val == nil { </s> add if val == nil || now >= int64(binary.BigEndian.Uint32(val)) { </s> remove const ( jsonTErr = iota jsonTObj jsonTStr jsonTNum jsonTBool ) // Parse JSON key-value pair // e.g.: "key":VALUE where VALUE is "string", true|false (boolean), or 123.456 (number) // Note the limitations: // . doesn't support whitespace // . doesn't support "null" // . doesn't validate boolean or number // . no proper handling of {} braces // . no handling of [] brackets // Return (key, value, type) func readJSON(ps *string) (string, string, int32) { s := *ps k := "" v := "" t := int32(jsonTErr) q1 := strings.IndexByte(s, '"') if q1 == -1 { return k, v, t } q2 := strings.IndexByte(s[q1+1:], '"') if q2 == -1 { return k, v, t } k = s[q1+1 : q1+1+q2] s = s[q1+1+q2+1:] if len(s) < 2 || s[0] != ':' { return k, v, t } if s[1] == '"' { q2 = strings.IndexByte(s[2:], '"') if q2 == -1 { return k, v, t } v = s[2 : 2+q2] t = jsonTStr s = s[2+q2+1:] } else if s[1] == '{' { t = jsonTObj s = s[1+1:] } else { sep := strings.IndexAny(s[1:], ",}") if sep == -1 { return k, v, t } v = s[1 : 1+sep] if s[1] == 't' || s[1] == 'f' { t = jsonTBool } else if s[1] == '.' || (s[1] >= '0' && s[1] <= '9') { t = jsonTNum } s = s[1+sep+1:] } *ps = s return k, v, t } </s> add </s> remove // decodeLogEntry - decodes query log entry from a line // nolint (gocyclo) func decodeLogEntry(ent *logEntry, str string) { var b bool var i int var err error for { k, v, t := readJSON(&str) if t == jsonTErr { break } switch k { case "IP": if len(ent.IP) == 0 { ent.IP = v } case "T": ent.Time, err = time.Parse(time.RFC3339, v) case "QH": ent.QHost = v case "QT": ent.QType = v case "QC": ent.QClass = v case "CP": ent.ClientProto, err = NewClientProto(v) case "Answer": ent.Answer, err = base64.StdEncoding.DecodeString(v) case "OrigAnswer": ent.OrigAnswer, err = base64.StdEncoding.DecodeString(v) case "IsFiltered": b, err = strconv.ParseBool(v) ent.Result.IsFiltered = b case "Rule": ent.Result.Rule = v case "FilterID": i, err = strconv.Atoi(v) ent.Result.FilterID = int64(i) case "Reason": i, err = strconv.Atoi(v) ent.Result.Reason = dnsfilter.Reason(i) case "ServiceName": ent.Result.ServiceName = v case "Upstream": ent.Upstream = v case "Elapsed": i, err = strconv.Atoi(v) ent.Elapsed = time.Duration(i) // pre-v0.99.3 compatibility: case "Question": var qstr []byte qstr, err = base64.StdEncoding.DecodeString(v) if err != nil { break } q := new(dns.Msg) err = q.Unpack(qstr) if err != nil { break } ent.QHost = q.Question[0].Name if len(ent.QHost) == 0 { break } ent.QHost = ent.QHost[:len(ent.QHost)-1] ent.QType = dns.TypeToString[q.Question[0].Qtype] ent.QClass = dns.ClassToString[q.Question[0].Qclass] case "Time": ent.Time, err = time.Parse(time.RFC3339, v) </s> add var logEntryHandlers = map[string](func(t json.Token, ent *logEntry) error){ "IP": func(t json.Token, ent *logEntry) error { v, ok := t.(string) if !ok { return nil } if len(ent.IP) == 0 { ent.IP = v } return nil }, "T": func(t json.Token, ent *logEntry) error { v, ok := t.(string) if !ok { return nil } var err error ent.Time, err = time.Parse(time.RFC3339, v) return err }, "QH": func(t json.Token, ent *logEntry) error { v, ok := t.(string) if !ok { return nil } ent.QHost = v return nil }, "QT": func(t json.Token, ent *logEntry) error { v, ok := t.(string) if !ok { return nil } ent.QType = v return nil }, "QC": func(t json.Token, ent *logEntry) error { v, ok := t.(string) if !ok { return nil } ent.QClass = v return nil }, "CP": func(t json.Token, ent *logEntry) error { v, ok := t.(string) if !ok { return nil } var err error ent.ClientProto, err = NewClientProto(v) return err }, "Answer": func(t json.Token, ent *logEntry) error { v, ok := t.(string) if !ok { return nil } var err error ent.Answer, err = base64.StdEncoding.DecodeString(v) return err }, "OrigAnswer": func(t json.Token, ent *logEntry) error { v, ok := t.(string) if !ok { return nil } var err error ent.OrigAnswer, err = base64.StdEncoding.DecodeString(v) return err }, "IsFiltered": func(t json.Token, ent *logEntry) error { v, ok := t.(string) if !ok { return nil } b, err := strconv.ParseBool(v) if err != nil { return err } ent.Result.IsFiltered = b return nil }, "Rule": func(t json.Token, ent *logEntry) error { v, ok := t.(string) if !ok { return nil } ent.Result.Rule = v return nil }, "FilterID": func(t json.Token, ent *logEntry) error { v, ok := t.(string) if !ok { return nil } i, err := strconv.Atoi(v) if err != nil { return err } ent.Result.FilterID = int64(i) return nil }, "Reason": func(t json.Token, ent *logEntry) error { v, ok := t.(string) if !ok { return nil } i, err := strconv.Atoi(v) if err != nil { return err } ent.Result.Reason = dnsfilter.Reason(i) return nil }, "ServiceName": func(t json.Token, ent *logEntry) error { v, ok := t.(string) if !ok { return nil } ent.Result.ServiceName = v return nil }, "Upstream": func(t json.Token, ent *logEntry) error { v, ok := t.(string) if !ok { return nil </s> remove a2 := convertMapToArray(m, maxDomains) d["top_queried_domains"] = convertTopArray(a2) </s> add
[ "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/3045da1742ee0e75392de1623900d7d88b08f0b4
internal/dnsfilter/sb_pc.go
if val == nil || now >= int64(binary.BigEndian.Uint32(val)) {
<mask> hashesToRequest := map[[32]byte]string{} <mask> for k, v := range c.hashToHost { <mask> key := k[0:2] <mask> val := c.cache.Get(key) <mask> if val != nil { <mask> expire := binary.BigEndian.Uint32(val) <mask> if now >= int64(expire) { <mask> val = nil <mask> } else { <mask> for i := 4; i < len(val); i += 32 { <mask> hash := val[i : i+32] <mask> var hash32 [32]byte <mask> copy(hash32[:], hash[0:32]) <mask> _, found := c.hashToHost[hash32] <mask> if found { <mask> log.Debug("%s: found in cache: %s: blocked by %v", c.svc, c.host, hash32) <mask> return 1 <mask> } <mask> } <mask> } <mask> } <mask> if val == nil { <mask> hashesToRequest[k] = v <mask> } <mask> } <mask> <mask> if len(hashesToRequest) == 0 { </s> Pull request: 2271 handle nolint Merge in DNS/adguard-home from 2271-handle-nolint to master Closes #2271. Squashed commit of the following: commit fde5c8795ac79e1f7d02ba8c8e369b5a724a000e Merge: fc2acd898 642dcd647 Author: Eugene Burkov <[email protected]> Date: Fri Nov 20 17:12:28 2020 +0300 Merge branch 'master' into 2271-handle-nolint commit fc2acd89871de08c39e80ace9e5bb8a7acb7afba Author: Eugene Burkov <[email protected]> Date: Tue Nov 17 11:55:29 2020 +0300 dnsforward: fix test output strings commit c4ebae6ea9c293bad239519c44ca5a6c576bb921 Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 22:43:20 2020 +0300 dnsfilter: make package pass tests commit f2d98c6acabd8977f3b1b361987eaa31eb6eb9ad Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 20:05:00 2020 +0300 querylog: make decoding pass tests commit ab5850d24c50d53b8393f2de448cc340241351d7 Merge: 6ed2066bf 8a9c6e8a0 Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 19:48:31 2020 +0300 Merge branch 'master' into 2271-handle-nolint commit 6ed2066bf567e13dd14cfa16fc7b109b59fa39ef Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 18:13:45 2020 +0300 home: fix tests naming commit af691081fb02b7500a746b16492f01f7f9befe9a Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 12:15:49 2020 +0300 home: impove code quality commit 2914cd3cd23ef2a1964116baab9187d89b377f86 Author: Eugene Burkov <[email protected]> Date: Wed Nov 11 15:46:39 2020 +0300 * querylog: remove useless check commit 9996840650e784ccc76d1f29964560435ba27dc7 Author: Eugene Burkov <[email protected]> Date: Wed Nov 11 13:18:34 2020 +0300 * all: fix noticed defects commit 2b15293e59337f70302fbc0db81ebb26bee0bed2 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 20:15:53 2020 +0300 * stats: remove last nolint directive commit b2e1ddf7b58196a2fdbf879f084edb41ca1aa1eb Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 18:35:41 2020 +0300 * all: remove another nolint directive commit c6fc5cfcc9c95ab9e570a95ab41c3e5c0125e62e Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 18:11:28 2020 +0300 * querylog: remove nolint directive commit 226ddbf2c92f737f085b44a4ddf6daec7b602153 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 16:35:26 2020 +0300 * home: remove nolint directive commit 2ea3086ad41e9003282add7e996ae722d72d878b Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 16:13:57 2020 +0300 * home: reduce cyclomatic complexity of run function commit f479b480c48e0bb832ddef8f57586f56b8a55bab Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 15:35:46 2020 +0300 * home: use crypto/rand instead of math/rand commit a28d4a53e3b930136b036606fc7e78404f1d208b Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 14:11:07 2020 +0300 * dnsforward: remove gocyclo nolint directive commit 64a0a324cc2b20614ceec3ccc6505e960fe526e9 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 11:45:49 2020 +0300 all *: remove some nolint directives Updates #2271. </s> remove id++ } if id <= nextDayID { a = append(a, sum) } if len(a) != int(limit/24) { log.Fatalf("len(a) != limit: %d %d", len(a), limit) } } d["dns_queries"] = a a = []uint64{} if timeUnit == Hours { for _, u := range units { a = append(a, u.NResult[RFiltered]) } } else { var sum uint64 id := firstDayID nextDayID := firstDayID + 24 for i := firstDayID - firstID; int(i) != len(units); i++ { sum += units[i].NResult[RFiltered] if id == nextDayID { a = append(a, sum) sum = 0 nextDayID += 24 </s> add } else { var sum uint64 id := firstDayID nextDayID := firstDayID + 24 for i := int(firstDayID - firstID); i != len(units); i++ { sum += numsGetter(units[i]) if id == nextDayID { nums = append(nums, sum) sum = 0 nextDayID += 24 } id++ </s> remove a = append(a, u.NResult[RParental]) } } else { var sum uint64 id := firstDayID nextDayID := firstDayID + 24 for i := firstDayID - firstID; int(i) != len(units); i++ { sum += units[i].NResult[RParental] if id == nextDayID { a = append(a, sum) sum = 0 nextDayID += 24 </s> add for _, it := range pairsGetter(u) { m[it.Name] += it.Count </s> remove const ( jsonTErr = iota jsonTObj jsonTStr jsonTNum jsonTBool ) // Parse JSON key-value pair // e.g.: "key":VALUE where VALUE is "string", true|false (boolean), or 123.456 (number) // Note the limitations: // . doesn't support whitespace // . doesn't support "null" // . doesn't validate boolean or number // . no proper handling of {} braces // . no handling of [] brackets // Return (key, value, type) func readJSON(ps *string) (string, string, int32) { s := *ps k := "" v := "" t := int32(jsonTErr) q1 := strings.IndexByte(s, '"') if q1 == -1 { return k, v, t } q2 := strings.IndexByte(s[q1+1:], '"') if q2 == -1 { return k, v, t } k = s[q1+1 : q1+1+q2] s = s[q1+1+q2+1:] if len(s) < 2 || s[0] != ':' { return k, v, t } if s[1] == '"' { q2 = strings.IndexByte(s[2:], '"') if q2 == -1 { return k, v, t } v = s[2 : 2+q2] t = jsonTStr s = s[2+q2+1:] } else if s[1] == '{' { t = jsonTObj s = s[1+1:] } else { sep := strings.IndexAny(s[1:], ",}") if sep == -1 { return k, v, t } v = s[1 : 1+sep] if s[1] == 't' || s[1] == 'f' { t = jsonTBool } else if s[1] == '.' || (s[1] >= '0' && s[1] <= '9') { t = jsonTNum } s = s[1+sep+1:] } *ps = s return k, v, t } </s> add
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/3045da1742ee0e75392de1623900d7d88b08f0b4
internal/dnsfilter/sb_pc.go
continue } if hash32, found := c.findInHash(val); found { log.Debug("%s: found in cache: %s: blocked by %v", c.svc, c.host, hash32) return 1
<mask> key := k[0:2] <mask> val := c.cache.Get(key) <mask> if val == nil || now >= int64(binary.BigEndian.Uint32(val)) { <mask> hashesToRequest[k] = v <mask> } <mask> } <mask> <mask> if len(hashesToRequest) == 0 { <mask> log.Debug("%s: found in cache: %s: not blocked", c.svc, c.host) </s> Pull request: 2271 handle nolint Merge in DNS/adguard-home from 2271-handle-nolint to master Closes #2271. Squashed commit of the following: commit fde5c8795ac79e1f7d02ba8c8e369b5a724a000e Merge: fc2acd898 642dcd647 Author: Eugene Burkov <[email protected]> Date: Fri Nov 20 17:12:28 2020 +0300 Merge branch 'master' into 2271-handle-nolint commit fc2acd89871de08c39e80ace9e5bb8a7acb7afba Author: Eugene Burkov <[email protected]> Date: Tue Nov 17 11:55:29 2020 +0300 dnsforward: fix test output strings commit c4ebae6ea9c293bad239519c44ca5a6c576bb921 Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 22:43:20 2020 +0300 dnsfilter: make package pass tests commit f2d98c6acabd8977f3b1b361987eaa31eb6eb9ad Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 20:05:00 2020 +0300 querylog: make decoding pass tests commit ab5850d24c50d53b8393f2de448cc340241351d7 Merge: 6ed2066bf 8a9c6e8a0 Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 19:48:31 2020 +0300 Merge branch 'master' into 2271-handle-nolint commit 6ed2066bf567e13dd14cfa16fc7b109b59fa39ef Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 18:13:45 2020 +0300 home: fix tests naming commit af691081fb02b7500a746b16492f01f7f9befe9a Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 12:15:49 2020 +0300 home: impove code quality commit 2914cd3cd23ef2a1964116baab9187d89b377f86 Author: Eugene Burkov <[email protected]> Date: Wed Nov 11 15:46:39 2020 +0300 * querylog: remove useless check commit 9996840650e784ccc76d1f29964560435ba27dc7 Author: Eugene Burkov <[email protected]> Date: Wed Nov 11 13:18:34 2020 +0300 * all: fix noticed defects commit 2b15293e59337f70302fbc0db81ebb26bee0bed2 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 20:15:53 2020 +0300 * stats: remove last nolint directive commit b2e1ddf7b58196a2fdbf879f084edb41ca1aa1eb Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 18:35:41 2020 +0300 * all: remove another nolint directive commit c6fc5cfcc9c95ab9e570a95ab41c3e5c0125e62e Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 18:11:28 2020 +0300 * querylog: remove nolint directive commit 226ddbf2c92f737f085b44a4ddf6daec7b602153 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 16:35:26 2020 +0300 * home: remove nolint directive commit 2ea3086ad41e9003282add7e996ae722d72d878b Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 16:13:57 2020 +0300 * home: reduce cyclomatic complexity of run function commit f479b480c48e0bb832ddef8f57586f56b8a55bab Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 15:35:46 2020 +0300 * home: use crypto/rand instead of math/rand commit a28d4a53e3b930136b036606fc7e78404f1d208b Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 14:11:07 2020 +0300 * dnsforward: remove gocyclo nolint directive commit 64a0a324cc2b20614ceec3ccc6505e960fe526e9 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 11:45:49 2020 +0300 all *: remove some nolint directives Updates #2271. </s> remove if val != nil { expire := binary.BigEndian.Uint32(val) if now >= int64(expire) { val = nil } else { for i := 4; i < len(val); i += 32 { hash := val[i : i+32] var hash32 [32]byte copy(hash32[:], hash[0:32]) _, found := c.hashToHost[hash32] if found { log.Debug("%s: found in cache: %s: blocked by %v", c.svc, c.host, hash32) return 1 } } } } if val == nil { </s> add if val == nil || now >= int64(binary.BigEndian.Uint32(val)) { </s> remove const ( jsonTErr = iota jsonTObj jsonTStr jsonTNum jsonTBool ) // Parse JSON key-value pair // e.g.: "key":VALUE where VALUE is "string", true|false (boolean), or 123.456 (number) // Note the limitations: // . doesn't support whitespace // . doesn't support "null" // . doesn't validate boolean or number // . no proper handling of {} braces // . no handling of [] brackets // Return (key, value, type) func readJSON(ps *string) (string, string, int32) { s := *ps k := "" v := "" t := int32(jsonTErr) q1 := strings.IndexByte(s, '"') if q1 == -1 { return k, v, t } q2 := strings.IndexByte(s[q1+1:], '"') if q2 == -1 { return k, v, t } k = s[q1+1 : q1+1+q2] s = s[q1+1+q2+1:] if len(s) < 2 || s[0] != ':' { return k, v, t } if s[1] == '"' { q2 = strings.IndexByte(s[2:], '"') if q2 == -1 { return k, v, t } v = s[2 : 2+q2] t = jsonTStr s = s[2+q2+1:] } else if s[1] == '{' { t = jsonTObj s = s[1+1:] } else { sep := strings.IndexAny(s[1:], ",}") if sep == -1 { return k, v, t } v = s[1 : 1+sep] if s[1] == 't' || s[1] == 'f' { t = jsonTBool } else if s[1] == '.' || (s[1] >= '0' && s[1] <= '9') { t = jsonTNum } s = s[1+sep+1:] } *ps = s return k, v, t } </s> add </s> remove // redirect to login page if not authenticated ok := false cookie, err := r.Cookie(sessionCookieName) if glProcessCookie(r) { log.Debug("Auth: authentification was handled by GL-Inet submodule") ok = true } else if err == nil { r := Context.auth.CheckSession(cookie.Value) if r == 0 { ok = true } else if r < 0 { log.Debug("Auth: invalid cookie value: %s", cookie) } } else { // there's no Cookie, check Basic authentication user, pass, ok2 := r.BasicAuth() if ok2 { u := Context.auth.UserFind(user, pass) if len(u.Name) != 0 { ok = true } else { log.Info("Auth: invalid Basic Authorization value") } } } if !ok { if r.URL.Path == "/" || r.URL.Path == "/index.html" { if glProcessRedirect(w, r) { log.Debug("Auth: redirected to login page by GL-Inet submodule") } else { w.Header().Set("Location", "/login.html") w.WriteHeader(http.StatusFound) } } else { w.WriteHeader(http.StatusForbidden) _, _ = w.Write([]byte("Forbidden")) } </s> add if optionalAuthThird(w, r) { </s> remove // nolint(gocyclo) </s> add // optionalAuthThird return true if user should authenticate first. func optionalAuthThird(w http.ResponseWriter, r *http.Request) (authFirst bool) { authFirst = false // redirect to login page if not authenticated ok := false cookie, err := r.Cookie(sessionCookieName) if glProcessCookie(r) { log.Debug("Auth: authentification was handled by GL-Inet submodule") ok = true } else if err == nil { r := Context.auth.CheckSession(cookie.Value) if r == 0 { ok = true } else if r < 0 { log.Debug("Auth: invalid cookie value: %s", cookie) } } else { // there's no Cookie, check Basic authentication user, pass, ok2 := r.BasicAuth() if ok2 { u := Context.auth.UserFind(user, pass) if len(u.Name) != 0 { ok = true } else { log.Info("Auth: invalid Basic Authorization value") } } } if !ok { if r.URL.Path == "/" || r.URL.Path == "/index.html" { if glProcessRedirect(w, r) { log.Debug("Auth: redirected to login page by GL-Inet submodule") } else { w.Header().Set("Location", "/login.html") w.WriteHeader(http.StatusFound) } } else { w.WriteHeader(http.StatusForbidden) _, _ = w.Write([]byte("Forbidden")) } authFirst = true } return authFirst }
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/3045da1742ee0e75392de1623900d7d88b08f0b4
internal/dnsfilter/sb_pc.go
func check(c *sbCtx, r Result, u upstream.Upstream) (Result, error) { c.hashToHost = hostnameToHashes(c.host) switch c.getCached() { case -1: return Result{}, nil case 1: return r, nil
<mask> } <mask> } <mask> } <mask> <mask> // Disabling "dupl": the algorithm of SB/PC is similar, but it uses different data <mask> // nolint:dupl <mask> func (d *Dnsfilter) checkSafeBrowsing(host string) (Result, error) { <mask> if log.GetLevel() >= log.DEBUG { <mask> timer := log.StartTimer() <mask> defer timer.LogElapsed("SafeBrowsing lookup for %s", host) <mask> } <mask> <mask> result := Result{} <mask> hashes := hostnameToHashes(host) <mask> <mask> c := &sbCtx{ <mask> host: host, <mask> svc: "SafeBrowsing", <mask> hashToHost: hashes, <mask> cache: gctx.safebrowsingCache, <mask> cacheTime: d.Config.CacheTime, <mask> } <mask> <mask> // check cache <mask> match := c.getCached() <mask> if match < 0 { <mask> return result, nil <mask> } else if match > 0 { <mask> result.IsFiltered = true <mask> result.Reason = FilteredSafeBrowsing <mask> result.Rule = "adguard-malware-shavar" <mask> return result, nil <mask> } <mask> <mask> question := c.getQuestion() <mask> log.Tracef("SafeBrowsing: checking %s: %s", host, question) <mask> </s> Pull request: 2271 handle nolint Merge in DNS/adguard-home from 2271-handle-nolint to master Closes #2271. Squashed commit of the following: commit fde5c8795ac79e1f7d02ba8c8e369b5a724a000e Merge: fc2acd898 642dcd647 Author: Eugene Burkov <[email protected]> Date: Fri Nov 20 17:12:28 2020 +0300 Merge branch 'master' into 2271-handle-nolint commit fc2acd89871de08c39e80ace9e5bb8a7acb7afba Author: Eugene Burkov <[email protected]> Date: Tue Nov 17 11:55:29 2020 +0300 dnsforward: fix test output strings commit c4ebae6ea9c293bad239519c44ca5a6c576bb921 Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 22:43:20 2020 +0300 dnsfilter: make package pass tests commit f2d98c6acabd8977f3b1b361987eaa31eb6eb9ad Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 20:05:00 2020 +0300 querylog: make decoding pass tests commit ab5850d24c50d53b8393f2de448cc340241351d7 Merge: 6ed2066bf 8a9c6e8a0 Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 19:48:31 2020 +0300 Merge branch 'master' into 2271-handle-nolint commit 6ed2066bf567e13dd14cfa16fc7b109b59fa39ef Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 18:13:45 2020 +0300 home: fix tests naming commit af691081fb02b7500a746b16492f01f7f9befe9a Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 12:15:49 2020 +0300 home: impove code quality commit 2914cd3cd23ef2a1964116baab9187d89b377f86 Author: Eugene Burkov <[email protected]> Date: Wed Nov 11 15:46:39 2020 +0300 * querylog: remove useless check commit 9996840650e784ccc76d1f29964560435ba27dc7 Author: Eugene Burkov <[email protected]> Date: Wed Nov 11 13:18:34 2020 +0300 * all: fix noticed defects commit 2b15293e59337f70302fbc0db81ebb26bee0bed2 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 20:15:53 2020 +0300 * stats: remove last nolint directive commit b2e1ddf7b58196a2fdbf879f084edb41ca1aa1eb Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 18:35:41 2020 +0300 * all: remove another nolint directive commit c6fc5cfcc9c95ab9e570a95ab41c3e5c0125e62e Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 18:11:28 2020 +0300 * querylog: remove nolint directive commit 226ddbf2c92f737f085b44a4ddf6daec7b602153 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 16:35:26 2020 +0300 * home: remove nolint directive commit 2ea3086ad41e9003282add7e996ae722d72d878b Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 16:13:57 2020 +0300 * home: reduce cyclomatic complexity of run function commit f479b480c48e0bb832ddef8f57586f56b8a55bab Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 15:35:46 2020 +0300 * home: use crypto/rand instead of math/rand commit a28d4a53e3b930136b036606fc7e78404f1d208b Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 14:11:07 2020 +0300 * dnsforward: remove gocyclo nolint directive commit 64a0a324cc2b20614ceec3ccc6505e960fe526e9 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 11:45:49 2020 +0300 all *: remove some nolint directives Updates #2271. </s> remove result := Result{} hashes := hostnameToHashes(host) c := &sbCtx{ host: host, svc: "Parental", hashToHost: hashes, cache: gctx.parentalCache, cacheTime: d.Config.CacheTime, </s> add ctx := &sbCtx{ host: host, svc: "SafeBrowsing", cache: gctx.safebrowsingCache, cacheTime: d.Config.CacheTime, </s> remove // Disabling "dupl": the algorithm of SB/PC is similar, but it uses different data // nolint:dupl func (d *Dnsfilter) checkParental(host string) (Result, error) { </s> add func (d *Dnsfilter) checkSafeBrowsing(host string) (Result, error) { </s> remove // check cache match := c.getCached() if match < 0 { return result, nil } else if match > 0 { result.IsFiltered = true result.Reason = FilteredParental result.Rule = "parental CATEGORY_BLACKLISTED" return result, nil </s> add res := Result{ IsFiltered: true, Reason: FilteredSafeBrowsing, Rule: "adguard-malware-shavar", </s> remove defer timer.LogElapsed("Parental lookup for %s", host) </s> add defer timer.LogElapsed("SafeBrowsing lookup for %s", host) </s> remove question := c.getQuestion() log.Tracef("Parental: checking %s: %s", host, question) req := dns.Msg{} req.SetQuestion(question, dns.TypeTXT) resp, err := d.parentalUpstream.Exchange(&req) if err != nil { return result, err </s> add func (d *Dnsfilter) checkParental(host string) (Result, error) { if log.GetLevel() >= log.DEBUG { timer := log.StartTimer() defer timer.LogElapsed("Parental lookup for %s", host)
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/3045da1742ee0e75392de1623900d7d88b08f0b4
internal/dnsfilter/sb_pc.go
<mask> return result, nil <mask> } <mask> <mask> question := c.getQuestion() <mask> log.Tracef("SafeBrowsing: checking %s: %s", host, question) <mask> <mask> req := dns.Msg{} <mask> req.SetQuestion(question, dns.TypeTXT) <mask> resp, err := d.safeBrowsingUpstream.Exchange(&req) <mask> if err != nil { </s> Pull request: 2271 handle nolint Merge in DNS/adguard-home from 2271-handle-nolint to master Closes #2271. Squashed commit of the following: commit fde5c8795ac79e1f7d02ba8c8e369b5a724a000e Merge: fc2acd898 642dcd647 Author: Eugene Burkov <[email protected]> Date: Fri Nov 20 17:12:28 2020 +0300 Merge branch 'master' into 2271-handle-nolint commit fc2acd89871de08c39e80ace9e5bb8a7acb7afba Author: Eugene Burkov <[email protected]> Date: Tue Nov 17 11:55:29 2020 +0300 dnsforward: fix test output strings commit c4ebae6ea9c293bad239519c44ca5a6c576bb921 Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 22:43:20 2020 +0300 dnsfilter: make package pass tests commit f2d98c6acabd8977f3b1b361987eaa31eb6eb9ad Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 20:05:00 2020 +0300 querylog: make decoding pass tests commit ab5850d24c50d53b8393f2de448cc340241351d7 Merge: 6ed2066bf 8a9c6e8a0 Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 19:48:31 2020 +0300 Merge branch 'master' into 2271-handle-nolint commit 6ed2066bf567e13dd14cfa16fc7b109b59fa39ef Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 18:13:45 2020 +0300 home: fix tests naming commit af691081fb02b7500a746b16492f01f7f9befe9a Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 12:15:49 2020 +0300 home: impove code quality commit 2914cd3cd23ef2a1964116baab9187d89b377f86 Author: Eugene Burkov <[email protected]> Date: Wed Nov 11 15:46:39 2020 +0300 * querylog: remove useless check commit 9996840650e784ccc76d1f29964560435ba27dc7 Author: Eugene Burkov <[email protected]> Date: Wed Nov 11 13:18:34 2020 +0300 * all: fix noticed defects commit 2b15293e59337f70302fbc0db81ebb26bee0bed2 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 20:15:53 2020 +0300 * stats: remove last nolint directive commit b2e1ddf7b58196a2fdbf879f084edb41ca1aa1eb Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 18:35:41 2020 +0300 * all: remove another nolint directive commit c6fc5cfcc9c95ab9e570a95ab41c3e5c0125e62e Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 18:11:28 2020 +0300 * querylog: remove nolint directive commit 226ddbf2c92f737f085b44a4ddf6daec7b602153 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 16:35:26 2020 +0300 * home: remove nolint directive commit 2ea3086ad41e9003282add7e996ae722d72d878b Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 16:13:57 2020 +0300 * home: reduce cyclomatic complexity of run function commit f479b480c48e0bb832ddef8f57586f56b8a55bab Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 15:35:46 2020 +0300 * home: use crypto/rand instead of math/rand commit a28d4a53e3b930136b036606fc7e78404f1d208b Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 14:11:07 2020 +0300 * dnsforward: remove gocyclo nolint directive commit 64a0a324cc2b20614ceec3ccc6505e960fe526e9 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 11:45:49 2020 +0300 all *: remove some nolint directives Updates #2271. </s> remove req := dns.Msg{} req.SetQuestion(question, dns.TypeTXT) resp, err := d.safeBrowsingUpstream.Exchange(&req) </s> add log.Tracef("%s: checking %s: %s", c.svc, c.host, question) req := (&dns.Msg{}).SetQuestion(question, dns.TypeTXT) resp, err := u.Exchange(req) </s> remove question := c.getQuestion() log.Tracef("Parental: checking %s: %s", host, question) req := dns.Msg{} req.SetQuestion(question, dns.TypeTXT) resp, err := d.parentalUpstream.Exchange(&req) if err != nil { return result, err </s> add func (d *Dnsfilter) checkParental(host string) (Result, error) { if log.GetLevel() >= log.DEBUG { timer := log.StartTimer() defer timer.LogElapsed("Parental lookup for %s", host) </s> remove return result, err </s> add return Result{}, err </s> remove // check cache match := c.getCached() if match < 0 { return result, nil } else if match > 0 { result.IsFiltered = true result.Reason = FilteredParental result.Rule = "parental CATEGORY_BLACKLISTED" return result, nil </s> add res := Result{ IsFiltered: true, Reason: FilteredSafeBrowsing, Rule: "adguard-malware-shavar", </s> remove // Disabling "dupl": the algorithm of SB/PC is similar, but it uses different data // nolint:dupl func (d *Dnsfilter) checkSafeBrowsing(host string) (Result, error) { if log.GetLevel() >= log.DEBUG { timer := log.StartTimer() defer timer.LogElapsed("SafeBrowsing lookup for %s", host) } result := Result{} hashes := hostnameToHashes(host) c := &sbCtx{ host: host, svc: "SafeBrowsing", hashToHost: hashes, cache: gctx.safebrowsingCache, cacheTime: d.Config.CacheTime, } // check cache match := c.getCached() if match < 0 { return result, nil } else if match > 0 { result.IsFiltered = true result.Reason = FilteredSafeBrowsing result.Rule = "adguard-malware-shavar" return result, nil </s> add func check(c *sbCtx, r Result, u upstream.Upstream) (Result, error) { c.hashToHost = hostnameToHashes(c.host) switch c.getCached() { case -1: return Result{}, nil case 1: return r, nil
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/3045da1742ee0e75392de1623900d7d88b08f0b4
internal/dnsfilter/sb_pc.go
log.Tracef("%s: checking %s: %s", c.svc, c.host, question) req := (&dns.Msg{}).SetQuestion(question, dns.TypeTXT) resp, err := u.Exchange(req)
<mask> <mask> question := c.getQuestion() <mask> log.Tracef("SafeBrowsing: checking %s: %s", host, question) <mask> <mask> req := dns.Msg{} <mask> req.SetQuestion(question, dns.TypeTXT) <mask> resp, err := d.safeBrowsingUpstream.Exchange(&req) <mask> if err != nil { <mask> return result, err <mask> } <mask> <mask> matched, receivedHashes := c.processTXT(resp) </s> Pull request: 2271 handle nolint Merge in DNS/adguard-home from 2271-handle-nolint to master Closes #2271. Squashed commit of the following: commit fde5c8795ac79e1f7d02ba8c8e369b5a724a000e Merge: fc2acd898 642dcd647 Author: Eugene Burkov <[email protected]> Date: Fri Nov 20 17:12:28 2020 +0300 Merge branch 'master' into 2271-handle-nolint commit fc2acd89871de08c39e80ace9e5bb8a7acb7afba Author: Eugene Burkov <[email protected]> Date: Tue Nov 17 11:55:29 2020 +0300 dnsforward: fix test output strings commit c4ebae6ea9c293bad239519c44ca5a6c576bb921 Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 22:43:20 2020 +0300 dnsfilter: make package pass tests commit f2d98c6acabd8977f3b1b361987eaa31eb6eb9ad Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 20:05:00 2020 +0300 querylog: make decoding pass tests commit ab5850d24c50d53b8393f2de448cc340241351d7 Merge: 6ed2066bf 8a9c6e8a0 Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 19:48:31 2020 +0300 Merge branch 'master' into 2271-handle-nolint commit 6ed2066bf567e13dd14cfa16fc7b109b59fa39ef Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 18:13:45 2020 +0300 home: fix tests naming commit af691081fb02b7500a746b16492f01f7f9befe9a Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 12:15:49 2020 +0300 home: impove code quality commit 2914cd3cd23ef2a1964116baab9187d89b377f86 Author: Eugene Burkov <[email protected]> Date: Wed Nov 11 15:46:39 2020 +0300 * querylog: remove useless check commit 9996840650e784ccc76d1f29964560435ba27dc7 Author: Eugene Burkov <[email protected]> Date: Wed Nov 11 13:18:34 2020 +0300 * all: fix noticed defects commit 2b15293e59337f70302fbc0db81ebb26bee0bed2 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 20:15:53 2020 +0300 * stats: remove last nolint directive commit b2e1ddf7b58196a2fdbf879f084edb41ca1aa1eb Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 18:35:41 2020 +0300 * all: remove another nolint directive commit c6fc5cfcc9c95ab9e570a95ab41c3e5c0125e62e Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 18:11:28 2020 +0300 * querylog: remove nolint directive commit 226ddbf2c92f737f085b44a4ddf6daec7b602153 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 16:35:26 2020 +0300 * home: remove nolint directive commit 2ea3086ad41e9003282add7e996ae722d72d878b Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 16:13:57 2020 +0300 * home: reduce cyclomatic complexity of run function commit f479b480c48e0bb832ddef8f57586f56b8a55bab Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 15:35:46 2020 +0300 * home: use crypto/rand instead of math/rand commit a28d4a53e3b930136b036606fc7e78404f1d208b Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 14:11:07 2020 +0300 * dnsforward: remove gocyclo nolint directive commit 64a0a324cc2b20614ceec3ccc6505e960fe526e9 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 11:45:49 2020 +0300 all *: remove some nolint directives Updates #2271. </s> remove log.Tracef("SafeBrowsing: checking %s: %s", host, question) </s> add </s> remove question := c.getQuestion() log.Tracef("Parental: checking %s: %s", host, question) req := dns.Msg{} req.SetQuestion(question, dns.TypeTXT) resp, err := d.parentalUpstream.Exchange(&req) if err != nil { return result, err </s> add func (d *Dnsfilter) checkParental(host string) (Result, error) { if log.GetLevel() >= log.DEBUG { timer := log.StartTimer() defer timer.LogElapsed("Parental lookup for %s", host) </s> remove return result, err </s> add return Result{}, err </s> remove matched, receivedHashes := c.processTXT(resp) if matched { result.IsFiltered = true result.Reason = FilteredParental result.Rule = "parental CATEGORY_BLACKLISTED" </s> add ctx := &sbCtx{ host: host, svc: "Parental", cache: gctx.parentalCache, cacheTime: d.Config.CacheTime, </s> remove // check cache match := c.getCached() if match < 0 { return result, nil } else if match > 0 { result.IsFiltered = true result.Reason = FilteredParental result.Rule = "parental CATEGORY_BLACKLISTED" return result, nil </s> add res := Result{ IsFiltered: true, Reason: FilteredSafeBrowsing, Rule: "adguard-malware-shavar",
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/3045da1742ee0e75392de1623900d7d88b08f0b4
internal/dnsfilter/sb_pc.go
return Result{}, err
<mask> req := dns.Msg{} <mask> req.SetQuestion(question, dns.TypeTXT) <mask> resp, err := d.safeBrowsingUpstream.Exchange(&req) <mask> if err != nil { <mask> return result, err <mask> } <mask> <mask> matched, receivedHashes := c.processTXT(resp) <mask> if matched { <mask> result.IsFiltered = true </s> Pull request: 2271 handle nolint Merge in DNS/adguard-home from 2271-handle-nolint to master Closes #2271. Squashed commit of the following: commit fde5c8795ac79e1f7d02ba8c8e369b5a724a000e Merge: fc2acd898 642dcd647 Author: Eugene Burkov <[email protected]> Date: Fri Nov 20 17:12:28 2020 +0300 Merge branch 'master' into 2271-handle-nolint commit fc2acd89871de08c39e80ace9e5bb8a7acb7afba Author: Eugene Burkov <[email protected]> Date: Tue Nov 17 11:55:29 2020 +0300 dnsforward: fix test output strings commit c4ebae6ea9c293bad239519c44ca5a6c576bb921 Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 22:43:20 2020 +0300 dnsfilter: make package pass tests commit f2d98c6acabd8977f3b1b361987eaa31eb6eb9ad Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 20:05:00 2020 +0300 querylog: make decoding pass tests commit ab5850d24c50d53b8393f2de448cc340241351d7 Merge: 6ed2066bf 8a9c6e8a0 Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 19:48:31 2020 +0300 Merge branch 'master' into 2271-handle-nolint commit 6ed2066bf567e13dd14cfa16fc7b109b59fa39ef Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 18:13:45 2020 +0300 home: fix tests naming commit af691081fb02b7500a746b16492f01f7f9befe9a Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 12:15:49 2020 +0300 home: impove code quality commit 2914cd3cd23ef2a1964116baab9187d89b377f86 Author: Eugene Burkov <[email protected]> Date: Wed Nov 11 15:46:39 2020 +0300 * querylog: remove useless check commit 9996840650e784ccc76d1f29964560435ba27dc7 Author: Eugene Burkov <[email protected]> Date: Wed Nov 11 13:18:34 2020 +0300 * all: fix noticed defects commit 2b15293e59337f70302fbc0db81ebb26bee0bed2 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 20:15:53 2020 +0300 * stats: remove last nolint directive commit b2e1ddf7b58196a2fdbf879f084edb41ca1aa1eb Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 18:35:41 2020 +0300 * all: remove another nolint directive commit c6fc5cfcc9c95ab9e570a95ab41c3e5c0125e62e Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 18:11:28 2020 +0300 * querylog: remove nolint directive commit 226ddbf2c92f737f085b44a4ddf6daec7b602153 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 16:35:26 2020 +0300 * home: remove nolint directive commit 2ea3086ad41e9003282add7e996ae722d72d878b Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 16:13:57 2020 +0300 * home: reduce cyclomatic complexity of run function commit f479b480c48e0bb832ddef8f57586f56b8a55bab Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 15:35:46 2020 +0300 * home: use crypto/rand instead of math/rand commit a28d4a53e3b930136b036606fc7e78404f1d208b Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 14:11:07 2020 +0300 * dnsforward: remove gocyclo nolint directive commit 64a0a324cc2b20614ceec3ccc6505e960fe526e9 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 11:45:49 2020 +0300 all *: remove some nolint directives Updates #2271. </s> remove req := dns.Msg{} req.SetQuestion(question, dns.TypeTXT) resp, err := d.safeBrowsingUpstream.Exchange(&req) </s> add log.Tracef("%s: checking %s: %s", c.svc, c.host, question) req := (&dns.Msg{}).SetQuestion(question, dns.TypeTXT) resp, err := u.Exchange(req) </s> remove question := c.getQuestion() log.Tracef("Parental: checking %s: %s", host, question) req := dns.Msg{} req.SetQuestion(question, dns.TypeTXT) resp, err := d.parentalUpstream.Exchange(&req) if err != nil { return result, err </s> add func (d *Dnsfilter) checkParental(host string) (Result, error) { if log.GetLevel() >= log.DEBUG { timer := log.StartTimer() defer timer.LogElapsed("Parental lookup for %s", host) </s> remove log.Tracef("SafeBrowsing: checking %s: %s", host, question) </s> add </s> remove matched, receivedHashes := c.processTXT(resp) if matched { result.IsFiltered = true result.Reason = FilteredParental result.Rule = "parental CATEGORY_BLACKLISTED" </s> add ctx := &sbCtx{ host: host, svc: "Parental", cache: gctx.parentalCache, cacheTime: d.Config.CacheTime, </s> remove result.IsFiltered = true result.Reason = FilteredSafeBrowsing result.Rule = "adguard-malware-shavar" </s> add return r, nil
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/3045da1742ee0e75392de1623900d7d88b08f0b4
internal/dnsfilter/sb_pc.go
c.storeCache(receivedHashes)
<mask> <mask> matched, receivedHashes := c.processTXT(resp) <mask> if matched { <mask> return r, nil <mask> } <mask> <mask> return Result{}, nil </s> Pull request: 2271 handle nolint Merge in DNS/adguard-home from 2271-handle-nolint to master Closes #2271. Squashed commit of the following: commit fde5c8795ac79e1f7d02ba8c8e369b5a724a000e Merge: fc2acd898 642dcd647 Author: Eugene Burkov <[email protected]> Date: Fri Nov 20 17:12:28 2020 +0300 Merge branch 'master' into 2271-handle-nolint commit fc2acd89871de08c39e80ace9e5bb8a7acb7afba Author: Eugene Burkov <[email protected]> Date: Tue Nov 17 11:55:29 2020 +0300 dnsforward: fix test output strings commit c4ebae6ea9c293bad239519c44ca5a6c576bb921 Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 22:43:20 2020 +0300 dnsfilter: make package pass tests commit f2d98c6acabd8977f3b1b361987eaa31eb6eb9ad Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 20:05:00 2020 +0300 querylog: make decoding pass tests commit ab5850d24c50d53b8393f2de448cc340241351d7 Merge: 6ed2066bf 8a9c6e8a0 Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 19:48:31 2020 +0300 Merge branch 'master' into 2271-handle-nolint commit 6ed2066bf567e13dd14cfa16fc7b109b59fa39ef Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 18:13:45 2020 +0300 home: fix tests naming commit af691081fb02b7500a746b16492f01f7f9befe9a Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 12:15:49 2020 +0300 home: impove code quality commit 2914cd3cd23ef2a1964116baab9187d89b377f86 Author: Eugene Burkov <[email protected]> Date: Wed Nov 11 15:46:39 2020 +0300 * querylog: remove useless check commit 9996840650e784ccc76d1f29964560435ba27dc7 Author: Eugene Burkov <[email protected]> Date: Wed Nov 11 13:18:34 2020 +0300 * all: fix noticed defects commit 2b15293e59337f70302fbc0db81ebb26bee0bed2 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 20:15:53 2020 +0300 * stats: remove last nolint directive commit b2e1ddf7b58196a2fdbf879f084edb41ca1aa1eb Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 18:35:41 2020 +0300 * all: remove another nolint directive commit c6fc5cfcc9c95ab9e570a95ab41c3e5c0125e62e Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 18:11:28 2020 +0300 * querylog: remove nolint directive commit 226ddbf2c92f737f085b44a4ddf6daec7b602153 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 16:35:26 2020 +0300 * home: remove nolint directive commit 2ea3086ad41e9003282add7e996ae722d72d878b Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 16:13:57 2020 +0300 * home: reduce cyclomatic complexity of run function commit f479b480c48e0bb832ddef8f57586f56b8a55bab Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 15:35:46 2020 +0300 * home: use crypto/rand instead of math/rand commit a28d4a53e3b930136b036606fc7e78404f1d208b Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 14:11:07 2020 +0300 * dnsforward: remove gocyclo nolint directive commit 64a0a324cc2b20614ceec3ccc6505e960fe526e9 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 11:45:49 2020 +0300 all *: remove some nolint directives Updates #2271. </s> remove result.IsFiltered = true result.Reason = FilteredSafeBrowsing result.Rule = "adguard-malware-shavar" </s> add return r, nil </s> remove return result, err </s> add return Result{}, err </s> remove matched, receivedHashes := c.processTXT(resp) if matched { result.IsFiltered = true result.Reason = FilteredParental result.Rule = "parental CATEGORY_BLACKLISTED" </s> add ctx := &sbCtx{ host: host, svc: "Parental", cache: gctx.parentalCache, cacheTime: d.Config.CacheTime, </s> remove question := c.getQuestion() log.Tracef("Parental: checking %s: %s", host, question) req := dns.Msg{} req.SetQuestion(question, dns.TypeTXT) resp, err := d.parentalUpstream.Exchange(&req) if err != nil { return result, err </s> add func (d *Dnsfilter) checkParental(host string) (Result, error) { if log.GetLevel() >= log.DEBUG { timer := log.StartTimer() defer timer.LogElapsed("Parental lookup for %s", host) </s> remove req := dns.Msg{} req.SetQuestion(question, dns.TypeTXT) resp, err := d.safeBrowsingUpstream.Exchange(&req) </s> add log.Tracef("%s: checking %s: %s", c.svc, c.host, question) req := (&dns.Msg{}).SetQuestion(question, dns.TypeTXT) resp, err := u.Exchange(req)
[ "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/3045da1742ee0e75392de1623900d7d88b08f0b4
internal/dnsfilter/sb_pc.go
return r, nil
<mask> } <mask> <mask> matched, receivedHashes := c.processTXT(resp) <mask> if matched { <mask> result.IsFiltered = true <mask> result.Reason = FilteredSafeBrowsing <mask> result.Rule = "adguard-malware-shavar" <mask> } <mask> c.storeCache(receivedHashes) <mask> <mask> return result, nil <mask> } </s> Pull request: 2271 handle nolint Merge in DNS/adguard-home from 2271-handle-nolint to master Closes #2271. Squashed commit of the following: commit fde5c8795ac79e1f7d02ba8c8e369b5a724a000e Merge: fc2acd898 642dcd647 Author: Eugene Burkov <[email protected]> Date: Fri Nov 20 17:12:28 2020 +0300 Merge branch 'master' into 2271-handle-nolint commit fc2acd89871de08c39e80ace9e5bb8a7acb7afba Author: Eugene Burkov <[email protected]> Date: Tue Nov 17 11:55:29 2020 +0300 dnsforward: fix test output strings commit c4ebae6ea9c293bad239519c44ca5a6c576bb921 Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 22:43:20 2020 +0300 dnsfilter: make package pass tests commit f2d98c6acabd8977f3b1b361987eaa31eb6eb9ad Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 20:05:00 2020 +0300 querylog: make decoding pass tests commit ab5850d24c50d53b8393f2de448cc340241351d7 Merge: 6ed2066bf 8a9c6e8a0 Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 19:48:31 2020 +0300 Merge branch 'master' into 2271-handle-nolint commit 6ed2066bf567e13dd14cfa16fc7b109b59fa39ef Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 18:13:45 2020 +0300 home: fix tests naming commit af691081fb02b7500a746b16492f01f7f9befe9a Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 12:15:49 2020 +0300 home: impove code quality commit 2914cd3cd23ef2a1964116baab9187d89b377f86 Author: Eugene Burkov <[email protected]> Date: Wed Nov 11 15:46:39 2020 +0300 * querylog: remove useless check commit 9996840650e784ccc76d1f29964560435ba27dc7 Author: Eugene Burkov <[email protected]> Date: Wed Nov 11 13:18:34 2020 +0300 * all: fix noticed defects commit 2b15293e59337f70302fbc0db81ebb26bee0bed2 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 20:15:53 2020 +0300 * stats: remove last nolint directive commit b2e1ddf7b58196a2fdbf879f084edb41ca1aa1eb Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 18:35:41 2020 +0300 * all: remove another nolint directive commit c6fc5cfcc9c95ab9e570a95ab41c3e5c0125e62e Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 18:11:28 2020 +0300 * querylog: remove nolint directive commit 226ddbf2c92f737f085b44a4ddf6daec7b602153 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 16:35:26 2020 +0300 * home: remove nolint directive commit 2ea3086ad41e9003282add7e996ae722d72d878b Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 16:13:57 2020 +0300 * home: reduce cyclomatic complexity of run function commit f479b480c48e0bb832ddef8f57586f56b8a55bab Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 15:35:46 2020 +0300 * home: use crypto/rand instead of math/rand commit a28d4a53e3b930136b036606fc7e78404f1d208b Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 14:11:07 2020 +0300 * dnsforward: remove gocyclo nolint directive commit 64a0a324cc2b20614ceec3ccc6505e960fe526e9 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 11:45:49 2020 +0300 all *: remove some nolint directives Updates #2271. </s> remove matched, receivedHashes := c.processTXT(resp) if matched { result.IsFiltered = true result.Reason = FilteredParental result.Rule = "parental CATEGORY_BLACKLISTED" </s> add ctx := &sbCtx{ host: host, svc: "Parental", cache: gctx.parentalCache, cacheTime: d.Config.CacheTime, </s> remove c.storeCache(receivedHashes) </s> add </s> remove return result, err </s> add return Result{}, err </s> remove question := c.getQuestion() log.Tracef("Parental: checking %s: %s", host, question) req := dns.Msg{} req.SetQuestion(question, dns.TypeTXT) resp, err := d.parentalUpstream.Exchange(&req) if err != nil { return result, err </s> add func (d *Dnsfilter) checkParental(host string) (Result, error) { if log.GetLevel() >= log.DEBUG { timer := log.StartTimer() defer timer.LogElapsed("Parental lookup for %s", host)
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/3045da1742ee0e75392de1623900d7d88b08f0b4
internal/dnsfilter/sb_pc.go
<mask> result.IsFiltered = true <mask> result.Reason = FilteredSafeBrowsing <mask> result.Rule = "adguard-malware-shavar" <mask> } <mask> c.storeCache(receivedHashes) <mask> <mask> return result, nil <mask> } <mask> <mask> // Disabling "dupl": the algorithm of SB/PC is similar, but it uses different data </s> Pull request: 2271 handle nolint Merge in DNS/adguard-home from 2271-handle-nolint to master Closes #2271. Squashed commit of the following: commit fde5c8795ac79e1f7d02ba8c8e369b5a724a000e Merge: fc2acd898 642dcd647 Author: Eugene Burkov <[email protected]> Date: Fri Nov 20 17:12:28 2020 +0300 Merge branch 'master' into 2271-handle-nolint commit fc2acd89871de08c39e80ace9e5bb8a7acb7afba Author: Eugene Burkov <[email protected]> Date: Tue Nov 17 11:55:29 2020 +0300 dnsforward: fix test output strings commit c4ebae6ea9c293bad239519c44ca5a6c576bb921 Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 22:43:20 2020 +0300 dnsfilter: make package pass tests commit f2d98c6acabd8977f3b1b361987eaa31eb6eb9ad Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 20:05:00 2020 +0300 querylog: make decoding pass tests commit ab5850d24c50d53b8393f2de448cc340241351d7 Merge: 6ed2066bf 8a9c6e8a0 Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 19:48:31 2020 +0300 Merge branch 'master' into 2271-handle-nolint commit 6ed2066bf567e13dd14cfa16fc7b109b59fa39ef Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 18:13:45 2020 +0300 home: fix tests naming commit af691081fb02b7500a746b16492f01f7f9befe9a Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 12:15:49 2020 +0300 home: impove code quality commit 2914cd3cd23ef2a1964116baab9187d89b377f86 Author: Eugene Burkov <[email protected]> Date: Wed Nov 11 15:46:39 2020 +0300 * querylog: remove useless check commit 9996840650e784ccc76d1f29964560435ba27dc7 Author: Eugene Burkov <[email protected]> Date: Wed Nov 11 13:18:34 2020 +0300 * all: fix noticed defects commit 2b15293e59337f70302fbc0db81ebb26bee0bed2 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 20:15:53 2020 +0300 * stats: remove last nolint directive commit b2e1ddf7b58196a2fdbf879f084edb41ca1aa1eb Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 18:35:41 2020 +0300 * all: remove another nolint directive commit c6fc5cfcc9c95ab9e570a95ab41c3e5c0125e62e Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 18:11:28 2020 +0300 * querylog: remove nolint directive commit 226ddbf2c92f737f085b44a4ddf6daec7b602153 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 16:35:26 2020 +0300 * home: remove nolint directive commit 2ea3086ad41e9003282add7e996ae722d72d878b Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 16:13:57 2020 +0300 * home: reduce cyclomatic complexity of run function commit f479b480c48e0bb832ddef8f57586f56b8a55bab Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 15:35:46 2020 +0300 * home: use crypto/rand instead of math/rand commit a28d4a53e3b930136b036606fc7e78404f1d208b Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 14:11:07 2020 +0300 * dnsforward: remove gocyclo nolint directive commit 64a0a324cc2b20614ceec3ccc6505e960fe526e9 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 11:45:49 2020 +0300 all *: remove some nolint directives Updates #2271. </s> remove return result, nil </s> add return Result{}, nil </s> remove // Disabling "dupl": the algorithm of SB/PC is similar, but it uses different data // nolint:dupl func (d *Dnsfilter) checkParental(host string) (Result, error) { </s> add func (d *Dnsfilter) checkSafeBrowsing(host string) (Result, error) { </s> remove // Disabling "dupl": the algorithm of SB/PC is similar, but it uses different data // nolint:dupl func (d *Dnsfilter) checkSafeBrowsing(host string) (Result, error) { if log.GetLevel() >= log.DEBUG { timer := log.StartTimer() defer timer.LogElapsed("SafeBrowsing lookup for %s", host) } result := Result{} hashes := hostnameToHashes(host) c := &sbCtx{ host: host, svc: "SafeBrowsing", hashToHost: hashes, cache: gctx.safebrowsingCache, cacheTime: d.Config.CacheTime, } // check cache match := c.getCached() if match < 0 { return result, nil } else if match > 0 { result.IsFiltered = true result.Reason = FilteredSafeBrowsing result.Rule = "adguard-malware-shavar" return result, nil </s> add func check(c *sbCtx, r Result, u upstream.Upstream) (Result, error) { c.hashToHost = hostnameToHashes(c.host) switch c.getCached() { case -1: return Result{}, nil case 1: return r, nil </s> remove result.IsFiltered = true result.Reason = FilteredSafeBrowsing result.Rule = "adguard-malware-shavar" </s> add return r, nil </s> remove matched, receivedHashes := c.processTXT(resp) if matched { result.IsFiltered = true result.Reason = FilteredParental result.Rule = "parental CATEGORY_BLACKLISTED" </s> add ctx := &sbCtx{ host: host, svc: "Parental", cache: gctx.parentalCache, cacheTime: d.Config.CacheTime,
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/3045da1742ee0e75392de1623900d7d88b08f0b4
internal/dnsfilter/sb_pc.go
return Result{}, nil
<mask> result.Rule = "adguard-malware-shavar" <mask> } <mask> c.storeCache(receivedHashes) <mask> <mask> return result, nil <mask> } <mask> <mask> // Disabling "dupl": the algorithm of SB/PC is similar, but it uses different data <mask> // nolint:dupl <mask> func (d *Dnsfilter) checkParental(host string) (Result, error) { </s> Pull request: 2271 handle nolint Merge in DNS/adguard-home from 2271-handle-nolint to master Closes #2271. Squashed commit of the following: commit fde5c8795ac79e1f7d02ba8c8e369b5a724a000e Merge: fc2acd898 642dcd647 Author: Eugene Burkov <[email protected]> Date: Fri Nov 20 17:12:28 2020 +0300 Merge branch 'master' into 2271-handle-nolint commit fc2acd89871de08c39e80ace9e5bb8a7acb7afba Author: Eugene Burkov <[email protected]> Date: Tue Nov 17 11:55:29 2020 +0300 dnsforward: fix test output strings commit c4ebae6ea9c293bad239519c44ca5a6c576bb921 Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 22:43:20 2020 +0300 dnsfilter: make package pass tests commit f2d98c6acabd8977f3b1b361987eaa31eb6eb9ad Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 20:05:00 2020 +0300 querylog: make decoding pass tests commit ab5850d24c50d53b8393f2de448cc340241351d7 Merge: 6ed2066bf 8a9c6e8a0 Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 19:48:31 2020 +0300 Merge branch 'master' into 2271-handle-nolint commit 6ed2066bf567e13dd14cfa16fc7b109b59fa39ef Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 18:13:45 2020 +0300 home: fix tests naming commit af691081fb02b7500a746b16492f01f7f9befe9a Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 12:15:49 2020 +0300 home: impove code quality commit 2914cd3cd23ef2a1964116baab9187d89b377f86 Author: Eugene Burkov <[email protected]> Date: Wed Nov 11 15:46:39 2020 +0300 * querylog: remove useless check commit 9996840650e784ccc76d1f29964560435ba27dc7 Author: Eugene Burkov <[email protected]> Date: Wed Nov 11 13:18:34 2020 +0300 * all: fix noticed defects commit 2b15293e59337f70302fbc0db81ebb26bee0bed2 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 20:15:53 2020 +0300 * stats: remove last nolint directive commit b2e1ddf7b58196a2fdbf879f084edb41ca1aa1eb Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 18:35:41 2020 +0300 * all: remove another nolint directive commit c6fc5cfcc9c95ab9e570a95ab41c3e5c0125e62e Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 18:11:28 2020 +0300 * querylog: remove nolint directive commit 226ddbf2c92f737f085b44a4ddf6daec7b602153 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 16:35:26 2020 +0300 * home: remove nolint directive commit 2ea3086ad41e9003282add7e996ae722d72d878b Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 16:13:57 2020 +0300 * home: reduce cyclomatic complexity of run function commit f479b480c48e0bb832ddef8f57586f56b8a55bab Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 15:35:46 2020 +0300 * home: use crypto/rand instead of math/rand commit a28d4a53e3b930136b036606fc7e78404f1d208b Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 14:11:07 2020 +0300 * dnsforward: remove gocyclo nolint directive commit 64a0a324cc2b20614ceec3ccc6505e960fe526e9 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 11:45:49 2020 +0300 all *: remove some nolint directives Updates #2271. </s> remove // Disabling "dupl": the algorithm of SB/PC is similar, but it uses different data // nolint:dupl func (d *Dnsfilter) checkParental(host string) (Result, error) { </s> add func (d *Dnsfilter) checkSafeBrowsing(host string) (Result, error) { </s> remove c.storeCache(receivedHashes) </s> add </s> remove // Disabling "dupl": the algorithm of SB/PC is similar, but it uses different data // nolint:dupl func (d *Dnsfilter) checkSafeBrowsing(host string) (Result, error) { if log.GetLevel() >= log.DEBUG { timer := log.StartTimer() defer timer.LogElapsed("SafeBrowsing lookup for %s", host) } result := Result{} hashes := hostnameToHashes(host) c := &sbCtx{ host: host, svc: "SafeBrowsing", hashToHost: hashes, cache: gctx.safebrowsingCache, cacheTime: d.Config.CacheTime, } // check cache match := c.getCached() if match < 0 { return result, nil } else if match > 0 { result.IsFiltered = true result.Reason = FilteredSafeBrowsing result.Rule = "adguard-malware-shavar" return result, nil </s> add func check(c *sbCtx, r Result, u upstream.Upstream) (Result, error) { c.hashToHost = hostnameToHashes(c.host) switch c.getCached() { case -1: return Result{}, nil case 1: return r, nil </s> remove defer timer.LogElapsed("Parental lookup for %s", host) </s> add defer timer.LogElapsed("SafeBrowsing lookup for %s", host) </s> remove question := c.getQuestion() log.Tracef("Parental: checking %s: %s", host, question) req := dns.Msg{} req.SetQuestion(question, dns.TypeTXT) resp, err := d.parentalUpstream.Exchange(&req) if err != nil { return result, err </s> add func (d *Dnsfilter) checkParental(host string) (Result, error) { if log.GetLevel() >= log.DEBUG { timer := log.StartTimer() defer timer.LogElapsed("Parental lookup for %s", host)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/3045da1742ee0e75392de1623900d7d88b08f0b4
internal/dnsfilter/sb_pc.go
func (d *Dnsfilter) checkSafeBrowsing(host string) (Result, error) {
<mask> <mask> return result, nil <mask> } <mask> <mask> // Disabling "dupl": the algorithm of SB/PC is similar, but it uses different data <mask> // nolint:dupl <mask> func (d *Dnsfilter) checkParental(host string) (Result, error) { <mask> if log.GetLevel() >= log.DEBUG { <mask> timer := log.StartTimer() <mask> defer timer.LogElapsed("Parental lookup for %s", host) <mask> } <mask> </s> Pull request: 2271 handle nolint Merge in DNS/adguard-home from 2271-handle-nolint to master Closes #2271. Squashed commit of the following: commit fde5c8795ac79e1f7d02ba8c8e369b5a724a000e Merge: fc2acd898 642dcd647 Author: Eugene Burkov <[email protected]> Date: Fri Nov 20 17:12:28 2020 +0300 Merge branch 'master' into 2271-handle-nolint commit fc2acd89871de08c39e80ace9e5bb8a7acb7afba Author: Eugene Burkov <[email protected]> Date: Tue Nov 17 11:55:29 2020 +0300 dnsforward: fix test output strings commit c4ebae6ea9c293bad239519c44ca5a6c576bb921 Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 22:43:20 2020 +0300 dnsfilter: make package pass tests commit f2d98c6acabd8977f3b1b361987eaa31eb6eb9ad Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 20:05:00 2020 +0300 querylog: make decoding pass tests commit ab5850d24c50d53b8393f2de448cc340241351d7 Merge: 6ed2066bf 8a9c6e8a0 Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 19:48:31 2020 +0300 Merge branch 'master' into 2271-handle-nolint commit 6ed2066bf567e13dd14cfa16fc7b109b59fa39ef Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 18:13:45 2020 +0300 home: fix tests naming commit af691081fb02b7500a746b16492f01f7f9befe9a Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 12:15:49 2020 +0300 home: impove code quality commit 2914cd3cd23ef2a1964116baab9187d89b377f86 Author: Eugene Burkov <[email protected]> Date: Wed Nov 11 15:46:39 2020 +0300 * querylog: remove useless check commit 9996840650e784ccc76d1f29964560435ba27dc7 Author: Eugene Burkov <[email protected]> Date: Wed Nov 11 13:18:34 2020 +0300 * all: fix noticed defects commit 2b15293e59337f70302fbc0db81ebb26bee0bed2 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 20:15:53 2020 +0300 * stats: remove last nolint directive commit b2e1ddf7b58196a2fdbf879f084edb41ca1aa1eb Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 18:35:41 2020 +0300 * all: remove another nolint directive commit c6fc5cfcc9c95ab9e570a95ab41c3e5c0125e62e Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 18:11:28 2020 +0300 * querylog: remove nolint directive commit 226ddbf2c92f737f085b44a4ddf6daec7b602153 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 16:35:26 2020 +0300 * home: remove nolint directive commit 2ea3086ad41e9003282add7e996ae722d72d878b Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 16:13:57 2020 +0300 * home: reduce cyclomatic complexity of run function commit f479b480c48e0bb832ddef8f57586f56b8a55bab Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 15:35:46 2020 +0300 * home: use crypto/rand instead of math/rand commit a28d4a53e3b930136b036606fc7e78404f1d208b Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 14:11:07 2020 +0300 * dnsforward: remove gocyclo nolint directive commit 64a0a324cc2b20614ceec3ccc6505e960fe526e9 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 11:45:49 2020 +0300 all *: remove some nolint directives Updates #2271. </s> remove return result, nil </s> add return Result{}, nil </s> remove defer timer.LogElapsed("Parental lookup for %s", host) </s> add defer timer.LogElapsed("SafeBrowsing lookup for %s", host) </s> remove // Disabling "dupl": the algorithm of SB/PC is similar, but it uses different data // nolint:dupl func (d *Dnsfilter) checkSafeBrowsing(host string) (Result, error) { if log.GetLevel() >= log.DEBUG { timer := log.StartTimer() defer timer.LogElapsed("SafeBrowsing lookup for %s", host) } result := Result{} hashes := hostnameToHashes(host) c := &sbCtx{ host: host, svc: "SafeBrowsing", hashToHost: hashes, cache: gctx.safebrowsingCache, cacheTime: d.Config.CacheTime, } // check cache match := c.getCached() if match < 0 { return result, nil } else if match > 0 { result.IsFiltered = true result.Reason = FilteredSafeBrowsing result.Rule = "adguard-malware-shavar" return result, nil </s> add func check(c *sbCtx, r Result, u upstream.Upstream) (Result, error) { c.hashToHost = hostnameToHashes(c.host) switch c.getCached() { case -1: return Result{}, nil case 1: return r, nil </s> remove c.storeCache(receivedHashes) </s> add
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/3045da1742ee0e75392de1623900d7d88b08f0b4
internal/dnsfilter/sb_pc.go
defer timer.LogElapsed("SafeBrowsing lookup for %s", host)
<mask> // nolint:dupl <mask> func (d *Dnsfilter) checkParental(host string) (Result, error) { <mask> if log.GetLevel() >= log.DEBUG { <mask> timer := log.StartTimer() <mask> defer timer.LogElapsed("Parental lookup for %s", host) <mask> } <mask> <mask> result := Result{} <mask> hashes := hostnameToHashes(host) <mask> </s> Pull request: 2271 handle nolint Merge in DNS/adguard-home from 2271-handle-nolint to master Closes #2271. Squashed commit of the following: commit fde5c8795ac79e1f7d02ba8c8e369b5a724a000e Merge: fc2acd898 642dcd647 Author: Eugene Burkov <[email protected]> Date: Fri Nov 20 17:12:28 2020 +0300 Merge branch 'master' into 2271-handle-nolint commit fc2acd89871de08c39e80ace9e5bb8a7acb7afba Author: Eugene Burkov <[email protected]> Date: Tue Nov 17 11:55:29 2020 +0300 dnsforward: fix test output strings commit c4ebae6ea9c293bad239519c44ca5a6c576bb921 Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 22:43:20 2020 +0300 dnsfilter: make package pass tests commit f2d98c6acabd8977f3b1b361987eaa31eb6eb9ad Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 20:05:00 2020 +0300 querylog: make decoding pass tests commit ab5850d24c50d53b8393f2de448cc340241351d7 Merge: 6ed2066bf 8a9c6e8a0 Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 19:48:31 2020 +0300 Merge branch 'master' into 2271-handle-nolint commit 6ed2066bf567e13dd14cfa16fc7b109b59fa39ef Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 18:13:45 2020 +0300 home: fix tests naming commit af691081fb02b7500a746b16492f01f7f9befe9a Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 12:15:49 2020 +0300 home: impove code quality commit 2914cd3cd23ef2a1964116baab9187d89b377f86 Author: Eugene Burkov <[email protected]> Date: Wed Nov 11 15:46:39 2020 +0300 * querylog: remove useless check commit 9996840650e784ccc76d1f29964560435ba27dc7 Author: Eugene Burkov <[email protected]> Date: Wed Nov 11 13:18:34 2020 +0300 * all: fix noticed defects commit 2b15293e59337f70302fbc0db81ebb26bee0bed2 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 20:15:53 2020 +0300 * stats: remove last nolint directive commit b2e1ddf7b58196a2fdbf879f084edb41ca1aa1eb Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 18:35:41 2020 +0300 * all: remove another nolint directive commit c6fc5cfcc9c95ab9e570a95ab41c3e5c0125e62e Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 18:11:28 2020 +0300 * querylog: remove nolint directive commit 226ddbf2c92f737f085b44a4ddf6daec7b602153 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 16:35:26 2020 +0300 * home: remove nolint directive commit 2ea3086ad41e9003282add7e996ae722d72d878b Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 16:13:57 2020 +0300 * home: reduce cyclomatic complexity of run function commit f479b480c48e0bb832ddef8f57586f56b8a55bab Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 15:35:46 2020 +0300 * home: use crypto/rand instead of math/rand commit a28d4a53e3b930136b036606fc7e78404f1d208b Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 14:11:07 2020 +0300 * dnsforward: remove gocyclo nolint directive commit 64a0a324cc2b20614ceec3ccc6505e960fe526e9 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 11:45:49 2020 +0300 all *: remove some nolint directives Updates #2271. </s> remove // Disabling "dupl": the algorithm of SB/PC is similar, but it uses different data // nolint:dupl func (d *Dnsfilter) checkParental(host string) (Result, error) { </s> add func (d *Dnsfilter) checkSafeBrowsing(host string) (Result, error) { </s> remove result := Result{} hashes := hostnameToHashes(host) c := &sbCtx{ host: host, svc: "Parental", hashToHost: hashes, cache: gctx.parentalCache, cacheTime: d.Config.CacheTime, </s> add ctx := &sbCtx{ host: host, svc: "SafeBrowsing", cache: gctx.safebrowsingCache, cacheTime: d.Config.CacheTime, </s> remove question := c.getQuestion() log.Tracef("Parental: checking %s: %s", host, question) req := dns.Msg{} req.SetQuestion(question, dns.TypeTXT) resp, err := d.parentalUpstream.Exchange(&req) if err != nil { return result, err </s> add func (d *Dnsfilter) checkParental(host string) (Result, error) { if log.GetLevel() >= log.DEBUG { timer := log.StartTimer() defer timer.LogElapsed("Parental lookup for %s", host) </s> remove // Disabling "dupl": the algorithm of SB/PC is similar, but it uses different data // nolint:dupl func (d *Dnsfilter) checkSafeBrowsing(host string) (Result, error) { if log.GetLevel() >= log.DEBUG { timer := log.StartTimer() defer timer.LogElapsed("SafeBrowsing lookup for %s", host) } result := Result{} hashes := hostnameToHashes(host) c := &sbCtx{ host: host, svc: "SafeBrowsing", hashToHost: hashes, cache: gctx.safebrowsingCache, cacheTime: d.Config.CacheTime, } // check cache match := c.getCached() if match < 0 { return result, nil } else if match > 0 { result.IsFiltered = true result.Reason = FilteredSafeBrowsing result.Rule = "adguard-malware-shavar" return result, nil </s> add func check(c *sbCtx, r Result, u upstream.Upstream) (Result, error) { c.hashToHost = hostnameToHashes(c.host) switch c.getCached() { case -1: return Result{}, nil case 1: return r, nil
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/3045da1742ee0e75392de1623900d7d88b08f0b4
internal/dnsfilter/sb_pc.go
ctx := &sbCtx{ host: host, svc: "SafeBrowsing", cache: gctx.safebrowsingCache, cacheTime: d.Config.CacheTime,
<mask> if log.GetLevel() >= log.DEBUG { <mask> timer := log.StartTimer() <mask> defer timer.LogElapsed("Parental lookup for %s", host) <mask> } <mask> <mask> result := Result{} <mask> hashes := hostnameToHashes(host) <mask> <mask> c := &sbCtx{ <mask> host: host, <mask> svc: "Parental", <mask> hashToHost: hashes, <mask> cache: gctx.parentalCache, <mask> cacheTime: d.Config.CacheTime, <mask> } <mask> <mask> // check cache <mask> match := c.getCached() <mask> if match < 0 { </s> Pull request: 2271 handle nolint Merge in DNS/adguard-home from 2271-handle-nolint to master Closes #2271. Squashed commit of the following: commit fde5c8795ac79e1f7d02ba8c8e369b5a724a000e Merge: fc2acd898 642dcd647 Author: Eugene Burkov <[email protected]> Date: Fri Nov 20 17:12:28 2020 +0300 Merge branch 'master' into 2271-handle-nolint commit fc2acd89871de08c39e80ace9e5bb8a7acb7afba Author: Eugene Burkov <[email protected]> Date: Tue Nov 17 11:55:29 2020 +0300 dnsforward: fix test output strings commit c4ebae6ea9c293bad239519c44ca5a6c576bb921 Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 22:43:20 2020 +0300 dnsfilter: make package pass tests commit f2d98c6acabd8977f3b1b361987eaa31eb6eb9ad Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 20:05:00 2020 +0300 querylog: make decoding pass tests commit ab5850d24c50d53b8393f2de448cc340241351d7 Merge: 6ed2066bf 8a9c6e8a0 Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 19:48:31 2020 +0300 Merge branch 'master' into 2271-handle-nolint commit 6ed2066bf567e13dd14cfa16fc7b109b59fa39ef Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 18:13:45 2020 +0300 home: fix tests naming commit af691081fb02b7500a746b16492f01f7f9befe9a Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 12:15:49 2020 +0300 home: impove code quality commit 2914cd3cd23ef2a1964116baab9187d89b377f86 Author: Eugene Burkov <[email protected]> Date: Wed Nov 11 15:46:39 2020 +0300 * querylog: remove useless check commit 9996840650e784ccc76d1f29964560435ba27dc7 Author: Eugene Burkov <[email protected]> Date: Wed Nov 11 13:18:34 2020 +0300 * all: fix noticed defects commit 2b15293e59337f70302fbc0db81ebb26bee0bed2 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 20:15:53 2020 +0300 * stats: remove last nolint directive commit b2e1ddf7b58196a2fdbf879f084edb41ca1aa1eb Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 18:35:41 2020 +0300 * all: remove another nolint directive commit c6fc5cfcc9c95ab9e570a95ab41c3e5c0125e62e Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 18:11:28 2020 +0300 * querylog: remove nolint directive commit 226ddbf2c92f737f085b44a4ddf6daec7b602153 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 16:35:26 2020 +0300 * home: remove nolint directive commit 2ea3086ad41e9003282add7e996ae722d72d878b Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 16:13:57 2020 +0300 * home: reduce cyclomatic complexity of run function commit f479b480c48e0bb832ddef8f57586f56b8a55bab Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 15:35:46 2020 +0300 * home: use crypto/rand instead of math/rand commit a28d4a53e3b930136b036606fc7e78404f1d208b Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 14:11:07 2020 +0300 * dnsforward: remove gocyclo nolint directive commit 64a0a324cc2b20614ceec3ccc6505e960fe526e9 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 11:45:49 2020 +0300 all *: remove some nolint directives Updates #2271. </s> remove // Disabling "dupl": the algorithm of SB/PC is similar, but it uses different data // nolint:dupl func (d *Dnsfilter) checkSafeBrowsing(host string) (Result, error) { if log.GetLevel() >= log.DEBUG { timer := log.StartTimer() defer timer.LogElapsed("SafeBrowsing lookup for %s", host) } result := Result{} hashes := hostnameToHashes(host) c := &sbCtx{ host: host, svc: "SafeBrowsing", hashToHost: hashes, cache: gctx.safebrowsingCache, cacheTime: d.Config.CacheTime, } // check cache match := c.getCached() if match < 0 { return result, nil } else if match > 0 { result.IsFiltered = true result.Reason = FilteredSafeBrowsing result.Rule = "adguard-malware-shavar" return result, nil </s> add func check(c *sbCtx, r Result, u upstream.Upstream) (Result, error) { c.hashToHost = hostnameToHashes(c.host) switch c.getCached() { case -1: return Result{}, nil case 1: return r, nil </s> remove defer timer.LogElapsed("Parental lookup for %s", host) </s> add defer timer.LogElapsed("SafeBrowsing lookup for %s", host) </s> remove // check cache match := c.getCached() if match < 0 { return result, nil } else if match > 0 { result.IsFiltered = true result.Reason = FilteredParental result.Rule = "parental CATEGORY_BLACKLISTED" return result, nil </s> add res := Result{ IsFiltered: true, Reason: FilteredSafeBrowsing, Rule: "adguard-malware-shavar", </s> remove matched, receivedHashes := c.processTXT(resp) if matched { result.IsFiltered = true result.Reason = FilteredParental result.Rule = "parental CATEGORY_BLACKLISTED" </s> add ctx := &sbCtx{ host: host, svc: "Parental", cache: gctx.parentalCache, cacheTime: d.Config.CacheTime,
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/3045da1742ee0e75392de1623900d7d88b08f0b4
internal/dnsfilter/sb_pc.go
res := Result{ IsFiltered: true, Reason: FilteredSafeBrowsing, Rule: "adguard-malware-shavar",
<mask> hashToHost: hashes, <mask> cache: gctx.parentalCache, <mask> cacheTime: d.Config.CacheTime, <mask> } <mask> <mask> // check cache <mask> match := c.getCached() <mask> if match < 0 { <mask> return result, nil <mask> } else if match > 0 { <mask> result.IsFiltered = true <mask> result.Reason = FilteredParental <mask> result.Rule = "parental CATEGORY_BLACKLISTED" <mask> return result, nil <mask> } <mask> <mask> question := c.getQuestion() <mask> log.Tracef("Parental: checking %s: %s", host, question) <mask> </s> Pull request: 2271 handle nolint Merge in DNS/adguard-home from 2271-handle-nolint to master Closes #2271. Squashed commit of the following: commit fde5c8795ac79e1f7d02ba8c8e369b5a724a000e Merge: fc2acd898 642dcd647 Author: Eugene Burkov <[email protected]> Date: Fri Nov 20 17:12:28 2020 +0300 Merge branch 'master' into 2271-handle-nolint commit fc2acd89871de08c39e80ace9e5bb8a7acb7afba Author: Eugene Burkov <[email protected]> Date: Tue Nov 17 11:55:29 2020 +0300 dnsforward: fix test output strings commit c4ebae6ea9c293bad239519c44ca5a6c576bb921 Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 22:43:20 2020 +0300 dnsfilter: make package pass tests commit f2d98c6acabd8977f3b1b361987eaa31eb6eb9ad Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 20:05:00 2020 +0300 querylog: make decoding pass tests commit ab5850d24c50d53b8393f2de448cc340241351d7 Merge: 6ed2066bf 8a9c6e8a0 Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 19:48:31 2020 +0300 Merge branch 'master' into 2271-handle-nolint commit 6ed2066bf567e13dd14cfa16fc7b109b59fa39ef Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 18:13:45 2020 +0300 home: fix tests naming commit af691081fb02b7500a746b16492f01f7f9befe9a Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 12:15:49 2020 +0300 home: impove code quality commit 2914cd3cd23ef2a1964116baab9187d89b377f86 Author: Eugene Burkov <[email protected]> Date: Wed Nov 11 15:46:39 2020 +0300 * querylog: remove useless check commit 9996840650e784ccc76d1f29964560435ba27dc7 Author: Eugene Burkov <[email protected]> Date: Wed Nov 11 13:18:34 2020 +0300 * all: fix noticed defects commit 2b15293e59337f70302fbc0db81ebb26bee0bed2 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 20:15:53 2020 +0300 * stats: remove last nolint directive commit b2e1ddf7b58196a2fdbf879f084edb41ca1aa1eb Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 18:35:41 2020 +0300 * all: remove another nolint directive commit c6fc5cfcc9c95ab9e570a95ab41c3e5c0125e62e Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 18:11:28 2020 +0300 * querylog: remove nolint directive commit 226ddbf2c92f737f085b44a4ddf6daec7b602153 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 16:35:26 2020 +0300 * home: remove nolint directive commit 2ea3086ad41e9003282add7e996ae722d72d878b Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 16:13:57 2020 +0300 * home: reduce cyclomatic complexity of run function commit f479b480c48e0bb832ddef8f57586f56b8a55bab Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 15:35:46 2020 +0300 * home: use crypto/rand instead of math/rand commit a28d4a53e3b930136b036606fc7e78404f1d208b Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 14:11:07 2020 +0300 * dnsforward: remove gocyclo nolint directive commit 64a0a324cc2b20614ceec3ccc6505e960fe526e9 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 11:45:49 2020 +0300 all *: remove some nolint directives Updates #2271. </s> remove // Disabling "dupl": the algorithm of SB/PC is similar, but it uses different data // nolint:dupl func (d *Dnsfilter) checkSafeBrowsing(host string) (Result, error) { if log.GetLevel() >= log.DEBUG { timer := log.StartTimer() defer timer.LogElapsed("SafeBrowsing lookup for %s", host) } result := Result{} hashes := hostnameToHashes(host) c := &sbCtx{ host: host, svc: "SafeBrowsing", hashToHost: hashes, cache: gctx.safebrowsingCache, cacheTime: d.Config.CacheTime, } // check cache match := c.getCached() if match < 0 { return result, nil } else if match > 0 { result.IsFiltered = true result.Reason = FilteredSafeBrowsing result.Rule = "adguard-malware-shavar" return result, nil </s> add func check(c *sbCtx, r Result, u upstream.Upstream) (Result, error) { c.hashToHost = hostnameToHashes(c.host) switch c.getCached() { case -1: return Result{}, nil case 1: return r, nil </s> remove result := Result{} hashes := hostnameToHashes(host) c := &sbCtx{ host: host, svc: "Parental", hashToHost: hashes, cache: gctx.parentalCache, cacheTime: d.Config.CacheTime, </s> add ctx := &sbCtx{ host: host, svc: "SafeBrowsing", cache: gctx.safebrowsingCache, cacheTime: d.Config.CacheTime, </s> remove matched, receivedHashes := c.processTXT(resp) if matched { result.IsFiltered = true result.Reason = FilteredParental result.Rule = "parental CATEGORY_BLACKLISTED" </s> add ctx := &sbCtx{ host: host, svc: "Parental", cache: gctx.parentalCache, cacheTime: d.Config.CacheTime, </s> remove question := c.getQuestion() log.Tracef("Parental: checking %s: %s", host, question) req := dns.Msg{} req.SetQuestion(question, dns.TypeTXT) resp, err := d.parentalUpstream.Exchange(&req) if err != nil { return result, err </s> add func (d *Dnsfilter) checkParental(host string) (Result, error) { if log.GetLevel() >= log.DEBUG { timer := log.StartTimer() defer timer.LogElapsed("Parental lookup for %s", host) </s> remove c.storeCache(receivedHashes) return result, err </s> add res := Result{ IsFiltered: true, Reason: FilteredParental, Rule: "parental CATEGORY_BLACKLISTED", } return check(ctx, res, d.parentalUpstream)
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/3045da1742ee0e75392de1623900d7d88b08f0b4
internal/dnsfilter/sb_pc.go
return check(ctx, res, d.safeBrowsingUpstream) }
<mask> IsFiltered: true, <mask> Reason: FilteredSafeBrowsing, <mask> Rule: "adguard-malware-shavar", <mask> } <mask> <mask> func (d *Dnsfilter) checkParental(host string) (Result, error) { <mask> if log.GetLevel() >= log.DEBUG { <mask> timer := log.StartTimer() <mask> defer timer.LogElapsed("Parental lookup for %s", host) <mask> } </s> Pull request: 2271 handle nolint Merge in DNS/adguard-home from 2271-handle-nolint to master Closes #2271. Squashed commit of the following: commit fde5c8795ac79e1f7d02ba8c8e369b5a724a000e Merge: fc2acd898 642dcd647 Author: Eugene Burkov <[email protected]> Date: Fri Nov 20 17:12:28 2020 +0300 Merge branch 'master' into 2271-handle-nolint commit fc2acd89871de08c39e80ace9e5bb8a7acb7afba Author: Eugene Burkov <[email protected]> Date: Tue Nov 17 11:55:29 2020 +0300 dnsforward: fix test output strings commit c4ebae6ea9c293bad239519c44ca5a6c576bb921 Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 22:43:20 2020 +0300 dnsfilter: make package pass tests commit f2d98c6acabd8977f3b1b361987eaa31eb6eb9ad Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 20:05:00 2020 +0300 querylog: make decoding pass tests commit ab5850d24c50d53b8393f2de448cc340241351d7 Merge: 6ed2066bf 8a9c6e8a0 Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 19:48:31 2020 +0300 Merge branch 'master' into 2271-handle-nolint commit 6ed2066bf567e13dd14cfa16fc7b109b59fa39ef Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 18:13:45 2020 +0300 home: fix tests naming commit af691081fb02b7500a746b16492f01f7f9befe9a Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 12:15:49 2020 +0300 home: impove code quality commit 2914cd3cd23ef2a1964116baab9187d89b377f86 Author: Eugene Burkov <[email protected]> Date: Wed Nov 11 15:46:39 2020 +0300 * querylog: remove useless check commit 9996840650e784ccc76d1f29964560435ba27dc7 Author: Eugene Burkov <[email protected]> Date: Wed Nov 11 13:18:34 2020 +0300 * all: fix noticed defects commit 2b15293e59337f70302fbc0db81ebb26bee0bed2 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 20:15:53 2020 +0300 * stats: remove last nolint directive commit b2e1ddf7b58196a2fdbf879f084edb41ca1aa1eb Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 18:35:41 2020 +0300 * all: remove another nolint directive commit c6fc5cfcc9c95ab9e570a95ab41c3e5c0125e62e Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 18:11:28 2020 +0300 * querylog: remove nolint directive commit 226ddbf2c92f737f085b44a4ddf6daec7b602153 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 16:35:26 2020 +0300 * home: remove nolint directive commit 2ea3086ad41e9003282add7e996ae722d72d878b Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 16:13:57 2020 +0300 * home: reduce cyclomatic complexity of run function commit f479b480c48e0bb832ddef8f57586f56b8a55bab Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 15:35:46 2020 +0300 * home: use crypto/rand instead of math/rand commit a28d4a53e3b930136b036606fc7e78404f1d208b Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 14:11:07 2020 +0300 * dnsforward: remove gocyclo nolint directive commit 64a0a324cc2b20614ceec3ccc6505e960fe526e9 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 11:45:49 2020 +0300 all *: remove some nolint directives Updates #2271. </s> remove defer timer.LogElapsed("Parental lookup for %s", host) </s> add defer timer.LogElapsed("SafeBrowsing lookup for %s", host) </s> remove // Disabling "dupl": the algorithm of SB/PC is similar, but it uses different data // nolint:dupl func (d *Dnsfilter) checkParental(host string) (Result, error) { </s> add func (d *Dnsfilter) checkSafeBrowsing(host string) (Result, error) { </s> remove question := c.getQuestion() log.Tracef("Parental: checking %s: %s", host, question) req := dns.Msg{} req.SetQuestion(question, dns.TypeTXT) resp, err := d.parentalUpstream.Exchange(&req) if err != nil { return result, err </s> add func (d *Dnsfilter) checkParental(host string) (Result, error) { if log.GetLevel() >= log.DEBUG { timer := log.StartTimer() defer timer.LogElapsed("Parental lookup for %s", host) </s> remove result := Result{} hashes := hostnameToHashes(host) c := &sbCtx{ host: host, svc: "Parental", hashToHost: hashes, cache: gctx.parentalCache, cacheTime: d.Config.CacheTime, </s> add ctx := &sbCtx{ host: host, svc: "SafeBrowsing", cache: gctx.safebrowsingCache, cacheTime: d.Config.CacheTime, </s> remove // Disabling "dupl": the algorithm of SB/PC is similar, but it uses different data // nolint:dupl func (d *Dnsfilter) checkSafeBrowsing(host string) (Result, error) { if log.GetLevel() >= log.DEBUG { timer := log.StartTimer() defer timer.LogElapsed("SafeBrowsing lookup for %s", host) } result := Result{} hashes := hostnameToHashes(host) c := &sbCtx{ host: host, svc: "SafeBrowsing", hashToHost: hashes, cache: gctx.safebrowsingCache, cacheTime: d.Config.CacheTime, } // check cache match := c.getCached() if match < 0 { return result, nil } else if match > 0 { result.IsFiltered = true result.Reason = FilteredSafeBrowsing result.Rule = "adguard-malware-shavar" return result, nil </s> add func check(c *sbCtx, r Result, u upstream.Upstream) (Result, error) { c.hashToHost = hostnameToHashes(c.host) switch c.getCached() { case -1: return Result{}, nil case 1: return r, nil
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/3045da1742ee0e75392de1623900d7d88b08f0b4
internal/dnsfilter/sb_pc.go
func (d *Dnsfilter) checkParental(host string) (Result, error) { if log.GetLevel() >= log.DEBUG { timer := log.StartTimer() defer timer.LogElapsed("Parental lookup for %s", host)
<mask> result.Rule = "parental CATEGORY_BLACKLISTED" <mask> return result, nil <mask> } <mask> <mask> question := c.getQuestion() <mask> log.Tracef("Parental: checking %s: %s", host, question) <mask> <mask> req := dns.Msg{} <mask> req.SetQuestion(question, dns.TypeTXT) <mask> resp, err := d.parentalUpstream.Exchange(&req) <mask> if err != nil { <mask> return result, err <mask> } <mask> <mask> matched, receivedHashes := c.processTXT(resp) <mask> if matched { <mask> result.IsFiltered = true </s> Pull request: 2271 handle nolint Merge in DNS/adguard-home from 2271-handle-nolint to master Closes #2271. Squashed commit of the following: commit fde5c8795ac79e1f7d02ba8c8e369b5a724a000e Merge: fc2acd898 642dcd647 Author: Eugene Burkov <[email protected]> Date: Fri Nov 20 17:12:28 2020 +0300 Merge branch 'master' into 2271-handle-nolint commit fc2acd89871de08c39e80ace9e5bb8a7acb7afba Author: Eugene Burkov <[email protected]> Date: Tue Nov 17 11:55:29 2020 +0300 dnsforward: fix test output strings commit c4ebae6ea9c293bad239519c44ca5a6c576bb921 Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 22:43:20 2020 +0300 dnsfilter: make package pass tests commit f2d98c6acabd8977f3b1b361987eaa31eb6eb9ad Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 20:05:00 2020 +0300 querylog: make decoding pass tests commit ab5850d24c50d53b8393f2de448cc340241351d7 Merge: 6ed2066bf 8a9c6e8a0 Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 19:48:31 2020 +0300 Merge branch 'master' into 2271-handle-nolint commit 6ed2066bf567e13dd14cfa16fc7b109b59fa39ef Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 18:13:45 2020 +0300 home: fix tests naming commit af691081fb02b7500a746b16492f01f7f9befe9a Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 12:15:49 2020 +0300 home: impove code quality commit 2914cd3cd23ef2a1964116baab9187d89b377f86 Author: Eugene Burkov <[email protected]> Date: Wed Nov 11 15:46:39 2020 +0300 * querylog: remove useless check commit 9996840650e784ccc76d1f29964560435ba27dc7 Author: Eugene Burkov <[email protected]> Date: Wed Nov 11 13:18:34 2020 +0300 * all: fix noticed defects commit 2b15293e59337f70302fbc0db81ebb26bee0bed2 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 20:15:53 2020 +0300 * stats: remove last nolint directive commit b2e1ddf7b58196a2fdbf879f084edb41ca1aa1eb Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 18:35:41 2020 +0300 * all: remove another nolint directive commit c6fc5cfcc9c95ab9e570a95ab41c3e5c0125e62e Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 18:11:28 2020 +0300 * querylog: remove nolint directive commit 226ddbf2c92f737f085b44a4ddf6daec7b602153 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 16:35:26 2020 +0300 * home: remove nolint directive commit 2ea3086ad41e9003282add7e996ae722d72d878b Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 16:13:57 2020 +0300 * home: reduce cyclomatic complexity of run function commit f479b480c48e0bb832ddef8f57586f56b8a55bab Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 15:35:46 2020 +0300 * home: use crypto/rand instead of math/rand commit a28d4a53e3b930136b036606fc7e78404f1d208b Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 14:11:07 2020 +0300 * dnsforward: remove gocyclo nolint directive commit 64a0a324cc2b20614ceec3ccc6505e960fe526e9 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 11:45:49 2020 +0300 all *: remove some nolint directives Updates #2271. </s> remove req := dns.Msg{} req.SetQuestion(question, dns.TypeTXT) resp, err := d.safeBrowsingUpstream.Exchange(&req) </s> add log.Tracef("%s: checking %s: %s", c.svc, c.host, question) req := (&dns.Msg{}).SetQuestion(question, dns.TypeTXT) resp, err := u.Exchange(req) </s> remove log.Tracef("SafeBrowsing: checking %s: %s", host, question) </s> add </s> remove return result, err </s> add return Result{}, err </s> remove matched, receivedHashes := c.processTXT(resp) if matched { result.IsFiltered = true result.Reason = FilteredParental result.Rule = "parental CATEGORY_BLACKLISTED" </s> add ctx := &sbCtx{ host: host, svc: "Parental", cache: gctx.parentalCache, cacheTime: d.Config.CacheTime, </s> remove // check cache match := c.getCached() if match < 0 { return result, nil } else if match > 0 { result.IsFiltered = true result.Reason = FilteredParental result.Rule = "parental CATEGORY_BLACKLISTED" return result, nil </s> add res := Result{ IsFiltered: true, Reason: FilteredSafeBrowsing, Rule: "adguard-malware-shavar",
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/3045da1742ee0e75392de1623900d7d88b08f0b4
internal/dnsfilter/sb_pc.go
ctx := &sbCtx{ host: host, svc: "Parental", cache: gctx.parentalCache, cacheTime: d.Config.CacheTime,
<mask> resp, err := d.parentalUpstream.Exchange(&req) <mask> if err != nil { <mask> return result, err <mask> } <mask> <mask> matched, receivedHashes := c.processTXT(resp) <mask> if matched { <mask> result.IsFiltered = true <mask> result.Reason = FilteredParental <mask> result.Rule = "parental CATEGORY_BLACKLISTED" <mask> } <mask> c.storeCache(receivedHashes) <mask> <mask> return result, err <mask> } </s> Pull request: 2271 handle nolint Merge in DNS/adguard-home from 2271-handle-nolint to master Closes #2271. Squashed commit of the following: commit fde5c8795ac79e1f7d02ba8c8e369b5a724a000e Merge: fc2acd898 642dcd647 Author: Eugene Burkov <[email protected]> Date: Fri Nov 20 17:12:28 2020 +0300 Merge branch 'master' into 2271-handle-nolint commit fc2acd89871de08c39e80ace9e5bb8a7acb7afba Author: Eugene Burkov <[email protected]> Date: Tue Nov 17 11:55:29 2020 +0300 dnsforward: fix test output strings commit c4ebae6ea9c293bad239519c44ca5a6c576bb921 Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 22:43:20 2020 +0300 dnsfilter: make package pass tests commit f2d98c6acabd8977f3b1b361987eaa31eb6eb9ad Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 20:05:00 2020 +0300 querylog: make decoding pass tests commit ab5850d24c50d53b8393f2de448cc340241351d7 Merge: 6ed2066bf 8a9c6e8a0 Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 19:48:31 2020 +0300 Merge branch 'master' into 2271-handle-nolint commit 6ed2066bf567e13dd14cfa16fc7b109b59fa39ef Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 18:13:45 2020 +0300 home: fix tests naming commit af691081fb02b7500a746b16492f01f7f9befe9a Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 12:15:49 2020 +0300 home: impove code quality commit 2914cd3cd23ef2a1964116baab9187d89b377f86 Author: Eugene Burkov <[email protected]> Date: Wed Nov 11 15:46:39 2020 +0300 * querylog: remove useless check commit 9996840650e784ccc76d1f29964560435ba27dc7 Author: Eugene Burkov <[email protected]> Date: Wed Nov 11 13:18:34 2020 +0300 * all: fix noticed defects commit 2b15293e59337f70302fbc0db81ebb26bee0bed2 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 20:15:53 2020 +0300 * stats: remove last nolint directive commit b2e1ddf7b58196a2fdbf879f084edb41ca1aa1eb Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 18:35:41 2020 +0300 * all: remove another nolint directive commit c6fc5cfcc9c95ab9e570a95ab41c3e5c0125e62e Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 18:11:28 2020 +0300 * querylog: remove nolint directive commit 226ddbf2c92f737f085b44a4ddf6daec7b602153 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 16:35:26 2020 +0300 * home: remove nolint directive commit 2ea3086ad41e9003282add7e996ae722d72d878b Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 16:13:57 2020 +0300 * home: reduce cyclomatic complexity of run function commit f479b480c48e0bb832ddef8f57586f56b8a55bab Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 15:35:46 2020 +0300 * home: use crypto/rand instead of math/rand commit a28d4a53e3b930136b036606fc7e78404f1d208b Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 14:11:07 2020 +0300 * dnsforward: remove gocyclo nolint directive commit 64a0a324cc2b20614ceec3ccc6505e960fe526e9 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 11:45:49 2020 +0300 all *: remove some nolint directives Updates #2271. </s> remove question := c.getQuestion() log.Tracef("Parental: checking %s: %s", host, question) req := dns.Msg{} req.SetQuestion(question, dns.TypeTXT) resp, err := d.parentalUpstream.Exchange(&req) if err != nil { return result, err </s> add func (d *Dnsfilter) checkParental(host string) (Result, error) { if log.GetLevel() >= log.DEBUG { timer := log.StartTimer() defer timer.LogElapsed("Parental lookup for %s", host) </s> remove result.IsFiltered = true result.Reason = FilteredSafeBrowsing result.Rule = "adguard-malware-shavar" </s> add return r, nil </s> remove return result, err </s> add return Result{}, err </s> remove c.storeCache(receivedHashes) return result, err </s> add res := Result{ IsFiltered: true, Reason: FilteredParental, Rule: "parental CATEGORY_BLACKLISTED", } return check(ctx, res, d.parentalUpstream) </s> remove // check cache match := c.getCached() if match < 0 { return result, nil } else if match > 0 { result.IsFiltered = true result.Reason = FilteredParental result.Rule = "parental CATEGORY_BLACKLISTED" return result, nil </s> add res := Result{ IsFiltered: true, Reason: FilteredSafeBrowsing, Rule: "adguard-malware-shavar",
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/3045da1742ee0e75392de1623900d7d88b08f0b4
internal/dnsfilter/sb_pc.go
res := Result{ IsFiltered: true, Reason: FilteredParental, Rule: "parental CATEGORY_BLACKLISTED", } return check(ctx, res, d.parentalUpstream)
<mask> result.IsFiltered = true <mask> result.Reason = FilteredParental <mask> result.Rule = "parental CATEGORY_BLACKLISTED" <mask> } <mask> c.storeCache(receivedHashes) <mask> <mask> return result, err <mask> } <mask> <mask> func httpError(r *http.Request, w http.ResponseWriter, code int, format string, args ...interface{}) { <mask> text := fmt.Sprintf(format, args...) <mask> log.Info("DNSFilter: %s %s: %s", r.Method, r.URL, text) </s> Pull request: 2271 handle nolint Merge in DNS/adguard-home from 2271-handle-nolint to master Closes #2271. Squashed commit of the following: commit fde5c8795ac79e1f7d02ba8c8e369b5a724a000e Merge: fc2acd898 642dcd647 Author: Eugene Burkov <[email protected]> Date: Fri Nov 20 17:12:28 2020 +0300 Merge branch 'master' into 2271-handle-nolint commit fc2acd89871de08c39e80ace9e5bb8a7acb7afba Author: Eugene Burkov <[email protected]> Date: Tue Nov 17 11:55:29 2020 +0300 dnsforward: fix test output strings commit c4ebae6ea9c293bad239519c44ca5a6c576bb921 Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 22:43:20 2020 +0300 dnsfilter: make package pass tests commit f2d98c6acabd8977f3b1b361987eaa31eb6eb9ad Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 20:05:00 2020 +0300 querylog: make decoding pass tests commit ab5850d24c50d53b8393f2de448cc340241351d7 Merge: 6ed2066bf 8a9c6e8a0 Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 19:48:31 2020 +0300 Merge branch 'master' into 2271-handle-nolint commit 6ed2066bf567e13dd14cfa16fc7b109b59fa39ef Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 18:13:45 2020 +0300 home: fix tests naming commit af691081fb02b7500a746b16492f01f7f9befe9a Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 12:15:49 2020 +0300 home: impove code quality commit 2914cd3cd23ef2a1964116baab9187d89b377f86 Author: Eugene Burkov <[email protected]> Date: Wed Nov 11 15:46:39 2020 +0300 * querylog: remove useless check commit 9996840650e784ccc76d1f29964560435ba27dc7 Author: Eugene Burkov <[email protected]> Date: Wed Nov 11 13:18:34 2020 +0300 * all: fix noticed defects commit 2b15293e59337f70302fbc0db81ebb26bee0bed2 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 20:15:53 2020 +0300 * stats: remove last nolint directive commit b2e1ddf7b58196a2fdbf879f084edb41ca1aa1eb Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 18:35:41 2020 +0300 * all: remove another nolint directive commit c6fc5cfcc9c95ab9e570a95ab41c3e5c0125e62e Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 18:11:28 2020 +0300 * querylog: remove nolint directive commit 226ddbf2c92f737f085b44a4ddf6daec7b602153 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 16:35:26 2020 +0300 * home: remove nolint directive commit 2ea3086ad41e9003282add7e996ae722d72d878b Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 16:13:57 2020 +0300 * home: reduce cyclomatic complexity of run function commit f479b480c48e0bb832ddef8f57586f56b8a55bab Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 15:35:46 2020 +0300 * home: use crypto/rand instead of math/rand commit a28d4a53e3b930136b036606fc7e78404f1d208b Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 14:11:07 2020 +0300 * dnsforward: remove gocyclo nolint directive commit 64a0a324cc2b20614ceec3ccc6505e960fe526e9 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 11:45:49 2020 +0300 all *: remove some nolint directives Updates #2271. </s> remove matched, receivedHashes := c.processTXT(resp) if matched { result.IsFiltered = true result.Reason = FilteredParental result.Rule = "parental CATEGORY_BLACKLISTED" </s> add ctx := &sbCtx{ host: host, svc: "Parental", cache: gctx.parentalCache, cacheTime: d.Config.CacheTime, </s> remove // check cache match := c.getCached() if match < 0 { return result, nil } else if match > 0 { result.IsFiltered = true result.Reason = FilteredParental result.Rule = "parental CATEGORY_BLACKLISTED" return result, nil </s> add res := Result{ IsFiltered: true, Reason: FilteredSafeBrowsing, Rule: "adguard-malware-shavar", </s> remove result.IsFiltered = true result.Reason = FilteredSafeBrowsing result.Rule = "adguard-malware-shavar" </s> add return r, nil </s> remove question := c.getQuestion() log.Tracef("Parental: checking %s: %s", host, question) req := dns.Msg{} req.SetQuestion(question, dns.TypeTXT) resp, err := d.parentalUpstream.Exchange(&req) if err != nil { return result, err </s> add func (d *Dnsfilter) checkParental(host string) (Result, error) { if log.GetLevel() >= log.DEBUG { timer := log.StartTimer() defer timer.LogElapsed("Parental lookup for %s", host) </s> remove c.storeCache(receivedHashes) </s> add
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/3045da1742ee0e75392de1623900d7d88b08f0b4
internal/dnsfilter/sb_pc.go
<mask> // TLSConfig is the TLS configuration for HTTPS, DNS-over-HTTPS, and DNS-over-TLS <mask> type TLSConfig struct { <mask> TLSListenAddr *net.TCPAddr `yaml:"-" json:"-"` <mask> QUICListenAddr *net.UDPAddr `yaml:"-" json:"-"` <mask> StrictSNICheck bool `yaml:"strict_sni_check" json:"-"` // Reject connection if the client uses server name (in SNI) that doesn't match the certificate <mask> <mask> CertificateChain string `yaml:"certificate_chain" json:"certificate_chain"` // PEM-encoded certificates chain <mask> PrivateKey string `yaml:"private_key" json:"private_key"` // PEM-encoded private key <mask> <mask> CertificatePath string `yaml:"certificate_path" json:"certificate_path"` // certificate file name </s> Pull request: 2271 handle nolint Merge in DNS/adguard-home from 2271-handle-nolint to master Closes #2271. Squashed commit of the following: commit fde5c8795ac79e1f7d02ba8c8e369b5a724a000e Merge: fc2acd898 642dcd647 Author: Eugene Burkov <[email protected]> Date: Fri Nov 20 17:12:28 2020 +0300 Merge branch 'master' into 2271-handle-nolint commit fc2acd89871de08c39e80ace9e5bb8a7acb7afba Author: Eugene Burkov <[email protected]> Date: Tue Nov 17 11:55:29 2020 +0300 dnsforward: fix test output strings commit c4ebae6ea9c293bad239519c44ca5a6c576bb921 Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 22:43:20 2020 +0300 dnsfilter: make package pass tests commit f2d98c6acabd8977f3b1b361987eaa31eb6eb9ad Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 20:05:00 2020 +0300 querylog: make decoding pass tests commit ab5850d24c50d53b8393f2de448cc340241351d7 Merge: 6ed2066bf 8a9c6e8a0 Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 19:48:31 2020 +0300 Merge branch 'master' into 2271-handle-nolint commit 6ed2066bf567e13dd14cfa16fc7b109b59fa39ef Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 18:13:45 2020 +0300 home: fix tests naming commit af691081fb02b7500a746b16492f01f7f9befe9a Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 12:15:49 2020 +0300 home: impove code quality commit 2914cd3cd23ef2a1964116baab9187d89b377f86 Author: Eugene Burkov <[email protected]> Date: Wed Nov 11 15:46:39 2020 +0300 * querylog: remove useless check commit 9996840650e784ccc76d1f29964560435ba27dc7 Author: Eugene Burkov <[email protected]> Date: Wed Nov 11 13:18:34 2020 +0300 * all: fix noticed defects commit 2b15293e59337f70302fbc0db81ebb26bee0bed2 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 20:15:53 2020 +0300 * stats: remove last nolint directive commit b2e1ddf7b58196a2fdbf879f084edb41ca1aa1eb Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 18:35:41 2020 +0300 * all: remove another nolint directive commit c6fc5cfcc9c95ab9e570a95ab41c3e5c0125e62e Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 18:11:28 2020 +0300 * querylog: remove nolint directive commit 226ddbf2c92f737f085b44a4ddf6daec7b602153 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 16:35:26 2020 +0300 * home: remove nolint directive commit 2ea3086ad41e9003282add7e996ae722d72d878b Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 16:13:57 2020 +0300 * home: reduce cyclomatic complexity of run function commit f479b480c48e0bb832ddef8f57586f56b8a55bab Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 15:35:46 2020 +0300 * home: use crypto/rand instead of math/rand commit a28d4a53e3b930136b036606fc7e78404f1d208b Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 14:11:07 2020 +0300 * dnsforward: remove gocyclo nolint directive commit 64a0a324cc2b20614ceec3ccc6505e960fe526e9 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 11:45:49 2020 +0300 all *: remove some nolint directives Updates #2271. </s> remove CertificateChain string `yaml:"certificate_chain" json:"certificate_chain"` // PEM-encoded certificates chain PrivateKey string `yaml:"private_key" json:"private_key"` // PEM-encoded private key </s> add // Reject connection if the client uses server name (in SNI) that doesn't match the certificate StrictSNICheck bool `yaml:"strict_sni_check" json:"-"` </s> remove CertificatePath string `yaml:"certificate_path" json:"certificate_path"` // certificate file name PrivateKeyPath string `yaml:"private_key_path" json:"private_key_path"` // private key file name </s> add // PEM-encoded certificates chain CertificateChain string `yaml:"certificate_chain" json:"certificate_chain"` // PEM-encoded private key PrivateKey string `yaml:"private_key" json:"private_key"` CertificatePath string `yaml:"certificate_path" json:"certificate_path"` PrivateKeyPath string `yaml:"private_key_path" json:"private_key_path"` </s> remove cert tls.Certificate // nolint(structcheck) - linter thinks that this field is unused, while TLSConfig is directly included into ServerConfig dnsNames []string // nolint(structcheck) // DNS names from certificate (SAN) or CN value from Subject </s> add cert tls.Certificate // DNS names from certificate (SAN) or CN value from Subject dnsNames []string </s> remove func getSession(u *User) []byte { // the developers don't currently believe that using a // non-cryptographic RNG for the session hash salt is // insecure salt := rand.Uint32() //nolint:gosec d := []byte(fmt.Sprintf("%d%s%s", salt, u.Name, u.PasswordHash)) </s> add func getSession(u *User) ([]byte, error) { maxSalt := big.NewInt(math.MaxUint32) salt, err := rand.Int(rand.Reader, maxSalt) if err != nil { return nil, err } d := []byte(fmt.Sprintf("%s%s%s", salt, u.Name, u.PasswordHash))
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/3045da1742ee0e75392de1623900d7d88b08f0b4
internal/dnsforward/config.go
// Reject connection if the client uses server name (in SNI) that doesn't match the certificate StrictSNICheck bool `yaml:"strict_sni_check" json:"-"`
<mask> TLSListenAddr *net.TCPAddr `yaml:"-" json:"-"` <mask> QUICListenAddr *net.UDPAddr `yaml:"-" json:"-"` <mask> StrictSNICheck bool `yaml:"strict_sni_check" json:"-"` // Reject connection if the client uses server name (in SNI) that doesn't match the certificate <mask> <mask> CertificateChain string `yaml:"certificate_chain" json:"certificate_chain"` // PEM-encoded certificates chain <mask> PrivateKey string `yaml:"private_key" json:"private_key"` // PEM-encoded private key <mask> <mask> CertificatePath string `yaml:"certificate_path" json:"certificate_path"` // certificate file name <mask> PrivateKeyPath string `yaml:"private_key_path" json:"private_key_path"` // private key file name <mask> <mask> CertificateChainData []byte `yaml:"-" json:"-"` </s> Pull request: 2271 handle nolint Merge in DNS/adguard-home from 2271-handle-nolint to master Closes #2271. Squashed commit of the following: commit fde5c8795ac79e1f7d02ba8c8e369b5a724a000e Merge: fc2acd898 642dcd647 Author: Eugene Burkov <[email protected]> Date: Fri Nov 20 17:12:28 2020 +0300 Merge branch 'master' into 2271-handle-nolint commit fc2acd89871de08c39e80ace9e5bb8a7acb7afba Author: Eugene Burkov <[email protected]> Date: Tue Nov 17 11:55:29 2020 +0300 dnsforward: fix test output strings commit c4ebae6ea9c293bad239519c44ca5a6c576bb921 Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 22:43:20 2020 +0300 dnsfilter: make package pass tests commit f2d98c6acabd8977f3b1b361987eaa31eb6eb9ad Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 20:05:00 2020 +0300 querylog: make decoding pass tests commit ab5850d24c50d53b8393f2de448cc340241351d7 Merge: 6ed2066bf 8a9c6e8a0 Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 19:48:31 2020 +0300 Merge branch 'master' into 2271-handle-nolint commit 6ed2066bf567e13dd14cfa16fc7b109b59fa39ef Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 18:13:45 2020 +0300 home: fix tests naming commit af691081fb02b7500a746b16492f01f7f9befe9a Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 12:15:49 2020 +0300 home: impove code quality commit 2914cd3cd23ef2a1964116baab9187d89b377f86 Author: Eugene Burkov <[email protected]> Date: Wed Nov 11 15:46:39 2020 +0300 * querylog: remove useless check commit 9996840650e784ccc76d1f29964560435ba27dc7 Author: Eugene Burkov <[email protected]> Date: Wed Nov 11 13:18:34 2020 +0300 * all: fix noticed defects commit 2b15293e59337f70302fbc0db81ebb26bee0bed2 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 20:15:53 2020 +0300 * stats: remove last nolint directive commit b2e1ddf7b58196a2fdbf879f084edb41ca1aa1eb Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 18:35:41 2020 +0300 * all: remove another nolint directive commit c6fc5cfcc9c95ab9e570a95ab41c3e5c0125e62e Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 18:11:28 2020 +0300 * querylog: remove nolint directive commit 226ddbf2c92f737f085b44a4ddf6daec7b602153 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 16:35:26 2020 +0300 * home: remove nolint directive commit 2ea3086ad41e9003282add7e996ae722d72d878b Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 16:13:57 2020 +0300 * home: reduce cyclomatic complexity of run function commit f479b480c48e0bb832ddef8f57586f56b8a55bab Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 15:35:46 2020 +0300 * home: use crypto/rand instead of math/rand commit a28d4a53e3b930136b036606fc7e78404f1d208b Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 14:11:07 2020 +0300 * dnsforward: remove gocyclo nolint directive commit 64a0a324cc2b20614ceec3ccc6505e960fe526e9 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 11:45:49 2020 +0300 all *: remove some nolint directives Updates #2271. </s> remove StrictSNICheck bool `yaml:"strict_sni_check" json:"-"` // Reject connection if the client uses server name (in SNI) that doesn't match the certificate </s> add </s> remove CertificatePath string `yaml:"certificate_path" json:"certificate_path"` // certificate file name PrivateKeyPath string `yaml:"private_key_path" json:"private_key_path"` // private key file name </s> add // PEM-encoded certificates chain CertificateChain string `yaml:"certificate_chain" json:"certificate_chain"` // PEM-encoded private key PrivateKey string `yaml:"private_key" json:"private_key"` CertificatePath string `yaml:"certificate_path" json:"certificate_path"` PrivateKeyPath string `yaml:"private_key_path" json:"private_key_path"` </s> remove cert tls.Certificate // nolint(structcheck) - linter thinks that this field is unused, while TLSConfig is directly included into ServerConfig dnsNames []string // nolint(structcheck) // DNS names from certificate (SAN) or CN value from Subject </s> add cert tls.Certificate // DNS names from certificate (SAN) or CN value from Subject dnsNames []string </s> remove const defaultConfJSON = "{\"upstream_dns\":[\"8.8.8.8:53\",\"8.8.4.4:53\"],\"upstream_dns_file\":\"\",\"bootstrap_dns\":[\"9.9.9.10\",\"149.112.112.10\",\"2620:fe::10\",\"2620:fe::fe:10\"],\"protection_enabled\":true,\"ratelimit\":0,\"blocking_mode\":\"\",\"blocking_ipv4\":\"\",\"blocking_ipv6\":\"\",\"edns_cs_enabled\":false,\"dnssec_enabled\":false,\"disable_ipv6\":false,\"upstream_mode\":\"\",\"cache_size\":0,\"cache_ttl_min\":0,\"cache_ttl_max\":0}" </s> add const defaultConfJSON = "{\"upstream_dns\":[\"8.8.8.8:53\",\"8.8.4.4:53\"],\"upstream_dns_file\":\"\",\"bootstrap_dns\":[\"9.9.9.10\",\"149.112.112.10\",\"2620:fe::10\",\"2620:fe::fe:10\"],\"protection_enabled\":true,\"ratelimit\":0,\"blocking_mode\":\"\",\"blocking_ipv4\":\"\",\"blocking_ipv6\":\"\",\"edns_cs_enabled\":false,\"dnssec_enabled\":false,\"disable_ipv6\":false,\"upstream_mode\":\"\",\"cache_size\":0,\"cache_ttl_min\":0,\"cache_ttl_max\":0}\n" </s> remove func getSession(u *User) []byte { // the developers don't currently believe that using a // non-cryptographic RNG for the session hash salt is // insecure salt := rand.Uint32() //nolint:gosec d := []byte(fmt.Sprintf("%d%s%s", salt, u.Name, u.PasswordHash)) </s> add func getSession(u *User) ([]byte, error) { maxSalt := big.NewInt(math.MaxUint32) salt, err := rand.Int(rand.Reader, maxSalt) if err != nil { return nil, err } d := []byte(fmt.Sprintf("%s%s%s", salt, u.Name, u.PasswordHash))
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/3045da1742ee0e75392de1623900d7d88b08f0b4
internal/dnsforward/config.go
// PEM-encoded certificates chain CertificateChain string `yaml:"certificate_chain" json:"certificate_chain"` // PEM-encoded private key PrivateKey string `yaml:"private_key" json:"private_key"` CertificatePath string `yaml:"certificate_path" json:"certificate_path"` PrivateKeyPath string `yaml:"private_key_path" json:"private_key_path"`
<mask> <mask> CertificateChain string `yaml:"certificate_chain" json:"certificate_chain"` // PEM-encoded certificates chain <mask> PrivateKey string `yaml:"private_key" json:"private_key"` // PEM-encoded private key <mask> <mask> CertificatePath string `yaml:"certificate_path" json:"certificate_path"` // certificate file name <mask> PrivateKeyPath string `yaml:"private_key_path" json:"private_key_path"` // private key file name <mask> <mask> CertificateChainData []byte `yaml:"-" json:"-"` <mask> PrivateKeyData []byte `yaml:"-" json:"-"` <mask> <mask> cert tls.Certificate // nolint(structcheck) - linter thinks that this field is unused, while TLSConfig is directly included into ServerConfig </s> Pull request: 2271 handle nolint Merge in DNS/adguard-home from 2271-handle-nolint to master Closes #2271. Squashed commit of the following: commit fde5c8795ac79e1f7d02ba8c8e369b5a724a000e Merge: fc2acd898 642dcd647 Author: Eugene Burkov <[email protected]> Date: Fri Nov 20 17:12:28 2020 +0300 Merge branch 'master' into 2271-handle-nolint commit fc2acd89871de08c39e80ace9e5bb8a7acb7afba Author: Eugene Burkov <[email protected]> Date: Tue Nov 17 11:55:29 2020 +0300 dnsforward: fix test output strings commit c4ebae6ea9c293bad239519c44ca5a6c576bb921 Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 22:43:20 2020 +0300 dnsfilter: make package pass tests commit f2d98c6acabd8977f3b1b361987eaa31eb6eb9ad Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 20:05:00 2020 +0300 querylog: make decoding pass tests commit ab5850d24c50d53b8393f2de448cc340241351d7 Merge: 6ed2066bf 8a9c6e8a0 Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 19:48:31 2020 +0300 Merge branch 'master' into 2271-handle-nolint commit 6ed2066bf567e13dd14cfa16fc7b109b59fa39ef Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 18:13:45 2020 +0300 home: fix tests naming commit af691081fb02b7500a746b16492f01f7f9befe9a Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 12:15:49 2020 +0300 home: impove code quality commit 2914cd3cd23ef2a1964116baab9187d89b377f86 Author: Eugene Burkov <[email protected]> Date: Wed Nov 11 15:46:39 2020 +0300 * querylog: remove useless check commit 9996840650e784ccc76d1f29964560435ba27dc7 Author: Eugene Burkov <[email protected]> Date: Wed Nov 11 13:18:34 2020 +0300 * all: fix noticed defects commit 2b15293e59337f70302fbc0db81ebb26bee0bed2 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 20:15:53 2020 +0300 * stats: remove last nolint directive commit b2e1ddf7b58196a2fdbf879f084edb41ca1aa1eb Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 18:35:41 2020 +0300 * all: remove another nolint directive commit c6fc5cfcc9c95ab9e570a95ab41c3e5c0125e62e Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 18:11:28 2020 +0300 * querylog: remove nolint directive commit 226ddbf2c92f737f085b44a4ddf6daec7b602153 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 16:35:26 2020 +0300 * home: remove nolint directive commit 2ea3086ad41e9003282add7e996ae722d72d878b Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 16:13:57 2020 +0300 * home: reduce cyclomatic complexity of run function commit f479b480c48e0bb832ddef8f57586f56b8a55bab Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 15:35:46 2020 +0300 * home: use crypto/rand instead of math/rand commit a28d4a53e3b930136b036606fc7e78404f1d208b Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 14:11:07 2020 +0300 * dnsforward: remove gocyclo nolint directive commit 64a0a324cc2b20614ceec3ccc6505e960fe526e9 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 11:45:49 2020 +0300 all *: remove some nolint directives Updates #2271. </s> remove CertificateChain string `yaml:"certificate_chain" json:"certificate_chain"` // PEM-encoded certificates chain PrivateKey string `yaml:"private_key" json:"private_key"` // PEM-encoded private key </s> add // Reject connection if the client uses server name (in SNI) that doesn't match the certificate StrictSNICheck bool `yaml:"strict_sni_check" json:"-"` </s> remove StrictSNICheck bool `yaml:"strict_sni_check" json:"-"` // Reject connection if the client uses server name (in SNI) that doesn't match the certificate </s> add </s> remove cert tls.Certificate // nolint(structcheck) - linter thinks that this field is unused, while TLSConfig is directly included into ServerConfig dnsNames []string // nolint(structcheck) // DNS names from certificate (SAN) or CN value from Subject </s> add cert tls.Certificate // DNS names from certificate (SAN) or CN value from Subject dnsNames []string </s> remove func getSession(u *User) []byte { // the developers don't currently believe that using a // non-cryptographic RNG for the session hash salt is // insecure salt := rand.Uint32() //nolint:gosec d := []byte(fmt.Sprintf("%d%s%s", salt, u.Name, u.PasswordHash)) </s> add func getSession(u *User) ([]byte, error) { maxSalt := big.NewInt(math.MaxUint32) salt, err := rand.Int(rand.Reader, maxSalt) if err != nil { return nil, err } d := []byte(fmt.Sprintf("%s%s%s", salt, u.Name, u.PasswordHash)) </s> remove const defaultConfJSON = "{\"upstream_dns\":[\"8.8.8.8:53\",\"8.8.4.4:53\"],\"upstream_dns_file\":\"\",\"bootstrap_dns\":[\"9.9.9.10\",\"149.112.112.10\",\"2620:fe::10\",\"2620:fe::fe:10\"],\"protection_enabled\":true,\"ratelimit\":0,\"blocking_mode\":\"\",\"blocking_ipv4\":\"\",\"blocking_ipv6\":\"\",\"edns_cs_enabled\":false,\"dnssec_enabled\":false,\"disable_ipv6\":false,\"upstream_mode\":\"\",\"cache_size\":0,\"cache_ttl_min\":0,\"cache_ttl_max\":0}" </s> add const defaultConfJSON = "{\"upstream_dns\":[\"8.8.8.8:53\",\"8.8.4.4:53\"],\"upstream_dns_file\":\"\",\"bootstrap_dns\":[\"9.9.9.10\",\"149.112.112.10\",\"2620:fe::10\",\"2620:fe::fe:10\"],\"protection_enabled\":true,\"ratelimit\":0,\"blocking_mode\":\"\",\"blocking_ipv4\":\"\",\"blocking_ipv6\":\"\",\"edns_cs_enabled\":false,\"dnssec_enabled\":false,\"disable_ipv6\":false,\"upstream_mode\":\"\",\"cache_size\":0,\"cache_ttl_min\":0,\"cache_ttl_max\":0}\n"
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/3045da1742ee0e75392de1623900d7d88b08f0b4
internal/dnsforward/config.go
cert tls.Certificate // DNS names from certificate (SAN) or CN value from Subject dnsNames []string
<mask> <mask> CertificateChainData []byte `yaml:"-" json:"-"` <mask> PrivateKeyData []byte `yaml:"-" json:"-"` <mask> <mask> cert tls.Certificate // nolint(structcheck) - linter thinks that this field is unused, while TLSConfig is directly included into ServerConfig <mask> dnsNames []string // nolint(structcheck) // DNS names from certificate (SAN) or CN value from Subject <mask> } <mask> <mask> // ServerConfig represents server configuration. <mask> // The zero ServerConfig is empty and ready for use. <mask> type ServerConfig struct { </s> Pull request: 2271 handle nolint Merge in DNS/adguard-home from 2271-handle-nolint to master Closes #2271. Squashed commit of the following: commit fde5c8795ac79e1f7d02ba8c8e369b5a724a000e Merge: fc2acd898 642dcd647 Author: Eugene Burkov <[email protected]> Date: Fri Nov 20 17:12:28 2020 +0300 Merge branch 'master' into 2271-handle-nolint commit fc2acd89871de08c39e80ace9e5bb8a7acb7afba Author: Eugene Burkov <[email protected]> Date: Tue Nov 17 11:55:29 2020 +0300 dnsforward: fix test output strings commit c4ebae6ea9c293bad239519c44ca5a6c576bb921 Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 22:43:20 2020 +0300 dnsfilter: make package pass tests commit f2d98c6acabd8977f3b1b361987eaa31eb6eb9ad Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 20:05:00 2020 +0300 querylog: make decoding pass tests commit ab5850d24c50d53b8393f2de448cc340241351d7 Merge: 6ed2066bf 8a9c6e8a0 Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 19:48:31 2020 +0300 Merge branch 'master' into 2271-handle-nolint commit 6ed2066bf567e13dd14cfa16fc7b109b59fa39ef Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 18:13:45 2020 +0300 home: fix tests naming commit af691081fb02b7500a746b16492f01f7f9befe9a Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 12:15:49 2020 +0300 home: impove code quality commit 2914cd3cd23ef2a1964116baab9187d89b377f86 Author: Eugene Burkov <[email protected]> Date: Wed Nov 11 15:46:39 2020 +0300 * querylog: remove useless check commit 9996840650e784ccc76d1f29964560435ba27dc7 Author: Eugene Burkov <[email protected]> Date: Wed Nov 11 13:18:34 2020 +0300 * all: fix noticed defects commit 2b15293e59337f70302fbc0db81ebb26bee0bed2 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 20:15:53 2020 +0300 * stats: remove last nolint directive commit b2e1ddf7b58196a2fdbf879f084edb41ca1aa1eb Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 18:35:41 2020 +0300 * all: remove another nolint directive commit c6fc5cfcc9c95ab9e570a95ab41c3e5c0125e62e Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 18:11:28 2020 +0300 * querylog: remove nolint directive commit 226ddbf2c92f737f085b44a4ddf6daec7b602153 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 16:35:26 2020 +0300 * home: remove nolint directive commit 2ea3086ad41e9003282add7e996ae722d72d878b Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 16:13:57 2020 +0300 * home: reduce cyclomatic complexity of run function commit f479b480c48e0bb832ddef8f57586f56b8a55bab Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 15:35:46 2020 +0300 * home: use crypto/rand instead of math/rand commit a28d4a53e3b930136b036606fc7e78404f1d208b Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 14:11:07 2020 +0300 * dnsforward: remove gocyclo nolint directive commit 64a0a324cc2b20614ceec3ccc6505e960fe526e9 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 11:45:49 2020 +0300 all *: remove some nolint directives Updates #2271. </s> remove CertificatePath string `yaml:"certificate_path" json:"certificate_path"` // certificate file name PrivateKeyPath string `yaml:"private_key_path" json:"private_key_path"` // private key file name </s> add // PEM-encoded certificates chain CertificateChain string `yaml:"certificate_chain" json:"certificate_chain"` // PEM-encoded private key PrivateKey string `yaml:"private_key" json:"private_key"` CertificatePath string `yaml:"certificate_path" json:"certificate_path"` PrivateKeyPath string `yaml:"private_key_path" json:"private_key_path"` </s> remove StrictSNICheck bool `yaml:"strict_sni_check" json:"-"` // Reject connection if the client uses server name (in SNI) that doesn't match the certificate </s> add </s> remove CertificateChain string `yaml:"certificate_chain" json:"certificate_chain"` // PEM-encoded certificates chain PrivateKey string `yaml:"private_key" json:"private_key"` // PEM-encoded private key </s> add // Reject connection if the client uses server name (in SNI) that doesn't match the certificate StrictSNICheck bool `yaml:"strict_sni_check" json:"-"` </s> remove if restart { err = s.Reconfigure(nil) if err != nil { httpError(r, w, http.StatusInternalServerError, "%s", err) return } } </s> add return restart </s> remove want: "{\"upstream_dns\":[\"8.8.8.8:53\",\"8.8.4.4:53\"],\"upstream_dns_file\":\"\",\"bootstrap_dns\":[\"9.9.9.10\",\"149.112.112.10\",\"2620:fe::10\",\"2620:fe::fe:10\"],\"protection_enabled\":true,\"ratelimit\":0,\"blocking_mode\":\"\",\"blocking_ipv4\":\"\",\"blocking_ipv6\":\"\",\"edns_cs_enabled\":false,\"dnssec_enabled\":false,\"disable_ipv6\":false,\"upstream_mode\":\"\",\"cache_size\":0,\"cache_ttl_min\":0,\"cache_ttl_max\":0}", </s> add want: "{\"upstream_dns\":[\"8.8.8.8:53\",\"8.8.4.4:53\"],\"upstream_dns_file\":\"\",\"bootstrap_dns\":[\"9.9.9.10\",\"149.112.112.10\",\"2620:fe::10\",\"2620:fe::fe:10\"],\"protection_enabled\":true,\"ratelimit\":0,\"blocking_mode\":\"\",\"blocking_ipv4\":\"\",\"blocking_ipv6\":\"\",\"edns_cs_enabled\":false,\"dnssec_enabled\":false,\"disable_ipv6\":false,\"upstream_mode\":\"\",\"cache_size\":0,\"cache_ttl_min\":0,\"cache_ttl_max\":0}\n",
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/3045da1742ee0e75392de1623900d7d88b08f0b4
internal/dnsforward/config.go
<mask> "strconv" <mask> "strings" <mask> <mask> "github.com/AdguardTeam/dnsproxy/upstream" <mask> "github.com/AdguardTeam/golibs/jsonutil" <mask> "github.com/AdguardTeam/golibs/log" <mask> "github.com/AdguardTeam/golibs/utils" <mask> "github.com/miekg/dns" <mask> ) <mask> </s> Pull request: 2271 handle nolint Merge in DNS/adguard-home from 2271-handle-nolint to master Closes #2271. Squashed commit of the following: commit fde5c8795ac79e1f7d02ba8c8e369b5a724a000e Merge: fc2acd898 642dcd647 Author: Eugene Burkov <[email protected]> Date: Fri Nov 20 17:12:28 2020 +0300 Merge branch 'master' into 2271-handle-nolint commit fc2acd89871de08c39e80ace9e5bb8a7acb7afba Author: Eugene Burkov <[email protected]> Date: Tue Nov 17 11:55:29 2020 +0300 dnsforward: fix test output strings commit c4ebae6ea9c293bad239519c44ca5a6c576bb921 Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 22:43:20 2020 +0300 dnsfilter: make package pass tests commit f2d98c6acabd8977f3b1b361987eaa31eb6eb9ad Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 20:05:00 2020 +0300 querylog: make decoding pass tests commit ab5850d24c50d53b8393f2de448cc340241351d7 Merge: 6ed2066bf 8a9c6e8a0 Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 19:48:31 2020 +0300 Merge branch 'master' into 2271-handle-nolint commit 6ed2066bf567e13dd14cfa16fc7b109b59fa39ef Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 18:13:45 2020 +0300 home: fix tests naming commit af691081fb02b7500a746b16492f01f7f9befe9a Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 12:15:49 2020 +0300 home: impove code quality commit 2914cd3cd23ef2a1964116baab9187d89b377f86 Author: Eugene Burkov <[email protected]> Date: Wed Nov 11 15:46:39 2020 +0300 * querylog: remove useless check commit 9996840650e784ccc76d1f29964560435ba27dc7 Author: Eugene Burkov <[email protected]> Date: Wed Nov 11 13:18:34 2020 +0300 * all: fix noticed defects commit 2b15293e59337f70302fbc0db81ebb26bee0bed2 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 20:15:53 2020 +0300 * stats: remove last nolint directive commit b2e1ddf7b58196a2fdbf879f084edb41ca1aa1eb Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 18:35:41 2020 +0300 * all: remove another nolint directive commit c6fc5cfcc9c95ab9e570a95ab41c3e5c0125e62e Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 18:11:28 2020 +0300 * querylog: remove nolint directive commit 226ddbf2c92f737f085b44a4ddf6daec7b602153 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 16:35:26 2020 +0300 * home: remove nolint directive commit 2ea3086ad41e9003282add7e996ae722d72d878b Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 16:13:57 2020 +0300 * home: reduce cyclomatic complexity of run function commit f479b480c48e0bb832ddef8f57586f56b8a55bab Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 15:35:46 2020 +0300 * home: use crypto/rand instead of math/rand commit a28d4a53e3b930136b036606fc7e78404f1d208b Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 14:11:07 2020 +0300 * dnsforward: remove gocyclo nolint directive commit 64a0a324cc2b20614ceec3ccc6505e960fe526e9 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 11:45:49 2020 +0300 all *: remove some nolint directives Updates #2271. </s> remove "math/rand" </s> add "math" "math/big" </s> remove // decodeLogEntry - decodes query log entry from a line // nolint (gocyclo) func decodeLogEntry(ent *logEntry, str string) { var b bool var i int var err error for { k, v, t := readJSON(&str) if t == jsonTErr { break } switch k { case "IP": if len(ent.IP) == 0 { ent.IP = v } case "T": ent.Time, err = time.Parse(time.RFC3339, v) case "QH": ent.QHost = v case "QT": ent.QType = v case "QC": ent.QClass = v case "CP": ent.ClientProto, err = NewClientProto(v) case "Answer": ent.Answer, err = base64.StdEncoding.DecodeString(v) case "OrigAnswer": ent.OrigAnswer, err = base64.StdEncoding.DecodeString(v) case "IsFiltered": b, err = strconv.ParseBool(v) ent.Result.IsFiltered = b case "Rule": ent.Result.Rule = v case "FilterID": i, err = strconv.Atoi(v) ent.Result.FilterID = int64(i) case "Reason": i, err = strconv.Atoi(v) ent.Result.Reason = dnsfilter.Reason(i) case "ServiceName": ent.Result.ServiceName = v case "Upstream": ent.Upstream = v case "Elapsed": i, err = strconv.Atoi(v) ent.Elapsed = time.Duration(i) // pre-v0.99.3 compatibility: case "Question": var qstr []byte qstr, err = base64.StdEncoding.DecodeString(v) if err != nil { break } q := new(dns.Msg) err = q.Unpack(qstr) if err != nil { break } ent.QHost = q.Question[0].Name if len(ent.QHost) == 0 { break } ent.QHost = ent.QHost[:len(ent.QHost)-1] ent.QType = dns.TypeToString[q.Question[0].Qtype] ent.QClass = dns.ClassToString[q.Question[0].Qclass] case "Time": ent.Time, err = time.Parse(time.RFC3339, v) </s> add var logEntryHandlers = map[string](func(t json.Token, ent *logEntry) error){ "IP": func(t json.Token, ent *logEntry) error { v, ok := t.(string) if !ok { return nil } if len(ent.IP) == 0 { ent.IP = v } return nil }, "T": func(t json.Token, ent *logEntry) error { v, ok := t.(string) if !ok { return nil } var err error ent.Time, err = time.Parse(time.RFC3339, v) return err }, "QH": func(t json.Token, ent *logEntry) error { v, ok := t.(string) if !ok { return nil } ent.QHost = v return nil }, "QT": func(t json.Token, ent *logEntry) error { v, ok := t.(string) if !ok { return nil } ent.QType = v return nil }, "QC": func(t json.Token, ent *logEntry) error { v, ok := t.(string) if !ok { return nil } ent.QClass = v return nil }, "CP": func(t json.Token, ent *logEntry) error { v, ok := t.(string) if !ok { return nil } var err error ent.ClientProto, err = NewClientProto(v) return err }, "Answer": func(t json.Token, ent *logEntry) error { v, ok := t.(string) if !ok { return nil } var err error ent.Answer, err = base64.StdEncoding.DecodeString(v) return err }, "OrigAnswer": func(t json.Token, ent *logEntry) error { v, ok := t.(string) if !ok { return nil } var err error ent.OrigAnswer, err = base64.StdEncoding.DecodeString(v) return err }, "IsFiltered": func(t json.Token, ent *logEntry) error { v, ok := t.(string) if !ok { return nil } b, err := strconv.ParseBool(v) if err != nil { return err } ent.Result.IsFiltered = b return nil }, "Rule": func(t json.Token, ent *logEntry) error { v, ok := t.(string) if !ok { return nil } ent.Result.Rule = v return nil }, "FilterID": func(t json.Token, ent *logEntry) error { v, ok := t.(string) if !ok { return nil } i, err := strconv.Atoi(v) if err != nil { return err } ent.Result.FilterID = int64(i) return nil }, "Reason": func(t json.Token, ent *logEntry) error { v, ok := t.(string) if !ok { return nil } i, err := strconv.Atoi(v) if err != nil { return err } ent.Result.Reason = dnsfilter.Reason(i) return nil }, "ServiceName": func(t json.Token, ent *logEntry) error { v, ok := t.(string) if !ok { return nil } ent.Result.ServiceName = v return nil }, "Upstream": func(t json.Token, ent *logEntry) error { v, ok := t.(string) if !ok { return nil </s> remove const ( jsonTErr = iota jsonTObj jsonTStr jsonTNum jsonTBool ) // Parse JSON key-value pair // e.g.: "key":VALUE where VALUE is "string", true|false (boolean), or 123.456 (number) // Note the limitations: // . doesn't support whitespace // . doesn't support "null" // . doesn't validate boolean or number // . no proper handling of {} braces // . no handling of [] brackets // Return (key, value, type) func readJSON(ps *string) (string, string, int32) { s := *ps k := "" v := "" t := int32(jsonTErr) q1 := strings.IndexByte(s, '"') if q1 == -1 { return k, v, t } q2 := strings.IndexByte(s[q1+1:], '"') if q2 == -1 { return k, v, t } k = s[q1+1 : q1+1+q2] s = s[q1+1+q2+1:] if len(s) < 2 || s[0] != ':' { return k, v, t } if s[1] == '"' { q2 = strings.IndexByte(s[2:], '"') if q2 == -1 { return k, v, t } v = s[2 : 2+q2] t = jsonTStr s = s[2+q2+1:] } else if s[1] == '{' { t = jsonTObj s = s[1+1:] } else { sep := strings.IndexAny(s[1:], ",}") if sep == -1 { return k, v, t } v = s[1 : 1+sep] if s[1] == 't' || s[1] == 'f' { t = jsonTBool } else if s[1] == '.' || (s[1] >= '0' && s[1] <= '9') { t = jsonTNum } s = s[1+sep+1:] } *ps = s return k, v, t } </s> add
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/3045da1742ee0e75392de1623900d7d88b08f0b4
internal/dnsforward/dnsforward_http.go
type dnsConfig struct { Upstreams *[]string `json:"upstream_dns"` UpstreamsFile *string `json:"upstream_dns_file"` Bootstraps *[]string `json:"bootstrap_dns"` ProtectionEnabled *bool `json:"protection_enabled"` RateLimit *uint32 `json:"ratelimit"` BlockingMode *string `json:"blocking_mode"` BlockingIPv4 *string `json:"blocking_ipv4"` BlockingIPv6 *string `json:"blocking_ipv6"` EDNSCSEnabled *bool `json:"edns_cs_enabled"` DNSSECEnabled *bool `json:"dnssec_enabled"` DisableIPv6 *bool `json:"disable_ipv6"` UpstreamMode *string `json:"upstream_mode"` CacheSize *uint32 `json:"cache_size"` CacheMinTTL *uint32 `json:"cache_ttl_min"` CacheMaxTTL *uint32 `json:"cache_ttl_max"`
<mask> log.Info("dns: %s %s: %s", r.Method, r.URL, text) <mask> http.Error(w, text, code) <mask> } <mask> <mask> type dnsConfigJSON struct { <mask> Upstreams []string `json:"upstream_dns"` <mask> UpstreamsFile string `json:"upstream_dns_file"` <mask> Bootstraps []string `json:"bootstrap_dns"` <mask> <mask> ProtectionEnabled bool `json:"protection_enabled"` <mask> RateLimit uint32 `json:"ratelimit"` <mask> BlockingMode string `json:"blocking_mode"` <mask> BlockingIPv4 string `json:"blocking_ipv4"` <mask> BlockingIPv6 string `json:"blocking_ipv6"` <mask> EDNSCSEnabled bool `json:"edns_cs_enabled"` <mask> DNSSECEnabled bool `json:"dnssec_enabled"` <mask> DisableIPv6 bool `json:"disable_ipv6"` <mask> UpstreamMode string `json:"upstream_mode"` <mask> CacheSize uint32 `json:"cache_size"` <mask> CacheMinTTL uint32 `json:"cache_ttl_min"` <mask> CacheMaxTTL uint32 `json:"cache_ttl_max"` <mask> } <mask> <mask> func (s *Server) handleGetConfig(w http.ResponseWriter, r *http.Request) { <mask> resp := dnsConfigJSON{} <mask> s.RLock() </s> Pull request: 2271 handle nolint Merge in DNS/adguard-home from 2271-handle-nolint to master Closes #2271. Squashed commit of the following: commit fde5c8795ac79e1f7d02ba8c8e369b5a724a000e Merge: fc2acd898 642dcd647 Author: Eugene Burkov <[email protected]> Date: Fri Nov 20 17:12:28 2020 +0300 Merge branch 'master' into 2271-handle-nolint commit fc2acd89871de08c39e80ace9e5bb8a7acb7afba Author: Eugene Burkov <[email protected]> Date: Tue Nov 17 11:55:29 2020 +0300 dnsforward: fix test output strings commit c4ebae6ea9c293bad239519c44ca5a6c576bb921 Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 22:43:20 2020 +0300 dnsfilter: make package pass tests commit f2d98c6acabd8977f3b1b361987eaa31eb6eb9ad Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 20:05:00 2020 +0300 querylog: make decoding pass tests commit ab5850d24c50d53b8393f2de448cc340241351d7 Merge: 6ed2066bf 8a9c6e8a0 Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 19:48:31 2020 +0300 Merge branch 'master' into 2271-handle-nolint commit 6ed2066bf567e13dd14cfa16fc7b109b59fa39ef Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 18:13:45 2020 +0300 home: fix tests naming commit af691081fb02b7500a746b16492f01f7f9befe9a Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 12:15:49 2020 +0300 home: impove code quality commit 2914cd3cd23ef2a1964116baab9187d89b377f86 Author: Eugene Burkov <[email protected]> Date: Wed Nov 11 15:46:39 2020 +0300 * querylog: remove useless check commit 9996840650e784ccc76d1f29964560435ba27dc7 Author: Eugene Burkov <[email protected]> Date: Wed Nov 11 13:18:34 2020 +0300 * all: fix noticed defects commit 2b15293e59337f70302fbc0db81ebb26bee0bed2 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 20:15:53 2020 +0300 * stats: remove last nolint directive commit b2e1ddf7b58196a2fdbf879f084edb41ca1aa1eb Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 18:35:41 2020 +0300 * all: remove another nolint directive commit c6fc5cfcc9c95ab9e570a95ab41c3e5c0125e62e Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 18:11:28 2020 +0300 * querylog: remove nolint directive commit 226ddbf2c92f737f085b44a4ddf6daec7b602153 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 16:35:26 2020 +0300 * home: remove nolint directive commit 2ea3086ad41e9003282add7e996ae722d72d878b Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 16:13:57 2020 +0300 * home: reduce cyclomatic complexity of run function commit f479b480c48e0bb832ddef8f57586f56b8a55bab Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 15:35:46 2020 +0300 * home: use crypto/rand instead of math/rand commit a28d4a53e3b930136b036606fc7e78404f1d208b Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 14:11:07 2020 +0300 * dnsforward: remove gocyclo nolint directive commit 64a0a324cc2b20614ceec3ccc6505e960fe526e9 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 11:45:49 2020 +0300 all *: remove some nolint directives Updates #2271. </s> remove func (s *Server) handleGetConfig(w http.ResponseWriter, r *http.Request) { resp := dnsConfigJSON{} </s> add func (s *Server) getDNSConfig() dnsConfig { </s> remove resp.Upstreams = stringArrayDup(s.conf.UpstreamDNS) resp.UpstreamsFile = s.conf.UpstreamDNSFileName resp.Bootstraps = stringArrayDup(s.conf.BootstrapDNS) resp.ProtectionEnabled = s.conf.ProtectionEnabled resp.BlockingMode = s.conf.BlockingMode resp.BlockingIPv4 = s.conf.BlockingIPv4 resp.BlockingIPv6 = s.conf.BlockingIPv6 resp.RateLimit = s.conf.Ratelimit resp.EDNSCSEnabled = s.conf.EnableEDNSClientSubnet resp.DNSSECEnabled = s.conf.EnableDNSSEC resp.DisableIPv6 = s.conf.AAAADisabled resp.CacheSize = s.conf.CacheSize resp.CacheMinTTL = s.conf.CacheMinTTL resp.CacheMaxTTL = s.conf.CacheMaxTTL </s> add upstreams := stringArrayDup(s.conf.UpstreamDNS) upstreamFile := s.conf.UpstreamDNSFileName bootstraps := stringArrayDup(s.conf.BootstrapDNS) protectionEnabled := s.conf.ProtectionEnabled blockingMode := s.conf.BlockingMode BlockingIPv4 := s.conf.BlockingIPv4 BlockingIPv6 := s.conf.BlockingIPv6 Ratelimit := s.conf.Ratelimit EnableEDNSClientSubnet := s.conf.EnableEDNSClientSubnet EnableDNSSEC := s.conf.EnableDNSSEC AAAADisabled := s.conf.AAAADisabled CacheSize := s.conf.CacheSize CacheMinTTL := s.conf.CacheMinTTL CacheMaxTTL := s.conf.CacheMaxTTL var upstreamMode string </s> remove if restart { err = s.Reconfigure(nil) if err != nil { httpError(r, w, http.StatusInternalServerError, "%s", err) return } } </s> add return restart </s> remove StrictSNICheck bool `yaml:"strict_sni_check" json:"-"` // Reject connection if the client uses server name (in SNI) that doesn't match the certificate </s> add </s> remove return nil </s> add return false } func (req *dnsConfig) checkBootstrap() (string, error) { if req.Bootstraps == nil { return "", nil } for _, boot := range *req.Bootstraps { if boot == "" { return boot, fmt.Errorf("invalid bootstrap server address: empty") } if _, err := upstream.NewResolver(boot, 0); err != nil { return boot, fmt.Errorf("invalid bootstrap server address: %w", err) } } return "", nil } func (req *dnsConfig) checkCacheTTL() bool { if req.CacheMinTTL == nil && req.CacheMaxTTL == nil { return true } var min, max uint32 if req.CacheMinTTL != nil { min = *req.CacheMinTTL } if req.CacheMaxTTL == nil { max = *req.CacheMaxTTL } return min <= max
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/3045da1742ee0e75392de1623900d7d88b08f0b4
internal/dnsforward/dnsforward_http.go
func (s *Server) getDNSConfig() dnsConfig {
<mask> CacheMinTTL uint32 `json:"cache_ttl_min"` <mask> CacheMaxTTL uint32 `json:"cache_ttl_max"` <mask> } <mask> <mask> func (s *Server) handleGetConfig(w http.ResponseWriter, r *http.Request) { <mask> resp := dnsConfigJSON{} <mask> s.RLock() <mask> resp.Upstreams = stringArrayDup(s.conf.UpstreamDNS) <mask> resp.UpstreamsFile = s.conf.UpstreamDNSFileName <mask> resp.Bootstraps = stringArrayDup(s.conf.BootstrapDNS) <mask> </s> Pull request: 2271 handle nolint Merge in DNS/adguard-home from 2271-handle-nolint to master Closes #2271. Squashed commit of the following: commit fde5c8795ac79e1f7d02ba8c8e369b5a724a000e Merge: fc2acd898 642dcd647 Author: Eugene Burkov <[email protected]> Date: Fri Nov 20 17:12:28 2020 +0300 Merge branch 'master' into 2271-handle-nolint commit fc2acd89871de08c39e80ace9e5bb8a7acb7afba Author: Eugene Burkov <[email protected]> Date: Tue Nov 17 11:55:29 2020 +0300 dnsforward: fix test output strings commit c4ebae6ea9c293bad239519c44ca5a6c576bb921 Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 22:43:20 2020 +0300 dnsfilter: make package pass tests commit f2d98c6acabd8977f3b1b361987eaa31eb6eb9ad Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 20:05:00 2020 +0300 querylog: make decoding pass tests commit ab5850d24c50d53b8393f2de448cc340241351d7 Merge: 6ed2066bf 8a9c6e8a0 Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 19:48:31 2020 +0300 Merge branch 'master' into 2271-handle-nolint commit 6ed2066bf567e13dd14cfa16fc7b109b59fa39ef Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 18:13:45 2020 +0300 home: fix tests naming commit af691081fb02b7500a746b16492f01f7f9befe9a Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 12:15:49 2020 +0300 home: impove code quality commit 2914cd3cd23ef2a1964116baab9187d89b377f86 Author: Eugene Burkov <[email protected]> Date: Wed Nov 11 15:46:39 2020 +0300 * querylog: remove useless check commit 9996840650e784ccc76d1f29964560435ba27dc7 Author: Eugene Burkov <[email protected]> Date: Wed Nov 11 13:18:34 2020 +0300 * all: fix noticed defects commit 2b15293e59337f70302fbc0db81ebb26bee0bed2 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 20:15:53 2020 +0300 * stats: remove last nolint directive commit b2e1ddf7b58196a2fdbf879f084edb41ca1aa1eb Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 18:35:41 2020 +0300 * all: remove another nolint directive commit c6fc5cfcc9c95ab9e570a95ab41c3e5c0125e62e Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 18:11:28 2020 +0300 * querylog: remove nolint directive commit 226ddbf2c92f737f085b44a4ddf6daec7b602153 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 16:35:26 2020 +0300 * home: remove nolint directive commit 2ea3086ad41e9003282add7e996ae722d72d878b Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 16:13:57 2020 +0300 * home: reduce cyclomatic complexity of run function commit f479b480c48e0bb832ddef8f57586f56b8a55bab Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 15:35:46 2020 +0300 * home: use crypto/rand instead of math/rand commit a28d4a53e3b930136b036606fc7e78404f1d208b Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 14:11:07 2020 +0300 * dnsforward: remove gocyclo nolint directive commit 64a0a324cc2b20614ceec3ccc6505e960fe526e9 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 11:45:49 2020 +0300 all *: remove some nolint directives Updates #2271. </s> remove resp.Upstreams = stringArrayDup(s.conf.UpstreamDNS) resp.UpstreamsFile = s.conf.UpstreamDNSFileName resp.Bootstraps = stringArrayDup(s.conf.BootstrapDNS) resp.ProtectionEnabled = s.conf.ProtectionEnabled resp.BlockingMode = s.conf.BlockingMode resp.BlockingIPv4 = s.conf.BlockingIPv4 resp.BlockingIPv6 = s.conf.BlockingIPv6 resp.RateLimit = s.conf.Ratelimit resp.EDNSCSEnabled = s.conf.EnableEDNSClientSubnet resp.DNSSECEnabled = s.conf.EnableDNSSEC resp.DisableIPv6 = s.conf.AAAADisabled resp.CacheSize = s.conf.CacheSize resp.CacheMinTTL = s.conf.CacheMinTTL resp.CacheMaxTTL = s.conf.CacheMaxTTL </s> add upstreams := stringArrayDup(s.conf.UpstreamDNS) upstreamFile := s.conf.UpstreamDNSFileName bootstraps := stringArrayDup(s.conf.BootstrapDNS) protectionEnabled := s.conf.ProtectionEnabled blockingMode := s.conf.BlockingMode BlockingIPv4 := s.conf.BlockingIPv4 BlockingIPv6 := s.conf.BlockingIPv6 Ratelimit := s.conf.Ratelimit EnableEDNSClientSubnet := s.conf.EnableEDNSClientSubnet EnableDNSSEC := s.conf.EnableDNSSEC AAAADisabled := s.conf.AAAADisabled CacheSize := s.conf.CacheSize CacheMinTTL := s.conf.CacheMinTTL CacheMaxTTL := s.conf.CacheMaxTTL var upstreamMode string </s> remove type dnsConfigJSON struct { Upstreams []string `json:"upstream_dns"` UpstreamsFile string `json:"upstream_dns_file"` Bootstraps []string `json:"bootstrap_dns"` ProtectionEnabled bool `json:"protection_enabled"` RateLimit uint32 `json:"ratelimit"` BlockingMode string `json:"blocking_mode"` BlockingIPv4 string `json:"blocking_ipv4"` BlockingIPv6 string `json:"blocking_ipv6"` EDNSCSEnabled bool `json:"edns_cs_enabled"` DNSSECEnabled bool `json:"dnssec_enabled"` DisableIPv6 bool `json:"disable_ipv6"` UpstreamMode string `json:"upstream_mode"` CacheSize uint32 `json:"cache_size"` CacheMinTTL uint32 `json:"cache_ttl_min"` CacheMaxTTL uint32 `json:"cache_ttl_max"` </s> add type dnsConfig struct { Upstreams *[]string `json:"upstream_dns"` UpstreamsFile *string `json:"upstream_dns_file"` Bootstraps *[]string `json:"bootstrap_dns"` ProtectionEnabled *bool `json:"protection_enabled"` RateLimit *uint32 `json:"ratelimit"` BlockingMode *string `json:"blocking_mode"` BlockingIPv4 *string `json:"blocking_ipv4"` BlockingIPv6 *string `json:"blocking_ipv6"` EDNSCSEnabled *bool `json:"edns_cs_enabled"` DNSSECEnabled *bool `json:"dnssec_enabled"` DisableIPv6 *bool `json:"disable_ipv6"` UpstreamMode *string `json:"upstream_mode"` CacheSize *uint32 `json:"cache_size"` CacheMinTTL *uint32 `json:"cache_ttl_min"` CacheMaxTTL *uint32 `json:"cache_ttl_max"` </s> remove js, err := json.Marshal(resp) if err != nil { httpError(r, w, http.StatusInternalServerError, "json.Marshal: %s", err) </s> add func (s *Server) handleGetConfig(w http.ResponseWriter, r *http.Request) { resp := s.getDNSConfig() w.Header().Set("Content-Type", "application/json") enc := json.NewEncoder(w) if err := enc.Encode(resp); err != nil { httpError(r, w, http.StatusInternalServerError, "json.Encoder: %s", err) </s> remove // nolint(gocyclo) - we need to check each JSON field separately </s> add </s> remove req := dnsConfigJSON{} js, err := jsonutil.DecodeObject(&req, r.Body) if err != nil { httpError(r, w, http.StatusBadRequest, "json.Decode: %s", err) </s> add req := dnsConfig{} dec := json.NewDecoder(r.Body) if err := dec.Decode(&req); err != nil { httpError(r, w, http.StatusBadRequest, "json Encode: %s", err)
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/3045da1742ee0e75392de1623900d7d88b08f0b4
internal/dnsforward/dnsforward_http.go
upstreams := stringArrayDup(s.conf.UpstreamDNS) upstreamFile := s.conf.UpstreamDNSFileName bootstraps := stringArrayDup(s.conf.BootstrapDNS) protectionEnabled := s.conf.ProtectionEnabled blockingMode := s.conf.BlockingMode BlockingIPv4 := s.conf.BlockingIPv4 BlockingIPv6 := s.conf.BlockingIPv6 Ratelimit := s.conf.Ratelimit EnableEDNSClientSubnet := s.conf.EnableEDNSClientSubnet EnableDNSSEC := s.conf.EnableDNSSEC AAAADisabled := s.conf.AAAADisabled CacheSize := s.conf.CacheSize CacheMinTTL := s.conf.CacheMinTTL CacheMaxTTL := s.conf.CacheMaxTTL var upstreamMode string
<mask> <mask> func (s *Server) handleGetConfig(w http.ResponseWriter, r *http.Request) { <mask> resp := dnsConfigJSON{} <mask> s.RLock() <mask> resp.Upstreams = stringArrayDup(s.conf.UpstreamDNS) <mask> resp.UpstreamsFile = s.conf.UpstreamDNSFileName <mask> resp.Bootstraps = stringArrayDup(s.conf.BootstrapDNS) <mask> <mask> resp.ProtectionEnabled = s.conf.ProtectionEnabled <mask> resp.BlockingMode = s.conf.BlockingMode <mask> resp.BlockingIPv4 = s.conf.BlockingIPv4 <mask> resp.BlockingIPv6 = s.conf.BlockingIPv6 <mask> resp.RateLimit = s.conf.Ratelimit <mask> resp.EDNSCSEnabled = s.conf.EnableEDNSClientSubnet <mask> resp.DNSSECEnabled = s.conf.EnableDNSSEC <mask> resp.DisableIPv6 = s.conf.AAAADisabled <mask> resp.CacheSize = s.conf.CacheSize <mask> resp.CacheMinTTL = s.conf.CacheMinTTL <mask> resp.CacheMaxTTL = s.conf.CacheMaxTTL <mask> if s.conf.FastestAddr { <mask> resp.UpstreamMode = "fastest_addr" <mask> } else if s.conf.AllServers { <mask> resp.UpstreamMode = "parallel" <mask> } </s> Pull request: 2271 handle nolint Merge in DNS/adguard-home from 2271-handle-nolint to master Closes #2271. Squashed commit of the following: commit fde5c8795ac79e1f7d02ba8c8e369b5a724a000e Merge: fc2acd898 642dcd647 Author: Eugene Burkov <[email protected]> Date: Fri Nov 20 17:12:28 2020 +0300 Merge branch 'master' into 2271-handle-nolint commit fc2acd89871de08c39e80ace9e5bb8a7acb7afba Author: Eugene Burkov <[email protected]> Date: Tue Nov 17 11:55:29 2020 +0300 dnsforward: fix test output strings commit c4ebae6ea9c293bad239519c44ca5a6c576bb921 Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 22:43:20 2020 +0300 dnsfilter: make package pass tests commit f2d98c6acabd8977f3b1b361987eaa31eb6eb9ad Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 20:05:00 2020 +0300 querylog: make decoding pass tests commit ab5850d24c50d53b8393f2de448cc340241351d7 Merge: 6ed2066bf 8a9c6e8a0 Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 19:48:31 2020 +0300 Merge branch 'master' into 2271-handle-nolint commit 6ed2066bf567e13dd14cfa16fc7b109b59fa39ef Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 18:13:45 2020 +0300 home: fix tests naming commit af691081fb02b7500a746b16492f01f7f9befe9a Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 12:15:49 2020 +0300 home: impove code quality commit 2914cd3cd23ef2a1964116baab9187d89b377f86 Author: Eugene Burkov <[email protected]> Date: Wed Nov 11 15:46:39 2020 +0300 * querylog: remove useless check commit 9996840650e784ccc76d1f29964560435ba27dc7 Author: Eugene Burkov <[email protected]> Date: Wed Nov 11 13:18:34 2020 +0300 * all: fix noticed defects commit 2b15293e59337f70302fbc0db81ebb26bee0bed2 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 20:15:53 2020 +0300 * stats: remove last nolint directive commit b2e1ddf7b58196a2fdbf879f084edb41ca1aa1eb Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 18:35:41 2020 +0300 * all: remove another nolint directive commit c6fc5cfcc9c95ab9e570a95ab41c3e5c0125e62e Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 18:11:28 2020 +0300 * querylog: remove nolint directive commit 226ddbf2c92f737f085b44a4ddf6daec7b602153 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 16:35:26 2020 +0300 * home: remove nolint directive commit 2ea3086ad41e9003282add7e996ae722d72d878b Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 16:13:57 2020 +0300 * home: reduce cyclomatic complexity of run function commit f479b480c48e0bb832ddef8f57586f56b8a55bab Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 15:35:46 2020 +0300 * home: use crypto/rand instead of math/rand commit a28d4a53e3b930136b036606fc7e78404f1d208b Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 14:11:07 2020 +0300 * dnsforward: remove gocyclo nolint directive commit 64a0a324cc2b20614ceec3ccc6505e960fe526e9 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 11:45:49 2020 +0300 all *: remove some nolint directives Updates #2271. </s> remove resp.UpstreamMode = "fastest_addr" </s> add upstreamMode = "fastest_addr" </s> remove func (s *Server) handleGetConfig(w http.ResponseWriter, r *http.Request) { resp := dnsConfigJSON{} </s> add func (s *Server) getDNSConfig() dnsConfig { </s> remove resp.UpstreamMode = "parallel" </s> add upstreamMode = "parallel" </s> remove if js.Exists("blocking_mode") { s.conf.BlockingMode = req.BlockingMode if req.BlockingMode == "custom_ip" { if js.Exists("blocking_ipv4") { s.conf.BlockingIPv4 = req.BlockingIPv4 s.conf.BlockingIPAddrv4 = net.ParseIP(req.BlockingIPv4) } if js.Exists("blocking_ipv6") { s.conf.BlockingIPv6 = req.BlockingIPv6 s.conf.BlockingIPAddrv6 = net.ParseIP(req.BlockingIPv6) } </s> add if dc.BlockingMode != nil { s.conf.BlockingMode = *dc.BlockingMode if *dc.BlockingMode == "custom_ip" { s.conf.BlockingIPv4 = *dc.BlockingIPv4 s.conf.BlockingIPAddrv4 = net.ParseIP(*dc.BlockingIPv4) s.conf.BlockingIPv6 = *dc.BlockingIPv6 s.conf.BlockingIPAddrv6 = net.ParseIP(*dc.BlockingIPv6) </s> remove js, err := json.Marshal(resp) if err != nil { httpError(r, w, http.StatusInternalServerError, "json.Marshal: %s", err) </s> add func (s *Server) handleGetConfig(w http.ResponseWriter, r *http.Request) { resp := s.getDNSConfig() w.Header().Set("Content-Type", "application/json") enc := json.NewEncoder(w) if err := enc.Encode(resp); err != nil { httpError(r, w, http.StatusInternalServerError, "json.Encoder: %s", err)
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/3045da1742ee0e75392de1623900d7d88b08f0b4
internal/dnsforward/dnsforward_http.go
upstreamMode = "fastest_addr"
<mask> resp.CacheSize = s.conf.CacheSize <mask> resp.CacheMinTTL = s.conf.CacheMinTTL <mask> resp.CacheMaxTTL = s.conf.CacheMaxTTL <mask> if s.conf.FastestAddr { <mask> resp.UpstreamMode = "fastest_addr" <mask> } else if s.conf.AllServers { <mask> resp.UpstreamMode = "parallel" <mask> } <mask> s.RUnlock() <mask> </s> Pull request: 2271 handle nolint Merge in DNS/adguard-home from 2271-handle-nolint to master Closes #2271. Squashed commit of the following: commit fde5c8795ac79e1f7d02ba8c8e369b5a724a000e Merge: fc2acd898 642dcd647 Author: Eugene Burkov <[email protected]> Date: Fri Nov 20 17:12:28 2020 +0300 Merge branch 'master' into 2271-handle-nolint commit fc2acd89871de08c39e80ace9e5bb8a7acb7afba Author: Eugene Burkov <[email protected]> Date: Tue Nov 17 11:55:29 2020 +0300 dnsforward: fix test output strings commit c4ebae6ea9c293bad239519c44ca5a6c576bb921 Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 22:43:20 2020 +0300 dnsfilter: make package pass tests commit f2d98c6acabd8977f3b1b361987eaa31eb6eb9ad Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 20:05:00 2020 +0300 querylog: make decoding pass tests commit ab5850d24c50d53b8393f2de448cc340241351d7 Merge: 6ed2066bf 8a9c6e8a0 Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 19:48:31 2020 +0300 Merge branch 'master' into 2271-handle-nolint commit 6ed2066bf567e13dd14cfa16fc7b109b59fa39ef Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 18:13:45 2020 +0300 home: fix tests naming commit af691081fb02b7500a746b16492f01f7f9befe9a Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 12:15:49 2020 +0300 home: impove code quality commit 2914cd3cd23ef2a1964116baab9187d89b377f86 Author: Eugene Burkov <[email protected]> Date: Wed Nov 11 15:46:39 2020 +0300 * querylog: remove useless check commit 9996840650e784ccc76d1f29964560435ba27dc7 Author: Eugene Burkov <[email protected]> Date: Wed Nov 11 13:18:34 2020 +0300 * all: fix noticed defects commit 2b15293e59337f70302fbc0db81ebb26bee0bed2 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 20:15:53 2020 +0300 * stats: remove last nolint directive commit b2e1ddf7b58196a2fdbf879f084edb41ca1aa1eb Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 18:35:41 2020 +0300 * all: remove another nolint directive commit c6fc5cfcc9c95ab9e570a95ab41c3e5c0125e62e Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 18:11:28 2020 +0300 * querylog: remove nolint directive commit 226ddbf2c92f737f085b44a4ddf6daec7b602153 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 16:35:26 2020 +0300 * home: remove nolint directive commit 2ea3086ad41e9003282add7e996ae722d72d878b Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 16:13:57 2020 +0300 * home: reduce cyclomatic complexity of run function commit f479b480c48e0bb832ddef8f57586f56b8a55bab Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 15:35:46 2020 +0300 * home: use crypto/rand instead of math/rand commit a28d4a53e3b930136b036606fc7e78404f1d208b Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 14:11:07 2020 +0300 * dnsforward: remove gocyclo nolint directive commit 64a0a324cc2b20614ceec3ccc6505e960fe526e9 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 11:45:49 2020 +0300 all *: remove some nolint directives Updates #2271. </s> remove resp.UpstreamMode = "parallel" </s> add upstreamMode = "parallel" </s> remove resp.Upstreams = stringArrayDup(s.conf.UpstreamDNS) resp.UpstreamsFile = s.conf.UpstreamDNSFileName resp.Bootstraps = stringArrayDup(s.conf.BootstrapDNS) resp.ProtectionEnabled = s.conf.ProtectionEnabled resp.BlockingMode = s.conf.BlockingMode resp.BlockingIPv4 = s.conf.BlockingIPv4 resp.BlockingIPv6 = s.conf.BlockingIPv6 resp.RateLimit = s.conf.Ratelimit resp.EDNSCSEnabled = s.conf.EnableEDNSClientSubnet resp.DNSSECEnabled = s.conf.EnableDNSSEC resp.DisableIPv6 = s.conf.AAAADisabled resp.CacheSize = s.conf.CacheSize resp.CacheMinTTL = s.conf.CacheMinTTL resp.CacheMaxTTL = s.conf.CacheMaxTTL </s> add upstreams := stringArrayDup(s.conf.UpstreamDNS) upstreamFile := s.conf.UpstreamDNSFileName bootstraps := stringArrayDup(s.conf.BootstrapDNS) protectionEnabled := s.conf.ProtectionEnabled blockingMode := s.conf.BlockingMode BlockingIPv4 := s.conf.BlockingIPv4 BlockingIPv6 := s.conf.BlockingIPv6 Ratelimit := s.conf.Ratelimit EnableEDNSClientSubnet := s.conf.EnableEDNSClientSubnet EnableDNSSEC := s.conf.EnableDNSSEC AAAADisabled := s.conf.AAAADisabled CacheSize := s.conf.CacheSize CacheMinTTL := s.conf.CacheMinTTL CacheMaxTTL := s.conf.CacheMaxTTL var upstreamMode string </s> remove if js.Exists("cache_ttl_min") { s.conf.CacheMinTTL = req.CacheMinTTL </s> add if dc.CacheMinTTL != nil { s.conf.CacheMinTTL = *dc.CacheMinTTL </s> remove if js.Exists("cache_ttl_max") { s.conf.CacheMaxTTL = req.CacheMaxTTL </s> add if dc.CacheMaxTTL != nil { s.conf.CacheMaxTTL = *dc.CacheMaxTTL </s> remove if js.Exists("upstream_mode") { s.conf.FastestAddr = false s.conf.AllServers = false switch req.UpstreamMode { case "": // </s> add if dc.UpstreamMode != nil { switch *dc.UpstreamMode {
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/3045da1742ee0e75392de1623900d7d88b08f0b4
internal/dnsforward/dnsforward_http.go
upstreamMode = "parallel"
<mask> resp.CacheMaxTTL = s.conf.CacheMaxTTL <mask> if s.conf.FastestAddr { <mask> resp.UpstreamMode = "fastest_addr" <mask> } else if s.conf.AllServers { <mask> resp.UpstreamMode = "parallel" <mask> } <mask> s.RUnlock() <mask> <mask> js, err := json.Marshal(resp) <mask> if err != nil { </s> Pull request: 2271 handle nolint Merge in DNS/adguard-home from 2271-handle-nolint to master Closes #2271. Squashed commit of the following: commit fde5c8795ac79e1f7d02ba8c8e369b5a724a000e Merge: fc2acd898 642dcd647 Author: Eugene Burkov <[email protected]> Date: Fri Nov 20 17:12:28 2020 +0300 Merge branch 'master' into 2271-handle-nolint commit fc2acd89871de08c39e80ace9e5bb8a7acb7afba Author: Eugene Burkov <[email protected]> Date: Tue Nov 17 11:55:29 2020 +0300 dnsforward: fix test output strings commit c4ebae6ea9c293bad239519c44ca5a6c576bb921 Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 22:43:20 2020 +0300 dnsfilter: make package pass tests commit f2d98c6acabd8977f3b1b361987eaa31eb6eb9ad Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 20:05:00 2020 +0300 querylog: make decoding pass tests commit ab5850d24c50d53b8393f2de448cc340241351d7 Merge: 6ed2066bf 8a9c6e8a0 Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 19:48:31 2020 +0300 Merge branch 'master' into 2271-handle-nolint commit 6ed2066bf567e13dd14cfa16fc7b109b59fa39ef Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 18:13:45 2020 +0300 home: fix tests naming commit af691081fb02b7500a746b16492f01f7f9befe9a Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 12:15:49 2020 +0300 home: impove code quality commit 2914cd3cd23ef2a1964116baab9187d89b377f86 Author: Eugene Burkov <[email protected]> Date: Wed Nov 11 15:46:39 2020 +0300 * querylog: remove useless check commit 9996840650e784ccc76d1f29964560435ba27dc7 Author: Eugene Burkov <[email protected]> Date: Wed Nov 11 13:18:34 2020 +0300 * all: fix noticed defects commit 2b15293e59337f70302fbc0db81ebb26bee0bed2 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 20:15:53 2020 +0300 * stats: remove last nolint directive commit b2e1ddf7b58196a2fdbf879f084edb41ca1aa1eb Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 18:35:41 2020 +0300 * all: remove another nolint directive commit c6fc5cfcc9c95ab9e570a95ab41c3e5c0125e62e Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 18:11:28 2020 +0300 * querylog: remove nolint directive commit 226ddbf2c92f737f085b44a4ddf6daec7b602153 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 16:35:26 2020 +0300 * home: remove nolint directive commit 2ea3086ad41e9003282add7e996ae722d72d878b Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 16:13:57 2020 +0300 * home: reduce cyclomatic complexity of run function commit f479b480c48e0bb832ddef8f57586f56b8a55bab Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 15:35:46 2020 +0300 * home: use crypto/rand instead of math/rand commit a28d4a53e3b930136b036606fc7e78404f1d208b Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 14:11:07 2020 +0300 * dnsforward: remove gocyclo nolint directive commit 64a0a324cc2b20614ceec3ccc6505e960fe526e9 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 11:45:49 2020 +0300 all *: remove some nolint directives Updates #2271. </s> remove resp.UpstreamMode = "fastest_addr" </s> add upstreamMode = "fastest_addr" </s> remove js, err := json.Marshal(resp) if err != nil { httpError(r, w, http.StatusInternalServerError, "json.Marshal: %s", err) </s> add func (s *Server) handleGetConfig(w http.ResponseWriter, r *http.Request) { resp := s.getDNSConfig() w.Header().Set("Content-Type", "application/json") enc := json.NewEncoder(w) if err := enc.Encode(resp); err != nil { httpError(r, w, http.StatusInternalServerError, "json.Encoder: %s", err) </s> remove resp.Upstreams = stringArrayDup(s.conf.UpstreamDNS) resp.UpstreamsFile = s.conf.UpstreamDNSFileName resp.Bootstraps = stringArrayDup(s.conf.BootstrapDNS) resp.ProtectionEnabled = s.conf.ProtectionEnabled resp.BlockingMode = s.conf.BlockingMode resp.BlockingIPv4 = s.conf.BlockingIPv4 resp.BlockingIPv6 = s.conf.BlockingIPv6 resp.RateLimit = s.conf.Ratelimit resp.EDNSCSEnabled = s.conf.EnableEDNSClientSubnet resp.DNSSECEnabled = s.conf.EnableDNSSEC resp.DisableIPv6 = s.conf.AAAADisabled resp.CacheSize = s.conf.CacheSize resp.CacheMinTTL = s.conf.CacheMinTTL resp.CacheMaxTTL = s.conf.CacheMaxTTL </s> add upstreams := stringArrayDup(s.conf.UpstreamDNS) upstreamFile := s.conf.UpstreamDNSFileName bootstraps := stringArrayDup(s.conf.BootstrapDNS) protectionEnabled := s.conf.ProtectionEnabled blockingMode := s.conf.BlockingMode BlockingIPv4 := s.conf.BlockingIPv4 BlockingIPv6 := s.conf.BlockingIPv6 Ratelimit := s.conf.Ratelimit EnableEDNSClientSubnet := s.conf.EnableEDNSClientSubnet EnableDNSSEC := s.conf.EnableDNSSEC AAAADisabled := s.conf.AAAADisabled CacheSize := s.conf.CacheSize CacheMinTTL := s.conf.CacheMinTTL CacheMaxTTL := s.conf.CacheMaxTTL var upstreamMode string </s> remove if js.Exists("upstream_mode") { s.conf.FastestAddr = false s.conf.AllServers = false switch req.UpstreamMode { case "": // </s> add if dc.UpstreamMode != nil { switch *dc.UpstreamMode { </s> remove if js.Exists("cache_ttl_max") { s.conf.CacheMaxTTL = req.CacheMaxTTL </s> add if dc.CacheMaxTTL != nil { s.conf.CacheMaxTTL = *dc.CacheMaxTTL
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/3045da1742ee0e75392de1623900d7d88b08f0b4
internal/dnsforward/dnsforward_http.go
func (s *Server) handleGetConfig(w http.ResponseWriter, r *http.Request) { resp := s.getDNSConfig() w.Header().Set("Content-Type", "application/json") enc := json.NewEncoder(w) if err := enc.Encode(resp); err != nil { httpError(r, w, http.StatusInternalServerError, "json.Encoder: %s", err)
<mask> resp.UpstreamMode = "parallel" <mask> } <mask> s.RUnlock() <mask> <mask> js, err := json.Marshal(resp) <mask> if err != nil { <mask> httpError(r, w, http.StatusInternalServerError, "json.Marshal: %s", err) <mask> return <mask> } <mask> w.Header().Set("Content-Type", "application/json") <mask> _, _ = w.Write(js) <mask> } </s> Pull request: 2271 handle nolint Merge in DNS/adguard-home from 2271-handle-nolint to master Closes #2271. Squashed commit of the following: commit fde5c8795ac79e1f7d02ba8c8e369b5a724a000e Merge: fc2acd898 642dcd647 Author: Eugene Burkov <[email protected]> Date: Fri Nov 20 17:12:28 2020 +0300 Merge branch 'master' into 2271-handle-nolint commit fc2acd89871de08c39e80ace9e5bb8a7acb7afba Author: Eugene Burkov <[email protected]> Date: Tue Nov 17 11:55:29 2020 +0300 dnsforward: fix test output strings commit c4ebae6ea9c293bad239519c44ca5a6c576bb921 Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 22:43:20 2020 +0300 dnsfilter: make package pass tests commit f2d98c6acabd8977f3b1b361987eaa31eb6eb9ad Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 20:05:00 2020 +0300 querylog: make decoding pass tests commit ab5850d24c50d53b8393f2de448cc340241351d7 Merge: 6ed2066bf 8a9c6e8a0 Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 19:48:31 2020 +0300 Merge branch 'master' into 2271-handle-nolint commit 6ed2066bf567e13dd14cfa16fc7b109b59fa39ef Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 18:13:45 2020 +0300 home: fix tests naming commit af691081fb02b7500a746b16492f01f7f9befe9a Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 12:15:49 2020 +0300 home: impove code quality commit 2914cd3cd23ef2a1964116baab9187d89b377f86 Author: Eugene Burkov <[email protected]> Date: Wed Nov 11 15:46:39 2020 +0300 * querylog: remove useless check commit 9996840650e784ccc76d1f29964560435ba27dc7 Author: Eugene Burkov <[email protected]> Date: Wed Nov 11 13:18:34 2020 +0300 * all: fix noticed defects commit 2b15293e59337f70302fbc0db81ebb26bee0bed2 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 20:15:53 2020 +0300 * stats: remove last nolint directive commit b2e1ddf7b58196a2fdbf879f084edb41ca1aa1eb Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 18:35:41 2020 +0300 * all: remove another nolint directive commit c6fc5cfcc9c95ab9e570a95ab41c3e5c0125e62e Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 18:11:28 2020 +0300 * querylog: remove nolint directive commit 226ddbf2c92f737f085b44a4ddf6daec7b602153 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 16:35:26 2020 +0300 * home: remove nolint directive commit 2ea3086ad41e9003282add7e996ae722d72d878b Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 16:13:57 2020 +0300 * home: reduce cyclomatic complexity of run function commit f479b480c48e0bb832ddef8f57586f56b8a55bab Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 15:35:46 2020 +0300 * home: use crypto/rand instead of math/rand commit a28d4a53e3b930136b036606fc7e78404f1d208b Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 14:11:07 2020 +0300 * dnsforward: remove gocyclo nolint directive commit 64a0a324cc2b20614ceec3ccc6505e960fe526e9 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 11:45:49 2020 +0300 all *: remove some nolint directives Updates #2271. </s> remove w.Header().Set("Content-Type", "application/json") _, _ = w.Write(js) </s> add </s> remove resp.UpstreamMode = "parallel" </s> add upstreamMode = "parallel" </s> remove if js.Exists("upstream_dns") { err = ValidateUpstreams(req.Upstreams) if err != nil { </s> add if req.Upstreams != nil { if err := ValidateUpstreams(*req.Upstreams); err != nil { </s> remove restart := false </s> add if s.setConfig(req) { if err := s.Reconfigure(nil); err != nil { httpError(r, w, http.StatusInternalServerError, "%s", err) return } } } func (s *Server) setConfig(dc dnsConfig) (restart bool) { </s> remove req := dnsConfigJSON{} js, err := jsonutil.DecodeObject(&req, r.Body) if err != nil { httpError(r, w, http.StatusBadRequest, "json.Decode: %s", err) </s> add req := dnsConfig{} dec := json.NewDecoder(r.Body) if err := dec.Decode(&req); err != nil { httpError(r, w, http.StatusBadRequest, "json Encode: %s", err)
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/3045da1742ee0e75392de1623900d7d88b08f0b4
internal/dnsforward/dnsforward_http.go
<mask> if err != nil { <mask> httpError(r, w, http.StatusInternalServerError, "json.Marshal: %s", err) <mask> return <mask> } <mask> w.Header().Set("Content-Type", "application/json") <mask> _, _ = w.Write(js) <mask> } <mask> <mask> func checkBlockingMode(req dnsConfigJSON) bool { <mask> bm := req.BlockingMode <mask> if !(bm == "default" || bm == "refused" || bm == "nxdomain" || bm == "null_ip" || bm == "custom_ip") { </s> Pull request: 2271 handle nolint Merge in DNS/adguard-home from 2271-handle-nolint to master Closes #2271. Squashed commit of the following: commit fde5c8795ac79e1f7d02ba8c8e369b5a724a000e Merge: fc2acd898 642dcd647 Author: Eugene Burkov <[email protected]> Date: Fri Nov 20 17:12:28 2020 +0300 Merge branch 'master' into 2271-handle-nolint commit fc2acd89871de08c39e80ace9e5bb8a7acb7afba Author: Eugene Burkov <[email protected]> Date: Tue Nov 17 11:55:29 2020 +0300 dnsforward: fix test output strings commit c4ebae6ea9c293bad239519c44ca5a6c576bb921 Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 22:43:20 2020 +0300 dnsfilter: make package pass tests commit f2d98c6acabd8977f3b1b361987eaa31eb6eb9ad Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 20:05:00 2020 +0300 querylog: make decoding pass tests commit ab5850d24c50d53b8393f2de448cc340241351d7 Merge: 6ed2066bf 8a9c6e8a0 Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 19:48:31 2020 +0300 Merge branch 'master' into 2271-handle-nolint commit 6ed2066bf567e13dd14cfa16fc7b109b59fa39ef Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 18:13:45 2020 +0300 home: fix tests naming commit af691081fb02b7500a746b16492f01f7f9befe9a Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 12:15:49 2020 +0300 home: impove code quality commit 2914cd3cd23ef2a1964116baab9187d89b377f86 Author: Eugene Burkov <[email protected]> Date: Wed Nov 11 15:46:39 2020 +0300 * querylog: remove useless check commit 9996840650e784ccc76d1f29964560435ba27dc7 Author: Eugene Burkov <[email protected]> Date: Wed Nov 11 13:18:34 2020 +0300 * all: fix noticed defects commit 2b15293e59337f70302fbc0db81ebb26bee0bed2 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 20:15:53 2020 +0300 * stats: remove last nolint directive commit b2e1ddf7b58196a2fdbf879f084edb41ca1aa1eb Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 18:35:41 2020 +0300 * all: remove another nolint directive commit c6fc5cfcc9c95ab9e570a95ab41c3e5c0125e62e Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 18:11:28 2020 +0300 * querylog: remove nolint directive commit 226ddbf2c92f737f085b44a4ddf6daec7b602153 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 16:35:26 2020 +0300 * home: remove nolint directive commit 2ea3086ad41e9003282add7e996ae722d72d878b Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 16:13:57 2020 +0300 * home: reduce cyclomatic complexity of run function commit f479b480c48e0bb832ddef8f57586f56b8a55bab Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 15:35:46 2020 +0300 * home: use crypto/rand instead of math/rand commit a28d4a53e3b930136b036606fc7e78404f1d208b Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 14:11:07 2020 +0300 * dnsforward: remove gocyclo nolint directive commit 64a0a324cc2b20614ceec3ccc6505e960fe526e9 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 11:45:49 2020 +0300 all *: remove some nolint directives Updates #2271. </s> remove func checkBlockingMode(req dnsConfigJSON) bool { bm := req.BlockingMode if !(bm == "default" || bm == "refused" || bm == "nxdomain" || bm == "null_ip" || bm == "custom_ip") { return false </s> add func (req *dnsConfig) checkBlockingMode() bool { if req.BlockingMode == nil { return true </s> remove ip := net.ParseIP(req.BlockingIPv4) if ip == nil || ip.To4() == nil { </s> add if req.BlockingIPv4 == nil || req.BlockingIPv6 == nil { </s> remove js, err := json.Marshal(resp) if err != nil { httpError(r, w, http.StatusInternalServerError, "json.Marshal: %s", err) </s> add func (s *Server) handleGetConfig(w http.ResponseWriter, r *http.Request) { resp := s.getDNSConfig() w.Header().Set("Content-Type", "application/json") enc := json.NewEncoder(w) if err := enc.Encode(resp); err != nil { httpError(r, w, http.StatusInternalServerError, "json.Encoder: %s", err) </s> remove if js.Exists("upstream_mode") && !(req.UpstreamMode == "" || req.UpstreamMode == "fastest_addr" || req.UpstreamMode == "parallel") { </s> add if !req.checkUpstreamsMode() {
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/3045da1742ee0e75392de1623900d7d88b08f0b4
internal/dnsforward/dnsforward_http.go
func (req *dnsConfig) checkBlockingMode() bool { if req.BlockingMode == nil { return true
<mask> w.Header().Set("Content-Type", "application/json") <mask> _, _ = w.Write(js) <mask> } <mask> <mask> func checkBlockingMode(req dnsConfigJSON) bool { <mask> bm := req.BlockingMode <mask> if !(bm == "default" || bm == "refused" || bm == "nxdomain" || bm == "null_ip" || bm == "custom_ip") { <mask> return false <mask> } <mask> <mask> if bm == "custom_ip" { <mask> ip := net.ParseIP(req.BlockingIPv4) <mask> if ip == nil || ip.To4() == nil { </s> Pull request: 2271 handle nolint Merge in DNS/adguard-home from 2271-handle-nolint to master Closes #2271. Squashed commit of the following: commit fde5c8795ac79e1f7d02ba8c8e369b5a724a000e Merge: fc2acd898 642dcd647 Author: Eugene Burkov <[email protected]> Date: Fri Nov 20 17:12:28 2020 +0300 Merge branch 'master' into 2271-handle-nolint commit fc2acd89871de08c39e80ace9e5bb8a7acb7afba Author: Eugene Burkov <[email protected]> Date: Tue Nov 17 11:55:29 2020 +0300 dnsforward: fix test output strings commit c4ebae6ea9c293bad239519c44ca5a6c576bb921 Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 22:43:20 2020 +0300 dnsfilter: make package pass tests commit f2d98c6acabd8977f3b1b361987eaa31eb6eb9ad Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 20:05:00 2020 +0300 querylog: make decoding pass tests commit ab5850d24c50d53b8393f2de448cc340241351d7 Merge: 6ed2066bf 8a9c6e8a0 Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 19:48:31 2020 +0300 Merge branch 'master' into 2271-handle-nolint commit 6ed2066bf567e13dd14cfa16fc7b109b59fa39ef Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 18:13:45 2020 +0300 home: fix tests naming commit af691081fb02b7500a746b16492f01f7f9befe9a Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 12:15:49 2020 +0300 home: impove code quality commit 2914cd3cd23ef2a1964116baab9187d89b377f86 Author: Eugene Burkov <[email protected]> Date: Wed Nov 11 15:46:39 2020 +0300 * querylog: remove useless check commit 9996840650e784ccc76d1f29964560435ba27dc7 Author: Eugene Burkov <[email protected]> Date: Wed Nov 11 13:18:34 2020 +0300 * all: fix noticed defects commit 2b15293e59337f70302fbc0db81ebb26bee0bed2 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 20:15:53 2020 +0300 * stats: remove last nolint directive commit b2e1ddf7b58196a2fdbf879f084edb41ca1aa1eb Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 18:35:41 2020 +0300 * all: remove another nolint directive commit c6fc5cfcc9c95ab9e570a95ab41c3e5c0125e62e Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 18:11:28 2020 +0300 * querylog: remove nolint directive commit 226ddbf2c92f737f085b44a4ddf6daec7b602153 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 16:35:26 2020 +0300 * home: remove nolint directive commit 2ea3086ad41e9003282add7e996ae722d72d878b Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 16:13:57 2020 +0300 * home: reduce cyclomatic complexity of run function commit f479b480c48e0bb832ddef8f57586f56b8a55bab Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 15:35:46 2020 +0300 * home: use crypto/rand instead of math/rand commit a28d4a53e3b930136b036606fc7e78404f1d208b Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 14:11:07 2020 +0300 * dnsforward: remove gocyclo nolint directive commit 64a0a324cc2b20614ceec3ccc6505e960fe526e9 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 11:45:49 2020 +0300 all *: remove some nolint directives Updates #2271. </s> remove w.Header().Set("Content-Type", "application/json") _, _ = w.Write(js) </s> add </s> remove ip := net.ParseIP(req.BlockingIPv4) if ip == nil || ip.To4() == nil { </s> add if req.BlockingIPv4 == nil || req.BlockingIPv6 == nil { </s> remove ip = net.ParseIP(req.BlockingIPv6) if ip == nil { </s> add ip4 := net.ParseIP(*req.BlockingIPv4) if ip4 == nil || ip4.To4() == nil { </s> remove // nolint (gocyclo) // Return TRUE if IP is within public Internet IP range func isPublicIP(ip net.IP) bool { ip4 := ip.To4() if ip4 != nil { switch ip4[0] { case 0: return false // software case 10: return false // private network case 127: return false // loopback case 169: if ip4[1] == 254 { return false // link-local } case 172: if ip4[1] >= 16 && ip4[1] <= 31 { return false // private network } case 192: if (ip4[1] == 0 && ip4[2] == 0) || // private network (ip4[1] == 0 && ip4[2] == 2) || // documentation (ip4[1] == 88 && ip4[2] == 99) || // reserved (ip4[1] == 168) { // private network return false } case 198: if (ip4[1] == 18 || ip4[2] == 19) || // private network (ip4[1] == 51 || ip4[2] == 100) { // documentation return false } case 203: if ip4[1] == 0 && ip4[2] == 113 { // documentation return false } case 224: if ip4[1] == 0 && ip4[2] == 0 { // multicast return false } case 255: if ip4[1] == 255 && ip4[2] == 255 && ip4[3] == 255 { // subnet return false } } } else { if ip.IsLoopback() || ip.IsLinkLocalMulticast() || ip.IsLinkLocalUnicast() { return false } } return true } </s> add
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/3045da1742ee0e75392de1623900d7d88b08f0b4
internal/dnsforward/dnsforward_http.go
bm := *req.BlockingMode
<mask> if req.BlockingMode == nil { <mask> return true <mask> } <mask> <mask> if bm == "custom_ip" { <mask> if req.BlockingIPv4 == nil || req.BlockingIPv6 == nil { <mask> return false <mask> } <mask> </s> Pull request: 2271 handle nolint Merge in DNS/adguard-home from 2271-handle-nolint to master Closes #2271. Squashed commit of the following: commit fde5c8795ac79e1f7d02ba8c8e369b5a724a000e Merge: fc2acd898 642dcd647 Author: Eugene Burkov <[email protected]> Date: Fri Nov 20 17:12:28 2020 +0300 Merge branch 'master' into 2271-handle-nolint commit fc2acd89871de08c39e80ace9e5bb8a7acb7afba Author: Eugene Burkov <[email protected]> Date: Tue Nov 17 11:55:29 2020 +0300 dnsforward: fix test output strings commit c4ebae6ea9c293bad239519c44ca5a6c576bb921 Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 22:43:20 2020 +0300 dnsfilter: make package pass tests commit f2d98c6acabd8977f3b1b361987eaa31eb6eb9ad Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 20:05:00 2020 +0300 querylog: make decoding pass tests commit ab5850d24c50d53b8393f2de448cc340241351d7 Merge: 6ed2066bf 8a9c6e8a0 Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 19:48:31 2020 +0300 Merge branch 'master' into 2271-handle-nolint commit 6ed2066bf567e13dd14cfa16fc7b109b59fa39ef Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 18:13:45 2020 +0300 home: fix tests naming commit af691081fb02b7500a746b16492f01f7f9befe9a Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 12:15:49 2020 +0300 home: impove code quality commit 2914cd3cd23ef2a1964116baab9187d89b377f86 Author: Eugene Burkov <[email protected]> Date: Wed Nov 11 15:46:39 2020 +0300 * querylog: remove useless check commit 9996840650e784ccc76d1f29964560435ba27dc7 Author: Eugene Burkov <[email protected]> Date: Wed Nov 11 13:18:34 2020 +0300 * all: fix noticed defects commit 2b15293e59337f70302fbc0db81ebb26bee0bed2 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 20:15:53 2020 +0300 * stats: remove last nolint directive commit b2e1ddf7b58196a2fdbf879f084edb41ca1aa1eb Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 18:35:41 2020 +0300 * all: remove another nolint directive commit c6fc5cfcc9c95ab9e570a95ab41c3e5c0125e62e Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 18:11:28 2020 +0300 * querylog: remove nolint directive commit 226ddbf2c92f737f085b44a4ddf6daec7b602153 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 16:35:26 2020 +0300 * home: remove nolint directive commit 2ea3086ad41e9003282add7e996ae722d72d878b Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 16:13:57 2020 +0300 * home: reduce cyclomatic complexity of run function commit f479b480c48e0bb832ddef8f57586f56b8a55bab Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 15:35:46 2020 +0300 * home: use crypto/rand instead of math/rand commit a28d4a53e3b930136b036606fc7e78404f1d208b Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 14:11:07 2020 +0300 * dnsforward: remove gocyclo nolint directive commit 64a0a324cc2b20614ceec3ccc6505e960fe526e9 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 11:45:49 2020 +0300 all *: remove some nolint directives Updates #2271. </s> remove ip := net.ParseIP(req.BlockingIPv4) if ip == nil || ip.To4() == nil { </s> add if req.BlockingIPv4 == nil || req.BlockingIPv6 == nil { </s> remove func checkBlockingMode(req dnsConfigJSON) bool { bm := req.BlockingMode if !(bm == "default" || bm == "refused" || bm == "nxdomain" || bm == "null_ip" || bm == "custom_ip") { return false </s> add func (req *dnsConfig) checkBlockingMode() bool { if req.BlockingMode == nil { return true </s> remove if js.Exists("blocking_mode") { s.conf.BlockingMode = req.BlockingMode if req.BlockingMode == "custom_ip" { if js.Exists("blocking_ipv4") { s.conf.BlockingIPv4 = req.BlockingIPv4 s.conf.BlockingIPAddrv4 = net.ParseIP(req.BlockingIPv4) } if js.Exists("blocking_ipv6") { s.conf.BlockingIPv6 = req.BlockingIPv6 s.conf.BlockingIPAddrv6 = net.ParseIP(req.BlockingIPv6) } </s> add if dc.BlockingMode != nil { s.conf.BlockingMode = *dc.BlockingMode if *dc.BlockingMode == "custom_ip" { s.conf.BlockingIPv4 = *dc.BlockingIPv4 s.conf.BlockingIPAddrv4 = net.ParseIP(*dc.BlockingIPv4) s.conf.BlockingIPv6 = *dc.BlockingIPv6 s.conf.BlockingIPAddrv6 = net.ParseIP(*dc.BlockingIPv6) </s> remove w.Header().Set("Content-Type", "application/json") _, _ = w.Write(js) </s> add </s> remove ip = net.ParseIP(req.BlockingIPv6) if ip == nil { </s> add ip4 := net.ParseIP(*req.BlockingIPv4) if ip4 == nil || ip4.To4() == nil {
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/3045da1742ee0e75392de1623900d7d88b08f0b4
internal/dnsforward/dnsforward_http.go
if req.BlockingIPv4 == nil || req.BlockingIPv6 == nil {
<mask> return false <mask> } <mask> <mask> if bm == "custom_ip" { <mask> ip := net.ParseIP(req.BlockingIPv4) <mask> if ip == nil || ip.To4() == nil { <mask> return false <mask> } <mask> <mask> ip = net.ParseIP(req.BlockingIPv6) <mask> if ip == nil { </s> Pull request: 2271 handle nolint Merge in DNS/adguard-home from 2271-handle-nolint to master Closes #2271. Squashed commit of the following: commit fde5c8795ac79e1f7d02ba8c8e369b5a724a000e Merge: fc2acd898 642dcd647 Author: Eugene Burkov <[email protected]> Date: Fri Nov 20 17:12:28 2020 +0300 Merge branch 'master' into 2271-handle-nolint commit fc2acd89871de08c39e80ace9e5bb8a7acb7afba Author: Eugene Burkov <[email protected]> Date: Tue Nov 17 11:55:29 2020 +0300 dnsforward: fix test output strings commit c4ebae6ea9c293bad239519c44ca5a6c576bb921 Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 22:43:20 2020 +0300 dnsfilter: make package pass tests commit f2d98c6acabd8977f3b1b361987eaa31eb6eb9ad Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 20:05:00 2020 +0300 querylog: make decoding pass tests commit ab5850d24c50d53b8393f2de448cc340241351d7 Merge: 6ed2066bf 8a9c6e8a0 Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 19:48:31 2020 +0300 Merge branch 'master' into 2271-handle-nolint commit 6ed2066bf567e13dd14cfa16fc7b109b59fa39ef Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 18:13:45 2020 +0300 home: fix tests naming commit af691081fb02b7500a746b16492f01f7f9befe9a Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 12:15:49 2020 +0300 home: impove code quality commit 2914cd3cd23ef2a1964116baab9187d89b377f86 Author: Eugene Burkov <[email protected]> Date: Wed Nov 11 15:46:39 2020 +0300 * querylog: remove useless check commit 9996840650e784ccc76d1f29964560435ba27dc7 Author: Eugene Burkov <[email protected]> Date: Wed Nov 11 13:18:34 2020 +0300 * all: fix noticed defects commit 2b15293e59337f70302fbc0db81ebb26bee0bed2 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 20:15:53 2020 +0300 * stats: remove last nolint directive commit b2e1ddf7b58196a2fdbf879f084edb41ca1aa1eb Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 18:35:41 2020 +0300 * all: remove another nolint directive commit c6fc5cfcc9c95ab9e570a95ab41c3e5c0125e62e Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 18:11:28 2020 +0300 * querylog: remove nolint directive commit 226ddbf2c92f737f085b44a4ddf6daec7b602153 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 16:35:26 2020 +0300 * home: remove nolint directive commit 2ea3086ad41e9003282add7e996ae722d72d878b Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 16:13:57 2020 +0300 * home: reduce cyclomatic complexity of run function commit f479b480c48e0bb832ddef8f57586f56b8a55bab Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 15:35:46 2020 +0300 * home: use crypto/rand instead of math/rand commit a28d4a53e3b930136b036606fc7e78404f1d208b Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 14:11:07 2020 +0300 * dnsforward: remove gocyclo nolint directive commit 64a0a324cc2b20614ceec3ccc6505e960fe526e9 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 11:45:49 2020 +0300 all *: remove some nolint directives Updates #2271. </s> remove ip = net.ParseIP(req.BlockingIPv6) if ip == nil { </s> add ip4 := net.ParseIP(*req.BlockingIPv4) if ip4 == nil || ip4.To4() == nil { </s> remove func checkBlockingMode(req dnsConfigJSON) bool { bm := req.BlockingMode if !(bm == "default" || bm == "refused" || bm == "nxdomain" || bm == "null_ip" || bm == "custom_ip") { return false </s> add func (req *dnsConfig) checkBlockingMode() bool { if req.BlockingMode == nil { return true </s> remove // nolint (gocyclo) // Return TRUE if IP is within public Internet IP range func isPublicIP(ip net.IP) bool { ip4 := ip.To4() if ip4 != nil { switch ip4[0] { case 0: return false // software case 10: return false // private network case 127: return false // loopback case 169: if ip4[1] == 254 { return false // link-local } case 172: if ip4[1] >= 16 && ip4[1] <= 31 { return false // private network } case 192: if (ip4[1] == 0 && ip4[2] == 0) || // private network (ip4[1] == 0 && ip4[2] == 2) || // documentation (ip4[1] == 88 && ip4[2] == 99) || // reserved (ip4[1] == 168) { // private network return false } case 198: if (ip4[1] == 18 || ip4[2] == 19) || // private network (ip4[1] == 51 || ip4[2] == 100) { // documentation return false } case 203: if ip4[1] == 0 && ip4[2] == 113 { // documentation return false } case 224: if ip4[1] == 0 && ip4[2] == 0 { // multicast return false } case 255: if ip4[1] == 255 && ip4[2] == 255 && ip4[3] == 255 { // subnet return false } } } else { if ip.IsLoopback() || ip.IsLinkLocalMulticast() || ip.IsLinkLocalUnicast() { return false } } return true } </s> add </s> remove w.Header().Set("Content-Type", "application/json") _, _ = w.Write(js) </s> add
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/3045da1742ee0e75392de1623900d7d88b08f0b4
internal/dnsforward/dnsforward_http.go
ip4 := net.ParseIP(*req.BlockingIPv4) if ip4 == nil || ip4.To4() == nil {
<mask> if ip == nil || ip.To4() == nil { <mask> return false <mask> } <mask> <mask> ip = net.ParseIP(req.BlockingIPv6) <mask> if ip == nil { <mask> return false <mask> } <mask> } <mask> <mask> return true </s> Pull request: 2271 handle nolint Merge in DNS/adguard-home from 2271-handle-nolint to master Closes #2271. Squashed commit of the following: commit fde5c8795ac79e1f7d02ba8c8e369b5a724a000e Merge: fc2acd898 642dcd647 Author: Eugene Burkov <[email protected]> Date: Fri Nov 20 17:12:28 2020 +0300 Merge branch 'master' into 2271-handle-nolint commit fc2acd89871de08c39e80ace9e5bb8a7acb7afba Author: Eugene Burkov <[email protected]> Date: Tue Nov 17 11:55:29 2020 +0300 dnsforward: fix test output strings commit c4ebae6ea9c293bad239519c44ca5a6c576bb921 Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 22:43:20 2020 +0300 dnsfilter: make package pass tests commit f2d98c6acabd8977f3b1b361987eaa31eb6eb9ad Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 20:05:00 2020 +0300 querylog: make decoding pass tests commit ab5850d24c50d53b8393f2de448cc340241351d7 Merge: 6ed2066bf 8a9c6e8a0 Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 19:48:31 2020 +0300 Merge branch 'master' into 2271-handle-nolint commit 6ed2066bf567e13dd14cfa16fc7b109b59fa39ef Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 18:13:45 2020 +0300 home: fix tests naming commit af691081fb02b7500a746b16492f01f7f9befe9a Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 12:15:49 2020 +0300 home: impove code quality commit 2914cd3cd23ef2a1964116baab9187d89b377f86 Author: Eugene Burkov <[email protected]> Date: Wed Nov 11 15:46:39 2020 +0300 * querylog: remove useless check commit 9996840650e784ccc76d1f29964560435ba27dc7 Author: Eugene Burkov <[email protected]> Date: Wed Nov 11 13:18:34 2020 +0300 * all: fix noticed defects commit 2b15293e59337f70302fbc0db81ebb26bee0bed2 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 20:15:53 2020 +0300 * stats: remove last nolint directive commit b2e1ddf7b58196a2fdbf879f084edb41ca1aa1eb Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 18:35:41 2020 +0300 * all: remove another nolint directive commit c6fc5cfcc9c95ab9e570a95ab41c3e5c0125e62e Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 18:11:28 2020 +0300 * querylog: remove nolint directive commit 226ddbf2c92f737f085b44a4ddf6daec7b602153 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 16:35:26 2020 +0300 * home: remove nolint directive commit 2ea3086ad41e9003282add7e996ae722d72d878b Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 16:13:57 2020 +0300 * home: reduce cyclomatic complexity of run function commit f479b480c48e0bb832ddef8f57586f56b8a55bab Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 15:35:46 2020 +0300 * home: use crypto/rand instead of math/rand commit a28d4a53e3b930136b036606fc7e78404f1d208b Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 14:11:07 2020 +0300 * dnsforward: remove gocyclo nolint directive commit 64a0a324cc2b20614ceec3ccc6505e960fe526e9 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 11:45:49 2020 +0300 all *: remove some nolint directives Updates #2271. </s> remove ip := net.ParseIP(req.BlockingIPv4) if ip == nil || ip.To4() == nil { </s> add if req.BlockingIPv4 == nil || req.BlockingIPv6 == nil { </s> remove func checkBlockingMode(req dnsConfigJSON) bool { bm := req.BlockingMode if !(bm == "default" || bm == "refused" || bm == "nxdomain" || bm == "null_ip" || bm == "custom_ip") { return false </s> add func (req *dnsConfig) checkBlockingMode() bool { if req.BlockingMode == nil { return true </s> remove // nolint (gocyclo) // Return TRUE if IP is within public Internet IP range func isPublicIP(ip net.IP) bool { ip4 := ip.To4() if ip4 != nil { switch ip4[0] { case 0: return false // software case 10: return false // private network case 127: return false // loopback case 169: if ip4[1] == 254 { return false // link-local } case 172: if ip4[1] >= 16 && ip4[1] <= 31 { return false // private network } case 192: if (ip4[1] == 0 && ip4[2] == 0) || // private network (ip4[1] == 0 && ip4[2] == 2) || // documentation (ip4[1] == 88 && ip4[2] == 99) || // reserved (ip4[1] == 168) { // private network return false } case 198: if (ip4[1] == 18 || ip4[2] == 19) || // private network (ip4[1] == 51 || ip4[2] == 100) { // documentation return false } case 203: if ip4[1] == 0 && ip4[2] == 113 { // documentation return false } case 224: if ip4[1] == 0 && ip4[2] == 0 { // multicast return false } case 255: if ip4[1] == 255 && ip4[2] == 255 && ip4[3] == 255 { // subnet return false } } } else { if ip.IsLoopback() || ip.IsLinkLocalMulticast() || ip.IsLinkLocalUnicast() { return false } } return true } </s> add </s> remove case ctFilteringStatus: res := entry.Result switch c.value { case filteringStatusAll: return true case filteringStatusFiltered: return res.IsFiltered || res.Reason == dnsfilter.NotFilteredWhiteList || res.Reason == dnsfilter.ReasonRewrite || res.Reason == dnsfilter.RewriteEtcHosts case filteringStatusBlocked: return res.IsFiltered && (res.Reason == dnsfilter.FilteredBlackList || res.Reason == dnsfilter.FilteredBlockedService) case filteringStatusBlockedService: return res.IsFiltered && res.Reason == dnsfilter.FilteredBlockedService case filteringStatusBlockedParental: return res.IsFiltered && res.Reason == dnsfilter.FilteredParental case filteringStatusBlockedSafebrowsing: return res.IsFiltered && res.Reason == dnsfilter.FilteredSafeBrowsing case filteringStatusWhitelisted: return res.Reason == dnsfilter.NotFilteredWhiteList case filteringStatusRewritten: return res.Reason == dnsfilter.ReasonRewrite || res.Reason == dnsfilter.RewriteEtcHosts case filteringStatusSafeSearch: return res.IsFiltered && res.Reason == dnsfilter.FilteredSafeSearch case filteringStatusProcessed: return !(res.Reason == dnsfilter.FilteredBlackList || res.Reason == dnsfilter.FilteredBlockedService || res.Reason == dnsfilter.NotFilteredWhiteList) default: return false } </s> add func (c *searchCriteria) ctDomainOrClientCase(entry *logEntry) bool { qhost := strings.ToLower(entry.QHost) searchVal := strings.ToLower(c.value) if c.strict && qhost == searchVal { return true } if !c.strict && strings.Contains(qhost, searchVal) { return true
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/3045da1742ee0e75392de1623900d7d88b08f0b4
internal/dnsforward/dnsforward_http.go
ip6 := net.ParseIP(*req.BlockingIPv6) return ip6 != nil
<mask> if ip4 == nil || ip4.To4() == nil { <mask> return false <mask> } <mask> } <mask> <mask> for _, valid := range []string{ <mask> "default", <mask> "refused", <mask> "nxdomain", </s> Pull request: 2271 handle nolint Merge in DNS/adguard-home from 2271-handle-nolint to master Closes #2271. Squashed commit of the following: commit fde5c8795ac79e1f7d02ba8c8e369b5a724a000e Merge: fc2acd898 642dcd647 Author: Eugene Burkov <[email protected]> Date: Fri Nov 20 17:12:28 2020 +0300 Merge branch 'master' into 2271-handle-nolint commit fc2acd89871de08c39e80ace9e5bb8a7acb7afba Author: Eugene Burkov <[email protected]> Date: Tue Nov 17 11:55:29 2020 +0300 dnsforward: fix test output strings commit c4ebae6ea9c293bad239519c44ca5a6c576bb921 Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 22:43:20 2020 +0300 dnsfilter: make package pass tests commit f2d98c6acabd8977f3b1b361987eaa31eb6eb9ad Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 20:05:00 2020 +0300 querylog: make decoding pass tests commit ab5850d24c50d53b8393f2de448cc340241351d7 Merge: 6ed2066bf 8a9c6e8a0 Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 19:48:31 2020 +0300 Merge branch 'master' into 2271-handle-nolint commit 6ed2066bf567e13dd14cfa16fc7b109b59fa39ef Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 18:13:45 2020 +0300 home: fix tests naming commit af691081fb02b7500a746b16492f01f7f9befe9a Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 12:15:49 2020 +0300 home: impove code quality commit 2914cd3cd23ef2a1964116baab9187d89b377f86 Author: Eugene Burkov <[email protected]> Date: Wed Nov 11 15:46:39 2020 +0300 * querylog: remove useless check commit 9996840650e784ccc76d1f29964560435ba27dc7 Author: Eugene Burkov <[email protected]> Date: Wed Nov 11 13:18:34 2020 +0300 * all: fix noticed defects commit 2b15293e59337f70302fbc0db81ebb26bee0bed2 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 20:15:53 2020 +0300 * stats: remove last nolint directive commit b2e1ddf7b58196a2fdbf879f084edb41ca1aa1eb Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 18:35:41 2020 +0300 * all: remove another nolint directive commit c6fc5cfcc9c95ab9e570a95ab41c3e5c0125e62e Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 18:11:28 2020 +0300 * querylog: remove nolint directive commit 226ddbf2c92f737f085b44a4ddf6daec7b602153 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 16:35:26 2020 +0300 * home: remove nolint directive commit 2ea3086ad41e9003282add7e996ae722d72d878b Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 16:13:57 2020 +0300 * home: reduce cyclomatic complexity of run function commit f479b480c48e0bb832ddef8f57586f56b8a55bab Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 15:35:46 2020 +0300 * home: use crypto/rand instead of math/rand commit a28d4a53e3b930136b036606fc7e78404f1d208b Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 14:11:07 2020 +0300 * dnsforward: remove gocyclo nolint directive commit 64a0a324cc2b20614ceec3ccc6505e960fe526e9 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 11:45:49 2020 +0300 all *: remove some nolint directives Updates #2271. </s> remove return true </s> add for _, valid := range []string{ "default", "refused", "nxdomain", "null_ip", } { if bm == valid { return true } } return false </s> remove ip = net.ParseIP(req.BlockingIPv6) if ip == nil { </s> add ip4 := net.ParseIP(*req.BlockingIPv4) if ip4 == nil || ip4.To4() == nil { </s> remove _, err := upstream.NewResolver(addr, 0) if err != nil { return fmt.Errorf("invalid bootstrap server address: %w", err) </s> add for _, valid := range []string{ "", "fastest_addr", "parallel", } { if *req.UpstreamMode == valid { return true } </s> remove // nolint (gocyclo) // Return TRUE if IP is within public Internet IP range func isPublicIP(ip net.IP) bool { ip4 := ip.To4() if ip4 != nil { switch ip4[0] { case 0: return false // software case 10: return false // private network case 127: return false // loopback case 169: if ip4[1] == 254 { return false // link-local } case 172: if ip4[1] >= 16 && ip4[1] <= 31 { return false // private network } case 192: if (ip4[1] == 0 && ip4[2] == 0) || // private network (ip4[1] == 0 && ip4[2] == 2) || // documentation (ip4[1] == 88 && ip4[2] == 99) || // reserved (ip4[1] == 168) { // private network return false } case 198: if (ip4[1] == 18 || ip4[2] == 19) || // private network (ip4[1] == 51 || ip4[2] == 100) { // documentation return false } case 203: if ip4[1] == 0 && ip4[2] == 113 { // documentation return false } case 224: if ip4[1] == 0 && ip4[2] == 0 { // multicast return false } case 255: if ip4[1] == 255 && ip4[2] == 255 && ip4[3] == 255 { // subnet return false } } } else { if ip.IsLoopback() || ip.IsLinkLocalMulticast() || ip.IsLinkLocalUnicast() { return false } } return true } </s> add </s> remove ip := net.ParseIP(req.BlockingIPv4) if ip == nil || ip.To4() == nil { </s> add if req.BlockingIPv4 == nil || req.BlockingIPv6 == nil {
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/3045da1742ee0e75392de1623900d7d88b08f0b4
internal/dnsforward/dnsforward_http.go
for _, valid := range []string{ "default", "refused", "nxdomain", "null_ip", } { if bm == valid { return true } } return false
<mask> return false <mask> } <mask> } <mask> <mask> return true <mask> } <mask> <mask> // Validate bootstrap server address <mask> func checkBootstrap(addr string) error { <mask> if addr == "" { // additional check is required because NewResolver() allows empty address </s> Pull request: 2271 handle nolint Merge in DNS/adguard-home from 2271-handle-nolint to master Closes #2271. Squashed commit of the following: commit fde5c8795ac79e1f7d02ba8c8e369b5a724a000e Merge: fc2acd898 642dcd647 Author: Eugene Burkov <[email protected]> Date: Fri Nov 20 17:12:28 2020 +0300 Merge branch 'master' into 2271-handle-nolint commit fc2acd89871de08c39e80ace9e5bb8a7acb7afba Author: Eugene Burkov <[email protected]> Date: Tue Nov 17 11:55:29 2020 +0300 dnsforward: fix test output strings commit c4ebae6ea9c293bad239519c44ca5a6c576bb921 Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 22:43:20 2020 +0300 dnsfilter: make package pass tests commit f2d98c6acabd8977f3b1b361987eaa31eb6eb9ad Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 20:05:00 2020 +0300 querylog: make decoding pass tests commit ab5850d24c50d53b8393f2de448cc340241351d7 Merge: 6ed2066bf 8a9c6e8a0 Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 19:48:31 2020 +0300 Merge branch 'master' into 2271-handle-nolint commit 6ed2066bf567e13dd14cfa16fc7b109b59fa39ef Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 18:13:45 2020 +0300 home: fix tests naming commit af691081fb02b7500a746b16492f01f7f9befe9a Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 12:15:49 2020 +0300 home: impove code quality commit 2914cd3cd23ef2a1964116baab9187d89b377f86 Author: Eugene Burkov <[email protected]> Date: Wed Nov 11 15:46:39 2020 +0300 * querylog: remove useless check commit 9996840650e784ccc76d1f29964560435ba27dc7 Author: Eugene Burkov <[email protected]> Date: Wed Nov 11 13:18:34 2020 +0300 * all: fix noticed defects commit 2b15293e59337f70302fbc0db81ebb26bee0bed2 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 20:15:53 2020 +0300 * stats: remove last nolint directive commit b2e1ddf7b58196a2fdbf879f084edb41ca1aa1eb Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 18:35:41 2020 +0300 * all: remove another nolint directive commit c6fc5cfcc9c95ab9e570a95ab41c3e5c0125e62e Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 18:11:28 2020 +0300 * querylog: remove nolint directive commit 226ddbf2c92f737f085b44a4ddf6daec7b602153 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 16:35:26 2020 +0300 * home: remove nolint directive commit 2ea3086ad41e9003282add7e996ae722d72d878b Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 16:13:57 2020 +0300 * home: reduce cyclomatic complexity of run function commit f479b480c48e0bb832ddef8f57586f56b8a55bab Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 15:35:46 2020 +0300 * home: use crypto/rand instead of math/rand commit a28d4a53e3b930136b036606fc7e78404f1d208b Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 14:11:07 2020 +0300 * dnsforward: remove gocyclo nolint directive commit 64a0a324cc2b20614ceec3ccc6505e960fe526e9 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 11:45:49 2020 +0300 all *: remove some nolint directives Updates #2271. </s> remove // Validate bootstrap server address func checkBootstrap(addr string) error { if addr == "" { // additional check is required because NewResolver() allows empty address return fmt.Errorf("invalid bootstrap server address: empty") </s> add func (req *dnsConfig) checkUpstreamsMode() bool { if req.UpstreamMode == nil { return true </s> remove _, err := upstream.NewResolver(addr, 0) if err != nil { return fmt.Errorf("invalid bootstrap server address: %w", err) </s> add for _, valid := range []string{ "", "fastest_addr", "parallel", } { if *req.UpstreamMode == valid { return true } </s> remove return nil </s> add return false } func (req *dnsConfig) checkBootstrap() (string, error) { if req.Bootstraps == nil { return "", nil } for _, boot := range *req.Bootstraps { if boot == "" { return boot, fmt.Errorf("invalid bootstrap server address: empty") } if _, err := upstream.NewResolver(boot, 0); err != nil { return boot, fmt.Errorf("invalid bootstrap server address: %w", err) } } return "", nil } func (req *dnsConfig) checkCacheTTL() bool { if req.CacheMinTTL == nil && req.CacheMaxTTL == nil { return true } var min, max uint32 if req.CacheMinTTL != nil { min = *req.CacheMinTTL } if req.CacheMaxTTL == nil { max = *req.CacheMaxTTL } return min <= max </s> remove // nolint (gocyclo) // Return TRUE if IP is within public Internet IP range func isPublicIP(ip net.IP) bool { ip4 := ip.To4() if ip4 != nil { switch ip4[0] { case 0: return false // software case 10: return false // private network case 127: return false // loopback case 169: if ip4[1] == 254 { return false // link-local } case 172: if ip4[1] >= 16 && ip4[1] <= 31 { return false // private network } case 192: if (ip4[1] == 0 && ip4[2] == 0) || // private network (ip4[1] == 0 && ip4[2] == 2) || // documentation (ip4[1] == 88 && ip4[2] == 99) || // reserved (ip4[1] == 168) { // private network return false } case 198: if (ip4[1] == 18 || ip4[2] == 19) || // private network (ip4[1] == 51 || ip4[2] == 100) { // documentation return false } case 203: if ip4[1] == 0 && ip4[2] == 113 { // documentation return false } case 224: if ip4[1] == 0 && ip4[2] == 0 { // multicast return false } case 255: if ip4[1] == 255 && ip4[2] == 255 && ip4[3] == 255 { // subnet return false } } } else { if ip.IsLoopback() || ip.IsLinkLocalMulticast() || ip.IsLinkLocalUnicast() { return false } } return true } </s> add </s> remove // nolint(gocyclo) </s> add // optionalAuthThird return true if user should authenticate first. func optionalAuthThird(w http.ResponseWriter, r *http.Request) (authFirst bool) { authFirst = false // redirect to login page if not authenticated ok := false cookie, err := r.Cookie(sessionCookieName) if glProcessCookie(r) { log.Debug("Auth: authentification was handled by GL-Inet submodule") ok = true } else if err == nil { r := Context.auth.CheckSession(cookie.Value) if r == 0 { ok = true } else if r < 0 { log.Debug("Auth: invalid cookie value: %s", cookie) } } else { // there's no Cookie, check Basic authentication user, pass, ok2 := r.BasicAuth() if ok2 { u := Context.auth.UserFind(user, pass) if len(u.Name) != 0 { ok = true } else { log.Info("Auth: invalid Basic Authorization value") } } } if !ok { if r.URL.Path == "/" || r.URL.Path == "/index.html" { if glProcessRedirect(w, r) { log.Debug("Auth: redirected to login page by GL-Inet submodule") } else { w.Header().Set("Location", "/login.html") w.WriteHeader(http.StatusFound) } } else { w.WriteHeader(http.StatusForbidden) _, _ = w.Write([]byte("Forbidden")) } authFirst = true } return authFirst }
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/3045da1742ee0e75392de1623900d7d88b08f0b4
internal/dnsforward/dnsforward_http.go
func (req *dnsConfig) checkUpstreamsMode() bool { if req.UpstreamMode == nil { return true
<mask> <mask> return true <mask> } <mask> <mask> // Validate bootstrap server address <mask> func checkBootstrap(addr string) error { <mask> if addr == "" { // additional check is required because NewResolver() allows empty address <mask> return fmt.Errorf("invalid bootstrap server address: empty") <mask> } <mask> _, err := upstream.NewResolver(addr, 0) <mask> if err != nil { <mask> return fmt.Errorf("invalid bootstrap server address: %w", err) <mask> } </s> Pull request: 2271 handle nolint Merge in DNS/adguard-home from 2271-handle-nolint to master Closes #2271. Squashed commit of the following: commit fde5c8795ac79e1f7d02ba8c8e369b5a724a000e Merge: fc2acd898 642dcd647 Author: Eugene Burkov <[email protected]> Date: Fri Nov 20 17:12:28 2020 +0300 Merge branch 'master' into 2271-handle-nolint commit fc2acd89871de08c39e80ace9e5bb8a7acb7afba Author: Eugene Burkov <[email protected]> Date: Tue Nov 17 11:55:29 2020 +0300 dnsforward: fix test output strings commit c4ebae6ea9c293bad239519c44ca5a6c576bb921 Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 22:43:20 2020 +0300 dnsfilter: make package pass tests commit f2d98c6acabd8977f3b1b361987eaa31eb6eb9ad Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 20:05:00 2020 +0300 querylog: make decoding pass tests commit ab5850d24c50d53b8393f2de448cc340241351d7 Merge: 6ed2066bf 8a9c6e8a0 Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 19:48:31 2020 +0300 Merge branch 'master' into 2271-handle-nolint commit 6ed2066bf567e13dd14cfa16fc7b109b59fa39ef Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 18:13:45 2020 +0300 home: fix tests naming commit af691081fb02b7500a746b16492f01f7f9befe9a Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 12:15:49 2020 +0300 home: impove code quality commit 2914cd3cd23ef2a1964116baab9187d89b377f86 Author: Eugene Burkov <[email protected]> Date: Wed Nov 11 15:46:39 2020 +0300 * querylog: remove useless check commit 9996840650e784ccc76d1f29964560435ba27dc7 Author: Eugene Burkov <[email protected]> Date: Wed Nov 11 13:18:34 2020 +0300 * all: fix noticed defects commit 2b15293e59337f70302fbc0db81ebb26bee0bed2 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 20:15:53 2020 +0300 * stats: remove last nolint directive commit b2e1ddf7b58196a2fdbf879f084edb41ca1aa1eb Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 18:35:41 2020 +0300 * all: remove another nolint directive commit c6fc5cfcc9c95ab9e570a95ab41c3e5c0125e62e Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 18:11:28 2020 +0300 * querylog: remove nolint directive commit 226ddbf2c92f737f085b44a4ddf6daec7b602153 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 16:35:26 2020 +0300 * home: remove nolint directive commit 2ea3086ad41e9003282add7e996ae722d72d878b Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 16:13:57 2020 +0300 * home: reduce cyclomatic complexity of run function commit f479b480c48e0bb832ddef8f57586f56b8a55bab Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 15:35:46 2020 +0300 * home: use crypto/rand instead of math/rand commit a28d4a53e3b930136b036606fc7e78404f1d208b Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 14:11:07 2020 +0300 * dnsforward: remove gocyclo nolint directive commit 64a0a324cc2b20614ceec3ccc6505e960fe526e9 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 11:45:49 2020 +0300 all *: remove some nolint directives Updates #2271. </s> remove _, err := upstream.NewResolver(addr, 0) if err != nil { return fmt.Errorf("invalid bootstrap server address: %w", err) </s> add for _, valid := range []string{ "", "fastest_addr", "parallel", } { if *req.UpstreamMode == valid { return true } </s> remove return true </s> add for _, valid := range []string{ "default", "refused", "nxdomain", "null_ip", } { if bm == valid { return true } } return false </s> remove return nil </s> add return false } func (req *dnsConfig) checkBootstrap() (string, error) { if req.Bootstraps == nil { return "", nil } for _, boot := range *req.Bootstraps { if boot == "" { return boot, fmt.Errorf("invalid bootstrap server address: empty") } if _, err := upstream.NewResolver(boot, 0); err != nil { return boot, fmt.Errorf("invalid bootstrap server address: %w", err) } } return "", nil } func (req *dnsConfig) checkCacheTTL() bool { if req.CacheMinTTL == nil && req.CacheMaxTTL == nil { return true } var min, max uint32 if req.CacheMinTTL != nil { min = *req.CacheMinTTL } if req.CacheMaxTTL == nil { max = *req.CacheMaxTTL } return min <= max </s> remove if js.Exists("bootstrap_dns") { for _, boot := range req.Bootstraps { if err := checkBootstrap(boot); err != nil { httpError(r, w, http.StatusBadRequest, "%s can not be used as bootstrap dns cause: %s", boot, err) return } } </s> add if errBoot, err := req.checkBootstrap(); err != nil { httpError(r, w, http.StatusBadRequest, "%s can not be used as bootstrap dns cause: %s", errBoot, err) return </s> remove // decodeLogEntry - decodes query log entry from a line // nolint (gocyclo) func decodeLogEntry(ent *logEntry, str string) { var b bool var i int var err error for { k, v, t := readJSON(&str) if t == jsonTErr { break } switch k { case "IP": if len(ent.IP) == 0 { ent.IP = v } case "T": ent.Time, err = time.Parse(time.RFC3339, v) case "QH": ent.QHost = v case "QT": ent.QType = v case "QC": ent.QClass = v case "CP": ent.ClientProto, err = NewClientProto(v) case "Answer": ent.Answer, err = base64.StdEncoding.DecodeString(v) case "OrigAnswer": ent.OrigAnswer, err = base64.StdEncoding.DecodeString(v) case "IsFiltered": b, err = strconv.ParseBool(v) ent.Result.IsFiltered = b case "Rule": ent.Result.Rule = v case "FilterID": i, err = strconv.Atoi(v) ent.Result.FilterID = int64(i) case "Reason": i, err = strconv.Atoi(v) ent.Result.Reason = dnsfilter.Reason(i) case "ServiceName": ent.Result.ServiceName = v case "Upstream": ent.Upstream = v case "Elapsed": i, err = strconv.Atoi(v) ent.Elapsed = time.Duration(i) // pre-v0.99.3 compatibility: case "Question": var qstr []byte qstr, err = base64.StdEncoding.DecodeString(v) if err != nil { break } q := new(dns.Msg) err = q.Unpack(qstr) if err != nil { break } ent.QHost = q.Question[0].Name if len(ent.QHost) == 0 { break } ent.QHost = ent.QHost[:len(ent.QHost)-1] ent.QType = dns.TypeToString[q.Question[0].Qtype] ent.QClass = dns.ClassToString[q.Question[0].Qclass] case "Time": ent.Time, err = time.Parse(time.RFC3339, v) </s> add var logEntryHandlers = map[string](func(t json.Token, ent *logEntry) error){ "IP": func(t json.Token, ent *logEntry) error { v, ok := t.(string) if !ok { return nil } if len(ent.IP) == 0 { ent.IP = v } return nil }, "T": func(t json.Token, ent *logEntry) error { v, ok := t.(string) if !ok { return nil } var err error ent.Time, err = time.Parse(time.RFC3339, v) return err }, "QH": func(t json.Token, ent *logEntry) error { v, ok := t.(string) if !ok { return nil } ent.QHost = v return nil }, "QT": func(t json.Token, ent *logEntry) error { v, ok := t.(string) if !ok { return nil } ent.QType = v return nil }, "QC": func(t json.Token, ent *logEntry) error { v, ok := t.(string) if !ok { return nil } ent.QClass = v return nil }, "CP": func(t json.Token, ent *logEntry) error { v, ok := t.(string) if !ok { return nil } var err error ent.ClientProto, err = NewClientProto(v) return err }, "Answer": func(t json.Token, ent *logEntry) error { v, ok := t.(string) if !ok { return nil } var err error ent.Answer, err = base64.StdEncoding.DecodeString(v) return err }, "OrigAnswer": func(t json.Token, ent *logEntry) error { v, ok := t.(string) if !ok { return nil } var err error ent.OrigAnswer, err = base64.StdEncoding.DecodeString(v) return err }, "IsFiltered": func(t json.Token, ent *logEntry) error { v, ok := t.(string) if !ok { return nil } b, err := strconv.ParseBool(v) if err != nil { return err } ent.Result.IsFiltered = b return nil }, "Rule": func(t json.Token, ent *logEntry) error { v, ok := t.(string) if !ok { return nil } ent.Result.Rule = v return nil }, "FilterID": func(t json.Token, ent *logEntry) error { v, ok := t.(string) if !ok { return nil } i, err := strconv.Atoi(v) if err != nil { return err } ent.Result.FilterID = int64(i) return nil }, "Reason": func(t json.Token, ent *logEntry) error { v, ok := t.(string) if !ok { return nil } i, err := strconv.Atoi(v) if err != nil { return err } ent.Result.Reason = dnsfilter.Reason(i) return nil }, "ServiceName": func(t json.Token, ent *logEntry) error { v, ok := t.(string) if !ok { return nil } ent.Result.ServiceName = v return nil }, "Upstream": func(t json.Token, ent *logEntry) error { v, ok := t.(string) if !ok { return nil
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/3045da1742ee0e75392de1623900d7d88b08f0b4
internal/dnsforward/dnsforward_http.go
for _, valid := range []string{ "", "fastest_addr", "parallel", } { if *req.UpstreamMode == valid { return true }
<mask> func checkBootstrap(addr string) error { <mask> if addr == "" { // additional check is required because NewResolver() allows empty address <mask> return fmt.Errorf("invalid bootstrap server address: empty") <mask> } <mask> _, err := upstream.NewResolver(addr, 0) <mask> if err != nil { <mask> return fmt.Errorf("invalid bootstrap server address: %w", err) <mask> } <mask> return nil <mask> } <mask> <mask> // nolint(gocyclo) - we need to check each JSON field separately </s> Pull request: 2271 handle nolint Merge in DNS/adguard-home from 2271-handle-nolint to master Closes #2271. Squashed commit of the following: commit fde5c8795ac79e1f7d02ba8c8e369b5a724a000e Merge: fc2acd898 642dcd647 Author: Eugene Burkov <[email protected]> Date: Fri Nov 20 17:12:28 2020 +0300 Merge branch 'master' into 2271-handle-nolint commit fc2acd89871de08c39e80ace9e5bb8a7acb7afba Author: Eugene Burkov <[email protected]> Date: Tue Nov 17 11:55:29 2020 +0300 dnsforward: fix test output strings commit c4ebae6ea9c293bad239519c44ca5a6c576bb921 Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 22:43:20 2020 +0300 dnsfilter: make package pass tests commit f2d98c6acabd8977f3b1b361987eaa31eb6eb9ad Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 20:05:00 2020 +0300 querylog: make decoding pass tests commit ab5850d24c50d53b8393f2de448cc340241351d7 Merge: 6ed2066bf 8a9c6e8a0 Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 19:48:31 2020 +0300 Merge branch 'master' into 2271-handle-nolint commit 6ed2066bf567e13dd14cfa16fc7b109b59fa39ef Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 18:13:45 2020 +0300 home: fix tests naming commit af691081fb02b7500a746b16492f01f7f9befe9a Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 12:15:49 2020 +0300 home: impove code quality commit 2914cd3cd23ef2a1964116baab9187d89b377f86 Author: Eugene Burkov <[email protected]> Date: Wed Nov 11 15:46:39 2020 +0300 * querylog: remove useless check commit 9996840650e784ccc76d1f29964560435ba27dc7 Author: Eugene Burkov <[email protected]> Date: Wed Nov 11 13:18:34 2020 +0300 * all: fix noticed defects commit 2b15293e59337f70302fbc0db81ebb26bee0bed2 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 20:15:53 2020 +0300 * stats: remove last nolint directive commit b2e1ddf7b58196a2fdbf879f084edb41ca1aa1eb Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 18:35:41 2020 +0300 * all: remove another nolint directive commit c6fc5cfcc9c95ab9e570a95ab41c3e5c0125e62e Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 18:11:28 2020 +0300 * querylog: remove nolint directive commit 226ddbf2c92f737f085b44a4ddf6daec7b602153 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 16:35:26 2020 +0300 * home: remove nolint directive commit 2ea3086ad41e9003282add7e996ae722d72d878b Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 16:13:57 2020 +0300 * home: reduce cyclomatic complexity of run function commit f479b480c48e0bb832ddef8f57586f56b8a55bab Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 15:35:46 2020 +0300 * home: use crypto/rand instead of math/rand commit a28d4a53e3b930136b036606fc7e78404f1d208b Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 14:11:07 2020 +0300 * dnsforward: remove gocyclo nolint directive commit 64a0a324cc2b20614ceec3ccc6505e960fe526e9 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 11:45:49 2020 +0300 all *: remove some nolint directives Updates #2271. </s> remove // Validate bootstrap server address func checkBootstrap(addr string) error { if addr == "" { // additional check is required because NewResolver() allows empty address return fmt.Errorf("invalid bootstrap server address: empty") </s> add func (req *dnsConfig) checkUpstreamsMode() bool { if req.UpstreamMode == nil { return true </s> remove return nil </s> add return false } func (req *dnsConfig) checkBootstrap() (string, error) { if req.Bootstraps == nil { return "", nil } for _, boot := range *req.Bootstraps { if boot == "" { return boot, fmt.Errorf("invalid bootstrap server address: empty") } if _, err := upstream.NewResolver(boot, 0); err != nil { return boot, fmt.Errorf("invalid bootstrap server address: %w", err) } } return "", nil } func (req *dnsConfig) checkCacheTTL() bool { if req.CacheMinTTL == nil && req.CacheMaxTTL == nil { return true } var min, max uint32 if req.CacheMinTTL != nil { min = *req.CacheMinTTL } if req.CacheMaxTTL == nil { max = *req.CacheMaxTTL } return min <= max </s> remove return true </s> add for _, valid := range []string{ "default", "refused", "nxdomain", "null_ip", } { if bm == valid { return true } } return false </s> remove // nolint(gocyclo) - we need to check each JSON field separately </s> add </s> remove req := dnsConfigJSON{} js, err := jsonutil.DecodeObject(&req, r.Body) if err != nil { httpError(r, w, http.StatusBadRequest, "json.Decode: %s", err) </s> add req := dnsConfig{} dec := json.NewDecoder(r.Body) if err := dec.Decode(&req); err != nil { httpError(r, w, http.StatusBadRequest, "json Encode: %s", err)
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/3045da1742ee0e75392de1623900d7d88b08f0b4
internal/dnsforward/dnsforward_http.go
return false } func (req *dnsConfig) checkBootstrap() (string, error) { if req.Bootstraps == nil { return "", nil } for _, boot := range *req.Bootstraps { if boot == "" { return boot, fmt.Errorf("invalid bootstrap server address: empty") } if _, err := upstream.NewResolver(boot, 0); err != nil { return boot, fmt.Errorf("invalid bootstrap server address: %w", err) } } return "", nil } func (req *dnsConfig) checkCacheTTL() bool { if req.CacheMinTTL == nil && req.CacheMaxTTL == nil { return true } var min, max uint32 if req.CacheMinTTL != nil { min = *req.CacheMinTTL } if req.CacheMaxTTL == nil { max = *req.CacheMaxTTL } return min <= max
<mask> _, err := upstream.NewResolver(addr, 0) <mask> if err != nil { <mask> return fmt.Errorf("invalid bootstrap server address: %w", err) <mask> } <mask> return nil <mask> } <mask> <mask> // nolint(gocyclo) - we need to check each JSON field separately <mask> func (s *Server) handleSetConfig(w http.ResponseWriter, r *http.Request) { <mask> req := dnsConfigJSON{} </s> Pull request: 2271 handle nolint Merge in DNS/adguard-home from 2271-handle-nolint to master Closes #2271. Squashed commit of the following: commit fde5c8795ac79e1f7d02ba8c8e369b5a724a000e Merge: fc2acd898 642dcd647 Author: Eugene Burkov <[email protected]> Date: Fri Nov 20 17:12:28 2020 +0300 Merge branch 'master' into 2271-handle-nolint commit fc2acd89871de08c39e80ace9e5bb8a7acb7afba Author: Eugene Burkov <[email protected]> Date: Tue Nov 17 11:55:29 2020 +0300 dnsforward: fix test output strings commit c4ebae6ea9c293bad239519c44ca5a6c576bb921 Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 22:43:20 2020 +0300 dnsfilter: make package pass tests commit f2d98c6acabd8977f3b1b361987eaa31eb6eb9ad Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 20:05:00 2020 +0300 querylog: make decoding pass tests commit ab5850d24c50d53b8393f2de448cc340241351d7 Merge: 6ed2066bf 8a9c6e8a0 Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 19:48:31 2020 +0300 Merge branch 'master' into 2271-handle-nolint commit 6ed2066bf567e13dd14cfa16fc7b109b59fa39ef Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 18:13:45 2020 +0300 home: fix tests naming commit af691081fb02b7500a746b16492f01f7f9befe9a Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 12:15:49 2020 +0300 home: impove code quality commit 2914cd3cd23ef2a1964116baab9187d89b377f86 Author: Eugene Burkov <[email protected]> Date: Wed Nov 11 15:46:39 2020 +0300 * querylog: remove useless check commit 9996840650e784ccc76d1f29964560435ba27dc7 Author: Eugene Burkov <[email protected]> Date: Wed Nov 11 13:18:34 2020 +0300 * all: fix noticed defects commit 2b15293e59337f70302fbc0db81ebb26bee0bed2 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 20:15:53 2020 +0300 * stats: remove last nolint directive commit b2e1ddf7b58196a2fdbf879f084edb41ca1aa1eb Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 18:35:41 2020 +0300 * all: remove another nolint directive commit c6fc5cfcc9c95ab9e570a95ab41c3e5c0125e62e Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 18:11:28 2020 +0300 * querylog: remove nolint directive commit 226ddbf2c92f737f085b44a4ddf6daec7b602153 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 16:35:26 2020 +0300 * home: remove nolint directive commit 2ea3086ad41e9003282add7e996ae722d72d878b Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 16:13:57 2020 +0300 * home: reduce cyclomatic complexity of run function commit f479b480c48e0bb832ddef8f57586f56b8a55bab Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 15:35:46 2020 +0300 * home: use crypto/rand instead of math/rand commit a28d4a53e3b930136b036606fc7e78404f1d208b Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 14:11:07 2020 +0300 * dnsforward: remove gocyclo nolint directive commit 64a0a324cc2b20614ceec3ccc6505e960fe526e9 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 11:45:49 2020 +0300 all *: remove some nolint directives Updates #2271. </s> remove // nolint(gocyclo) - we need to check each JSON field separately </s> add </s> remove _, err := upstream.NewResolver(addr, 0) if err != nil { return fmt.Errorf("invalid bootstrap server address: %w", err) </s> add for _, valid := range []string{ "", "fastest_addr", "parallel", } { if *req.UpstreamMode == valid { return true } </s> remove req := dnsConfigJSON{} js, err := jsonutil.DecodeObject(&req, r.Body) if err != nil { httpError(r, w, http.StatusBadRequest, "json.Decode: %s", err) </s> add req := dnsConfig{} dec := json.NewDecoder(r.Body) if err := dec.Decode(&req); err != nil { httpError(r, w, http.StatusBadRequest, "json Encode: %s", err) </s> remove // Validate bootstrap server address func checkBootstrap(addr string) error { if addr == "" { // additional check is required because NewResolver() allows empty address return fmt.Errorf("invalid bootstrap server address: empty") </s> add func (req *dnsConfig) checkUpstreamsMode() bool { if req.UpstreamMode == nil { return true </s> remove js, err := json.Marshal(resp) if err != nil { httpError(r, w, http.StatusInternalServerError, "json.Marshal: %s", err) </s> add func (s *Server) handleGetConfig(w http.ResponseWriter, r *http.Request) { resp := s.getDNSConfig() w.Header().Set("Content-Type", "application/json") enc := json.NewEncoder(w) if err := enc.Encode(resp); err != nil { httpError(r, w, http.StatusInternalServerError, "json.Encoder: %s", err)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/3045da1742ee0e75392de1623900d7d88b08f0b4
internal/dnsforward/dnsforward_http.go
<mask> } <mask> return nil <mask> } <mask> <mask> // nolint(gocyclo) - we need to check each JSON field separately <mask> func (s *Server) handleSetConfig(w http.ResponseWriter, r *http.Request) { <mask> req := dnsConfigJSON{} <mask> js, err := jsonutil.DecodeObject(&req, r.Body) <mask> if err != nil { <mask> httpError(r, w, http.StatusBadRequest, "json.Decode: %s", err) </s> Pull request: 2271 handle nolint Merge in DNS/adguard-home from 2271-handle-nolint to master Closes #2271. Squashed commit of the following: commit fde5c8795ac79e1f7d02ba8c8e369b5a724a000e Merge: fc2acd898 642dcd647 Author: Eugene Burkov <[email protected]> Date: Fri Nov 20 17:12:28 2020 +0300 Merge branch 'master' into 2271-handle-nolint commit fc2acd89871de08c39e80ace9e5bb8a7acb7afba Author: Eugene Burkov <[email protected]> Date: Tue Nov 17 11:55:29 2020 +0300 dnsforward: fix test output strings commit c4ebae6ea9c293bad239519c44ca5a6c576bb921 Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 22:43:20 2020 +0300 dnsfilter: make package pass tests commit f2d98c6acabd8977f3b1b361987eaa31eb6eb9ad Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 20:05:00 2020 +0300 querylog: make decoding pass tests commit ab5850d24c50d53b8393f2de448cc340241351d7 Merge: 6ed2066bf 8a9c6e8a0 Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 19:48:31 2020 +0300 Merge branch 'master' into 2271-handle-nolint commit 6ed2066bf567e13dd14cfa16fc7b109b59fa39ef Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 18:13:45 2020 +0300 home: fix tests naming commit af691081fb02b7500a746b16492f01f7f9befe9a Author: Eugene Burkov <[email protected]> Date: Mon Nov 16 12:15:49 2020 +0300 home: impove code quality commit 2914cd3cd23ef2a1964116baab9187d89b377f86 Author: Eugene Burkov <[email protected]> Date: Wed Nov 11 15:46:39 2020 +0300 * querylog: remove useless check commit 9996840650e784ccc76d1f29964560435ba27dc7 Author: Eugene Burkov <[email protected]> Date: Wed Nov 11 13:18:34 2020 +0300 * all: fix noticed defects commit 2b15293e59337f70302fbc0db81ebb26bee0bed2 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 20:15:53 2020 +0300 * stats: remove last nolint directive commit b2e1ddf7b58196a2fdbf879f084edb41ca1aa1eb Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 18:35:41 2020 +0300 * all: remove another nolint directive commit c6fc5cfcc9c95ab9e570a95ab41c3e5c0125e62e Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 18:11:28 2020 +0300 * querylog: remove nolint directive commit 226ddbf2c92f737f085b44a4ddf6daec7b602153 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 16:35:26 2020 +0300 * home: remove nolint directive commit 2ea3086ad41e9003282add7e996ae722d72d878b Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 16:13:57 2020 +0300 * home: reduce cyclomatic complexity of run function commit f479b480c48e0bb832ddef8f57586f56b8a55bab Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 15:35:46 2020 +0300 * home: use crypto/rand instead of math/rand commit a28d4a53e3b930136b036606fc7e78404f1d208b Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 14:11:07 2020 +0300 * dnsforward: remove gocyclo nolint directive commit 64a0a324cc2b20614ceec3ccc6505e960fe526e9 Author: Eugene Burkov <[email protected]> Date: Tue Nov 10 11:45:49 2020 +0300 all *: remove some nolint directives Updates #2271. </s> remove req := dnsConfigJSON{} js, err := jsonutil.DecodeObject(&req, r.Body) if err != nil { httpError(r, w, http.StatusBadRequest, "json.Decode: %s", err) </s> add req := dnsConfig{} dec := json.NewDecoder(r.Body) if err := dec.Decode(&req); err != nil { httpError(r, w, http.StatusBadRequest, "json Encode: %s", err) </s> remove return nil </s> add return false } func (req *dnsConfig) checkBootstrap() (string, error) { if req.Bootstraps == nil { return "", nil } for _, boot := range *req.Bootstraps { if boot == "" { return boot, fmt.Errorf("invalid bootstrap server address: empty") } if _, err := upstream.NewResolver(boot, 0); err != nil { return boot, fmt.Errorf("invalid bootstrap server address: %w", err) } } return "", nil } func (req *dnsConfig) checkCacheTTL() bool { if req.CacheMinTTL == nil && req.CacheMaxTTL == nil { return true } var min, max uint32 if req.CacheMinTTL != nil { min = *req.CacheMinTTL } if req.CacheMaxTTL == nil { max = *req.CacheMaxTTL } return min <= max </s> remove _, err := upstream.NewResolver(addr, 0) if err != nil { return fmt.Errorf("invalid bootstrap server address: %w", err) </s> add for _, valid := range []string{ "", "fastest_addr", "parallel", } { if *req.UpstreamMode == valid { return true } </s> remove js, err := json.Marshal(resp) if err != nil { httpError(r, w, http.StatusInternalServerError, "json.Marshal: %s", err) </s> add func (s *Server) handleGetConfig(w http.ResponseWriter, r *http.Request) { resp := s.getDNSConfig() w.Header().Set("Content-Type", "application/json") enc := json.NewEncoder(w) if err := enc.Encode(resp); err != nil { httpError(r, w, http.StatusInternalServerError, "json.Encoder: %s", err) </s> remove if js.Exists("upstream_dns") { err = ValidateUpstreams(req.Upstreams) if err != nil { </s> add if req.Upstreams != nil { if err := ValidateUpstreams(*req.Upstreams); err != nil {
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/3045da1742ee0e75392de1623900d7d88b08f0b4
internal/dnsforward/dnsforward_http.go