Commit 8da38987 authored by Tails developers's avatar Tails developers
Browse files

Import htpdate (commit ba7f0b9) that allows setting wget's --dns-timeout.

parent 5f6d57b4
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
# #
# htpdate time poller version 0.9.3 # htpdate time poller version 0.9.3
# Copyright (C) 2005 Eddy Vervest # Copyright (C) 2005 Eddy Vervest
# Copyright (C) 2010 Tails dev team <amnesia@boum.org> # Copyright (C) 2010-2011 Tails developers <tails@boum.org>
# #
# This program is free software; you can redistribute it and/or # This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License # modify it under the terms of the GNU General Public License
...@@ -52,8 +52,9 @@ my $set_date = 1; ...@@ -52,8 +52,9 @@ my $set_date = 1;
my $ssl_protocol = 'TLSv1'; # will be passed to wget's --secure-protocol my $ssl_protocol = 'TLSv1'; # will be passed to wget's --secure-protocol
my $useragent = "htpdate/$VERSION"; my $useragent = "htpdate/$VERSION";
my $userid = ''; # userid for proxy servers my $userid = ''; # userid for proxy servers
my $dns_timeout;
our ($opt_d, $opt_h, $opt_q, $opt_x, $opt_u, $opt_a, $opt_f, $opt_l, $opt_p); our ($opt_d, $opt_h, $opt_q, $opt_x, $opt_u, $opt_a, $opt_f, $opt_l, $opt_p, $opt_t);
sub message { sub message {
my @msg = @_; my @msg = @_;
...@@ -81,7 +82,7 @@ sub error (@_) { ...@@ -81,7 +82,7 @@ sub error (@_) {
sub parseCommandLine () { sub parseCommandLine () {
# specify valid switches # specify valid switches
getopts('dhqxfpu:a:l:') || usage(); getopts('dhqxfpu:a:l:t:') || usage();
usage() if $opt_h; usage() if $opt_h;
usage() unless $ARGV[0]; usage() unless $ARGV[0];
...@@ -94,6 +95,7 @@ sub parseCommandLine () { ...@@ -94,6 +95,7 @@ sub parseCommandLine () {
$paranoid = 1 if $opt_p; $paranoid = 1 if $opt_p;
$quiet = 1 if $opt_q; $quiet = 1 if $opt_q;
$set_date = 0 if $opt_x; $set_date = 0 if $opt_x;
$dns_timeout = $opt_t if $opt_t;
my @urls; my @urls;
foreach my $url (@ARGV) { foreach my $url (@ARGV) {
...@@ -111,7 +113,7 @@ sub usage () { ...@@ -111,7 +113,7 @@ sub usage () {
print STDERR <<USAGE; print STDERR <<USAGE;
htpdate version $VERSION htpdate version $VERSION
Usage: $0 [-dhqxf] [-u userid] [-a useragent] <URL> [<URL> ...] Usage: $0 [-dhqxf] [-u userid] [-a useragent] [-t dns_timeout] <URL> [<URL> ...]
-d debug -d debug
-h show this help -h show this help
...@@ -122,6 +124,7 @@ Usage: $0 [-dhqxf] [-u userid] [-a useragent] <URL> [<URL> ...] ...@@ -122,6 +124,7 @@ Usage: $0 [-dhqxf] [-u userid] [-a useragent] <URL> [<URL> ...]
-f request the full page and referenced resources rather than only its header -f request the full page and referenced resources rather than only its header
-l log to this file rather than to STDOUT -l log to this file rather than to STDOUT
-p paranoid mode: don't set time unless all servers could be reached -p paranoid mode: don't set time unless all servers could be reached
-t DNS timeout for wget
e.g. $0 -x http://www.microsoft.com/ https://check.torproject.org/ e.g. $0 -x http://www.microsoft.com/ https://check.torproject.org/
...@@ -174,6 +177,7 @@ sub getRemoteDateDiff { ...@@ -174,6 +177,7 @@ sub getRemoteDateDiff {
'--no-directories', '--no-directories',
'--secure-protocol', $ssl_protocol, '--secure-protocol', $ssl_protocol,
); );
push @wget_options, ('--dns-timeout', $dns_timeout) if defined $dns_timeout;
push @wget_options, ('--directory-prefix', $tmpdir); push @wget_options, ('--directory-prefix', $tmpdir);
if ($fullrequest) { if ($fullrequest) {
push @wget_options, ('--page-requisites', '--span-hosts'); push @wget_options, ('--page-requisites', '--span-hosts');
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment