diff --git a/models/peers.js b/models/peers.js index 5ac4ab6..6fe5989 100644 --- a/models/peers.js +++ b/models/peers.js @@ -7,7 +7,8 @@ var PeersSchema = new Schema({ port: { type: String, default: "" }, protocol: { type: String, default: "" }, version: { type: String, default: "" }, - country: { type: String, default: "" } + country: { type: String, default: "" }, + country_code: { type: String, default: "" } }); module.exports = mongoose.model('Peers', PeersSchema); diff --git a/scripts/peers.js b/scripts/peers.js index ea092a2..9b96d48 100644 --- a/scripts/peers.js +++ b/scripts/peers.js @@ -31,7 +31,7 @@ mongoose.connect(dbString, { useNewUrlParser: true, useCreateIndex: true, useUni var rateLimit = new RateLimit(1, 2000, false); db.find_peer(address, function(peer) { if (peer) { - if (isNaN(peer['port']) || peer['port'].length < 2 || peer['country'].length < 1) { + if (isNaN(peer['port']) || peer['port'].length < 2 || peer['country'].length < 1 || peer['country_code'].length < 1) { db.drop_peers(function() { console.log('Saved peers missing ports or country, dropping peers. Re-run this script afterwards.'); exit(); @@ -47,7 +47,8 @@ mongoose.connect(dbString, { useNewUrlParser: true, useCreateIndex: true, useUni port: port, protocol: body[i].version, version: body[i].subver.replace('/', '').replace('/', ''), - country: geo.country_name + country: geo.country_name, + country_code: geo.country_code }, function(){ loop.next(); }); diff --git a/views/includes/net_list.pug b/views/includes/net_list.pug index 6a7804b..919cd69 100644 --- a/views/includes/net_list.pug +++ b/views/includes/net_list.pug @@ -10,17 +10,20 @@ script. ajax: { url: '/ext/connections', dataSrc: function ( json ) { - /*for ( var i=0;i" + json.data[i]['txid'] + ""; - json.data[i]['blockindex'] = "" + json.data[i]['blockindex'] + ""; - 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; } }, + rowCallback: function (row, data, index) { + var flagBlock = ''; + if (data['country_code'].length > 1) { + flagBlock = ' 
'; + } + $("td:eq(0)", row).html(data['address']); + $("td:eq(1)", row).html(data['protocol']); + $("td:eq(2)", row).html(data['version']); + $("td:eq(3)", row).html(data['country']+flagBlock); + + }, columns: [ { data: 'address', width: '25%' }, { data: 'protocol', width: '25%' },