diff --git a/xtr.pl b/xtr.pl index 10efdfa..2e81b4d 100644 --- a/xtr.pl +++ b/xtr.pl @@ -10,7 +10,7 @@ use Socket; use DBI; use File::Fetch; use PerlIO::gzip; -use LWP::UserAgent; +use HTTP::Tiny; use HTTP::Request; use Data::Validate::IP qw(is_ipv4); use Data::Dumper; @@ -31,6 +31,10 @@ use Data::Dumper; ### CHANGELOG ###################################################################################################################################### +# v0.6 (2019-08-22) +# * FIX: replaced bug-driven LWP::* with HTTP::Tiny +# * FIX: client_protocol_version moved from "3" to "4" +# # v0.5 (2019-08-18) # * FIX: dropped "timeout" option of Net::Traceroute (details -> https://rt.cpan.org/Ticket/Display.html?id=107066) # * FIX: altered dependency on which an output will be send ("$tr->found" -> "$tr->hops > 1") @@ -62,12 +66,12 @@ use Data::Dumper; ### VARS ########################################################################################################################################### -my $VERSION = "0.5"; +my $VERSION = "0.6"; my $dbfile = 'ip2asn.db'; my $ip2asn_csv_url = 'http://iptoasn.com/data/ip2asn-v4-u32.tsv.gz'; my $master_server = 'xtr-master.xicon.eu'; my $get_my_ip_service = 'http://ipv4.xicon.eu/'; # some service, which returns just the ip of the requesting host (in this case, us.) -my $client_protocol_version = 3; +my $client_protocol_version = 4; my $my_ip = get_my_ipv4($get_my_ip_service); my $my_ext_ip = ""; # set different ip, if access differs from default public ip my $my_port = 12111; @@ -136,20 +140,19 @@ sub send_server_status { my ($master_server,$hostname,$port,$status) = @_; my $url = "http://".$master_server."/v3/server/add/".$hostname."/".$port."/".$status; - my $ua = LWP::UserAgent->new(timeout => 2); - my $req = HTTP::Request->new("PUT", $url); - my $response = $ua->request($req); - return $response->is_success; + my $httptiny = HTTP::Tiny->new("timeout" => 10); + my $response = $httptiny->request("PUT",$url); + return $response->{'success'}; } sub get_my_ipv4 { my ($ip_service) = @_; - my $ua = LWP::UserAgent->new(timeout => 10); - my $response = $ua->get($ip_service); - if(is_ipv4($response->decoded_content)) + my $httptiny = HTTP::Tiny->new("timeout" => 10); + my $response = $httptiny->request("GET",$ip_service); + if(is_ipv4($response->{'content'})) { - return $response->decoded_content; + return $response->{'content'}; } else {