diff --git a/ddclient.in b/ddclient.in index 5e4759e..9a8e442 100755 --- a/ddclient.in +++ b/ddclient.in @@ -555,6 +555,16 @@ my %services = ( 'server' => setv(T_FQDNP, 1, 0, 'nic.changeip.com', undef), }, }, + 'cdmon' => { + 'updateable' => undef, + 'update' => \&dinamico_cdmon_update, + 'examples' => \&dinamico_cdmon_examples, + 'variables' => merge( + { 'server' => setv(T_FQDNP, 1, 0, 1, 'dinamico.cdmon.org', undef) }, + { 'min-interval' => setv(T_DELAY, 0, 0, 1, 0, interval('5m')),}, + $variables{'service-common-defaults'}, + ), + }, 'cloudflare' => { 'updateable' => undef, 'update' => \&nic_cloudflare_update, @@ -5450,6 +5460,153 @@ sub nic_1984_update { } } } +###################################################################### +## dinamico_cdmon_examples +###################################################################### +sub dinamico_cdmon_examples { +return <{$k} ) { + if( 'ARRAY' eq ref $params->{$k} ) { + push @{ $params->{$k} }, $v; + } else { + $params->{$k} = [ $params->{$k}, $v ]; + } + } else { + $params->{$k} = $v; + } + } + + if (exists $params->{'resultat'}) { + if ($params->{'resultat'} eq 'guardatok' || $params->{'resultat'} eq 'customok') { + # &resultat=guardatok&newip=x.x.x.x& + # Cuando se hace una petición sin la variable cip y la autentificación ha sido correcta, se nos devuelve la IP actual que detecta el servidor. + # When a request is made without the cip variable and the authentication has been correct, the current IP detected by the server is returned. + + # &resultat=customok&newip=x.x.x.x&customip=x.x.x.x&temps=1200000& + # Cuando hemos mandado nuestra IP mediante la variable cip y la autentificación ha sido satisfactoria. + # When we have sent our IP through the cip variable and the authentication has been successful. + + # &resultat=guardatok&temps=1200000 + # Nos devuelve este resultado, para informarnos que se ha guardado bien la configuración y que los cambios no estarán operativos hasta pasados 20 minutos. + # It returns this result, to inform us that the configuration has been saved correctly and that the changes will not be operational until after 20 minutes. + + my $newip = $ip; + my $msg; + $msg = sprintf "updating %s: good", $h; + + if (exists $params->{'customip'}) { + $msg .= sprintf " : sent IP address %s", $params->{'customip'}; + } else { + $msg .= sprintf " : sent IP address %s", $ip; + } + + if (exists $params->{'newip'}) {$newip = $params->{'newip'}; $msg .= sprintf " :IP address set to newip:%s", $newip;} + if (exists $params->{'temps'}) {$msg .= sprintf ", the changes will not be operational until after %d minutes", int(int($params->{'temps'})/60000);} + + #$config{$h}{'ip'} = $ip; + $config{$h}{'ip'} = $newip; + $config{$h}{'mtime'} = $now; + $config{$h}{'status'} = 'good'; + success("%s.", $msg); + + } elsif ($params->{'resultat'} eq 'badip') { + # &resultat=badip& + # Nos devuelve este resultado cuando la autentificación ha sido satisfactoria pero la IP es errónea. + # It returns this result when the authentication has been successful but the IP is wrong. + $config{$h}{'status'} = 'failed'; + warning("SENT: %s", $url) unless opt('verbose'); + warning("REPLIED: %s", $reply); + failed("Not updating %s: The IP address is not valid. ==> %s", $h, $result); + } elsif ($params->{'resultat'} eq 'errorlogin') { + # &resultat=errorlogin& + # Nos devuelve este resultado cuando la autentificación no ha sido satisfactoria. + # It returns this result when the authentication has not been successful. The username or password is incorrect. + $config{$h}{'status'} = 'failed'; + warning("SENT: %s", $url) unless opt('verbose'); + warning("REPLIED: %s", $reply); + failed("Not updating %s: The username or password is incorrect. ==> %s", $h, $result); + } elsif ($params->{'resultat'} eq 'novaversio') { + # &resultat=novaversio& + # Nos devuelve este resultado en raras ocasiones, sólo cuando modificamos el archivo que procesa todas las peticiones para obligar a todos los usuarios a actualizar a una nueva versión de la aplicación. En su caso sólo tendrá que ponerse en contacto con nosotros para obtener la nueva URL para hacer la petición. + # It returns this result on rare occasions, only when we modify the file that processes all requests to force all users to upgrade to a new version of the application. In your case, you will only have to contact us to obtain the new URL to make the request. + $config{$h}{'status'} = 'failed'; + warning("SENT: %s", $url) unless opt('verbose'); + warning("REPLIED: %s", $reply); + failed("Not updating %s: Update to a new version of the application API. ==> %s", $h, $result); + } else { + $config{$h}{'status'} = 'failed'; + warning("SENT: %s", $url) unless opt('verbose'); + warning("REPLIED: %s", $reply); + failed("Not updating %s: Unknown return parameters. ==> %s", $h, $result); + } + + debug("Exist"); + } else { + failed("updating %s: Invalid resultat.'%s'", $h, $result); + } + } +} ###################################################################### ## nic_changeip_examples