From 2a075aa4c80bc212a8c6267c56d12ce7ec41fe10 Mon Sep 17 00:00:00 2001 From: Johannes Dewender Date: Sun, 16 Nov 2014 23:41:32 +0100 Subject: [PATCH] ignore invalid ipv4 addresses We can't handle ipv6 addresses, so we ignore them if given as parameter. We use the IP of the remote given with the connection. That is either ipv4, when listening on ipv4 or it is not and we fail later. --- mysql/announce.php | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/mysql/announce.php b/mysql/announce.php index f871cfb..d9c0923 100644 --- a/mysql/announce.php +++ b/mysql/announce.php @@ -74,12 +74,21 @@ { // dotted decimal only $_GET['ip'] = trim($_GET['ip'],'::ffff:'); - if (!ip2long($_GET['ip'])) tracker_error('invalid ip, dotted decimal only'); + if (!ip2long($_GET['ip'])) { + unset($_GET['ip']); + //tracker_error('invalid ip, dotted decimal only'); + } +} +if (!isset($_GET['ip'])) +{ + // set ip to connected client + if (isset($_SERVER['REMOTE_ADDR'])) { + $_GET['ip'] = trim($_SERVER['REMOTE_ADDR'],'::ffff:'); + } else { + // cannot locate suitable ip, must abort + tracker_error('could not locate clients ip'); + } } -// set ip to connected client -elseif (isset($_SERVER['REMOTE_ADDR'])) $_GET['ip'] = trim($_SERVER['REMOTE_ADDR'],'::ffff:'); -// cannot locate suitable ip, must abort -else tracker_error('could not locate clients ip'); // integer - numwant - optional // number of peers that the client has requested @@ -108,4 +117,4 @@ // close database peertracker::close(); -?> \ No newline at end of file +?>