#!/usr/bin/perl -w use strict; use vars qw($myip $firewall $target $username $password $version); use vars qw($pass $url $sock @result $result $code); # YOUR hn.org name and password go here. $username = "yourname"; $password = "yourpass"; # If you're behind a firewall or HTTP proxy, set this to 1. # If you're not sure, set it to 1; that's the safer setting anyway. # If you KNOW you're not behind a firewall or proxy, set to 0. $firewall = 1; # Okay, that's all you'll need to configure *here*. You're not done, # though... You still need to configure this to run automatically, and to # use the correct IP address. For Linux users with pppd, the easiest way # to put a line like this in /etc/ppp/ip-up : # # /usr/local/sbin/hammernode.pl $4 # # If that doesn't make much sense, see `man pppd' which details what # parameters pppd sends to ip-up. # # A clever trick for dhcpcd users... put this in your # /etc/dhcpcd/dhcpcd-eth0.exe file: # # source /etc/dhcpc/dhcpcd-eth0.info && /usr/local/sbin/hammernode.pl $IPADDR # # (I discovered this was necessary -- my cable modem company puts an # "invisible" HTTP proxy in between me and the 'net, and my domains were # being assigned the address of the proxy. # # (C)2000-2001 David E. Smith and released to the # public under the terms of the GNU General Public License. # # Modified by Daniel Hagan on 4/2001 to use IO::Socket, # Syslog, and some error checking. Now logs all output to daemon facility. # # Other changes made/suggested by Aurelien Beaujean # Sorry, but I can't type the accent over the first "e" in Aurelien. # ############### use MIME::Base64 (); use Sys::Syslog qw(:DEFAULT setlogsock); use IO::Socket; # If you don't let syslogd listen on an inet port, uncomment this line. # #setlogsock 'unix'; openlog ("hammernode", 'pid', 'daemon'); $myip = shift; if ($firewall && !$myip) { syslog ('err', "FATAL: IP required as command line argument when \$firewall is set to true."); exit(1); } $target = "dup.hn.org"; $version = "v0.22pl0"; $pass = MIME::Base64::encode_base64("$username:$password"); if ($firewall == 1) { $url = "/vanity/update/?VER=1&IP=$myip" ; } else { $url = "/vanity/update/?VER=1" ; } syslog ('info', 'Setting domain to %s.', $myip); $sock = new IO::Socket::INET( PeerAddr => "$target", PeerPort => 'http(80)' ); if (!$sock) { syslog('err', "FATAL: Connect to $target, port 80, failed: %m"); exit(1); } $sock->autoflush(1); $sock->print("GET $url HTTP/1.0\r\n"); $sock->print("User-Agent: hammenode.pl $version\r\n"); $sock->print("Host: $target\r\n"); $sock->print("Authorization: Basic $pass\r\n\r\n"); # Legacy sleep from v0.21pl2. May be necessary on some slow PC platforms. # If you are having problems, try uncommenting this first. # #sleep 5; @result = $sock->getlines(); undef $sock; #Close the socket $result = join '', @result; $result =~ m/DDNS_Response_Code=(\d+)/i; $code = $1; if ($code == 101) { syslog ('info', "Succeeded in setting domain to $myip."); exit(0); } else { syslog ('notice', "Received DDNS Reponse Code $code, probably failed."); exit(1); }