-
Notifications
You must be signed in to change notification settings - Fork 170
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Split resolv.conf in lines #618
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -113,13 +113,6 @@ function _M.parse_nameservers(path) | |
|
||
local search = { } | ||
local nameservers = { search = search } | ||
local domains = match(resolv_conf, 'search%s+([^\n]+)') | ||
|
||
ngx.log(ngx.DEBUG, 'search ', domains) | ||
for domain in gmatch(domains or '', '([^%s]+)') do | ||
ngx.log(ngx.DEBUG, 'search domain: ', domain) | ||
insert(search, domain) | ||
end | ||
|
||
local resolver | ||
resolver, err = _M.parse_resolver(resty_env.value('RESOLVER')) | ||
|
@@ -131,10 +124,23 @@ function _M.parse_nameservers(path) | |
-- see https://github.com/3scale/apicast/issues/321 for more details | ||
insert(nameservers, resolver) | ||
end | ||
|
||
for _,line in ipairs(re.split(resolv_conf, "\n+")) do | ||
|
||
local domains = match(line, '^search%s+([^\n]+)') | ||
|
||
if domains then | ||
ngx.log(ngx.DEBUG, 'search ', domains) | ||
|
||
for domain in gmatch(domains or '', '([^%s]+)') do | ||
ngx.log(ngx.DEBUG, 'search domain: ', domain) | ||
insert(search, domain) | ||
end | ||
end | ||
|
||
for server in gmatch(resolv_conf, 'nameserver%s+([^%s]+)') do | ||
local server = match(line, '^nameserver%s+([^%s]+)') | ||
-- TODO: implement port matching based on https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=549190 | ||
if server ~= resolver then | ||
if server and server ~= resolver then | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we don't have tests for the case where server == resolver. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
insert(nameservers, nameserver.new(server)) | ||
end | ||
end | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,9 @@ run_tests(); | |
__DATA__ | ||
|
||
=== TEST 1: uses all resolvers | ||
both RESOLVER env variable and resolvers in resolv.conf should be used | ||
both RESOLVER env variable and resolvers in resolv.conf should be used. | ||
checking if commented 'nameserver' and 'search' keywords impact on the | ||
resolv.conf file parsing. | ||
--- main_config | ||
env RESOLVER=$TEST_NGINX_RESOLVER; | ||
--- http_config | ||
|
@@ -34,6 +36,15 @@ GET /t | |
nameservers: 3 127.0.1.15353 1.2.3.453 4.5.6.753 | ||
--- user_files | ||
>>> resolv.conf | ||
# nameserver updated in comentary | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is good. It's testing more things than before, so I think it's worth expanding the description of the test (line 16). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done in d49b712 |
||
#nameserver updated in comentary | ||
#comentary nameserver 1.2.3.4 | ||
#comentary nameserver | ||
# search updated.example.com in comentary | ||
#search updated in comentary | ||
#search nameserver 1.2.3.4 | ||
#search nameserver | ||
search localdomain.example.com local | ||
nameserver 1.2.3.4 | ||
nameserver 4.5.6.7 | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a nitpick. Changelog should focus on "what" and not "how".
Here would be better fit: Skip lines starting with a comment when parsing
resolv.conf
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I bear that in mind. Thanks