Merge pull request #65 in DNS/adguard-dns from fix/strings to master

* commit 'd591ea6264bb287a6e57f815a0bc75b7b920bb87':
  Makefile -- run npm build whenever any .js file changes inside client/
  fix strings
  Fix strings
  Fix strings
This commit is contained in:
Eugene Bujak 2018-10-10 17:57:36 +03:00
commit e2295c1a11
13 changed files with 39 additions and 32 deletions

View File

@ -4,7 +4,8 @@ NATIVE_GOARCH = $(shell unset GOARCH; go env GOARCH)
mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST))) mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST)))
mkfile_dir := $(patsubst %/,%,$(dir $(mkfile_path))) mkfile_dir := $(patsubst %/,%,$(dir $(mkfile_path)))
GOPATH := $(mkfile_dir)/build/gopath GOPATH := $(mkfile_dir)/build/gopath
STATIC := build/static/index.html JSFILES = $(shell find client -path client/node_modules -prune -o -type f -name '*.js')
STATIC = build/static/index.html
.PHONY: all build clean .PHONY: all build clean
all: build all: build
@ -15,7 +16,7 @@ client/node_modules: client/package.json client/package-lock.json
npm --prefix client install npm --prefix client install
touch client/node_modules touch client/node_modules
$(STATIC): client/node_modules $(STATIC): $(JSFILES) client/node_modules
npm --prefix client run build-prod npm --prefix client run build-prod
AdguardDNS: $(STATIC) *.go AdguardDNS: $(STATIC) *.go

View File

