Re: [Ddclient-support] ddclient improvement suggestion.
Brought to you by:
supersandro2000,
wimpunk
From: Paul N. P. <pau...@gm...> - 2015-01-01 19:54:49
|
I can only imagine the joyous times involved in uncovering such a bug. On Thu, Jan 1, 2015 at 11:47 AM, balthasar_s < bic...@ch...> wrote: > ddclient won't update the IP until a minimal interval since last update. > Very good. But the way it's implemented now can lead to problems in > specific circumstances. > > For example. It's 2015. But the system clock is erroneously set to > 2020 (because of problems with NTP or something else). Then ddclient > runs and remembers in the cache that the last run was in 2020. After > the system clock is (automatically) set back to 2015, ddclient becomes > non-functional. It will refuse to update the IP because the 5 minute > (or whatever else) interval since 2020 has not passed yet. Until 2020 > ddclient won't update anything unless the cache is removed. > This is problematic because when you notice that you have to fix it > and remove the cache it's too late because the IP changed, was not > updated and you don't have access to your computer. > > This can be easily improved. Instead of checking the time distance > into the future check the time distance in both directions. To do so > replace one line in the interval_expired function. > > > Change this: > > sub interval_expired { > my ($host, $time, $interval) = @_; > > return 1 if !exists $cache{$host}; > return 1 if !exists $cache{$host}{$time} || !$cache{$host}{$time}; > return 1 if !exists $config{$host}{$interval} || > !$config{$host}{$interval}; > > return $now > ($cache{$host}{$time} + $config{$host}{$interval}); > } > > to this: > > sub interval_expired { > my ($host, $time, $interval) = @_; > > return 1 if !exists $cache{$host}; > return 1 if !exists $cache{$host}{$time} || !$cache{$host}{$time}; > return 1 if !exists $config{$host}{$interval} || > !$config{$host}{$interval}; > > return ($now > ($cache{$host}{$time} + $config{$host}{$interval})) > || ($now < ($cache{$host}{$time} - $config{$host}{$interval})); > } > > > that's all. > > > Balthasar Szczepański > > > ------------------------------------------------------------------------------ > Dive into the World of Parallel Programming! The Go Parallel Website, > sponsored by Intel and developed in partnership with Slashdot Media, is > your > hub for all things parallel software development, from weekly thought > leadership blogs to news, videos, case studies, tutorials and more. Take a > look and join the conversation now. http://goparallel.sourceforge.net > _______________________________________________ > Ddclient-support mailing list > Ddc...@li... > https://lists.sourceforge.net/lists/listinfo/ddclient-support > |