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 @@
#
# htpdate time poller version 0.9.3
# 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
# modify it under the terms of the GNU General Public License
......@@ -52,8 +52,9 @@ my $set_date = 1;
my $ssl_protocol = 'TLSv1'; # will be passed to wget's --secure-protocol
my $useragent = "htpdate/$VERSION";
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 {
my @msg = @_;
......@@ -81,7 +82,7 @@ sub error (@_) {
sub parseCommandLine () {
# specify valid switches
getopts('dhqxfpu:a:l:') || usage();
getopts('dhqxfpu:a:l:t:') || usage();
usage() if $opt_h;
usage() unless $ARGV[0];
......@@ -94,6 +95,7 @@ sub parseCommandLine () {
$paranoid = 1 if $opt_p;
$quiet = 1 if $opt_q;
$set_date = 0 if $opt_x;
$dns_timeout = $opt_t if $opt_t;
my @urls;
foreach my $url (@ARGV) {
......@@ -111,7 +113,7 @@ sub usage () {
print STDERR <<USAGE;
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
-h show this help
......@@ -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
-l log to this file rather than to STDOUT
-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/
......@@ -174,6 +177,7 @@ sub getRemoteDateDiff {
'--no-directories',
'--secure-protocol', $ssl_protocol,
);
push @wget_options, ('--dns-timeout', $dns_timeout) if defined $dns_timeout;
push @wget_options, ('--directory-prefix', $tmpdir);
if ($fullrequest) {
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