Skip to content

Commit

Permalink
fix: several DNS related validation
Browse files Browse the repository at this point in the history
  • Loading branch information
yichya committed Feb 18, 2024
1 parent ec534a4 commit 64469f3
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 18 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
16 changes: 12 additions & 4 deletions core/root/usr/share/xray/feature/dns.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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;
}),
Expand Down
1 change: 0 additions & 1 deletion core/root/www/luci-static/resources/view/xray/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
Expand Down
27 changes: 14 additions & 13 deletions core/root/www/luci-static/resources/view/xray/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 <code>127.0.0.1:53</code>."));
dns_udp_hijack.datatype = 'or(ip4addr, ip4addrport)';
dns_udp_hijack.datatype = 'ip4addrport';

s.tab("firewall", _("Extra Firewall Options"));

Expand All @@ -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.'));

Expand All @@ -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 <code>/var/etc/xray/config.json</code> for tags of generated inbounds and outbounds. See <a href="https://xtls.github.io/config/features/multiple.html">here</a> 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 <a href="https://xtls.github.io/config/features/multiple.html">here</a> 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;
Expand Down

0 comments on commit 64469f3

Please sign in to comment.