@ -297,7 +297,7 @@ export const setRules = rules => async (dispatch) => {
.replace(/^\n/g, '') .replace(/^\n/g, '')
.replace(/\n\s*\n/g, '\n'); .replace(/\n\s*\n/g, '\n');
await apiClient.setRules(replacedLineEndings); await apiClient.setRules(replacedLineEndings);
dispatch(addSuccessToast('Custom rules saved')); dispatch(addSuccessToast('Updated the custom filtering rules'));
dispatch(setRulesSuccess()); dispatch(setRulesSuccess());
} catch (error) { } catch (error) {
dispatch(addErrorToast({ error })); dispatch(addErrorToast({ error }));
@ -456,7 +456,7 @@ export const setUpstream = url => async (dispatch) => {
dispatch(setUpstreamRequest()); dispatch(setUpstreamRequest());
try { try {
await apiClient.setUpstream(url); await apiClient.setUpstream(url);
dispatch(addSuccessToast('Upstream DNS servers saved')); dispatch(addSuccessToast('Updated the upstream DNS servers'));
dispatch(setUpstreamSuccess()); dispatch(setUpstreamSuccess());
} catch (error) { } catch (error) {
dispatch(addErrorToast({ error })); dispatch(addErrorToast({ error }));

View File

@ -6,7 +6,7 @@ import map from 'lodash/map';
import Card from '../ui/Card'; import Card from '../ui/Card';
const Clients = props => ( const Clients = props => (
<Card title="Top blocked domains" subtitle="in the last 24 hours" bodyType="card-table" refresh={props.refreshButton}> <Card title="Top blocked domains" subtitle="for the last 24 hours" bodyType="card-table" refresh={props.refreshButton}>
<ReactTable <ReactTable
data={map(props.topBlockedDomains, (value, prop) => ( data={map(props.topBlockedDomains, (value, prop) => (
{ ip: prop, domain: value } { ip: prop, domain: value }

View File

@ -6,7 +6,7 @@ import map from 'lodash/map';
import Card from '../ui/Card'; import Card from '../ui/Card';
const Clients = props => ( const Clients = props => (
<Card title="Top clients" subtitle="in the last 24 hours" bodyType="card-table" refresh={props.refreshButton}> <Card title="Top clients" subtitle="for the last 24 hours" bodyType="card-table" refresh={props.refreshButton}>
<ReactTable <ReactTable
data={map(props.topClients, (value, prop) => ( data={map(props.topClients, (value, prop) => (
{ ip: prop, count: value } { ip: prop, count: value }
@ -15,7 +15,7 @@ const Clients = props => (
Header: 'IP', Header: 'IP',
accessor: 'ip', accessor: 'ip',
}, { }, {
Header: 'Request count', Header: 'Requests count',
accessor: 'count', accessor: 'count',
}]} }]}
showPagination={false} showPagination={false}

View File

@ -7,13 +7,13 @@ import Tooltip from '../ui/Tooltip';
const tooltipType = 'tooltip-custom--narrow'; const tooltipType = 'tooltip-custom--narrow';
const Counters = props => ( const Counters = props => (
<Card title="General statistics" subtitle="in the last 24 hours" bodyType="card-table" refresh={props.refreshButton}> <Card title="General statistics" subtitle="for the last 24 hours" bodyType="card-table" refresh={props.refreshButton}>
<table className="table card-table"> <table className="table card-table">
<tbody> <tbody>
<tr> <tr>
<td> <td>
DNS Queries DNS Queries
<Tooltip text="A number of DNS quieries processed in the last 24 hours" type={tooltipType} /> <Tooltip text="A number of DNS quieries processed for the last 24 hours" type={tooltipType} />
</td> </td>
<td className="text-right"> <td className="text-right">
<span className="text-muted"> <span className="text-muted">
@ -23,8 +23,8 @@ const Counters = props => (
</tr> </tr>
<tr> <tr>
<td> <td>
Blocked by filters Blocked by <a href="#filters">Filters</a>
<Tooltip text="A number of DNS requests blocked by filters" type={tooltipType} /> <Tooltip text="A number of DNS requests blocked by adblock filters and hosts blocklists" type={tooltipType} />
</td> </td>
<td className="text-right"> <td className="text-right">
<span className="text-muted"> <span className="text-muted">
@ -35,7 +35,7 @@ const Counters = props => (
<tr> <tr>
<td> <td>
Blocked malware/phishing Blocked malware/phishing
<Tooltip text="A number of DNS requests blocked" type={tooltipType} /> <Tooltip text="A number of DNS requests blocked by the AdGuard browsing security module" type={tooltipType} />
</td> </td>
<td className="text-right"> <td className="text-right">
<span className="text-muted"> <span className="text-muted">

View File

@ -6,7 +6,7 @@ import map from 'lodash/map';
import Card from '../ui/Card'; import Card from '../ui/Card';
const QueriedDomains = props => ( const QueriedDomains = props => (
<Card title="Top queried domains" subtitle="in the last 24 hours" bodyType="card-table" refresh={props.refreshButton}> <Card title="Top queried domains" subtitle="for the last 24 hours" bodyType="card-table" refresh={props.refreshButton}>
<ReactTable <ReactTable
data={map(props.topQueriedDomains, (value, prop) => ( data={map(props.topQueriedDomains, (value, prop) => (
{ ip: prop, count: value } { ip: prop, count: value }
@ -15,7 +15,7 @@ const QueriedDomains = props => (
Header: 'IP', Header: 'IP',
accessor: 'ip', accessor: 'ip',
}, { }, {
Header: 'Request count', Header: 'Requests count',
accessor: 'count', accessor: 'count',
}]} }]}
showPagination={false} showPagination={false}

View File

@ -5,7 +5,7 @@ import PropTypes from 'prop-types';
import Card from '../ui/Card'; import Card from '../ui/Card';
const Statistics = props => ( const Statistics = props => (
<Card title="Statistics" subtitle="Last 24 hours" bodyType="card-graph" refresh={props.refreshButton}> <Card title="Statistics" subtitle="for the last 24 hours" bodyType="card-graph" refresh={props.refreshButton}>
{props.history ? {props.history ?
<ResponsiveLine <ResponsiveLine
data={props.history} data={props.history}

View File

@ -39,11 +39,11 @@ class Filters extends Component {
width: 90, width: 90,
className: 'text-center', className: 'text-center',
}, { }, {
Header: 'Filter name', Header: 'Name',
accessor: 'name', accessor: 'name',
Cell: ({ value }) => (<div className="logs__row logs__row--overflow"><span className="logs__text" title={value}>{value}</span></div>), Cell: ({ value }) => (<div className="logs__row logs__row--overflow"><span className="logs__text" title={value}>{value}</span></div>),
}, { }, {
Header: 'Host file URL', Header: 'Filter URL',
accessor: 'url', accessor: 'url',
Cell: ({ value }) => (<div className="logs__row logs__row--overflow"><a href={value} target='_blank' rel='noopener noreferrer' className="link logs__text">{value}</a></div>), Cell: ({ value }) => (<div className="logs__row logs__row--overflow"><a href={value} target='_blank' rel='noopener noreferrer' className="link logs__text">{value}</a></div>),
}, { }, {
@ -51,7 +51,7 @@ class Filters extends Component {
accessor: 'rulesCount', accessor: 'rulesCount',
className: 'text-center', className: 'text-center',
}, { }, {
Header: 'Last time update', Header: 'Last time updated',
accessor: 'lastUpdated', accessor: 'lastUpdated',
className: 'text-center', className: 'text-center',
}, { }, {
@ -73,7 +73,7 @@ class Filters extends Component {
<div className="row"> <div className="row">
<div className="col-md-12"> <div className="col-md-12">
<Card <Card
title="Blocking filters and hosts files" title="Filters and hosts blocklists"
subtitle="AdGuard DNS understands basic adblock rules and hosts files syntax." subtitle="AdGuard DNS understands basic adblock rules and hosts files syntax."
> >
<ReactTable <ReactTable
@ -104,7 +104,7 @@ class Filters extends Component {
addFilter={this.props.addFilter} addFilter={this.props.addFilter}
isFilterAdded={this.props.filtering.isFilterAdded} isFilterAdded={this.props.filtering.isFilterAdded}
title="New filter subscription" title="New filter subscription"
inputDescription="Enter valid URL or file path of the filter into field above. You will be subscribed to that filter." inputDescription="Enter a valid URL to a filter subscription or a hosts file."
/> />
</div> </div>
); );

View File

@ -51,10 +51,10 @@ class Logs extends Component {
if (userRules.match(preparedBlockingRule)) { if (userRules.match(preparedBlockingRule)) {
this.props.setRules(userRules.replace(`${blockingRule}`, '')); this.props.setRules(userRules.replace(`${blockingRule}`, ''));
this.props.addSuccessToast(`Removing rule from custom list: ${blockingRule}`); this.props.addSuccessToast(`Rule removed from the custom filtering rules: ${blockingRule}`);
} else if (!userRules.match(preparedUnblockingRule)) { } else if (!userRules.match(preparedUnblockingRule)) {
this.props.setRules(`${userRules}${lineEnding}${unblockingRule}\n`); this.props.setRules(`${userRules}${lineEnding}${unblockingRule}\n`);
this.props.addSuccessToast(`Adding rule to custom list: ${unblockingRule}`); this.props.addSuccessToast(`Rule added to the custom filtering rules: ${unblockingRule}`);
} }
this.props.getFilteringStatus(); this.props.getFilteringStatus();

View File

@ -27,7 +27,7 @@ export default class Upstream extends Component {
return ( return (
<Card <Card
title="Upstream DNS servers" title="Upstream DNS servers"
subtitle="If you keep this field empty, AdGuard will use <a href='https://1.1.1.1/' target='_blank'>Cloudflare DNS</a> as an upstream." subtitle="If you keep this field empty, AdGuard will use <a href='https://1.1.1.1/' target='_blank'>Cloudflare DNS</a> as an upstream. Use tls:// prefix for DNS over TLS servers."
bodyType="card-body box-body--settings" bodyType="card-body box-body--settings"
> >
<div className="row"> <div className="row">

View File

@ -17,7 +17,7 @@ export default class Settings extends Component {
safebrowsing: { safebrowsing: {
enabled: false, enabled: false,
title: 'Use AdGuard browsing security web service', title: 'Use AdGuard browsing security web service',
subtitle: 'AdGuard DNS will check if domain is blacklisted by the browsing security web service (sb.adtidy.org). It will use privacy-safe lookup API to do the check.', subtitle: 'AdGuard DNS will check if domain is blacklisted by the browsing security web service. It will use privacy-friendly lookup API to perform the check: only a short prefix of the domain name SHA256 hash is sent to the server.',
}, },
parental: { parental: {
enabled: false, enabled: false,
@ -27,7 +27,7 @@ export default class Settings extends Component {
safesearch: { safesearch: {
enabled: false, enabled: false,
title: 'Enforce safe search', title: 'Enforce safe search',
subtitle: 'AdGuard DNS can enforce safe search in the major search engines: Google, Bing, Yandex.', subtitle: 'AdGuard DNS can enforce safe search in the following search engines: Google, Bing, Yandex.',
}, },
}; };

View File

@ -34,8 +34,20 @@ export const normalizeLogs = logs => logs.map((log) => {
}; };
}); });
const STATS_NAMES = {
avg_processing_time: 'Average processing time',
blocked_filtering: 'Blocked by filters',
dns_queries: 'DNS queries',
replaced_parental: 'Blocked adult websites',
replaced_safebrowsing: 'Blocked malware/phishing',
replaced_safesearch: 'Enforced safe search',
};
export const normalizeHistory = history => Object.keys(history).map((key) => { export const normalizeHistory = history => Object.keys(history).map((key) => {
const id = key.replace(/_/g, ' ').replace(/^\w/, c => c.toUpperCase()); let id = STATS_NAMES[key];
if (!id) {
id = key.replace(/_/g, ' ').replace(/^\w/, c => c.toUpperCase());
}
const dayAgo = subHours(Date.now(), 24); const dayAgo = subHours(Date.now(), 24);

View File

@ -19,12 +19,6 @@ import (
"github.com/miekg/dns" "github.com/miekg/dns"
) )
// top domains/clients/blocked stats in the last 24 hours
// on start we read the saved stats from the last 24 hours and add them to the stats
// stats are counted using hourly LRU, rotating hourly and keeping last 24 hours
type hourTop struct { type hourTop struct {
domains gcache.Cache domains gcache.Cache
blocked gcache.Cache blocked gcache.Cache