-
Notifications
You must be signed in to change notification settings - Fork 170
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[dns] use both RESOLVER and resolver.conf
closes #321 we need to use all nameservers because we can't trust dnsmasq as it returns the first answer even though it is not the same class
- Loading branch information
Showing
3 changed files
with
72 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
use Test::Nginx::Socket 'no_plan'; | ||
use Cwd qw(cwd); | ||
|
||
my $pwd = cwd(); | ||
my $apicast = $ENV{TEST_NGINX_APICAST_PATH} || "$pwd/apicast"; | ||
|
||
$ENV{TEST_NGINX_LUA_PATH} = "$apicast/src/?.lua;;"; | ||
$ENV{TEST_NGINX_HTTP_CONFIG} = "$apicast/http.d/*.conf"; | ||
$ENV{TEST_NGINX_APICAST_PATH} = $apicast; | ||
$ENV{RESOLVER} = '127.0.1.1:5353'; | ||
|
||
|
||
env_to_nginx( | ||
'RESOLVER' | ||
); | ||
master_on(); | ||
log_level('warn'); | ||
repeat_each(2); | ||
no_root_location(); | ||
run_tests(); | ||
|
||
__DATA__ | ||
=== TEST 1: uses all resolvers | ||
both RESOLVER env variable and resolvers in resolv.conf should be used | ||
--- http_config | ||
lua_package_path "$TEST_NGINX_LUA_PATH"; | ||
init_by_lua_block { | ||
require('resty.resolver').init(ngx.config.prefix() .. 'html/resolv.conf') | ||
} | ||
--- config | ||
location = /t { | ||
content_by_lua_block { | ||
local nameservers = require('resty.resolver').nameservers() | ||
ngx.say('nameservers: ', #nameservers, ' ', nameservers[1], ' ', nameservers[2], ' ', nameservers[3]) | ||
} | ||
} | ||
--- request | ||
GET /t | ||
--- response_body | ||
nameservers: 3 127.0.1.15353 1.2.3.453 4.5.6.753 | ||
--- user_files | ||
>>> resolv.conf | ||
nameserver 1.2.3.4 | ||
nameserver 4.5.6.7 |