Merge: + DNS: "dns.upstream_dns_file" setting
Merge in DNS/adguard-home from 1680-upstreams-file to master Fix #1680 * commit '88c67764b9515902514b0a8e4f00af29a353c584': * (dnsforward): don't fail when default upstream is not set * (dnsforward): upgrade dnsproxy to v0.32.1 * (ui): fix strings + client: Display upstreams list loaded from a file + DNS: "dns.upstream_dns_file" setting
This commit is contained in:
@@ -132,7 +132,8 @@
|
||||
"encryption_settings": "Encryption settings",
|
||||
"dhcp_settings": "DHCP settings",
|
||||
"upstream_dns": "Upstream DNS servers",
|
||||
"upstream_dns_hint": "If you keep this field empty, AdGuard Home will use <a href='https://www.quad9.net/' target='_blank'>Quad9</a> as an upstream.",
|
||||
"upstream_dns_help": "Enter servers addresses one per line. <0>Learn more</0> about configuring upstream DNS servers.",
|
||||
"upstream_dns_configured_in_file": "Configured in {{path}}",
|
||||
"test_upstream_btn": "Test upstreams",
|
||||
"upstreams": "Upstreams",
|
||||
"apply_btn": "Apply",
|
||||
|
||||
@@ -7,49 +7,56 @@ import classnames from 'classnames';
|
||||
|
||||
import Examples from './Examples';
|
||||
import { renderRadioField, renderTextareaField } from '../../../../helpers/form';
|
||||
import { DNS_REQUEST_OPTIONS, FORM_NAME } from '../../../../helpers/constants';
|
||||
import { DNS_REQUEST_OPTIONS, FORM_NAME, UPSTREAM_CONFIGURATION_WIKI_LINK } from '../../../../helpers/constants';
|
||||
import { testUpstream } from '../../../../actions';
|
||||
import { removeEmptyLines } from '../../../../helpers/helpers';
|
||||
|
||||
const getInputFields = () => [{
|
||||
// eslint-disable-next-line react/display-name
|
||||
getTitle: () => <label className="form__label" htmlFor="upstream_dns">
|
||||
<Trans>upstream_dns</Trans>
|
||||
</label>,
|
||||
name: 'upstream_dns',
|
||||
type: 'text',
|
||||
component: renderTextareaField,
|
||||
className: 'form-control form-control--textarea font-monospace',
|
||||
placeholder: 'upstream_dns',
|
||||
normalizeOnBlur: removeEmptyLines,
|
||||
},
|
||||
{
|
||||
name: 'upstream_mode',
|
||||
type: 'radio',
|
||||
value: DNS_REQUEST_OPTIONS.LOAD_BALANCING,
|
||||
component: renderRadioField,
|
||||
subtitle: 'load_balancing_desc',
|
||||
placeholder: 'load_balancing',
|
||||
},
|
||||
{
|
||||
name: 'upstream_mode',
|
||||
type: 'radio',
|
||||
value: DNS_REQUEST_OPTIONS.PARALLEL,
|
||||
component: renderRadioField,
|
||||
subtitle: 'upstream_parallel',
|
||||
placeholder: 'parallel_requests',
|
||||
},
|
||||
{
|
||||
name: 'upstream_mode',
|
||||
type: 'radio',
|
||||
value: DNS_REQUEST_OPTIONS.FASTEST_ADDR,
|
||||
component: renderRadioField,
|
||||
subtitle: 'fastest_addr_desc',
|
||||
placeholder: 'fastest_addr',
|
||||
}];
|
||||
const Title = () => <label className="form__label" htmlFor="upstream_dns">
|
||||
<Trans components={[<a href={UPSTREAM_CONFIGURATION_WIKI_LINK} key="0">link</a>]}>
|
||||
upstream_dns_help
|
||||
</Trans>
|
||||
</label>;
|
||||
|
||||
const getInputFields = (upstream_dns_file) => [
|
||||
{
|
||||
getTitle: Title,
|
||||
name: 'upstream_dns',
|
||||
type: 'text',
|
||||
value: 'test',
|
||||
component: renderTextareaField,
|
||||
className: 'form-control form-control--textarea font-monospace',
|
||||
placeholder: 'upstream_dns',
|
||||
normalizeOnBlur: removeEmptyLines,
|
||||
disabled: !!upstream_dns_file,
|
||||
},
|
||||
{
|
||||
name: 'upstream_mode',
|
||||
type: 'radio',
|
||||
value: DNS_REQUEST_OPTIONS.LOAD_BALANCING,
|
||||
component: renderRadioField,
|
||||
subtitle: 'load_balancing_desc',
|
||||
placeholder: 'load_balancing',
|
||||
},
|
||||
{
|
||||
name: 'upstream_mode',
|
||||
type: 'radio',
|
||||
value: DNS_REQUEST_OPTIONS.PARALLEL,
|
||||
component: renderRadioField,
|
||||
subtitle: 'upstream_parallel',
|
||||
placeholder: 'parallel_requests',
|
||||
},
|
||||
{
|
||||
name: 'upstream_mode',
|
||||
type: 'radio',
|
||||
value: DNS_REQUEST_OPTIONS.FASTEST_ADDR,
|
||||
component: renderRadioField,
|
||||
subtitle: 'fastest_addr_desc',
|
||||
placeholder: 'fastest_addr',
|
||||
},
|
||||
];
|
||||
|
||||
const Form = ({
|
||||
submitting, invalid, processingSetConfig, processingTestUpstream, handleSubmit,
|
||||
submitting, invalid, handleSubmit,
|
||||
}) => {
|
||||
const dispatch = useDispatch();
|
||||
const { t } = useTranslation();
|
||||
@@ -57,6 +64,9 @@ const Form = ({
|
||||
const bootstrap_dns = useSelector(
|
||||
(store) => store.form[FORM_NAME.UPSTREAM].values.bootstrap_dns,
|
||||
);
|
||||
const upstream_dns_file = useSelector((state) => state.dnsConfig.upstream_dns_file);
|
||||
const processingTestUpstream = useSelector((state) => state.settings.processingTestUpstream);
|
||||
const processingSetConfig = useSelector((state) => state.dnsConfig.processingSetConfig);
|
||||
|
||||
const handleUpstreamTest = () => dispatch(testUpstream({
|
||||
upstream_dns,
|
||||
@@ -67,7 +77,7 @@ const Form = ({
|
||||
'btn-loading': processingTestUpstream,
|
||||
});
|
||||
|
||||
const INPUT_FIELDS = getInputFields();
|
||||
const INPUT_FIELDS = getInputFields(upstream_dns_file);
|
||||
|
||||
return <form onSubmit={handleSubmit}>
|
||||
<div className="row">
|
||||
@@ -146,8 +156,6 @@ Form.propTypes = {
|
||||
initialValues: PropTypes.object,
|
||||
upstream_dns: PropTypes.string,
|
||||
bootstrap_dns: PropTypes.string,
|
||||
processingTestUpstream: PropTypes.bool,
|
||||
processingSetConfig: PropTypes.bool,
|
||||
};
|
||||
|
||||
export default reduxForm({ form: FORM_NAME.UPSTREAM })(Form);
|
||||
|
||||
@@ -12,31 +12,41 @@ const Upstream = () => {
|
||||
upstream_dns,
|
||||
bootstrap_dns,
|
||||
upstream_mode,
|
||||
processingSetConfig,
|
||||
} = useSelector((state) => state.dnsConfig, shallowEqual);
|
||||
|
||||
const { processingTestUpstream } = useSelector((state) => state.settings, shallowEqual);
|
||||
const upstream_dns_file = useSelector((state) => state.dnsConfig.upstream_dns_file);
|
||||
|
||||
const handleSubmit = (values) => {
|
||||
dispatch(setDnsConfig(values));
|
||||
const {
|
||||
bootstrap_dns,
|
||||
upstream_dns,
|
||||
upstream_mode,
|
||||
} = values;
|
||||
|
||||
const dnsConfig = {
|
||||
bootstrap_dns,
|
||||
upstream_mode,
|
||||
...(upstream_dns_file ? null : { upstream_dns }),
|
||||
};
|
||||
|
||||
dispatch(setDnsConfig(dnsConfig));
|
||||
};
|
||||
|
||||
const upstreamDns = upstream_dns_file ? t('upstream_dns_configured_in_file', { path: upstream_dns_file }) : upstream_dns;
|
||||
|
||||
return <Card
|
||||
title={t('upstream_dns')}
|
||||
subtitle={t('upstream_dns_hint')}
|
||||
bodyType="card-body box-body--settings"
|
||||
>
|
||||
<div className="row">
|
||||
<div className="col">
|
||||
<Form
|
||||
initialValues={{
|
||||
upstream_dns,
|
||||
upstream_dns: upstreamDns,
|
||||
bootstrap_dns,
|
||||
upstream_mode,
|
||||
}}
|
||||
onSubmit={handleSubmit}
|
||||
processingTestUpstream={processingTestUpstream}
|
||||
processingSetConfig={processingSetConfig}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -52,6 +52,7 @@ export const REPOSITORY = {
|
||||
|
||||
export const PRIVACY_POLICY_LINK = 'https://adguard.com/privacy/home.html';
|
||||
export const PORT_53_FAQ_LINK = 'https://github.com/AdguardTeam/AdGuardHome/wiki/FAQ#bindinuse';
|
||||
export const UPSTREAM_CONFIGURATION_WIKI_LINK = 'https://github.com/AdguardTeam/AdGuardHome/wiki/Configuration#upstreams';
|
||||
|
||||
export const GETTING_STARTED_LINK = 'https://github.com/AdguardTeam/AdGuardHome/wiki/Getting-Started#update';
|
||||
|
||||
|
||||
@@ -48,6 +48,7 @@ const dnsConfig = handleActions(
|
||||
edns_cs_enabled: false,
|
||||
disable_ipv6: false,
|
||||
dnssec_enabled: false,
|
||||
upstream_dns_file: '',
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user