Skip to content

Commit 92e2b0c

Browse files
committed
Remove city and region
please delete data/geopeers.inc
1 parent 2b9ff6f commit 92e2b0c

4 files changed

Lines changed: 9 additions & 21 deletions

File tree

src/Config.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class Config {
2222
const RPC_PASSWORD = "PASSWORD";
2323

2424

25-
// Use ip-api.com to get country, city and isp of peers. API is limited to 150 requests per minutes.
25+
// Use ip-api.com to get country and isp of peers. API is limited to 150 requests per minutes.
2626
// Peer geo data is stored as long as the peer is connected. A page reload (main/peers) only
2727
// causes an API request if new peers connected (older than 2 minutes) since the last load. Up to
2828
// 100 ips/peers are checked per request. You should not run into any trouble with the API limit.

src/Peer.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@ class Peer{
3838
public $bytesrecvPerMsg; // array
3939
public $country; // string
4040
public $countryCode; // string
41-
public $region; // string
42-
public $city; // string
4341
public $isp; // string
4442
public $hosted; // bool
4543

src/Utility.php

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ function createPeersGeo($peerinfo){
501501
break;
502502
}
503503
// For removing old peers that disconnected. Value of all peers that are still conected will be changed to 1 later. All peers with 0 at the end of the function will be deleted.
504-
$arrayPeers[$key][7] = 0;
504+
$arrayPeers[$key][5] = 0;
505505
}
506506
// Oldest peer hasn't shown up -> Node isn't connected to any of the previously stored peers
507507
if(!$delete){
@@ -541,18 +541,14 @@ function createPeersGeo($peerinfo){
541541
$countryInfo = $ipData[array_search($peerObj->ip, array_column($ipData, 'query'))];
542542
$countryCode = checkCountryCode($countryInfo['countryCode']);
543543
$country = checkString($countryInfo['country']);
544-
$region = checkString($countryInfo['regionName']);
545-
$city = checkString($countryInfo['country']);
546544
$isp = checkString($countryInfo['isp']);
547545
$hosted = checkHosted($isp);
548546
// Adds the new peer to the save list
549-
$arrayPeers[$peerObj->id] = array($peerObj->ip, $countryCode, $country, $region, $city, $isp, $hosted, 1);
547+
$arrayPeers[$peerObj->id] = array($peerObj->ip, $countryCode, $country, $isp, $hosted, 1);
550548
}elseif($peerObj->age > 2){
551549
// If IP-Api.com call failed we set all data to Unknown and don't store the data
552550
$countryCode = "UN";
553551
$country = "Unknown";
554-
$region = "Unknown";
555-
$city = "Unknown";
556552
$isp = "Unknown";
557553
$hosted = false;
558554
// Only counted for peers older than 2 minutes
@@ -561,8 +557,6 @@ function createPeersGeo($peerinfo){
561557
// If peer is younger than 2 minutes
562558
$countryCode = "NX";
563559
$country = "New";
564-
$region = "New";
565-
$city = "New";
566560
$isp = "New";
567561
$hosted = false;
568562
}
@@ -575,11 +569,9 @@ function createPeersGeo($peerinfo){
575569
}
576570
$countryCode = $arrayPeers[$id][1];
577571
$country = $arrayPeers[$id][2];
578-
$region = $arrayPeers[$id][3];
579-
$city = $arrayPeers[$id][4];
580-
$isp = $arrayPeers[$id][5];
581-
$hosted = $arrayPeers[$id][6];
582-
$arrayPeers[$id][7] = 1;
572+
$isp = $arrayPeers[$id][3];
573+
$hosted = $arrayPeers[$id][4];
574+
$arrayPeers[$id][5] = 1;
583575
}
584576

585577
// Counts the countries
@@ -593,8 +585,6 @@ function createPeersGeo($peerinfo){
593585
// Adds country data to peer object
594586
$peerObj->countryCode = $countryCode;
595587
$peerObj->country = $country;
596-
$peerObj->region = $region;
597-
$peerObj->city = $city;
598588
$peerObj->isp = $isp;
599589
$peerObj->hosted = $hosted;
600590
if($hosted){
@@ -616,7 +606,7 @@ function createPeersGeo($peerinfo){
616606
if(isset($ipData)) {
617607
// Removes all peers that the node is not connected to anymore.
618608
foreach($arrayPeers as $key => $peer){
619-
if($peer[7] == 0){
609+
if($peer[5] == 0){
620610
unset($arrayPeers[$key]);
621611
}
622612
}
@@ -654,7 +644,7 @@ function getIpData($ips){
654644
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
655645
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
656646
curl_setopt($ch, CURLOPT_POST, true);
657-
curl_setopt($ch, CURLOPT_URL,'http://ip-api.com/batch?fields=query,country,countryCode,regionName,city,isp,status');
647+
curl_setopt($ch, CURLOPT_URL,'http://ip-api.com/batch?fields=query,country,countryCode,isp,status');
658648
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));
659649
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT , CONFIG::PEERS_GEO_TIMEOUT);
660650
curl_setopt($ch, CURLOPT_TIMEOUT, CONFIG::PEERS_GEO_TIMEOUT+1);

views/settings.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
</div>
3232
<div class="x_content">
3333

34-
<div class="alert alert-warning" role="alert">If Geo Tracing is activated, <b>ip-api.com</b> is used to determine peer geo data (ISP, Country and City). For each new peer the data is requested
34+
<div class="alert alert-warning" role="alert">If Geo Tracing is activated, <b>ip-api.com</b> is used to determine peer geo data (ISP and Country). For each new peer the data is requested
3535
once and stored as long as the peer is connected. The API is limited to 150 requests per minute (Up to 100 IPs per request). Page reloads have almost no effect on the limit since peer geo data is temporarily stored.
3636
Therefore it is highly unlikley to run in any troubles.<br /><br /></div>
3737

0 commit comments

Comments
 (0)