Network peer updates

-Added a new port_filter setting to the 3 network_page tables which allows showing only results from peers on the selected port
-Added a new hide_protocols setting to the 3 network_page tables which allows hiding results from peers on the selected protocols
-Added a Port column to the data table on the Network page Connections tab
-The data table on the Network page Connections tab is now sortable
-The peer sync now refreshes data for peers that existed since last sync
-Adding and updating peers now displays the port # in the log output
-The /ext/getnetworkpeers api is now sorted by ip4/ip6, address and port which also means all data on the Network page is sorted this way by default as well
-The /ext/getnetworkpeers api no longer requires the internal argument for calls originating from the Network page
-The Network page now only makes a single call to the /ext/getnetworkpeers api instead of 3 calls
-The find_peer and drop_peer functions now requiresa port to distinguish between multiple connections to the same peer on different ports
This commit is contained in:
Joe Uhren
2022-07-01 21:11:57 -06:00
parent fb5ce795fa
commit 8fa337f6f9
6 changed files with 245 additions and 151 deletions
+18 -5
View File
@@ -436,7 +436,7 @@ if (lib.is_locked([database]) == false) {
address = address.replace("[", "").replace("]", "");
}
db.find_peer(address, function(peer) {
db.find_peer(address, port, function(peer) {
if (peer) {
if ((peer['port'] != null && (isNaN(peer['port']) || peer['port'].length < 2)) || peer['country'].length < 1 || peer['country_code'].length < 1) {
db.drop_peers(function() {
@@ -445,9 +445,22 @@ if (lib.is_locked([database]) == false) {
});
}
// peer already exists
console.log('Updated peer %s [%s/%s]', address, (i + 1).toString(), body.length.toString());
loop.next();
// peer already exists and should be refreshed
// drop peer
db.drop_peer(address, port, function() {
// re-add the peer to refresh the data and extend the expiry date
db.create_peer({
address: address,
port: port,
protocol: peer.protocol,
version: peer.version,
country: peer.country,
country_code: peer.country_code
}, function() {
console.log('Updated peer %s:%s [%s/%s]', address, port.toString(), (i + 1).toString(), body.length.toString());
loop.next();
});
});
} else {
const rateLimitLib = require('../lib/ratelimit');
const rateLimit = new rateLimitLib.RateLimit(1, 2000, false);
@@ -471,7 +484,7 @@ if (lib.is_locked([database]) == false) {
country: geo.country_name,
country_code: geo.country_code
}, function() {
console.log('Added new peer %s [%s/%s]', address, (i + 1).toString(), body.length.toString());
console.log('Added new peer %s:%s [%s/%s]', address, port.toString(), (i + 1).toString(), body.length.toString());
loop.next();
});
}