luci-app-mosdns: optimize rule file write
Signed-off-by: sbwml <admin@cooluc.com>
This commit is contained in:
parent
6f37807cf5
commit
b98af55480
@ -1,7 +1,7 @@
|
|||||||
include $(TOPDIR)/rules.mk
|
include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
PKG_NAME:=luci-app-mosdns
|
PKG_NAME:=luci-app-mosdns
|
||||||
PKG_VERSION:=1.6.0
|
PKG_VERSION:=1.6.1
|
||||||
PKG_RELEASE:=1
|
PKG_RELEASE:=1
|
||||||
|
|
||||||
LUCI_TITLE:=LuCI Support for mosdns
|
LUCI_TITLE:=LuCI Support for mosdns
|
||||||
|
@ -37,7 +37,7 @@ function renderStatus(isRunning) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return view.extend({
|
return view.extend({
|
||||||
load: function() {
|
load: function () {
|
||||||
return Promise.all([
|
return Promise.all([
|
||||||
L.resolveDefault(fs.exec('/usr/bin/mosdns', ['version']), null),
|
L.resolveDefault(fs.exec('/usr/bin/mosdns', ['version']), null),
|
||||||
]);
|
]);
|
||||||
@ -314,10 +314,15 @@ return view.extend({
|
|||||||
return fs.trimmed('/etc/mosdns/rule/cloudflare-cidr.txt');
|
return fs.trimmed('/etc/mosdns/rule/cloudflare-cidr.txt');
|
||||||
};
|
};
|
||||||
o.write = function (section_id, formvalue) {
|
o.write = function (section_id, formvalue) {
|
||||||
|
return this.cfgvalue(section_id).then(function (value) {
|
||||||
|
if (value == formvalue) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
return fs.write('/etc/mosdns/rule/cloudflare-cidr.txt', formvalue.trim().replace(/\r\n/g, '\n') + '\n')
|
return fs.write('/etc/mosdns/rule/cloudflare-cidr.txt', formvalue.trim().replace(/\r\n/g, '\n') + '\n')
|
||||||
.then(function (i) {
|
.then(function (i) {
|
||||||
return fs.exec('/etc/init.d/mosdns', ['restart']);
|
return fs.exec('/etc/init.d/mosdns', ['restart']);
|
||||||
});
|
});
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
/* api */
|
/* api */
|
||||||
@ -344,6 +349,10 @@ return view.extend({
|
|||||||
return fs.trimmed('/etc/mosdns/config_custom.yaml');
|
return fs.trimmed('/etc/mosdns/config_custom.yaml');
|
||||||
};
|
};
|
||||||
o.write = function (section_id, formvalue) {
|
o.write = function (section_id, formvalue) {
|
||||||
|
return this.cfgvalue(section_id).then(function (value) {
|
||||||
|
if (value == formvalue) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
return fs.write('/etc/mosdns/config_custom.yaml', formvalue.trim().replace(/\r\n/g, '\n') + '\n')
|
return fs.write('/etc/mosdns/config_custom.yaml', formvalue.trim().replace(/\r\n/g, '\n') + '\n')
|
||||||
.then(function (i) {
|
.then(function (i) {
|
||||||
ui.addNotification(null, E('p', _('Configuration have been saved.')), 'info');
|
ui.addNotification(null, E('p', _('Configuration have been saved.')), 'info');
|
||||||
@ -352,6 +361,7 @@ return view.extend({
|
|||||||
.catch(function (e) {
|
.catch(function (e) {
|
||||||
ui.addNotification(null, E('p', _('Unable to save contents: %s').format(e.message)));
|
ui.addNotification(null, E('p', _('Unable to save contents: %s').format(e.message)));
|
||||||
});
|
});
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
o = s.taboption('geodata', form.DynamicList, 'geosite_tags', _('GeoSite Tags'),
|
o = s.taboption('geodata', form.DynamicList, 'geosite_tags', _('GeoSite Tags'),
|
||||||
|
Loading…
Reference in New Issue
Block a user