use=web, use=<fw>: Strip HTTP headers before searching for IP

This commit is contained in:
Richard Hansen 2024-07-22 21:03:25 -04:00
parent b563e9c2fd
commit e272caa385
3 changed files with 15 additions and 1 deletions

View file

@ -131,6 +131,10 @@ repository history](https://github.com/ddclient/ddclient/commits/master).
[#713](https://github.com/ddclient/ddclient/pull/713) [#713](https://github.com/ddclient/ddclient/pull/713)
* `easydns`: Fixed successful updates treated as failed updates. * `easydns`: Fixed successful updates treated as failed updates.
[#713](https://github.com/ddclient/ddclient/pull/713) [#713](https://github.com/ddclient/ddclient/pull/713)
* Any IP addresses in an HTTP response's headers are now ignored when
obtaining the IP address from a web-based IP discovery service
(`--usev4=webv4`, `--usev6=webv6`) or from a router/firewall device.
[#719](https://github.com/ddclient/ddclient/pull/719)
## 2023-11-23 v3.11.2 ## 2023-11-23 v3.11.2

View file

@ -222,6 +222,7 @@ sub query_cisco {
ignore_ssl_option => 1, ignore_ssl_option => 1,
ssl_validate => opt('fw-ssl-validate', $h), ssl_validate => opt('fw-ssl-validate', $h),
) // ''; ) // '';
$reply =~ s/^.*?\n\n//s;
return $reply; return $reply;
} }
@ -2788,6 +2789,7 @@ sub get_ip {
url => $url, url => $url,
ssl_validate => opt('web-ssl-validate', $h), ssl_validate => opt('web-ssl-validate', $h),
) // ''; ) // '';
$reply =~ s/^.*?\n\n//s;
} }
} elsif ($use eq 'disabled') { } elsif ($use eq 'disabled') {
## This is a no-op... Do not get an IP address for this host/service ## This is a no-op... Do not get an IP address for this host/service
@ -2814,6 +2816,7 @@ sub get_ip {
ignore_ssl_option => 1, ignore_ssl_option => 1,
ssl_validate => opt('fw-ssl-validate', $h), ssl_validate => opt('fw-ssl-validate', $h),
) // ''; ) // '';
$reply =~ s/^.*?\n\n//s;
} }
} else { } else {
warning("ignoring unsupported '--use' strategy: $use"); warning("ignoring unsupported '--use' strategy: $use");
@ -3181,6 +3184,7 @@ sub get_ipv4 {
ipversion => 4, # when using a URL to find IPv4 address we should force use of IPv4 ipversion => 4, # when using a URL to find IPv4 address we should force use of IPv4
ssl_validate => opt('web-ssl-validate', $h), ssl_validate => opt('web-ssl-validate', $h),
) // ''; ) // '';
$reply =~ s/^.*?\n\n//s;
} }
} elsif ($usev4 eq 'disabled') { } elsif ($usev4 eq 'disabled') {
## This is a no-op... Do not get an IPv4 address for this host/service ## This is a no-op... Do not get an IPv4 address for this host/service
@ -3212,6 +3216,7 @@ sub get_ipv4 {
ignore_ssl_option => 1, ignore_ssl_option => 1,
ssl_validate => opt('fw-ssl-validate', $h), ssl_validate => opt('fw-ssl-validate', $h),
) // ''; ) // '';
$reply =~ s/^.*?\n\n//s;
} }
} else { } else {
warning("ignoring unsupported '--usev4' strategy: $usev4"); warning("ignoring unsupported '--usev4' strategy: $usev4");
@ -3289,6 +3294,7 @@ sub get_ipv6 {
ipversion => 6, # when using a URL to find IPv6 address we should force use of IPv6 ipversion => 6, # when using a URL to find IPv6 address we should force use of IPv6
ssl_validate => opt('web-ssl-validate', $h), ssl_validate => opt('web-ssl-validate', $h),
) // ''; ) // '';
$reply =~ s/^.*?\n\n//s;
} }
} elsif ($usev6 eq 'disabled') { } elsif ($usev6 eq 'disabled') {
$reply = ''; $reply = '';

View file

@ -27,7 +27,11 @@ sub run_httpd {
host => $ipv eq '4' ? '127.0.0.1' : '::1', host => $ipv eq '4' ? '127.0.0.1' : '::1',
daemon_args => {V6Only => 1}, daemon_args => {V6Only => 1},
); );
my $headers = ['content-type' => 'text/plain']; my $headers = [
'content-type' => 'text/plain',
'this-ipv4-should-be-ignored' => 'skip skip2 192.0.2.255',
'this-ipv6-should-be-ignored' => 'skip skip2 2001:db8::ff',
];
my $content = $ipv eq '4' my $content = $ipv eq '4'
? '192.0.2.1 skip 192.0.2.2 skip2 192.0.2.3' ? '192.0.2.1 skip 192.0.2.2 skip2 192.0.2.3'
: '2001:db8::1 skip 2001:db8::2 skip2 2001:db8::3'; : '2001:db8::1 skip 2001:db8::2 skip2 2001:db8::3';