mirror of
https://github.com/openwrt/luci.git
synced 2026-05-31 02:21:50 +08:00
luci-app-ddns: correctness fixes
Signed-off-by: Paul Donald <newtwen+github@gmail.com>
This commit is contained in:
@@ -171,9 +171,9 @@ return view.extend({
|
||||
.catch(function(e) { ui.addNotification(null, E('p', e.message)) });
|
||||
},
|
||||
|
||||
HandleStopDDnsRule(m, section_id, ev) {
|
||||
handleStopDDnsRule(m, section_id, ev) {
|
||||
return fs.exec('/usr/lib/ddns/dynamic_dns_lucihelper.sh',
|
||||
[ '-S', section_id, '--', 'start' ])
|
||||
[ '-S', section_id, '--', 'stop' ])
|
||||
.then(L.bind(m.render, m))
|
||||
.catch(function(e) { ui.addNotification(null, E('p', e.message)) });
|
||||
},
|
||||
@@ -551,7 +551,7 @@ return view.extend({
|
||||
},
|
||||
stop_opt = {
|
||||
'class': 'cbi-button cbi-button-neutral stop',
|
||||
'click': ui.createHandlerFn(_this, 'HandleStopDDnsRule', m, section_id),
|
||||
'click': ui.createHandlerFn(_this, 'handleStopDDnsRule', m, section_id),
|
||||
'title': _('Stop this service'),
|
||||
};
|
||||
|
||||
|
||||
@@ -15,7 +15,12 @@ const luci_helper = '/usr/lib/ddns/dynamic_dns_lucihelper.sh';
|
||||
const ddns_version_file = '/usr/share/ddns/version';
|
||||
|
||||
|
||||
function shellquote(value) {
|
||||
if (value == null)
|
||||
value = '';
|
||||
|
||||
return "'" + replace(value, "'", "'\\''") + "'";
|
||||
}
|
||||
|
||||
function get_dateformat() {
|
||||
return uci.get('ddns', 'global', 'ddns_dateformat') || '%F %R';
|
||||
@@ -126,9 +131,9 @@ const methods = {
|
||||
if (forceDnsTcp == 1) push(command, '-t');
|
||||
// if (isGlue == 1) push(command, '-g');
|
||||
|
||||
push(command, '-l', lookupHost);
|
||||
push(command, '-S', section);
|
||||
if (length(dnsServer) > 0) push(command, '-d', dnsServer);
|
||||
push(command, '-l', shellquote(lookupHost));
|
||||
push(command, '-S', shellquote(section));
|
||||
if (length(dnsServer) > 0) push(command, '-d', shellquote(dnsServer));
|
||||
push(command, '-- get_registered_ip');
|
||||
|
||||
const result = system(`${join(' ', command)}`);
|
||||
@@ -221,50 +226,40 @@ const methods = {
|
||||
|
||||
const hasCommand = (command) => { return (system(`command -v ${command} 1>/dev/null`) == 0) ? true : false };
|
||||
|
||||
const hasWget = () => hasCommand('wget');
|
||||
const hasWget = () => {
|
||||
return cache.has_wget ??= hasCommand('wget');
|
||||
}
|
||||
|
||||
const hasWgetSsl = () => {
|
||||
if (cache['has_wgetssl']) return cache['has_wgetssl'];
|
||||
const result = hasWget() && system(`wget 2>&1 | grep -iqF 'https'`) == 0 ? true : false;
|
||||
cache['has_wgetssl'] = result;
|
||||
return result;
|
||||
return cache.has_wgetssl ??= hasWget() && system(`wget 2>&1 | grep -iqF 'https'`) == 0 ? true : false;
|
||||
};
|
||||
|
||||
const hasGNUWgetSsl = () => {
|
||||
if (cache['has_gnuwgetssl']) return cache['has_gnuwgetssl'];
|
||||
const result = hasWget() && system(`wget -V 2>&1 | grep -iqF '+https'`) == 0 ? true : false;
|
||||
cache['has_gnuwgetssl'] = result;
|
||||
return result;
|
||||
return cache.has_gnuwgetssl ??= hasWget() && system(`wget -V 2>&1 | grep -iqF '+https'`) == 0 ? true : false;
|
||||
};
|
||||
|
||||
const hasCurl = () => {
|
||||
if (cache['has_curl']) return cache['has_curl'];
|
||||
const result = hasCommand('curl');
|
||||
cache['has_curl'] = result;
|
||||
return result;
|
||||
return cache.has_curl ??= hasCommand('curl');
|
||||
};
|
||||
|
||||
const hasCurlSsl = () => {
|
||||
return system(`curl -V 2>&1 | grep -qF 'https'`) == 0 ? true : false;
|
||||
return cache.has_curl_ssl ??= system(`curl -V 2>&1 | grep -qF 'https'`) == 0 ? true : false;
|
||||
};
|
||||
|
||||
const hasFetch = () => {
|
||||
if (cache['has_fetch']) return cache['has_fetch'];
|
||||
const result = hasCommand('uclient-fetch');
|
||||
cache['has_fetch'] = result;
|
||||
return result;
|
||||
return cache.has_fetch ??= hasCommand('uclient-fetch');
|
||||
};
|
||||
|
||||
const hasFetchSsl = () => {
|
||||
return stat('/lib/libustream-ssl.so') == 0 ? true : false;
|
||||
return cache.has_fetch_ssl ??= stat('/lib/libustream-ssl.so') ? true : false;
|
||||
};
|
||||
|
||||
const hasCurlPxy = () => {
|
||||
return system(`grep -i 'all_proxy' /usr/lib/libcurl.so*`) == 0 ? true : false;
|
||||
return cache.has_curl_proxy ??= system(`grep -i 'all_proxy' /usr/lib/libcurl.so*`) == 0 ? true : false;
|
||||
};
|
||||
|
||||
const hasBbwget = () => {
|
||||
return system(`wget -V 2>&1 | grep -iqF 'busybox'`) == 0 ? true : false;
|
||||
return cache.has_bbwget ??= system(`wget -V 2>&1 | grep -iqF 'busybox'`) == 0 ? true : false;
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user