d5e663fdc67698b35ae76607dd7cf3b722a3b46f
[openwrt.git] / openwrt / package / htpdate / patches / 500-check-time-delta-opt.patch
1 diff -ruN htpdate-0.8.0-old/htpdate.c htpdate-0.8.0-new/htpdate.c
2 --- htpdate-0.8.0-old/htpdate.c 2005-05-26 23:32:18.000000000 +0200
3 +++ htpdate-0.8.0-new/htpdate.c 2005-06-02 04:33:33.000000000 +0200
4 @@ -243,7 +243,7 @@
5 printf("htpdate version %s\n", version);
6 printf("\
7 Usage: htpdate [-0|-1] [-a|-q|-s] [-d|-D] [-h|-l] [-i pid file] [-m minpoll]\n\
8 - [-M maxpoll] [-P <proxyserver>[:port]] <host[:port]> ...\n\n\
9 + [-M maxpoll] [-C limit] [-P <proxyserver>[:port]] <host[:port]> ...\n\n\
10 -0 HTTP/1.0 request (default)\n\
11 -1 HTTP/1.1 request\n\
12 -a adjust time smoothly\n\
13 @@ -257,6 +257,8 @@
14 -m minimum poll interval (2^m)\n\
15 -M maximum poll interval (2^M)\n\
16 -P proxy server\n\
17 + -C time delta limit in server responses (in seconds)\n\
18 + default: 1 year, unlimited: 0\n\
19 host web server hostname or ip address\n\
20 port port number (default 80 and 8080 for proxy server)\n\n");
21
22 @@ -271,6 +273,7 @@
23 int port, proxyport = 8080;
24 int sumtime, numservers, validtime, goodtime, mean, i;
25 double timeavg;
26 + int timedeltalimit = YEAR;
27 unsigned int nap = 0, when = 500000;
28 unsigned int minsleep = 10, maxsleep = 18, sleeptime = minsleep;
29 char setmode = 0, httpversion = 0, try, param;
30 @@ -283,7 +286,7 @@
31
32
33 /* Parse the command line switches and arguments */
34 - while ( (param = getopt(argc, argv, "01adhi:lm:qsDM:P:") ) != -1)
35 + while ( (param = getopt(argc, argv, "01adhi:lm:qsDM:P:C:") ) != -1)
36 switch (param)
37 {
38 case '0': /* adjust time */
39 @@ -340,6 +343,12 @@
40 }
41 }
42 break;
43 + case 'C': /* time delta limit in server responses */
44 + if ( (timedeltalimit = atoi(optarg) ) < 0 ) {
45 + printlog( 1, "Invalid time delta limit" );
46 + exit(1);
47 + }
48 + break;
49 case '?':
50 return 1;
51 default:
52 @@ -458,10 +467,12 @@
53 try--;
54 } while ( timestamp && try && daemonize );
55
56 - /* Only include valid responses in timedelta[], |delta time| < year */
57 - if ( ( timestamp > -YEAR ) && ( timestamp < YEAR ) ) {
58 - timedelta[validtime] = timestamp;
59 + timedelta[validtime] = timestamp;
60 + /* Only include valid responses in timedelta[], |delta time| < validlimit */
61 + if ( ( timedeltalimit == 0 ) || ( ( timestamp > -timedeltalimit ) && ( timestamp < timedeltalimit ) ) ) {
62 validtime++;
63 + } else {
64 + printlog( 0, "Invalid server response (host: %s, time delta: %d, limit: %d)", host, timestamp, timedeltalimit);
65 }
66
67 /* Sleep for a while, unless we detected a time offset */
This page took 0.061116 seconds and 3 git commands to generate.