From 9e1bdea2caa04787626637dda00b03fc070dddfe Mon Sep 17 00:00:00 2001 From: XiCoN-FJS- Date: Tue, 14 Apr 2020 02:12:27 +0200 Subject: [PATCH] Added Maxmind's TOS * FIX: Maxmind now allows redistributing GeoLite2-ASN database if requirements are fulfilled (https://git.xicon.eu/xicon/xtr/issues/3) * ADD: Maxmind's TOS added as start-up message --- README.md | 11 ++++++++--- xtrd.pl | 47 +++++++++++++++++++++++++++++++++++------------ 2 files changed, 43 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index e9a2b7f..b2bcd25 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,14 @@ # xtr -This is the server for the XTR (XiCoN Trace Route). It's more of a master browser for the clients, so an web frontend can get a list of all the available clients combined from one auto-updated source. It opens a port and listening to HTTP requests (GET and PUT). It can list all online and offline clients. It also accepts new client entries via a PUT request (target client address in database has to be the request ip). +This is the server for the XTR (XiCoN Trace Route). It's more of a master browser for the clients, so an web frontend can get a list of all the +available clients combined from one auto-updated source. It opens a port and listening to HTTP requests (GET and PUT). It can list all online and +offline clients. It also accepts new client entries via a PUT request (target client address in database has to be the request ip). The server keeps the list of clients up2date with checking their availablity with each request of all online clients. +For now, only IPv4 clients are supported. This will change in the future. -This software uses the iptoasn database (https://iptoasn.com/) to determine the AS for each client. To keep track of all ip to asn relations, this software creates a local database file "ip2asn.db", which is a simple SQLite3 database with an index for faster searches. +This software uses the MaxMind GeoLite2 database (https://www.maxmind.com) to determine the AS for each hop. To lookup the AS information the script +uses the MaxMind perl module which uses the MaxMind DB library. -For now, only IPv4 clients are supported. This will change in the future. \ No newline at end of file + +This product includes GeoLite2 ASN data created by MaxMind, available from http://www.maxmind.com. diff --git a/xtrd.pl b/xtrd.pl index b2f995a..02264ad 100644 --- a/xtrd.pl +++ b/xtrd.pl @@ -6,7 +6,6 @@ use Dancer2; use Socket; use DBI; use File::Fetch; -use PerlIO::gzip; use HTTP::Tiny; use HTTP::Request; use Data::Validate::Domain qw(is_domain); @@ -22,15 +21,21 @@ use Data::Dumper; # offline clients. It also accepts new client entries via a PUT request (target client address in database has to be the request ip). # # The server keeps the list of clients up2date with checking their availablity with each request of all online clients. -# -# This software uses the iptoasn database (https://iptoasn.com/) to determine the AS for each client. To keep track of all ip to asn relations, -# this software creates a local database file "ip2asn.db", which is a simple SQLite3 database with an index for faster searches. -# # For now, only IPv4 clients are supported. This will change in the future. +# +# This software uses the MaxMind GeoLite2 database (https://www.maxmind.com) to determine the AS for each hop. To lookup the AS information the script +# uses the MaxMind perl module which uses the MaxMind DB library. +# +# +# This product includes GeoLite2 ASN data created by MaxMind, available from http://www.maxmind.com. ###################################################################################################################################################### ### CHANGELOG ###################################################################################################################################### +# v0.5 (2020-04-14) +# * FIX: Maxmind now allows redistributing GeoLite2-ASN database if requirements are fulfilled (https://git.xicon.eu/xicon/xtr/issues/3) +# * ADD: Maxmind's TOS added as start-up message +# # v0.4 (2019-08-22) # * ADD: added better documentation # * ADD: list of API commands via API @@ -46,20 +51,27 @@ use Data::Dumper; # Either install all listed modules with "cpan -i " or use your system's package manager (apt, yum, yast). # # On Debian just install there packages: -# libperlio-gzip-perl -# libdancer2-perl -# libdbi-perl -# libdbd-sqlite3-perl -# libdata-validate-ip-perl +# screen +# libperlio-gzip-perl +# libdancer2-perl +# libdbi-perl +# libdbd-sqlite3-perl +# libdata-validate-ip-perl +# build-essential +# cpanminus +# libmaxminddb0 +# libmaxminddb-dev +# +# After that, execute this command to install maxmind database reader module: +# cpanm -q -n MaxMind::DB::Reader::XS # ###################################################################################################################################################### ### VARS ############################################################################################################################################# my $dbfile = 'xtrd.db'; -my $ip2asn_csv_url = 'http://iptoasn.com/data/ip2asn-v4-u32.tsv.gz'; my $max_dbfile = 'GeoLite2-ASN.mmdb'; -my $max_db_source = 'http://geolite.maxmind.com/download/geoip/database/GeoLite2-ASN.tar.gz'; +my $max_db_source = 'http://xtr.xicon.eu/GeoLite2-ASN.tar.gz'; my $server_protocol_version = 3; my $min_client_version = 4; set port => 12110; @@ -350,3 +362,14 @@ sub create_db_table return 0; } } + +sub print_maxmind_tos +{ + print qq{ --------------------------------------------------------------------------------------------------------------------------------------- }; + print "\n"; + print qq{ This product includes GeoLite2 ASN data created by MaxMind, available from http://www.maxmind.com. }; + print "\n"; + print qq{ --------------------------------------------------------------------------------------------------------------------------------------- }; + print "\n"; + print "\n"; +} \ No newline at end of file