adds missing lines
This commit is contained in:
parent
a287740880
commit
e8565136a9
|
@ -1,5 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
|
||||||
// License Information /////////////////////////////////////////////////////////////////////////////
|
// License Information /////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -96,9 +97,13 @@ peertracker::open();
|
||||||
$_GET['info_hash'] = peertracker::$api->escape_sql($_GET['info_hash']);
|
$_GET['info_hash'] = peertracker::$api->escape_sql($_GET['info_hash']);
|
||||||
$_GET['peer_id'] = peertracker::$api->escape_sql($_GET['peer_id']);
|
$_GET['peer_id'] = peertracker::$api->escape_sql($_GET['peer_id']);
|
||||||
|
|
||||||
|
$json = file_get_contents("http://localhost:4567/as_info/{$_GET['ip']}.json");
|
||||||
|
$parsed_json = json_decode($json);
|
||||||
|
$as_code = $parsed_json->{'country'};
|
||||||
|
$country = $parsed_json->{'as_code'};
|
||||||
|
|
||||||
// announce peers
|
// announce peers
|
||||||
// need to pass as_code and country
|
// need to pass as_code and country
|
||||||
$json = file_get_contents("http://localhost:4567/as_info/123.123.123.123.json");
|
|
||||||
peertracker::peers($as_code, $country);
|
peertracker::peers($as_code, $country);
|
||||||
|
|
||||||
// track client
|
// track client
|
||||||
|
|
|
@ -24,7 +24,8 @@
|
||||||
// Configuration ///////////////////////////////////////////////////////////////////////////////////
|
// Configuration ///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
// tracker state
|
// tracker state
|
||||||
require('../mysql.config.php');
|
require '../mysql.config.php';
|
||||||
|
|
||||||
// Tracker Operations //////////////////////////////////////////////////////////////////////////////
|
// Tracker Operations //////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
// fatal error, stop execution
|
// fatal error, stop execution
|
||||||
|
@ -366,20 +367,21 @@ class peertracker
|
||||||
}
|
}
|
||||||
|
|
||||||
// insert new peer
|
// insert new peer
|
||||||
public static function new_peer()
|
public static function new_peer($as_code, $country)
|
||||||
{
|
{
|
||||||
// insert peer
|
// insert peer
|
||||||
self::$api->query(
|
self::$api->query(
|
||||||
// insert into the peers table
|
// insert into the peers table
|
||||||
"INSERT IGNORE INTO `{$_SERVER['tracker']['db_prefix']}peers` " .
|
"INSERT IGNORE INTO `{$_SERVER['tracker']['db_prefix']}peers` " .
|
||||||
// table columns
|
// table columns
|
||||||
'(info_hash, peer_id, compact, ip, port, state, updated) ' .
|
'(info_hash, peer_id, compact, ip, port, state, as_code, country, updated)' .
|
||||||
// 20-byte info_hash, 20-byte peer_id
|
// 20-byte info_hash, 20-byte peer_id
|
||||||
"VALUES ('{$_GET['info_hash']}', '{$_GET['peer_id']}', '" .
|
"VALUES ('{$_GET['info_hash']}', '{$_GET['peer_id']}', '" .
|
||||||
// 6-byte compacted peer info
|
// 6-byte compacted peer info
|
||||||
self::$api->escape_sql(pack('Nn', ip2long($_GET['ip']), $_GET['port'])) . "', " .
|
self::$api->escape_sql(pack('Nn', ip2long($_GET['ip']), $_GET['port'])) . "', " .
|
||||||
// dotted decimal string ip, integer port, integer state and unix timestamp updated
|
// dotted decimal string ip, integer port, integer state and unix timestamp updated
|
||||||
"'{$_GET['ip']}', {$_GET['port']}, {$_SERVER['tracker']['seeding']}, " . time() . '); '
|
"'{$_GET['ip']}', {$_GET['port']}, {$_SERVER['tracker']['seeding']}, " .
|
||||||
|
"'{$as_code}', '{$country}', " . time() . ');'
|
||||||
) OR tracker_error('failed to add new peer data');
|
) OR tracker_error('failed to add new peer data');
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
@ -454,7 +456,7 @@ class peertracker
|
||||||
// client continuing download
|
// client continuing download
|
||||||
default:
|
default:
|
||||||
// new peer
|
// new peer
|
||||||
if (!isset($pState[2])) self::new_peer();
|
if (!isset($pState[2])) self::new_peer($as_code, $country);
|
||||||
// peer status
|
// peer status
|
||||||
elseif (
|
elseif (
|
||||||
// check that ip addresses match
|
// check that ip addresses match
|
||||||
|
|
Loading…
Reference in New Issue
Block a user