Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

Code contribution for Sitelutions

Help
2005-10-30
2014-03-29
  • killerbobjr
    killerbobjr
    2005-10-30

    Here's my contribution for Sitelutions DynDNS.

    At the end of "my %services", add:

    ---- code starts ----

        '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'},
                            ),
        },

    ---- code ends ----

    then at the bottom of the file add:

    ---- code starts ----

    ######################################################################
    ## nic_sitelutions_examples
    ######################################################################
    sub nic_sitelutions_examples {
        return <<EoEXAMPLE;

    o 'sitelutions'

    The 'sitelutions' protocol is used by DNS services offered by www.sitelutions.com.

    Configuration variables applicable to the 'sitelutions' protocol are:
      protocol=sitelutions         ##
      server=fqdn.of.service       ## defaults to sitelutions.com
      login=service-login          ## login name and password  registered with the service
      password=service-password    ##
      A_record_id                  ## Id of the A record for the host registered with the service.

    Example ${program}.conf file entries:
      ## single host update
      protocol=sitelutions,                                         \\   login=my-sitelutions.com-login,                               \\   password=my-sitelutions.com-password                          \\   my-sitelutions.com-id_of_A_record

    EoEXAMPLE
    }
    ######################################################################
    ## nic_sitelutions_update
    ##
    ## written by Mike W. Smith
    ##
    ## based on http://www.sitelutions.com/help/dynamic_dns_clients#updatespec
    ## needs this url to update:
    ## https://www.sitelutions.com/dnsup?id=990331&user=myemail@mydomain.com&pass=SecretPass&ip=192.168.10.4
    ## domain=domain.com&password=domain_password&ip=your_ip
    ##
    ######################################################################
    sub nic_sitelutions_update {

        debug("\nnic_sitelutions_update -------------------");

        ## update each configured host
        foreach my $h (@_) {
            info("setting IP address to %s for %s", $ip, $h);
            verbose("UPDATE:","updating %s", $h);

            my $url;
            $url   = "http://$config{$h}{'server'}/dnsup";
            $url  .= "?id=$h";
            $url  .= "&user=$config{$h}{'login'}";
            $url  .= "&pass=$config{$h}{'password'}";
            $url  .= "&ip=";
            $url  .= $ip if $ip;

            my $reply = geturl(opt('proxy'), $url);
            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;
            if (grep /success/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);
            }
        }
    }

    ######################################################################

    ---- code ends ----

    Also a minor bug fix for the Namecheap code:

           my $url;
            $url   = "http://$config{$h}{'server'}/update";
            $url  .= "?domain=$config{$h}{'login'}";
            $url  .= "&host=$h";
            $url  .= "&password=$config{$h}{'password'}";
            $url  .= "&ip=";
            $url  .= $ip if $ip;

    is changed to:

            my $url;
            $url   = "http://$config{$h}{'server'}/update";
            $url  .= "?host=$config{$h}{'login'}";
            $url  .= "&domain=$h";
            $url  .= "&password=$config{$h}{'password'}";
            $url  .= "&ip=";
            $url  .= $ip if $ip;

    The Namecheap code is kind of screwy in that it doesn't let you update multiple A records within a single domain. I'd bother to fix it except Namecheap's DNS interface doesn't allow me to enter "*" (or "@" as they use it), so I can't test.

     
    • wimpunk
      wimpunk
      2005-11-01

      Can you post your modifications as a patch in the patches section?  Or send it directly to me.

      wimpunk.

       
    • killerbobjr
      killerbobjr
      2005-11-03

      >>  Can you post your modifications as a patch in the patches section?

      Done.

       
    • nog
      nog
      2014-03-29

      I suggest changing to https in:
      $url = "http://$config{$h}{'server'}/update";

      Otherwise, user/pass and the rest of the params are sent cleartext