zold 0.10.3 → 0.10.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/html/map.html +66 -51
- data/lib/zold/commands/node.rb +2 -2
- data/lib/zold/copies.rb +4 -1
- data/lib/zold/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 64a5fc8ee84ebe8ee31211bd472784f1634a7392
|
4
|
+
data.tar.gz: e016476f3c823b7dd433bc96531639906db64d38
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b67567ae28c14b77c422f368e9996eac97ffa166b5d35328e7ed0c1cfa90bd237fc9ecefa6a8d6255fb1ed2efcc650dd2a6819a0c5798b8b11cf4bf179893d58
|
7
|
+
data.tar.gz: 9af5c4f63487be52e9a4fd7bca7ef7197811340ef6d109231160bf2faf49185e2ce66e3cf2c8f8b42d97e734280d8e43b393b6c9268459f752d0567258b0307d
|
data/html/map.html
CHANGED
@@ -49,64 +49,79 @@ SOFTWARE.
|
|
49
49
|
#remotes li { list-style: none; }
|
50
50
|
</style>
|
51
51
|
<script>
|
52
|
-
function
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
52
|
+
function put_marker_by_ip(map, coords, ip, port) {
|
53
|
+
$.getJSON('http://www.geoplugin.net/json.gp?ip=' + ip, function(json) {
|
54
|
+
var lat = parseFloat(json['geoplugin_latitude']), lon = parseFloat(json['geoplugin_longitude']);
|
55
|
+
console.log(ip + ' located at ' + lat + '/' + lon);
|
56
|
+
new google.maps.Marker({
|
57
|
+
position: { lat: lat, lng: lon },
|
58
|
+
map: map,
|
59
|
+
title: ''
|
60
|
+
});
|
61
|
+
console.log('Marker set for ' + coords + ' at ' + lat + '/' + lon);
|
62
|
+
}).fail(function() { console.log('Failed to find geo-location for ' + ip) });
|
63
|
+
}
|
64
|
+
function put_marker_by_host(map, coords, host, port) {
|
65
|
+
$.getJSON('https://api.exana.io/dns/' + host + '/a', function(json) {
|
66
|
+
ip = $.grep(json['answer'], function (a, i) { return a['type'] == 'A'; })[0]['rdata'];
|
67
|
+
console.log('Host ' + host + ' resolved to ' + ip);
|
68
|
+
put_marker_by_ip(map, coords, ip, port);
|
69
|
+
}).fail(function() { console.log('Failed to find IP for ' + host) });
|
70
|
+
}
|
71
|
+
function put_markers(map, remotes) {
|
72
|
+
$.each(remotes, function (i, r) {
|
73
|
+
var host = r['host'], port = r['port'];
|
74
|
+
var coords = host + ':' + port;
|
75
|
+
var items = $('#remotes li[data-coords="' + coords + '"]');
|
76
|
+
if (items.length) {
|
77
|
+
var li = items.first();
|
78
|
+
$.getJSON('http://' + coords + '/', function(json) {
|
79
|
+
li.html(coords + ': ' + json['score']['value'] + '/' + json['wallets'] + ' (' + json['version'] + ')');
|
80
|
+
if (host.match(/^[0-9\.]+$/)) {
|
81
|
+
put_marker_by_ip(map, host + ':' + port, host, port);
|
82
|
+
} else {
|
83
|
+
put_marker_by_host(map, host + ':' + port, host, port);
|
84
|
+
}
|
85
|
+
}).done(function() { li.css('color', 'darkgreen'); }).fail(function() { li.css('color', 'red'); });
|
86
|
+
} else {
|
87
|
+
$('#remotes').append('<li data-coords="' + coords + '">' + coords + '</li>')
|
88
|
+
}
|
89
|
+
});
|
90
|
+
}
|
91
|
+
function refresh_list(map) {
|
92
|
+
$.getJSON('http://b1.zold.io/remotes', function(data) {
|
93
|
+
var remotes = data['all'];
|
94
|
+
console.log(remotes.length + ' remote nodes found');
|
95
|
+
put_markers(map, remotes);
|
96
|
+
});
|
97
|
+
}
|
98
|
+
function refresh(map) {
|
99
|
+
$.getJSON('http://b1.zold.io/', function(data) {
|
61
100
|
$('#header').html(
|
62
101
|
'Version: ' + data['version'] + '<br/>' +
|
63
102
|
'Host: ' + data['score']['host'] + ':' + data['score']['port'] + '<br/>' +
|
64
103
|
'Score: ' + data['score']['value'] + '<br/>' +
|
65
104
|
'Wallets: ' + data['wallets']
|
66
105
|
);
|
106
|
+
refresh_list(map);
|
107
|
+
window.setTimeout(refresh, 10000);
|
67
108
|
});
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
if (items.length) {
|
85
|
-
var li = items.first();
|
86
|
-
$.getJSON('http://' + coords + '/', function(data) {
|
87
|
-
li.html(coords + ': ' + data['score']['value'] + '/' + data['wallets'] + ' (' + data['version'] + ')');
|
88
|
-
})
|
89
|
-
.done(function() { li.css('color', 'darkgreen'); })
|
90
|
-
.fail(function() { li.css('color', 'red'); });
|
91
|
-
var ip = host;
|
92
|
-
if (!ip.match(/[0-9\.]+/)) {
|
93
|
-
$.get('http://api.konvert.me/forward-dns/' + host, function(data) {
|
94
|
-
ip = data
|
95
|
-
});
|
96
|
-
}
|
97
|
-
li.attr('title', ip);
|
98
|
-
$.getJSON('http://ip-api.com/json/' + ip, function(data) {
|
99
|
-
new google.maps.Marker({
|
100
|
-
position: { lat: data['lat'], lng: data['lon'] },
|
101
|
-
map: map,
|
102
|
-
title: coords
|
103
|
-
}).setMap(map);
|
104
|
-
});
|
105
|
-
} else {
|
106
|
-
$('#remotes').append('<li data-coords="' + coords + '">' + coords + '</li>')
|
107
|
-
}
|
108
|
-
});
|
109
|
-
}, 10000);
|
109
|
+
}
|
110
|
+
function init() {
|
111
|
+
var map = new google.maps.Map(
|
112
|
+
document.getElementById("map"),
|
113
|
+
{
|
114
|
+
center: new google.maps.LatLng(55.751244, 37.618423),
|
115
|
+
mapTypeId: google.maps.MapTypeId.ROADMAP,
|
116
|
+
zoom: 3
|
117
|
+
}
|
118
|
+
);
|
119
|
+
var marker = new google.maps.Marker({
|
120
|
+
position: { lat: 55, lng: 37 },
|
121
|
+
map: map,
|
122
|
+
title: 'Hello'
|
123
|
+
});
|
124
|
+
refresh(map);
|
110
125
|
};
|
111
126
|
</script>
|
112
127
|
</head>
|
data/lib/zold/commands/node.rb
CHANGED
@@ -56,8 +56,8 @@ module Zold
|
|
56
56
|
"The strength of the score (default: #{Score::STRENGTH})",
|
57
57
|
default: Score::STRENGTH
|
58
58
|
o.integer '--threads',
|
59
|
-
'How many threads to use for scores finding (default:
|
60
|
-
default:
|
59
|
+
'How many threads to use for scores finding (default: 4)',
|
60
|
+
default: 4
|
61
61
|
o.bool '--standalone',
|
62
62
|
'Never communicate with other nodes (mostly for testing)',
|
63
63
|
default: false
|
data/lib/zold/copies.rb
CHANGED
@@ -63,7 +63,10 @@ module Zold
|
|
63
63
|
raise "Score can't be negative: #{score}" if score < 0
|
64
64
|
FileUtils.mkdir_p(@dir)
|
65
65
|
list = load
|
66
|
-
target = list.find
|
66
|
+
target = list.find do |s|
|
67
|
+
f = File.join(@dir, s[:name])
|
68
|
+
File.exist?(f) && File.read(f) == content
|
69
|
+
end
|
67
70
|
if target.nil?
|
68
71
|
max = Dir.new(@dir)
|
69
72
|
.select { |f| f =~ /^[0-9]+$/ }
|
data/lib/zold/version.rb
CHANGED