mirror of
https://github.com/kiddin9/op-packages.git
synced 2026-11-05 01:44:16 +08:00
⛅ Sync 2026-05-03 20:20:03
This commit is contained in:
1 parent
c47789a4ed
commit
5ab974c5cd
72 files changed
+5840
-4686
No files matched your search
@@ -7,7 +7,7 @@
|
||||
'require ui';
|
||||
'require view';
|
||||
|
||||
var callServiceList = rpc.declare({
|
||||
const callServiceList = rpc.declare({
|
||||
object: 'service',
|
||||
method: 'list',
|
||||
params: ['name'],
|
||||
@@ -15,8 +15,8 @@ var callServiceList = rpc.declare({
|
||||
});
|
||||
|
||||
function getServiceStatus() {
|
||||
return L.resolveDefault(callServiceList('mosdns'), {}).then(function (res) {
|
||||
var isRunning = false;
|
||||
return L.resolveDefault(callServiceList('mosdns'), {}).then(res => {
|
||||
let isRunning = false;
|
||||
try {
|
||||
isRunning = res['mosdns']['instances']['mosdns']['running'];
|
||||
} catch (e) { }
|
||||
@@ -25,8 +25,8 @@ function getServiceStatus() {
|
||||
}
|
||||
|
||||
function renderStatus(isRunning) {
|
||||
var spanTemp = '<em><span style="color:%s"><strong>%s %s</strong></span></em>';
|
||||
var renderHTML;
|
||||
const spanTemp = '<em><span style="color:%s"><strong>%s %s</strong></span></em>';
|
||||
let renderHTML;
|
||||
if (isRunning) {
|
||||
renderHTML = spanTemp.format('green', _('MosDNS'), _('RUNNING'));
|
||||
} else {
|
||||
@@ -70,27 +70,27 @@ async function loadCodeMirrorResources() {
|
||||
await loadScripts();
|
||||
}
|
||||
|
||||
var callMosdns = rpc.declare({
|
||||
const callMosdns = rpc.declare({
|
||||
object: 'luci.mosdns',
|
||||
method: 'get_version',
|
||||
expect: { '': {} }
|
||||
});
|
||||
|
||||
var callFlushCache = rpc.declare({
|
||||
const callFlushCache = rpc.declare({
|
||||
object: 'luci.mosdns',
|
||||
method: 'flush_cache',
|
||||
expect: { '': {} }
|
||||
});
|
||||
|
||||
return view.extend({
|
||||
load: function () {
|
||||
load() {
|
||||
return Promise.all([
|
||||
L.resolveDefault(callMosdns(), null),
|
||||
]);
|
||||
},
|
||||
|
||||
handleFlushCache: function () {
|
||||
return callFlushCache().then(function(res) {
|
||||
handleFlushCache() {
|
||||
return callFlushCache().then(res => {
|
||||
if (res.success) {
|
||||
ui.addNotification(null, E('p', _('Flushing DNS Cache Success.')), 'info');
|
||||
} else {
|
||||
@@ -99,24 +99,20 @@ return view.extend({
|
||||
});
|
||||
},
|
||||
|
||||
render: function (data) {
|
||||
var m, s, o, v;
|
||||
v = '';
|
||||
render(data) {
|
||||
let m, s, o;
|
||||
|
||||
var version = (data[0] && data[0].version) ? data[0].version : null;
|
||||
if (version) {
|
||||
v = version;
|
||||
}
|
||||
m = new form.Map('mosdns', _('MosDNS') + ' ' + v,
|
||||
const version = (data[0] && data[0].version) ? data[0].version : '';
|
||||
m = new form.Map('mosdns', _('MosDNS') + ' ' + version,
|
||||
_('MosDNS is a plugin-based DNS forwarder/traffic splitter.'));
|
||||
|
||||
s = m.section(form.TypedSection);
|
||||
s.anonymous = true;
|
||||
s.render = function () {
|
||||
setTimeout(function () {
|
||||
poll.add(function () {
|
||||
return L.resolveDefault(getServiceStatus()).then(function (res) {
|
||||
var view = document.getElementById('service_status');
|
||||
s.render = () => {
|
||||
setTimeout(() => {
|
||||
poll.add(() => {
|
||||
return L.resolveDefault(getServiceStatus()).then(res => {
|
||||
const view = document.getElementById('service_status');
|
||||
if (view) {
|
||||
view.innerHTML = renderStatus(res);
|
||||
} else {
|
||||
@@ -132,14 +128,14 @@ return view.extend({
|
||||
return E('div', { class: 'cbi-section', id: 'status_bar' }, [
|
||||
E('p', { id: 'service_status' }, _('Collecting data...'))
|
||||
]);
|
||||
}
|
||||
};
|
||||
|
||||
s = m.section(form.NamedSection, 'config', 'mosdns');
|
||||
|
||||
s.tab('basic', _('Basic Options'));
|
||||
s.tab("advanced", _("Advanced Options"));
|
||||
s.tab("cloudflare", _("Cloudflare Options"));
|
||||
s.tab("api", _("API Options"));
|
||||
s.tab('advanced', _('Advanced Options'));
|
||||
s.tab('cloudflare', _('Cloudflare Options'));
|
||||
s.tab('api', _('API Options'));
|
||||
s.tab('geodata', _('GeoData Export'));
|
||||
|
||||
/* basic */
|
||||
@@ -271,13 +267,13 @@ return view.extend({
|
||||
o.depends('configfile', '/var/etc/mosdns.json');
|
||||
|
||||
o = s.taboption('advanced', form.Value, 'idle_timeout', _('Idle Timeout'),
|
||||
_('DoH/TCP/DoT Connection Multiplexing idle timeout (default 30 seconds)'))
|
||||
_('DoH/TCP/DoT Connection Multiplexing idle timeout (default 30 seconds)'));
|
||||
o.datatype = 'and(uinteger,min(1))';
|
||||
o.default = '30';
|
||||
o.depends('configfile', '/var/etc/mosdns.json');
|
||||
|
||||
o = s.taboption('advanced', form.Flag, 'enable_pipeline', _('TCP/DoT Connection Multiplexing'),
|
||||
_('Enable TCP/DoT RFC 7766 new Query Pipelining connection multiplexing mode'))
|
||||
_('Enable TCP/DoT RFC 7766 new Query Pipelining connection multiplexing mode'));
|
||||
o.rmempty = false;
|
||||
o.default = false;
|
||||
o.depends('configfile', '/var/etc/mosdns.json');
|
||||
@@ -362,9 +358,9 @@ return view.extend({
|
||||
o.depends('adblock', '1');
|
||||
o.default = 'geosite.dat';
|
||||
o.value('geosite.dat', 'v2ray-geosite');
|
||||
o.value('https://raw.githubusercontent.com/privacy-protection-tools/anti-AD/master/anti-ad-domains.txt', 'anti-AD')
|
||||
o.value('https://raw.githubusercontent.com/Cats-Team/AdRules/main/mosdns_adrules.txt', 'Cats-Team/AdRules')
|
||||
o.value('https://raw.githubusercontent.com/neodevpro/neodevhost/master/domain', 'NEO DEV HOST')
|
||||
o.value('https://raw.githubusercontent.com/privacy-protection-tools/anti-AD/master/anti-ad-domains.txt', 'anti-AD');
|
||||
o.value('https://raw.githubusercontent.com/Cats-Team/AdRules/main/mosdns_adrules.txt', 'Cats-Team/AdRules');
|
||||
o.value('https://raw.githubusercontent.com/neodevpro/neodevhost/master/domain', 'NEO DEV HOST');
|
||||
|
||||
/* cloudflare */
|
||||
o = s.taboption('cloudflare', form.Flag, 'cloudflare', _('Enabled'),
|
||||
@@ -383,12 +379,10 @@ return view.extend({
|
||||
_('IPv4 CIDR: <a href="https://www.cloudflare.com/ips-v4" target="_blank">https://www.cloudflare.com/ips-v4</a> <br /> IPv6 CIDR: <a href="https://www.cloudflare.com/ips-v6" target="_blank">https://www.cloudflare.com/ips-v6</a>'));
|
||||
o.rows = 15;
|
||||
o.depends('configfile', '/var/etc/mosdns.json');
|
||||
o.cfgvalue = function (section_id) {
|
||||
return fs.trimmed('/etc/mosdns/rule/cloudflare-cidr.txt');
|
||||
};
|
||||
o.write = function (section_id, formvalue) {
|
||||
return this.cfgvalue(section_id).then(function (value) {
|
||||
if (value == formvalue) {
|
||||
o.cfgvalue = section_id => fs.trimmed('/etc/mosdns/rule/cloudflare-cidr.txt');
|
||||
o.write = function(section_id, formvalue) {
|
||||
return this.cfgvalue(section_id).then(value => {
|
||||
if (value === formvalue) {
|
||||
return;
|
||||
}
|
||||
return fs.write('/etc/mosdns/rule/cloudflare-cidr.txt', formvalue.trim().replace(/\r\n/g, '\n') + '\n');
|
||||
@@ -410,9 +404,9 @@ return view.extend({
|
||||
o.depends('cache', '1');
|
||||
|
||||
/* configuration */
|
||||
var configeditor = null;
|
||||
setTimeout(function () {
|
||||
var textarea = document.getElementById('widget.cbid.mosdns.config._custom');
|
||||
let configeditor = null;
|
||||
setTimeout(() => {
|
||||
const textarea = document.getElementById('widget.cbid.mosdns.config._custom');
|
||||
if (textarea) {
|
||||
configeditor = CodeMirror.fromTextArea(textarea, {
|
||||
autoRefresh: true,
|
||||
@@ -421,9 +415,9 @@ return view.extend({
|
||||
lint: true,
|
||||
gutters: ['CodeMirror-lint-markers'],
|
||||
matchBrackets: true,
|
||||
mode: "text/yaml",
|
||||
mode: 'text/yaml',
|
||||
styleActiveLine: true,
|
||||
theme: "dracula"
|
||||
theme: 'dracula'
|
||||
});
|
||||
}
|
||||
}, 600);
|
||||
@@ -432,23 +426,17 @@ return view.extend({
|
||||
Only accepts configuration content in yaml format.'));
|
||||
o.rows = 25;
|
||||
o.depends('configfile', '/etc/mosdns/config_custom.yaml');
|
||||
o.cfgvalue = function (section_id) {
|
||||
return fs.trimmed('/etc/mosdns/config_custom.yaml');
|
||||
};
|
||||
o.write = function (section_id, formvalue) {
|
||||
o.cfgvalue = section_id => fs.trimmed('/etc/mosdns/config_custom.yaml');
|
||||
o.write = function(section_id, formvalue) {
|
||||
if (configeditor) {
|
||||
var editorContent = configeditor.getValue();
|
||||
const editorContent = configeditor.getValue();
|
||||
if (editorContent === formvalue) {
|
||||
return;
|
||||
}
|
||||
return fs.write('/etc/mosdns/config_custom.yaml', editorContent.trim().replace(/\r\n/g, '\n') + '\n')
|
||||
.then(function (i) {
|
||||
return fs.exec('/etc/init.d/mosdns', ['restart']);
|
||||
})
|
||||
.then(function () {
|
||||
return window.location.reload();
|
||||
})
|
||||
.catch(function (e) {
|
||||
.then(i => fs.exec('/etc/init.d/mosdns', ['restart']))
|
||||
.then(() => window.location.reload())
|
||||
.catch(e => {
|
||||
ui.addNotification(null, E('p', _('Unable to save contents: %s').format(e.message)));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -6,24 +6,24 @@
|
||||
'require rpc';
|
||||
'require ui';
|
||||
|
||||
var callPrintLog = rpc.declare({
|
||||
const callPrintLog = rpc.declare({
|
||||
object: 'luci.mosdns',
|
||||
method: 'print_log',
|
||||
expect: { '': {} }
|
||||
});
|
||||
|
||||
var callCleanLog = rpc.declare({
|
||||
const callCleanLog = rpc.declare({
|
||||
object: 'luci.mosdns',
|
||||
method: 'clean_log',
|
||||
expect: { '': {} }
|
||||
});
|
||||
|
||||
var scrollPosition = 0;
|
||||
var userScrolled = false;
|
||||
var logTextarea;
|
||||
let scrollPosition = 0;
|
||||
let userScrolled = false;
|
||||
let logTextarea;
|
||||
|
||||
function pollLog() {
|
||||
return callPrintLog().then(function (res) {
|
||||
return callPrintLog().then(res => {
|
||||
logTextarea.value = res.log || _('No log data.');
|
||||
|
||||
if (!userScrolled) {
|
||||
@@ -32,20 +32,20 @@ function pollLog() {
|
||||
logTextarea.scrollTop = scrollPosition;
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
return view.extend({
|
||||
handleCleanLogs: function () {
|
||||
return callCleanLog().then(function(res) {
|
||||
handleCleanLogs() {
|
||||
return callCleanLog().then(res => {
|
||||
if (res.success) {
|
||||
logTextarea.value = ''; // Clear textarea on success
|
||||
} else {
|
||||
ui.addNotification(null, E('p', _('Failed to clean logs.') + (res.error ? ': ' + res.error : '')), 'error');
|
||||
}
|
||||
}).catch(function (e) { ui.addNotification(null, E('p', e.message)) });
|
||||
}).catch(e => ui.addNotification(null, E('p', e.message)));
|
||||
},
|
||||
|
||||
render: function () {
|
||||
render() {
|
||||
logTextarea = E('textarea', {
|
||||
'class': 'cbi-input-textarea',
|
||||
'wrap': 'off',
|
||||
@@ -53,16 +53,16 @@ return view.extend({
|
||||
'style': 'width: calc(100% - 20px);height: 535px;margin: 10px;overflow-y: scroll;',
|
||||
});
|
||||
|
||||
logTextarea.addEventListener('scroll', function () {
|
||||
logTextarea.addEventListener('scroll', () => {
|
||||
userScrolled = true;
|
||||
scrollPosition = logTextarea.scrollTop;
|
||||
});
|
||||
|
||||
var log_textarea_wrapper = E('div', { 'id': 'log_textarea' }, logTextarea);
|
||||
const log_textarea_wrapper = E('div', { 'id': 'log_textarea' }, logTextarea);
|
||||
|
||||
poll.add(pollLog);
|
||||
|
||||
var clear_logs_button = E('input', { 'class': 'btn cbi-button-action', 'type': 'button', 'style': 'margin-left: 10px; margin-top: 10px;', 'value': _('Clear logs') });
|
||||
const clear_logs_button = E('input', { 'class': 'btn cbi-button-action', 'type': 'button', 'style': 'margin-left: 10px; margin-top: 10px;', 'value': _('Clear logs') });
|
||||
clear_logs_button.addEventListener('click', this.handleCleanLogs.bind(this));
|
||||
|
||||
return E([
|
||||
|
||||
@@ -5,10 +5,10 @@
|
||||
'require view';
|
||||
|
||||
return view.extend({
|
||||
render: function () {
|
||||
var m, s, o;
|
||||
render() {
|
||||
let m, s, o;
|
||||
|
||||
m = new form.Map("mosdns", _("Rule Settings"),
|
||||
m = new form.Map('mosdns', _('Rule Settings'),
|
||||
_('The list of rules only apply to \'Default Config\' profiles.'));
|
||||
|
||||
s = m.section(form.TypedSection);
|
||||
@@ -32,27 +32,21 @@ return view.extend({
|
||||
+ '</font>'
|
||||
);
|
||||
o.rows = 25;
|
||||
o.cfgvalue = function (section_id) {
|
||||
return fs.trimmed('/etc/mosdns/rule/whitelist.txt').catch(function (e) {
|
||||
return "";
|
||||
});
|
||||
};
|
||||
o.write = function (section_id, formvalue) {
|
||||
return this.cfgvalue(section_id).then(function (value) {
|
||||
if (value == formvalue) {
|
||||
o.cfgvalue = section_id => fs.trimmed('/etc/mosdns/rule/whitelist.txt').catch(e => '');
|
||||
o.write = function(section_id, formvalue) {
|
||||
return this.cfgvalue(section_id).then(value => {
|
||||
if (value === formvalue) {
|
||||
return;
|
||||
}
|
||||
return fs.write('/etc/mosdns/rule/whitelist.txt', (formvalue.trim() ? formvalue.trim().replace(/\r\n/g, '\n') + '\n' : ''))
|
||||
.catch(function (e) {
|
||||
.catch(e => {
|
||||
ui.addNotification(null, E('p', _('Unable to save contents: %s').format(e.message)));
|
||||
});
|
||||
});
|
||||
};
|
||||
o.remove = function (section_id) {
|
||||
return fs.write('/etc/mosdns/rule/whitelist.txt', '').catch(function (e) {
|
||||
ui.addNotification(null, E('p', _('Unable to save contents: %s').format(e.message)));
|
||||
});
|
||||
};
|
||||
o.remove = section_id => fs.write('/etc/mosdns/rule/whitelist.txt', '').catch(e => {
|
||||
ui.addNotification(null, E('p', _('Unable to save contents: %s').format(e.message)));
|
||||
});
|
||||
|
||||
// --- Block Lists ---
|
||||
o = s.taboption('blocklist', form.TextValue, '_blocklist',
|
||||
@@ -62,27 +56,21 @@ return view.extend({
|
||||
+ '</font>'
|
||||
);
|
||||
o.rows = 25;
|
||||
o.cfgvalue = function (section_id) {
|
||||
return fs.trimmed('/etc/mosdns/rule/blocklist.txt').catch(function (e) {
|
||||
return "";
|
||||
});
|
||||
};
|
||||
o.write = function (section_id, formvalue) {
|
||||
return this.cfgvalue(section_id).then(function (value) {
|
||||
if (value == formvalue) {
|
||||
o.cfgvalue = section_id => fs.trimmed('/etc/mosdns/rule/blocklist.txt').catch(e => '');
|
||||
o.write = function(section_id, formvalue) {
|
||||
return this.cfgvalue(section_id).then(value => {
|
||||
if (value === formvalue) {
|
||||
return;
|
||||
}
|
||||
return fs.write('/etc/mosdns/rule/blocklist.txt', (formvalue.trim() ? formvalue.trim().replace(/\r\n/g, '\n') + '\n' : ''))
|
||||
.catch(function (e) {
|
||||
.catch(e => {
|
||||
ui.addNotification(null, E('p', _('Unable to save contents: %s').format(e.message)));
|
||||
});
|
||||
});
|
||||
};
|
||||
o.remove = function (section_id) {
|
||||
return fs.write('/etc/mosdns/rule/blocklist.txt', '').catch(function (e) {
|
||||
ui.addNotification(null, E('p', _('Unable to save contents: %s').format(e.message)));
|
||||
});
|
||||
};
|
||||
o.remove = section_id => fs.write('/etc/mosdns/rule/blocklist.txt', '').catch(e => {
|
||||
ui.addNotification(null, E('p', _('Unable to save contents: %s').format(e.message)));
|
||||
});
|
||||
|
||||
// --- Grey Lists ---
|
||||
o = s.taboption('greylist', form.TextValue, '_greylist',
|
||||
@@ -92,27 +80,21 @@ return view.extend({
|
||||
+ '</font>'
|
||||
);
|
||||
o.rows = 25;
|
||||
o.cfgvalue = function (section_id) {
|
||||
return fs.trimmed('/etc/mosdns/rule/greylist.txt').catch(function (e) {
|
||||
return "";
|
||||
});
|
||||
};
|
||||
o.write = function (section_id, formvalue) {
|
||||
return this.cfgvalue(section_id).then(function (value) {
|
||||
if (value == formvalue) {
|
||||
o.cfgvalue = section_id => fs.trimmed('/etc/mosdns/rule/greylist.txt').catch(e => '');
|
||||
o.write = function(section_id, formvalue) {
|
||||
return this.cfgvalue(section_id).then(value => {
|
||||
if (value === formvalue) {
|
||||
return;
|
||||
}
|
||||
return fs.write('/etc/mosdns/rule/greylist.txt', (formvalue.trim() ? formvalue.trim().replace(/\r\n/g, '\n') + '\n' : ''))
|
||||
.catch(function (e) {
|
||||
.catch(e => {
|
||||
ui.addNotification(null, E('p', _('Unable to save contents: %s').format(e.message)));
|
||||
});
|
||||
});
|
||||
};
|
||||
o.remove = function (section_id) {
|
||||
return fs.write('/etc/mosdns/rule/greylist.txt', '').catch(function (e) {
|
||||
ui.addNotification(null, E('p', _('Unable to save contents: %s').format(e.message)));
|
||||
});
|
||||
};
|
||||
o.remove = section_id => fs.write('/etc/mosdns/rule/greylist.txt', '').catch(e => {
|
||||
ui.addNotification(null, E('p', _('Unable to save contents: %s').format(e.message)));
|
||||
});
|
||||
|
||||
// --- DDNS Lists ---
|
||||
o = s.taboption('ddnslist', form.TextValue, '_ddnslist',
|
||||
@@ -122,27 +104,21 @@ return view.extend({
|
||||
+ '</font>'
|
||||
);
|
||||
o.rows = 25;
|
||||
o.cfgvalue = function (section_id) {
|
||||
return fs.trimmed('/etc/mosdns/rule/ddnslist.txt').catch(function (e) {
|
||||
return "";
|
||||
});
|
||||
};
|
||||
o.write = function (section_id, formvalue) {
|
||||
return this.cfgvalue(section_id).then(function (value) {
|
||||
if (value == formvalue) {
|
||||
o.cfgvalue = section_id => fs.trimmed('/etc/mosdns/rule/ddnslist.txt').catch(e => '');
|
||||
o.write = function(section_id, formvalue) {
|
||||
return this.cfgvalue(section_id).then(value => {
|
||||
if (value === formvalue) {
|
||||
return;
|
||||
}
|
||||
return fs.write('/etc/mosdns/rule/ddnslist.txt', (formvalue.trim() ? formvalue.trim().replace(/\r\n/g, '\n') + '\n' : ''))
|
||||
.catch(function (e) {
|
||||
.catch(e => {
|
||||
ui.addNotification(null, E('p', _('Unable to save contents: %s').format(e.message)));
|
||||
});
|
||||
});
|
||||
};
|
||||
o.remove = function (section_id) {
|
||||
return fs.write('/etc/mosdns/rule/ddnslist.txt', '').catch(function (e) {
|
||||
ui.addNotification(null, E('p', _('Unable to save contents: %s').format(e.message)));
|
||||
});
|
||||
};
|
||||
o.remove = section_id => fs.write('/etc/mosdns/rule/ddnslist.txt', '').catch(e => {
|
||||
ui.addNotification(null, E('p', _('Unable to save contents: %s').format(e.message)));
|
||||
});
|
||||
|
||||
// --- Hosts ---
|
||||
o = s.taboption('hostslist', form.TextValue, '_hostslist',
|
||||
@@ -152,27 +128,21 @@ return view.extend({
|
||||
+ '</font>'
|
||||
);
|
||||
o.rows = 25;
|
||||
o.cfgvalue = function (section_id) {
|
||||
return fs.trimmed('/etc/mosdns/rule/hosts.txt').catch(function (e) {
|
||||
return "";
|
||||
});
|
||||
};
|
||||
o.write = function (section_id, formvalue) {
|
||||
return this.cfgvalue(section_id).then(function (value) {
|
||||
if (value == formvalue) {
|
||||
o.cfgvalue = section_id => fs.trimmed('/etc/mosdns/rule/hosts.txt').catch(e => '');
|
||||
o.write = function(section_id, formvalue) {
|
||||
return this.cfgvalue(section_id).then(value => {
|
||||
if (value === formvalue) {
|
||||
return;
|
||||
}
|
||||
return fs.write('/etc/mosdns/rule/hosts.txt', (formvalue.trim() ? formvalue.trim().replace(/\r\n/g, '\n') + '\n' : ''))
|
||||
.catch(function (e) {
|
||||
.catch(e => {
|
||||
ui.addNotification(null, E('p', _('Unable to save contents: %s').format(e.message)));
|
||||
});
|
||||
});
|
||||
};
|
||||
o.remove = function (section_id) {
|
||||
return fs.write('/etc/mosdns/rule/hosts.txt', '').catch(function (e) {
|
||||
ui.addNotification(null, E('p', _('Unable to save contents: %s').format(e.message)));
|
||||
});
|
||||
};
|
||||
o.remove = section_id => fs.write('/etc/mosdns/rule/hosts.txt', '').catch(e => {
|
||||
ui.addNotification(null, E('p', _('Unable to save contents: %s').format(e.message)));
|
||||
});
|
||||
|
||||
// --- Redirect ---
|
||||
o = s.taboption('redirectlist', form.TextValue, '_redirectlist',
|
||||
@@ -182,27 +152,21 @@ return view.extend({
|
||||
+ '</font>'
|
||||
);
|
||||
o.rows = 25;
|
||||
o.cfgvalue = function (section_id) {
|
||||
return fs.trimmed('/etc/mosdns/rule/redirect.txt').catch(function (e) {
|
||||
return "";
|
||||
});
|
||||
};
|
||||
o.write = function (section_id, formvalue) {
|
||||
return this.cfgvalue(section_id).then(function (value) {
|
||||
if (value == formvalue) {
|
||||
o.cfgvalue = section_id => fs.trimmed('/etc/mosdns/rule/redirect.txt').catch(e => '');
|
||||
o.write = function(section_id, formvalue) {
|
||||
return this.cfgvalue(section_id).then(value => {
|
||||
if (value === formvalue) {
|
||||
return;
|
||||
}
|
||||
return fs.write('/etc/mosdns/rule/redirect.txt', (formvalue.trim() ? formvalue.trim().replace(/\r\n/g, '\n') + '\n' : ''))
|
||||
.catch(function (e) {
|
||||
.catch(e => {
|
||||
ui.addNotification(null, E('p', _('Unable to save contents: %s').format(e.message)));
|
||||
});
|
||||
});
|
||||
};
|
||||
o.remove = function (section_id) {
|
||||
return fs.write('/etc/mosdns/rule/redirect.txt', '').catch(function (e) {
|
||||
ui.addNotification(null, E('p', _('Unable to save contents: %s').format(e.message)));
|
||||
});
|
||||
};
|
||||
o.remove = section_id => fs.write('/etc/mosdns/rule/redirect.txt', '').catch(e => {
|
||||
ui.addNotification(null, E('p', _('Unable to save contents: %s').format(e.message)));
|
||||
});
|
||||
|
||||
// --- Block PTR ---
|
||||
o = s.taboption('localptrlist', form.TextValue, '_localptrlist',
|
||||
@@ -212,27 +176,21 @@ return view.extend({
|
||||
+ '</font>'
|
||||
);
|
||||
o.rows = 25;
|
||||
o.cfgvalue = function (section_id) {
|
||||
return fs.trimmed('/etc/mosdns/rule/local-ptr.txt').catch(function (e) {
|
||||
return "";
|
||||
});
|
||||
};
|
||||
o.write = function (section_id, formvalue) {
|
||||
return this.cfgvalue(section_id).then(function (value) {
|
||||
if (value == formvalue) {
|
||||
o.cfgvalue = section_id => fs.trimmed('/etc/mosdns/rule/local-ptr.txt').catch(e => '');
|
||||
o.write = function(section_id, formvalue) {
|
||||
return this.cfgvalue(section_id).then(value => {
|
||||
if (value === formvalue) {
|
||||
return;
|
||||
}
|
||||
return fs.write('/etc/mosdns/rule/local-ptr.txt', (formvalue.trim() ? formvalue.trim().replace(/\r\n/g, '\n') + '\n' : ''))
|
||||
.catch(function (e) {
|
||||
.catch(e => {
|
||||
ui.addNotification(null, E('p', _('Unable to save contents: %s').format(e.message)));
|
||||
});
|
||||
});
|
||||
};
|
||||
o.remove = function (section_id) {
|
||||
return fs.write('/etc/mosdns/rule/local-ptr.txt', '').catch(function (e) {
|
||||
ui.addNotification(null, E('p', _('Unable to save contents: %s').format(e.message)));
|
||||
});
|
||||
};
|
||||
o.remove = section_id => fs.write('/etc/mosdns/rule/local-ptr.txt', '').catch(e => {
|
||||
ui.addNotification(null, E('p', _('Unable to save contents: %s').format(e.message)));
|
||||
});
|
||||
|
||||
// --- Streaming Media ---
|
||||
o = s.taboption('streamingmedialist', form.TextValue, '_streamingmedialist',
|
||||
@@ -242,35 +200,30 @@ return view.extend({
|
||||
+ '</font>'
|
||||
);
|
||||
o.rows = 25;
|
||||
o.cfgvalue = function (section_id) {
|
||||
return fs.trimmed('/etc/mosdns/rule/streaming.txt').catch(function (e) {
|
||||
return "";
|
||||
});
|
||||
};
|
||||
o.write = function (section_id, formvalue) {
|
||||
return this.cfgvalue(section_id).then(function (value) {
|
||||
if (value == formvalue) {
|
||||
o.cfgvalue = section_id => fs.trimmed('/etc/mosdns/rule/streaming.txt').catch(e => '');
|
||||
o.write = function(section_id, formvalue) {
|
||||
return this.cfgvalue(section_id).then(value => {
|
||||
if (value === formvalue) {
|
||||
return;
|
||||
}
|
||||
return fs.write('/etc/mosdns/rule/streaming.txt', (formvalue.trim() ? formvalue.trim().replace(/\r\n/g, '\n') + '\n' : ''))
|
||||
.catch(function (e) {
|
||||
.catch(e => {
|
||||
ui.addNotification(null, E('p', _('Unable to save contents: %s').format(e.message)));
|
||||
});
|
||||
});
|
||||
};
|
||||
o.remove = function (section_id) {
|
||||
return fs.write('/etc/mosdns/rule/streaming.txt', '').catch(function (e) {
|
||||
ui.addNotification(null, E('p', _('Unable to save contents: %s').format(e.message)));
|
||||
});
|
||||
};
|
||||
o.remove = section_id => fs.write('/etc/mosdns/rule/streaming.txt', '').catch(e => {
|
||||
ui.addNotification(null, E('p', _('Unable to save contents: %s').format(e.message)));
|
||||
});
|
||||
|
||||
return m.render();
|
||||
},
|
||||
|
||||
handleSaveApply: function (ev) {
|
||||
return this.handleSave(ev).then(function() {
|
||||
handleSaveApply(ev) {
|
||||
return this.handleSave(ev).then(() => {
|
||||
window.location.reload();
|
||||
});
|
||||
},
|
||||
|
||||
handleReset: null
|
||||
});
|
||||
@@ -5,28 +5,28 @@
|
||||
'require view';
|
||||
'require rpc';
|
||||
|
||||
var callStartUpdate = rpc.declare({
|
||||
const callStartUpdate = rpc.declare({
|
||||
object: 'luci.mosdns',
|
||||
method: 'start_update',
|
||||
expect: { '': {} }
|
||||
});
|
||||
|
||||
var callGetUpdateLog = rpc.declare({
|
||||
const callGetUpdateLog = rpc.declare({
|
||||
object: 'luci.mosdns',
|
||||
method: 'get_update_log',
|
||||
expect: { '': {} }
|
||||
});
|
||||
|
||||
return view.extend({
|
||||
handleUpdate: function () {
|
||||
var logTextarea = E('textarea', {
|
||||
handleUpdate() {
|
||||
const logTextarea = E('textarea', {
|
||||
'class': 'cbi-input-textarea',
|
||||
'readonly': 'readonly',
|
||||
'style': 'width: 100%; height: 300px; font-family: monospace; font-size: 12px; margin-top: 10px;',
|
||||
'placeholder': _('Starting update...')
|
||||
});
|
||||
|
||||
var closeButton = E('button', {
|
||||
const closeButton = E('button', {
|
||||
'class': 'btn',
|
||||
'style': 'display: none;',
|
||||
'click': ui.hideModal
|
||||
@@ -38,8 +38,8 @@ return view.extend({
|
||||
E('div', { 'class': 'right' }, [ closeButton ])
|
||||
]);
|
||||
|
||||
var pollLog = function() {
|
||||
return callGetUpdateLog().then(function(res) {
|
||||
const pollLog = () => {
|
||||
return callGetUpdateLog().then(res => {
|
||||
if (res && res.log) {
|
||||
logTextarea.value = res.log;
|
||||
logTextarea.scrollTop = logTextarea.scrollHeight;
|
||||
@@ -60,10 +60,10 @@ return view.extend({
|
||||
});
|
||||
};
|
||||
|
||||
return callStartUpdate().then(function(res) {
|
||||
return callStartUpdate().then(res => {
|
||||
if (res.success) {
|
||||
var interval = window.setInterval(function() {
|
||||
pollLog().then(function(continuePolling) {
|
||||
const interval = window.setInterval(() => {
|
||||
pollLog().then(continuePolling => {
|
||||
if (!continuePolling) {
|
||||
window.clearInterval(interval);
|
||||
}
|
||||
@@ -73,14 +73,14 @@ return view.extend({
|
||||
ui.hideModal();
|
||||
ui.addNotification(null, E('p', res.error || _('Failed to start update.')), 'error');
|
||||
}
|
||||
}).catch(function(e) {
|
||||
}).catch(e => {
|
||||
ui.hideModal();
|
||||
ui.addNotification(null, E('p', _('Update failed: %s').format(e.message)), 'error');
|
||||
});
|
||||
},
|
||||
|
||||
render: function () {
|
||||
var m, s, o;
|
||||
render() {
|
||||
let m, s, o;
|
||||
|
||||
m = new form.Map('mosdns', _('Update GeoIP & GeoSite databases'),
|
||||
_('Automatically update GeoIP and GeoSite databases as well as ad filtering rules through scheduled tasks.'));
|
||||
@@ -105,14 +105,14 @@ return view.extend({
|
||||
o = s.option(form.ListValue, 'geo_update_day_time', _('Update Time'));
|
||||
for (let t = 0; t < 24; t++) {
|
||||
o.value(t, t + ':00');
|
||||
};
|
||||
}
|
||||
o.default = 3;
|
||||
|
||||
o = s.option(form.ListValue, 'geoip_type', _('GeoIP Type'),
|
||||
_('Little: only include Mainland China and Private IP addresses.') +
|
||||
'<br>' +
|
||||
_('Full: includes all Countries and Private IP addresses.')
|
||||
);
|
||||
);
|
||||
o.value('geoip', _('Full'));
|
||||
o.value('geoip-only-cn-private', _('Little'));
|
||||
o.rmempty = false;
|
||||
@@ -129,7 +129,7 @@ return view.extend({
|
||||
o.title = _('Database Update');
|
||||
o.inputtitle = _('Check And Update');
|
||||
o.inputstyle = 'apply';
|
||||
o.onclick = L.bind(this.handleUpdate, this);
|
||||
o.onclick = () => this.handleUpdate();
|
||||
|
||||
return m.render();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user