diff --git a/luci-app-homeproxy/htdocs/luci-static/resources/view/homeproxy/node.js b/luci-app-homeproxy/htdocs/luci-static/resources/view/homeproxy/node.js index d84e2c8c1..88ceb30a7 100644 --- a/luci-app-homeproxy/htdocs/luci-static/resources/view/homeproxy/node.js +++ b/luci-app-homeproxy/htdocs/luci-static/resources/view/homeproxy/node.js @@ -1331,6 +1331,9 @@ return view.extend({ o.depends({'filter_nodes': 'disabled', '!reverse': true}); o.rmempty = false; + o = s.taboption('subscription', form.Value, 'user_agent', _('User-Agent')); + o.placeholder = 'Wget/1.21 (HomeProxy, like v2rayN)'; + o = s.taboption('subscription', form.Flag, 'allow_insecure', _('Allow insecure'), _('Allow insecure connection by default when add nodes from subscriptions.') + '
' + diff --git a/luci-app-homeproxy/root/etc/homeproxy/scripts/generate_client.uc b/luci-app-homeproxy/root/etc/homeproxy/scripts/generate_client.uc index 9941d30d4..032443953 100755 --- a/luci-app-homeproxy/root/etc/homeproxy/scripts/generate_client.uc +++ b/luci-app-homeproxy/root/etc/homeproxy/scripts/generate_client.uc @@ -9,6 +9,7 @@ import { readfile, writefile } from 'fs'; import { isnan } from 'math'; +import { connect } from 'ubus'; import { cursor } from 'uci'; import { @@ -17,6 +18,8 @@ import { HP_DIR, RUN_DIR } from 'homeproxy'; +const ubus = connect(); + /* UCI config start */ const uci = cursor(); @@ -41,11 +44,9 @@ const uciruleset = 'ruleset'; const routing_mode = uci.get(uciconfig, ucimain, 'routing_mode') || 'bypass_mainland_china'; -let wan_dns = executeCommand('ifstatus wan | jsonfilter -e \'@["dns-server"][0]\''); -if (wan_dns.exitcode === 0 && trim(wan_dns.stdout)) - wan_dns = trim(wan_dns.stdout); -else - wan_dns = (routing_mode in ['proxy_mainland_china', 'global']) ? '208.67.222.222' : '114.114.114.114'; +let wan_dns = ubus.call('network.interface', 'status', {'interface': 'wan'})?.['dns-server']?.[0]; +if (!wan_dns) + wan_dns = (routing_mode in ['proxy_mainland_china', 'global']) ? '8.8.8.8' : '223.5.5.5'; const dns_port = uci.get(uciconfig, uciinfra, 'dns_port') || '5333'; diff --git a/luci-app-homeproxy/root/etc/homeproxy/scripts/homeproxy.uc b/luci-app-homeproxy/root/etc/homeproxy/scripts/homeproxy.uc index b846c4346..5623ab0dd 100644 --- a/luci-app-homeproxy/root/etc/homeproxy/scripts/homeproxy.uc +++ b/luci-app-homeproxy/root/etc/homeproxy/scripts/homeproxy.uc @@ -74,11 +74,14 @@ export function getTime(epoch) { }; -export function wGET(url) { +export function wGET(url, ua) { if (!url || type(url) !== 'string') return null; - const output = executeCommand(`/usr/bin/wget -qO- --user-agent 'Wget/1.21 (HomeProxy, like v2rayN)' --timeout=10 ${shellQuote(url)}`) || {}; + if (!ua) + ua = 'Wget/1.21 (HomeProxy, like v2rayN)'; + + const output = executeCommand(`/usr/bin/wget -qO- --user-agent ${shellQuote(ua)} --timeout=10 ${shellQuote(url)}`) || {}; return trim(output.stdout); }; /* Utilities end */ diff --git a/luci-app-homeproxy/root/etc/homeproxy/scripts/update_subscriptions.uc b/luci-app-homeproxy/root/etc/homeproxy/scripts/update_subscriptions.uc index d10639f00..0dfbf1fac 100755 --- a/luci-app-homeproxy/root/etc/homeproxy/scripts/update_subscriptions.uc +++ b/luci-app-homeproxy/root/etc/homeproxy/scripts/update_subscriptions.uc @@ -35,6 +35,7 @@ const allow_insecure = uci.get(uciconfig, ucisubscription, 'allow_insecure') || filter_keywords = uci.get(uciconfig, ucisubscription, 'filter_keywords') || [], packet_encoding = uci.get(uciconfig, ucisubscription, 'packet_encoding') || 'xudp', subscription_urls = uci.get(uciconfig, ucisubscription, 'subscription_url') || [], + user_agent = uci.get(uciconfig, ucisubscription, 'user_agent'), via_proxy = uci.get(uciconfig, ucisubscription, 'update_via_proxy') || '0'; const routing_mode = uci.get(uciconfig, ucimain, 'routing_mode') || 'bypass_mainalnd_china'; @@ -385,7 +386,7 @@ function parse_uri(uri) { /* * https://www.v2fly.org/config/protocols/vmess.html#vmess-md5-%E8%AE%A4%E8%AF%81%E4%BF%A1%E6%81%AF-%E6%B7%98%E6%B1%B0%E6%9C%BA%E5%88%B6 * else if (uri.aid && int(uri.aid) !== 0) { - * log(sprintf('Skipping unsupported %s node: %s.', 'VMess', uri.ps || uri.add)); + * log(sprintf('Skipping unsupported %s node: %s.', uri[0], uri.ps || uri.add)); * return null; * } */ @@ -457,7 +458,7 @@ function main() { const groupHash = calcStringMD5(url); node_cache[groupHash] = {}; - const res = wGET(url); + const res = wGET(url, user_agent); if (isEmpty(res)) { log(sprintf('Failed to fetch resources from %s.', url)); continue;