Network: Add tab with info to easily get addnode data for Wallets
This commit is contained in:
@@ -826,6 +826,28 @@ module.exports = {
|
||||
})
|
||||
},
|
||||
|
||||
drop_peer: function(address, cb) {
|
||||
Peers.deleteOne({address: address}, function(err) {
|
||||
if (err) {
|
||||
console.log(err);
|
||||
return cb();
|
||||
} else {
|
||||
return cb ()
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
drop_peers: function(cb) {
|
||||
Peers.deleteMany({}, function(err) {
|
||||
if (err) {
|
||||
console.log(err);
|
||||
return cb();
|
||||
} else {
|
||||
return cb ()
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
get_peers: function(cb) {
|
||||
Peers.find({}, function(err, peers) {
|
||||
if (err) {
|
||||
|
||||
@@ -4,6 +4,7 @@ var mongoose = require('mongoose')
|
||||
var PeersSchema = new Schema({
|
||||
createdAt: { type: Date, expires: 86400, default: Date.now()},
|
||||
address: { type: String, default: "" },
|
||||
port: { type: String, default: "" },
|
||||
protocol: { type: String, default: "" },
|
||||
version: { type: String, default: "" },
|
||||
country: { type: String, default: "" }
|
||||
|
||||
+11
-3
@@ -26,20 +26,28 @@ mongoose.connect(dbString, { useNewUrlParser: true, useCreateIndex: true, useUni
|
||||
request({uri: 'http://127.0.0.1:' + settings.port + '/api/getpeerinfo', json: true, headers: {'User-Agent': 'eiquidus'}}, function (error, response, body) {
|
||||
lib.syncLoop(body.length, function (loop) {
|
||||
var i = loop.iteration();
|
||||
var address = body[i].addr.substring(0, body[i].addr.lastIndexOf(":")).replace("[","").replace("]","");
|
||||
var address = body[i].addr.split(':')[0];
|
||||
var port = body[i].addr.split(':')[1];
|
||||
var rateLimit = new RateLimit(1, 2000, false);
|
||||
db.find_peer(address, function(peer) {
|
||||
if (peer) {
|
||||
if (isNaN(peer['port']) || peer['port'].length < 2) {
|
||||
db.drop_peers(function() {
|
||||
console.log('Saved peers missing ports, dropping peers. Re-reun this script afterwards.');
|
||||
exit();
|
||||
});
|
||||
}
|
||||
// peer already exists
|
||||
loop.next();
|
||||
} else {
|
||||
rateLimit.schedule(function() {
|
||||
request({uri: 'http://ip-api.com/json/' + address + '?fields=country', json: true, headers: {'User-Agent': 'eiquidus'}}, function (error, response, geo) {
|
||||
request({uri: 'http://freegeoip.net/json/' + address, json: true, headers: {'User-Agent': 'eiquidus'}}, function (error, response, geo) {
|
||||
db.create_peer({
|
||||
address: address,
|
||||
port: port,
|
||||
protocol: body[i].version,
|
||||
version: body[i].subver.replace('/', '').replace('/', ''),
|
||||
country: geo.country
|
||||
country: geo.country_name
|
||||
}, function(){
|
||||
loop.next();
|
||||
});
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
script.
|
||||
$(document).ready(function(){
|
||||
var ctable = $('#addnodes-table').dataTable( {
|
||||
autoWidth: true,
|
||||
searching: false,
|
||||
ordering: false,
|
||||
responsive: true,
|
||||
lengthChange: true,
|
||||
processing: true,
|
||||
ajax: {
|
||||
url: '/ext/connections',
|
||||
dataSrc: function ( json ) {
|
||||
var rows = []
|
||||
for ( var i=0;i<json.data.length; i++ ) {
|
||||
rows.push({'nodes':'addnode='+json.data[i]['address']+':'+json.data[i]['port']});
|
||||
}
|
||||
return rows;
|
||||
}
|
||||
},
|
||||
columns: [
|
||||
{ data: 'nodes', width: '100%' }
|
||||
],
|
||||
columnDefs: [
|
||||
{ targets: '_all', className: 'text-left'}
|
||||
]
|
||||
});
|
||||
var ctable = $('#addnodes2-table').dataTable( {
|
||||
autoWidth: true,
|
||||
searching: false,
|
||||
ordering: false,
|
||||
responsive: true,
|
||||
lengthChange: true,
|
||||
processing: true,
|
||||
ajax: {
|
||||
url: '/ext/connections',
|
||||
dataSrc: function ( json ) {
|
||||
var rows = []
|
||||
for ( var i=0;i<json.data.length; i++ ) {
|
||||
rows.push({'nodes':'addnode '+json.data[i]['address']+':'+json.data[i]['port']+' onetry'});
|
||||
}
|
||||
return rows;
|
||||
}
|
||||
},
|
||||
columns: [
|
||||
{ data: 'nodes', width: '100%' }
|
||||
],
|
||||
columnDefs: [
|
||||
{ targets: '_all', className: 'text-left'}
|
||||
]
|
||||
});
|
||||
});
|
||||
.panel.panel-default
|
||||
.panel-body
|
||||
:markdown
|
||||
If you have trouble syncing your wallet, add these lines to your coin daemon .conf file and restart the wallet.
|
||||
|
||||
*Typically you can access the config file through QT-wallet menu, Tools > Open Wallet Configuration File*
|
||||
table#addnodes-table.table.table-bordered.table-striped
|
||||
thead
|
||||
tr
|
||||
th.text-center AddNode Config Lines
|
||||
tbody.text-center
|
||||
|
||||
.panel-body
|
||||
:markdown
|
||||
Alternatively you can try one of these lines in the coin wallet debug window, or add them with *coindaemon*-cli
|
||||
table#addnodes2-table.table.table-bordered.table-striped
|
||||
thead
|
||||
tr
|
||||
th.text-center OneTry Node Lines
|
||||
tbody.text-center
|
||||
@@ -0,0 +1,40 @@
|
||||
script.
|
||||
$(document).ready(function(){
|
||||
var ctable = $('#connections-table').dataTable( {
|
||||
autoWidth: true,
|
||||
searching: false,
|
||||
ordering: false,
|
||||
responsive: true,
|
||||
lengthChange: true,
|
||||
processing: true,
|
||||
ajax: {
|
||||
url: '/ext/connections',
|
||||
dataSrc: function ( json ) {
|
||||
/*for ( var i=0;i<json.data.length; i++ ) {
|
||||
json.data[i]['timestamp'] = new Date((json.data[i]['timestamp']) * 1000).toUTCString();
|
||||
json.data[i]['txid'] = "<a href='/tx/" + json.data[i]['txid'] + "'>" + json.data[i]['txid'] + "</a>";
|
||||
json.data[i]['blockindex'] = "<a href='/block/" + json.data[i]['blockhash'] + "'>" + json.data[i]['blockindex'] + "</a>";
|
||||
var amount = json.data[i]['total'] / 100000000;
|
||||
json.data[i]['total'] = amount.toFixed(8);
|
||||
json.data[i]['recipients'] = json.data[i]['vout'].length;
|
||||
}*/
|
||||
return json.data;
|
||||
}
|
||||
},
|
||||
columns: [
|
||||
{ data: 'address', width: '25%' },
|
||||
{ data: 'protocol', width: '25%' },
|
||||
{ data: 'version', width:'25%' },
|
||||
{ data: 'country', width: '25%'}
|
||||
]
|
||||
});
|
||||
});
|
||||
.panel.panel-default
|
||||
table#connections-table.table.table-bordered.table-striped
|
||||
thead
|
||||
tr
|
||||
th.text-center #{settings.locale.net_address}
|
||||
th.text-center #{settings.locale.net_protocol}
|
||||
th.text-center #{settings.locale.net_subversion}
|
||||
th.text-center #{settings.locale.net_country}
|
||||
tbody.text-center
|
||||
+11
-34
@@ -1,40 +1,17 @@
|
||||
extends layout
|
||||
|
||||
block content
|
||||
script.
|
||||
$(document).ready(function(){
|
||||
var ctable = $('#connections-table').dataTable( {
|
||||
autoWidth: true,
|
||||
searching: false,
|
||||
ordering: false,
|
||||
responsive: true,
|
||||
lengthChange: true,
|
||||
processing: true,
|
||||
ajax: {
|
||||
url: '/ext/connections',
|
||||
dataSrc: function ( json ) {
|
||||
return json.data;
|
||||
}
|
||||
},
|
||||
columns: [
|
||||
{ data: 'address', width: '25%' },
|
||||
{ data: 'protocol', width: '25%' },
|
||||
{ data: 'version', width:'25%' },
|
||||
{ data: 'country', width: '25%'}
|
||||
]
|
||||
});
|
||||
});
|
||||
.col-md-12(style="margin-bottom: 4%")
|
||||
.row.text-center(style='margin-bottom:15px;')
|
||||
i #{settings.locale.net_warning}
|
||||
.panel.panel-default
|
||||
.panel-heading
|
||||
strong #{settings.locale.net_connections}
|
||||
table#connections-table.table.table-bordered.table-striped
|
||||
thead
|
||||
tr
|
||||
th.text-center #{settings.locale.net_address}
|
||||
th.text-center #{settings.locale.net_protocol}
|
||||
th.text-center #{settings.locale.net_subversion}
|
||||
th.text-center #{settings.locale.net_country}
|
||||
tbody.text-center
|
||||
.tabpanel
|
||||
ul.nav.nav-tabs(role='tablist')
|
||||
li.active(role='presentation')
|
||||
a(href='#connections', aria-controls='connections', role='tab', data-toggle='tab') #{settings.locale.net_connections}
|
||||
li(role='presentation')
|
||||
a(href='#addnodes', aria-controls='addnodes', role='tab', data-toggle='tab') Add Nodes
|
||||
.tab-content
|
||||
#connections.tabpanel.tab-pane.active
|
||||
include ./includes/net_list.jade
|
||||
#addnodes.tabpanel.tab-pane
|
||||
include ./includes/net_addnodes.jade
|
||||
|
||||
Reference in New Issue
Block a user