This is an automated email from the ASF dual-hosted git repository.
membphis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-apisix.git
The following commit(s) were added to refs/heads/master by this push:
new 7340a07 CLI: fixed bad code style. (#1182)
7340a07 is described below
commit 7340a07411d24e86cd369788c6fe50422dd54848
Author: Ayeshmantha Perera <[email protected]>
AuthorDate: Tue Mar 3 10:34:20 2020 +0100
CLI: fixed bad code style. (#1182)
---
bin/apisix | 28 ++++++++++++++--------------
1 file changed, 14 insertions(+), 14 deletions(-)
diff --git a/bin/apisix b/bin/apisix
index 3a078f8..a8cb07f 100755
--- a/bin/apisix
+++ b/bin/apisix
@@ -540,23 +540,23 @@ local function check_or_version(cur_ver_s, need_ver_s)
return true
end
+local function system_dns_resolver(file_path)
+ local file, err = io.open(file_path, "rb")
+ if not file then
+ return false, "failed to open file: " .. file_path .. ", error info:"
.. err
+ end
-local function system_dns_resolver()
- local file, err = io.open("/etc/resolv.conf")
- if err then
- return nil, err
- else
- local dns_addrs = {}
- for line in file:lines() do
- local addr, n =
line:gsub("^nameserver%s+(%d+%.%d+%.%d+%.%d+)%s*$", "%1")
- if n == 1 then
- table.insert(dns_addrs, addr)
- end
+ local dns_addrs = {}
+ for line in file:lines() do
+ local addr, n = line:gsub("^nameserver%s+(%d+%.%d+%.%d+%.%d+)%s*$",
"%1")
+ if n == 1 then
+ table.insert(dns_addrs, addr)
end
- return dns_addrs
end
-end
+ file:close()
+ return dns_addrs
+end
local _M = {version = 0.1}
@@ -636,7 +636,7 @@ local function init()
sys_conf["worker_processes"] = "auto"
end
- local dns_addrs = system_dns_resolver()
+ local dns_addrs = system_dns_resolver("/etc/resolv.conf")
if dns_addrs then
local dns_resolver = sys_conf["dns_resolver"]
if dns_resolver then