From c7f8f20aada3e339b82434fab3d1b02c52bdd4e1 Mon Sep 17 00:00:00 2001 From: Ildar Kamalov Date: Thu, 19 Mar 2020 16:09:17 +0300 Subject: [PATCH] + client: handle rewrite auto --- client/src/__locales/en.json | 3 ++- client/src/components/Filters/Check/Info.js | 7 ++++++- client/src/components/Logs/index.js | 20 +++++++++++++++++++- client/src/helpers/constants.js | 1 + client/src/helpers/helpers.js | 1 + 5 files changed, 29 insertions(+), 3 deletions(-) diff --git a/client/src/__locales/en.json b/client/src/__locales/en.json index 17ebac91..02929a8e 100644 --- a/client/src/__locales/en.json +++ b/client/src/__locales/en.json @@ -386,7 +386,8 @@ "rewrite_not_found": "No DNS rewrites found", "rewrite_confirm_delete": "Are you sure you want to delete DNS rewrite for \"{{key}}\"?", "rewrite_desc": "Allows to easily configure custom DNS response for a specific domain name.", - "rewrite_applied": "Applied Rewrite rule", + "rewrite_applied": "Rewrite rule is applied", + "rewrite_hosts_applied": "Rewritten by the hosts file rule", "dns_rewrites": "DNS rewrites", "form_domain": "Enter domain name or wildcard", "form_answer": "Enter IP address or domain name", diff --git a/client/src/components/Filters/Check/Info.js b/client/src/components/Filters/Check/Info.js index 85a0ded3..9c9e85d7 100644 --- a/client/src/components/Filters/Check/Info.js +++ b/client/src/components/Filters/Check/Info.js @@ -5,6 +5,7 @@ import { withNamespaces } from 'react-i18next'; import { checkFiltered, checkRewrite, + checkRewriteHosts, checkBlackList, checkNotFilteredNotFound, checkWhiteList, @@ -38,6 +39,10 @@ const getTitle = (reason, filterName, t, onlyFiltered) => { return t('rewrite_applied'); } + if (checkRewriteHosts(reason)) { + return t('rewrite_hosts_applied'); + } + if (checkBlackList(reason)) { return filterName; } @@ -75,7 +80,7 @@ const getTitle = (reason, filterName, t, onlyFiltered) => { const getColor = (reason) => { if (checkFiltered(reason)) { return 'red'; - } else if (checkRewrite(reason)) { + } else if (checkRewrite(reason) || checkRewriteHosts(reason)) { return 'blue'; } else if (checkWhiteList(reason)) { return 'green'; diff --git a/client/src/components/Logs/index.js b/client/src/components/Logs/index.js index 03153603..82cae6da 100644 --- a/client/src/components/Logs/index.js +++ b/client/src/components/Logs/index.js @@ -12,6 +12,7 @@ import { isToday, checkFiltered, checkRewrite, + checkRewriteHosts, checkWhiteList, checkBlackList, checkBlockedService, @@ -170,6 +171,7 @@ class Logs extends Component { const isFiltered = checkFiltered(reason); const isBlackList = checkBlackList(reason); const isRewrite = checkRewrite(reason); + const isRewriteAuto = checkRewriteHosts(reason); const isWhiteList = checkWhiteList(reason); const isBlockedService = checkBlockedService(reason); const isBlockedCnameIp = originalAnswer; @@ -221,6 +223,13 @@ class Logs extends Component { rewrite_applied )} + {isRewriteAuto && ( + + + rewrite_hosts_applied + + + )}
{this.renderResponseList(responses, status)} @@ -236,6 +245,15 @@ class Logs extends Component { const { reason, domain } = original; const isFiltered = checkFiltered(reason); const isRewrite = checkRewrite(reason); + const isAutoRewrite = checkRewriteHosts(reason); + + if (isAutoRewrite) { + return ( +
+ {formatClientCell(row, t)} +
+ ); + } return ( @@ -364,7 +382,7 @@ class Logs extends Component { return { className: 'green', }; - } else if (checkRewrite(reason)) { + } else if (checkRewrite(reason) || checkRewriteHosts(reason)) { return { className: 'blue', }; diff --git a/client/src/helpers/constants.js b/client/src/helpers/constants.js index 9d5c2cf9..cafbd5b1 100644 --- a/client/src/helpers/constants.js +++ b/client/src/helpers/constants.js @@ -256,6 +256,7 @@ export const FILTERED_STATUS = { NOT_FILTERED_NOT_FOUND: 'NotFilteredNotFound', FILTERED_BLOCKED_SERVICE: 'FilteredBlockedService', REWRITE: 'Rewrite', + REWRITE_HOSTS: 'RewriteEtcHosts', FILTERED_SAFE_SEARCH: 'FilteredSafeSearch', FILTERED_SAFE_BROWSING: 'FilteredSafeBrowsing', FILTERED_PARENTAL: 'FilteredParental', diff --git a/client/src/helpers/helpers.js b/client/src/helpers/helpers.js index e32ec9a2..28c2fe94 100644 --- a/client/src/helpers/helpers.js +++ b/client/src/helpers/helpers.js @@ -431,6 +431,7 @@ export const createOnBlurHandler = (event, input, normalizeOnBlur) => ( export const checkFiltered = reason => reason.indexOf(FILTERED) === 0; export const checkRewrite = reason => reason === FILTERED_STATUS.REWRITE; +export const checkRewriteHosts = reason => reason === FILTERED_STATUS.REWRITE_HOSTS; export const checkBlackList = reason => reason === FILTERED_STATUS.FILTERED_BLACK_LIST; export const checkWhiteList = reason => reason === FILTERED_STATUS.NOT_FILTERED_WHITE_LIST; export const checkNotFilteredNotFound = reason => reason === FILTERED_STATUS.NOT_FILTERED_NOT_FOUND;