mirror of
https://github.com/itdoginfo/podkop.git
synced 2025-12-06 19:46:52 +03:00
feat: add custom port support to dns
This commit is contained in:
@@ -3,7 +3,18 @@ import { validateDNS } from '../validateDns.js';
|
|||||||
import { invalidIPs, validIPs } from './validateIp.test';
|
import { invalidIPs, validIPs } from './validateIp.test';
|
||||||
import { invalidDomains, validDomains } from './validateDomain.test';
|
import { invalidDomains, validDomains } from './validateDomain.test';
|
||||||
|
|
||||||
const validDns = [...validIPs, ...validDomains];
|
export const additionalValidDns = [
|
||||||
|
['Google DNS (port 53)', '8.8.8.8:53'],
|
||||||
|
['Google DNS (port 5353)', '8.8.8.8:5353'],
|
||||||
|
['Cloudflare DNS (port 853)', '1.1.1.1:853'],
|
||||||
|
['Cloudflare domain (port 853)', 'cloudflare-dns.com:853'],
|
||||||
|
['DoH IP', '1.1.1.1/dns-query'],
|
||||||
|
['DoH IP with port 443', '1.1.1.1:443/dns-query'],
|
||||||
|
['DoH domain', 'cloudflare-dns.com/dns-query'],
|
||||||
|
['DoH domain with port 443', 'cloudflare-dns.com:443/dns-query'],
|
||||||
|
];
|
||||||
|
|
||||||
|
const validDns = [...validIPs, ...validDomains, ...additionalValidDns];
|
||||||
|
|
||||||
const invalidDns = [...invalidIPs, ...invalidDomains];
|
const invalidDns = [...invalidIPs, ...invalidDomains];
|
||||||
|
|
||||||
|
|||||||
@@ -7,11 +7,14 @@ export function validateDNS(value: string): ValidationResult {
|
|||||||
return { valid: false, message: _('DNS server address cannot be empty') };
|
return { valid: false, message: _('DNS server address cannot be empty') };
|
||||||
}
|
}
|
||||||
|
|
||||||
if (validateIPV4(value).valid) {
|
const cleanedValueWithoutPort = value.replace(/:(\d+)(?=\/|$)/, '');
|
||||||
|
const cleanedIpWithoutPath = cleanedValueWithoutPort.split('/')[0];
|
||||||
|
|
||||||
|
if (validateIPV4(cleanedIpWithoutPath).valid) {
|
||||||
return { valid: true, message: _('Valid') };
|
return { valid: true, message: _('Valid') };
|
||||||
}
|
}
|
||||||
|
|
||||||
if (validateDomain(value).valid) {
|
if (validateDomain(cleanedValueWithoutPort).valid) {
|
||||||
return { valid: true, message: _('Valid') };
|
return { valid: true, message: _('Valid') };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -40,10 +40,12 @@ function validateDNS(value) {
|
|||||||
if (!value) {
|
if (!value) {
|
||||||
return { valid: false, message: _("DNS server address cannot be empty") };
|
return { valid: false, message: _("DNS server address cannot be empty") };
|
||||||
}
|
}
|
||||||
if (validateIPV4(value).valid) {
|
const cleanedValueWithoutPort = value.replace(/:(\d+)(?=\/|$)/, "");
|
||||||
|
const cleanedIpWithoutPath = cleanedValueWithoutPort.split("/")[0];
|
||||||
|
if (validateIPV4(cleanedIpWithoutPath).valid) {
|
||||||
return { valid: true, message: _("Valid") };
|
return { valid: true, message: _("Valid") };
|
||||||
}
|
}
|
||||||
if (validateDomain(value).valid) {
|
if (validateDomain(cleanedValueWithoutPort).valid) {
|
||||||
return { valid: true, message: _("Valid") };
|
return { valid: true, message: _("Valid") };
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
|
|||||||
Reference in New Issue
Block a user