update 2025-02-03 16:25:52
This commit is contained in:
parent
1ec425005c
commit
7313b32114
|
@ -106,43 +106,6 @@ function updateResVersion(El, version) {
|
|||
return El;
|
||||
}
|
||||
|
||||
function renderNATBehaviorTest(El) {
|
||||
let resEl = E('div', { 'class': 'control-group' }, [
|
||||
E('select', {
|
||||
'id': '_status_nattest_l4proto',
|
||||
'class': 'cbi-input-select',
|
||||
'style': 'width: 5em'
|
||||
}, [
|
||||
E('option', { 'value': 'udp' }, 'UDP'),
|
||||
E('option', { 'value': 'tcp' }, 'TCP')
|
||||
]),
|
||||
E('button', {
|
||||
'class': 'cbi-button cbi-button-apply',
|
||||
'click': ui.createHandlerFn(this, function() {
|
||||
const stun = this.formvalue(this.section.section);
|
||||
const l4proto = document.getElementById('_status_nattest_l4proto').value;
|
||||
const l4proto_idx = document.getElementById('_status_nattest_l4proto').selectedIndex;
|
||||
|
||||
return fs.exec_direct('/etc/fchomo/scripts/natcheck.sh', [stun, l4proto, getRandom(32768, 61000)]).then((stdout) => {
|
||||
this.description = '<details><summary>' + _('Expand/Collapse result') + '</summary>' + stdout + '</details>';
|
||||
|
||||
return this.map.reset().then((res) => {
|
||||
document.getElementById('_status_nattest_l4proto').selectedIndex = l4proto_idx;
|
||||
});
|
||||
});
|
||||
})
|
||||
}, [ _('Check') ])
|
||||
]);
|
||||
|
||||
let newEl = E('div', { style: 'font-weight: bold; align-items: center; display: flex' }, []);
|
||||
if (El) {
|
||||
newEl.appendChild(E([El, resEl]));
|
||||
} else
|
||||
newEl.appendChild(resEl);
|
||||
|
||||
return newEl;
|
||||
}
|
||||
|
||||
return view.extend({
|
||||
load() {
|
||||
return Promise.all([
|
||||
|
@ -247,7 +210,7 @@ return view.extend({
|
|||
}
|
||||
|
||||
so = ss.option(form.Value, '_nattest', _('Check routerself NAT Behavior'));
|
||||
so.default = hm.stunserver[0][0];
|
||||
so.default = `udp://${hm.stunserver[0][0]}`;
|
||||
hm.stunserver.forEach((res) => {
|
||||
so.value.apply(so, res);
|
||||
})
|
||||
|
@ -257,14 +220,60 @@ return view.extend({
|
|||
.format('https://github.com/muink/openwrt-stuntman');
|
||||
so.readonly = true;
|
||||
} else {
|
||||
so.renderWidget = function(/* ... */) {
|
||||
let El = form.Value.prototype.renderWidget.apply(this, arguments);
|
||||
so.renderWidget = function(section_id, option_index, cfgvalue) {
|
||||
const cval = new URL(cfgvalue || this.default);
|
||||
//console.info(cval.toString());
|
||||
let El = form.Value.prototype.renderWidget.call(this, section_id, option_index, cval.host);
|
||||
|
||||
return renderNATBehaviorTest.call(this, El);
|
||||
let resEl = E('div', { 'class': 'control-group' }, [
|
||||
E('select', {
|
||||
'id': '_status_nattest_l4proto',
|
||||
'class': 'cbi-input-select',
|
||||
'style': 'width: 5em'
|
||||
}, [
|
||||
...[
|
||||
['udp', 'UDP'], // default
|
||||
['tcp', 'TCP']
|
||||
].map(res => E('option', {
|
||||
value: res[0],
|
||||
selected: (cval.protocol === `${res[0]}:`) ? "" : null
|
||||
}, res[1]))
|
||||
]),
|
||||
E('button', {
|
||||
'class': 'cbi-button cbi-button-apply',
|
||||
'click': ui.createHandlerFn(this, function() {
|
||||
const stun = this.formvalue(this.section.section);
|
||||
const l4proto = document.getElementById('_status_nattest_l4proto').value;
|
||||
|
||||
return fs.exec_direct('/etc/fchomo/scripts/natcheck.sh', [stun, l4proto, getRandom(32768, 61000)]).then((stdout) => {
|
||||
this.description = '<details><summary>' + _('Expand/Collapse result') + '</summary>' + stdout + '</details>';
|
||||
|
||||
return this.map.reset().then((res) => {
|
||||
});
|
||||
});
|
||||
})
|
||||
}, [ _('Check') ])
|
||||
]);
|
||||
ui.addValidator(resEl.querySelector('#_status_nattest_l4proto'), 'string', false, (v) => {
|
||||
const section_id = this.section.section;
|
||||
const stun = this.formvalue(section_id);
|
||||
|
||||
this.onchange.call(this, {}, section_id, stun);
|
||||
return true;
|
||||
}, 'change');
|
||||
|
||||
let newEl = E('div', { style: 'font-weight: bold; align-items: center; display: flex' }, []);
|
||||
if (El) {
|
||||
newEl.appendChild(E([El, resEl]));
|
||||
} else
|
||||
newEl.appendChild(resEl);
|
||||
|
||||
return newEl;
|
||||
}
|
||||
}
|
||||
so.onchange = function(ev, section_id, value) {
|
||||
this.default = value;
|
||||
const l4proto = document.getElementById('_status_nattest_l4proto').value;
|
||||
this.default = `${l4proto}://${value}`;
|
||||
}
|
||||
so.write = function() {};
|
||||
so.remove = function() {};
|
||||
|
|
|
@ -617,7 +617,7 @@ mixin_authentications() {
|
|||
}
|
||||
|
||||
mixin_tun_dns_hijacks() {
|
||||
dns_hijack="$1" yq -M -i '.tun.dns_hijack += [strenv(dns_hijack)]' "$RUN_PROFILE_PATH"
|
||||
dns_hijack="$1" yq -M -i '.tun.dns-hijack += [strenv(dns_hijack)]' "$RUN_PROFILE_PATH"
|
||||
}
|
||||
|
||||
mixin_fake_ip_filters() {
|
||||
|
|
Loading…
Reference in New Issue