diff --git a/client/src/__locales/en.json b/client/src/__locales/en.json index 9634cf70..67c9f55f 100644 --- a/client/src/__locales/en.json +++ b/client/src/__locales/en.json @@ -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}}\"?", diff --git a/client/src/components/Filters/Check/index.tsx b/client/src/components/Filters/Check/index.tsx index 996d6b75..cd10dfc8 100644 --- a/client/src/components/Filters/Check/index.tsx +++ b/client/src/components/Filters/Check/index.tsx @@ -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_id?: string; + dns_record_type?: 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({ + formState: { isValid }, + } = useForm({ mode: 'onBlur', defaultValues: { name: '', + client_id: '', + dns_record_type: DNS_RECORD_TYPES[0], }, }); @@ -48,24 +54,56 @@ const Check = ({ onSubmit }: Props) => { - - - } /> )} /> + ( + + )} + /> + + ( + + )} + /> + + + {hostname && ( <>
diff --git a/client/src/components/Filters/CustomRules.tsx b/client/src/components/Filters/CustomRules.tsx index db7fa92d..24a3b044 100644 --- a/client/src/components/Filters/CustomRules.tsx +++ b/client/src/components/Filters/CustomRules.tsx @@ -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,12 @@ class CustomRules extends Component { this.props.setRules(this.props.filtering.userRules); }; - handleCheck = (values: any) => { - this.props.checkHost(values); + handleCheck = (values: FilteringCheckFormValues) => { + const filteredValues = Object.fromEntries( + Object.entries(values).filter(([_, value]) => value !== undefined && value !== '') + ); + + this.props.checkHost(filteredValues); }; onScroll = (e: any) => syncScroll(e, this.ref); diff --git a/client/src/helpers/constants.ts b/client/src/helpers/constants.ts index 7b54ae8d..d4e7c940 100644 --- a/client/src/helpers/constants.ts +++ b/client/src/helpers/constants.ts @@ -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" +];