adds missing lines
This commit is contained in:
parent
a287740880
commit
e8565136a9
|
@ -1,5 +1,6 @@
|
|||
<?php
|
||||
|
||||
|
||||
// License Information /////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/*
|
||||
|
@ -96,9 +97,13 @@ peertracker::open();
|
|||
$_GET['info_hash'] = peertracker::$api->escape_sql($_GET['info_hash']);
|
||||
$_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
|
||||
// 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);
|
||||
|
||||
// track client
|
||||
|
|
|
@ -24,7 +24,8 @@
|
|||
// Configuration ///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// tracker state
|
||||
require('../mysql.config.php');
|
||||
require '../mysql.config.php';
|
||||
|
||||
// Tracker Operations //////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// fatal error, stop execution
|
||||
|
@ -366,20 +367,21 @@ class peertracker
|
|||
}
|
||||
|
||||
// insert new peer
|
||||
public static function new_peer()
|
||||
public static function new_peer($as_code, $country)
|
||||
{
|
||||
// insert peer
|
||||
self::$api->query(
|
||||
// insert into the peers table
|
||||
"INSERT IGNORE INTO `{$_SERVER['tracker']['db_prefix']}peers` " .
|
||||
// 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
|
||||
"VALUES ('{$_GET['info_hash']}', '{$_GET['peer_id']}', '" .
|
||||
// 6-byte compacted peer info
|
||||
self::$api->escape_sql(pack('Nn', ip2long($_GET['ip']), $_GET['port'])) . "', " .
|
||||
// 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');
|
||||
exit;
|
||||
}
|
||||
|
@ -454,7 +456,7 @@ class peertracker
|
|||
// client continuing download
|
||||
default:
|
||||
// new peer
|
||||
if (!isset($pState[2])) self::new_peer();
|
||||
if (!isset($pState[2])) self::new_peer($as_code, $country);
|
||||
// peer status
|
||||
elseif (
|
||||
// check that ip addresses match
|
||||
|
|
Loading…
Reference in New Issue
Block a user