From e8885dbf3e8f4e9f5e486031813712c88625ba64 Mon Sep 17 00:00:00 2001 From: Ildar Kamalov Date: Fri, 29 Nov 2019 18:05:15 +0300 Subject: [PATCH] + client: handle blocked by response in query log --- client/src/__locales/en.json | 5 +++-- client/src/components/Logs/index.js | 22 +++++++++++++++++++--- client/src/helpers/helpers.js | 4 +++- 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/client/src/__locales/en.json b/client/src/__locales/en.json index 6be758f5..f91355ee 100644 --- a/client/src/__locales/en.json +++ b/client/src/__locales/en.json @@ -405,5 +405,6 @@ "netname": "Network name", "descr": "Description", "whois": "Whois", - "filtering_rules_learn_more": "<0>Learn more about creating your own hosts blocklists." -} \ No newline at end of file + "filtering_rules_learn_more": "<0>Learn more about creating your own hosts blocklists.", + "blocked_by_response": "Blocked by CNAME or IP in response" +} diff --git a/client/src/components/Logs/index.js b/client/src/components/Logs/index.js index 3b52f4e4..449a6538 100644 --- a/client/src/components/Logs/index.js +++ b/client/src/components/Logs/index.js @@ -134,9 +134,16 @@ class Logs extends Component { ); }; + normalizeResponse = response => ( + response.map((response) => { + const { value, type, ttl } = response; + return `${type}: ${value} (ttl=${ttl})`; + }) + ); + getResponseCell = ({ value: responses, original }) => { const { - reason, filterId, rule, status, + reason, filterId, rule, status, originalAnswer, } = original; const { t, filtering } = this.props; const { filters } = filtering; @@ -149,6 +156,7 @@ class Logs extends Component { const isBlockedService = reason === FILTERED_STATUS.FILTERED_BLOCKED_SERVICE; const currentService = SERVICES.find(service => service.id === original.serviceName); const serviceName = currentService && currentService.name; + const normalizedAnswer = originalAnswer && this.normalizeResponse(originalAnswer); let filterName = ''; if (filterId === 0) { @@ -168,7 +176,12 @@ class Logs extends Component { return (
- {(isFiltered || isBlockedService) && ( + {originalAnswer && ( + + blocked_by_response + + )} + {!originalAnswer && (isFiltered || isBlockedService) && ( {parsedFilteredReason} @@ -183,7 +196,10 @@ class Logs extends Component { )}
- {this.renderResponseList(responses, status)} + {originalAnswer + ? this.renderResponseList(normalizedAnswer, status) + : this.renderResponseList(responses, status) + } {isWhiteList && this.renderTooltip(isWhiteList, rule, filterName)}
diff --git a/client/src/helpers/helpers.js b/client/src/helpers/helpers.js index 089f0604..d7c78fc2 100644 --- a/client/src/helpers/helpers.js +++ b/client/src/helpers/helpers.js @@ -50,6 +50,7 @@ export const normalizeLogs = logs => logs.map((log) => { rule, service_name, status, + original_answer, } = log; const { host: domain, type } = question; const responsesArray = response ? response.map((response) => { @@ -65,8 +66,9 @@ export const normalizeLogs = logs => logs.map((log) => { client, filterId, rule, - serviceName: service_name, status, + serviceName: service_name, + originalAnswer: original_answer, }; });