Resolve conflict
This commit is contained in:
@@ -55,7 +55,9 @@ export const EMPTY_DATE = '0001-01-01T00:00:00Z';
|
||||
export const DEBOUNCE_TIMEOUT = 300;
|
||||
export const DEBOUNCE_FILTER_TIMEOUT = 500;
|
||||
export const CHECK_TIMEOUT = 1000;
|
||||
export const STOP_TIMEOUT = 10000;
|
||||
export const SUCCESS_TOAST_TIMEOUT = 5000;
|
||||
export const FAILURE_TOAST_TIMEOUT = 30000;
|
||||
export const HIDE_TOOLTIP_DELAY = 300;
|
||||
|
||||
export const UNSAFE_PORTS = [
|
||||
1,
|
||||
@@ -256,18 +258,6 @@ export const ENCRYPTION_SOURCE = {
|
||||
CONTENT: 'content',
|
||||
};
|
||||
|
||||
export const FILTERED_STATUS = {
|
||||
FILTERED_BLACK_LIST: 'FilteredBlackList',
|
||||
NOT_FILTERED_WHITE_LIST: 'NotFilteredWhiteList',
|
||||
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',
|
||||
};
|
||||
|
||||
export const FILTERED = 'Filtered';
|
||||
export const NOT_FILTERED = 'NotFiltered';
|
||||
|
||||
@@ -336,25 +326,124 @@ export const DNS_RECORD_TYPES = [
|
||||
];
|
||||
|
||||
export const DEFAULT_LOGS_FILTER = {
|
||||
filter_domain: '',
|
||||
filter_client: '',
|
||||
filter_question_type: '',
|
||||
filter_response_status: '',
|
||||
search: '',
|
||||
response_status: '',
|
||||
};
|
||||
|
||||
export const DEFAULT_LANGUAGE = 'en';
|
||||
|
||||
export const TABLE_DEFAULT_PAGE_SIZE = 100;
|
||||
export const TABLE_DEFAULT_PAGE_SIZE = 50;
|
||||
|
||||
export const SMALL_TABLE_DEFAULT_PAGE_SIZE = 20;
|
||||
export const TABLE_FIRST_PAGE = 0;
|
||||
|
||||
export const LEASES_TABLE_DEFAULT_PAGE_SIZE = 20;
|
||||
|
||||
export const FILTERED_STATUS = {
|
||||
FILTERED_BLACK_LIST: 'FilteredBlackList',
|
||||
NOT_FILTERED_WHITE_LIST: 'NotFilteredWhiteList',
|
||||
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',
|
||||
};
|
||||
|
||||
export const RESPONSE_FILTER = {
|
||||
ALL: 'all',
|
||||
FILTERED: 'filtered',
|
||||
ALL: {
|
||||
query: 'all',
|
||||
label: 'show_all_responses',
|
||||
},
|
||||
FILTERED: {
|
||||
query: 'filtered',
|
||||
label: 'filtered',
|
||||
},
|
||||
PROCESSED: {
|
||||
query: 'processed',
|
||||
label: 'show_processed_responses',
|
||||
},
|
||||
SPACE: {
|
||||
query: 'all',
|
||||
label: '',
|
||||
disabled: true,
|
||||
},
|
||||
BLOCKED: {
|
||||
query: 'blocked',
|
||||
label: 'show_blocked_responses',
|
||||
},
|
||||
BLOCKED_THREATS: {
|
||||
query: 'blocked_safebrowsing',
|
||||
label: 'blocked_threats',
|
||||
},
|
||||
BLOCKED_ADULT_WEBSITES: {
|
||||
query: 'blocked_parental',
|
||||
label: 'blocked_adult_websites',
|
||||
},
|
||||
ALLOWED: {
|
||||
query: 'whitelisted',
|
||||
label: 'allowed',
|
||||
},
|
||||
REWRITTEN: {
|
||||
query: 'rewritten',
|
||||
label: 'rewritten',
|
||||
},
|
||||
SAFE_SEARCH: {
|
||||
query: 'safe_search',
|
||||
label: 'safe_search',
|
||||
},
|
||||
};
|
||||
|
||||
export const FILTERED_STATUS_TO_META_MAP = {
|
||||
[FILTERED_STATUS.NOT_FILTERED_WHITE_LIST]: {
|
||||
label: RESPONSE_FILTER.ALLOWED.label,
|
||||
color: 'green',
|
||||
},
|
||||
[FILTERED_STATUS.NOT_FILTERED_NOT_FOUND]: {
|
||||
label: RESPONSE_FILTER.PROCESSED.label,
|
||||
color: 'white',
|
||||
},
|
||||
[FILTERED_STATUS.FILTERED_BLOCKED_SERVICE]: {
|
||||
label: RESPONSE_FILTER.BLOCKED.label,
|
||||
color: 'red',
|
||||
},
|
||||
[FILTERED_STATUS.FILTERED_SAFE_SEARCH]: {
|
||||
label: RESPONSE_FILTER.SAFE_SEARCH.label,
|
||||
color: 'yellow',
|
||||
},
|
||||
[FILTERED_STATUS.FILTERED_BLACK_LIST]: {
|
||||
label: RESPONSE_FILTER.BLOCKED.label,
|
||||
color: 'red',
|
||||
},
|
||||
[FILTERED_STATUS.REWRITE]: {
|
||||
label: RESPONSE_FILTER.REWRITTEN.label,
|
||||
color: 'blue',
|
||||
},
|
||||
[FILTERED_STATUS.REWRITE_HOSTS]: {
|
||||
label: RESPONSE_FILTER.REWRITTEN.label,
|
||||
color: 'blue',
|
||||
},
|
||||
[FILTERED_STATUS.FILTERED_SAFE_BROWSING]: {
|
||||
label: RESPONSE_FILTER.BLOCKED_THREATS.label,
|
||||
color: 'yellow',
|
||||
},
|
||||
[FILTERED_STATUS.FILTERED_PARENTAL]: {
|
||||
label: RESPONSE_FILTER.BLOCKED_ADULT_WEBSITES.label,
|
||||
color: 'yellow',
|
||||
},
|
||||
};
|
||||
|
||||
export const DEFAULT_TIME_FORMAT = 'HH:mm:ss';
|
||||
|
||||
export const LONG_TIME_FORMAT = 'HH:mm:ss.SSS';
|
||||
|
||||
export const DEFAULT_SHORT_DATE_FORMAT_OPTIONS = {
|
||||
year: 'numeric',
|
||||
month: 'numeric',
|
||||
day: 'numeric',
|
||||
hour12: false,
|
||||
};
|
||||
|
||||
export const DEFAULT_DATE_FORMAT_OPTIONS = {
|
||||
year: 'numeric',
|
||||
month: 'numeric',
|
||||
@@ -371,9 +460,15 @@ export const DETAILED_DATE_FORMAT_OPTIONS = {
|
||||
|
||||
export const CUSTOM_FILTERING_RULES_ID = 0;
|
||||
|
||||
export const ACTION = {
|
||||
block: 'block',
|
||||
unblock: 'unblock',
|
||||
export const BLOCK_ACTIONS = {
|
||||
BLOCK: 'block',
|
||||
UNBLOCK: 'unblock',
|
||||
};
|
||||
|
||||
export const SCHEME_TO_PROTOCOL_MAP = {
|
||||
doh: 'dns_over_https',
|
||||
dot: 'dns_over_tls',
|
||||
'': 'plain_dns',
|
||||
};
|
||||
|
||||
export const DNS_REQUEST_OPTIONS = {
|
||||
@@ -408,3 +503,5 @@ export const FORM_NAME = {
|
||||
LOGIN: 'login',
|
||||
CACHE: 'cache',
|
||||
};
|
||||
|
||||
export const smallScreenSize = 767;
|
||||
|
||||
@@ -92,10 +92,10 @@ export const renderGroupField = ({
|
||||
&& <span className="input-group-append">
|
||||
<button
|
||||
type="button"
|
||||
className="btn btn-secondary btn-icon"
|
||||
className="btn btn-secondary btn-icon btn-icon--green"
|
||||
onClick={removeField}
|
||||
>
|
||||
<svg className="icon icon--close">
|
||||
<svg className="icon icon--small">
|
||||
<use xlinkHref="#cross" />
|
||||
</svg>
|
||||
</button>
|
||||
|
||||
@@ -5,24 +5,26 @@ import { WHOIS_ICONS } from './constants';
|
||||
const getFormattedWhois = (whois, t) => {
|
||||
const whoisInfo = normalizeWhois(whois);
|
||||
return (
|
||||
Object.keys(whoisInfo).map((key) => {
|
||||
const icon = WHOIS_ICONS[key];
|
||||
return (
|
||||
<span className="logs__whois text-muted" key={key} title={t(key)}>
|
||||
Object.keys(whoisInfo)
|
||||
.map((key) => {
|
||||
const icon = WHOIS_ICONS[key];
|
||||
return (
|
||||
<span className="logs__whois text-muted" key={key} title={t(key)}>
|
||||
{icon && (
|
||||
<Fragment>
|
||||
<svg className="logs__whois-icon icons">
|
||||
<use xlinkHref={`#${icon}`} />
|
||||
</svg>
|
||||
</svg>
|
||||
|
||||
</Fragment>
|
||||
)}{whoisInfo[key]}
|
||||
</span>
|
||||
);
|
||||
})
|
||||
);
|
||||
})
|
||||
);
|
||||
};
|
||||
|
||||
export const formatClientCell = (row, t) => {
|
||||
export const formatClientCell = (row, t, isDetailed = false) => {
|
||||
const { value, original: { info } } = row;
|
||||
let whoisContainer = '';
|
||||
let nameContainer = value;
|
||||
@@ -31,11 +33,13 @@ export const formatClientCell = (row, t) => {
|
||||
const { name, whois_info } = info;
|
||||
|
||||
if (name) {
|
||||
nameContainer = (
|
||||
<span className="logs__text logs__text--wrap" title={`${name} (${value})`}>
|
||||
{name} <small>({value})</small>
|
||||
</span>
|
||||
);
|
||||
nameContainer = isDetailed
|
||||
? <small title={value}>{value}</small>
|
||||
: <div className="logs__text logs__text--nowrap" title={`${name} (${value})`}>
|
||||
{name}
|
||||
{' '}
|
||||
<small>{`(${value})`}</small>
|
||||
</div>;
|
||||
}
|
||||
|
||||
if (whois_info) {
|
||||
@@ -48,11 +52,11 @@ export const formatClientCell = (row, t) => {
|
||||
}
|
||||
|
||||
return (
|
||||
<span className="logs__text">
|
||||
<Fragment>
|
||||
<div className="logs__text" title={value}>
|
||||
<>
|
||||
{nameContainer}
|
||||
{whoisContainer}
|
||||
</Fragment>
|
||||
</span>
|
||||
</>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
/* eslint-disable no-bitwise */
|
||||
import 'url-polyfill';
|
||||
import dateParse from 'date-fns/parse';
|
||||
import dateFormat from 'date-fns/format';
|
||||
@@ -13,29 +12,30 @@ import i18n from 'i18next';
|
||||
import uniqBy from 'lodash/uniqBy';
|
||||
import ipaddr from 'ipaddr.js';
|
||||
import versionCompare from './versionCompare';
|
||||
import { getTrackerData } from './trackers/trackers';
|
||||
|
||||
import {
|
||||
STANDARD_DNS_PORT,
|
||||
STANDARD_WEB_PORT,
|
||||
STANDARD_HTTPS_PORT,
|
||||
CHECK_TIMEOUT,
|
||||
DNS_RECORD_TYPES,
|
||||
DEFAULT_TIME_FORMAT,
|
||||
DEFAULT_DATE_FORMAT_OPTIONS,
|
||||
DETAILED_DATE_FORMAT_OPTIONS,
|
||||
DEFAULT_LANGUAGE,
|
||||
FILTERED_STATUS,
|
||||
DEFAULT_TIME_FORMAT,
|
||||
DETAILED_DATE_FORMAT_OPTIONS,
|
||||
DNS_RECORD_TYPES,
|
||||
FILTERED,
|
||||
FILTERED_STATUS,
|
||||
IP_MATCH_LIST_STATUS,
|
||||
STANDARD_DNS_PORT,
|
||||
STANDARD_HTTPS_PORT,
|
||||
STANDARD_WEB_PORT,
|
||||
} from './constants';
|
||||
|
||||
/**
|
||||
* @param time {string} The time to format
|
||||
* @returns {string} Returns the time in the format HH:mm:ss
|
||||
*/
|
||||
export const formatTime = (time) => {
|
||||
export const formatTime = (time, options = DEFAULT_TIME_FORMAT) => {
|
||||
const parsedTime = dateParse(time);
|
||||
return dateFormat(parsedTime, DEFAULT_TIME_FORMAT);
|
||||
return dateFormat(parsedTime, options);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -68,34 +68,48 @@ export const isToday = (date) => isSameDay(new Date(date), new Date());
|
||||
|
||||
export const normalizeLogs = (logs) => logs.map((log) => {
|
||||
const {
|
||||
time,
|
||||
question,
|
||||
answer: response,
|
||||
reason,
|
||||
answer,
|
||||
answer_dnssec,
|
||||
client,
|
||||
client_proto,
|
||||
elapsedMs,
|
||||
question,
|
||||
reason,
|
||||
status,
|
||||
time,
|
||||
filterId,
|
||||
rule,
|
||||
service_name,
|
||||
status,
|
||||
original_answer,
|
||||
upstream,
|
||||
} = log;
|
||||
|
||||
const { host: domain, type } = question;
|
||||
const responsesArray = response ? response.map((response) => {
|
||||
|
||||
const response = answer ? answer.map((response) => {
|
||||
const { value, type, ttl } = response;
|
||||
return `${type}: ${value} (ttl=${ttl})`;
|
||||
}) : [];
|
||||
|
||||
const tracker = getTrackerData(domain);
|
||||
|
||||
return {
|
||||
time,
|
||||
domain,
|
||||
type,
|
||||
response: responsesArray,
|
||||
response,
|
||||
reason,
|
||||
client,
|
||||
client_proto,
|
||||
filterId,
|
||||
rule,
|
||||
status,
|
||||
serviceName: service_name,
|
||||
originalAnswer: original_answer,
|
||||
tracker,
|
||||
answer_dnssec,
|
||||
elapsedMs,
|
||||
upstream,
|
||||
};
|
||||
});
|
||||
|
||||
@@ -563,6 +577,25 @@ export const getIpMatchListStatus = (ip, list) => {
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {string} elapsedMs
|
||||
* @param {function} t translate
|
||||
* @returns {string}
|
||||
*/
|
||||
export const formatElapsedMs = (elapsedMs, t) => {
|
||||
const formattedElapsedMs = parseInt(elapsedMs, 10) || parseFloat(elapsedMs)
|
||||
.toFixed(2);
|
||||
return `${formattedElapsedMs} ${t('milliseconds_abbreviation')}`;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param language {string}
|
||||
*/
|
||||
export const setHtmlLangAttr = (language) => {
|
||||
window.document.documentElement.lang = language;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param values {object}
|
||||
* @returns {object}
|
||||
|
||||
@@ -3,13 +3,13 @@ import adguardDb from './adguard.json';
|
||||
import { REPOSITORY } from '../constants';
|
||||
|
||||
/**
|
||||
@typedef TrackerData
|
||||
@type {object}
|
||||
@property {string} id - tracker ID.
|
||||
@property {string} name - tracker name.
|
||||
@property {string} url - tracker website url.
|
||||
@property {number} category - tracker category.
|
||||
@property {source} source - tracker data source.
|
||||
@typedef TrackerData
|
||||
@type {object}
|
||||
@property {string} id - tracker ID.
|
||||
@property {string} name - tracker name.
|
||||
@property {string} url - tracker website url.
|
||||
@property {number} category - tracker category.
|
||||
@property {source} source - tracker data source.
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -20,45 +20,6 @@ export const sources = {
|
||||
ADGUARD: 2,
|
||||
};
|
||||
|
||||
/**
|
||||
* Gets tracker data in the specified database
|
||||
*
|
||||
* @param {String} domainName domain name to check
|
||||
* @param {*} trackersDb trackers database
|
||||
* @param {number} source source ID
|
||||
* @returns {TrackerData} tracker data or null if no matching tracker found
|
||||
*/
|
||||
const getTrackerDataFromDb = (domainName, trackersDb, source) => {
|
||||
if (!domainName) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const parts = domainName.split(/\./g).reverse();
|
||||
let hostToCheck = '';
|
||||
|
||||
// Check every subdomain
|
||||
for (let i = 0; i < parts.length; i += 1) {
|
||||
hostToCheck = parts[i] + (i > 0 ? '.' : '') + hostToCheck;
|
||||
const trackerId = trackersDb.trackerDomains[hostToCheck];
|
||||
|
||||
if (trackerId) {
|
||||
const trackerData = trackersDb.trackers[trackerId];
|
||||
const categoryName = trackersDb.categories[trackerData.categoryId];
|
||||
|
||||
return {
|
||||
id: trackerId,
|
||||
name: trackerData.name,
|
||||
url: trackerData.url,
|
||||
category: categoryName,
|
||||
source,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// No tracker found for the specified domain
|
||||
return null;
|
||||
};
|
||||
|
||||
/**
|
||||
* Gets the source metadata for the specified tracker
|
||||
* @param {TrackerData} trackerData tracker data
|
||||
@@ -74,7 +35,8 @@ export const getSourceData = (trackerData) => {
|
||||
name: 'Whotracks.me',
|
||||
url: `https://whotracks.me/trackers/${trackerData.id}.html`,
|
||||
};
|
||||
} if (trackerData.source === sources.ADGUARD) {
|
||||
}
|
||||
if (trackerData.source === sources.ADGUARD) {
|
||||
return {
|
||||
name: 'AdGuard',
|
||||
url: REPOSITORY.TRACKERS_DB,
|
||||
@@ -84,6 +46,49 @@ export const getSourceData = (trackerData) => {
|
||||
return null;
|
||||
};
|
||||
|
||||
/**
|
||||
* Gets tracker data in the specified database
|
||||
*
|
||||
* @param {String} domainName domain name to check
|
||||
* @param {*} trackersDb trackers database
|
||||
* @param {number} source source ID
|
||||
* @returns {TrackerData} tracker data or null if no matching tracker found
|
||||
*/
|
||||
const getTrackerDataFromDb = (domainName, trackersDb, source) => {
|
||||
if (!domainName) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const parts = domainName.split(/\./g)
|
||||
.reverse();
|
||||
let hostToCheck = '';
|
||||
|
||||
// Check every subdomain
|
||||
for (let i = 0; i < parts.length; i += 1) {
|
||||
hostToCheck = parts[i] + (i > 0 ? '.' : '') + hostToCheck;
|
||||
const trackerId = trackersDb.trackerDomains[hostToCheck];
|
||||
|
||||
if (trackerId) {
|
||||
const trackerData = trackersDb.trackers[trackerId];
|
||||
const categoryName = trackersDb.categories[trackerData.categoryId];
|
||||
trackerData.source = source;
|
||||
const sourceData = getSourceData(trackerData);
|
||||
|
||||
return {
|
||||
id: trackerId,
|
||||
name: trackerData.name,
|
||||
url: trackerData.url,
|
||||
category: categoryName,
|
||||
source,
|
||||
sourceData,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// No tracker found for the specified domain
|
||||
return null;
|
||||
};
|
||||
|
||||
/**
|
||||
* Gets tracker data from the trackers database
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user