Skip to content

Instantly share code, notes, and snippets.

@kazeburo
Created June 21, 2012 02:44
Show Gist options
  • Select an option

  • Save kazeburo/2963516 to your computer and use it in GitHub Desktop.

Select an option

Save kazeburo/2963516 to your computer and use it in GitHub Desktop.
diff --git a/lib/Net/DNS/Lite.pm b/lib/Net/DNS/Lite.pm
index f3e24e0..deb173a 100644
--- a/lib/Net/DNS/Lite.pm
+++ b/lib/Net/DNS/Lite.pm
@@ -381,6 +381,7 @@ sub parse_resolv_conf {
$self->{search} = [];
my $attempts;
+ my $timeout;
for (split /\n/, $resolvconf) {
s/\s*[;#].*$//; # not quite legal, but many people insist
@@ -401,7 +402,7 @@ sub parse_resolv_conf {
} elsif (/^\s*options\s+(.*?)\s*$/i) {
for (split /\s+/, $1) {
if (/^timeout:(\d+)$/) {
- $self->{timeout} = [$1];
+ $timeout = $1;
} elsif (/^attempts:(\d+)$/) {
$attempts = $1;
} elsif (/^ndots:(\d+)$/) {
@@ -412,6 +413,12 @@ sub parse_resolv_conf {
}
}
}
+
+ if ( $timeout || $attempts ) {
+ $timeout ||= 5;
+ $attempts ||= 2;
+ $self->{timeout} = [ map { $timeout } 1..$attempts ];
+ }
}
sub _parse_resolv_conf_file {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment