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.
This commit is contained in:
Johannes Dewender 2014-11-16 23:41:32 +01:00
parent 4b12f2f6cf
commit 2a075aa4c8

View File

@ -74,12 +74,21 @@ if (isset($_GET['ip']) && $_SERVER['tracker']['external_ip'])
{ {
// dotted decimal only // dotted decimal only
$_GET['ip'] = trim($_GET['ip'],'::ffff:'); $_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 // integer - numwant - optional
// number of peers that the client has requested // number of peers that the client has requested