2019-12-04 18:52:38 +00:00
|
|
|
import { handleActions } from 'redux-actions';
|
|
|
|
|
|
|
|
import * as actions from '../actions/dnsConfig';
|
2020-08-19 15:23:05 +00:00
|
|
|
import { ALL_INTERFACES_IP, BLOCKING_MODES } from '../helpers/constants';
|
2019-12-04 18:52:38 +00:00
|
|
|
|
2020-08-19 15:23:05 +00:00
|
|
|
const DEFAULT_BLOCKING_IPV4 = ALL_INTERFACES_IP;
|
2019-12-05 13:00:20 +00:00
|
|
|
const DEFAULT_BLOCKING_IPV6 = '::';
|
|
|
|
|
2019-12-04 18:52:38 +00:00
|
|
|
const dnsConfig = handleActions(
|
|
|
|
{
|
2020-05-22 14:06:05 +00:00
|
|
|
[actions.getDnsConfigRequest]: (state) => ({ ...state, processingGetConfig: true }),
|
|
|
|
[actions.getDnsConfigFailure]: (state) => ({ ...state, processingGetConfig: false }),
|
2019-12-05 13:00:20 +00:00
|
|
|
[actions.getDnsConfigSuccess]: (state, { payload }) => {
|
|
|
|
const {
|
|
|
|
blocking_ipv4,
|
|
|
|
blocking_ipv6,
|
2020-04-22 16:32:07 +00:00
|
|
|
upstream_dns,
|
|
|
|
bootstrap_dns,
|
2019-12-05 13:00:20 +00:00
|
|
|
...values
|
|
|
|
} = payload;
|
|
|
|
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
...values,
|
|
|
|
blocking_ipv4: blocking_ipv4 || DEFAULT_BLOCKING_IPV4,
|
|
|
|
blocking_ipv6: blocking_ipv6 || DEFAULT_BLOCKING_IPV6,
|
2020-04-22 16:32:07 +00:00
|
|
|
upstream_dns: (upstream_dns && upstream_dns.join('\n')) || '',
|
|
|
|
bootstrap_dns: (bootstrap_dns && bootstrap_dns.join('\n')) || '',
|
2019-12-05 13:00:20 +00:00
|
|
|
processingGetConfig: false,
|
|
|
|
};
|
|
|
|
},
|
2019-12-04 18:52:38 +00:00
|
|
|
|
2020-05-22 14:06:05 +00:00
|
|
|
[actions.setDnsConfigRequest]: (state) => ({ ...state, processingSetConfig: true }),
|
|
|
|
[actions.setDnsConfigFailure]: (state) => ({ ...state, processingSetConfig: false }),
|
2019-12-04 18:52:38 +00:00
|
|
|
[actions.setDnsConfigSuccess]: (state, { payload }) => ({
|
|
|
|
...state,
|
|
|
|
...payload,
|
|
|
|
processingSetConfig: false,
|
|
|
|
}),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
processingGetConfig: false,
|
|
|
|
processingSetConfig: false,
|
2020-01-17 12:03:47 +00:00
|
|
|
blocking_mode: BLOCKING_MODES.default,
|
2019-12-04 18:52:38 +00:00
|
|
|
ratelimit: 20,
|
2019-12-05 13:00:20 +00:00
|
|
|
blocking_ipv4: DEFAULT_BLOCKING_IPV4,
|
|
|
|
blocking_ipv6: DEFAULT_BLOCKING_IPV6,
|
|
|
|
edns_cs_enabled: false,
|
2019-12-18 10:17:24 +00:00
|
|
|
disable_ipv6: false,
|
2020-02-18 11:35:27 +00:00
|
|
|
dnssec_enabled: false,
|
2020-09-08 11:06:19 +00:00
|
|
|
upstream_dns_file: '',
|
2019-12-04 18:52:38 +00:00
|
|
|
},
|
|
|
|
);
|
|
|
|
|
|
|
|
export default dnsConfig;
|