mirror of
https://github.com/vincentmli/bpfire.git
synced 2026-04-28 11:43:25 +02:00
DDNS: Send proper user agent.
This commit is contained in:
@@ -857,10 +857,11 @@ sub FetchPublicIp {
|
|||||||
my ($peer, $peerport) = (/^(?:[a-zA-Z ]+\:\/\/)?(?:[A-Za-z0-9\_\.\-]*?(?:\:[A-Za-z0-9\_\.\-]*?)?\@)?([a-zA-Z0-9\.\_\-]*?)(?:\:([0-9]{1,5}))?(?:\/.*?)?$/);
|
my ($peer, $peerport) = (/^(?:[a-zA-Z ]+\:\/\/)?(?:[A-Za-z0-9\_\.\-]*?(?:\:[A-Za-z0-9\_\.\-]*?)?\@)?([a-zA-Z0-9\.\_\-]*?)(?:\:([0-9]{1,5}))?(?:\/.*?)?$/);
|
||||||
Net::SSLeay::set_proxy($peer,$peerport,$proxysettings{'UPSTREAM_USER'},$proxysettings{'UPSTREAM_PASSWORD'} );
|
Net::SSLeay::set_proxy($peer,$peerport,$proxysettings{'UPSTREAM_USER'},$proxysettings{'UPSTREAM_PASSWORD'} );
|
||||||
}
|
}
|
||||||
|
my $user_agent = &MakeUserAgent();
|
||||||
my ($out, $response) = Net::SSLeay::get_http( 'checkip.dns.lightningwirelabs.com',
|
my ($out, $response) = Net::SSLeay::get_http( 'checkip.dns.lightningwirelabs.com',
|
||||||
80,
|
80,
|
||||||
"/",
|
"/",
|
||||||
Net::SSLeay::make_headers('User-Agent' => 'IPFire' )
|
Net::SSLeay::make_headers('User-Agent' => $user_agent )
|
||||||
);
|
);
|
||||||
if ($response =~ m%HTTP/1\.. 200 OK%) {
|
if ($response =~ m%HTTP/1\.. 200 OK%) {
|
||||||
$out =~ /Your IP address is: (\d+.\d+.\d+.\d+)/;
|
$out =~ /Your IP address is: (\d+.\d+.\d+.\d+)/;
|
||||||
@@ -980,4 +981,29 @@ sub GetIcmpDescription ($) {
|
|||||||
'Experimental');
|
'Experimental');
|
||||||
if ($index>41) {return 'unknown'} else {return @icmp_description[$index]};
|
if ($index>41) {return 'unknown'} else {return @icmp_description[$index]};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub GetCoreUpdateVersion() {
|
||||||
|
my $core_update;
|
||||||
|
|
||||||
|
open(FILE, "/opt/pakfire/db/core/mine");
|
||||||
|
while (<FILE>) {
|
||||||
|
$core_update = $_;
|
||||||
|
last;
|
||||||
|
}
|
||||||
|
close(FILE);
|
||||||
|
|
||||||
|
return $core_update;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub MakeUserAgent() {
|
||||||
|
my $user_agent = "IPFire/$General::version";
|
||||||
|
|
||||||
|
my $core_update = &GetCoreUpdateVersion();
|
||||||
|
if ($core_update ne "") {
|
||||||
|
$user_agent .= "/$core_update";
|
||||||
|
}
|
||||||
|
|
||||||
|
return $user_agent;
|
||||||
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|||||||
@@ -260,9 +260,10 @@ if ($ip ne $ipcache) {
|
|||||||
$authstring = "username=$settings{'LOGIN'}&password=$settings{'PASSWORD'}";
|
$authstring = "username=$settings{'LOGIN'}&password=$settings{'PASSWORD'}";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
my $user_agent = &General::MakeUserAgent();
|
||||||
my ($out, $response) = Net::SSLeay::get_https("dns.lightningwirelabs.com", 443,
|
my ($out, $response) = Net::SSLeay::get_https("dns.lightningwirelabs.com", 443,
|
||||||
"/update?hostname=$settings{'HOSTDOMAIN'}&address4=$ip&$authstring",
|
"/update?hostname=$settings{'HOSTDOMAIN'}&address4=$ip&$authstring",
|
||||||
Net::SSLeay::make_headers('User-Agent' => 'IPFire')
|
Net::SSLeay::make_headers('User-Agent' => $user_agent)
|
||||||
);
|
);
|
||||||
|
|
||||||
# Valid response are 'ok' 'nochange'
|
# Valid response are 'ok' 'nochange'
|
||||||
|
|||||||
Reference in New Issue
Block a user