Pull request 2353: AGDNS-2688-check-host
Merge in DNS/adguard-home from AGDNS-2688-check-host to master Squashed commit of the following: commit bd9ed498b0e36fa044e6921fa946062ac40fe616 Merge: 8dffd94a3c41af2763Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Fri Mar 14 13:42:34 2025 +0300 Merge branch 'master' into AGDNS-2688-check-host commit 8dffd94a3bc700cf014cbb16aee9c6339bdc7ffa Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Mar 12 17:12:56 2025 +0300 filtering: imp code commit d9a01c8fa60c70e3fd19c40c1a58aec00ae64a6a Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Mar 11 20:33:18 2025 +0300 all: imp code commit f1aca5f2eb71a1d8bb155a309c618e7a80f8fde5 Author: Ildar Kamalov <ik@adguard.com> Date: Tue Mar 11 16:05:32 2025 +0300 ADG-9783 update check form commit a8ebb0401dbaa08fdd04171b1ac66b87d0228c7b Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon Mar 10 16:41:55 2025 +0300 dnsforward: imp docs commit 36f5db9075cc525c13905e0318dfbc4089355523 Merge: 9a746ee9a66fba942cAuthor: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon Mar 10 16:09:22 2025 +0300 Merge branch 'master' into AGDNS-2688-check-host commit 9a746ee9a05895676a60980eb4bd1381fe8d8e4b Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon Mar 10 16:06:48 2025 +0300 all: imp docs commit 0a25e1e8f3536053e30049497bb42a58c6a153d6 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Mar 6 21:48:44 2025 +0300 all: imp code commit ec618bc484190dde52a0dc57d144bade8dfc22e2 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Mar 6 17:38:35 2025 +0300 all: imp code commit 979c5cfd4c34e2aac46ea11b7fcba8d2929966b8 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Mar 5 21:22:54 2025 +0300 all: add tests commit ce0d6117ad7f341edcc018a68acedaa0b718bef1 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Mar 4 15:13:06 2025 +0300 all: check host
This commit is contained in:
committed by
Eugene Burkov
parent
c41af2763f
commit
1a3853d52a
@@ -620,6 +620,10 @@
|
||||
"check_cname": "CNAME: {{cname}}",
|
||||
"check_reason": "Reason: {{reason}}",
|
||||
"check_service": "Service name: {{service}}",
|
||||
"check_hostname": "Hostname or domain name",
|
||||
"check_client_id": "Client identifier (ClientID or IP address)",
|
||||
"check_enter_client_id": "Enter client identifier",
|
||||
"check_dns_record": "Select DNS record type",
|
||||
"service_name": "Service name",
|
||||
"check_not_found": "Not found in your filter lists",
|
||||
"client_confirm_block": "Are you sure you want to block the client \"{{ip}}\"?",
|
||||
|
||||
@@ -9,13 +9,17 @@ import Info from './Info';
|
||||
import { RootState } from '../../../initialState';
|
||||
import { validateRequiredValue } from '../../../helpers/validators';
|
||||
import { Input } from '../../ui/Controls/Input';
|
||||
import { DNS_RECORD_TYPES } from '../../../helpers/constants';
|
||||
import { Select } from '../../ui/Controls/Select';
|
||||
|
||||
interface FormValues {
|
||||
export type FilteringCheckFormValues = {
|
||||
name: string;
|
||||
client?: string;
|
||||
qtype?: string;
|
||||
}
|
||||
|
||||
type Props = {
|
||||
onSubmit?: (data: FormValues) => void;
|
||||
onSubmit?: (data: FilteringCheckFormValues) => void;
|
||||
};
|
||||
|
||||
const Check = ({ onSubmit }: Props) => {
|
||||
@@ -27,11 +31,13 @@ const Check = ({ onSubmit }: Props) => {
|
||||
const {
|
||||
control,
|
||||
handleSubmit,
|
||||
formState: { isDirty, isValid },
|
||||
} = useForm<FormValues>({
|
||||
formState: { isValid },
|
||||
} = useForm<FilteringCheckFormValues>({
|
||||
mode: 'onBlur',
|
||||
defaultValues: {
|
||||
name: '',
|
||||
client: '',
|
||||
qtype: DNS_RECORD_TYPES[0],
|
||||
},
|
||||
});
|
||||
|
||||
@@ -48,24 +54,56 @@ const Check = ({ onSubmit }: Props) => {
|
||||
<Input
|
||||
{...field}
|
||||
type="text"
|
||||
label={t('check_hostname')}
|
||||
data-testid="check_domain_name"
|
||||
placeholder={t('form_enter_host')}
|
||||
placeholder="example.com"
|
||||
error={fieldState.error?.message}
|
||||
rightAddon={
|
||||
<span className="input-group-append">
|
||||
<button
|
||||
className="btn btn-success btn-standard btn-large"
|
||||
type="submit"
|
||||
data-testid="check_domain_submit"
|
||||
disabled={!isDirty || !isValid || processingCheck}>
|
||||
{t('check')}
|
||||
</button>
|
||||
</span>
|
||||
}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
|
||||
<Controller
|
||||
name="client"
|
||||
control={control}
|
||||
render={({ field, fieldState }) => (
|
||||
<Input
|
||||
{...field}
|
||||
type="text"
|
||||
data-testid="check_client_id"
|
||||
label={t('check_client_id')}
|
||||
placeholder={t('check_enter_client_id')}
|
||||
error={fieldState.error?.message}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
|
||||
<Controller
|
||||
name="qtype"
|
||||
control={control}
|
||||
render={({ field }) => (
|
||||
<Select
|
||||
{...field}
|
||||
label={t('check_dns_record')}
|
||||
data-testid="check_dns_record_type"
|
||||
>
|
||||
{DNS_RECORD_TYPES.map((type) => (
|
||||
<option key={type} value={type}>
|
||||
{type}
|
||||
</option>
|
||||
))}
|
||||
</Select>
|
||||
)}
|
||||
/>
|
||||
|
||||
<button
|
||||
className="btn btn-success btn-standard btn-large"
|
||||
type="submit"
|
||||
data-testid="check_domain_submit"
|
||||
disabled={!isValid || processingCheck}
|
||||
>
|
||||
{t('check')}
|
||||
</button>
|
||||
|
||||
{hostname && (
|
||||
<>
|
||||
<hr />
|
||||
|
||||
@@ -7,7 +7,7 @@ import PageTitle from '../ui/PageTitle';
|
||||
|
||||
import Examples from './Examples';
|
||||
|
||||
import Check from './Check';
|
||||
import Check, { FilteringCheckFormValues } from './Check';
|
||||
|
||||
import { getTextareaCommentsHighlight, syncScroll } from '../../helpers/highlightTextareaComments';
|
||||
import { COMMENT_LINE_DEFAULT_TOKEN } from '../../helpers/constants';
|
||||
@@ -48,8 +48,18 @@ class CustomRules extends Component<CustomRulesProps> {
|
||||
this.props.setRules(this.props.filtering.userRules);
|
||||
};
|
||||
|
||||
handleCheck = (values: any) => {
|
||||
this.props.checkHost(values);
|
||||
handleCheck = (values: FilteringCheckFormValues) => {
|
||||
const params: FilteringCheckFormValues = { name: values.name };
|
||||
|
||||
if (values.client) {
|
||||
params.client = values.client;
|
||||
}
|
||||
|
||||
if (values.qtype) {
|
||||
params.qtype = values.qtype;
|
||||
}
|
||||
|
||||
this.props.checkHost(params);
|
||||
};
|
||||
|
||||
onScroll = (e: any) => syncScroll(e, this.ref);
|
||||
|
||||
@@ -523,3 +523,12 @@ export const TIME_UNITS = {
|
||||
HOURS: 'hours',
|
||||
DAYS: 'days',
|
||||
};
|
||||
|
||||
export const DNS_RECORD_TYPES = [
|
||||
"A", "AAAA", "AFSDB", "APL", "CAA", "CDNSKEY", "CDS", "CERT", "CNAME",
|
||||
"CSYNC", "DHCID", "DLV", "DNAME", "DNSKEY", "DS", "EUI48", "EUI64",
|
||||
"HINFO", "HIP", "HTTPS", "IPSECKEY", "KEY", "KX", "LOC", "MX", "NAPTR",
|
||||
"NS", "NSEC", "NSEC3", "NSEC3PARAM", "OPENPGPKEY", "PTR", "RP", "RRSIG",
|
||||
"SIG", "SMIMEA", "SOA", "SRV", "SSHFP", "SVCB", "TA", "TKEY",
|
||||
"TLSA", "TSIG", "TXT", "URI", "ZONEMD"
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user