Hi !
Here's the situation:
I am running ManuAdminMod on my homePC and my gameserver is hosted elsewhere (at EscapedTurkey.com) so I am using the 'Log tracing by FTP' function to trace the games_mp.log file.
However, EscapedTurkey requires that your 'game server account must not be continuously accessed for FTP, log files, or statistics'. They have an limit of 500 FTP transfers per 24 hours, else your IP will be banned. :banned: This happened to me yesterday, so that's why I am opening this topic
The problem is that ManuAdminMod makes an FTP transfer every 2 seconds. See the serverlogfile EscapedTurkey support sent me below:
Mon May 17 21:57:17 2010 1 85.145.XXX.XXX 0 /cod4/main/games_mp.log b _ o r freek_1 ftp 0 * c
Mon May 17 21:57:18 2010 1 85.145.XXX.XXX 0 /cod4/main/games_mp.log b _ o r freek_1 ftp 0 * c
Mon May 17 21:57:20 2010 1 85.145.XXX.XXX 0 /cod4/main/games_mp.log b _ o r freek_1 ftp 0 * c
Mon May 17 21:57:21 2010 1 85.145.XXX.XXX 0 /cod4/main/games_mp.log b _ o r freek_1 ftp 0 * c
Mon May 17 21:57:22 2010 1 85.145.XXX.XXX 0 /cod4/main/games_mp.log b _ o r freek_1 ftp 0 * c
Mon May 17 21:57:23 2010 1 85.145.XXX.XXX 0 /cod4/main/games_mp.log b _ o r freek_1 ftp 0 * c
Mon May 17 21:57:25 2010 1 85.145.XXX.XXX 0 /cod4/main/games_mp.log b _ o r freek_1 ftp 0 * c
Mon May 17 21:57:26 2010 1 85.145.XXX.XXX 0 /cod4/main/games_mp.log b _ o r freek_1 ftp 0 * c
Mon May 17 21:57:27 2010 1 85.145.XXX.XXX 0 /cod4/main/games_mp.log b _ o r freek_1 ftp 0 * c
Mon May 17 21:57:28 2010 1 85.145.XXX.XXX 0 /cod4/main/games_mp.log b _ o r freek_1 ftp 0 * c
Mon May 17 21:57:30 2010 1 85.145.XXX.XXX 0 /cod4/main/games_mp.log b _ o r freek_1 ftp 0 * c
Mon May 17 21:57:32 2010 1 85.145.XXX.XXX 0 /cod4/main/games_mp.log b _ o r freek_1 ftp 0 * c
Mon May 17 21:57:33 2010 1 85.145.XXX.XXX 0 /cod4/main/games_mp.log b _ o r freek_1 ftp 0 * c
Mon May 17 21:57:34 2010 1 85.145.XXX.XXX 0 /cod4/main/games_mp.log b _ o r freek_1 ftp 0 * c
Mon May 17 21:57:35 2010 1 85.145.XXX.XXX 0 /cod4/main/games_mp.log b _ o r freek_1 ftp 0 * c
Mon May 17 21:57:36 2010 1 85.145.XXX.XXX 0 /cod4/main/games_mp.log b _ o r freek_1 ftp 0 * c
Mon May 17 21:57:38 2010 1 85.145.XXX.XXX 0 /cod4/main/games_mp.log b _ o r freek_1 ftp 0 * c
Mon May 17 21:57:40 2010 1 85.145.XXX.XXX 0 /cod4/main/games_mp.log b _ o r freek_1 ftp 0 * c
Mon May 17 21:57:41 2010 1 85.145.XXX.XXX 0 /cod4/main/games_mp.log b _ o r freek_1 ftp 0 * c
Mon May 17 21:57:42 2010 1 85.145.XXX.XXX 0 /cod4/main/games_mp.log b _ o r freek_1 ftp 0 * c
Mon May 17 21:57:43 2010 1 85.145.XXX.XXX 0 /cod4/main/games_mp.log b _ o r freek_1 ftp 0 * c
Mon May 17 21:57:45 2010 1 85.145.XXX.XXX 0 /cod4/main/games_mp.log b _ o r freek_1 ftp 0 * c
Mon May 17 21:57:46 2010 1 85.145.XXX.XXX 0 /cod4/main/games_mp.log b _ o r freek_1 ftp 0 * c
Mon May 17 21:57:47 2010 1 85.145.XXX.XXX 0 /cod4/main/games_mp.log b _ o r freek_1 ftp 0 * c
Mon May 17 21:57:48 2010 1 85.145.XXX.XXX 0 /cod4/main/games_mp.log b _ o r freek_1 ftp 0 * c
Mon May 17 21:57:50 2010 1 85.145.XXX.XXX 0 /cod4/main/games_mp.log b _ o r freek_1 ftp 0 * c
Mon May 17 21:57:51 2010 1 85.145.XXX.XXX 0 /cod4/main/games_mp.log b _ o r freek_1 ftp 0 * c
Mon May 17 21:57:53 2010 1 85.145.XXX.XXX 0 /cod4/main/games_mp.log b _ o r freek_1 ftp 0 * c
Mon May 17 21:57:54 2010 1 85.145.XXX.XXX 0 /cod4/main/games_mp.log b _ o r freek_1 ftp 0 * c
Mon May 17 21:57:55 2010 1 85.145.XXX.XXX 0 /cod4/main/games_mp.log b _ o r freek_1 ftp 0 * c
Mon May 17 21:57:56 2010 1 85.145.XXX.XXX 0 /cod4/main/games_mp.log b _ o r freek_1 ftp 0 * c
Mon May 17 21:57:58 2010 1 85.145.XXX.XXX 0 /cod4/main/games_mp.log b _ o r freek_1 ftp 0 * c
Mon May 17 21:57:59 2010 1 85.145.XXX.XXX 0 /cod4/main/games_mp.log b _ o r freek_1 ftp 0 * c
Mon May 17 21:58:01 2010 1 85.145.XXX.XXX 0 /cod4/main/games_mp.log b _ o r freek_1 ftp 0 * c
Mon May 17 21:58:02 2010 1 85.145.XXX.XXX 0 /cod4/main/games_mp.log b _ o r freek_1 ftp 0 * c
Mon May 17 21:58:03 2010 1 85.145.XXX.XXX 0 /cod4/main/games_mp.log b _ o r freek_1 ftp 0 * c
Mon May 17 21:58:05 2010 1 85.145.XXX.XXX 0 /cod4/main/games_mp.log b _ o r freek_1 ftp 0 * c
Alles anzeigen
As you can see from the times, ManuAdminMod makes an FTP transfer every 2 seconds. And since they have a limit of 500 transfers per 24 hours, my IP will get banned very quickly, causing that I cannot access my own gameserver anymore ! :banned:
My question: Is there a way to limit the amount of FTP transfers or limit the interval between the FTP transfers ManuAdminMod makes ?
I found that the file 'parser_ftp.class' handles the FTP logtracing. (It's located in \adminmod\classes ) and looks like this:
<?php
class parser_ftp extends parser {
private $host;
private $user;
private $pw;
private $port;
private $passive;
private $localLogFile;
private $remoteLogFile;
private $con;
private $logging;
private $connected = 0;
public function __construct($logfile, &$success, $host, $user, $pw, $port, $passive = true) {
$this->logging = &$GLOBALS['logging'];
$this->host = $host;
$this->user = $user;
$this->pw = $pw;
$this->port = $port;
$this->passive = $passive;
$this->remoteLogFile["dir"] = dirname($logfile);
$this->remoteLogFile["file"] = basename($logfile);
$this->localLogFile = LOGDIR . "/ftplog.tmp";
if (!$this->connect($errmsg)) {
$success = false;
$this->logging->write(MOD_ERROR, "FTP error: $errmsg");
}
else {
$this->logging->write(MOD_NOTICE, "Successfully connected to FTP server: '$this->host' on port $this->port as '$this->user'");
}
parent::__construct($this->localLogFile, $success);
}
private function connect(&$errmsg = "") {
$this->con = ftp_connect($this->host, $this->port, 5);
if (!$this->con) {
$errmsg = "Connection to $this->host on port $this->port failed";
//No connection
return false;
}
if (!ftp_login($this->con, $this->user, $this->pw)) {
$errmsg = "Login failed with user $this->user";
//Dir does not exist
return false;
}
if (!ftp_pasv($this->con, $this->passive)) {
$errmsg = "Passive mode not available at this server";
//Passive mode not available
return false;
}
if (!ftp_chdir($this->con, $this->remoteLogFile["dir"])) {
$errmsg = "Dir does not exist: {$this->remoteLogFile['dir']}";
//Dir does not exist
return false;
}
$size = ftp_size($this->con, $this->remoteLogFile["file"]);
if ($size == -1) {
$errmsg = "File {$this->remoteLogFile["file"]} does not exist or server does not support SIZE";
//Server does not support "size"
return false;
}
if ($this->logpos === false) {
$this->logpos = $size;
}
$fp = fopen($this->localLogFile, "w");
if (!$fp) {
$errmsg = "Error writing to LOCAL file $this->localLogFile, maybe not enough permissions";
return false;
}
fseek($fp, $this->logpos -1, SEEK_SET);
fwrite($fp, "\0", 1);
fclose($fp);
$this->connected = time();
return true;
}
public function getNewLines() {
if (!is_resource($this->con)) {
$this->error(1);
return array();
}
/*
//Reconnect after 12h
if (time() - $this->connected > 12 * 60 * 60) {
$this->disconnect();
sleep(2);
if ($this->connect($errmsg)) {
$this->logging->write(MOD_NOTICE, "Successfully reconnected after 12hrs");
}
else {
$this->error(4);
}
}
*/
$status = ftp_get($this->con, $this->localLogFile, $this->remoteLogFile["file"], FTP_BINARY, $this->logpos);
if (!$status) {
$this->error(2);
return array();
}
clearstatcache();
if (filesize($this->localLogFile) - $this->logpos > 140 * 300) { //140 Zeichen Durchnitt pro Zeile, 500 Zeilen maximal!!
$this->error(3);
return array();
}
$lines = parent::getNewLines();
return $lines;
}
public function __destruct() {
$this->disconnect();
}
private function disconnect() {
file_put_contents($this->localLogFile, "");
if (is_resource($this->con)) {
ftp_quit($this->con);
}
}
private function error($code = 0) {
$this->logging->write(MOD_WARNING, "Error getting new loglines by FTP (code: $code), trying to reconnect...");
$this->disconnect();
$logpos = $this->logpos;
for ($i = 1; $i <= 5; $i ++) {
$this->logging->write(MOD_NOTICE, "waiting ".pow(2, $i)." seconds until next try...");
sleep(pow(2, $i));
if ($this->connect($errmsg)) {
$this->logging->write(MOD_NOTICE, "Successfully reconnected to FTP server: '$this->host' on port $this->port as '$this->user'");
$this->logpos = $logpos;
return;
}
$this->logging->write(MOD_WARNING, "Reconnect ($i) failed: '$errmsg'");
}
$this->logging->write(MOD_ERROR, "FTP-Connection failed after 5 retries, quitting mod");
}
}
Alles anzeigen
I hope someone can help me limiting the amount/interval of FTP transfers. I think it shouldn't be too hard, I am guessing by just adding some pauses in the script above the problem can be solved.
Without this solution, I cannot run ManuAdminMod on my server .. :omg: MANU ADMIN MOD !!
Thanks in advance for the trouble to be taken !