config xmlrpc tag 'login' changed to 'user'
quit on invalid configuration instead of triggering an error validate user name
This commit is contained in:
parent
96e573e8bd
commit
2172962622
@ -9,7 +9,7 @@
|
|||||||
<port>port</port>
|
<port>port</port>
|
||||||
|
|
||||||
<!-- XmlRpc Login Details -->
|
<!-- XmlRpc Login Details -->
|
||||||
<login>SuperAdmin</login>
|
<user>SuperAdmin</user>
|
||||||
<pass>password</pass>
|
<pass>password</pass>
|
||||||
|
|
||||||
</server>
|
</server>
|
||||||
|
@ -27,6 +27,7 @@ use ManiaControl\Update\UpdateManager;
|
|||||||
use ManiaControl\Utils\CommandLineHelper;
|
use ManiaControl\Utils\CommandLineHelper;
|
||||||
use ManiaControl\Utils\Formatter;
|
use ManiaControl\Utils\Formatter;
|
||||||
use Maniaplanet\DedicatedServer\Connection;
|
use Maniaplanet\DedicatedServer\Connection;
|
||||||
|
use Maniaplanet\DedicatedServer\Xmlrpc\AuthenticationException;
|
||||||
use Maniaplanet\DedicatedServer\Xmlrpc\Exception;
|
use Maniaplanet\DedicatedServer\Xmlrpc\Exception;
|
||||||
use Maniaplanet\DedicatedServer\Xmlrpc\TransportException;
|
use Maniaplanet\DedicatedServer\Xmlrpc\TransportException;
|
||||||
|
|
||||||
@ -345,7 +346,7 @@ class ManiaControl implements CommandListener, TimerListener {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
$this->client = Connection::factory($this->server->config->host, $this->server->config->port, self::SCRIPT_TIMEOUT, $this->server->config->login, $this->server->config->pass, self::API_VERSION);
|
$this->client = Connection::factory($this->server->config->host, $this->server->config->port, self::SCRIPT_TIMEOUT, $this->server->config->login, $this->server->config->pass, self::API_VERSION);
|
||||||
} catch (Exception $e) {
|
} catch (AuthenticationException $e) {
|
||||||
$message = "Couldn't authenticate on Server with User '{$this->server->config->login}' & Pass '{$this->server->config->pass}'! " . $e->getMessage();
|
$message = "Couldn't authenticate on Server with User '{$this->server->config->login}' & Pass '{$this->server->config->pass}'! " . $e->getMessage();
|
||||||
$this->quit($message, true);
|
$this->quit($message, true);
|
||||||
}
|
}
|
||||||
|
@ -103,13 +103,13 @@ class Server implements CallbackListener {
|
|||||||
if ($serverId) {
|
if ($serverId) {
|
||||||
$serverElements = $this->maniaControl->config->xpath("server[@id='{$serverId}']");
|
$serverElements = $this->maniaControl->config->xpath("server[@id='{$serverId}']");
|
||||||
if (!$serverElements) {
|
if (!$serverElements) {
|
||||||
trigger_error("No Server configured with the ID '{$serverId}'!", E_USER_ERROR);
|
$this->maniaControl->quit("No Server configured with the ID '{$serverId}'!", true);
|
||||||
}
|
}
|
||||||
$serverElement = $serverElements[0];
|
$serverElement = $serverElements[0];
|
||||||
} else {
|
} else {
|
||||||
$serverElements = $this->maniaControl->config->xpath('server');
|
$serverElements = $this->maniaControl->config->xpath('server');
|
||||||
if (!$serverElements) {
|
if (!$serverElements) {
|
||||||
trigger_error('No Server configured!', E_USER_ERROR);
|
$this->maniaControl->quit('Invalid server configuration (No Server configured).', true);
|
||||||
}
|
}
|
||||||
$serverElement = $serverElements[0];
|
$serverElement = $serverElements[0];
|
||||||
}
|
}
|
||||||
@ -117,33 +117,39 @@ class Server implements CallbackListener {
|
|||||||
// Host
|
// Host
|
||||||
$hostElements = $serverElement->xpath('host');
|
$hostElements = $serverElement->xpath('host');
|
||||||
if (!$hostElements) {
|
if (!$hostElements) {
|
||||||
trigger_error("Invalid server configuration (Host).", E_USER_ERROR);
|
$this->maniaControl->quit('Invalid server configuration (Missing Host).', true);
|
||||||
}
|
}
|
||||||
$host = (string)$hostElements[0];
|
$host = (string)$hostElements[0];
|
||||||
|
|
||||||
// Port
|
// Port
|
||||||
$portElements = $serverElement->xpath('port');
|
$portElements = $serverElement->xpath('port');
|
||||||
if (!$portElements) {
|
if (!$portElements) {
|
||||||
trigger_error("Invalid server configuration (Port).", E_USER_ERROR);
|
$this->maniaControl->quit('Invalid server configuration (Missing Port).', true);
|
||||||
}
|
}
|
||||||
$port = (string)$portElements[0];
|
$port = (string)$portElements[0];
|
||||||
|
|
||||||
// Login
|
// Login
|
||||||
$loginElements = $serverElement->xpath('login');
|
$userElements = $serverElement->xpath('user');
|
||||||
if (!$loginElements) {
|
if (!$userElements) {
|
||||||
trigger_error("Invalid server configuration (Login).", E_USER_ERROR);
|
$userElements = $serverElement->xpath('login');
|
||||||
|
}
|
||||||
|
if (!$userElements) {
|
||||||
|
$this->maniaControl->quit('Invalid server configuration (Missing User).', true);
|
||||||
|
}
|
||||||
|
$user = (string)$userElements[0];
|
||||||
|
if (!in_array($user, array('SuperAdmin', 'Admin', 'User'))) {
|
||||||
|
$this->maniaControl->quit('Invalid server configuration (Invalid User).', true);
|
||||||
}
|
}
|
||||||
$login = (string)$loginElements[0];
|
|
||||||
|
|
||||||
// Password
|
// Password
|
||||||
$passElements = $serverElement->xpath('pass');
|
$passElements = $serverElement->xpath('pass');
|
||||||
if (!$passElements) {
|
if (!$passElements) {
|
||||||
trigger_error("Invalid server configuration (Pass).", E_USER_ERROR);
|
$this->maniaControl->quit('Invalid server configuration (Pass).', true);
|
||||||
}
|
}
|
||||||
$pass = (string)$passElements[0];
|
$pass = (string)$passElements[0];
|
||||||
|
|
||||||
// Create config object
|
// Create config object
|
||||||
$config = new ServerConfig($serverId, $host, $port, $login, $pass);
|
$config = new ServerConfig($serverId, $host, $port, $user, $pass);
|
||||||
if (!$config->validate()) {
|
if (!$config->validate()) {
|
||||||
$this->maniaControl->quit("Your config file doesn't seem to be maintained properly. Please check the server configuration again!", true);
|
$this->maniaControl->quit("Your config file doesn't seem to be maintained properly. Please check the server configuration again!", true);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user