pax_global_header00006660000000000000000000000064136053234630014517gustar00rootroot0000000000000052 comment=89c2230adaa02fea758322011e0c0c4135c68060 ddclient-3.9.1/000077500000000000000000000000001360532346300133175ustar00rootroot00000000000000ddclient-3.9.1/.gitignore000066400000000000000000000000431360532346300153040ustar00rootroot00000000000000patches release .svn .cvsignore *~ ddclient-3.9.1/COPYING000066400000000000000000000431061360532346300143560ustar00rootroot00000000000000 GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19yy name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. ddclient-3.9.1/COPYRIGHT000066400000000000000000000015451360532346300146170ustar00rootroot00000000000000ddclient - update client for www.dyndns.org accounts Copyright (C) 1999 Paul Burry (paul@burry.ca) Copyright (C) 2000 Paul Burry (paul@burry.ca) Copyright (C) 2001 Paul Burry (paul@burry.ca) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ddclient-3.9.1/ChangeLog000066400000000000000000000465741360532346300151110ustar00rootroot000000000000002018-08-09 wimpunk * [r208] ddclient: cosmetic, remove stray space indent * [r207] ddclient: Support IPv6 for CloudFlare * [r206] ddclient: name cheap support https now From name cheap it seems http is supported now. Since the password was send on plaintext, https should be used * [r205] ddclient: Use JSON::PP instead of the (deprecated) JSON::Any * [r204] ddclient: Follow expected behavior Align ddclient behavior and documentation with namecheap's - https://www.namecheap.com/support/knowledgebase/article.aspx/583/11/how-do-i-configure-ddclient * [r203] ddclient: Specify port number properly to 'nsupdate' (#58) If a port number is included in the 'server' configuration item, ddclient allows a port number to be specified by appending a colon and the port number to the server's name or IPv4 address. However, nsupdate does not support this syntax, it requires the port number to be separated from the server name/address by whitespace. Signed-off-by: Kevin P. Fleming 2017-04-30 wimpunk * [r202] README.md, README.ssl, ddclient, sample-etc_ddclient.conf, sample-etc_rc.d_init.d_ddclient.alpine: Adding support for freemyip.com Support provided by @Cadence-GitHub in by pull request #47 2015-10-13 wimpunk * [r195] ddclient, sample-etc_ddclient.conf: Merge pull request #25 from dancapper/master Adding configurable TTL to Cloudflare This change adds configurable TTL to cloudflare instead of just using hardcoded value of 1 which sets "automatic" TTL any time ddclient updates the IP address. * [r194] sample-etc_ddclient.conf: Merge pull request #24 from gkranis/master Adding duckdns example Duckdns example added to sample-etc_ddclient.conf * [r193] README.md, sample-etc_rc.d_init.d_ddclient.ubuntu: Prevent service to start multiple times. Added messages if trying to start/stop already started/stopped service. Added daemon install instructions for ubuntu. * [r192] ddclient: odd-fw-patch-squashed * [r191] README.md, ddclient: Added support for woima.fi dyndns service 2015-09-28 wimpunk * [r190] ddclient: Cleanup: removing revision info. Removing revision info even when it's just in the comments. * [r189] ChangeLog: Adding ChangeLog Since we are not going to fetch the changes from svn anymore, we add the old ChangeLog again. * [r188] .cvsignore, .gitignore: Cleanup: removing old ignore files Switching to git so we don't need .cvsignore anymore * [r187] COPYING: FSF address Address for FSF was wrong, corrected * [r186] Changelog.old, README.cisco, ddclient, sample-etc_cron.d_ddclient, sample-etc_ddclient.conf, sample-etc_dhclient-exit-hooks, sample-etc_dhcpc_dhcpcd-eth0.exe, sample-etc_ppp_ip-up.local, sample-etc_rc.d_init.d_ddclient.lsb, sample-etc_rc.d_init.d_ddclient.redhat: Cleanup: removing Id tags from the files Preparing a complete move to git. The Id tag isn't useful so removing from the files seemed to be the best solotion 2015-05-28 wimpunk * [r183] ., release: Removing unneeded release directory 2015-03-23 wimpunk * [r182] ddclient: Reverting to the old perl requirements like suggested in #75 The new requirements were added when adding support for cloudflare. By the simple fix suggested by Roy Tam we could revert the requirements which make ddclient back usable on CentOS and RHEL. * [r181] ddclient: ddclient: made json optional As suggested in pull 7 on github by @abelbeck and @Bugsbane it is better to make the use of JSON related to the use of cloudflare. * [r180] ddclient: ddclient: reindenting cloudflare Indenting cloudflare according to the vim tags * [r179] ddclient: ddclient: correction after duckdns merge Correcting duckdns configuration after commit r178 * [r178] ddclient: Added simple support for Duckdns www.duckdns.org Patch provided by gkranis on github. Merge branch 'gkranis' 2015-03-21 wimpunk * [r177] README.md: Added duckDNS to the README.md * [r176] sample-etc_rc.d_init.d_ddclient.ubuntu: update ubuntu init.d script Merge pull request #9 from gottaloveit/master * [r175] Changelog, Changelog.old: Renamed Changelog to Changelog.old Avoiding conflicts on case insensitive filesystems * [r174] ddclient: Add missing config line for CloudFlare Merge pull request #19 from shikasta-net/fixes * [r173] ddclient: Merge pull request #22 from reddyr/patch-1 loopia.se changed the "Current Address:" output string to "Current IP Address:" * [r172] ddclient: fixed missing ) for cloudflare service hash Merge pull request #16 from adepretis/master 2015-01-20 wimpunk * [r171] README.md, ddclient, sample-etc_ddclient.conf: Adding support for google domain Patch gently provided through github on https://github.com/wimpunk/ddclient/pull/13 2014-10-08 wimpunk * [r170] README.md, ddclient, sample-etc_ddclient.conf: Added support for Cloudflare and multi domain support for namecheap Pull request #7 from @roberthawdon See https://github.com/wimpunk/ddclient/pull/7 for more info. 2014-09-09 wimpunk * [r169] ddclient: Bugfix: allowing long username-password combinations Patch provided by @dirdi through github. 2014-08-20 wimpunk * [r166] ddclient: Fixing bug #72: Account info revealed during noip update * [r165] ddclient: Interfaces can be named almost anything on modern systems. Patch provided by Stephen Couchman through github 2014-06-30 wimpunk * [r164] ddclient: Only delete A RR, not any RR for the FQDN Make the delete command specific to A RRs. This prevents ddclient from deleting other RRs unrelated to the dynamic address, but on the same FQDN. This can be specifically a problem with KEY RRs when using SIG(0) instead of symmetric keys. Reported by: Wellie Chao Bug report: http://sourceforge.net/p/ddclient/bugs/71/ Fixes #71 2014-06-02 wimpunk * [r163] README.md, ddclient: Adding support for nsupdate. Patch provided by Daniel Roethlisberger through github. 2014-04-29 wimpunk * [r162] README.md, README.ssl, ddclient: Removed revision information Revision information isn't very usable when switching to git. 2014-03-20 wimpunk * [r161] README.md, README.ssl, ddclient, sample-etc_rc.d_init.d_ddclient.alpine: Added Alpine Linux init script Patch send by Tal on github. * [r160] RELEASENOTE: Corrected release note 2013-12-26 wimpunk * [r159] release/readme.txt: Commiting updated release information * [r158] README.md, RELEASENOTE: Committing release notes and readme information to trunk 2013-11-05 wimpunk * [r156] patches: Moving patching to the root of the repository. The patches are mostly there for historical reasons. They've been moved away to make cleaning easier. I think the applied patches should even be removed. 2013-10-28 wimpunk * [r155] ddclient: Fallback to iproute if ifconfig doesn't work. This fix applies the patch provided by Maccied Grela in [bugs:#26] * [r154] ddclient: preventing deep sleep - see [bugs:#46] Fixing [bugs:#46] by applying the provided patch. 2013-07-08 wimpunk * [r153] ddclient: Applying patch from [fb1ad014] fixing bug [#14] More info can be found on [fb1ad014] and has been discussed in the mailinglist: http://article.gmane.org/gmane.network.dns.ddclient.user/71. The patch was send by Rodrigo Araujo. 2013-05-14 wimpunk * [r152] ddclient: Adding sha1-patch provided by pirast in [9742ac09] 2013-04-28 wimpunk * [r150] README.md, ddclient, sample-etc_ddclient.conf: Adding support for ChangeIP based on the patch from Michele Giorato http://sourceforge.net/p/ddclient/discussion/399428/thread/e85661ad/ * [r148] README.md: Updated README file * [r147] ., README, README.md: Applying markdown syntax to README 2011-07-11 wimpunk * [r131] release/readme.txt: Updates after releasing 3.8.1 * [r129] release/readme.txt: Corrected release/readme.txt * [r128] sample-etc_ppp_ip-up.local: Applied ip-up_run-parts.diff from ubuntu * [r127] ddclient: Applied smc-barricade-fw-alt.diff from ubuntu 2011-07-03 wimpunk * [r126] ddclient: Fixing #28: FreeDNS.afraid.org changed api slightly 2011-05-19 wimpunk * [r125] ddclient, sample-etc_ddclient.conf: Added patch for dtdns-support (#39) 2011-03-09 wimpunk * [r124] ddclient: Patching with nic_updateable-warning patch provided by antespi in ticket #2 2011-03-08 wimpunk * [r123] ddclient: Patching with zoneedit patch provided by killer-jk in ticket #15 2010-12-07 wimpunk * [r122] ddclient: Added longer password support, sended by Ingo Schwarze (#3130634) 2010-10-13 wimpunk * [r121] ddclient: Fixing bug #13: multiple fetch-ip but introducing a multiple ip bug 2010-09-14 wimpunk * [r120] ddclient: patch for #10: invalid value for keyword ip 2010-09-13 wimpunk * [r119] ddclient: Applied patch from ticket #8, patch for cache content leaks to global * [r118] ddclient: Applied patch from ticket #7, provided by Chris Carr 2010-07-01 wimpunk * [r117] ddclient: Fixed #6: Add Red Hat package name to Perl module IO::Socket::SSL error message 2010-02-24 wimpunk * [r116] ddclient: Subversion revision added 2009-11-09 wimpunk * [r115] ddclient, patches/cisco-asa.patch: Added cisco-asa patch (2891001) submitted by Philip Gladstone * [r114] ddclient, patches/prevent-hang.patch: Added prevent-hang patch (2880462) submitted by Panos 2009-10-19 wimpunk * [r113] ddclient, patches/foreground.patch: Added foreground patch (1893144) submitted by John Palkovic 2009-09-10 wimpunk * [r112] README, ddclient, patches/loopia.patch, sample-etc_ddclient.conf: #1609799 Support for LoopiaDNS (submitted by scilence) 2009-08-05 wimpunk * [r111] ddclient, patches/freedns-patch: applied freedns patch (patch 2832129) 2009-05-16 wimpunk * [r110] ddclient: Bug 2792436: fixed abuse message of dyndns 2009-02-27 wimpunk * [r109] sample-etc_ddclient.conf: Added warning about the update interval (#2619505) 2009-01-27 wimpunk * [r108] .cvsignore, RELEASENOTE, ddclient, release, release/readme.txt: Modified during the release of ddclient-3.8.0 2008-12-04 wimpunk * [r106] ddclient: help about postscript added 2008-11-19 wimpunk * [r105] ddclient, patches/password.patch: Added better password handling sended by Ingo Schwarze * [r104] TODO, sample-ddclient-wrapper.sh: Added ddclient wrapper script * [r103] ddclient: Extra fix for multiple IP's 2008-11-01 wimpunk * [r102] sample-etc_ddclient.conf: Added some remarks concerning the postscript. See https://sourceforge.net/forum/message.php?msg_id=5550545 2008-09-30 wimpunk * [r101] ddclient, patches/multiple-ip.patch: Added support for multiple IP adresses. See http://permalink.gmane.org/gmane.network.dns.ddclient.user/17 * [r100] patches/namecheap.patch: extra comments added to namecheap patch 2008-07-04 wimpunk * [r99] patches/namecheap.patch: namecheap patch added to patches section 2008-06-13 wimpunk * [r98] .: New trunk created based on the old trunk/svn * [r96] svn: Moved old trunk/svn to ddclient and it will be the new trunk * [r95] svn: Ignoring test configuration * [r94] svn/.cvsignore, svn/RELEASENOTE, svn/UPGRADE: Added some release related files * [r93] svn/patches/no-host.patch: Added not used no-host patch to patches section 2008-06-05 wimpunk * [r90] svn/ddclient: Added more info about the daemon interval * [r89] svn/ddclient: Preventing error while reading cache when ip wasn't set correctly before * [r88] svn/ddclient: Preventing an error when trying to send a message on mail-failure 2008-06-02 wimpunk * [r87] svn/ddclient, svn/sample-etc_ddclient.conf: Modified documentation about zoneedit based on the comments from Oren Held 2008-03-04 wimpunk * [r86] svn/patches/ddclient.daemon-timeout.patch: Added patch which was applied to rev 27 (posted by James deBoer) 2008-02-19 wimpunk * [r85] svn/patches/eurodns.patch: Patch modified to apply on ddclient 3.7.3 2008-02-08 wimpunk * [r84] svn/patches/mail-on-kill.patch: Added mail-on-kill patch to patches section 2008-02-05 wimpunk * [r83] svn/ddclient: Sending mail when killed, not after TERM-signal * [r82] svn/README: Added creation of cache dir 2007-10-29 wimpunk * [r81] svn/ddclient, svn/patches/ubuntu/default-timeout.patch: Added and applied default timeout patch from https://bugs.launchpad.net/ubuntu/+source/ddclient/+bug/116066 2007-08-29 wimpunk * [r80] svn/ddclient, svn/patches/ddclient-noip.patch: Added ddclient-noip.patch send by Kurt Bussche. 2007-08-07 wimpunk * [r78] svn/ddclient: Updated version number to 3.7.3 2007-08-01 wimpunk * [r77] svn/ddclient, svn/patches/typo_dnspark.patch: Applied typo_dnspark.patch send by Marco 2007-07-31 wimpunk * [r76] svn/README.ssl: Renamed dyndns.org to dyndns.com * [r75] svn/README: Removed ^M at line 37 * [r74] svn/ddclient: Removed line 183, comments on Vigor 2200 USB 2007-07-30 wimpunk * [r73] svn: Ignoring ChangeLog since autogenerated * [r72] svn/Changelog: Notification about changed ChangeLog configuration * [r71] svn/patches/ubuntu/dyndns_com.diff: Removed patch since it's invalid * [r70] svn/patches/opendns.patch: Added not applied opendns.patch, see tracker #1758564 * [r69] svn/patches/debianpatches, svn/patches/debianpatches/abuse_msg.diff, svn/patches/debianpatches/cachedir.diff, svn/patches/debianpatches/cisco_fw.diff, svn/patches/debianpatches/config_path.diff, svn/patches/debianpatches/daemon_check.diff, svn/patches/debianpatches/daemon_interval.diff, svn/patches/debianpatches/help_nonroot(2).diff, svn/patches/debianpatches/help_nonroot.diff, svn/patches/debianpatches/ip-up_run-parts.diff, svn/patches/debianpatches/maxinterval.diff, svn/patches/debianpatches/readme.txt, svn/patches/debianpatches/sample_path.diff, svn/patches/debianpatches/smc-barricade-7401bra.patch, svn/patches/debianpatches/smc-barricade-fw-alt.diff, svn/patches/debianpatches/update-new-config.patch, svn/patches/ubuntu, svn/patches/ubuntu/checked_ssl_load.diff, svn/patches/ubuntu/config_path.diff, svn/patches/ubuntu/daemon_interval.diff, svn/patches/ubuntu/dyndns_com.diff, svn/patches/ubuntu/sample_ubuntu.diff, svn/patches/ubuntu/series, svn/patches/ubuntu/smc-barricade-fw-alt.diff: Added debian and ubuntu patches 2007-07-29 wimpunk * [r68] svn/TODO: Added url to feature request dyndns 2007-07-12 wimpunk * [r67] svn/README, svn/patches/readme.patch: Run dos2unix on readme and it's patch which Marco Rodrigues submitted. * [r66] svn/README, svn/patches/readme.patch: Partial applied readme.patch. See tracker #1752931 2007-07-10 wimpunk * [r65] svn/ddclient: signature modified * [r64] svn/ddclient: Added website to ddclient comments * [r63] svn/patches/regex_vlan.patch: Added extra comments to the patch. * [r62] svn/ddclient, svn/patches/create_patch.sh, svn/patches/regex_vlan.patch, svn/patches/typo_namecheap_patch.diff.new: Added patches and applied regex_vlan.patch. See bug #1747337 * [r61] svn/ddclient: Applied typo_namecheap_patch.diff send by Marco Rodrigues 2007-07-07 wimpunk * [r60] svn/sample-etc_ppp_ip-up.local: Reverted the patch from torsten. See [ 1749470 ] Bug in Script sample-etc_ppp_ip-up.local 2007-07-04 wimpunk * [r59] svn/release, svn/release/readme.txt: Adding some release documentation 2007-06-14 wimpunk * [r57] svn/Changelog, svn/ddclient: Changed version number * [r55] svn/patches, svn/patches/3com-oc-remote812.patch, svn/patches/easydns.patch, svn/patches/eurodns.patch: Patches directory added 2007-06-12 wimpunk * [r54] svn/ddclient: 3com-oc-remote812 patch by The_Beast via IRC: see patches/3com-oc-remote812.patch 2007-06-05 wimpunk * [r53] svn/ddclient: Applied easydns.patch, patch 117054 2007-05-28 wimpunk * [r52] svn/ddclient: Changed nic_namecheap_update following the suggestion of edmdude on the forum (https://sourceforge.net/forum/message.php?msg_id=4316938) 2007-05-19 wimpunk * [r48] svn/ddclient: Cosmetic change about checkip * [r47] svn/ddclient: Applied checked_ssl_load.diff from ubuntu * [r46] svn/ddclient: Removed the two empty lines at the end of ddclient 2007-02-26 wimpunk * [r44] svn/TODO: added a TODO list 2007-02-21 wimpunk * [r43] svn/Changelog, svn/ddclient: Preventing unitialized values, check https://sourceforge.net/forum/message.php?msg_id=4167772 2007-01-24 wimpunk * [r40] svn/Changelog, svn/ddclient: Changed max-interval to 25days. See https://www.dyndns.com/services/dns/dyndns/faq.html 2006-12-03 wimpunk * [r39] svn/Changelog, svn/ddclient: Applied maxinterval.diff: Increase max interval for updates. See http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=129370 http://www.dyndns.com/support/services/dyndns/faq.html#q15 * [r38] svn/ddclient: Applied cisco_fw.diff: Use configured hostname for firewall access with -use=cisco (closes: #345712). Thanks to Per Carlson for the patch! See http://bugs.debian.org/345712. 2006-12-02 wimpunk * [r37] svn/Changelog, svn/ddclient: Applied smc-barricade-7401bra.patch: Support for SMC Barricade 7401BRA FW firewall (submitted by Torsten) Changelog modified for all previous patches from Torsten * [r36] svn/ddclient: Applied update-new-config.patch: Force update if config has changed (submitted by Torsten) * [r35] svn/sample-etc_ppp_ip-up.local: Applied ip-up_run-parts.diff: Fix parameter in ip-up script. (submitted by Torsten) * [r34] svn/ddclient: Applied help_nonroot.diff: Allow calling the help function as non-root. (submitted by Torsten) * [r33] svn/ddclient: Applied cachedir.diff: Original ddclient stores a cache file in /etc which would belong in /var/cache in my opinion and according to the FHS. Patch changes that. (submitted by Torsten) * [r32] svn/ddclient: Applied abuse_msg.diff: ddclient still reports the email to contact dyndns.org but they prefer a web form today (IIRC). This patch adjusts the abuse warning printed by ddclient. (submitted by Torsten) * [r31] svn/Changelog: Changed Changelog syntax 2006-11-27 wimpunk * [r30] svn/Changelog, svn/ddclient: Don't send any mail when in not running daemon mode (patch submitted by Daniel Thaler) 2006-11-03 wimpunk * [r28] svn/Changelog, svn/ddclient: Added patch "Patch: Treat --daemon values as intervals" (submitted by James deBoer) 2006-09-30 wimpunk * [r22] svn/Changelog, svn/sample-etc_rc.d_init.d_ddclient.ubuntu: Added initscript for Ubuntu (posted by Paolo Martinelli) 2006-09-14 wimpunk * [r21] svn/Changelog, svn/ddclient: URL of zoneedit has changed (see bug #1558483) 2006-06-14 wimpunk * [r11] svn/Changelog, svn/ddclient: Changed version number * [r8] ., html, svn, xml: Created trunk and tags, moved directories to it * [r6] Changed the order of perl and update of README.ssl 2006-06-11 ddfisher * [r5] see Changelog 2006-06-10 ddfisher * [r4] updated changelog * [r3] See Changelog 2006-05-22 wimpunk * [r2] Reorganise ddclient-3.9.1/Changelog.old000066400000000000000000000254441360532346300157170ustar00rootroot00000000000000Changelog 3.7.3 * Changelog moved to more correct ChangeLog generated by svn2cl --group-by-day -i See http://tinyurl.com/2fzhc6 3.7.2 * Preventing unitialized values, check https://sourceforge.net/forum/message.php?msg_id=4167772 * added a TODO list * Removed the two empty lines at the end of ddclient * Applied checked_ssl_load.diff from Ubuntu * Cosmetic change about checkip * Changed nic_namecheap_update following the suggestion of edmdude on the forum (https://sourceforge.net/forum/message.php?msg_id=4316938) * Applied easydns.patch * 3com-oc-remote812 patch by The_Beast via IRC. * Applied eurodns.patch 3.7.1 * URL of zoneedit has changed (see bug #1558483) * Added initscript for Ubuntu (posted by Paolo Martinelli) * Added patch "Patch: Treat --daemon values as intervals" (submitted by James deBoer) * Don't send any mail when in not running daemon mode (patch submitted by Daniel Thaler) * Changed Changelog syntax * Applied patches submitted by Torsten: abuse_msg.diff: ddclient still reports the email to contact dyndns.org but they prefer a web form today (IIRC). This patch adjusts the abuse warning printed by ddclient. cachedir.diff: Original ddclient stores a cache file in /etc which would belong in /var/cache in my opinion and according to the FHS. help_nonroot.diff: Allow calling the help function as non-root. update-new-config.patch: Force update if config has changed smc-barricade-7401bra.patch: Support for SMC Barricade 7401BRA FW firewall cisco_fw.diff: Use configured hostname for firewall access with -use=cisco (closes: #345712). Thanks to Per Carlson for the patch! See http://bugs.debian.org/345712. maxinterval.diff: Increase max interval for updates. See http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=129370 http://www.dyndns.com/support/services/dyndns/faq.html#q15 * Changed max-interval to 25days. See https://www.dyndns.com/services/dns/dyndns/faq.html 3.7.0 - Added vi tag - Added support for 2Wire 1701HG Gateway (see https://sourceforge.net/forum/message.php?msg_id=3496041 submitted by hemo) - added ssl-support by perlhaq - updated cvs version to 3.7.0-pre - added support for Linksys RV042, see feature requests #1501093, #1500877 - added support for netgear-rp614, see feature request #1237039 - added support for watchguard-edge-x, patch #1468981 - added support for dlink-524, see patch #1314272 - added support for rtp300 - added support for netgear-wpn824 - added support for linksys-wcg200, see patch #1280713 - added support for netgear-dg834g, see patch #1176425 - added support for netgear-wgt624, see patch #1165209 - added support for sveasoft, see patch #1102432 - added support for smc-barricade-7004vbr, see patch #1087989 - added support for sitecom-dc202, see patch #1060119 - fixed the error of stripping out '#' in the middle of password, bug #1465932 - fixed a couple bugs in sample-etc_rc.d_init.d_ddclient and added some extra auto distro detection - added the validation of values when reading the configuration value. - this fixes a bug when trying to use periods/intervals in the daemon check times, bug #1209743 - added timeout option to the IO::Socket call for timing out the initial connection, bug: #1085110 3.6.7 - modified sample-etc_rc.d_init.d_ddclient.lsb (bug #1231930) - support for ConCont Protocol (patch #1265128) submitted by seather_misery - problem with sending mail should be solved - corrected a few writing mistakes - support for 'NetComm NB3' adsl modem (submitted by crazyprog) - Added Sitelutions DynDNS, fixed minor Namecheap bug (patch #1346867) 3.6.6 - support for olitec-SX200 - added sample-etc_rc.d_init.d_ddclient.lsb as a sample script for lsb-compliant systems. - support for linksys wrt854g (thanks to Nick Triantos) - support for linksys ver 3 - support for Thomson (Alcatel) SpeedTouch 510 (thanks to Aldoir) - Cosmetic fixes submitted by John Owens 3.6.5 - there was a bug in the linksys-ver2 - support for postscript (thanks to Larry Hendrickson) - Changelog out of README - modified all documentation to use /etc/ddclient/ddclient.conf (notified by nicolasmartin in bug [1070646]) 3.6.4 - added support for NameCheap service (thanks to Dan Boardman) - added support for linksys ver2 (thanks to Dan Perik) 3.6.3 - renamed sample-etc_dhclient-enter-hooks to sample-etc_dhclient-exit-hooks - add support for the Allnet 1298 Router - add -a to ifconfig to query all interfaces (for Solaris and OpenBSD) - update the process status to reflect what is happening. - add a To: line when sending e-mail - add mail-failure to send mail on failures only - try all addresses for multihomed hosts (like check.dyndns.org) - add support for dnspark - add sample for OrgDNS.org 3.6.2 - add support for Xsense Aero - add support for Alcatel Speedtouch Pro - do authentication when either the login or password are defined. - fix parsing of web status pages - 3.6 - add support for EasyDNS (see easydns.com) - add warning for possible incorrect continuation lines in the .conf file. - add if-skip with the default as was used before. - add cmd-skip. - 3.5.4 - added !active result code for DynDNS.org - 3.5.2 - avoid undefined variable in get_ip - 3.5.1 - fix parsing of quoted strings in .conf file - add filename and line number to any warnings regarding files. - 3.5 - allow any url to be specified for -fw {address|url} use -fw-skip {pattern} to specify a string preceding the IP address at the URL's page - allow any url to be specified for -web {address|url} use -web-skip {pattern} to specify a string preceding the IP address at the URL's page - modify -test to display any IP addresses that could be obtained from any interfaces, builtin fw definitions, or web status pages. - 3.4.6 (not released) - fix errors in -help - allow non-FQDNs as hosts; dslreports requires this. - handle german ifconfig output - try to get english messages from ifconfig so other languages are handled too. - added support for com 3c886a 56k Lan Modem - 3.4.5 - handle french ifconfig output - 3.4.4 - added support for obtaining the IP address from a Cisco DHCP interface. (Thanks, Tim) - 3.4.2 - update last modified time when nochg is returned from dyndns - add example regarding fw-login and fw-password's required by some home routers - 3.4.1 - add option (-pid) to record process id in a file. This option should be defined in the .conf file as it is done in the sample. - add detection of SIGHUP. When this signal is received, ddclient will wake up immediately, reload it's configuration file, and update the IP addresses if necessary. - 3.4 - ALL PEOPLE USING THIS CLIENT ARE URGED TO UPGRADE TO 3.4 or better. - fixed several timer related bugs. - reformatted some messages. - 3.3.8 - added support for the ISDN channels on ELSA LANCOM DSL/10 router - 3.3.7 - suppress repeated identical e-mail messages. - 3.3.6 - added support for the ELSA LANCOM DSL/10 router - ignore 0.0.0.0 when obtained from any FW/router. - 3.3.5 - fixed sample ddclient.conf. fw-ip= should be fw= - fixed problem getting status pages for some routers - 3.3.4 - added support for the MaxGate's UGATE-3x00 routers - 3.3.3 - sample* correct checks for private addresses - add redhat specific sample-etc_rc.d_init.d_ddclient.redhat - make daemon-mode be the default when named ddclientd - added support for the Linksys BEF* Internet Routers - 3.3.2 - (sample-etc_rc.d_init.d_ddclient) set COLUMNS to a large number so that 'ps -aef' will not prematurely truncate the CMD. - 3.3 - added rpm (thanks to Bo Forslund) - added support for the Netgear RT3xx Internet Routers - modified sample-etc_rc.d_init.d_ddclient to work with other Unix beside RedHat. - avoid rewritting the ddclient.cache file unnecessarily - fixed other minor bugs - 3.2.0 - add support for DynDNS's custom domain service. - change suggested directory to /usr/sbin - 3.1.0 - clean up; fix minor bugs. - removed -refresh - add min-interval to avoid too frequent update attempts. - add min-error-interval to avoid too frequent update attempts when the service is unavailable. - 3.0.1 - make all values case sensitive (ie. passwords) - 3.0 - new release! - new ddclient.conf format - rewritten to support DynDNS's NIC2 and other dynamic DNS services - added Hammernode (hn.org) - added ZoneEdit (zoneedit.com) - added DSLreports (dslreports.com) host monitoring - added support for obtaining IP addresses from - interfaces, - commands, - web, - external commands, - Watchguard's SOHO router - Netopia's R910 router - and SMC's Barracade - added daemon mode - added logging msgs to syslog and e-mail - 2.3.7 - add -refresh to the sample scripts so default arguments are obtained from the cache - added local-ip script for obtaining the address of an interface - added public-ip script for obtaining the ip address as seen from a public web page - 2.3.6 - fixed bug the broke enabling retrying when members.dyndns.org was down. - 2.3.5 - prevent warnings from earlier versions of Perl. - 2.3.4 - added sample-etc_dhclient-enter-hooks for those using the ISC DHCP client (dhclient) - 2.3.3 - make sure that ddclient.conf is only readable by the owner so that no one - else can see the password (courtesy of Steve Greenland). -- NOTE: you will need to change the permissions on ddclient.conf to prevent -- others from obtaining viewing your password. -- ie. chmod go-rwx /etc/ddclient.conf - 2.3.2 - make sure 'quiet' messages are printed when -verbose or -debug is enabled - fix error messages for those people using proxies. - 2.3 - fixed a problem reading in cached entries - 2.2.1 - sample-etc_ppp_ip-up.local - local ip address is $4 or $PPP_LOCAL (for debian) - use as the line terminator (some proxies are strict about this) - 2.2 - added support (-static) for updating static DNS (thanks Marc Sira) - changed ddclient.cache format (old style is still read) - sample-etc_ppp_ip-up.local - detect improper calling sequences - sample-etc_ppp_ip-up.local - local ip address is $3 or $PPP_LOCAL (for debian) - 2.1.2 - updated README - 2.1.1 - make sure result code reflects any failures - optionally (-quiet) omit messages for unnecessary updates - update sample-etc_cron.d_ddclient to use -quiet - 2.1 - avoid unnecessary updates by recording the last hosts updated in a cache file (default /etc/ddclient.cache) - optionally (-force) force an update, even if it may be unnecessary. This can be used to prevent dyndns.org from deleting a host that has not required an update for a long period of time. - optionally (-refresh), reissue all host updates. This can be used together with cron to periodically update DynDNS. See sample-etc-cron.d-ddclient for details. - optionally (-retry) save failed updates for future processing. This feature can be used to reissue updates that may have failed due to network connectivity problems or a DynDNS server outage ------------------------------------------------------------------------ ddclient-3.9.1/README.cisco000066400000000000000000000021141360532346300152740ustar00rootroot00000000000000Method 1 ------------------------------------------------------ The following config will allow the Linux machine (10.1.1.2) to read the IP address from the DHCP interface on the Cisco router (eth0) as user ddclient. Since ddclient is configured with a priv level of 1 it cannot do anything except look at the routers stats, ip addresses, etc. This should be pretty harmless even if ddclient's password were to be discovered. This has been tested with Cisco IOS 12.1(5)T5 running on a Cisco 2621 router. Cisco Router Config (Assuming eth0 is DHCP interface) ----------------------------------------------------- user ddclient password password user ddclient priv 1 ip http auth local ip http access-class 99 ip http port 1021 ip http server access-list 99 permit host 10.1.1.2 DDClient Config --------------------------------------------------- use=cisco, fw=10.1.1.1, if=eth0, fw-login=ddclient, fw-password=password Method 2 ------------------------------------------------------ use=fw fw=192.168.1.1/exec/show/interfaces/CR fw-skip=FastEthernet0/0 fw-login=ddclient fw-password=xxxxxxxx ddclient-3.9.1/README.md000066400000000000000000000202721360532346300146010ustar00rootroot00000000000000=============================================================================== # DDCLIENT v3.9.1 ddclient is a Perl client used to update dynamic DNS entries for accounts on many dynamic DNS services. =============================================================================== Dynamic DNS services currently supported include: DynDNS.com - See http://www.dyndns.com for details on obtaining a free account. Hammernode - See http://www.hn.org for details on obtaining a free account. Zoneedit - See http://www.zoneedit.com for details. EasyDNS - See http://www.easydns.com for details. NameCheap - See http://www.namecheap.com for details ConCont - See http://www.dydns.za.net for details DnsPark - See http://www.dnspark.com for details DslReports - See http://www.dslreports.com for details Sitelutions - See http://www.sitelutions.com for details Loopia - See http://www.loopia.se for details Noip - See http://www.noip.com/ for details Freedns - See http://freedns.afraid.org/ for details ChangeIP - See http://www.changeip.com/ for details dtdns - See http://www.dtdns.com/ for details nsupdate - See nsupdate(1) and ddns-confgen(8) for details CloudFlare - See https://www.cloudflare.com/ for details Google - See http://www.google.com/domains for details Duckdns - See https://duckdns.org/ for details Freemyip - See https://freemyip.com for details woima.fi - See https://woima.fi/ for details Yandex - See https://domain.yandex.com/ for details DNS Made Easy - See https://dnsmadeeasy.com/ for details DonDominio - See https://www.dondominio.com for details NearlyFreeSpeech.net - See https://www.nearlyfreespeech.net/services/dns for details DDclient now supports many of cable/dsl broadband routers. Comments, suggestions and requests: use the issues on https://github.com/ddclient/ddclient/issues/new The code was originally written by Paul Burry and is now hosted and maintained through github.com. Please check out http://ddclient.net ------------------------------------------------------------------------------- ## REQUIREMENTS: - one or more accounts from one of the dynamic DNS services - Perl 5.014 or later - `Data::Validate::IP` perl library - `IO::Socket::SSL` perl library for ssl-support - `JSON::PP` perl library for JSON support - `IO::Socket:INET6` perl library for ipv6-support - Linux or probably any common Unix system ------------------------------------------------------------------------------- ## INSTALLATION: cp ddclient /usr/sbin/ mkdir /etc/ddclient mkdir /var/cache/ddclient cp sample-etc_ddclient.conf /etc/ddclient/ddclient.conf vi /etc/ddclient/ddclient.conf -- and change hostnames, logins, and passwords appropriately ## For those using systemd: cp sample-etc_systemd.service /etc/systemd/system/ddclient.service ## enable automatic startup when booting systemctl enable ddclient.service ## start the first time by hand systemctl start ddclient.service ## For those using Redhat style rc files and using daemon-mode: cp sample-etc_rc.d_init.d_ddclient /etc/rc.d/init.d/ddclient ## enable automatic startup when booting ## check your distribution /sbin/chkconfig --add ddclient ## start the first time by hand /etc/rc.d/init.d/ddclient start ## For those using Alpine style rc files and using daemon-mode: cp sample-etc_rc.d_init.d_ddclient.alpine /etc/init.d/ddclient ## enable automatic startup when booting rc-update add ddclient ## make sure you have perl installed apk add perl ## start the first time by hand rc-service ddclient start ## For those using Ubuntu style rc files and using daemon-mode: cp sample-etc_rc.d_init.d_ddclient.ubuntu /etc/init.d/ddclient ## enable automatic startup when booting update-rc.d ddclient defaults ## make sure you have perl and the required modules installed apt-get install perl libdata-validate-ip-perl ## if you plan to use cloudflare or feedns you need the perl json module apt-get install libjson-any-perl ## start the first time by hand service ddclient start ## If you are not using daemon-mode, configure cron and dhcp or ppp ## as described below. ------------------------------------------------------------------------------- ## TROUBLESHOOTING: 1. enable debugging and verbose messages. ``$ ddclient -daemon=0 -debug -verbose -noquiet`` 2. Do you need to specify a proxy? If so, just add a ``proxy=your.isp.proxy`` to the ddclient.conf file. 3. Define the IP address of your router with ``fw=xxx.xxx.xxx.xxx`` in ``/etc/ddclient/ddclient.conf`` and then try ``$ ddclient -daemon=0 -query`` to see if the router status web page can be understood. 4. Need support for another router/firewall? Define the router status page yourself with: ``fw=url-to-your-router``'s-status-page ``fw-skip=any-string-preceding-your-IP-address`` ddclient does something like this to provide builtin support for common routers. For example, the Linksys routers could have been added with: fw=192.168.1.1/Status.htm fw-skip=WAN.*?IP Address OR Send me the output from: $ ddclient -geturl {fw-ip-status-url} [-login login [-password password]] and I'll add it to the next release! ie. for my fw/router I used: $ ddclient -geturl 192.168.1.254/status.htm 5. Some broadband routers require the use of a password when ddclient accesses its status page to determine the router's WAN IP address. If this is the case for your router, add fw-login=your-router-login fw-password=your-router-password to the beginning of your ddclient.conf file. Note that some routers use either 'root' or 'admin' as their login while some others accept anything. ------------------------------------------------------------------------------- ## USING DDCLIENT WITH ppp If you are using a ppp connection, you can easily update your DynDNS entry with each connection, with: ## configure pppd to update DynDNS with each connection cp sample-etc_ppp_ip-up.local /etc/ppp/ip-up.local Alternatively, you may just configure ddclient to operate as a daemon and monitor your ppp interface. ------------------------------------------------------------------------------- ## USING DDCLIENT WITH cron If you have not configured ddclient to use daemon-mode, you'll need to configure cron to force an update once a month so that the dns entry will not become stale. ## configure cron to force an update twice a month cp sample-etc_cron.d_ddclient /etc/cron.d/ddclient vi /etc/cron.d/ddclient ------------------------------------------------------------------------------- ## USING DDCLIENT WITH dhcpcd-1.3.17 If you are using dhcpcd-1.3.17 or thereabouts, you can easily update your DynDNS entry automatically every time your lease is obtained or renewed by creating an executable file named: /etc/dhcpc/dhcpcd-{your-interface}.exe ie.: cp sample-etc_dhcpc_dhcpcd-eth0.exe /etc/dhcpc/dhcpcd-{your-interface}.exe In my case, it is named dhcpcd-eth0.exe and contains the lines: #!/bin/sh PATH=/usr/sbin:/root/bin:${PATH} logger -t dhcpcd IP address changed to $1 ddclient -proxy fasthttp.sympatico.ca -wildcard -ip $1 | logger -t ddclient exit 0 Other DHCP clients may have another method of calling out to programs for updating DNS entries. Alternatively, you may just configure ddclient to operate as a daemon and monitor your ethernet interface. ------------------------------------------------------------------------------- ## USING DDCLIENT WITH dhclient If you are using the ISC DHCP client (dhclient), you can update your DynDNS entry automatically every time your lease is obtained or renewed by creating an executable file named: /etc/dhclient-exit-hooks ie.: cp sample-etc_dhclient-exit-hooks /etc/dhclient-exit-hooks Edit /etc/dhclient-exit-hooks to change any options required. Alternatively, you may just configure ddclient to operate as a daemon and monitor your ethernet interface. ------------------------------------------------------------------------------- ddclient-3.9.1/README.ssl000066400000000000000000000005741360532346300150050ustar00rootroot00000000000000Since 3.7.0, ddclient support ssl-updates To use ssl, put "ssl=yes" in your configuration and make sure you have IO::Socket::SSL. On debian, you need libio-socket-ssl-perl to have IO::Socket::SSL On alpine, you need perl-io-socket-ssl to have IO::Socket::SSL ssl support is tested on folowing dynamic dns providers: - dyndns.com - freemyip.com - DNS Made Easy - dondominio.com ddclient-3.9.1/RELEASENOTE000066400000000000000000000014511360532346300150110ustar00rootroot00000000000000Yet again it's been a while but here is new release of ddclient. As usual, there are some important changes and some documentation is modified. A detailed overview can be found in git log but here's a quick overview: * added support for Yandex.Mail for Domain DNS service * added support for NearlyFreeSpeech.net * added support for DNS Made Easy * added systemd instructions * added support for dondominio.com * updated perl instruction * updated fritzbox instructions * fixed multidomain support for namecheap * fixed support for Yandex A very big thank you for everyone who created a pull request on github and for everyone who helped to fix the little issues caused by the new providers. And a very special thank you for @DaveSophoServices who started to help with the maintenance of ddclient. ddclient-3.9.1/TODO000066400000000000000000000005701360532346300140110ustar00rootroot00000000000000* ssl: - check if the library can be used - ssl on routers - ssl on other providers * notice about irc: there's almost always someone there but we're sometimes idle or at work... * adding router: halted, only in patches section. * add doc postscript * FAQ: bad hostname (checkip) * note about init-scripts. * request from dyndns: http://tinyurl.com/2l3twf * check bugs ddclient-3.9.1/UPGRADE000066400000000000000000000000001360532346300143170ustar00rootroot00000000000000ddclient-3.9.1/ddclient000077500000000000000000005625211360532346300150460ustar00rootroot00000000000000#!/usr/bin/perl -w #!/usr/local/bin/perl -w ###################################################################### # # DDCLIENT - a Perl client for updating DynDNS information # # Author: Paul Burry (paul+ddclient@burry.ca) # ddclient-developers: see https://sourceforge.net/project/memberlist.php?group_id=116817 # # website: http://ddclient.sf.net # # Support for multiple IP numbers added by # Astaro AG, Ingo Schwarze September 16, 2008 # # Support for multiple domain support for Namecheap by Robert Ian Hawdon 2010-09-03: https://robertianhawdon.me.uk/ # # Initial Cloudflare support by Ian Pye, updated by Robert Ian Hawdon 2012-07-16 # Further updates by Peter Roberts to support the new API 2013-09-26, 2014-06-22: http://blog.peter-r.co.uk/ # # ###################################################################### require 5.004; use strict; use Getopt::Long; use Sys::Hostname; use IO::Socket; use Data::Validate::IP; my $version = "3.9.1"; my $programd = $0; $programd =~ s%^.*/%%; my $program = $programd; $program =~ s/d$//; my $now = time; my $hostname = hostname(); my $etc = ($program =~ /test/i) ? './' : '/etc/ddclient/'; my $cachedir = ($program =~ /test/i) ? './' : '/var/cache/ddclient/'; my $savedir = ($program =~ /test/i) ? 'URL/' : '/tmp/'; my $msgs = ''; my $last_msgs = ''; use vars qw($file $lineno); local $file = ''; local $lineno = ''; $ENV{'PATH'} = (exists($ENV{PATH}) ? "$ENV{PATH}:" : "") . "/sbin:/usr/sbin:/bin:/usr/bin:/etc:/usr/lib:"; sub T_ANY {'any'}; sub T_STRING {'string'}; sub T_EMAIL {'e-mail address'}; sub T_NUMBER {'number'}; sub T_DELAY {'time delay (ie. 1d, 1hour, 1m)'}; sub T_LOGIN {'login'}; sub T_PASSWD {'password'}; sub T_BOOL {'boolean value'}; sub T_FQDN {'fully qualified host name'}; sub T_OFQDN {'optional fully qualified host name'}; sub T_FILE {'file name'}; sub T_FQDNP {'fully qualified host name and optional port number'}; sub T_PROTO {'protocol'} sub T_USE {'ip strategy'} sub T_IF {'interface'} sub T_PROG {'program name'} sub T_IP {'ip'} sub T_POSTS {'postscript'}; ## strategies for obtaining an ip address. my %builtinweb = ( 'dyndns' => { 'url' => 'http://checkip.dyndns.org/', 'skip' => 'Current IP Address:', }, 'dnspark' => { 'url' => 'http://ipdetect.dnspark.com/', 'skip' => 'Current Address:', }, 'loopia' => { 'url' => 'http://dns.loopia.se/checkip/checkip.php', 'skip' => 'Current IP Address:', }, ); my %builtinfw = ( 'watchguard-soho' => { 'name' => 'Watchguard SOHO FW', 'url' => '/pubnet.htm', 'skip' => 'NAME=IPAddress VALUE=', }, 'netopia-r910' => { 'name' => 'Netopia R910 FW', 'url' => '/WanEvtLog', 'skip' => 'local:', }, 'smc-barricade' => { 'name' => 'SMC Barricade FW', 'url' => '/status.htm', 'skip' => 'IP Address', }, 'smc-barricade-alt' => { 'name' => 'SMC Barricade FW (alternate config)', 'url' => '/status.HTM', 'skip' => 'WAN IP', }, 'smc-barricade-7401bra' => { 'name' => 'SMC Barricade 7401BRA FW', 'url' => '/admin/wan1.htm', 'skip' => 'IP Address', }, 'netgear-rt3xx' => { 'name' => 'Netgear FW', 'url' => '/mtenSysStatus.html', 'skip' => 'IP Address', }, 'elsa-lancom-dsl10' => { 'name' => 'ELSA LanCom DSL/10 DSL FW', 'url' => '/config/1/6/8/3/', 'skip' => 'IP.Address', }, 'elsa-lancom-dsl10-ch01' => { 'name' => 'ELSA LanCom DSL/10 DSL FW (isdn ch01)', 'url' => '/config/1/6/8/3/', 'skip' => 'IP.Address.*?CH01', }, 'elsa-lancom-dsl10-ch02' => { 'name' => 'ELSA LanCom DSL/10 DSL FW (isdn ch01)', 'url' => '/config/1/6/8/3/', 'skip' => 'IP.Address.*?CH02', }, 'linksys' => { 'name' => 'Linksys FW', 'url' => '/Status.htm', 'skip' => 'WAN.*?Address', }, 'linksys-ver2' => { 'name' => 'Linksys FW version 2', 'url' => '/RouterStatus.htm', 'skip' => 'WAN.*?Address', }, 'linksys-ver3' => { 'name' => 'Linksys FW version 3', 'url' => '/Status_Router.htm', 'skip' => 'WAN.*?Address', }, 'linksys-wrt854g' => { 'name' => 'Linksys WRT854G FW', 'url' => '/Status_Router.asp', 'skip' => 'IP Address:', }, 'maxgate-ugate3x00' => { 'name' => 'MaxGate UGATE-3x00 FW', 'url' => '/Status.htm', 'skip' => 'WAN.*?IP Address', }, 'netcomm-nb3' => { 'name' => 'NetComm NB3', 'url' => '/MainPage?id=6', 'skip' => 'ppp-0', }, '3com-3c886a' => { 'name' => '3com 3c886a 56k Lan Modem', 'url' => '/stat3.htm', 'skip' => 'IP address in use', }, 'sohoware-nbg800' => { 'name' => 'SOHOWare BroadGuard NBG800', 'url' => '/status.htm', 'skip' => 'Internet IP', }, 'xsense-aero' => { 'name' => 'Xsense Aero', 'url' => '/A_SysInfo.htm', 'skip' => 'WAN.*?IP Address', }, 'alcatel-stp' => { 'name' => 'Alcatel Speed Touch Pro', 'url' => '/cgi/router/', 'skip' => 'Brt', }, 'alcatel-510' => { 'name' => 'Alcatel Speed Touch 510', 'url' => '/cgi/ip/', 'skip' => 'ppp', }, 'allnet-1298' => { 'name' => 'Allnet 1298', 'url' => '/cgi/router/', 'skip' => 'WAN', }, '3com-oc-remote812' => { 'name' => '3com OfficeConnect Remote 812', 'url' => '/callEvent', 'skip' => '.*LOCAL', }, 'e-tech' => { 'name' => 'E-tech Router', 'url' => '/Status.htm', 'skip' => 'Public IP Address', }, 'cayman-3220h' => { 'name' => 'Cayman 3220-H DSL', 'url' => '/shell/show+ip+interfaces', 'skip' => '.*inet', }, 'vigor-2200usb' => { 'name' => 'Vigor 2200 USB', 'url' => '/doc/online.sht', 'skip' => 'PPPoA', }, 'dlink-614' => { 'name' => 'D-Link DI-614+', 'url' => '/st_devic.html', 'skip' => 'WAN', }, 'dlink-604' => { 'name' => 'D-Link DI-604', 'url' => '/st_devic.html', 'skip' => 'WAN.*?IP.*Address', }, 'olitec-SX200' => { 'name' => 'olitec-SX200', 'url' => '/doc/wan.htm', 'skip' => 'st_wan_ip[0] = "', }, 'westell-6100' => { 'name' => 'Westell C90-610015-06 DSL Router', 'url' => '/advstat.htm', 'skip' => 'IP.+?Address', }, '2wire' => { 'name' => '2Wire 1701HG Gateway', 'url' => '/xslt?PAGE=B01', 'skip' => 'Internet Address:', }, 'linksys-rv042-wan1' => { 'name' => 'Linksys RV042 Dual Homed Router WAN Port 2', 'url' => '/home.htm', 'skip' => 'WAN1 IP', }, 'linksys-rv042-wan2' => { 'name' => 'Linksys RV042 Dual Homed Router WAN Port 2', 'url' => '/home.htm', 'skip' => 'WAN2 IP', }, 'netgear-rp614' => { 'name' => 'Netgear RP614 FW', 'url' => '/sysstatus.html', 'skip' => 'IP Address', }, 'watchguard-edge-x' => { 'name' => 'Watchguard Edge X FW', 'url' => '/netstat.htm', 'skip' => 'inet addr:', }, 'dlink-524' => { 'name' => 'D-Link DI-524', 'url' => '/st_device.html', 'skip' => 'WAN.*?Addres', }, 'rtp300' => { 'name' => 'Linksys RTP300', 'url' => '/cgi-bin/webcm?getpage=%2Fusr%2Fwww_safe%2Fhtml%2Fstatus%2FRouter.html', 'skip' => 'Internet.*?IP Address', }, 'netgear-wpn824' => { 'name' => 'Netgear WPN824 FW', 'url' => '/RST_status.htm', 'skip' => 'IP Address', }, 'linksys-wcg200' => { 'name' => 'Linksys WCG200 FW', 'url' => '/RgStatus.asp', 'skip' => 'WAN.IP.*?Address', }, 'netgear-dg834g' => { 'name' => 'netgear-dg834g', 'url' => '/setup.cgi?next_file=s_status.htm&todo=cfg_init', 'skip' => '', }, 'netgear-wgt624' => { 'name' => 'Netgear WGT624', 'url' => '/RST_st_dhcp.htm', 'skip' => 'IP Address', }, 'sveasoft' => { 'name' => 'Sveasoft WRT54G/WRT54GS', 'url' => '/Status_Router.asp', 'skip' => 'var wan_ip', }, 'smc-barricade-7004vbr' => { 'name' => 'SMC Barricade FW (7004VBR model config)', 'url' => '/status_main.stm', 'skip' => 'var wan_ip=', }, 'sitecom-dc202' => { 'name' => 'Sitecom DC-202 FW', 'url' => '/status.htm', 'skip' => 'Internet IP Address', }, ); my %ip_strategies = ( 'ip' => ": obtain IP from -ip {address}", 'web' => ": obtain IP from an IP discovery page on the web", 'fw' => ": obtain IP from the firewall specified by -fw {type|address}", 'if' => ": obtain IP from the -if {interface}", 'cmd' => ": obtain IP from the -cmd {external-command}", 'cisco' => ": obtain IP from Cisco FW at the -fw {address}", 'cisco-asa' => ": obtain IP from Cisco ASA at the -fw {address}", map { $_ => sprintf ": obtain IP from %s at the -fw {address}", $builtinfw{$_}->{'name'} } keys %builtinfw, ); sub ip_strategies_usage { return map { sprintf(" -use=%-22s %s.", $_, $ip_strategies{$_}) } sort keys %ip_strategies; } my %web_strategies = ( 'dyndns'=> 1, 'dnspark'=> 1, 'loopia'=> 1, ); sub setv { return { 'type' => shift, 'required' => shift, 'cache' => shift, 'config' => shift, 'default' => shift, 'minimum' => shift, }; }; my %variables = ( 'global-defaults' => { 'daemon' => setv(T_DELAY, 0, 0, 1, 0, interval('60s')), 'foreground' => setv(T_BOOL, 0, 0, 1, 0, undef), 'file' => setv(T_FILE, 0, 0, 1, "$etc$program.conf", undef), 'cache' => setv(T_FILE, 0, 0, 1, "$cachedir$program.cache", undef), 'pid' => setv(T_FILE, 0, 0, 1, "", undef), 'proxy' => setv(T_FQDNP, 0, 0, 1, '', undef), 'protocol' => setv(T_PROTO, 0, 0, 1, 'dyndns2', undef), 'use' => setv(T_USE, 0, 0, 1, 'ip', undef), 'ip' => setv(T_IP, 0, 0, 1, undef, undef), 'if' => setv(T_IF, 0, 0, 1, 'ppp0', undef), 'if-skip' => setv(T_STRING,1, 0, 1, '', undef), 'web' => setv(T_STRING,0, 0, 1, 'dyndns', undef), 'web-skip' => setv(T_STRING,1, 0, 1, '', undef), 'fw' => setv(T_ANY, 0, 0, 1, '', undef), 'fw-skip' => setv(T_STRING,1, 0, 1, '', undef), 'fw-banlocal' => setv(T_BOOL, 0, 0, 1, 0, undef), 'fw-login' => setv(T_LOGIN, 1, 0, 1, '', undef), 'fw-password' => setv(T_PASSWD,1, 0, 1, '', undef), 'cmd' => setv(T_PROG, 0, 0, 1, '', undef), 'cmd-skip' => setv(T_STRING,1, 0, 1, '', undef), 'timeout' => setv(T_DELAY, 0, 0, 1, interval('120s'), interval('120s')), 'retry' => setv(T_BOOL, 0, 0, 0, 0, undef), 'force' => setv(T_BOOL, 0, 0, 0, 0, undef), 'ssl' => setv(T_BOOL, 0, 0, 0, 0, undef), 'ipv6' => setv(T_BOOL, 0, 0, 0, 0, undef), 'syslog' => setv(T_BOOL, 0, 0, 1, 0, undef), 'facility' => setv(T_STRING,0, 0, 1, 'daemon', undef), 'priority' => setv(T_STRING,0, 0, 1, 'notice', undef), 'mail' => setv(T_EMAIL, 0, 0, 1, '', undef), 'mail-failure' => setv(T_EMAIL, 0, 0, 1, '', undef), 'exec' => setv(T_BOOL, 0, 0, 1, 1, undef), 'debug' => setv(T_BOOL, 0, 0, 1, 0, undef), 'verbose' => setv(T_BOOL, 0, 0, 1, 0, undef), 'quiet' => setv(T_BOOL, 0, 0, 1, 0, undef), 'help' => setv(T_BOOL, 0, 0, 1, 0, undef), 'test' => setv(T_BOOL, 0, 0, 1, 0, undef), 'geturl' => setv(T_STRING,0, 0, 0, '', undef), 'postscript' => setv(T_POSTS, 0, 0, 1, '', undef), }, 'service-common-defaults' => { 'server' => setv(T_FQDNP, 1, 0, 1, 'members.dyndns.org', undef), 'login' => setv(T_LOGIN, 1, 0, 1, '', undef), 'password' => setv(T_PASSWD, 1, 0, 1, '', undef), 'host' => setv(T_STRING, 1, 1, 1, '', undef), 'use' => setv(T_USE, 0, 0, 1, 'ip', undef), 'if' => setv(T_IF, 0, 0, 1, 'ppp0', undef), 'if-skip' => setv(T_STRING,0, 0, 1, '', undef), 'web' => setv(T_STRING,0, 0, 1, 'dyndns', undef), 'web-skip' => setv(T_STRING,0, 0, 1, '', undef), 'fw' => setv(T_ANY, 0, 0, 1, '', undef), 'fw-skip' => setv(T_STRING,0, 0, 1, '', undef), 'fw-banlocal' => setv(T_BOOL, 0, 0, 1, 0, undef), 'fw-login' => setv(T_LOGIN, 0, 0, 1, '', undef), 'fw-password' => setv(T_PASSWD,0, 0, 1, '', undef), 'cmd' => setv(T_PROG, 0, 0, 1, '', undef), 'cmd-skip' => setv(T_STRING,0, 0, 1, '', undef), 'ipv6' => setv(T_BOOL, 0, 0, 0, 0, undef), 'ip' => setv(T_IP, 0, 1, 0, undef, undef), 'wtime' => setv(T_DELAY, 0, 1, 1, 0, interval('30s')), 'mtime' => setv(T_NUMBER, 0, 1, 0, 0, undef), 'atime' => setv(T_NUMBER, 0, 1, 0, 0, undef), 'status' => setv(T_ANY, 0, 1, 0, '', undef), 'min-interval' => setv(T_DELAY, 0, 0, 1, interval('30s'), 0), 'max-interval' => setv(T_DELAY, 0, 0, 1, interval('25d'), 0), 'min-error-interval' => setv(T_DELAY, 0, 0, 1, interval('5m'), 0), 'warned-min-interval' => setv(T_ANY, 0, 1, 0, 0, undef), 'warned-min-error-interval' => setv(T_ANY, 0, 1, 0, 0, undef), }, 'dyndns-common-defaults' => { 'static' => setv(T_BOOL, 0, 1, 1, 0, undef), 'wildcard' => setv(T_BOOL, 0, 1, 1, 0, undef), 'mx' => setv(T_OFQDN, 0, 1, 1, '', undef), 'backupmx' => setv(T_BOOL, 0, 1, 1, 0, undef), }, 'easydns-common-defaults' => { 'wildcard' => setv(T_BOOL, 0, 1, 1, 0, undef), 'mx' => setv(T_OFQDN, 0, 1, 1, '', undef), 'backupmx' => setv(T_BOOL, 0, 1, 1, 0, undef), }, 'dnspark-common-defaults' => { 'mx' => setv(T_OFQDN, 0, 1, 1, '', undef), 'mxpri' => setv(T_NUMBER, 0, 0, 1, 5, undef), }, 'noip-common-defaults' => { 'static' => setv(T_BOOL, 0, 1, 1, 0, undef), }, 'noip-service-common-defaults' => { 'server' => setv(T_FQDNP, 1, 0, 1, 'dynupdate.no-ip.com', undef), 'login' => setv(T_LOGIN, 1, 0, 1, '', undef), 'password' => setv(T_PASSWD, 1, 0, 1, '', undef), 'host' => setv(T_STRING, 1, 1, 1, '', undef), 'ip' => setv(T_IP, 0, 1, 0, undef, undef), 'wtime' => setv(T_DELAY, 0, 1, 1, 0, interval('30s')), 'mtime' => setv(T_NUMBER, 0, 1, 0, 0, undef), 'atime' => setv(T_NUMBER, 0, 1, 0, 0, undef), 'status' => setv(T_ANY, 0, 1, 0, '', undef), 'min-interval' => setv(T_DELAY, 0, 0, 1, interval('30s'), 0), 'max-interval' => setv(T_DELAY, 0, 0, 1, interval('25d'), 0), 'min-error-interval' => setv(T_DELAY, 0, 0, 1, interval('5m'), 0), 'warned-min-interval' => setv(T_ANY, 0, 1, 0, 0, undef), 'warned-min-error-interval' => setv(T_ANY, 0, 1, 0, 0, undef), }, 'zoneedit-service-common-defaults' => { 'zone' => setv(T_OFQDN, 0, 0, 1, undef, undef), }, 'dtdns-common-defaults' => { 'login' => setv(T_LOGIN, 0, 0, 0, 'unused', undef), 'client' => setv(T_STRING, 0, 1, 1, $program, undef), }, 'nsupdate-common-defaults' => { 'ttl' => setv(T_NUMBER, 0, 1, 0, 600, undef), 'zone' => setv(T_STRING, 1, 1, 1, '', undef), 'tcp' => setv(T_BOOL, 0, 1, 1, 0, undef), }, 'cloudflare-common-defaults' => { 'server' => setv(T_FQDNP, 1, 0, 1, 'api.cloudflare.com/client/v4', undef), 'zone' => setv(T_FQDN, 1, 0, 1, '', undef), 'static' => setv(T_BOOL, 0, 1, 1, 0, undef), 'wildcard' => setv(T_BOOL, 0, 1, 1, 0, undef), 'mx' => setv(T_OFQDN, 0, 1, 1, '', undef), 'backupmx' => setv(T_BOOL, 0, 1, 1, 0, undef), 'ttl' => setv(T_NUMBER, 1, 0, 1, 1, undef), }, 'googledomains-common-defaults' => { 'server' => setv(T_FQDNP, 1, 0, 1, 'domains.google.com', undef), }, 'duckdns-common-defaults' => { 'server' => setv(T_FQDNP, 1, 0, 1, 'www.duckdns.org', undef), 'login' => setv(T_LOGIN, 0, 0, 0, 'unused', undef), }, 'freemyip-common-defaults' => { 'server' => setv(T_FQDNP, 1, 0, 1, 'freemyip.com', undef), 'login' => setv(T_LOGIN, 0, 0, 0, 'unused', undef), }, 'woima-common-defaults' => { 'static' => setv(T_BOOL, 0, 1, 1, 0, undef), 'wildcard' => setv(T_BOOL, 0, 1, 1, 0, undef), 'mx' => setv(T_OFQDN, 0, 1, 1, '', undef), 'backupmx' => setv(T_BOOL, 0, 1, 1, 0, undef), 'custom' => setv(T_BOOL, 0, 1, 1, 0, undef), 'script' => setv(T_STRING, 1, 1, 1, '/nic/update', undef), }, 'woima-service-common-defaults' => { 'server' => setv(T_FQDNP, 1, 0, 1, 'dyn.woima.fi', undef), 'login' => setv(T_LOGIN, 1, 0, 1, '', undef), 'password' => setv(T_PASSWD, 1, 0, 1, '', undef), 'ip' => setv(T_IP, 0, 1, 0, undef, undef), 'wtime' => setv(T_DELAY, 0, 1, 1, 0, interval('30s')), 'mtime' => setv(T_NUMBER, 0, 1, 0, 0, undef), 'atime' => setv(T_NUMBER, 0, 1, 0, 0, undef), 'status' => setv(T_ANY, 0, 1, 0, '', undef), 'min-interval' => setv(T_DELAY, 0, 0, 1, interval('30s'), 0), 'max-interval' => setv(T_DELAY, 0, 0, 1, interval('25d'), 0), 'min-error-interval' => setv(T_DELAY, 0, 0, 1, interval('5m'), 0), 'warned-min-interval' => setv(T_ANY, 0, 1, 0, 0, undef), 'warned-min-error-interval' => setv(T_ANY, 0, 1, 0, 0, undef), }, 'yandex-common-defaults' => { 'server' => setv(T_FQDNP, 1, 0, 1, 'pddimp.yandex.ru', undef), }, 'dnsmadeeasy-common-defaults' => { 'server' => setv(T_FQDNP, 1, 0, 1, 'cp.dnsmadeeasy.com', undef), 'script' => setv(T_STRING, 1, 1, 1, '/servlet/updateip', undef), }, 'dondominio-common-defaults' => { 'server' => setv(T_FQDNP, 1, 0, 1, 'dondns.dondominio.com', undef), }, ); my %services = ( 'dyndns1' => { 'updateable' => \&nic_dyndns2_updateable, 'update' => \&nic_dyndns1_update, 'examples' => \&nic_dyndns1_examples, 'variables' => merge( $variables{'dyndns-common-defaults'}, $variables{'service-common-defaults'}, ), }, 'dyndns2' => { 'updateable' => \&nic_dyndns2_updateable, 'update' => \&nic_dyndns2_update, 'examples' => \&nic_dyndns2_examples, 'variables' => merge( { 'custom' => setv(T_BOOL, 0, 1, 1, 0, undef), }, { 'script' => setv(T_STRING, 1, 1, 1, '/nic/update', undef), }, # { 'offline' => setv(T_BOOL, 0, 1, 1, 0, undef), }, $variables{'dyndns-common-defaults'}, $variables{'service-common-defaults'}, ), }, 'noip' => { 'updateable' => undef, 'update' => \&nic_noip_update, 'examples' => \&nic_noip_examples, 'variables' => merge( { 'custom' => setv(T_BOOL, 0, 1, 1, 0, undef), }, $variables{'noip-common-defaults'}, $variables{'noip-service-common-defaults'}, ), }, 'concont' => { 'updateable' => undef, 'update' => \&nic_concont_update, 'examples' => \&nic_concont_examples, 'variables' => merge( $variables{'service-common-defaults'}, { 'mx' => setv(T_OFQDN, 0, 1, 1, '', undef), }, { 'wildcard' => setv(T_BOOL, 0, 1, 1, 0, undef), }, ), }, 'dslreports1' => { 'updateable' => undef, 'update' => \&nic_dslreports1_update, 'examples' => \&nic_dslreports1_examples, 'variables' => merge( { 'host' => setv(T_NUMBER, 1, 1, 1, 0, undef) }, $variables{'service-common-defaults'}, ), }, 'hammernode1' => { 'updateable' => undef, 'update' => \&nic_hammernode1_update, 'examples' => \&nic_hammernode1_examples, 'variables' => merge( { 'server' => setv(T_FQDNP, 1, 0, 1, 'dup.hn.org', undef) }, { 'min-interval' => setv(T_DELAY, 0, 0, 1, interval('5m'), 0),}, $variables{'service-common-defaults'}, ), }, 'zoneedit1' => { 'updateable' => undef, 'update' => \&nic_zoneedit1_update, 'examples' => \&nic_zoneedit1_examples, 'variables' => merge( { 'server' => setv(T_FQDNP, 1, 0, 1, 'dynamic.zoneedit.com', undef) }, { 'min-interval' => setv(T_DELAY, 0, 0, 1, interval('5m'), 0),}, $variables{'service-common-defaults'}, $variables{'zoneedit-service-common-defaults'}, ), }, 'easydns' => { 'updateable' => undef, 'update' => \&nic_easydns_update, 'examples' => \&nic_easydns_examples, 'variables' => merge( { 'server' => setv(T_FQDNP, 1, 0, 1, 'members.easydns.com', undef) }, { 'min-interval' => setv(T_DELAY, 0, 0, 1, interval('5m'), 0),}, $variables{'easydns-common-defaults'}, $variables{'service-common-defaults'}, ), }, 'dnspark' => { 'updateable' => undef, 'update' => \&nic_dnspark_update, 'examples' => \&nic_dnspark_examples, 'variables' => merge( { 'server' => setv(T_FQDNP, 1, 0, 1, 'www.dnspark.com', undef) }, { 'min-interval' => setv(T_DELAY, 0, 0, 1, interval('5m'), 0),}, $variables{'dnspark-common-defaults'}, $variables{'service-common-defaults'}, ), }, 'namecheap' => { 'updateable' => undef, 'update' => \&nic_namecheap_update, 'examples' => \&nic_namecheap_examples, 'variables' => merge( { 'server' => setv(T_FQDNP, 1, 0, 1, 'dynamicdns.park-your-domain.com', undef) }, { 'min-interval' => setv(T_DELAY, 0, 0, 1, 0, interval('5m')),}, $variables{'service-common-defaults'}, ), }, 'nfsn' => { 'updateable' => undef, 'update' => \&nic_nfsn_update, 'examples' => \&nic_nfsn_examples, 'variables' => merge( { 'server' => setv(T_FQDNP, 1, 0, 1, 'api.nearlyfreespeech.net', undef) }, { 'min_interval' => setv(T_FQDNP, 0, 0, 1, 0, interval('5m')) }, { 'ttl' => setv(T_NUMBER, 1, 0, 1, 300, undef) }, { 'zone' => setv(T_FQDN, 1, 0, 1, undef, undef) }, $variables{'service-common-defaults'}, ), }, 'sitelutions' => { 'updateable' => undef, 'update' => \&nic_sitelutions_update, 'examples' => \&nic_sitelutions_examples, 'variables' => merge( { 'server' => setv(T_FQDNP, 1, 0, 1, 'www.sitelutions.com', undef) }, { 'min-interval' => setv(T_DELAY, 0, 0, 1, 0, interval('5m')),}, $variables{'service-common-defaults'}, ), }, 'freedns' => { 'updateable' => undef, 'update' => \&nic_freedns_update, 'examples' => \&nic_freedns_examples, 'variables' => merge( { 'server' => setv(T_FQDNP, 1, 0, 1, 'freedns.afraid.org', undef) }, { 'min-interval' => setv(T_DELAY, 0, 0, 1, 0, interval('5m')),}, $variables{'service-common-defaults'}, ), }, 'changeip' => { 'updateable' => undef, 'update' => \&nic_changeip_update, 'examples' => \&nic_changeip_examples, 'variables' => merge( { 'server' => setv(T_FQDNP, 1, 0, 1, 'nic.changeip.com', undef) }, { 'min-interval' => setv(T_DELAY, 0, 0, 1, 0, interval('5m')),}, $variables{'service-common-defaults'}, ), }, 'dtdns' => { 'updateable' => undef, 'update' => \&nic_dtdns_update, 'examples' => \&nic_dtdns_examples, 'variables' => merge( $variables{'dtdns-common-defaults'}, $variables{'service-common-defaults'}, ), }, 'nsupdate' => { 'updateable' => undef, 'update' => \&nic_nsupdate_update, 'examples' => \&nic_nsupdate_examples, 'variables' => merge( { 'login' => setv(T_LOGIN, 1, 0, 1, '/usr/bin/nsupdate', undef), }, $variables{'nsupdate-common-defaults'}, $variables{'service-common-defaults'}, ), }, 'cloudflare' => { 'updateable' => undef, 'update' => \&nic_cloudflare_update, 'examples' => \&nic_cloudflare_examples, 'variables' => merge( { 'server' => setv(T_FQDNP, 1, 0, 1, 'api.cloudflare.com/client/v4', undef) }, { 'min-interval' => setv(T_DELAY, 0, 0, 1, interval('5m'), 0),}, $variables{'cloudflare-common-defaults'}, $variables{'service-common-defaults'}, ), }, 'googledomains' => { 'updateable' => undef, 'update' => \&nic_googledomains_update, 'examples' => \&nic_googledomains_examples, 'variables' => merge( { 'min-interval' => setv(T_DELAY, 0, 0, 1, interval('5m'), 0),}, $variables{'googledomains-common-defaults'}, $variables{'service-common-defaults'}, ), }, 'duckdns' => { 'updateable' => undef, 'update' => \&nic_duckdns_update, 'examples' => \&nic_duckdns_examples, 'variables' => merge( $variables{'duckdns-common-defaults'}, $variables{'service-common-defaults'}, ), }, 'freemyip' => { 'updateable' => undef, 'update' => \&nic_freemyip_update, 'examples' => \&nic_freemyip_examples, 'variables' => merge( $variables{'freemyip-common-defaults'}, $variables{'service-common-defaults'}, ), }, 'woima' => { 'updateable' => undef, 'update' => \&nic_woima_update, 'examples' => \&nic_woima_examples, 'variables' => merge( $variables{'woima-common-defaults'}, $variables{'woima-service-common-defaults'}, ), }, 'yandex' => { 'updateable' => undef, 'update' => \&nic_yandex_update, 'examples' => \&nic_yandex_examples, 'variables' => merge( { 'min-interval' => setv(T_DELAY, 0, 0, 1, interval('5m'), 0),}, $variables{'yandex-common-defaults'}, $variables{'service-common-defaults'}, ), }, 'dnsmadeeasy' => { 'updateable' => undef, 'update' => \&nic_dnsmadeeasy_update, 'examples' => \&nic_dnsmadeeasy_examples, 'variables' => merge( $variables{'dnsmadeeasy-common-defaults'}, $variables{'service-common-defaults'}, ), }, 'dondominio' => { 'updateable' => undef, 'update' => \&nic_dondominio_update, 'examples' => \&nic_dondominio_examples, 'variables' => merge( $variables{'dondominio-common-defaults'}, $variables{'service-common-defaults'}, ), }, ); $variables{'merged'} = merge($variables{'global-defaults'}, $variables{'service-common-defaults'}, $variables{'dyndns-common-defaults'}, map { $services{$_}{'variables'} } keys %services, ); my @opt = ( "usage: ${program} [options]", "options are:", [ "daemon", "=s", "-daemon delay : run as a daemon, specify delay as an interval." ], [ "foreground", "!", "-foreground : do not fork" ], [ "proxy", "=s", "-proxy host : use 'host' as the HTTP proxy" ], [ "server", "=s", "-server host : update DNS information on 'host'" ], [ "protocol", "=s", "-protocol type : update protocol used" ], [ "file", "=s", "-file path : load configuration information from 'path'" ], [ "cache", "=s", "-cache path : record address used in 'path'" ], [ "pid", "=s", "-pid path : record process id in 'path'" ], "", [ "use", "=s", "-use which : how the should IP address be obtained." ], &ip_strategies_usage(), "", [ "ip", "=s", "-ip address : set the IP address to 'address'" ], "", [ "if", "=s", "-if interface : obtain IP address from 'interface'" ], [ "if-skip", "=s", "-if-skip pattern : skip any IP addresses before 'pattern' in the output of ifconfig {if}" ], "", [ "web", "=s", "-web provider|url : obtain IP address from provider's IP checking page" ], [ "web-skip", "=s", "-web-skip pattern : skip any IP addresses before 'pattern' on the web provider|url" ], "", [ "fw", "=s", "-fw address|url : obtain IP address from firewall at 'address'" ], [ "fw-skip", "=s", "-fw-skip pattern : skip any IP addresses before 'pattern' on the firewall address|url" ], [ "fw-banlocal", "!", "-fw-banlocal : ignore local IP addresses on the firewall address|url" ], [ "fw-login", "=s", "-fw-login login : use 'login' when getting IP from fw" ], [ "fw-password", "=s", "-fw-password secret : use password 'secret' when getting IP from fw" ], "", [ "cmd", "=s", "-cmd program : obtain IP address from by calling {program}" ], [ "cmd-skip", "=s", "-cmd-skip pattern : skip any IP addresses before 'pattern' in the output of {cmd}" ], "", [ "login", "=s", "-login user : login as 'user'" ], [ "password", "=s", "-password secret : use password 'secret'" ], [ "host", "=s", "-host host : update DNS information for 'host'" ], "", [ "options", "=s", "-options opt,opt : optional per-service arguments (see below)" ], "", [ "ssl", "!", "-{no}ssl : do updates over encrypted SSL connection" ], [ "retry", "!", "-{no}retry : retry failed updates." ], [ "force", "!", "-{no}force : force an update even if the update may be unnecessary" ], [ "timeout", "=i", "-timeout max : wait at most 'max' seconds for the host to respond" ], [ "syslog", "!", "-{no}syslog : log messages to syslog" ], [ "facility", "=s", "-facility {type} : log messages to syslog to facility {type}" ], [ "priority", "=s", "-priority {pri} : log messages to syslog with priority {pri}" ], [ "mail", "=s", "-mail address : e-mail messages to {address}" ], [ "mail-failure","=s", "-mail-failure address : e-mail messages for failed updates to {address}" ], [ "exec", "!", "-{no}exec : do {not} execute; just show what would be done" ], [ "debug", "!", "-{no}debug : print {no} debugging information" ], [ "verbose", "!", "-{no}verbose : print {no} verbose information" ], [ "quiet", "!", "-{no}quiet : print {no} messages for unnecessary updates" ], [ "ipv6", "!", "-{no}ipv6 : use ipv6" ], [ "help", "", "-help : this message" ], [ "postscript", "", "-postscript : script to run after updating ddclient, has new IP as param" ], [ "query", "!", "-{no}query : print {no} ip addresses and exit" ], [ "test", "!", "" ], ## hidden [ "geturl", "=s", "" ], ## hidden "", nic_examples(), "$program version $version, ", " originally written by Paul Burry, paul+ddclient\@burry.ca", " project now maintained on http://ddclient.sourceforge.net" ); ## process args my ($opt_usage, %opt) = process_args(@opt); my ($result, %config, %globals, %cache); my $saved_cache = ''; my %saved_opt = %opt; $result = 'OK'; test_geturl(opt('geturl')) if opt('geturl'); ## process help option if (opt('help')) { *STDERR = *STDOUT; usage(0); } ## read config file because 'daemon' mode may be defined there. read_config(define($opt{'file'}, default('file')), \%config, \%globals); init_config(); test_possible_ip() if opt('query'); if (!opt('daemon') && $programd =~ /d$/) { $opt{'daemon'} = minimum('daemon'); } my $caught_hup = 0; my $caught_term = 0; my $caught_kill = 0; $SIG{'HUP'} = sub { $caught_hup = 1; }; $SIG{'TERM'} = sub { $caught_term = 1; }; $SIG{'KILL'} = sub { $caught_kill = 1; }; # don't fork() if foreground or force is on if (opt('foreground') || opt('force')) { ; } elsif (opt('daemon')) { $SIG{'CHLD'} = 'IGNORE'; my $pid = fork; if ($pid < 0) { print STDERR "${program}: can not fork ($!)\n"; exit -1; } elsif ($pid) { exit 0; } $SIG{'CHLD'} = 'DEFAULT'; open(STDOUT, ">/dev/null"); open(STDERR, ">/dev/null"); open(STDIN, " 0) && !$caught_hup && !$caught_term && !$caught_kill) { my $delay = $left > 10 ? 10 : $left; $0 = sprintf("%s - sleeping for %s seconds", $program, $left); $left -= sleep $delay; # preventing deep sleep - see [bugs:#46] if ($left > $daemon) { $left = $daemon; } } $caught_hup = 0; $result = 0; } elsif (! scalar(%config)) { warning("no hosts to update.") unless !opt('quiet') || opt('verbose') || !$daemon; $result = 1; } else { $result = $result eq 'OK' ? 0 : 1; } } while ($daemon && !$result && !$caught_term && !$caught_kill); warning("caught SIGKILL; exiting") if $caught_kill; unlink_pid(); sendmail(); exit($result); ###################################################################### ## runpostscript ###################################################################### sub runpostscript { my ($ip) = @_; if ( defined $globals{postscript} ) { if ( -x $globals{postscript}) { system ("$globals{postscript} $ip &"); } else { warning ("Can not execute post script: %s", $globals{postscript}); } } } ###################################################################### ## update_nics ###################################################################### sub update_nics { my %examined = (); my %iplist = (); foreach my $s (sort keys %services) { my (@hosts, %ips) = (); my $updateable = $services{$s}{'updateable'}; my $update = $services{$s}{'update'}; foreach my $h (sort keys %config) { next if $config{$h}{'protocol'} ne lc($s); $examined{$h} = 1; # we only do this once per 'use' and argument combination my $use = opt('use', $h); my $arg_ip = opt('ip', $h) || ''; my $arg_fw = opt('fw', $h) || ''; my $arg_if = opt('if', $h) || ''; my $arg_web = opt('web', $h) || ''; my $arg_cmd = opt('cmd', $h) || ''; my $ip = ""; if (exists $iplist{$use}{$arg_ip}{$arg_fw}{$arg_if}{$arg_web}{$arg_cmd}) { $ip = $iplist{$use}{$arg_ip}{$arg_fw}{$arg_if}{$arg_web}{$arg_cmd}; } else { $ip = get_ip($use, $h); if (!defined $ip || !$ip) { warning("unable to determine IP address") if !$daemon || opt('verbose'); next; } if ($ip !~ /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/) { if( !ipv6_match($ip) ) { warning("malformed IP address (%s)", $ip); next; } } $iplist{$use}{$arg_ip}{$arg_fw}{$arg_if}{$arg_web}{$arg_cmd} = $ip; } $config{$h}{'wantip'} = $ip; next if !nic_updateable($h, $updateable); push @hosts, $h; $ips{$ip} = $h; } if (@hosts) { $0 = sprintf("%s - updating %s", $program, join(',', @hosts)); &$update(@hosts); runpostscript(join ' ', keys %ips); } } foreach my $h (sort keys %config) { if (!exists $examined{$h}) { failed("%s was not updated because protocol %s is not supported.", $h, define($config{$h}{'protocol'}, '') ); } } write_cache(opt('cache')); } ###################################################################### ## unlink_pid() ###################################################################### sub unlink_pid { if (opt('pid') && opt('daemon')) { unlink opt('pid'); } } ###################################################################### ## write_pid() ###################################################################### sub write_pid { my $file = opt('pid'); if ($file && opt('daemon')) { local *FD; if (! open(FD, "> $file")) { warning("Cannot create file '%s'. ($!)", $file); } else { printf FD "$$\n"; close(FD); } } } ###################################################################### ## write_cache($file) ###################################################################### sub write_cache { my ($file) = @_; ## merge the updated host entries into the cache. foreach my $h (keys %config) { if (! exists $cache{$h} || $config{$h}{'update'}) { map {$cache{$h}{$_} = $config{$h}{$_} } @{$config{$h}{'cacheable'}}; } else { map {$cache{$h}{$_} = $config{$h}{$_} } qw(atime wtime status); } } ## construct the cache file. my $cache = ""; foreach my $h (sort keys %cache) { my $opt = join(',', map { "$_=".define($cache{$h}{$_},'') } sort keys %{$cache{$h}}); $cache .= sprintf "%s%s%s\n", $opt, ($opt ? ' ' : ''), $h; } $file = '' if defined($saved_cache) && $cache eq $saved_cache; ## write the updates and other entries to the cache file. if ($file) { $saved_cache = undef; local *FD; if (! open(FD, "> $file")) { fatal("Cannot create file '%s'. ($!)", $file); } printf FD "## $program-$version\n"; printf FD "## last updated at %s (%d)\n", prettytime($now), $now; printf FD $cache; close(FD); } } ###################################################################### ## read_cache($file) - called before reading the .conf ###################################################################### sub read_cache { my $file = shift; my $config = shift; my $globals = {}; %{$config} = (); ## read the cache file ignoring anything on the command-line. if (-e $file) { my %saved = %opt; %opt = (); $saved_cache = _read_config($config, $globals, "##\\s*$program-$version\\s*", $file); %opt = %saved; foreach my $h (keys %cache) { if (exists $config->{$h}) { foreach (qw(atime mtime wtime ip status)) { $config->{$h}{$_} = $cache{$h}{$_} if exists $cache{$h}{$_}; } } } } } ###################################################################### ## parse_assignments(string) return (rest, %variables) ## parse_assignment(string) return (name, value, rest) ###################################################################### sub parse_assignments { my $rest = shift; my @args = @_; my %variables = (); my ($name, $value); while (1) { $rest =~ s/^\s+//; ($name, $value, $rest) = parse_assignment($rest, @args); if (defined $name) { $variables{$name} = $value; } else { last; } } return ($rest, %variables); } sub parse_assignment { my $rest = shift; my $stop = @_ ? shift : '[\n\s,]'; my ($c, $name, $value); my ($escape, $quote) = (0, ''); if ($rest =~ /^\s*([a-z][0-9a-z_-]*)=(.*)/i) { ($name, $rest, $value) = ($1, $2, ''); while (length($c = substr($rest,0,1))) { $rest = substr($rest,1); if ($escape) { $value .= $c; $escape = 0; } elsif ($c eq "\\") { $escape = 1; } elsif ($quote && $c eq $quote) { $quote = '' } elsif (!$quote && $c =~ /[\'\"]/) { $quote = $c; } elsif (!$quote && $c =~ /^${stop}/) { last; } else { $value .= $c; } } } warning("assignment ended with an open quote") if $quote; return ($name, $value, $rest); } ###################################################################### ## read_config ###################################################################### sub read_config { my $file = shift; my $config = shift; my $globals = shift; my %globals = (); _read_config($config, $globals, '', $file, %globals); } sub _read_config { my $config = shift; my $globals = shift; my $stamp = shift; local $file = shift; my %globals = @_; my %config = (); my $content = ''; local *FD; if (! open(FD, "< $file")) { # fatal("Cannot open file '%s'. ($!)", $file); warning("Cannot open file '%s'. ($!)", $file); } # Check for only owner has any access to config file my ($dev, $ino, $mode, @statrest) = stat(FD); if ($mode & 077) { if (-f FD && (chmod 0600, $file)) { warning("file $file must be accessible only by its owner (fixed)."); } else { # fatal("file $file must be accessible only by its owner."); warning("file $file must be accessible only by its owner."); } } local $lineno = 0; my $continuation = ''; my %passwords = (); while () { s/[\r\n]//g; $lineno++; ## check for the program version stamp if (($. == 1) && $stamp && ($_ !~ /^$stamp$/i)) { warning("program version mismatch; ignoring %s", $file); last; } if (/\\\s+$/) { warning("whitespace follows the \\ at the end-of-line.\nIf you meant to have a line continuation, remove the trailing whitespace."); } $content .= "$_\n" unless /^#/; ## parsing passwords is special if (/^([^#]*\s)?([^#]*?password\S*?)\s*=\s*('.*'|[^']\S*)(.*)/) { my ($head, $key, $value, $tail) = ($1 || '', $2, $3, $4); $value = $1 if $value =~ /^'(.*)'$/; $passwords{$key} = $value; $_ = "${head}${key}=dummy${tail}"; } ## remove comments s/#.*//; ## handle continuation lines $_ = "$continuation$_"; if (/\\$/) { chop; $continuation = $_; next; } $continuation = ''; s/^\s+//; # remove leading white space s/\s+$//; # remove trailing white space s/\s+/ /g; # canonify next if /^$/; ## expected configuration line is: ## [opt=value,opt=..] [host [login [password]]] my %locals; ($_, %locals) = parse_assignments($_); s/\s*,\s*/,/g; my @args = split; ## verify that keywords are valid...and check the value foreach my $k (keys %locals) { $locals{$k} = $passwords{$k} if defined $passwords{$k}; if (!exists $variables{'merged'}{$k}) { warning("unrecognized keyword '%s' (ignored)", $k); delete $locals{$k}; } else { my $def = $variables{'merged'}{$k}; my $value = check_value($locals{$k}, $def); if (!defined($value)) { warning("Invalid Value for keyword '%s' = '%s'", $k, $locals{$k}); delete $locals{$k}; } else { $locals{$k} = $value; } } } if (exists($locals{'host'})) { $args[0] = @args ? "$args[0],$locals{host}" : "$locals{host}"; } ## accumulate globals if ($#args < 0) { map { $globals{$_} = $locals{$_} } keys %locals; } ## process this host definition if (@args) { my ($host, $login, $password) = @args; ## add in any globals.. %locals = %{ merge(\%locals, \%globals) }; ## override login and password if specified the old way. $locals{'login'} = $login if defined $login; $locals{'password'} = $password if defined $password; ## allow {host} to be a comma separated list of hosts foreach my $h (split_by_comma($host)) { ## save a copy of the current globals $config{$h} = { %locals }; $config{$h}{'host'} = $h; } } %passwords = (); } close(FD); warning("file ends while expecting a continuation line.") if $continuation; %$globals = %globals; %$config = %config; return $content; } ###################################################################### ## init_config - ###################################################################### sub init_config { %opt = %saved_opt; ## $opt{'quiet'} = 0 if opt('verbose'); ## infer the IP strategy if possible $opt{'use'} = 'ip' if !define($opt{'use'}) && defined($opt{'ip'}); $opt{'use'} = 'if' if !define($opt{'use'}) && defined($opt{'if'}); $opt{'use'} = 'web' if !define($opt{'use'}) && defined($opt{'web'}); ## sanity check $opt{'max-interval'} = min(interval(opt('max-interval')), interval(default('max-interval'))); $opt{'min-interval'} = max(interval(opt('min-interval')), interval(default('min-interval'))); $opt{'min-error-interval'} = max(interval(opt('min-error-interval')), interval(default('min-error-interval'))); $opt{'timeout'} = 0 if opt('timeout') < 0; ## only set $opt{'daemon'} if it has been explicitly passed in if (define($opt{'daemon'},$globals{'daemon'},0)) { $opt{'daemon'} = interval(opt('daemon')); $opt{'daemon'} = minimum('daemon') if ($opt{'daemon'} < minimum('daemon')); } ## define or modify host options specified on the command-line if (exists $opt{'options'} && defined $opt{'options'}) { ## collect cmdline configuration options. my %options = (); foreach my $opt (split_by_comma($opt{'options'})) { my ($name,$var) = split /\s*=\s*/, $opt; $options{$name} = $var; } ## determine hosts specified with -host my @hosts = (); if (exists $opt{'host'}) { foreach my $h (split_by_comma($opt{'host'})) { push @hosts, $h; } } ## and those in -options=... if (exists $options{'host'}) { foreach my $h (split_by_comma($options{'host'})) { push @hosts, $h; } delete $options{'host'}; } ## merge options into host definitions or globals if (@hosts) { foreach my $h (@hosts) { $config{$h} = merge(\%options, $config{$h}); } $opt{'host'} = join(',', @hosts); } else { %globals = %{ merge(\%options, \%globals) }; } } ## override global options with those on the command-line. foreach my $o (keys %opt) { if (defined $opt{$o} && exists $variables{'global-defaults'}{$o}) { $globals{$o} = $opt{$o}; } } ## sanity check if (defined $opt{'host'} && defined $opt{'retry'}) { usage("options -retry and -host (or -option host=..) are mutually exclusive"); } ## determine hosts to update (those on the cmd-line, config-file, or failed cached) my @hosts = keys %config; if (opt('host')) { @hosts = split_by_comma($opt{'host'}); } if (opt('retry')) { @hosts = map { $_ if $cache{$_}{'status'} ne 'good' } keys %cache; } ## remove any other hosts my %hosts; map { $hosts{$_} = undef } @hosts; map { delete $config{$_} unless exists $hosts{$_} } keys %config; ## collect the cacheable variables. foreach my $proto (keys %services) { my @cacheable = (); foreach my $k (keys %{$services{$proto}{'variables'}}) { push @cacheable, $k if $services{$proto}{'variables'}{$k}{'cache'}; } $services{$proto}{'cacheable'} = [ @cacheable ]; } ## sanity check.. ## make sure config entries have all defaults and they meet minimums ## first the globals... foreach my $k (keys %globals) { my $def = $variables{'merged'}{$k}; my $ovalue = define($globals{$k}, $def->{'default'}); my $value = check_value($ovalue, $def); if ($def->{'required'} && !defined $value) { $value = default($k); warning("'%s=%s' is an invalid %s. (using default of %s)", $k, $ovalue, $def->{'type'}, $value); } $globals{$k} = $value; } ## now the host definitions... HOST: foreach my $h (keys %config) { my $proto; $proto = $config{$h}{'protocol'}; $proto = opt('protocol') if !defined($proto); load_sha1_support($proto) if (grep (/^$proto$/, ("freedns", "nfsn"))); load_json_support($proto) if (grep (/^$proto$/, ("cloudflare","yandex","nfsn"))); if (!exists($services{$proto})) { warning("skipping host: %s: unrecognized protocol '%s'", $h, $proto); delete $config{$h}; } else { my $svars = $services{$proto}{'variables'}; my $conf = { 'protocol' => $proto }; foreach my $k (keys %$svars) { my $def = $svars->{$k}; my $ovalue = define($config{$h}{$k}, $def->{'default'}); my $value = check_value($ovalue, $def); if ($def->{'required'} && !defined $value) { warning("skipping host: %s: '%s=%s' is an invalid %s.", $h, $k, $ovalue, $def->{'type'}); delete $config{$h}; next HOST; } $conf->{$k} = $value; } $config{$h} = $conf; $config{$h}{'cacheable'} = [ @{$services{$proto}{'cacheable'}} ]; } } } ###################################################################### ## usage ###################################################################### sub usage { my $exitcode = 1; $exitcode = shift if @_ != 0; # use first arg if given my $msg = ''; if (@_) { my $format = shift; $msg .= sprintf $format, @_; 1 while chomp($msg); $msg .= "\n"; } printf STDERR "%s%s\n", $msg, $opt_usage; sendmail(); exit $exitcode; } ###################################################################### ## process_args - ###################################################################### sub process_args { my @spec = (); my $usage = ""; my %opts = (); foreach (@_) { if (ref $_) { my ($key, $specifier, $arg_usage) = @$_; my $value = default($key); ## add a option specifier push @spec, $key . $specifier; ## define the default value which can be overwritten later $opt{$key} = undef; next unless $arg_usage; ## add a line to the usage; $usage .= " $arg_usage"; if (defined($value) && $value ne '') { $usage .= " (default: "; if ($specifier eq '!') { $usage .= "no" if ($specifier eq '!') && !$value; $usage .= $key; } else { $usage .= $value; } $usage .= ")"; } $usage .= "."; } else { $usage .= $_; } $usage .= "\n"; } ## process the arguments if (! GetOptions(\%opt, @spec)) { $opt{"help"} = 1; } return ($usage, %opt); } ###################################################################### ## test_possible_ip - print possible IPs ###################################################################### sub test_possible_ip { local $opt{'debug'} = 0; printf "use=ip, ip=%s address is %s\n", opt('ip'), define(get_ip('ip'), 'NOT FOUND') if defined opt('ip'); { local $opt{'use'} = 'if'; foreach my $if (grep {/^[a-zA-Z]/} `ifconfig -a`) { $if =~ s/:?\s.*//is; local $opt{'if'} = $if; printf "use=if, if=%s address is %s\n", opt('if'), define(get_ip('if'), 'NOT FOUND'); } } if (opt('fw')) { if (opt('fw') !~ m%/%) { foreach my $fw (sort keys %builtinfw) { local $opt{'use'} = $fw; printf "use=$fw address is %s\n", define(get_ip($fw), 'NOT FOUND'); } } local $opt{'use'} = 'fw'; printf "use=fw, fw=%s address is %s\n", opt('fw'), define(get_ip(opt('fw')), 'NOT FOUND') if ! exists $builtinfw{opt('fw')}; } { local $opt{'use'} = 'web'; foreach my $web (sort keys %builtinweb) { local $opt{'web'} = $web; printf "use=web, web=$web address is %s\n", define(get_ip('web'), 'NOT FOUND'); } printf "use=web, web=%s address is %s\n", opt('web'), define(get_ip('web'), 'NOT FOUND') if ! exists $builtinweb{opt('web')}; } if (opt('cmd')) { local $opt{'use'} = 'cmd'; printf "use=cmd, cmd=%s address is %s\n", opt('cmd'), define(get_ip('cmd'), 'NOT FOUND'); } exit 0 unless opt('debug'); } ###################################################################### ## test_geturl - print (and save if -test) result of fetching a URL ###################################################################### sub test_geturl { my $url = shift; my $reply = geturl(opt('proxy'), $url, opt('login'), opt('password')); print "URL $url\n";; print defined($reply) ? $reply : "\n"; exit; } ###################################################################### ## load_file ###################################################################### sub load_file { my $file = shift; my $buffer = ''; if (exists($ENV{'TEST_CASE'})) { my $try = "$file-$ENV{'TEST_CASE'}"; $file = $try if -f $try; } local *FD; if (open(FD, "< $file")) { read(FD, $buffer, -s FD); close(FD); debug("Loaded %d bytes from %s", length($buffer), $file); } else { debug("Load failed from %s ($!)", $file); } return $buffer } ###################################################################### ## save_file ###################################################################### sub save_file { my ($file, $buffer, $opt) = @_; $file .= "-$ENV{'TEST_CASE'}" if exists $ENV{'TEST_CASE'}; if (defined $opt) { my $i = 0; while (-f "$file-$i") { if ('unique' =~ /^$opt/i) { my $a = join('\n', grep {!/^Date:/} split /\n/, $buffer); my $b = join('\n', grep {!/^Date:/} split /\n/, load_file("$file-$i")); last if $a eq $b; } $i++; } $file = "$file-$i"; } debug("Saving to %s", $file); local *FD; open(FD, "> $file") or return; print FD $buffer; close(FD); return $buffer; } ###################################################################### ## print_opt ## print_globals ## print_config ## print_cache ## print_info ###################################################################### sub _print_hash { my ($string, $ptr) = @_; my $value = $ptr; if (! defined($ptr)) { $value = ""; } elsif (ref $ptr eq 'HASH') { foreach my $key (sort keys %$ptr) { _print_hash("${string}\{$key\}", $ptr->{$key}); } return; } printf "%-36s : %s\n", $string, $value; } sub print_hash { my ($string, $hash) = @_; printf "=== %s ====\n", $string; _print_hash($string, $hash); } sub print_opt { print_hash("opt", \%opt); } sub print_globals { print_hash("globals", \%globals); } sub print_config { print_hash("config", \%config); } sub print_cache { print_hash("cache", \%cache); } sub print_info { print_opt(); print_globals(); print_config(); print_cache(); } ###################################################################### ## pipecmd - run an external command ## logger ## sendmail ###################################################################### sub pipecmd { my $cmd = shift; my $stdin = join("\n", @_); my $ok = 0; ## remove trailing newlines 1 while chomp($stdin); ## override when debugging. $cmd = opt('exec') ? "| $cmd" : "> /dev/null"; ## execute the command. local *FD; if (! open(FD, $cmd)) { printf STDERR "$program: cannot execute command %s.\n", $cmd; } elsif ($stdin && (! print FD "$stdin\n")) { printf STDERR "$program: failed writting to %s.\n", $cmd; close(FD); } elsif (! close(FD)) { printf STDERR "$program: failed closing %s.($@)\n", $cmd; } elsif (opt('exec') && $?) { printf STDERR "$program: failed %s. ($@)\n", $cmd; } else { $ok = 1; } return $ok; } sub logger { if (opt('syslog') && opt('facility') && opt('priority')) { my $facility = opt('facility'); my $priority = opt('priority'); return pipecmd("logger -p$facility.$priority -t${program}\[$$\]", @_); } return 1; } sub sendmail { my $recipients = opt('mail'); if (opt('mail-failure') && ($result ne 'OK' && $result ne '0')) { $recipients = opt('mail-failure'); } if ($msgs && $recipients && $msgs ne $last_msgs) { pipecmd("sendmail -oi $recipients", "To: $recipients", "Subject: status report from $program\@$hostname", "\r\n", $msgs, "", "regards,", " $program\@$hostname (version $version)" ); } $last_msgs = $msgs; $msgs = ''; } ###################################################################### ## split_by_comma ## merge ## default ## minimum ## opt ###################################################################### sub split_by_comma { my $string = shift; return split /\s*[, ]\s*/, $string if defined $string; return (); } sub merge { my %merged = (); foreach my $h (@_) { foreach my $k (keys %$h) { $merged{$k} = $h->{$k} unless exists $merged{$k}; } } return \%merged; } sub default { my $v = shift; return $variables{'merged'}{$v}{'default'}; } sub minimum { my $v = shift; return $variables{'merged'}{$v}{'minimum'}; } sub opt { my $v = shift; my $h = shift; return $config{$h}{$v} if defined($h && $config{$h}{$v}); return $opt{$v} if defined $opt{$v}; return $globals{$v} if defined $globals{$v}; return default($v) if defined default($v); return undef; } sub min { my $min = shift; foreach my $arg (@_) { $min = $arg if $arg < $min; } return $min; } sub max { my $max = shift; foreach my $arg (@_) { $max = $arg if $arg > $max; } return $max; } ###################################################################### ## define ###################################################################### sub define { foreach (@_) { return $_ if defined $_; } return undef; } ###################################################################### ## ynu ###################################################################### sub ynu { my ($value, $yes, $no, $undef) = @_; return $no if !defined($value) || !$value; return $yes if $value eq '1'; foreach (qw(yes true)) { return $yes if $_ =~ /^$value/i; } foreach (qw(no false)) { return $no if $_ =~ /^$value/i; } return $undef; } ###################################################################### ## msg ## debug ## warning ## fatal ###################################################################### sub _msg { my $log = shift; my $prefix = shift; my $format = shift; my $buffer = sprintf $format, @_; chomp($buffer); $prefix = sprintf "%-9s ", $prefix if $prefix; if ($file) { $prefix .= "file $file"; $prefix .= ", line $lineno" if $lineno; $prefix .= ": "; } if ($prefix) { $buffer = "$prefix$buffer"; $buffer =~ s/\n/\n$prefix /g; } $buffer .= "\n"; print $buffer; $msgs .= $buffer if $log; logger($buffer) if $log; } sub msg { _msg(0, '', @_); } sub verbose { _msg(1, @_) if opt('verbose'); } sub info { _msg(1, 'INFO:', @_) if opt('verbose'); } sub debug { _msg(0, 'DEBUG:', @_) if opt('debug'); } sub debug2 { _msg(0, 'DEBUG:', @_) if opt('debug') && opt('verbose');} sub warning { _msg(1, 'WARNING:', @_); } sub fatal { _msg(1, 'FATAL:', @_); sendmail(); exit(1); } sub success { _msg(1, 'SUCCESS:', @_); } sub failed { _msg(1, 'FAILED:', @_); $result = 'FAILED'; } sub prettytime { return scalar(localtime(shift)); } sub prettyinterval { my $interval = shift; use integer; my $s = $interval % 60; $interval /= 60; my $m = $interval % 60; $interval /= 60; my $h = $interval % 24; $interval /= 24; my $d = $interval; my $string = ""; $string .= "$d day" if $d; $string .= "s" if $d > 1; $string .= ", " if $string && $h; $string .= "$h hour" if $h; $string .= "s" if $h > 1; $string .= ", " if $string && $m; $string .= "$m minute" if $m; $string .= "s" if $m > 1; $string .= ", " if $string && $s; $string .= "$s second" if $s; $string .= "s" if $s > 1; return $string; } sub interval { my $value = shift; if ($value =~ /^(\d+)(seconds|s)/i) { $value = $1; } elsif ($value =~ /^(\d+)(minutes|m)/i) { $value = $1 * 60; } elsif ($value =~ /^(\d+)(hours|h)/i) { $value = $1 * 60*60; } elsif ($value =~ /^(\d+)(days|d)/i) { $value = $1 * 60*60*24; } elsif ($value !~ /^\d+$/) { $value = undef; } return $value; } 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}); } ###################################################################### ## check_value ###################################################################### sub check_value { my ($value, $def) = @_; my $type = $def->{'type'}; my $min = $def->{'minimum'}; my $required = $def->{'required'}; if (!defined $value && !$required) { ; } elsif ($type eq T_DELAY) { $value = interval($value); $value = $min if defined($value) && defined($min) && $value < $min; } elsif ($type eq T_NUMBER) { return undef if $value !~ /^\d+$/; $value = $min if defined($min) && $value < $min; } elsif ($type eq T_BOOL) { if ($value =~ /^y(es)?$|^t(true)?$|^1$/i) { $value = 1; } elsif ($value =~ /^n(o)?$|^f(alse)?$|^0$/i) { $value = 0; } else { return undef; } } elsif ($type eq T_FQDN || $type eq T_OFQDN && $value ne '') { $value = lc $value; return undef if $value !~ /[^.]\.[^.]/; } elsif ($type eq T_FQDNP) { $value = lc $value; return undef if $value !~ /[^.]\.[^.].*(:\d+)?$/; } elsif ($type eq T_PROTO) { $value = lc $value; return undef if ! exists $services{$value}; } elsif ($type eq T_USE) { $value = lc $value; return undef if ! exists $ip_strategies{$value}; } elsif ($type eq T_FILE) { return undef if $value eq ""; } elsif ($type eq T_IF) { return undef if $value !~ /^[a-zA-Z0-9:._-]+$/; } elsif ($type eq T_PROG) { return undef if $value eq ""; } elsif ($type eq T_LOGIN) { return undef if $value eq ""; # } elsif ($type eq T_PASSWD) { # return undef if $value =~ /:/; } elsif ($type eq T_IP) { if( !ipv6_match($value) ) { return undef if $value !~ /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/; } } return $value; } ###################################################################### ## encode_base64 - from MIME::Base64 ###################################################################### sub encode_base64 ($;$) { my $res = ''; my $eol = $_[1]; $eol = "\n" unless defined $eol; pos($_[0]) = 0; # ensure start at the beginning while ($_[0] =~ /(.{1,45})/gs) { $res .= substr(pack('u', $1), 1); chop($res); } $res =~ tr|` -_|AA-Za-z0-9+/|; # `# help emacs # fix padding at the end my $padding = (3 - length($_[0]) % 3) % 3; $res =~ s/.{$padding}$/'=' x $padding/e if $padding; $res; } ###################################################################### ## load_ssl_support ###################################################################### sub load_ssl_support { my $ssl_loaded = eval {require IO::Socket::SSL}; unless ($ssl_loaded) { fatal(<<"EOM"); Error loading the Perl module IO::Socket::SSL needed for SSL connect. On Debian, the package libio-socket-ssl-perl must be installed. On Red Hat, the package perl-IO-Socket-SSL must be installed. On Alpine, the package perl-io-socket-ssl must be installed. EOM } import IO::Socket::SSL; { no warnings; $IO::Socket::SSL::DEBUG = 0; } } ###################################################################### ## load_ipv6_support ###################################################################### sub load_ipv6_support { my $ipv6_loaded = eval {require IO::Socket::INET6}; unless ($ipv6_loaded) { fatal(<<"EOM"); Error loading the Perl module IO::Socket::INET6 needed for ipv6 connect. On Debian, the package libio-socket-inet6-perl must be installed. On Red Hat, the package perl-IO-Socket-INET6 must be installed. On Alpine, the package perl-io-socket-inet6 must be installed. EOM } import IO::Socket::INET6; { no warnings; $IO::Socket::INET6::DEBUG = 0; } } ###################################################################### ## load_sha1_support ###################################################################### sub load_sha1_support { my $why = shift; my $sha1_loaded = eval {require Digest::SHA1}; my $sha_loaded = eval {require Digest::SHA}; unless ($sha1_loaded || $sha_loaded) { fatal(<<"EOM"); Error loading the Perl module Digest::SHA1 or Digest::SHA needed for $why update. On Debian, the package libdigest-sha1-perl or libdigest-sha-perl must be installed. EOM } if($sha1_loaded) { import Digest::SHA1 (qw/sha1_hex/); } elsif($sha_loaded) { import Digest::SHA (qw/sha1_hex/); } } ###################################################################### ## load_json_support ###################################################################### sub load_json_support { my $why = shift; my $json_loaded = eval {require JSON::PP}; unless ($json_loaded) { fatal(<<"EOM"); Error loading the Perl module JSON::PP needed for $why update. EOM } import JSON::PP (qw/decode_json/); } ###################################################################### ## geturl ###################################################################### sub geturl { my $proxy = shift || ''; my $url = shift || ''; my $login = shift || ''; my $password = shift || ''; my $headers = shift || ''; my $method = shift || 'GET'; my $data = shift || ''; my ($peer, $server, $port, $default_port, $use_ssl); my ($sd, $rq, $request, $reply); debug("proxy = $proxy"); debug("url = %s", $url); ## canonify proxy and url my $force_ssl; $force_ssl = 1 if ($url =~ /^https:/); $proxy =~ s%^https?://%%i; $url =~ s%^https?://%%i; $server = $url; $server =~ s%/.*%%; $url = "/" unless $url =~ m%/%; $url =~ s%^[^/]*/%%; debug("server = $server"); opt('fw') && debug("opt(fw = ",opt('fw'),")"); $globals{'fw'} && debug("glo fw = $globals{'fw'}"); #if ( $globals{'ssl'} and $server ne $globals{'fw'} ) { ## always omit SSL for connections to local router if ( $force_ssl || ($globals{'ssl'} and (caller(1))[3] ne 'main::get_ip') ) { $use_ssl = 1; $default_port = 443; load_ssl_support; } else { $use_ssl = 0; $default_port = 80; } ## determine peer and port to use. $peer = $proxy || $server; $peer =~ s%/.*%%; $port = $peer; $port =~ s%^.*:%%; $port = $default_port unless $port =~ /^\d+$/; $peer =~ s%:.*$%%; my $to = sprintf "%s%s", $server, $proxy ? " via proxy $peer:$port" : ""; verbose("CONNECT:", "%s", $to); $request = "$method "; if (!$use_ssl) { $request .= "http://$server" if $proxy; } else { $request .= "https://$server" if $proxy; } $request .= "/$url HTTP/1.0\n"; $request .= "Host: $server\n"; my $auth = encode_base64("${login}:${password}", ""); $request .= "Authorization: Basic $auth\n" if $login || $password; $request .= "User-Agent: ${program}/${version}\n"; if ($data) { $request .= "Content-Type: application/x-www-form-urlencoded\n" if ! $headers =~ /^Content-Type: /; $request .= "Content-Length: " . length($data) . "\n"; } $request .= "Connection: close\n"; $request .= "$headers\n"; $request .= "\n"; $request .= $data; ## make sure newlines are for some pedantic proxy servers ($rq = $request) =~ s/\n/\r\n/g; # local $^W = 0; $0 = sprintf("%s - connecting to %s port %s", $program, $peer, $port); if (! opt('exec')) { debug("skipped network connection"); verbose("SENDING:", "%s", $request); } elsif ($use_ssl) { $sd = IO::Socket::SSL->new( PeerAddr => $peer, PeerPort => $port, Proto => 'tcp', MultiHomed => 1, Timeout => opt('timeout'), ); defined $sd or warning("cannot connect to $peer:$port socket: $@ " . IO::Socket::SSL::errstr()); } elsif ($globals{'ipv6'}) { load_ipv6_support; $sd = IO::Socket::INET6->new( PeerAddr => $peer, PeerPort => $port, Proto => 'tcp', MultiHomed => 1, Timeout => opt('timeout'), ); defined $sd or warning("cannot connect to $peer:$port socket: $@"); } else { $sd = IO::Socket::INET->new( PeerAddr => $peer, PeerPort => $port, Proto => 'tcp', MultiHomed => 1, Timeout => opt('timeout'), ); defined $sd or warning("cannot connect to $peer:$port socket: $@"); } if (defined $sd) { ## send the request to the http server verbose("CONNECTED: ", $use_ssl ? 'using SSL' : 'using HTTP'); verbose("SENDING:", "%s", $request); $0 = sprintf("%s - sending to %s port %s", $program, $peer, $port); my $result = syswrite $sd, $rq; if ($result != length($rq)) { warning("cannot send to $peer:$port ($!)."); } else { $0 = sprintf("%s - reading from %s port %s", $program, $peer, $port); eval { local $SIG{'ALRM'} = sub { die "timeout";}; alarm(opt('timeout')) if opt('timeout') > 0; while ($_ = <$sd>) { $0 = sprintf("%s - read from %s port %s", $program, $peer, $port); verbose("RECEIVE:", "%s", define($_, "")); $reply .= $_ if defined $_; } if (opt('timeout') > 0) { alarm(0); } }; close($sd); if ($@ and $@ =~ /timeout/) { warning("TIMEOUT: %s after %s seconds", $to, opt('timeout')); $reply = ''; } $reply = '' if !defined $reply; } } $0 = sprintf("%s - closed %s port %s", $program, $peer, $port); ## during testing simulate reading the URL if (opt('test')) { my $filename = "$server/$url"; $filename =~ s|/|%2F|g; if (opt('exec')) { $reply = save_file("${savedir}$filename", $reply, 'unique'); } else { $reply = load_file("${savedir}$filename"); } } $reply =~ s/\r//g if defined $reply; return $reply; } ###################################################################### ## un_zero_pad ###################################################################### sub un_zero_pad { my $in_str = shift(@_); my @out_str = (); if ($in_str eq '0.0.0.0') { return $in_str; } foreach my $block (split /\./, $in_str) { $block =~ s/^0+//; if ($block eq '') { $block = '0'; } push @out_str, $block; } return join('.', @out_str); } ###################################################################### ## filter_local ###################################################################### sub filter_local { my $in_ip = shift(@_); if ($in_ip eq '0.0.0.0') { return $in_ip; } my @guess_local = ( '^10\.', '^172\.(?:1[6-9]|2[0-9]|3[01])\.', '^192\.168' ); foreach my $block (@guess_local) { if ($in_ip =~ /$block/) { return '0.0.0.0'; } } return $in_ip; } ###################################################################### ## get_ip ###################################################################### sub get_ip { my $use = lc shift; my $h = shift; my ($ip, $arg, $reply, $url, $skip) = (undef, opt($use, $h), ''); $arg = '' unless $arg; if ($use eq 'ip') { $ip = opt('ip', $h); $arg = 'ip'; } elsif ($use eq 'if') { $skip = opt('if-skip', $h) || ''; $reply = `ifconfig $arg 2> /dev/null`; $reply = `ip addr list dev $arg 2> /dev/null` if $?; $reply = '' if $?; } elsif ($use eq 'cmd') { if ($arg) { $skip = opt('cmd-skip', $h) || ''; $reply = `$arg`; $reply = '' if $?; } } elsif ($use eq 'web') { $url = opt('web', $h) || ''; $skip = opt('web-skip', $h) || ''; if (exists $builtinweb{$url}) { $skip = $builtinweb{$url}->{'skip'} unless $skip; $url = $builtinweb{$url}->{'url'}; } $arg = $url; if ($url) { $reply = geturl(opt('proxy', $h), $url) || ''; } } elsif (($use eq 'cisco')) { # Stuff added to support Cisco router ip http daemon # User fw-login should only have level 1 access to prevent # password theft. This is pretty harmless. my $queryif = opt('if', $h); $skip = opt('fw-skip', $h) || ''; # Convert slashes to protected value "\/" $queryif =~ s%\/%\\\/%g; # Protect special HTML characters (like '?') $queryif =~ s/([\?&= ])/sprintf("%%%02x",ord($1))/ge; $url = "http://".opt('fw', $h)."/level/1/exec/show/ip/interface/brief/${queryif}/CR"; $reply = geturl('', $url, opt('fw-login', $h), opt('fw-password', $h)) || ''; $arg = $url; } elsif (($use eq 'cisco-asa')) { # Stuff added to support Cisco ASA ip https daemon # User fw-login should only have level 1 access to prevent # password theft. This is pretty harmless. my $queryif = opt('if', $h); $skip = opt('fw-skip', $h) || ''; # Convert slashes to protected value "\/" $queryif =~ s%\/%\\\/%g; # Protect special HTML characters (like '?') $queryif =~ s/([\?&= ])/sprintf("%%%02x",ord($1))/ge; $url = "https://".opt('fw', $h)."/exec/show%20interface%20${queryif}"; $reply = geturl('', $url, opt('fw-login', $h), opt('fw-password', $h)) || ''; $arg = $url; } else { $url = opt('fw', $h) || ''; $skip = opt('fw-skip', $h) || ''; if (exists $builtinfw{$use}) { $skip = $builtinfw{$use}->{'skip'} unless $skip; $url = "http://${url}" . $builtinfw{$use}->{'url'} unless $url =~ /\//; } $arg = $url; if ($url) { $reply = geturl('', $url, opt('fw-login', $h), opt('fw-password', $h)) || ''; } } if (!defined $reply) { $reply = ''; } if ($skip) { $skip =~ s/ /\\s/is; $reply =~ s/^.*?${skip}//is; } if ($reply =~ /^.*?\b(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\b.*/is) { $ip = $1; $ip = un_zero_pad($ip); $ip = filter_local($ip) if opt('fw-banlocal', $h); } elsif ( $ip = ipv6_match($reply) ) { $ip = un_zero_pad($ip); $ip = filter_local($ip) if opt('fw-banlocal', $h); } else { warning("found neither ipv4 nor ipv6 address"); } if (($use ne 'ip') && (define($ip,'') eq '0.0.0.0')) { $ip = undef; } debug("get_ip: using %s, %s reports %s", $use, $arg, define($ip, "")); return $ip; } ###################################################################### ## ipv6_match determine ipv6 address from given string and return them ###################################################################### sub ipv6_match { my $content = shift; my $omits; my $ip = ""; my $linenumbers = 0; my @values = split('\n', $content); foreach my $val (@values) { next unless $val =~ /((:{0,2}[A-F0-9]{1,4}){0,7}:{1,2}[A-F0-9]{1,4})/ai; # invalid char my $parsed = $1; # check for at least 7 colons my $count_colon = () = $parsed =~ /:/g; if ($count_colon != 7) { # or one double colon my $count_double_colon = () = $parsed =~ /::/g; if ($count_double_colon != 1) { next } } return $parsed; } return; } ###################################################################### ## group_hosts_by ###################################################################### sub group_hosts_by { my ($hosts, $attributes) = @_; my %groups = (); foreach my $h (@$hosts) { my @keys = (@$attributes, 'wantip'); map { $config{$h}{$_} = '' unless exists $config{$h}{$_} } @keys; my $sig = join(',', map { "$_=$config{$h}{$_}" } @keys); push @{$groups{$sig}}, $h; } return %groups; } ###################################################################### ## encode_www_form_urlencoded ###################################################################### sub encode_www_form_urlencoded { my $formdata = shift; my $must_encode = qr'[<>"#%{}|\\^~\[\]`;/?:=&+]'; my $encoded; my $i = 0; foreach my $k (keys %$formdata) { my $kenc = $k; my $venc = $formdata->{$k}; $kenc =~ s/($must_encode)/sprintf('%%%02X', ord($1))/ge; $venc =~ s/($must_encode)/sprintf('%%%02X', ord($1))/ge; $kenc =~ s/ /+/g; $venc =~ s/ /+/g; $encoded .= $kenc.'='.$venc; if ($i < (keys %$formdata) - 1) { $encoded .= '&'; } $i++; } return $encoded; } ###################################################################### ## nic_examples ###################################################################### sub nic_examples { my $examples = ""; my $separator = ""; foreach my $s (sort keys %services) { my $subr = $services{$s}{'examples'}; my $example; if (defined($subr) && ($example = &$subr())) { chomp($example); $examples .= $example; $examples .= "\n\n$separator"; $separator = "\n"; } } my $intro = < $now) { warning("cannot update %s from %s to %s until after %s.", $host, ($cache{$host}{'ip'} ? $cache{$host}{'ip'} : ''), $ip, prettytime($cache{$host}{'wtime'}) ); } elsif ($cache{$host}{'mtime'} && interval_expired($host, 'mtime', 'max-interval')) { warning("forcing update of %s from %s to %s; %s since last update on %s.", $host, ($cache{$host}{'ip'} ? $cache{$host}{'ip'} : ''), $ip, prettyinterval($config{$host}{'max-interval'}), prettytime($cache{$host}{'mtime'}) ); $update = 1; } elsif ((!exists($cache{$host}{'ip'})) || ("$cache{$host}{'ip'}" ne "$ip")) { if (($cache{$host}{'status'} eq 'good') && !interval_expired($host, 'mtime', 'min-interval')) { warning("skipping update of %s from %s to %s.\nlast updated %s.\nWait at least %s between update attempts.", $host, ($cache{$host}{'ip'} ? $cache{$host}{'ip'} : ''), $ip, ($cache{$host}{'mtime'} ? prettytime($cache{$host}{'mtime'}) : ''), prettyinterval($config{$host}{'min-interval'}) ) if opt('verbose') || !define($cache{$host}{'warned-min-interval'}, 0); $cache{$host}{'warned-min-interval'} = $now; } elsif (($cache{$host}{'status'} ne 'good') && !interval_expired($host, 'atime', 'min-error-interval')) { warning("skipping update of %s from %s to %s.\nlast updated %s but last attempt on %s failed.\nWait at least %s between update attempts.", $host, ($cache{$host}{'ip'} ? $cache{$host}{'ip'} : ''), $ip, ($cache{$host}{'mtime'} ? prettytime($cache{$host}{'mtime'}) : ''), ($cache{$host}{'atime'} ? prettytime($cache{$host}{'atime'}) : ''), prettyinterval($config{$host}{'min-error-interval'}) ) if opt('verbose') || !define($cache{$host}{'warned-min-error-interval'}, 0); $cache{$host}{'warned-min-error-interval'} = $now; } else { $update = 1; } } elsif (defined($sub) && &$sub($host)) { $update = 1; } elsif ((defined($cache{$host}{'static'}) && defined($config{$host}{'static'}) && ($cache{$host}{'static'} ne $config{$host}{'static'})) || (defined($cache{$host}{'wildcard'}) && defined($config{$host}{'wildcard'}) && ($cache{$host}{'wildcard'} ne $config{$host}{'wildcard'})) || (defined($cache{$host}{'mx'}) && defined($config{$host}{'mx'}) && ($cache{$host}{'mx'} ne $config{$host}{'mx'})) || (defined($cache{$host}{'backupmx'}) && defined($config{$host}{'backupmx'}) && ($cache{$host}{'backupmx'} ne $config{$host}{'backupmx'})) ) { info("updating %s because host settings have been changed.", $host); $update = 1; } else { success("%s: skipped: IP address was already set to %s.", $host, $ip) if opt('verbose'); } $config{$host}{'status'} = define($cache{$host}{'status'},''); $config{$host}{'update'} = $update; if ($update) { $config{$host}{'status'} = 'noconnect'; $config{$host}{'atime'} = $now; $config{$host}{'wtime'} = 0; $config{$host}{'warned-min-interval'} = 0; $config{$host}{'warned-min-error-interval'} = 0; delete $cache{$host}{'warned-min-interval'}; delete $cache{$host}{'warned-min-error-interval'}; } return $update; } ###################################################################### ## header_ok ###################################################################### sub header_ok { my ($host, $line) = @_; my $ok = 0; if ($line =~ m%^s*HTTP/1.*\s+(\d+)%i) { my $result = $1; if ($result eq '200') { $ok = 1; } elsif ($result eq '401') { failed("updating %s: authorization failed (%s)", $host, $line); } } else { failed("updating %s: unexpected line (%s)", $host, $line); } return $ok; } ###################################################################### ## nic_dyndns1_examples ###################################################################### sub nic_dyndns1_examples { return <\s*(.*)\s*%i; $return_code = $1 if $line =~ m%^return\s+code\s*:\s*(.*)\s*$%i; $error_code = $1 if $line =~ m%^error\s+code\s*:\s*(.*)\s*$%i; } if ($return_code ne 'NOERROR' || $error_code ne 'NOERROR' || !$title) { $config{$h}{'status'} = 'failed'; $title = "incomplete response from $config{$h}{server}" unless $title; warning("SENT: %s", $url) unless opt('verbose'); warning("REPLIED: %s", $reply); failed("updating %s: %s", $h, $title); } else { $config{$h}{'ip'} = $ip; $config{$h}{'mtime'} = $now; $config{$h}{'status'} = 'good'; success("updating %s: %s: IP address set to %s (%s)", $h, $return_code, $ip, $title); } } } ###################################################################### ## nic_dyndns2_updateable ###################################################################### sub nic_dyndns2_updateable { my $host = shift; my $update = 0; if ($config{$host}{'mx'} ne $cache{$host}{'mx'}) { info("forcing updating %s because 'mx' has changed to %s.", $host, $config{$host}{'mx'}); $update = 1; } elsif ($config{$host}{'mx'} && (ynu($config{$host}{'backupmx'},1,2,3) ne ynu($config{$host}{'backupmx'},1,2,3))) { info("forcing updating %s because 'backupmx' has changed to %s.", $host, ynu($config{$host}{'backupmx'},"YES","NO","NO")); $update = 1; } elsif ($config{$host}{'static'} ne $cache{$host}{'static'}) { info("forcing updating %s because 'static' has changed to %s.", $host, ynu($config{$host}{'static'},"YES","NO","NO")); $update = 1; } return $update; } ###################################################################### ## nic_dyndns2_examples ###################################################################### sub nic_dyndns2_examples { return < 'Bad authorization (username or password)', 'badsys' => 'The system parameter given was not valid', 'notfqdn' => 'A Fully-Qualified Domain Name was not provided', 'nohost' => 'The hostname specified does not exist in the database', '!yours' => 'The hostname specified exists, but not under the username currently being used', '!donator' => 'The offline setting was set, when the user is not a donator', '!active' => 'The hostname specified is in a Custom DNS domain which has not yet been activated.', 'abuse', => 'The hostname specified is blocked for abuse; you should receive an email notification ' . 'which provides an unblock request link. More info can be found on ' . 'https://www.dyndns.com/support/abuse.html', 'numhost' => 'System error: Too many or too few hosts found. Contact support@dyndns.org', 'dnserr' => 'System error: DNS error encountered. Contact support@dyndns.org', 'nochg' => 'No update required; unnecessary attempts to change to the current address are considered abusive', ); ## update each set of hosts that had similar configurations foreach my $sig (keys %groups) { my @hosts = @{$groups{$sig}}; my $hosts = join(',', @hosts); my $h = $hosts[0]; my $ip = $config{$h}{'wantip'}; delete $config{$_}{'wantip'} foreach @hosts; info("setting IP address to %s for %s", $ip, $hosts); verbose("UPDATE:","updating %s", $hosts); ## Select the DynDNS system to update my $url = "http://$config{$h}{'server'}$config{$h}{'script'}?system="; if ($config{$h}{'custom'}) { warning("updating %s: 'custom' and 'static' may not be used together. ('static' ignored)", $hosts) if $config{$h}{'static'}; # warning("updating %s: 'custom' and 'offline' may not be used together. ('offline' ignored)", $hosts) # if $config{$h}{'offline'}; $url .= 'custom'; } elsif ($config{$h}{'static'}) { # warning("updating %s: 'static' and 'offline' may not be used together. ('offline' ignored)", $hosts) # if $config{$h}{'offline'}; $url .= 'statdns'; } else { $url .= 'dyndns'; } $url .= "&hostname=$hosts"; $url .= "&myip="; $url .= $ip if $ip; ## some args are not valid for a custom domain. $url .= "&wildcard=ON" if ynu($config{$h}{'wildcard'}, 1, 0, 0); if ($config{$h}{'mx'}) { $url .= "&mx=$config{$h}{'mx'}"; $url .= "&backmx=" . ynu($config{$h}{'backupmx'}, 'YES', 'NO'); } my $reply = geturl(opt('proxy'), $url, $config{$h}{'login'}, $config{$h}{'password'}); if (!defined($reply) || !$reply) { failed("updating %s: Could not connect to %s.", $hosts, $config{$h}{'server'}); last; } last if !header_ok($hosts, $reply); my @reply = split /\n/, $reply; my $state = 'header'; my $returnedip = $ip; foreach my $line (@reply) { if ($state eq 'header') { $state = 'body'; } elsif ($state eq 'body') { $state = 'results' if $line eq ''; } elsif ($state =~ /^results/) { $state = 'results2'; # bug #10: some dyndns providers does not return the IP so # we can't use the returned IP my ($status, $returnedip) = split / /, lc $line; $ip = $returnedip if (not $ip); my $h = shift @hosts; $config{$h}{'status'} = $status; if ($status eq 'good') { $config{$h}{'ip'} = $ip; $config{$h}{'mtime'} = $now; success("updating %s: %s: IP address set to %s", $h, $status, $ip); } elsif (exists $errors{$status}) { if ($status eq 'nochg') { warning("updating %s: %s: %s", $h, $status, $errors{$status}); $config{$h}{'ip'} = $ip; $config{$h}{'mtime'} = $now; $config{$h}{'status'} = 'good'; } else { failed("updating %s: %s: %s", $h, $status, $errors{$status}); } } elsif ($status =~ /w(\d+)(.)/) { my ($wait, $units) = ($1, lc $2); my ($sec, $scale) = ($wait, 1); ($scale, $units) = (1, 'seconds') if $units eq 's'; ($scale, $units) = (60, 'minutes') if $units eq 'm'; ($scale, $units) = (60*60, 'hours') if $units eq 'h'; $sec = $wait * $scale; $config{$h}{'wtime'} = $now + $sec; warning("updating %s: %s: wait $wait $units before further updates", $h, $status, $ip); } else { failed("updating %s: %s: unexpected status (%s)", $h, $line); } } } failed("updating %s: Could not connect to %s.", $hosts, $config{$h}{'server'}) if $state ne 'results2'; } } ###################################################################### ## nic_noip_update ## Note: uses same features as nic_dyndns2_update, less return codes ###################################################################### sub nic_noip_update { debug("\nnic_noip_update -------------------"); ## group hosts with identical attributes together my %groups = group_hosts_by([ @_ ], [ qw(login password server static custom wildcard mx backupmx) ]); my %errors = ( 'badauth' => 'Invalid username or password', 'badagent' => 'Invalid user agent', 'nohost' => 'The hostname specified does not exist in the database', '!donator' => 'The offline setting was set, when the user is not a donator', 'abuse', => 'The hostname specified is blocked for abuse; open a trouble ticket at http://www.no-ip.com', 'numhost' => 'System error: Too many or too few hosts found. open a trouble ticket at http://www.no-ip.com', 'dnserr' => 'System error: DNS error encountered. Contact support@dyndns.org', 'nochg' => 'No update required; unnecessary attempts to change to the current address are considered abusive', ); ## update each set of hosts that had similar configurations foreach my $sig (keys %groups) { my @hosts = @{$groups{$sig}}; my $hosts = join(',', @hosts); my $h = $hosts[0]; my $ip = $config{$h}{'wantip'}; delete $config{$_}{'wantip'} foreach @hosts; info("setting IP address to %s for %s", $ip, $hosts); verbose("UPDATE:","updating %s", $hosts); my $url = "http://$config{$h}{'server'}/nic/update?system="; $url .= 'noip'; $url .= "&hostname=$hosts"; $url .= "&myip="; $url .= $ip if $ip; my $reply = geturl(opt('proxy'), $url, $config{$h}{'login'}, $config{$h}{'password'}); if (!defined($reply) || !$reply) { failed("updating %s: Could not connect to %s.", $hosts, $config{$h}{'server'}); last; } last if !header_ok($hosts, $reply); my @reply = split /\n/, $reply; my $state = 'header'; foreach my $line (@reply) { if ($state eq 'header') { $state = 'body'; } elsif ($state eq 'body') { $state = 'results' if $line eq ''; } elsif ($state =~ /^results/) { $state = 'results2'; my ($status, $ip) = split / /, lc $line; my $h = shift @hosts; $config{$h}{'status'} = $status; if ($status eq 'good') { $config{$h}{'ip'} = $ip; $config{$h}{'mtime'} = $now; success("updating %s: %s: IP address set to %s", $h, $status, $ip); } elsif (exists $errors{$status}) { if ($status eq 'nochg') { warning("updating %s: %s: %s", $h, $status, $errors{$status}); $config{$h}{'ip'} = $ip; $config{$h}{'mtime'} = $now; $config{$h}{'status'} = 'good'; } else { failed("updating %s: %s: %s", $h, $status, $errors{$status}); } } elsif ($status =~ /w(\d+)(.)/) { my ($wait, $units) = ($1, lc $2); my ($sec, $scale) = ($wait, 1); ($scale, $units) = (1, 'seconds') if $units eq 's'; ($scale, $units) = (60, 'minutes') if $units eq 'm'; ($scale, $units) = (60*60, 'hours') if $units eq 'h'; $sec = $wait * $scale; $config{$h}{'wtime'} = $now + $sec; warning("updating %s: %s: wait $wait $units before further updates", $h, $status, $ip); } else { failed("updating %s: %s: unexpected status (%s)", $h, $line); } } } failed("updating %s: Could not connect to %s.", $hosts, $config{$h}{'server'}) if $state ne 'results2'; } } ###################################################################### ## nic_noip_examples ###################################################################### sub nic_noip_examples { return </i, @reply) { $config{$h}{'ip'} = $ip; $config{$h}{'mtime'} = $now; $config{$h}{'status'} = 'good'; success("updating %s: good: IP address set to %s", $h, $ip); } else { $config{$h}{'status'} = 'failed'; warning("SENT: %s", $url) unless opt('verbose'); warning("REPLIED: %s", $reply); failed("updating %s: Invalid reply.", $h); } } } ###################################################################### ## nic_zoneedit1_examples ###################################################################### sub nic_zoneedit1_examples { return < # # ###################################################################### sub nic_zoneedit1_update { debug("\nnic_zoneedit1_update -------------------"); ## group hosts with identical attributes together my %groups = group_hosts_by([ @_ ], [ qw(login password server zone) ]); ## update each set of hosts that had similar configurations foreach my $sig (keys %groups) { my @hosts = @{$groups{$sig}}; my $hosts = join(',', @hosts); my $h = $hosts[0]; my $ip = $config{$h}{'wantip'}; delete $config{$_}{'wantip'} foreach @hosts; info("setting IP address to %s for %s", $ip, $hosts); verbose("UPDATE:","updating %s", $hosts); my $url = ''; $url .= "http://$config{$h}{'server'}/auth/dynamic.html"; $url .= "?host=$hosts"; $url .= "&dnsto=$ip" if $ip; $url .= "&zone=$config{$h}{'zone'}" if defined $config{$h}{'zone'}; my $reply = geturl(opt('proxy'), $url, $config{$h}{'login'}, $config{$h}{'password'}); if (!defined($reply) || !$reply) { failed("updating %s: Could not connect to %s.", $hosts, $config{$h}{'server'}); last; } last if !header_ok($hosts, $reply); my @reply = split /\n/, $reply; foreach my $line (@reply) { if ($line =~ /^[^<]*<(SUCCESS|ERROR)\s+([^>]+)>(.*)/) { my ($status, $assignments, $rest) = ($1, $2, $3); my ($left, %var) = parse_assignments($assignments); if (keys %var) { my ($status_code, $status_text, $status_ip) = ('999', '', $ip); $status_code = $var{'CODE'} if exists $var{'CODE'}; $status_text = $var{'TEXT'} if exists $var{'TEXT'}; $status_ip = $var{'IP'} if exists $var{'IP'}; if ($status eq 'SUCCESS' || ($status eq 'ERROR' && $var{'CODE'} eq '707')) { $config{$h}{'ip'} = $status_ip; $config{$h}{'mtime'} = $now; $config{$h}{'status'} = 'good'; success("updating %s: IP address set to %s (%s: %s)", $h, $ip, $status_code, $status_text); } else { $config{$h}{'status'} = 'failed'; failed("updating %s: %s: %s", $h, $status_code, $status_text); } shift @hosts; $h = $hosts[0]; $hosts = join(',', @hosts); } $line = $rest; redo if $line; } } failed("updating %s: no response from %s", $hosts, $config{$h}{'server'}) if @hosts; } } ###################################################################### ## nic_easydns_updateable ###################################################################### sub nic_easydns_updateable { my $host = shift; my $update = 0; if ($config{$host}{'mx'} ne $cache{$host}{'mx'}) { info("forcing updating %s because 'mx' has changed to %s.", $host, $config{$host}{'mx'}); $update = 1; } elsif ($config{$host}{'mx'} && (ynu($config{$host}{'backupmx'},1,2,3) ne ynu($config{$host}{'backupmx'},1,2,3))) { info("forcing updating %s because 'backupmx' has changed to %s.", $host, ynu($config{$host}{'backupmx'},"YES","NO","NO")); $update = 1; } elsif ($config{$host}{'static'} ne $cache{$host}{'static'}) { info("forcing updating %s because 'static' has changed to %s.", $host, ynu($config{$host}{'static'},"YES","NO","NO")); $update = 1; } return $update; } ###################################################################### ## nic_easydns_examples ###################################################################### sub nic_easydns_examples { return < [ $_ ] } @_; my %errors = ( 'NOACCESS' => 'Authentication failed. This happens if the username/password OR host or domain are wrong.', 'NOSERVICE'=> 'Dynamic DNS is not turned on for this domain.', 'ILLEGAL' => 'Client sent data that is not allowed in a dynamic DNS update.', 'TOOSOON' => 'Update frequency is too short.', ); ## update each set of hosts that had similar configurations foreach my $sig (keys %groups) { my @hosts = @{$groups{$sig}}; my $hosts = join(',', @hosts); my $h = $hosts[0]; my $ip = $config{$h}{'wantip'}; delete $config{$_}{'wantip'} foreach @hosts; info("setting IP address to %s for %s", $ip, $hosts); verbose("UPDATE:","updating %s", $hosts); #'http://members.easydns.com/dyn/dyndns.php?hostname=test.burry.ca&myip=10.20.30.40&wildcard=ON' my $url; $url = "http://$config{$h}{'server'}/dyn/dyndns.php?"; $url .= "hostname=$hosts"; $url .= "&myip="; $url .= $ip if $ip; $url .= "&wildcard=" . ynu($config{$h}{'wildcard'}, 'ON', 'OFF', 'OFF') if defined $config{$h}{'wildcard'}; if ($config{$h}{'mx'}) { $url .= "&mx=$config{$h}{'mx'}"; $url .= "&backmx=" . ynu($config{$h}{'backupmx'}, 'YES', 'NO'); } my $reply = geturl(opt('proxy'), $url, $config{$h}{'login'}, $config{$h}{'password'}); if (!defined($reply) || !$reply) { failed("updating %s: Could not connect to %s.", $hosts, $config{$h}{'server'}); last; } last if !header_ok($hosts, $reply); my @reply = split /\n/, $reply; my $state = 'header'; foreach my $line (@reply) { if ($state eq 'header') { $state = 'body'; } elsif ($state eq 'body') { $state = 'results' if $line eq ''; } elsif ($state =~ /^results/) { $state = 'results2'; my ($status) = $line =~ /^(\S*)\b.*/; my $h = shift @hosts; $config{$h}{'status'} = $status; if ($status eq 'NOERROR') { $config{$h}{'ip'} = $ip; $config{$h}{'mtime'} = $now; success("updating %s: %s: IP address set to %s", $h, $status, $ip); } elsif ($status =~ /TOOSOON/) { ## make sure we wait at least a little my ($wait, $units) = (5, 'm'); my ($sec, $scale) = ($wait, 1); ($scale, $units) = (1, 'seconds') if $units eq 's'; ($scale, $units) = (60, 'minutes') if $units eq 'm'; ($scale, $units) = (60*60, 'hours') if $units eq 'h'; $config{$h}{'wtime'} = $now + $sec; warning("updating %s: %s: wait $wait $units before further updates", $h, $status, $ip); } elsif (exists $errors{$status}) { failed("updating %s: %s: %s", $h, $line, $errors{$status}); } else { failed("updating %s: %s: unexpected status (%s)", $h, $line); } last; } } failed("updating %s: Could not connect to %s.", $hosts, $config{$h}{'server'}) if $state ne 'results2'; } } ###################################################################### ###################################################################### ## nic_dnspark_updateable ###################################################################### sub nic_dnspark_updateable { my $host = shift; my $update = 0; if ($config{$host}{'mx'} ne $cache{$host}{'mx'}) { info("forcing updating %s because 'mx' has changed to %s.", $host, $config{$host}{'mx'}); $update = 1; } elsif ($config{$host}{'mx'} && ($config{$host}{'mxpri'} ne $cache{$host}{'mxpri'})) { info("forcing updating %s because 'mxpri' has changed to %s.", $host, $config{$host}{'mxpri'}); $update = 1; } return $update; } ###################################################################### ## nic_dnspark_examples ###################################################################### sub nic_dnspark_examples { return < [ $_ ] } @_; my %errors = ( 'nochange' => 'No changes made to the hostname(s). Continual updates with no changes lead to blocked clients.', 'nofqdn' => 'No valid FQDN (fully qualified domain name) was specified', 'nohost'=> 'An invalid hostname was specified. This due to the fact the hostname has not been created in the system. Creating new host names via clients is not supported.', 'abuse' => 'The hostname specified has been blocked for abuse.', 'unauth' => 'The username specified is not authorized to update this hostname and domain.', 'blocked' => 'The dynamic update client (specified by the user-agent) has been blocked from the system.', 'notdyn' => 'The hostname specified has not been marked as a dynamic host. Hosts must be marked as dynamic in the system in order to be updated via clients. This prevents unwanted or accidental updates.', ); ## update each set of hosts that had similar configurations foreach my $sig (keys %groups) { my @hosts = @{$groups{$sig}}; my $hosts = join(',', @hosts); my $h = $hosts[0]; my $ip = $config{$h}{'wantip'}; delete $config{$_}{'wantip'} foreach @hosts; info("setting IP address to %s for %s", $ip, $hosts); verbose("UPDATE:","updating %s", $hosts); #'http://www.dnspark.com:80/visitors/update.html?myip=10.20.30.40&hostname=test.burry.ca' my $url; $url = "http://$config{$h}{'server'}/visitors/update.html"; $url .= "?hostname=$hosts"; $url .= "&myip="; $url .= $ip if $ip; if ($config{$h}{'mx'}) { $url .= "&mx=$config{$h}{'mx'}"; $url .= "&mxpri=" . $config{$h}{'mxpri'}; } my $reply = geturl(opt('proxy'), $url, $config{$h}{'login'}, $config{$h}{'password'}); if (!defined($reply) || !$reply) { failed("updating %s: Could not connect to %s.", $hosts, $config{$h}{'server'}); last; } last if !header_ok($hosts, $reply); my @reply = split /\n/, $reply; my $state = 'header'; foreach my $line (@reply) { if ($state eq 'header') { $state = 'body'; } elsif ($state eq 'body') { $state = 'results' if $line eq ''; } elsif ($state =~ /^results/) { $state = 'results2'; my ($status) = $line =~ /^(\S*)\b.*/; my $h = pop @hosts; $config{$h}{'status'} = $status; if ($status eq 'ok') { $config{$h}{'ip'} = $ip; $config{$h}{'mtime'} = $now; success("updating %s: %s: IP address set to %s", $h, $status, $ip); } elsif ($status =~ /TOOSOON/) { ## make sure we wait at least a little my ($wait, $units) = (5, 'm'); my ($sec, $scale) = ($wait, 1); ($scale, $units) = (1, 'seconds') if $units eq 's'; ($scale, $units) = (60, 'minutes') if $units eq 'm'; ($scale, $units) = (60*60, 'hours') if $units eq 'h'; $config{$h}{'wtime'} = $now + $sec; warning("updating %s: %s: wait $wait $units before further updates", $h, $status, $ip); } elsif (exists $errors{$status}) { failed("updating %s: %s: %s", $h, $line, $errors{$status}); } else { failed("updating %s: %s: unexpected status (%s)", $h, $line); } last; } } failed("updating %s: Could not connect to %s.", $hosts, $config{$h}{'server'}) if $state ne 'results2'; } } ###################################################################### ###################################################################### ## nic_namecheap_examples ###################################################################### sub nic_namecheap_examples { return <0/i, @reply) { $config{$h}{'ip'} = $ip; $config{$h}{'mtime'} = $now; $config{$h}{'status'} = 'good'; success("updating %s: good: IP address set to %s", $h, $ip); } else { $config{$h}{'status'} = 'failed'; warning("SENT: %s", $url) unless opt('verbose'); warning("REPLIED: %s", $reply); failed("updating %s: Invalid reply.", $h); } } } ###################################################################### ###################################################################### ## nic_nfsn_examples ###################################################################### sub nic_nfsn_examples { return <{'error'}) { failed("Invalid error response: %s", $resp); return; } failed($json->{'error'}); if (defined $json->{'debug'}) { failed($json->{'debug'}); } } ###################################################################### ## nic_nfsn_update ## ## Written by John Brooks ## ## Based on API docs: https://members.nearlyfreespeech.net/wiki/API/Introduction ## Uses the API endpoints under https://api.nearlyfreespeech.net/dns/$zone/ ## ## NB: There is no "updateRR" API function; to update an existing RR, we use ## removeRR to delete the RR, and then addRR to re-add it with the new data. ## ###################################################################### sub nic_nfsn_update { debug("\nnic_nfsn_update -------------------"); ## update each configured host foreach my $h (@_) { my $zone = $config{$h}{'zone'}; my $name; if ($h eq $zone) { $name = ''; } elsif ($h !~ /$zone$/) { $config{$h}{'status'} = 'failed'; failed("updating %s: %s is outside zone %s", $h, $h, $zone); next; } else { $name = $h; $name =~ s/(.*)\.${zone}$/$1/; } my $ip = delete $config{$h}{'wantip'}; info("setting IP address to %s for %s", $ip, $h); verbose("UPDATE", "updating %s", $h); my $list_path = "/dns/$zone/listRRs"; my $list_body = encode_www_form_urlencoded({name => $name, type => 'A'}); my $list_resp = nic_nfsn_make_request($h, $list_path, 'POST', $list_body); if (!header_ok($h, $list_resp)) { $config{$h}{'status'} = 'failed'; nic_nfsn_handle_error($list_resp, $h); next; } $list_resp =~ s/^.*?\n\n//s; # Strip header my $list = eval{decode_json($list_resp)}; if ($@) { $config{$h}{'status'} = 'failed'; failed("updating %s: JSON decoding failure", $h); next; } my $rr_ttl = $config{$h}{'ttl'}; if (ref($list) eq 'ARRAY' && defined $list->[0]->{'data'}) { my $rr_data = $list->[0]->{'data'}; my $rm_path = "/dns/$zone/removeRR"; my $rm_data = {name => $name, type => 'A', data => $rr_data}; my $rm_body = encode_www_form_urlencoded($rm_data); my $rm_resp = nic_nfsn_make_request($h, $rm_path, 'POST', $rm_body); if (!header_ok($h, $rm_resp)) { $config{$h}{'status'} = 'failed'; nic_nfsn_handle_error($rm_resp); next; } } my $add_path = "/dns/$zone/addRR"; my $add_data = {name => $name, type => 'A', data => $ip, ttl => $rr_ttl}; my $add_body = encode_www_form_urlencoded($add_data); my $add_resp = nic_nfsn_make_request($h, $add_path, 'POST', $add_body); if (header_ok($h, $add_resp)) { $config{$h}{'ip'} = $ip; $config{$h}{'mtime'} = $now; $config{$h}{'status'} = 'good'; success("updating %s: good: IP address set to %s", $h, $ip); } else { $config{$h}{'status'} = 'failed'; nic_nfsn_handle_error($add_resp, $h); } } } ###################################################################### ###################################################################### ## nic_sitelutions_examples ###################################################################### sub nic_sitelutions_examples { return < ## This returns a list of host|currentIP|updateURL lines. ## Pick the line that matches myhost, and fetch the URL. ## word 'Updated' for success, 'fail' for failure. ## ###################################################################### sub nic_freedns_update { debug("\nnic_freedns_update -------------------"); ## First get the list of updatable hosts my $url; $url = "http://$config{$_[0]}{'server'}/api/?action=getdyndns&sha=".&sha1_hex("$config{$_[0]}{'login'}|$config{$_[0]}{'password'}"); my $reply = geturl(opt('proxy'), $url); if (!defined($reply) || !$reply || !header_ok($_[0], $reply)) { failed("updating %s: Could not connect to %s for site list.", $_[0], $url); return; } my @lines = split("\n", $reply); my %freedns_hosts; grep { my @rec = split(/\|/, $_); $freedns_hosts{$rec[0]} = \@rec if ($#rec > 0); } @lines; if (!keys %freedns_hosts) { failed("Could not get freedns update URLs from %s", $config{$_[0]}{'server'}); return; } ## update each configured host foreach my $h (@_) { if(!$h){ next }; my $ip = delete $config{$h}{'wantip'}; info("setting IP address to %s for %s", $ip, $h); verbose("UPDATE:","updating %s", $h); if($ip eq $freedns_hosts{$h}->[1]) { $config{$h}{'ip'} = $ip; $config{$h}{'mtime'} = $now; $config{$h}{'status'} = 'good'; success("update not necessary %s: good: IP address already set to %s", $h, $ip); } else { my $reply = geturl(opt('proxy'), $freedns_hosts{$h}->[2]); if (!defined($reply) || !$reply) { failed("updating %s: Could not connect to %s.", $h, $freedns_hosts{$h}->[2]); last; } if(!header_ok($h, $reply)) { $config{$h}{'status'} = 'failed'; last; } if($reply =~ /Updated.*$h.*to.*$ip/) { $config{$h}{'ip'} = $ip; $config{$h}{'mtime'} = $now; $config{$h}{'status'} = 'good'; success("updating %s: good: IP address set to %s", $h, $ip); } else { $config{$h}{'status'} = 'failed'; warning("SENT: %s", $freedns_hosts{$h}->[2]) unless opt('verbose'); warning("REPLIED: %s", $reply); failed("updating %s: Invalid reply.", $h); } } } } ###################################################################### ## nic_changeip_examples ###################################################################### sub nic_changeip_examples { return < ## fully qualified hostname to update Example ${program}.conf file entries: ## single host update protocol=nsupdate \\ server=ns1.example.com \\ password=/etc/${program}/dyn.example.com.key \\ zone=dyn.example.com \\ ttl=3600 \\ myhost.dyn.example.com EoEXAMPLE } ###################################################################### ## nic_nsupdate_update ## by Daniel Roethlisberger ###################################################################### sub nic_nsupdate_update { debug("\nnic_nsupdate_update -------------------"); ## group hosts with identical attributes together my %groups = group_hosts_by([ @_ ], [ qw(login password server zone) ]); ## update each set of hosts that had similar configurations foreach my $sig (keys %groups) { my @hosts = @{$groups{$sig}}; my $hosts = join(',', @hosts); my $h = $hosts[0]; my $binary = $config{$h}{'login'}; my $keyfile = $config{$h}{'password'}; my $server = $config{$h}{'server'}; ## nsupdate requires a port number to be separated by whitepace, not colon $server =~ s/:/ /; my $zone = $config{$h}{'zone'}; my $ip = $config{$h}{'wantip'}; my $recordtype = ''; if (is_ipv6($ip)) { $recordtype = 'AAAA'; } else { $recordtype = 'A'; } delete $config{$_}{'wantip'} foreach @hosts; info("setting IP address to %s for %s", $ip, $hosts); verbose("UPDATE:","updating %s", $hosts); ## send separate requests for each zone with all hosts in that zone my $instructions = <{result}) { failed ("invalid json or result."); next; } # Pull the ID out of the json, messy my ($zone_id) = map { $_->{name} eq $config{$key}{'zone'} ? $_->{id} : () } @{ $response->{result} }; unless($zone_id) { failed("updating %s: No zone ID found.", $config{$key}{'zone'}); next; } info("zone ID is $zone_id"); # Get DNS record ID $url = "https://$config{$key}{'server'}/zones/$zone_id/dns_records?"; if (is_ipv6($ip)) { $url .= "type=AAAA&name=$domain"; } else { $url .= "type=A&name=$domain"; } $reply = geturl(opt('proxy'), $url, undef, undef, $headers); unless ($reply) { failed("updating %s: Could not connect to %s.", $domain, $config{$key}{'server'}); last; } last if !header_ok($domain, $reply); # Strip header $reply =~ s/^.*?\n\n//s; $response = eval {decode_json($reply)}; if (!defined $response || !defined $response->{result}) { failed ("invalid json or result."); next; } # Pull the ID out of the json, messy my ($dns_rec_id) = map { $_->{name} eq $domain ? $_->{id} : () } @{ $response->{result} }; unless($dns_rec_id) { failed("updating %s: No DNS record ID found.", $domain); next; } info("DNS record ID is $dns_rec_id"); # Set domain $url = "https://$config{$key}{'server'}/zones/$zone_id/dns_records/$dns_rec_id"; my $data = "{\"content\":\"$ip\"}"; $reply = geturl(opt('proxy'), $url, undef, undef, $headers, "PATCH", $data); unless ($reply) { failed("updating %s: Could not connect to %s.", $domain, $config{$domain}{'server'}); last; } last if !header_ok($domain, $reply); # Strip header $reply =~ s/^.*?\n\n//s; $response = eval {decode_json($reply)}; if (!defined $response || !defined $response->{result}) { failed ("invalid json or result."); } else { success ("%s -- Updated Successfully to %s", $domain, $ip); } # Cache $config{$key}{'ip'} = $ip; $config{$key}{'mtime'} = $now; $config{$key}{'status'} = 'good'; } } } ###################################################################### ## nic_yandex_examples ###################################################################### sub nic_yandex_examples { return <{success} eq 'error') { failed ("%s", $response->{error}); next; } # Pull the ID out of the json my ($id) = map { $_->{fqdn} eq $host ? $_->{record_id} : () } @{ $response->{records} }; unless($id) { failed("updating %s: DNS record ID not found.", $host); next; } # Update the DNS record $url = "https://$config{$host}{'server'}/api2/admin/dns/edit"; my $data = "domain="; $data .= $config{$key}{'login'}; $data .= "&record_id="; $data .= $id; $data .= "&content="; $data .= $ip if $ip; $reply = geturl(opt('proxy'), $url, '', '', $headers, 'POST', $data); unless ($reply) { failed("updating %s: Could not connect to %s.", $host, $config{$host}{'server'}); last; } last if !header_ok($host, $reply); # Strip header $reply =~ s/^.*?\n\n//s; $response = eval { decode_json($reply) }; if ($response->{success} eq 'error') { failed ("%s", $response->{error}); } else { success ("%s -- Updated Successfully to %s", $host, $ip); } # Cache $config{$host}{'ip'} = $ip; $config{$host}{'mtime'} = $now; $config{$host}{'status'} = 'good'; } } } ###################################################################### ## nic_duckdns_examples ###################################################################### sub nic_duckdns_examples { return < 'Bad authorization (username or password)', 'badsys' => 'The system parameter given was not valid', 'notfqdn' => 'A Fully-Qualified Domain Name was not provided', 'nohost' => 'The hostname specified does not exist in the database', '!yours' => 'The hostname specified exists, but not under the username currently being used', '!donator' => 'The offline setting was set, when the user is not a donator', '!active' => 'The hostname specified is in a Custom DNS domain which has not yet been activated.', 'abuse', => 'The hostname specified is blocked for abuse; you should receive an email notification ' . 'which provides an unblock request link. More info can be found on ' . 'https://www.dyndns.com/support/abuse.html', 'numhost' => 'System error: Too many or too few hosts found. Contact support@dyndns.org', 'dnserr' => 'System error: DNS error encountered. Contact support@dyndns.org', 'nochg' => 'No update required; unnecessary attempts to change to the current address are considered abusive', ); my @hosts = @_; foreach my $key (keys @hosts) { my $h = $hosts[$key]; my $ip = $config{$h}{'wantip'}; delete $config{$h}{'wantip'}; info("setting IP address to %s for %s", $ip, $h); verbose("UPDATE:","updating %s", $h); ## Select the DynDNS system to update my $url = "http://$config{$h}{'server'}$config{$h}{'script'}?system="; if ($config{$h}{'custom'}) { warning("updating %s: 'custom' and 'static' may not be used together. ('static' ignored)", $h) if $config{$h}{'static'}; # warning("updating %s: 'custom' and 'offline' may not be used together. ('offline' ignored)", $h) # if $config{$h}{'offline'}; $url .= 'custom'; } elsif ($config{$h}{'static'}) { # warning("updating %s: 'static' and 'offline' may not be used together. ('offline' ignored)", $h) # if $config{$h}{'offline'}; $url .= 'statdns'; } else { $url .= 'dyndns'; } $url .= "&hostname=$h"; $url .= "&myip="; $url .= $ip if $ip; ## some args are not valid for a custom domain. $url .= "&wildcard=ON" if ynu($config{$h}{'wildcard'}, 1, 0, 0); if ($config{$h}{'mx'}) { $url .= "&mx=$config{$h}{'mx'}"; $url .= "&backmx=" . ynu($config{$h}{'backupmx'}, 'YES', 'NO'); } my $reply = geturl(opt('proxy'), $url, $config{$h}{'login'}, $config{$h}{'password'}); if (!defined($reply) || !$reply) { failed("updating %s: Could not connect to %s.", $h, $config{$h}{'server'}); last; } last if !header_ok($h, $reply); my @reply = split /\n/, $reply; my $state = 'header'; my $returnedip = $ip; foreach my $line (@reply) { if ($state eq 'header') { $state = 'body'; } elsif ($state eq 'body') { $state = 'results' if $line eq ''; } elsif ($state =~ /^results/) { $state = 'results2'; # bug #10: some dyndns providers does not return the IP so # we can't use the returned IP my ($status, $returnedip) = split / /, lc $line; $ip = $returnedip if (not $ip); #my $h = shift @hosts; $config{$h}{'status'} = $status; if ($status eq 'good') { $config{$h}{'ip'} = $ip; $config{$h}{'mtime'} = $now; success("updating %s: %s: IP address set to %s", $h, $status, $ip); } elsif (exists $errors{$status}) { if ($status eq 'nochg') { warning("updating %s: %s: %s", $h, $status, $errors{$status}); $config{$h}{'ip'} = $ip; $config{$h}{'mtime'} = $now; $config{$h}{'status'} = 'good'; } else { failed("updating %s: %s: %s", $h, $status, $errors{$status}); } } elsif ($status =~ /w(\d+)(.)/) { my ($wait, $units) = ($1, lc $2); my ($sec, $scale) = ($wait, 1); ($scale, $units) = (1, 'seconds') if $units eq 's'; ($scale, $units) = (60, 'minutes') if $units eq 'm'; ($scale, $units) = (60*60, 'hours') if $units eq 'h'; $sec = $wait * $scale; $config{$h}{'wtime'} = $now + $sec; warning("updating %s: %s: wait $wait $units before further updates", $h, $status, $ip); } else { failed("updating %s: %s: unexpected status (%s)", $h, $line); } } } failed("updating %s: Could not connect to %s.", $h, $config{$h}{'server'}) if $state ne 'results2'; } } ###################################################################### ## nic_dondominio_examples ###################################################################### sub nic_dondominio_examples { return < 'Invalid username or password, or invalid IP syntax', 'error-auth-suspend' => 'User has had their account suspended due to complaints or misuse of the service.', 'error-auth-voided' => 'User has had their account permanently revoked.', 'error-record-invalid' =>'Record ID number does not exist in the system.', 'error-record-auth' => 'User does not have access to this record.', 'error-record-ip-same' => 'No update required.', 'error-system' => 'General system error which is caught and recognized by the system.', 'error' => 'General system error unrecognized by the system.', 'success' => 'Record successfully updated!', ); ## update each configured host ## should improve to update in one pass foreach my $h (@_) { my $ip = delete $config{$h}{'wantip'}; info("Setting IP address to %s for %s", $ip, $h); verbose("UPDATE:","Updating %s", $h); # Set the URL that we're going to to update my $url; $url = $globals{'ssl'} ? "https://" : "http://"; $url .= $config{$h}{'server'}.$config{$h}{'script'}; $url .= "?username=$config{$h}{'login'}"; $url .= "&password=$config{$h}{'password'}"; $url .= "&ip=$ip"; $url .= "&id=$h"; # Try to get URL my $reply = geturl(opt('proxy'), $url); # No response, declare as failed if (!defined($reply) || !$reply) { failed("Updating %s: Could not connect to %s.", $h, $config{$h}{'server'}); last; } last if !header_ok($h, $reply); my @reply = split /\n/, $reply; my $returned = pop(@reply); if ($returned =~ 'success') { $config{$h}{'ip'} = $ip; $config{$h}{'mtime'} = $now; $config{$h}{'status'} = 'good'; success("Updating %s: good: IP address set to %s", $h, $ip); } else { $config{$h}{'status'} = 'failed'; failed("Updating %s: Server said: '$returned': $messages{$returned}", $h); } } } ###################################################################### # vim: ai ts=4 sw=4 tw=78 : __END__ ddclient-3.9.1/sample-ddclient-wrapper.sh000077500000000000000000000010761360532346300204050ustar00rootroot00000000000000#!/bin/bash # # This wrapper should be usefull for people who want to run a postscript with # multiple arguments. Currently ddclient has a feature which doesn't allow # multiple arguments. # This example has been written to be able to update multiple domains with # multiple login. It expects a /etc/ddclient/ddclient-domain2.conf with the # configuration of the extra domain # the second domain who has to be updated : ${SECONDCONFIG:=/etc/ddclient/ddclient-domain2.conf} # ddclient adds the new IP as argument IP=$1 ddclient -ip ${IP} -file ${SECONDCONFIG} -daemon 0 ddclient-3.9.1/sample-etc_cron.d_ddclient000066400000000000000000000014501360532346300204050ustar00rootroot00000000000000###################################################################### ## ddclient is an IP address updater for www.dyndns.org ###################################################################### ## minute 0-59 ## hour 0-23 ## day of month 1-31 ## month 1-12 (or names, see below) ## day of week 0-7 (0 or 7 is Sun, or use names) ###################################################################### ## force an update twice a month (only if you are not using daemon-mode) ## ## 30 23 1,15 * * root /usr/sbin/ddclient -daemon=0 -syslog -quiet -force ###################################################################### ## retry failed updates every hour (only if you are not using daemon-mode) ## ## 0 * * * * root /usr/sbin/ddclient -daemon=0 -syslog -quiet retry ddclient-3.9.1/sample-etc_ddclient.conf000066400000000000000000000177201360532346300200750ustar00rootroot00000000000000###################################################################### ## ## Define default global variables with lines like: ## var=value [, var=value]* ## These values will be used for each following host unless overridden ## with a local variable definition. ## ## Define local variables for one or more hosts with: ## var=value [, var=value]* host.and.domain[,host2.and.domain...] ## ## Lines can be continued on the following line by ending the line ## with a \ ## ## ## Warning: not all supported routers or dynamic DNS services ## are mentioned here. ## ###################################################################### daemon=300 # check every 300 seconds syslog=yes # log update msgs to syslog mail=root # mail all msgs to root mail-failure=root # mail failed update msgs to root pid=/var/run/ddclient.pid # record PID in file. ssl=yes # use ssl-support. Works with # ssl-library # postscript=script # run script after updating. The # new IP is added as argument. # #use=watchguard-soho, fw=192.168.111.1:80 # via Watchguard's SOHO FW #use=netopia-r910, fw=192.168.111.1:80 # via Netopia R910 FW #use=smc-barricade, fw=192.168.123.254:80 # via SMC's Barricade FW #use=netgear-rt3xx, fw=192.168.0.1:80 # via Netgear's internet FW #use=linksys, fw=192.168.1.1:80 # via Linksys's internet FW #use=maxgate-ugate3x00, fw=192.168.0.1:80 # via MaxGate's UGATE-3x00 FW #use=elsa-lancom-dsl10, fw=10.0.0.254:80 # via ELSA LanCom DSL/10 DSL Router #use=elsa-lancom-dsl10-ch01, fw=10.0.0.254:80 # via ELSA LanCom DSL/10 DSL Router #use=elsa-lancom-dsl10-ch02, fw=10.0.0.254:80 # via ELSA LanCom DSL/10 DSL Router #use=alcatel-stp, fw=10.0.0.138:80 # via Alcatel Speed Touch Pro #use=xsense-aero, fw=192.168.1.1:80 # via Xsense Aero Router #use=allnet-1298, fw=192.168.1.1:80 # via AllNet 1298 DSL Router #use=3com-oc-remote812, fw=192.168.0.254:80 # via 3com OfficeConnect Remote 812 #use=e-tech, fw=192.168.1.1:80 # via E-tech Router #use=cayman-3220h, fw=192.168.0.1:1080 # via Cayman 3220-H DSL Router # #fw-login=admin, fw-password=XXXXXX # FW login and password # ## To obtain an IP address from FW status page (using fw-login, fw-password) #use=fw, fw=192.168.1.254/status.htm, fw-skip='IP Address' # found after IP Address # ## To obtain an IP address from Web status page (using the proxy if defined) ## by default, checkip.dyndns.org is used if you use the dyndns protocol. ## Using use=web is enough to get it working. ## WARNING: set deamon at least to 600 seconds if you use checkip or you could ## get banned from their service. #use=web, web=checkip.dyndns.org/, web-skip='IP Address' # found after IP Address # #use=ip, ip=127.0.0.1 # via static IP's #use=if, if=eth0 # via interfaces #use=web # via web # #protocol=dyndns2 # default protocol #proxy=fasthttp.sympatico.ca:80 # default proxy #server=members.dyndns.org # default server #server=members.dyndns.org:8245 # default server (bypassing proxies) #login=your-login # default login #password=test # default password #mx=mx.for.your.host # default MX #backupmx=yes|no # host is primary MX? #wildcard=yes|no # add wildcard CNAME? ## ## dyndns.org dynamic addresses ## ## (supports variables: wildcard,mx,backupmx) ## # server=members.dyndns.org, \ # protocol=dyndns2 \ # your-dynamic-host.dyndns.org ## ## dyndns.org static addresses ## ## (supports variables: wildcard,mx,backupmx) ## # static=yes, \ # server=members.dyndns.org, \ # protocol=dyndns2 \ # your-static-host.dyndns.org ## ## ## dyndns.org custom addresses ## ## (supports variables: wildcard,mx,backupmx) ## # custom=yes, \ # server=members.dyndns.org, \ # protocol=dyndns2 \ # your-domain.top-level,your-other-domain.top-level ## ## ZoneEdit (zoneedit.com) ## # server=dynamic.zoneedit.com, \ # protocol=zoneedit1, \ # login=your-zoneedit-login, \ # password=your-zoneedit-password \ # your.any.domain,your-2nd.any.dom ## ## EasyDNS (easydns.com) ## # server=members.easydns.com, \ # protocol=easydns, \ # login=your-easydns-login, \ # password=your-easydns-password \ # your.any.domain,your-2nd.any.domain ## ## Hammernode (hn.org) dynamic addresses ## # server=dup.hn.org, \ # protocol=hammernode1, \ # login=your-hn-login, \ # password=your-hn-password \ # your-hn-host.hn.org,your-2nd-hn-host.hn.org ## ## dslreports.com dynamic-host monitoring ## # server=members.dslreports.com \ # protocol=dslreports1, \ # login=dslreports-login, \ # password=dslreports-password \ # dslreports-unique-id ## ## OrgDNS.org account-configuration ## # use=web, web=members.orgdns.org/nic/ip # server=www.orgdns.org \ # protocol=dyndns2 \ # login=yourLoginName \ # password=yourPassword \ # yourSubdomain.orgdns.org ## ## dnspark.com ## (supports variables: mx, mxpri) ## # use=web, web=ipdetect.dnspark.com, web-skip='Current Address:' # protocol=dnspark, \ # server=www.dnspark.com, \ # your-host.dnspark.com ## ## NameCheap (namecheap.com) ## # protocol=namecheap, \ # server=dynamicdns.park-your-domain.com, \ # login=my-namecheap.com-login, \ # password=my-namecheap.com-password \ # fully.qualified.host ## ## NearlyFreeSpeech.NET (nearlyfreespeech.net) ## # protocol = nfsn, \ # login=member-login, \ # password=api-key, \ # zone=example.com \ # example.com,subdomain.example.com ## ## ## Loopia (loopia.se) ## # use=web # web=loopia # protocol=dyndns2 # server=dns.loopia.se # script=/XDynDNSServer/XDynDNS.php # login=my-loopia.se-login # password=my-loopia.se-password # my.domain.tld,other.domain.tld ## ## ## ChangeIP (changeip.com) ## ## single host update # protocol=changeip, \ # login=my-my-changeip.com-login, \ # password=my-changeip.com-password \ # myhost.changeip.org ## ## DtDNS (www.dtdns.com) ## # protocol=dtdns, # server=www.dtdns.com, # client=ddclient, # password=my-dtdns.com-password # myhost.dtdns.net, otherhost.dtdns.net ## ## CloudFlare (www.cloudflare.com) ## #protocol=cloudflare, \ #zone=domain.tld, \ #ttl=1, \ #login=your-login-email, \ #password=APIKey \ #domain.tld,my.domain.tld ## ## Google Domains (www.google.com/domains) ## # protocol=googledomains, # login=my-auto-generated-username, # password=my-auto-generated-password # my.domain.tld, otherhost.domain.tld ## ## Duckdns (http://www.duckdns.org/) ## # # password=my-auto-generated-password # protocol=duckdns hostwithoutduckdnsorg ## ## Freemyip (http://freemyip.com/) ## # # protocol=freemyip, # password=my-token # myhost ## ## MyOnlinePortal (http://myonlineportal.net) ## # protocol=dyndns2 # ssl=yes # # ipv6=yes # optional # use=web, web=myonlineportal.net/checkip # # use=if, if=eth0 # alternative to use=web # # if-skip=Scope:Link # alternative to use=web # login=your-myonlineportal-username # password=your-myonlineportal-password # domain.myonlineportal.net ## ## nsupdate.info IPV4(https://www.nsupdate.info) ## #protocol=dyndns2 #use=web, web=http://ipv4.nsupdate.info/myip #server=ipv4.nsupdate.info #login=domain.nsupdate.info #password='123' #domain.nsupdate.info ## ## nsupdate.info IPV6 (https://www.nsupdate.info) ## ddclient releases <= 3.8.1 do not support IPv6 ## #protocol=dyndns2 #usev6=if, if=eth0 #server=ipv6.nsupdate.info #login=domain.nsupdate.info #password='123' #domain.nsupdate.info ## ## Yandex.Mail for Domain (domain.yandex.com) ## # protocol=yandex, \ # login=domain.tld, \ # password=yandex-pdd-token \ # my.domain.tld,other.domain.tld \ ## DNS Made Easy (https://dnsmadeeasy.com) ## # protocol=dnsmadeeasy, # login=your-account-email-address # password=your-generated-password # your-numeric-record-id-1,your-numeric-record-id-2,... ddclient-3.9.1/sample-etc_dhclient-exit-hooks000066400000000000000000000007531360532346300212430ustar00rootroot00000000000000#!/bin/sh ###################################################################### # The /etc/dhclient-enter-hooks script is run by the ISC DHCP client's standard # update script whenever dhclient obtains or renews an address. PATH=/usr/sbin:${PATH} case "$new_ip_address" in 10.*) ;; 172.1[6-9].* | 172.2[0-9].* | 172.3[0-1].*) ;; 192.168.*) ;; *) logger -t dhclient IP address changed to $new_ip_address ddclient -daemon=0 -syslog -use=ip -ip=$new_ip_address >/dev/null 2>&1 ;; esac ddclient-3.9.1/sample-etc_dhcpc_dhcpcd-eth0.exe000066400000000000000000000010131360532346300213530ustar00rootroot00000000000000#!/bin/sh ###################################################################### PATH=/usr/sbin:${PATH} ## update the DNS server unless the IP address is a private address ## that may be used as an internal LAN address. This may be true if ## other interfaces are assigned private addresses from internal ## DHCP server. case "$1" in 10.*) ;; 172.1[6-9].* | 172.2[0-9].* | 172.3[0-1].*) ;; 192.168.*) ;; *) logger -t dhcpcd IP address changed to $1 ddclient -daemon=0 -syslog -use=ip -ip=$1 >/dev/null 2>&1 ;; esac ddclient-3.9.1/sample-etc_ppp_ip-up.local000066400000000000000000000023711360532346300203610ustar00rootroot00000000000000#!/bin/sh ###################################################################### ## ## On my host, pppd invokes this script with args: ## /etc/ppp/ip-up.local ppp0 /dev/pts/1 115200 192.168.2.1 192.168.2.3 ## ## From the manual page for my pppd, these aguments are: ## scriptname interface-name tty-device speed local-IP-address remote-IP-address ipparam ## ## Some people have reported that their pppd returns their ## local-IP-address as $3. If that's also the case for you, ## you may need to change the $4 below to $3. This may not ## be necessary if your pppd also passes the local-ip-address ## in the environment as either PPP_LOCAL or IPLOCAL. ## ###################################################################### PATH=/usr/sbin:${PATH} IP= IP=${IP:-$PPP_LOCAL} IP=${IP:-$IPLOCAL} IP=${IP:-$4} IFACE= IFACE=${IFACE:-$PPP_IFACE} IFACE=${IFACE:-$1} ## update the DNS server unless the IP address is a private address ## that may be used as an internal LAN address (or PPtP tunnel). logger -t ddclient $0 $* case "$IP" in 10.*) ;; 172.1[6-9].* | 172.2[0-9].* | 172.3[0-1].*) ;; 192.168.*) ;; "") logger -t ddclient No local IP given so cannot update ;; *) ( sleep 5 ddclient -daemon=0 -syslog -use=if -if=$IFACE >/dev/null 2>&1 ) & ;; esac ddclient-3.9.1/sample-etc_rc.d_init.d_ddclient000077500000000000000000000034721360532346300213260ustar00rootroot00000000000000#!/bin/bash # # ddclient This shell script takes care of starting and stopping # ddclient. # # chkconfig: 2345 65 35 # description: ddclient provides support for updating dynamic DNS services. CONF=/etc/ddclient/ddclient.conf program=ddclient [ -f $CONF ] || exit 0 system=unknown if [ -f /etc/fedora-release ]; then system=fedora elif [ -f /etc/redhat-release ]; then system=redhat elif [ -f /etc/debian_version ]; then system=debian fi PID='' if [ "$system" = "fedora" ] || [ "$system" = "redhat" ]; then . /etc/init.d/functions PID=`pidofproc $program` else PID=`ps -aef | grep "$program - sleep" | grep -v grep | awk '{print $2}'` fi PATH=/usr/sbin:/usr/local/sbin:${PATH} export PATH # See how we were called. case "$1" in start) # Start daemon. DELAY=`grep -v '^\s*#' $CONF | grep -i -m 1 "daemon" | awk -F '=' '{print $2}'` if [ -z "$DELAY" ] ; then DELAY="-daemon 300" else DELAY='' fi echo -n "Starting ddclient: " if [ "$system" = "fedora" ] || [ "$system" = "redhat" ]; then daemon $program $DELAY else ddclient $DELAY fi echo ;; stop) # Stop daemon. echo -n "Shutting down ddclient: " if [ -n "$PID" ] ; then if [ "$system" = "fedora" ] || [ "$system" = "redhat" ]; then killproc $program else kill $PID fi else echo "ddclient is not running" fi echo ;; restart) $0 stop $0 start ;; status) if [ "$system" = "fedora" ] || [ "$system" = "redhat" ]; then status $program else if test "$PID" then for p in $PID do echo "$program (pid $p) is running" done else echo "$program is stopped" fi fi ;; *) echo "Usage: ddclient {start|stop|restart|status}" exit 1 esac exit 0 ddclient-3.9.1/sample-etc_rc.d_init.d_ddclient.alpine000077500000000000000000000014341360532346300225710ustar00rootroot00000000000000#!/sbin/openrc-run description="ddclient Daemon for Alpine" command="/usr/sbin/ddclient" config_file="/etc/ddclient/ddclient.conf" command_args="" pidfile=$(grep -v '^\s*#' "${config_file}" | grep -i -m 1 pid= | awk -F '=' '{print $2}') delay=$(grep -v '^\s*#' "${config_file}" | grep -i -m 1 "daemon" | awk -F '=' '{print $2}') if [ -z "${delay}" ] then command_args="-daemon 300" else command_args="" fi depend() { use logger need net after firewall } start() { ebegin "Starting ddclient" start-stop-daemon --start \ --exec "${command}" \ --pidfile "${pidfile}" \ -- \ ${command_args} eend $? } stop() { ebegin "Stopping ddclient" start-stop-daemon --stop --exec "${command}" \ --pidfile "${pidfile}" eend $? } ddclient-3.9.1/sample-etc_rc.d_init.d_ddclient.lsb000077500000000000000000000031161360532346300221000ustar00rootroot00000000000000#!/bin/sh # # ddclient This shell script takes care of starting and stopping # ddclient. # # chkconfig: 2345 65 35 # description: ddclient provides support for updating dynamic DNS services. # # Above is for RedHat and now the LSB part ### BEGIN INIT INFO # Provides: ddclient # Required-Start: $syslog $remote_fs # Should-Start: $time ypbind sendmail # Required-Stop: $syslog $remote_fs # Should-Stop: $time ypbind sendmail # Default-Start: 3 5 # Default-Stop: 0 1 2 6 # Short-Description: ddclient provides support for updating dynamic DNS services # Description: ddclient is a Perl client used to update dynamic DNS # entries for accounts on many dynamic DNS services and # can be used on many types of firewalls ### END INIT INFO # ### [ -f /etc/ddclient/ddclient.conf ] || exit 0 DDCLIENT_BIN=/usr/sbin/ddclient # # LSB Standard (SuSE,RedHat,...) # if [ -f /lib/lsb/init-functions ] ; then . /lib/lsb/init-functions fi # See how we were called. case "$1" in start) echo -n "Starting ddclient " start_daemon $DDCLIENT_BIN -daemon 300 rc_status -v ;; stop) echo -n "Shutting down ddclient " killproc -TERM `basename $DDCLIENT_BIN` rc_status -v ;; restart) $0 stop $0 start rc_status ;; status) echo -n "Checking for service ddclient " checkproc `basename $DDCLIENT_BIN`w rc_status -v ;; *) echo "Usage: ddclient {start|stop|restart|status}" exit 1 esac exit 0 ddclient-3.9.1/sample-etc_rc.d_init.d_ddclient.redhat000077500000000000000000000013241360532346300225660ustar00rootroot00000000000000#!/bin/sh # # ddclient This shell script takes care of starting and stopping # ddclient. # # chkconfig: 2345 65 35 # description: ddclient provides support for updating dynamic DNS services. [ -f /etc/ddclient/ddclient.conf ] || exit 0 . /etc/rc.d/init.d/functions # See how we were called. case "$1" in start) # Start daemon. echo -n "Starting ddclient: " touch /var/lock/subsys/ddclient daemon ddclient -daemon 300 echo ;; stop) # Stop daemon. echo -n "Shutting down ddclient: " killproc ddclient echo rm -f /var/lock/subsys/ddclient ;; restart) $0 stop $0 start ;; status) status ddclient ;; *) echo "Usage: ddclient {start|stop|restart|status}" exit 1 esac exit 0 ddclient-3.9.1/sample-etc_rc.d_init.d_ddclient.ubuntu000077500000000000000000000030001360532346300226320ustar00rootroot00000000000000#!/bin/sh ### BEGIN INIT INFO # Provides: ddclient # Required-Start: $remote_fs $syslog $network # Required-Stop: $remote_fs $syslog $network # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Start ddclient daemon at boot time # Description: Start ddclient that provides support for updating dynamic DNS services. Originally submitted by paolo martinelli, updated by joe passavanti ### END INIT INFO DDCLIENT=/usr/sbin/ddclient CONF=/etc/ddclient/ddclient.conf PIDFILE=/var/run/ddclient.pid test -x $DDCLIENT || exit 0 test -f $CONF || exit 0 . /lib/lsb/init-functions case "$1" in start) if [ ! -f $PIDFILE ]; then log_begin_msg "Starting ddclient..." DELAY=`grep -v '^\s*#' $CONF | grep -i -m 1 "daemon" | awk -F '=' '{print $2}'` if [ -z "$DELAY" ] ; then DELAY="-daemon 300" else DELAY='' fi start-stop-daemon -S -q -p $PIDFILE -x $DDCLIENT -- $DELAY log_end_msg $? else log_warning_msg "Service ddclient already running..." fi ;; stop) if [ -f $PIDFILE ] ; then log_begin_msg "Stopping ddclient..." start-stop-daemon -K -q -p $PIDFILE log_end_msg $? rm -f $PIDFILE else log_warning_msg "No ddclient running..." fi ;; restart|reload|force-reload) $0 stop $0 start ;; *) log_success_msg "Usage: $0 {start|stop|restart|reload|force-reload}" exit 1 ;; esac exit 0 ddclient-3.9.1/sample-etc_systemd.service000066400000000000000000000002731360532346300205050ustar00rootroot00000000000000[Unit] Description=Dynamic DNS Update Client After=network.target [Service] Type=forking PIDFile=/var/run/ddclient.pid ExecStart=/usr/sbin/ddclient [Install] WantedBy=multi-user.target ddclient-3.9.1/sample-get-ip-from-fritzbox000077500000000000000000000020521360532346300205160ustar00rootroot00000000000000#!/bin/bash # # Scirpt to fetch IP from fritzbox # # Contributed by @Rusk85 in request #45 # Script can be used in the configuration by adding # # use=cmd, cmd=/etc/ddclient/get-ip-from-fritzbox # # All credits for this one liner go to the author of this blog: # http://scytale.name/blog/2010/01/fritzbox-wan-ip # As the author explains its not required to tamper with the provided IP for the FritzBox # as it always binds to that address for UPnP. # Disclaimer: It might be necessary to make the script executable curl -s -H 'Content-Type: text/xml; charset="utf-8"' \ -H 'SOAPAction: urn:schemas-upnp-org:service:WANIPConnection:1#GetExternalIPAddress' \ -d ' ' \ 'http://fritz.box:49000/igdupnp/control/WANIPConn1' | \ grep -Eo '\<[[:digit:]]{1,3}(\.[[:digit:]]{1,3}){3}\>'