You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2021/01/05 01:10:05 UTC
[GitHub] [apisix] MarsSec773 opened a new issue #3186: Cannot parse DNS IPv6 address
MarsSec773 opened a new issue #3186:
URL: https://github.com/apache/apisix/issues/3186
# Improve Docs
Continue with #3184
I got an error of "local DNS is empty" when I try to deploy a APISIX pod.
I specified DNS resolver as IPv6 address.
## Please describe which part of docs should be improved or typo fixed
Source code with the error:
```
local dns_resolver = sys_conf["dns_resolver"]
if not dns_resolver or #dns_resolver == 0 then
local dns_addrs, err = local_dns_resolver("/etc/resolv.conf")
if not dns_addrs then
util.die("failed to import local DNS: ", err, "\n")
end
if #dns_addrs == 0 then
util.die("local DNS is empty\n")
end
sys_conf["dns_resolver"] = dns_addrs
end
```
DNS address is not read because local_dns_resolver function doesn't parse IPv6 address.
We can see the regex.
```
local function local_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 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
end
file:close()
return dns_addrs
end
```
I hope this improvement could be applied, thanks.
## Describe the solution you'd like
Add a regex for IPv6 DNS resolver.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] MarsSec773 commented on issue #3186: Cannot parse DNS IPv6 address
Posted by GitBox <gi...@apache.org>.
MarsSec773 commented on issue #3186:
URL: https://github.com/apache/apisix/issues/3186#issuecomment-754352950
> @MarsSec773
> Can you try #3187?
Thank you very much for your quick response.
Everything works great.
By adding [ ] to enclose the IPv6 address additionally, I got running state of apisix server.
```
NAME READY STATUS RESTARTS AGE
apisix-server-65fd5bb697-d8xv6 1/1 Running 0 26s
```
I don't have experience of coding Lua. FYI, let me provide my final script.
```
local function local_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 dns_addrs = {}
for line in file:lines() do
local addr, n = line:gsub("^nameserver%s+(%d+%.%d+%.%d+%.%d+)%s*$", "%1")
local addr6, n6 = line:gsub("^nameserver%s+([^%s]+)%s*$", "%1")
if n == 1 then
table_insert(dns_addrs, addr)
end
if n6 == 1 then
table_insert(dns_addrs, "[" .. addr6 .. "]")
end
end
file:close()
return dns_addrs
end
```
Thank you so much @spacewander .
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] spacewander commented on issue #3186: Cannot parse DNS IPv6 address
Posted by GitBox <gi...@apache.org>.
spacewander commented on issue #3186:
URL: https://github.com/apache/apisix/issues/3186#issuecomment-754333951
@MarsSec773
Can you try https://github.com/apache/apisix/pull/3187?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] spacewander closed issue #3186: Cannot parse DNS IPv6 address
Posted by GitBox <gi...@apache.org>.
spacewander closed issue #3186:
URL: https://github.com/apache/apisix/issues/3186
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org