Skip to content

Commit

Permalink
Merge branch 'master' into WIP-2276-releases
Browse files Browse the repository at this point in the history
  • Loading branch information
ainar-g committed Dec 29, 2020
2 parents dde64ed + 483f02c commit ecc0577
Show file tree
Hide file tree
Showing 25 changed files with 276 additions and 168 deletions.
2 changes: 1 addition & 1 deletion AGHTechDoc.md
Expand Up @@ -1846,7 +1846,7 @@ Response:
}

There are also deprecated properties `filter_id` and `rule` on the top level of
the response object. Their usaga should be replaced with
the response object. Their usage should be replaced with
`rules[*].filter_list_id` and `rules[*].text` correspondingly. See the
_OpenAPI_ documentation and the `./openapi/CHANGELOG.md` file.

Expand Down
7 changes: 3 additions & 4 deletions README.md
Expand Up @@ -137,8 +137,7 @@ AdGuard Home provides a lot of features out-of-the-box with no need to install a
| Force Safe search on search engines |||
| Per-client (device) configuration |||
| Access settings (choose who can use AGH DNS) |||
| Written in a memory-safe language |||
| Running without root privileges |||
| Running [without root privileges](https://github.com/AdguardTeam/AdGuardHome/wiki/Getting-Started#running-without-superuser) |||

<a id="comparison-adblock"></a>
### How does AdGuard Home compare to traditional ad blockers
Expand Down Expand Up @@ -303,8 +302,8 @@ Here's what you can also do to contribute:

* Python library (https://github.com/frenck/python-adguardhome)
* Hass.io add-on (https://github.com/hassio-addons/addon-adguard-home)
* OpenWrt LUCI app (https://github.com/rufengsuixing/luci-app-adguardhome)

* OpenWrt LUCI app (https://github.com/kongfl888/luci-app-adguardhome)
* Prometheus exporter for AdGuard Home (https://github.com/ebrianne/adguard-exporter)

<a id="acknowledgments"></a>
## Acknowledgments
Expand Down
3 changes: 1 addition & 2 deletions client/src/__locales/en.json
Expand Up @@ -270,7 +270,7 @@
"source_label": "Source",
"found_in_known_domain_db": "Found in the known domains database.",
"category_label": "Category",
"rule_label": "Rule",
"rule_label": "Rule(s)",
"list_label": "List",
"unknown_filter": "Unknown filter {{filterId}}",
"known_tracker": "Known tracker",
Expand Down Expand Up @@ -530,7 +530,6 @@
"check_ip": "IP addresses: {{ip}}",
"check_cname": "CNAME: {{cname}}",
"check_reason": "Reason: {{reason}}",
"check_rule": "Rule: {{rule}}",
"check_service": "Service name: {{service}}",
"service_name": "Service name",
"check_not_found": "Not found in your filter lists",
Expand Down
31 changes: 14 additions & 17 deletions client/src/components/Filters/Check/Info.js
Expand Up @@ -12,7 +12,7 @@ import {
checkSafeSearch,
checkSafeBrowsing,
checkParental,
getFilterName,
getRulesToFilterList,
} from '../../../helpers/helpers';
import { BLOCK_ACTIONS, FILTERED, FILTERED_STATUS } from '../../../helpers/constants';
import { toggleBlocking } from '../../../actions';
Expand Down Expand Up @@ -41,32 +41,27 @@ const renderBlockingButton = (isFiltered, domain) => {
</button>;
};

const getTitle = (reason) => {
const getTitle = () => {
const { t } = useTranslation();

const filters = useSelector((state) => state.filtering.filters, shallowEqual);
const whitelistFilters = useSelector((state) => state.filtering.whitelistFilters, shallowEqual);
const filter_id = useSelector((state) => state.filtering.check.filter_id);

const filterName = getFilterName(
filters,
whitelistFilters,
filter_id,
'filtered_custom_rules',
(filter) => (filter?.name ? t('query_log_filtered', { filter: filter.name }) : ''),
);
const rules = useSelector((state) => state.filtering.check.rules, shallowEqual);
const reason = useSelector((state) => state.filtering.check.reason);

const getReasonFiltered = (reason) => {
const filterKey = reason.replace(FILTERED, '');
return i18next.t('query_log_filtered', { filter: filterKey });
};

const ruleAndFilterNames = getRulesToFilterList(rules, filters, whitelistFilters);

const REASON_TO_TITLE_MAP = {
[FILTERED_STATUS.NOT_FILTERED_NOT_FOUND]: t('check_not_found'),
[FILTERED_STATUS.REWRITE]: t('rewrite_applied'),
[FILTERED_STATUS.REWRITE_HOSTS]: t('rewrite_hosts_applied'),
[FILTERED_STATUS.FILTERED_BLACK_LIST]: filterName,
[FILTERED_STATUS.NOT_FILTERED_WHITE_LIST]: filterName,
[FILTERED_STATUS.FILTERED_BLACK_LIST]: ruleAndFilterNames,
[FILTERED_STATUS.NOT_FILTERED_WHITE_LIST]: ruleAndFilterNames,
[FILTERED_STATUS.FILTERED_SAFE_SEARCH]: getReasonFiltered(reason),
[FILTERED_STATUS.FILTERED_SAFE_BROWSING]: getReasonFiltered(reason),
[FILTERED_STATUS.FILTERED_PARENTAL]: getReasonFiltered(reason),
Expand All @@ -78,22 +73,25 @@ const getTitle = (reason) => {

return <>
<div>{t('check_reason', { reason })}</div>
<div>{filterName}</div>
<div>
{t('rule_label')}:
&nbsp;
{ruleAndFilterNames}
</div>
</>;
};

const Info = () => {
const {
hostname,
reason,
rule,
service_name,
cname,
ip_addrs,
} = useSelector((state) => state.filtering.check, shallowEqual);
const { t } = useTranslation();

const title = getTitle(reason);
const title = getTitle();

const className = classNames('card mb-0 p-3', {
'logs__row--red': checkFiltered(reason),
Expand All @@ -112,7 +110,6 @@ const Info = () => {
<div>{title}</div>
{!onlyFiltered
&& <>
{rule && <div>{t('check_rule', { rule })}</div>}
{service_name && <div>{t('check_service', { service: service_name })}</div>}
{cname && <div>{t('check_cname', { cname })}</div>}
{ip_addrs && <div>{t('check_ip', { ip: ip_addrs.join(', ') })}</div>}
Expand Down
26 changes: 16 additions & 10 deletions client/src/components/Logs/Cells/ResponseCell.js
Expand Up @@ -4,8 +4,9 @@ import classNames from 'classnames';
import React from 'react';
import propTypes from 'prop-types';
import {
getRulesToFilterList,
formatElapsedMs,
getFilterName,
getFilterNames,
getServiceName,
} from '../../../helpers/helpers';
import { FILTERED_STATUS, FILTERED_STATUS_TO_META_MAP } from '../../../helpers/constants';
Expand All @@ -18,8 +19,7 @@ const ResponseCell = ({
response,
status,
upstream,
rule,
filterId,
rules,
service_name,
}) => {
const { t } = useTranslation();
Expand All @@ -36,7 +36,6 @@ const ResponseCell = ({

const statusLabel = t(isBlockedByResponse ? 'blocked_by_cname_or_ip' : FILTERED_STATUS_TO_META_MAP[reason]?.LABEL || reason);
const boldStatusLabel = <span className="font-weight-bold">{statusLabel}</span>;
const filter = getFilterName(filters, whitelistFilters, filterId);

const renderResponses = (responseArr) => {
if (!responseArr || responseArr.length === 0) {
Expand All @@ -57,13 +56,17 @@ const ResponseCell = ({
install_settings_dns: upstream,
elapsed: formattedElapsedMs,
response_code: status,
...(service_name ? { service_name: getServiceName(service_name) } : { filter }),
rule_label: rule,
...(service_name
&& { service_name: getServiceName(service_name) }
),
...(rules.length > 0
&& { rule_label: getRulesToFilterList(rules, filters, whitelistFilters) }
),
response_table_header: renderResponses(response),
original_response: renderResponses(originalResponse),
};

const content = rule
const content = rules.length > 0
? Object.entries(COMMON_CONTENT)
: Object.entries({
...COMMON_CONTENT,
Expand All @@ -78,7 +81,8 @@ const ResponseCell = ({
}
return getServiceName(service_name);
case FILTERED_STATUS.FILTERED_BLACK_LIST:
return filter;
case FILTERED_STATUS.NOT_FILTERED_WHITE_LIST:
return getFilterNames(rules, filters, whitelistFilters).join(', ');
default:
return formattedElapsedMs;
}
Expand Down Expand Up @@ -113,8 +117,10 @@ ResponseCell.propTypes = {
response: propTypes.array.isRequired,
status: propTypes.string.isRequired,
upstream: propTypes.string.isRequired,
rule: propTypes.string,
filterId: propTypes.number,
rules: propTypes.arrayOf(propTypes.shape({
text: propTypes.string.isRequired,
filter_list_id: propTypes.number.isRequired,
})),
service_name: propTypes.string,
};

Expand Down
18 changes: 9 additions & 9 deletions client/src/components/Logs/Cells/index.js
Expand Up @@ -6,11 +6,11 @@ import propTypes from 'prop-types';
import {
captitalizeWords,
checkFiltered,
getRulesToFilterList,
formatDateTime,
formatElapsedMs,
formatTime,
getBlockingClientName,
getFilterName,
getServiceName,
processContent,
} from '../../../helpers/helpers';
Expand Down Expand Up @@ -70,8 +70,7 @@ const Row = memo(({
upstream,
type,
client_proto,
filterId,
rule,
rules,
originalResponse,
status,
service_name,
Expand Down Expand Up @@ -107,8 +106,6 @@ const Row = memo(({

const sourceData = getSourceData(tracker);

const filter = getFilterName(filters, whitelistFilters, filterId);

const {
confirmMessage,
buttonKey: blockingClientKey,
Expand Down Expand Up @@ -172,8 +169,9 @@ const Row = memo(({
response_details: 'title',
install_settings_dns: upstream,
elapsed: formattedElapsedMs,
filter: rule ? filter : null,
rule_label: rule,
...(rules.length > 0
&& { rule_label: getRulesToFilterList(rules, filters, whitelistFilters) }
),
response_table_header: response?.join('\n'),
response_code: status,
client_details: 'title',
Expand Down Expand Up @@ -235,8 +233,10 @@ Row.propTypes = {
upstream: propTypes.string.isRequired,
type: propTypes.string.isRequired,
client_proto: propTypes.string.isRequired,
filterId: propTypes.number,
rule: propTypes.string,
rules: propTypes.arrayOf(propTypes.shape({
text: propTypes.string.isRequired,
filter_list_id: propTypes.number.isRequired,
})),
originalResponse: propTypes.array,
status: propTypes.string.isRequired,
service_name: propTypes.string,
Expand Down
10 changes: 10 additions & 0 deletions client/src/components/Logs/Logs.css
Expand Up @@ -428,3 +428,13 @@
margin-right: 1px;
opacity: 0.5;
}

.filteringRules__rule {
margin-bottom: 0;
}

.filteringRules__filter {
font-style: italic;
font-weight: normal;
margin-bottom: 1rem;
}
5 changes: 5 additions & 0 deletions client/src/helpers/constants.js
Expand Up @@ -339,6 +339,7 @@ export const FILTERED_STATUS = {
FILTERED_BLOCKED_SERVICE: 'FilteredBlockedService',
REWRITE: 'Rewrite',
REWRITE_HOSTS: 'RewriteEtcHosts',
REWRITE_RULE: 'RewriteRule',
FILTERED_SAFE_SEARCH: 'FilteredSafeSearch',
FILTERED_SAFE_BROWSING: 'FilteredSafeBrowsing',
FILTERED_PARENTAL: 'FilteredParental',
Expand Down Expand Up @@ -430,6 +431,10 @@ export const FILTERED_STATUS_TO_META_MAP = {
LABEL: RESPONSE_FILTER.REWRITTEN.LABEL,
COLOR: QUERY_STATUS_COLORS.BLUE,
},
[FILTERED_STATUS.REWRITE_RULE]: {
LABEL: RESPONSE_FILTER.REWRITTEN.LABEL,
COLOR: QUERY_STATUS_COLORS.BLUE,
},
[FILTERED_STATUS.FILTERED_SAFE_BROWSING]: {
LABEL: RESPONSE_FILTER.BLOCKED_THREATS.LABEL,
COLOR: QUERY_STATUS_COLORS.YELLOW,
Expand Down

0 comments on commit ecc0577

Please sign in to comment.