luci-app-ddns: check existence of nslookup util rather than making DNS request 2384/head
authorDavid Beitey <david@davidjb.com>
Fri, 21 Dec 2018 02:51:56 +0000 (02:51 +0000)
committerDavid Beitey <david@davidjb.com>
Fri, 21 Dec 2018 02:54:54 +0000 (12:54 +1000)
This saves a DNS request whenever the check is performed.  For systems with nameservers configured in `/etc/resolv.conf`, nslookup will sent a request to those servers (eg bypassing /etc/hosts), thus taking a lot more time than necessary.  For servers that are remote, this will take a *lot* longer than just checking if the nslookup util exists.

This change follows in the same vein as all the other checks and just using `which` without actually invoking the util's functionality.

Signed-off-by: David Beitey <david@davidjb.com>
applications/luci-app-ddns/luasrc/tools/ddns.lua

index 6f0c7f0952e596f6cce8fb38a8a43c6190aa481b..2b92e3e6362c2ce11efedc2e3e0af48f4329cadf 100755 (executable)
@@ -103,7 +103,7 @@ function env_info(type)
                end
 
                local function has_nslookup()
-                       return (SYS.call( [[$(which nslookup) localhost 2>&1 | grep -qF "(null)"]] ) ~= 0)
+                       return (SYS.call( [[which nslookup >/dev/null 2>&1]] ) == 0)
                end
 
                if type == "has_bindhost" then