mirror of
https://github.com/bdnugget/freeminer.git
synced 2026-11-07 06:57:27 +00:00
name=
This commit is contained in:
1 parent
b45e693da4
commit
7c951990bd
4 files changed
+53
-21
No files matched your search
+16
-6
@@ -8,24 +8,34 @@ the serverlist webpage template.
|
||||
|
||||
First install node.js, eg:
|
||||
|
||||
# apt-get install nodejs
|
||||
# apt install nodejs
|
||||
# pacman -S nodejs
|
||||
# emerge nodejs
|
||||
|
||||
Then install doT.js and its dependencies:
|
||||
|
||||
# apt install node-dot node-commander
|
||||
|
||||
Or with npm:
|
||||
|
||||
$ npm install dot commander mkdirp
|
||||
|
||||
Or manually:
|
||||
|
||||
$ cd ~/code
|
||||
$ git clone https://github.com/olado/doT.git
|
||||
$ cd doT
|
||||
$ npm install
|
||||
|
||||
Or with npm:
|
||||
|
||||
$ npm install dot commander mkdirp
|
||||
|
||||
And finally compile the template:
|
||||
|
||||
$ cd ~/freeminer/util/master
|
||||
|
||||
$ /usr/share/nodejs/dot/bin/dot-packer -s . -d .
|
||||
|
||||
or
|
||||
|
||||
$ ~/code/doT/bin/dot-packer -s . -d .
|
||||
|
||||
or
|
||||
@@ -38,7 +48,7 @@ Embedding to any page
|
||||
|
||||
<script>
|
||||
var master = {
|
||||
root: 'http://servers.freeminer.org/',
|
||||
root: '//servers.freeminer.org/',
|
||||
limit: 10,
|
||||
clients_min: 1,
|
||||
no_flags: 1,
|
||||
@@ -46,4 +56,4 @@ Embedding to any page
|
||||
no_uptime: 1
|
||||
};
|
||||
</script>
|
||||
<script src="http://servers.freeminer.org/list.js"></script>
|
||||
<script src="//servers.freeminer.org/list.js"></script>
|
||||
+20
-4
@@ -1,6 +1,7 @@
|
||||
var master;
|
||||
if (!master) master = {};
|
||||
if (typeof(master.root) == 'undefined') master.root = "http://servers.freeminer.org/";
|
||||
if (typeof(master.root) == 'undefined') master.root = "//servers.freeminer.org/";
|
||||
if (!master.play_root) master.play_root = '//play.freeminer.org/';
|
||||
if (!master.output) master.output = '#server_list';
|
||||
if (!master.list) master.list = "list";
|
||||
if (!master.list_root) master.list_root = master.root;
|
||||
@@ -29,6 +30,16 @@ function escapeHTML(str) {
|
||||
return str.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"');
|
||||
}
|
||||
|
||||
function addressEscaped(address, port) {
|
||||
var isIPv6 = address.indexOf(":") != -1;
|
||||
var addrStr = (isIPv6 ? '[' : '') +
|
||||
escapeHTML(address) +
|
||||
(isIPv6 ? ']' : '');
|
||||
if (port)
|
||||
addrStr += ':' + parseInt(port);
|
||||
return addrStr;
|
||||
}
|
||||
|
||||
function addressString(server) {
|
||||
var isIPv6 = server.address.indexOf(":") != -1;
|
||||
var addrStr = (isIPv6 ? '[' : '') +
|
||||
@@ -42,7 +53,7 @@ function addressString(server) {
|
||||
str += ' class="mts_tooltip" title="' + addrStr + '"'
|
||||
}
|
||||
if (server.port != 30000)
|
||||
shortStr += ':' + server.port;
|
||||
shortStr += ':' + parseInt(server.port);
|
||||
return str + '>' + shortStr + '</span>';
|
||||
}
|
||||
|
||||
@@ -86,9 +97,14 @@ function get() {
|
||||
jQuery.getJSON(master.list_url, draw);
|
||||
}
|
||||
|
||||
function maybeGet() {
|
||||
if (!document.hidden)
|
||||
get();
|
||||
}
|
||||
|
||||
function loaded(){
|
||||
if (!master.no_refresh) {
|
||||
setInterval(get, 60 * 1000);
|
||||
setInterval(maybeGet, 60 * 1000);
|
||||
}
|
||||
get();
|
||||
}
|
||||
@@ -100,6 +116,6 @@ toast(master.root + 'style.css', master.root + 'servers.js', function() {
|
||||
if (typeof(jQuery) != 'undefined')
|
||||
return loaded();
|
||||
else
|
||||
toast('//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js', loaded);
|
||||
toast('//ajax.googleapis.com/ajax/libs/jquery/3.7.1/jquery.min.js', loaded);
|
||||
});
|
||||
|
||||
@@ -58,6 +58,7 @@ no strict qw(refs);
|
||||
use warnings "NONFATAL" => "all";
|
||||
no warnings qw(uninitialized);
|
||||
no if $] >= 5.017011, warnings => 'experimental::smartmatch';
|
||||
no if $] >= 5.038, warnings => 'deprecated::smartmatch';
|
||||
use utf8;
|
||||
use Socket;
|
||||
BEGIN {
|
||||
@@ -106,7 +107,7 @@ our %config = (
|
||||
#debug => 1,
|
||||
list_full => $root_path . 'list_full',
|
||||
list_pub => $root_path . 'list',
|
||||
log => $root_path . 'log.log',
|
||||
log => $root_path . '../log/master.log',
|
||||
time_purge => 86400 * 1,
|
||||
time_alive => 650,
|
||||
source_check => 1,
|
||||
@@ -309,7 +310,7 @@ sub request (;$) {
|
||||
$param->{ping} = $duration if $pingret;
|
||||
printlog " PING t=$config{ping_timeout}, $param->{address}:$param->{port} = ( $pingret, $duration, $ip )" if $config{debug};
|
||||
}
|
||||
return if !$param->{ping};
|
||||
return if !$param->{ping} and !($param->{ip} ~~ $config{trusted});
|
||||
}
|
||||
my $list = read_json($config{list_full}) || {};
|
||||
printlog "readed[$config{list_full}] list size=", scalar @{$list->{list}} if $config{debug};
|
||||
@@ -337,7 +338,7 @@ sub request (;$) {
|
||||
|
||||
$list->{list} = [
|
||||
sort { $b->{clients} <=> $a->{clients} || $a->{start} <=> $b->{start} }
|
||||
grep { $_->{time} > time - $config{time_alive} and !$_->{off} and (!$config{ping} or !$config{pingable} or $_->{ping}) }
|
||||
grep { $_->{time} > time - $config{time_alive} and !$_->{off} and (!$config{ping} or !$config{pingable} or $_->{ping} or ($param->{ip} ~~ $config{trusted})) }
|
||||
@{$list_full}
|
||||
];
|
||||
$list->{total} = {clients => 0, servers => 0};
|
||||
|
||||
+13
-8
@@ -14,19 +14,20 @@
|
||||
{{? !master.no_flags}}<th>Flags</th>{{?}}
|
||||
{{? !master.no_uptime}}<th>Uptime, Age</th>{{?}}
|
||||
{{? !master.no_ping}}<th>Ping, Lag</th>{{?}}
|
||||
{{? !master.no_play}}<th>Play</th>{{?}}
|
||||
</tr></thead>
|
||||
<tbody>
|
||||
{{~it.list :server:index}}
|
||||
{{ if (master.limit && index + 1 > master.limit) break;}}
|
||||
{{ if (master.min_clients && server.clients < master.min_clients) continue;}}
|
||||
<tr>
|
||||
{{? !master.no_address}}
|
||||
{{? !master.no_address }}
|
||||
<td class ="address">
|
||||
{{=addressString(server)}}
|
||||
</td>{{?}}
|
||||
{{? !master.no_clients}}
|
||||
{{? !master.no_clients }}
|
||||
<td class="clients{{? server.clients_list && server.clients_list.length > 0}} mts_hover_list_text{{?}}">
|
||||
{{=server.clients}}/{{=server.clients_max}}{{? !master.no_avgtop}} {{=Math.floor(server.pop_v)}}/{{=server.clients_top}}{{?}}
|
||||
{{=server.clients}}/{{=server.clients_max}}{{? !master.no_avgtop }} {{=Math.floor(server.pop_v)}}/{{=server.clients_top}}{{?}}
|
||||
{{=hoverList("Clients", server.clients_list)}}
|
||||
</td>{{?}}
|
||||
{{? !master.no_version}}
|
||||
@@ -35,15 +36,15 @@
|
||||
{{=escapeHTML(server.mapgen || '?')}}
|
||||
{{=hoverList("Mods", server.mods)}}
|
||||
</td>{{?}}
|
||||
{{? !master.no_name}}
|
||||
{{? !master.no_name }}
|
||||
<td class="name">
|
||||
{{? server.url}}
|
||||
{{? server.url }}
|
||||
<a href="{{=escapeHTML(server.url)}}">{{=tooltipString(server.name, 25)}}</a>
|
||||
{{??}}
|
||||
{{=tooltipString(server.name, 25)}}
|
||||
{{?}}
|
||||
</td>{{?}}
|
||||
{{? !master.no_description}}
|
||||
{{? !master.no_description }}
|
||||
<td class="description">
|
||||
{{=tooltipString(server.description, 50)}}
|
||||
</td>{{?}}
|
||||
@@ -59,15 +60,19 @@
|
||||
{{=server.rollback ? 'Rol ' : ''}}
|
||||
{{=server.can_see_far_names ? 'Far ' : ''}}
|
||||
</td>{{?}}
|
||||
{{? !master.no_uptime}}
|
||||
{{? !master.no_uptime }}
|
||||
<td class="uptime">
|
||||
{{=humanTime(server.uptime)}}, {{=humanTime(server.game_time)}}
|
||||
{{? server.first}} {{=hoverString("First seen", humanTime(+new Date()/1000 -server.first))}} {{?}}
|
||||
</td>{{?}}
|
||||
{{? !master.no_ping}}
|
||||
{{? !master.no_ping }}
|
||||
<td class="ping">
|
||||
{{=Math.floor(server.ping * 1000)}}{{? server.lag}}, {{= Math.floor(server.lag * 1000)}}{{?}}
|
||||
</td>{{?}}
|
||||
{{? !master.no_play }}
|
||||
<td class="play">
|
||||
{{? server.proto_multi && server.proto_multi.wss }}<a href="{{= master.play_root }}?go=1&address={{= addressEscaped(server.address) + "&port=" + parseInt(server.proto_multi.wss) }}&name=">Play</a>{{?}}
|
||||
</td>{{?}}
|
||||
</tr>
|
||||
{{~}}
|
||||
</tbody>
|
||||
|
||||
Reference in new issue
Block a user