Author Topic: Sending additional POST variables through postServerTCPObj  (Read 5864 times)

I can't seem to figure out how to do this. Using trinick's script, and echoing out %this.cmd (with my added false Uptime variable), this is what shows up.

Code: [Select]
POST /postServer.php HTTP/1.0
Host: [REMOVED]
Content-Type: application/x-www-form-urlencoded
Content-Length: 163

ServerName=Freebuild&Port=28000&Players=1&MaxPlayers=6&Map=Freebuild&Mod=&Passworded=1&Dedicated=0&BrickCount=0&DemoPlayers=0&blid=18701&Uptime=4944948474&csg=1800&ver=21&build=1931

I assume this is not working right (nginx reports no such Uptime, ver, and build index (the hell happened to csg)) because of the Content-Length, I'm assuming. If I'm right, it's supposed to be 181 with the added variable, and 163 without.
Code: [Select]
2014/10/14 09:44:47 [error] 6958#0: *802 FastCGI sent in stderr: "PHP message: PHP Notice:  Undefined index: ver in /srv/http/blmaster/postServer.php on line 16
PHP message: PHP Notice:  Undefined index: build in /srv/http/blmaster/postServer.php on line 16
PHP message: PHP Notice:  Undefined index: Uptime in /srv/http/blmaster/postServer.php on line 16" while reading response header from upstream, client: [my IP], server: [my custom master server's URL], request: "POST /postServer.php HTTP/1.0", upstream: "fastcgi://127.0.0.1:64000", host: "[my custom master server's URL]"

Is there a better way to do this, or do I just need to outright make my own method of posting to my master server?

I ask this because I can't seem to figure out what Blockland is doing to remove dead servers from the main master list. My workaround idea was to send the uptime of each server everytime it posted using the default function, and have a script on the server check for duplicate uptimes via cron every so often (e.g. 10 minutes, since it posts every 5*timescale).

I'm also wanting to make a separate master server for my friends and I. We're all still paranoid of being DDoS'd and I've been told it still happens from other active users I keep in touch with. It works, except for this and names, which according to trinick, you need to tap into the auth server to do, and I'd rather stay far the hell away.
Someone's gonna ask, there's your answer.

I believe the master server does a 5 min check with each server to see if it can communicate back. If not, it will remove it.

I believe the master server does a 5 min check with each server to see if it can communicate back. If not, it will remove it.
I mentioned that lol. I'm asking for what Blockland is sending back - what function, packet, string, w/e, or sending an extra variable through to do my own checks.

I think you are able to dump the post object

ok well

I figured out a workaround that doesn't involve Blockland at all, and it's just to use time() on the PHP side of things to determine when the server posted.

This could still be useful though, so I'll leave it unlocked in case I can get an answer.

The way I remove dead servers from the master server list is by storing the time of the server posting with the server data. Then every time someone loads the server list it removes all servers that haven't posted for 5 minutes and displays the rest.

Here, I'll post my PHP code.

Retrieval Page
Code: [Select]
<?php
$con mysqli_connect("---""---""---""---");

if(mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " mysqli_connect_error();
}

$prune mysqli_query($con"DELETE FROM Servers WHERE (TIME < NOW() - INTERVAL 5 MINUTE)");

$result mysqli_query($con,"SELECT * FROM Servers");

echo "FIELDS\tIP\tPORT\tPASSWORDED\tDEDICATED\tSERVERNAME\tPLAYERS\tMAXPLAYERS\tMAPNAME\tBRICKCOUNT\n";

echo "START\n";

while($row mysqli_fetch_array($result)) {
  echo $row['IP'] . "\t" $row['PORT'] . "\t" $row['PASSWORDED'] . "\t" $row['DEDICATED'] . "\t" $row['SERVERNAME'] . "\t" $row['PLAYERS'] . "\t" $row['MAXPLAYERS'] . "\t" $row['MAPNAME'] . "\t" $row['BRICKCOUNT'] . "\n";
}

echo "END\n";

mysqli_close($con);
?>


Posting Page
Code: [Select]
<?php
$con mysqli_connect("---""---""---""---");

if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " mysqli_connect_error();
}

$prune mysqli_prepare($con"DELETE FROM Servers WHERE IP='?'");
mysqli_stmt_bind_param($prune"s"$_SERVER[REMOTE_ADDR]);
mysqli_stmt_execute($prune);

$sqlStmt mysqli_prepare($con"INSERT INTO Servers (IP, PORT, PASSWORDED, DEDICATED, SERVERNAME, PLAYERS, MAXPLAYERS, MAPNAME, BRICKCOUNT, TIME)
  VALUES (?, ?, ?, ?, ?, ?, ?, \"? (?)\", ?, current_timestamp)"
);
mysqli_stmt_bind_param($sqlStmt"ssiisiissi"$_SERVER[REMOTE_ADDR], $_POST[Port], $_POST[Passworded],$_POST[Dedicated], $_POST[ServerName], $_POST[Players], $_POST[MaxPlayers], $_POST[Map], $_POST[ver], $_POST[BrickCount]);
mysqli_stmt_execute($sqlStmt) or die(mysqli_error($con));

mysqli_close($con);
?>

« Last Edit: October 18, 2014, 05:42:08 PM by $trinick »