Squashed commit of the following: commit 69d23105ce68e61132f2eb6571deb41fad25efbf Merge: 76df0402758b47adafAuthor: Ildar Kamalov <ik@adguard.com> Date: Tue Jan 16 12:22:52 2024 +0300 Merge branch 'master' into ADG-7965 commit 76df04027f52157b7ac820888bf8b91ecb93c48c Author: Ildar Kamalov <ik@adguard.com> Date: Fri Jan 12 13:18:21 2024 +0300 remove changelog commit e79b7bffdd8e9dc6d530049489e9fe8365827ae6 Merge: df0f189291e0ff4d43Author: Ildar Kamalov <ik@adguard.com> Date: Fri Jan 12 13:17:50 2024 +0300 Merge branch 'master' into ADG-7965 commit df0f18929f4d4b7f9d20347fa5f8481b667a1bd8 Author: Ildar Kamalov <ik@adguard.com> Date: Wed Jan 10 19:21:34 2024 +0300 fix changelog commit 814308708d13e2f8a0077941e9547f379ee8f375 Author: Ildar Kamalov <ik@adguard.com> Date: Wed Jan 10 18:04:24 2024 +0300 handle empty string commit e9e672cd99c6dddad567dbf384c7ea30ff2262cc Author: Ildar Kamalov <ik@adguard.com> Date: Tue Jan 9 16:15:02 2024 +0300 changelog commit 34fb9b71e882ed5230df8d4caca88a930996f86b Author: Ildar Kamalov <ik@adguard.com> Date: Tue Jan 9 13:23:09 2024 +0300 ADG-7965 replace empty string with load_balance for upstream_mode
65 lines
2.5 KiB
JavaScript
65 lines
2.5 KiB
JavaScript
import { handleActions } from 'redux-actions';
|
|
|
|
import * as actions from '../actions/dnsConfig';
|
|
import { ALL_INTERFACES_IP, BLOCKING_MODES, DNS_REQUEST_OPTIONS } from '../helpers/constants';
|
|
|
|
const DEFAULT_BLOCKING_IPV4 = ALL_INTERFACES_IP;
|
|
const DEFAULT_BLOCKING_IPV6 = '::';
|
|
|
|
const dnsConfig = handleActions(
|
|
{
|
|
[actions.getDnsConfigRequest]: (state) => ({ ...state, processingGetConfig: true }),
|
|
[actions.getDnsConfigFailure]: (state) => ({ ...state, processingGetConfig: false }),
|
|
[actions.getDnsConfigSuccess]: (state, { payload }) => {
|
|
const {
|
|
blocking_ipv4,
|
|
blocking_ipv6,
|
|
upstream_dns,
|
|
upstream_mode,
|
|
fallback_dns,
|
|
bootstrap_dns,
|
|
local_ptr_upstreams,
|
|
ratelimit_whitelist,
|
|
...values
|
|
} = payload;
|
|
|
|
return {
|
|
...state,
|
|
...values,
|
|
blocking_ipv4: blocking_ipv4 || DEFAULT_BLOCKING_IPV4,
|
|
blocking_ipv6: blocking_ipv6 || DEFAULT_BLOCKING_IPV6,
|
|
upstream_dns: (upstream_dns && upstream_dns.join('\n')) || '',
|
|
fallback_dns: (fallback_dns && fallback_dns.join('\n')) || '',
|
|
bootstrap_dns: (bootstrap_dns && bootstrap_dns.join('\n')) || '',
|
|
local_ptr_upstreams: (local_ptr_upstreams && local_ptr_upstreams.join('\n')) || '',
|
|
ratelimit_whitelist: (ratelimit_whitelist && ratelimit_whitelist.join('\n')) || '',
|
|
processingGetConfig: false,
|
|
upstream_mode: upstream_mode === '' ? DNS_REQUEST_OPTIONS.LOAD_BALANCING : upstream_mode,
|
|
};
|
|
},
|
|
|
|
[actions.setDnsConfigRequest]: (state) => ({ ...state, processingSetConfig: true }),
|
|
[actions.setDnsConfigFailure]: (state) => ({ ...state, processingSetConfig: false }),
|
|
[actions.setDnsConfigSuccess]: (state, { payload }) => ({
|
|
...state,
|
|
...payload,
|
|
processingSetConfig: false,
|
|
}),
|
|
},
|
|
{
|
|
processingGetConfig: false,
|
|
processingSetConfig: false,
|
|
blocking_mode: BLOCKING_MODES.default,
|
|
ratelimit: 20,
|
|
blocking_ipv4: DEFAULT_BLOCKING_IPV4,
|
|
blocking_ipv6: DEFAULT_BLOCKING_IPV6,
|
|
blocked_response_ttl: 10,
|
|
edns_cs_enabled: false,
|
|
disable_ipv6: false,
|
|
dnssec_enabled: false,
|
|
upstream_dns_file: '',
|
|
},
|
|
);
|
|
|
|
export default dnsConfig;
|