parent
afd6be561e
commit
662cdd2f88
@ -1331,6 +1331,9 @@ return view.extend({
|
|||||||
o.depends({'filter_nodes': 'disabled', '!reverse': true});
|
o.depends({'filter_nodes': 'disabled', '!reverse': true});
|
||||||
o.rmempty = false;
|
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'),
|
o = s.taboption('subscription', form.Flag, 'allow_insecure', _('Allow insecure'),
|
||||||
_('Allow insecure connection by default when add nodes from subscriptions.') +
|
_('Allow insecure connection by default when add nodes from subscriptions.') +
|
||||||
'<br/>' +
|
'<br/>' +
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
import { readfile, writefile } from 'fs';
|
import { readfile, writefile } from 'fs';
|
||||||
import { isnan } from 'math';
|
import { isnan } from 'math';
|
||||||
|
import { connect } from 'ubus';
|
||||||
import { cursor } from 'uci';
|
import { cursor } from 'uci';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
@ -17,6 +18,8 @@ import {
|
|||||||
HP_DIR, RUN_DIR
|
HP_DIR, RUN_DIR
|
||||||
} from 'homeproxy';
|
} from 'homeproxy';
|
||||||
|
|
||||||
|
const ubus = connect();
|
||||||
|
|
||||||
/* UCI config start */
|
/* UCI config start */
|
||||||
const uci = cursor();
|
const uci = cursor();
|
||||||
|
|
||||||
@ -41,11 +44,9 @@ const uciruleset = 'ruleset';
|
|||||||
|
|
||||||
const routing_mode = uci.get(uciconfig, ucimain, 'routing_mode') || 'bypass_mainland_china';
|
const routing_mode = uci.get(uciconfig, ucimain, 'routing_mode') || 'bypass_mainland_china';
|
||||||
|
|
||||||
let wan_dns = executeCommand('ifstatus wan | jsonfilter -e \'@["dns-server"][0]\'');
|
let wan_dns = ubus.call('network.interface', 'status', {'interface': 'wan'})?.['dns-server']?.[0];
|
||||||
if (wan_dns.exitcode === 0 && trim(wan_dns.stdout))
|
if (!wan_dns)
|
||||||
wan_dns = trim(wan_dns.stdout);
|
wan_dns = (routing_mode in ['proxy_mainland_china', 'global']) ? '8.8.8.8' : '223.5.5.5';
|
||||||
else
|
|
||||||
wan_dns = (routing_mode in ['proxy_mainland_china', 'global']) ? '208.67.222.222' : '114.114.114.114';
|
|
||||||
|
|
||||||
const dns_port = uci.get(uciconfig, uciinfra, 'dns_port') || '5333';
|
const dns_port = uci.get(uciconfig, uciinfra, 'dns_port') || '5333';
|
||||||
|
|
||||||
|
@ -74,11 +74,14 @@ export function getTime(epoch) {
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export function wGET(url) {
|
export function wGET(url, ua) {
|
||||||
if (!url || type(url) !== 'string')
|
if (!url || type(url) !== 'string')
|
||||||
return null;
|
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);
|
return trim(output.stdout);
|
||||||
};
|
};
|
||||||
/* Utilities end */
|
/* Utilities end */
|
||||||
|
@ -35,6 +35,7 @@ const allow_insecure = uci.get(uciconfig, ucisubscription, 'allow_insecure') ||
|
|||||||
filter_keywords = uci.get(uciconfig, ucisubscription, 'filter_keywords') || [],
|
filter_keywords = uci.get(uciconfig, ucisubscription, 'filter_keywords') || [],
|
||||||
packet_encoding = uci.get(uciconfig, ucisubscription, 'packet_encoding') || 'xudp',
|
packet_encoding = uci.get(uciconfig, ucisubscription, 'packet_encoding') || 'xudp',
|
||||||
subscription_urls = uci.get(uciconfig, ucisubscription, 'subscription_url') || [],
|
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';
|
via_proxy = uci.get(uciconfig, ucisubscription, 'update_via_proxy') || '0';
|
||||||
|
|
||||||
const routing_mode = uci.get(uciconfig, ucimain, 'routing_mode') || 'bypass_mainalnd_china';
|
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
|
* 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) {
|
* 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;
|
* return null;
|
||||||
* }
|
* }
|
||||||
*/
|
*/
|
||||||
@ -457,7 +458,7 @@ function main() {
|
|||||||
const groupHash = calcStringMD5(url);
|
const groupHash = calcStringMD5(url);
|
||||||
node_cache[groupHash] = {};
|
node_cache[groupHash] = {};
|
||||||
|
|
||||||
const res = wGET(url);
|
const res = wGET(url, user_agent);
|
||||||
if (isEmpty(res)) {
|
if (isEmpty(res)) {
|
||||||
log(sprintf('Failed to fetch resources from %s.', url));
|
log(sprintf('Failed to fetch resources from %s.', url));
|
||||||
continue;
|
continue;
|
||||||
|
Loading…
Reference in New Issue
Block a user