diff --git a/README.md b/README.md index ef6581fa..1456259d 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,7 @@ Fork this repository and: ## Changelog since 3.4.0 * 2024-02-18 chore: optimize code style; bump version +* 2024-02-19 fix: several DNS related validation ## Changelog since 3.3.0 diff --git a/core/root/usr/share/xray/feature/dns.mjs b/core/root/usr/share/xray/feature/dns.mjs index 7712faa9..9f6bb408 100644 --- a/core/root/usr/share/xray/feature/dns.mjs +++ b/core/root/usr/share/xray/feature/dns.mjs @@ -10,7 +10,7 @@ const fallback_default_dns = "1.1.1.1:53"; const geosite_existence = access("/usr/share/xray/geosite.dat") || false; function split_ipv4_host_port(val, port_default) { - const result = match(val, /([0-9\.]+):([0-9]+)/); + const result = match(val, /^([0-9\.]+):([0-9]+)$/); if (result == null) { return { address: val, @@ -143,11 +143,19 @@ export function dns_conf(proxy, config, manual_tproxy, fakedns) { } } + let resolve_merged = {}; + for (let k in keys(domain_extra_options)) { + const v = domain_extra_options[k]; + let original = resolve_merged[v] || []; + push(original, k); + resolve_merged[v] = original; + } + let servers = [ ...fake_dns_domains(fakedns), - ...map(keys(domain_extra_options), function (k) { - let i = split_ipv4_host_port(domain_extra_options[k]); - i["domains"] = [`domain:${k}`]; + ...map(keys(resolve_merged), function (k) { + let i = split_ipv4_host_port(k); + i["domains"] = uniq(resolve_merged[k]); i["skipFallback"] = true; return i; }), diff --git a/core/root/www/luci-static/resources/view/xray/core.js b/core/root/www/luci-static/resources/view/xray/core.js index 3516141c..9b0b408b 100644 --- a/core/root/www/luci-static/resources/view/xray/core.js +++ b/core/root/www/luci-static/resources/view/xray/core.js @@ -199,7 +199,6 @@ return view.extend({ o.modalonly = true; o = ss.taboption('general', form.Value, 'domain_resolve_dns', _('Resolve Domain via DNS'), _("Specify a DNS to resolve server hostname. Be careful of possible recursion.")); - o.datatype = 'hostport'; o.modalonly = true; o = ss.taboption('general', form.Value, 'server_port', _('Server Port')); diff --git a/core/root/www/luci-static/resources/view/xray/preview.js b/core/root/www/luci-static/resources/view/xray/preview.js index ed2710ac..3fbf64d8 100644 --- a/core/root/www/luci-static/resources/view/xray/preview.js +++ b/core/root/www/luci-static/resources/view/xray/preview.js @@ -14,10 +14,10 @@ return view.extend({ s.tab("dns_hijack", _("DNS Hijacking")); let dns_tcp_hijack = s.taboption('dns_hijack', form.Value, 'dns_tcp_hijack', _('Hijack TCP DNS Requests'), _("Redirect all outgoing TCP requests with destination port 53 to the address specified. In most cases not necessary.")); - dns_tcp_hijack.datatype = 'or(ip4addr, ip4addrport)'; + dns_tcp_hijack.datatype = 'ip4addrport'; let dns_udp_hijack = s.taboption('dns_hijack', form.Value, 'dns_udp_hijack', _('Hijack UDP DNS Requests'), _("Redirect all outgoing UDP requests with destination port 53 to the address specified. Recommended to use 127.0.0.1:53.")); - dns_udp_hijack.datatype = 'or(ip4addr, ip4addrport)'; + dns_udp_hijack.datatype = 'ip4addrport'; s.tab("firewall", _("Extra Firewall Options")); @@ -38,15 +38,7 @@ return view.extend({ let ttl_hop_limit_match = s.taboption('firewall', form.Value, 'ttl_hop_limit_match', _('TTL / Hop Limit Match'), _("Only override TTL / hop limit for packets with specific TTL / hop limit.")); ttl_hop_limit_match.datatype = 'uinteger'; - s.tab("sniffing", _("Legacy Inbounds and Sniffing")); - - let socks_port = s.taboption('sniffing', form.Value, 'socks_port', _('Socks5 proxy port'), _("Deprecated for security concerns. Use Extra Inbound instead.")); - socks_port.datatype = 'port'; - socks_port.placeholder = 1080; - - let http_port = s.taboption('sniffing', form.Value, 'http_port', _('HTTP proxy port'), _("Deprecated for security concerns. Use Extra Inbound instead.")); - http_port.datatype = 'port'; - http_port.placeholder = 1081; + s.tab("sniffing", _("Sniffing")); s.taboption('sniffing', form.Flag, 'tproxy_sniffing', _('Enable Sniffing'), _('Route requests according to domain settings in "DNS Settings" tab in core settings. Deprecated; use FakeDNS instead.')); @@ -67,8 +59,17 @@ return view.extend({ dynamic_direct_timeout.datatype = 'uinteger'; dynamic_direct_timeout.placeholder = 300; - s.tab('custom_options', _('Custom Options')); - let custom_config = s.taboption('custom_options', form.TextValue, 'custom_config', _('Custom Configurations'), _('Check /var/etc/xray/config.json for tags of generated inbounds and outbounds. See here for help')); + s.tab('deprecated', _('Deprecated Features')); + + let socks_port = s.taboption('deprecated', form.Value, 'socks_port', _('Socks5 proxy port'), _("Deprecated for security concerns and will be removed in next major version. Use Extra Inbound instead.")); + socks_port.datatype = 'port'; + socks_port.placeholder = 1080; + + let http_port = s.taboption('deprecated', form.Value, 'http_port', _('HTTP proxy port'), _("Deprecated for security concerns and will be removed in next major version. Use Extra Inbound instead.")); + http_port.datatype = 'port'; + http_port.placeholder = 1081; + + let custom_config = s.taboption('deprecated', form.TextValue, 'custom_config', _('Custom Configurations'), _('See here for help. Deprecated and will be removed in next major version.')); custom_config.monospace = true; custom_config.rows = 20; custom_config.validate = shared.validate_object;