diff --git a/ChangeLog.md b/ChangeLog.md index d0ca95c..eea6429 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -41,6 +41,8 @@ repository history](https://github.com/ddclient/ddclient/commits/master). * The second and subsequent lines in a multi-line log message are now prefixed with a `|` character. [#676](https://github.com/ddclient/ddclient/pull/676) + * `emailonly`: New `protocol` option that simply emails you when your IP + address changes. [#654](https://github.com/ddclient/ddclient/pull/654) ### Bug fixes diff --git a/ddclient.conf.in b/ddclient.conf.in index 8652635..e916958 100644 --- a/ddclient.conf.in +++ b/ddclient.conf.in @@ -391,3 +391,9 @@ ssl=yes # use ssl-support. Works with # password=ddns_password # redirect=2 # example.com + +## +## Email Only +## +# protocol=emailonly +# host.example.com diff --git a/ddclient.in b/ddclient.in index c0fa54e..9ce0d1d 100755 --- a/ddclient.in +++ b/ddclient.in @@ -1067,6 +1067,18 @@ my %services = ( %{$variables{'service-common-defaults'}}, }, }, + 'emailonly' => { + 'updateable' => undef, + 'update' => \&nic_emailonly_update, + 'examples' => \&nic_emailonly_examples, + 'variables' => { + %{$variables{'service-common-defaults'}}, + 'login' => undef, + 'password' => undef, + # Change default to never re-notify if IP address has not changed. + 'max-interval' => setv(T_DELAY, 0, 0, 'inf', 0), + }, + }, ); # Delete undefined variables to make it easier to cancel previously defined variables. for my $svc (values(%services)) { @@ -8080,6 +8092,55 @@ sub nic_infomaniak_update { } } +###################################################################### +## nic_emailonly_update +## +## Written by Joel Croteau +## +## Do not update Dynamic DNS, only send status emails. Use if you do +## not have a DDNS host, but still want to get emails when your IP +## address changes. Note that you must set the "mail" config option +## and configure sendmail for this to have an effect. At least one +## host must be specified; the host names are mentioned in the email. +###################################################################### +sub nic_emailonly_update { + debug("\nnic_emailonly_update -------------------"); + # Note: This is logged after $config{$_}{'max-interval'] even if the IP address hasn't changed, + # so it is best to avoid phrasing like, "IP address has changed." + logmsg(email => 1, join("\n", 'Host IP addresses:', map({ + my $ipv4 = delete($config{$_}{'wantipv4'}); + my $ipv6 = delete($config{$_}{'wantipv6'}); + $config{$_}{'status-ipv4'} = 'good' if $ipv4; + $config{$_}{'status-ipv6'} = 'good' if $ipv6; + $config{$_}{'ipv4'} = $ipv4 if $ipv4; + $config{$_}{'ipv6'} = $ipv6 if $ipv6; + $config{$_}{'mtime'} = $now; + sprintf('%30s %s', $_, join(' ', grep(defined($_), $ipv4, $ipv6))); + } @_))); +} + +###################################################################### +## nic_emailonly_examples +###################################################################### +sub nic_emailonly_examples { + return <<"EoEXAMPLE"; +o 'emailonly' + +The 'emailonly' protocol is a dummy protocol that will send status emails but +not actually issue any dynamic DNS updates. You can use this if you don\'t +have a DDNS host, but still want to get emails when your IP address changes. +For this to have an effect, you must set the 'mail' config option, have +sendmail properly configured on your machine, and specify at least one dummy +hostname. + +Example ${program}.conf file entries: + ## single host update + mail=me\@example.com + protocol=emailonly + host.example.com +EoEXAMPLE +} + # Execute main() if this file is run as a script or run via PAR (https://metacpan.org/pod/PAR), # otherwise do nothing. This "modulino" pattern makes it possible to import this file as a module # and test its functions directly; there's no need for test-only command-line arguments or stdout