+ client: handle rewrite auto

This commit is contained in:
Ildar Kamalov 2020-03-19 16:09:17 +03:00
parent 2f9bc13ffd
commit c7f8f20aad
5 changed files with 29 additions and 3 deletions

View File

@ -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",

View File

@ -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';

View File

@ -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 {
<Trans>rewrite_applied</Trans>
</strong>
)}
{isRewriteAuto && (
<span className="logs__text">
<strong>
<Trans>rewrite_hosts_applied</Trans>
</strong>
</span>
)}
</div>
<div className="logs__list-wrap">
{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 (
<div className="logs__row logs__row--overflow logs__row--column">
{formatClientCell(row, t)}
</div>
);
}
return (
<Fragment>
@ -364,7 +382,7 @@ class Logs extends Component {
return {
className: 'green',
};
} else if (checkRewrite(reason)) {
} else if (checkRewrite(reason) || checkRewriteHosts(reason)) {
return {
className: 'blue',
};

View File

@ -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',

View File

@ -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;