From f5932d8be344a4e88eb3066234b4a1254e3b409b Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Sun, 2 Aug 2020 16:49:28 -0400 Subject: [PATCH] New `-list-web-services` option This will make it possible for the Debian package to fetch the list of supported built-in web-based IP discovery services and prompt the user to choose one upon installation. --- ddclient.in | 135 +++++++++++++++++++++++++++------------------------- 1 file changed, 70 insertions(+), 65 deletions(-) diff --git a/ddclient.in b/ddclient.in index 41818a44..38702b1e 100755 --- a/ddclient.in +++ b/ddclient.in @@ -884,92 +884,97 @@ my %opt = (); my $deprecated_handler = sub { warning("'-$_[0]' is deprecated and does nothing"); }; $opt{'fw-banlocal'} = $deprecated_handler; $opt{'if-skip'} = $deprecated_handler; +$opt{'list-web-services'} = sub { + printf("%s %s\n", $_, $builtinweb{$_}{url}) for sort(keys(%builtinweb)); + exit(0); +}; my @opt = ( "usage: ${program} [options]", "options are:", - ["daemon", "=s", "-daemon : run as a daemon, specify as an interval"], - ["foreground", "!", "-foreground : do not fork"], - ["proxy", "=s", "-proxy : use as the HTTP proxy"], - ["server", "=s", "-server : update DNS information on "], - ["protocol", "=s", "-protocol : update protocol used"], - ["file", "=s", "-file : load configuration information from "], - ["cache", "=s", "-cache : record address used in "], - ["pid", "=s", "-pid : record process id in if daemonized"], + ["daemon", "=s", "-daemon : run as a daemon, specify as an interval"], + ["foreground", "!", "-foreground : do not fork"], + ["proxy", "=s", "-proxy : use as the HTTP proxy"], + ["server", "=s", "-server : update DNS information on "], + ["protocol", "=s", "-protocol : update protocol used"], + ["file", "=s", "-file : load configuration information from "], + ["cache", "=s", "-cache : record address used in "], + ["pid", "=s", "-pid : record process id in if daemonized"], "", - ["use", "=s", "-use : deprecated, see 'usev4' and 'usev6'"], + ["use", "=s", "-use : deprecated, see 'usev4' and 'usev6'"], &ip_strategies_usage(), - [ "usev4", "=s", "-usev4 : how the should IPv4 address be obtained."], + [ "usev4", "=s", "-usev4 : how the should IPv4 address be obtained."], &ipv4_strategies_usage(), - [ "usev6", "=s", "-usev6 : how the should IPv6 address be obtained."], + [ "usev6", "=s", "-usev6 : how the should IPv6 address be obtained."], &ipv6_strategies_usage(), "", " Options that apply to 'use=ip':", - ["ip", "=s", "-ip
: deprecated, use 'ipv4' or 'ipv6'"], - ["ipv4", "=s", "-ipv4
: set the IPv4 address to
"], - ["ipv6", "=s", "-ipv6
: set the IPv6 address to
"], + ["ip", "=s", "-ip
: deprecated, use 'ipv4' or 'ipv6'"], + ["ipv4", "=s", "-ipv4
: set the IPv4 address to
"], + ["ipv6", "=s", "-ipv6
: set the IPv6 address to
"], "", " Options that apply to 'use=if':", - ["if", "=s", "-if : deprecated, use 'ifv4' or 'ifv6'"], - ["ifv4", "=s", "-ifv4 : obtain IPv4 address from "], - ["ifv6", "=s", "-ifv6 : obtain IPv6 address from "], + ["if", "=s", "-if : deprecated, use 'ifv4' or 'ifv6'"], + ["ifv4", "=s", "-ifv4 : obtain IPv4 address from "], + ["ifv6", "=s", "-ifv6 : obtain IPv6 address from "], "", " Options that apply to 'use=web':", - ["web", "=s", "-web | : deprecated, use 'webv4' or 'webv6'"], - ["web-skip", "=s", "-web-skip : deprecated, use 'webv4-skip' or 'webv6-skip'"], - ["webv4", "=s", "-webv4 |: obtain IPv4 address from a web-based IP discovery service, either a known or a custom "], - ["webv4-skip", "=s", "-webv4-skip : skip any IP addresses before in the output of 'ip address show dev ' (or 'ifconfig ')"], - ["webv6", "=s", "-webv6 |: obtain IPv6 address from a web-based IP discovery service, either a known or a custom "], - ["webv6-skip", "=s", "-webv6-skip : skip any IP addresses before in the output of 'ip address show dev ' (or 'ifconfig ')"], + ["web", "=s", "-web | : deprecated, use 'webv4' or 'webv6'"], + ["web-skip", "=s", "-web-skip : deprecated, use 'webv4-skip' or 'webv6-skip'"], + ["webv4", "=s", "-webv4 |: obtain IPv4 address from a web-based IP discovery service, either a known or a custom "], + ["webv4-skip", "=s", "-webv4-skip : skip any IP addresses before in the output of 'ip address show dev ' (or 'ifconfig ')"], + ["webv6", "=s", "-webv6 |: obtain IPv6 address from a web-based IP discovery service, either a known or a custom "], + ["webv6-skip", "=s", "-webv6-skip : skip any IP addresses before in the output of 'ip address show dev ' (or 'ifconfig ')"], + ["list-web-services", "", "-list-web-services : print a machine-readable list of web-based IP discovery services for use with 'web=' and exit. Format: one service per line, each line has the form ' '"], "", " Options that apply to 'use=fw' and 'use=':", - ["fw", "=s", "-fw
| : deprecated, use 'fwv4' or 'fwv6'"], - ["fw-skip", "=s", "-fw-skip : deprecated, use 'fwv4-skip' or 'fwv6-skip'"], - ["fwv4", "=s", "-fwv4
| : obtain IPv4 address from device with IP address
or URL "], - ["fwv4-skip", "=s", "-fwv4-skip : skip any IP addresses before in the text returned from the device"], - ["fwv6", "=s", "-fwv6
| : obtain IPv6 address from device with IP address
or URL "], - ["fwv6-skip", "=s", "-fwv6-skip : skip any IP addresses before in the text returned from the device"], - ["fw-login", "=s", "-fw-login : use when getting the IP from the device"], - ["fw-password", "=s", "-fw-password : use password when getting the IP from the device"], + ["fw", "=s", "-fw
| : deprecated, use 'fwv4' or 'fwv6'"], + ["fw-skip", "=s", "-fw-skip : deprecated, use 'fwv4-skip' or 'fwv6-skip'"], + ["fwv4", "=s", "-fwv4
| : obtain IPv4 address from device with IP address
or URL "], + ["fwv4-skip", "=s", "-fwv4-skip : skip any IP addresses before in the text returned from the device"], + ["fwv6", "=s", "-fwv6
| : obtain IPv6 address from device with IP address
or URL "], + ["fwv6-skip", "=s", "-fwv6-skip : skip any IP addresses before in the text returned from the device"], + ["fw-login", "=s", "-fw-login : use when getting the IP from the device"], + ["fw-password", "=s", "-fw-password : use password when getting the IP from the device"], "", " Options that apply to 'use=cmd':", - ["cmd", "=s", "-cmd : deprecated, use 'cmdv4' or 'cmdv6'"], - ["cmd-skip", "=s", "-cmd-skip : deprecated, filter in program wrapper script"], - ["cmdv4", "=s", "-cmdv4 : obtain IPv4 address from the output of "], - ["cmdv6", "=s", "-cmdv6 : obtain IPv6 address from the output of "], + ["cmd", "=s", "-cmd : deprecated, use 'cmdv4' or 'cmdv6'"], + ["cmd-skip", "=s", "-cmd-skip : deprecated, filter in program wrapper script"], + ["cmdv4", "=s", "-cmdv4 : obtain IPv4 address from the output of "], + ["cmdv6", "=s", "-cmdv6 : obtain IPv6 address from the output of "], "", - ["login", "=s", "-login : log in to the dynamic DNS service as "], - ["password", "=s", "-password : log in to the dynamic DNS service with password "], - ["host", "=s", "-host : update DNS information for "], + ["login", "=s", "-login : log in to the dynamic DNS service as "], + ["password", "=s", "-password : log in to the dynamic DNS service with password "], + ["host", "=s", "-host : update DNS information for "], "", - ["options", "=s", "-options =[,=,...]\n : optional per-service arguments (see below)"], + ["options", "=s", "-options =[,=,...]\n : optional per-service arguments (see below)"], "", - ["ssl", "!", "-{no}ssl : do updates over encrypted SSL connection"], - ["ssl_ca_dir", "=s", "-ssl_ca_dir : look in for certificates of trusted certificate authorities (default: auto-detect)"], - ["ssl_ca_file", "=s", "-ssl_ca_file : look at for certificates of trusted certificate authorities (default: auto-detect)"], - ["fw-ssl-validate","!", "-{no}fw-ssl-validate : Validate SSL certificate when retrieving IP address from firewall"], - ["web-ssl-validate","!","-{no}web-ssl-validate : Validate SSL certificate when retrieving IP address from web"], - ["curl", "!", "-{no}curl : use curl for network connections"], - ["retry", "!", "-{no}retry : retry failed updates"], - ["force", "!", "-{no}force : force an update even if the update may be unnecessary"], - ["timeout", "=i", "-timeout : when fetching a URL, wait at most seconds for a response"], - ["syslog", "!", "-{no}syslog : log messages to syslog"], - ["facility", "=s", "-facility : log messages to syslog to facility "], - ["priority", "=s", "-priority : log messages to syslog with priority "], - ["max-warn", "=i", "-max-warn : log at most warning messages for undefined IP address"], - ["mail", "=s", "-mail
: e-mail messages to
"], - ["mail-failure", "=s", "-mail-failure : e-mail messages for failed updates to "], - ["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"], - ["help", "", "-help : display this message and exit"], - ["postscript", "", "-postscript : script to run after updating ddclient, has new IP as param"], - ["query", "!", "-{no}query : print {no} ip addresses and exit"], - ["fw-banlocal", "!", ""], ## deprecated - ["if-skip", "=s", ""], ## deprecated - ["test", "!", ""], ## hidden - ["geturl", "=s", ""], ## hidden + ["ssl", "!", "-{no}ssl : do updates over encrypted SSL connection"], + ["ssl_ca_dir", "=s", "-ssl_ca_dir : look in for certificates of trusted certificate authorities (default: auto-detect)"], + ["ssl_ca_file", "=s", "-ssl_ca_file : look at for certificates of trusted certificate authorities (default: auto-detect)"], + ["fw-ssl-validate", "!", "-{no}fw-ssl-validate : Validate SSL certificate when retrieving IP address from firewall"], + ["web-ssl-validate", "!","-{no}web-ssl-validate : Validate SSL certificate when retrieving IP address from web"], + ["curl", "!", "-{no}curl : use curl for network connections"], + ["retry", "!", "-{no}retry : retry failed updates"], + ["force", "!", "-{no}force : force an update even if the update may be unnecessary"], + ["timeout", "=i", "-timeout : when fetching a URL, wait at most seconds for a response"], + ["syslog", "!", "-{no}syslog : log messages to syslog"], + ["facility", "=s", "-facility : log messages to syslog to facility "], + ["priority", "=s", "-priority : log messages to syslog with priority "], + ["max-warn", "=i", "-max-warn : log at most warning messages for undefined IP address"], + ["mail", "=s", "-mail
: e-mail messages to
"], + ["mail-failure", "=s", "-mail-failure : e-mail messages for failed updates to "], + ["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"], + ["help", "", "-help : display this message and exit"], + ["postscript", "", "-postscript : script to run after updating ddclient, has new IP as param"], + ["query", "!", "-{no}query : print {no} ip addresses and exit"], + ["fw-banlocal", "!", ""], ## deprecated + ["if-skip", "=s", ""], ## deprecated + ["test", "!", ""], ## hidden + ["geturl", "=s", ""], ## hidden "", nic_examples(), "$program version $version, ",