Home
Reading
Searching
Subscribe
Sponsors
Statistics
Posting
Contact
Spam
Lists
Links
About
Hosting
Filtering
Features Download
Marketing
Archives
FAQ
Blog
 
Gmane
From: Rodrigo Araujo <roa-YWehAnL2kLNBDgjK7y7TUQ <at> public.gmane.org>
Subject: Ticket 14 (allow reusing the use option) fix proposed patch
Newsgroups: gmane.network.dns.ddclient.user
Date: Sunday 30th June 2013 23:47:42 UTC (over 4 years ago)
Hello.

Attached is my proposed solution for fixing the following issue:

http://sourceforge.net/apps/trac/ddclient/ticket/14

Basically, in the subrouting update_nics, instead of using only the
'use' value as key to the %iplist hash when checking to avoid repeating
the same command, I use several option values related to the host being
processed and that may (or may not) be related to the -use option being
processed for the host.

Initially I used a much more simple approach by using only 2 keys - $use
and opt($use, $h) - and that would work for most cases, but when you
have options like -use=cisco or -use=cisco-asa that accept arguments
from -fw and -if, that wouldn't be enough. I decided to use all keys
instead: it's not pretty but it does the job, as it doesn't really
matter if all the options aren't used by the method or aren't defined at
all (it will use '' as value in that case). Only disadvantages is there
might be some miliseconds of overhead (but hardly noticeable as perl
hashes are very efficient) and you might have to keep in mind to update
this "key chain" (let's call it that) should you add more arguments
related to "-use" methods in the future.

Probably could be reworked to use another subroutine to do the dirty
job, but if you ask me this is enough for my usage cenarios where I have
multiple providers, each with different IP addresses, and I must
sometimes use the same -use argument for each, such as -use=if,if=eth0
for one and -use=if,if=eth1 for another, or -use=cmd method invoking a
different cmd for each one and playing with curl (like cmd="curl -sS
--interface eth2http://checkip.dyndns.org/",
cmd-skip="Current IP
Address: ", \ ...) - with this patch, it works like a charm and should
be easy for you to figure more uses out of it, but should you need more
elaborate examples please let me know.

Other change I did is in the get_ip function to make the $arg variable
value be retrieved related to the $h (host), as the opt subroutine
handles that well already (and thus I removed a line in update_nics that
redefined $opt{$use} as local, seemed more logical to me to do it like
this). I also took advantage of the opt subroutine handling the $h
(host) argument and retrieving the global variable if necessary to do
minor cleanups in the update_nics sub. Seems good to me, but please
confirm.

The attached patch was made against the trunk svn version, but also
applies well to version 3.8.1 (at least the one that comes with Fedora
17, where I tested).

Can you check if it's worthy (and doesn't break anything) to include on
the upcoming 3.8.2 version? If this is not the place to submit the
patch, then I'm sorry and please tell me where is the correct place (I
couldn't figure out where to do it in trac).

Best regards, and keep up the excelent work :)

-- 
Rodrigo Araújo 
Administrador de Sistemas
Eurotux Informática, S.A. | www.eurotux.com
Tel: (+351) 253680300 - Suporte: (+351) 253680301 Fax: (+351) 253680319
 
CD: 3ms