v6
This commit is contained in:
parent
b8fbb97679
commit
64b95749cf
25
xtr.pl
25
xtr.pl
@ -10,7 +10,7 @@ use Socket;
|
|||||||
use DBI;
|
use DBI;
|
||||||
use File::Fetch;
|
use File::Fetch;
|
||||||
use PerlIO::gzip;
|
use PerlIO::gzip;
|
||||||
use LWP::UserAgent;
|
use HTTP::Tiny;
|
||||||
use HTTP::Request;
|
use HTTP::Request;
|
||||||
use Data::Validate::IP qw(is_ipv4);
|
use Data::Validate::IP qw(is_ipv4);
|
||||||
use Data::Dumper;
|
use Data::Dumper;
|
||||||
@ -31,6 +31,10 @@ use Data::Dumper;
|
|||||||
|
|
||||||
|
|
||||||
### CHANGELOG ######################################################################################################################################
|
### 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)
|
# v0.5 (2019-08-18)
|
||||||
# * FIX: dropped "timeout" option of Net::Traceroute (details -> https://rt.cpan.org/Ticket/Display.html?id=107066)
|
# * 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")
|
# * FIX: altered dependency on which an output will be send ("$tr->found" -> "$tr->hops > 1")
|
||||||
@ -62,12 +66,12 @@ use Data::Dumper;
|
|||||||
|
|
||||||
|
|
||||||
### VARS ###########################################################################################################################################
|
### VARS ###########################################################################################################################################
|
||||||
my $VERSION = "0.5";
|
my $VERSION = "0.6";
|
||||||
my $dbfile = 'ip2asn.db';
|
my $dbfile = 'ip2asn.db';
|
||||||
my $ip2asn_csv_url = 'http://iptoasn.com/data/ip2asn-v4-u32.tsv.gz';
|
my $ip2asn_csv_url = 'http://iptoasn.com/data/ip2asn-v4-u32.tsv.gz';
|
||||||
my $master_server = 'xtr-master.xicon.eu';
|
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 $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_ip = get_my_ipv4($get_my_ip_service);
|
||||||
my $my_ext_ip = ""; # set different ip, if access differs from default public ip
|
my $my_ext_ip = ""; # set different ip, if access differs from default public ip
|
||||||
my $my_port = 12111;
|
my $my_port = 12111;
|
||||||
@ -136,20 +140,19 @@ sub send_server_status
|
|||||||
{
|
{
|
||||||
my ($master_server,$hostname,$port,$status) = @_;
|
my ($master_server,$hostname,$port,$status) = @_;
|
||||||
my $url = "http://".$master_server."/v3/server/add/".$hostname."/".$port."/".$status;
|
my $url = "http://".$master_server."/v3/server/add/".$hostname."/".$port."/".$status;
|
||||||
my $ua = LWP::UserAgent->new(timeout => 2);
|
my $httptiny = HTTP::Tiny->new("timeout" => 10);
|
||||||
my $req = HTTP::Request->new("PUT", $url);
|
my $response = $httptiny->request("PUT",$url);
|
||||||
my $response = $ua->request($req);
|
return $response->{'success'};
|
||||||
return $response->is_success;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub get_my_ipv4
|
sub get_my_ipv4
|
||||||
{
|
{
|
||||||
my ($ip_service) = @_;
|
my ($ip_service) = @_;
|
||||||
my $ua = LWP::UserAgent->new(timeout => 10);
|
my $httptiny = HTTP::Tiny->new("timeout" => 10);
|
||||||
my $response = $ua->get($ip_service);
|
my $response = $httptiny->request("GET",$ip_service);
|
||||||
if(is_ipv4($response->decoded_content))
|
if(is_ipv4($response->{'content'}))
|
||||||
{
|
{
|
||||||
return $response->decoded_content;
|
return $response->{'content'};
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user