Browse Source

hide remote peer IP for third-party connections #2

yggdrasil-0.4.7
ghost 1 year ago
parent
commit
c3c2a106a7
  1. 5
      README.md
  2. 12
      src/config/app.php.example
  3. 39
      src/crontab/crawler.php
  4. 8
      src/public/assets/theme/default/css/framework.css
  5. 18
      src/public/peer.php

5
README.md

@ -65,8 +65,13 @@ Crawler
* @d47081: [BTC](https://www.blockchain.com/explorer/addresses/btc/bc1qngdf2kwty6djjqpk0ynkpq9wmlrmtm7e0c534y) | [LTC](https://live.blockcypher.com/ltc/address/LUSiqzKsfB1vBLvpu515DZktG9ioKqLyj7) | [XMR](835gSR1Uvka19gnWPkU2pyRozZugRZSPHDuFL6YajaAqjEtMwSPr4jafM8idRuBWo7AWD3pwFQSYRMRW9XezqrK4BEXBgXE) | [ZEPH](ZEPHsADHXqnhfWhXrRcXnyBQMucE3NM7Ng5ZVB99XwA38PTnbjLKpCwcQVgoie8EJuWozKgBiTmDFW4iY7fNEgSEWyAy4dotqtX) | Support our server by order [Linux VPS](https://www.yourserver.se/portal/aff.php?aff=610) * @d47081: [BTC](https://www.blockchain.com/explorer/addresses/btc/bc1qngdf2kwty6djjqpk0ynkpq9wmlrmtm7e0c534y) | [LTC](https://live.blockcypher.com/ltc/address/LUSiqzKsfB1vBLvpu515DZktG9ioKqLyj7) | [XMR](835gSR1Uvka19gnWPkU2pyRozZugRZSPHDuFL6YajaAqjEtMwSPr4jafM8idRuBWo7AWD3pwFQSYRMRW9XezqrK4BEXBgXE) | [ZEPH](ZEPHsADHXqnhfWhXrRcXnyBQMucE3NM7Ng5ZVB99XwA38PTnbjLKpCwcQVgoie8EJuWozKgBiTmDFW4iY7fNEgSEWyAy4dotqtX) | Support our server by order [Linux VPS](https://www.yourserver.se/portal/aff.php?aff=610)
#### License #### License
* Engine sources [MIT License](https://github.com/YGGverse/YGGstate/blob/main/LICENSE) * Engine sources [MIT License](https://github.com/YGGverse/YGGstate/blob/main/LICENSE)
#### Components
* [SVG icons](https://icons.getbootstrap.com/)
#### Feedback #### Feedback
Feel free to [share](https://github.com/YGGverse/YGGstate/issues) your ideas and bug reports! Feel free to [share](https://github.com/YGGverse/YGGstate/issues) your ideas and bug reports!

12
src/config/app.php.example

@ -73,6 +73,18 @@ define('WEBSITE_PEER_REMOTE_PAGINATION_LIMIT', 20);
define('WEBSITE_PEER_PORT_CHECK_TIMEOUT', 60 * 5); define('WEBSITE_PEER_PORT_CHECK_TIMEOUT', 60 * 5);
// API // API
define('API_PEER_FIELDS', (array)
[
'bytes_recvd',
'bytes_sent',
'coords',
'key',
'port',
'uptime',
// ...
]
);
define('API_PEERS', (object) define('API_PEERS', (object)
[ [
'tls://94.140.114.241:4708' => WEBSITE_URL, 'tls://94.140.114.241:4708' => WEBSITE_URL,

39
src/crontab/crawler.php

@ -134,29 +134,38 @@ try {
@unlink(__DIR__ . '/../public/api/trackers.json'); @unlink(__DIR__ . '/../public/api/trackers.json');
// Update peers // Update peers
if ($connectedPeers = Yggverse\Yggdrasilctl\Yggdrasil::getPeers()) { if (!$connectedPeers = Yggverse\Yggdrasilctl\Yggdrasil::getPeers())
{
exit;
}
if ($handle = fopen(__DIR__ . '/../public/api/peers.json', 'w+')) { // Update peers
fwrite($handle, json_encode($connectedPeers));
fclose($handle);
}
} else { /// Remove remote addresses
$jsonPeers = [];
foreach ($connectedPeers as $connectedPeerAddress => $connectedPeerInfo)
{
foreach ($connectedPeerInfo as $connectedPeerInfoKey => $connectedPeerInfoValue)
{
if (in_array($connectedPeerInfoKey, (array) API_PEER_FIELDS))
{
$jsonPeers[$connectedPeerAddress][$connectedPeerInfoKey] = $connectedPeerInfoValue;
}
}
}
exit; /// Save dump
if ($handle = fopen(__DIR__ . '/../public/api/peers.json', 'w+'))
{
fwrite($handle, json_encode($jsonPeers));
fclose($handle);
} }
// Update trackers // Update trackers
if (API_PEERS) { if ($handle = fopen(__DIR__ . '/../public/api/trackers.json', 'w+'))
{
if ($handle = fopen(__DIR__ . '/../public/api/trackers.json', 'w+')) {
fwrite($handle, json_encode(API_PEERS)); fwrite($handle, json_encode(API_PEERS));
fclose($handle); fclose($handle);
}
} else {
exit;
} }
// @TODO merge peers data from remote trackers // @TODO merge peers data from remote trackers

8
src/public/assets/theme/default/css/framework.css

@ -130,6 +130,10 @@
/* responsive rules */ /* responsive rules */
.width-13-px {
width: 13px;
}
.width-100 { .width-100 {
width: 100%; width: 100%;
} }
@ -138,6 +142,10 @@
width: 50%; width: 50%;
} }
.no-wrap {
white-space: nowrap;
}
@media (max-width: 1220px) { @media (max-width: 1220px) {
.width-tablet-100 { .width-tablet-100 {

18
src/public/peer.php

@ -232,7 +232,6 @@ $peerPortStatuses = $db->findLastPeerPortStatusesByPeerId($requestPeerId);
</span> </span>
<?php } ?> <?php } ?>
</h1> </h1>
</div> </div>
</div> </div>
</div> </div>
@ -249,9 +248,18 @@ $peerPortStatuses = $db->findLastPeerPortStatusesByPeerId($requestPeerId);
<?php echo _('Time') ?> <?php echo _('Time') ?>
</a> </a>
</th> </th>
<?php if (!empty($_SERVER['REMOTE_ADDR']) && $peerInfo->address == $_SERVER['REMOTE_ADDR']) { ?>
<th class="text-left"> <th class="text-left">
<?php echo _('Remote') ?> <?php echo _('Remote') ?>
<sub title="<?php echo _('Feature hidden for others') ?>">
<svg class="width-13-px" xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-eye-slash" viewBox="0 0 16 16">
<path d="M13.359 11.238C15.06 9.72 16 8 16 8s-3-5.5-8-5.5a7.028 7.028 0 0 0-2.79.588l.77.771A5.944 5.944 0 0 1 8 3.5c2.12 0 3.879 1.168 5.168 2.457A13.134 13.134 0 0 1 14.828 8c-.058.087-.122.183-.195.288-.335.48-.83 1.12-1.465 1.755-.165.165-.337.328-.517.486l.708.709z"/>
<path d="M11.297 9.176a3.5 3.5 0 0 0-4.474-4.474l.823.823a2.5 2.5 0 0 1 2.829 2.829l.822.822zm-2.943 1.299.822.822a3.5 3.5 0 0 1-4.474-4.474l.823.823a2.5 2.5 0 0 0 2.829 2.829z"/>
<path d="M3.35 5.47c-.18.16-.353.322-.518.487A13.134 13.134 0 0 0 1.172 8l.195.288c.335.48.83 1.12 1.465 1.755C4.121 11.332 5.881 12.5 8 12.5c.716 0 1.39-.133 2.02-.36l.77.772A7.029 7.029 0 0 1 8 13.5C3 13.5 0 8 0 8s.939-1.721 2.641-3.238l.708.709zm10.296 8.884-12-12 .708-.708 12 12-.708.708z"/>
</svg>
</sub>
</th> </th>
<?php } ?>
<th class="text-center"> <th class="text-center">
<?php echo _('Port') ?> <?php echo _('Port') ?>
</th> </th>
@ -269,8 +277,12 @@ $peerPortStatuses = $db->findLastPeerPortStatusesByPeerId($requestPeerId);
<tbody> <tbody>
<?php foreach ($peerRemoteConnections as $i => $peerRemoteConnection) { ?> <?php foreach ($peerRemoteConnections as $i => $peerRemoteConnection) { ?>
<tr> <tr>
<td class="text-left"><?php echo date('Y-m-d H:s:i', $peerRemoteConnection->timeAdded) ?></td> <td class="text-left no-wrap"><?php echo date('Y-m-d H:s:i', $peerRemoteConnection->timeAdded) ?></td>
<td class="text-left"><?php echo $peerRemoteConnection->remote ?></td> <?php if (!empty($_SERVER['REMOTE_ADDR']) && $peerInfo->address == $_SERVER['REMOTE_ADDR']) { ?>
<td class="text-left">
<?php echo $peerRemoteConnection->remote ?>
</td>
<?php } ?>
<td class="text-center"><?php echo $peerRemoteConnection->connectionPort ?></td> <td class="text-center"><?php echo $peerRemoteConnection->connectionPort ?></td>
<td class="text-left"><?php echo $peerRemoteConnection->route ?></td> <td class="text-left"><?php echo $peerRemoteConnection->route ?></td>
<td class="text-center"> <td class="text-center">

Loading…
Cancel
Save