Votazione: come ricevere voti sul server

I giocatori votano il server su akvarium.space e noi inoltriamo immediatamente il voto al tuo server, così puoi assegnare la ricompensa. Ci sono due metodi, entrambi attivabili: richiesta HTTP con JSON e comando RCON.

Chi può votare

  • Solo il giocatore il cui nickname è collegato ad Akvarium: l'accesso al sito avviene tramite /akvarium login su play.akvarium.space. Quindi il nickname nel voto è sempre reale: il proprietario ha effettivamente giocato.
  • 1 voto al giorno per ogni server da ogni nickname (giornata secondo l'ora di Mosca).
  • Massimo 10 voti al giorno da ogni nickname per tutti i server e 20 da ogni IP.
  • Tra un voto e l'altro dallo stesso nickname devono passare almeno 5 secondi.
  • Nella classifica vengono conteggiati i voti degli ultimi 30 giorni.

Metodo 1. HTTP JSON

Per ogni voto inviamo una richiesta POST al tuo indirizzo. Il corpo è un JSON, la firma è nell'intestazione X-Akv-Signature: si tratta di un HMAC-SHA256 della stringa «timestamp.corpo» con il tuo segreto. Il segreto è mostrato nella pagina di gestione del server.

Intestazioni della richiesta
POST /akvarium-vote HTTP/1.1
Content-Type: application/json
User-Agent: akvarium.space-monitoring/1.0
X-Akv-Timestamp: 1764950400
X-Akv-Vote-Id: 1842
X-Akv-Signature: sha256=5d41402abc4b2a76b9719d911017c592...
Corpo della richiesta
{
  "type": "vote",
  "server": "akvarium",
  "nick": "Steve",
  "voteId": 1842,
  "timestamp": 1764950400,
  "test": false
}
  • Rispondi con un codice 2xx entro 6 secondi: così capiremo che il voto è stato accettato.
  • Se non c'è risposta o il codice non è 2xx, riproveremo altre due volte: dopo 30 secondi e dopo 5 minuti. Quindi verifica il voteId e non assegnare la ricompensa due volte.
  • Verifica la firma e l'orario: il timestamp non deve essere più vecchio di 5 minuti.
  • Il voto di prova ha "test": true e voteId 0: non è necessario assegnare una ricompensa per questo.
Node.js
// Node.js 18+ (Express)
const crypto = require('crypto');
const express = require('express');
const app = express();
const SECRET = process.env.AKV_SECRET; // secret from the server settings page
const seen = new Set(); // keep voteIds in your DB in production

app.post('/akvarium-vote', express.raw({ type: 'application/json' }), (req, res) => {
  const body = req.body.toString('utf8');
  const ts = Number(req.get('X-Akv-Timestamp'));
  const expected = 'sha256=' + crypto.createHmac('sha256', SECRET).update(ts + '.' + body).digest('hex');
  const got = req.get('X-Akv-Signature') || '';
  if (got.length !== expected.length || !crypto.timingSafeEqual(Buffer.from(got), Buffer.from(expected))) {
    return res.status(401).send('bad signature');
  }
  if (Math.abs(Date.now() / 1000 - ts) > 300) return res.status(400).send('old');
  const vote = JSON.parse(body);
  if (vote.test) return res.send('test ok');
  if (seen.has(vote.voteId)) return res.send('duplicate');
  seen.add(vote.voteId);
  // give the reward to vote.nick here
  res.send('ok');
});

app.listen(8080);
PHP
<?php
// PHP 7.4+
$secret = getenv('AKV_SECRET');
$body = file_get_contents('php://input');
$ts = (int)($_SERVER['HTTP_X_AKV_TIMESTAMP'] ?? 0);
$expected = 'sha256=' . hash_hmac('sha256', $ts . '.' . $body, $secret);
if (!hash_equals($expected, $_SERVER['HTTP_X_AKV_SIGNATURE'] ?? '')) {
  http_response_code(401); exit('bad signature');
}
if (abs(time() - $ts) > 300) { http_response_code(400); exit('old'); }
$vote = json_decode($body, true);
if ($vote['test']) { exit('test ok'); }
// check that $vote['voteId'] is new, then reward $vote['nick']
echo 'ok';
Python
# Python 3 (Flask)
import hmac, hashlib, json, os, time
from flask import Flask, request

app = Flask(__name__)
SECRET = os.environ["AKV_SECRET"].encode()

@app.post("/akvarium-vote")
def vote():
    body = request.get_data()
    ts = request.headers.get("X-Akv-Timestamp", "0")
    expected = "sha256=" + hmac.new(SECRET, ts.encode() + b"." + body, hashlib.sha256).hexdigest()
    if not hmac.compare_digest(expected, request.headers.get("X-Akv-Signature", "")):
        return "bad signature", 401
    if abs(time.time() - int(ts)) > 300:
        return "old", 400
    data = json.loads(body)
    if data["test"]:
        return "test ok"
    # check that data["voteId"] is new, then reward data["nick"]
    return "ok"

Metodo 2. RCON

Ci connettiamo all'RCON del tuo server ed eseguiamo un singolo comando. Scrivi il comando senza la barra iniziale «/». Il nickname del giocatore viene inserito automaticamente al posto di {nick}; se {nick} non è presente nel comando, il nickname verrà aggiunto alla fine separato da uno spazio.

Abilita RCON
# server.properties
enable-rcon=true
rcon.port=25575
rcon.password=long-random-password
Esempi di comandi (senza «/»)
give {nick} diamond 3
eco give {nick} 100
lp user {nick} permission settemp vote.bonus true 1d
broadcast {nick} voted for the server!
  • I voti (HTTP e RCON) arrivano dall'IP 185.192.247.15: puoi aprire la porta RCON solo per esso.
  • La password RCON è memorizzata crittografata e non viene mostrata a nessuno, nemmeno a te.
  • L'host deve essere un indirizzo pubblico: non sono accettati indirizzi locali o di reti interne.

Test in questa stessa pagina di gestione

Nella pagina di gestione del server c'è il pulsante «Invia test»: invia un voto di prova a tutte le configurazioni e mostra se è arrivato; in caso contrario, indica a quale passo si è verificato l'errore (indirizzo, connessione, password RCON, risposta del server).

  • Non più di un test ogni 10 secondi.
  • Totale 50 test, dopodiché i test vengono bloccati per 48 ore, quindi il contatore si azzera.

Aggiungi server

© 2026 akvarium.space. Non è un prodotto ufficiale di Minecraft. Non approvato da Mojang AB o Microsoft né associato a essi.