qiujiayu commented on a change in pull request #1217: enable local DNS
URL: https://github.com/apache/incubator-apisix/pull/1217#discussion_r396290873
##########
File path: t/APISIX.pm
##########
@@ -37,6 +37,38 @@ sub read_file($) {
$data;
}
+sub local_dns_resolver() {
+ open my $in, "/etc/resolv.conf" or die "cannot open /etc/resolv.conf";
+ my @lines = <$in>;
+ my @dns_addrs = ();
+ foreach my $line (@lines){
+ $line =~ m/^nameserver\s+(\d+[.]\d+[.]\d+[.]\d+)\s*$/;
+ if ($1) {
+ push(@dns_addrs, $1);
+ }
+ }
+ close($in);
+ return @dns_addrs
+}
+
+
+my $dns_addrs_str = "";
+my $dns_addrs_tbl_str = "";
+my $enable_local_dns = 0;
+if ($enable_local_dns) {
+ my @dns_addrs = local_dns_resolver();
+ $dns_addrs_tbl_str = "{";
+ foreach my $addr (@dns_addrs){
+ $dns_addrs_str = "$dns_addrs_str $addr";
+ $dns_addrs_tbl_str = "$dns_addrs_tbl_str\"$addr\", ";
+ }
+ $dns_addrs_tbl_str = "$dns_addrs_tbl_str}";
+} else {
+ $dns_addrs_str = "8.8.8.8 114.114.114.114";
+ $dns_addrs_tbl_str = "{\"8.8.8.8\", \"114.114.114.114\"}";
+}
+
+
Review comment:
had add a test case for enable local DNS
----------------------------------------------------------------
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:
[email protected]
With regards,
Apache Git Services