diff --git a/client/src/__locales/en.json b/client/src/__locales/en.json index 64c6b4b5..92540ea6 100644 --- a/client/src/__locales/en.json +++ b/client/src/__locales/en.json @@ -79,7 +79,7 @@ "no_settings": "No settings", "general_settings": "General settings", "upstream_dns": "Upstream DNS servers", - "upstream_dns_hint": "If you keep this field empty, AdGuard Home will use Cloudflare DNS<\/a> as an upstream. Use tls:\/\/ prefix for DNS over TLS servers.", + "upstream_dns_hint": "If you keep this field empty, AdGuard Home will use Cloudflare DNS<\/a> as an upstream.", "test_upstream_btn": "Test upstreams", "apply_btn": "Apply", "disabled_filtering_toast": "Disabled filtering", @@ -246,5 +246,8 @@ "form_error_equal": "Shouldn't be equal", "form_error_password": "Password mismatched", "reset_settings": "Reset settings", - "update_announcement": "AdGuard Home {{version}} is now available! <0>Click here<\/0> for more info." -} \ No newline at end of file + "update_announcement": "AdGuard Home {{version}} is now available! <0>Click here for more info.", + "upstream_parallel": "Use parallel queries to speed up resolving by simultaneously querying all upstream servers", + "bootstrap_dns": "Bootstrap DNS servers", + "bootstrap_dns_desc": "Bootstrap DNS servers are used to resolve IP addresses of the DOH/DOT resolvers you specify as upstreams." +} diff --git a/client/src/actions/index.js b/client/src/actions/index.js index 1bb99064..ad63ed16 100644 --- a/client/src/actions/index.js +++ b/client/src/actions/index.js @@ -3,7 +3,7 @@ import round from 'lodash/round'; import { t } from 'i18next'; import { showLoading, hideLoading } from 'react-redux-loading-bar'; -import { normalizeHistory, normalizeFilteringStatus, normalizeLogs } from '../helpers/helpers'; +import { normalizeHistory, normalizeFilteringStatus, normalizeLogs, normalizeTextarea } from '../helpers/helpers'; import { SETTINGS_NAMES } from '../helpers/constants'; import Api from '../api/Api'; @@ -452,10 +452,18 @@ export const setUpstreamRequest = createAction('SET_UPSTREAM_REQUEST'); export const setUpstreamFailure = createAction('SET_UPSTREAM_FAILURE'); export const setUpstreamSuccess = createAction('SET_UPSTREAM_SUCCESS'); -export const setUpstream = url => async (dispatch) => { +export const setUpstream = config => async (dispatch) => { dispatch(setUpstreamRequest()); try { - await apiClient.setUpstream(url); + const values = { ...config }; + values.bootstrap_dns = ( + values.bootstrap_dns && normalizeTextarea(values.bootstrap_dns) + ) || []; + values.upstream_dns = ( + values.upstream_dns && normalizeTextarea(values.upstream_dns) + ) || []; + + await apiClient.setUpstream(values); dispatch(addSuccessToast('updated_upstream_dns_toast')); dispatch(setUpstreamSuccess()); } catch (error) { @@ -468,11 +476,18 @@ export const testUpstreamRequest = createAction('TEST_UPSTREAM_REQUEST'); export const testUpstreamFailure = createAction('TEST_UPSTREAM_FAILURE'); export const testUpstreamSuccess = createAction('TEST_UPSTREAM_SUCCESS'); -export const testUpstream = servers => async (dispatch) => { +export const testUpstream = config => async (dispatch) => { dispatch(testUpstreamRequest()); try { - const upstreamResponse = await apiClient.testUpstream(servers); + const values = { ...config }; + values.bootstrap_dns = ( + values.bootstrap_dns && normalizeTextarea(values.bootstrap_dns) + ) || []; + values.upstream_dns = ( + values.upstream_dns && normalizeTextarea(values.upstream_dns) + ) || []; + const upstreamResponse = await apiClient.testUpstream(values); const testMessages = Object.keys(upstreamResponse).map((key) => { const message = upstreamResponse[key]; if (message !== 'OK') { diff --git a/client/src/api/Api.js b/client/src/api/Api.js index d20a334a..17df1221 100644 --- a/client/src/api/Api.js +++ b/client/src/api/Api.js @@ -34,7 +34,7 @@ export default class Api { GLOBAL_QUERY_LOG = { path: 'querylog', method: 'GET' }; GLOBAL_QUERY_LOG_ENABLE = { path: 'querylog_enable', method: 'POST' }; GLOBAL_QUERY_LOG_DISABLE = { path: 'querylog_disable', method: 'POST' }; - GLOBAL_SET_UPSTREAM_DNS = { path: 'set_upstream_dns', method: 'POST' }; + GLOBAL_SET_UPSTREAM_DNS = { path: 'set_upstreams_config', method: 'POST' }; GLOBAL_TEST_UPSTREAM_DNS = { path: 'test_upstream_dns', method: 'POST' }; GLOBAL_VERSION = { path: 'version.json', method: 'GET' }; GLOBAL_ENABLE_PROTECTION = { path: 'enable_protection', method: 'POST' }; @@ -110,7 +110,7 @@ export default class Api { const { path, method } = this.GLOBAL_SET_UPSTREAM_DNS; const config = { data: url, - header: { 'Content-Type': 'text/plain' }, + headers: { 'Content-Type': 'application/json' }, }; return this.makeRequest(path, method, config); } @@ -119,7 +119,7 @@ export default class Api { const { path, method } = this.GLOBAL_TEST_UPSTREAM_DNS; const config = { data: servers, - header: { 'Content-Type': 'text/plain' }, + headers: { 'Content-Type': 'application/json' }, }; return this.makeRequest(path, method, config); } diff --git a/client/src/components/Settings/Upstream.js b/client/src/components/Settings/Upstream.js deleted file mode 100644 index fe24c4d7..00000000 --- a/client/src/components/Settings/Upstream.js +++ /dev/null @@ -1,97 +0,0 @@ -import React, { Component } from 'react'; -import PropTypes from 'prop-types'; -import classnames from 'classnames'; -import { Trans, withNamespaces } from 'react-i18next'; -import Card from '../ui/Card'; - -class Upstream extends Component { - handleChange = (e) => { - const { value } = e.currentTarget; - this.props.handleUpstreamChange(value); - }; - - handleSubmit = (e) => { - e.preventDefault(); - this.props.handleUpstreamSubmit(); - }; - - handleTest = () => { - this.props.handleUpstreamTest(); - } - - render() { - const testButtonClass = classnames({ - 'btn btn-primary btn-standard mr-2': true, - 'btn btn-primary btn-standard mr-2 btn-loading': this.props.processingTestUpstream, - }); - const { t } = this.props; - - return ( - -
-
-
-