@ -3,52 +3,49 @@
@@ -3,52 +3,49 @@
// Load dependencies
require_once __DIR__ . '/../vendor/autoload.php';
// Scan host
foreach ((array) scandir(__DIR__ . '/../host') as $host )
// Check arguments
if (empty($argv[1]) )
{
// Skip meta
if ($host == '.' || $host == '..' || is_file($host))
{
continue;
}
// Check host configured
if (!file_exists(__DIR__ . '/../host/' . $host . '/config.json'))
{
echo sprintf(
_('Host "%s" not configured!') . PHP_EOL,
$host
);
continue;
exit(_('Configured hostname required as argument!') . PHP_EOL);
}
// Check cert exists
if (!file_exists(__DIR__ . '/../host/' . $host . '/cert.pem'))
if (!file_exists(__DIR__ . '/../host/' . $argv[1] . '/cert.pem'))
{
echo sprintf(
exit(
sprintf(
_('Certificate for host "%s" not found!') . PHP_EOL,
$host
$argv[1]
)
);
continue;
}
// Check key exists
if (!file_exists(__DIR__ . '/../host/' . $host . '/key.rsa'))
if (!file_exists(__DIR__ . '/../host/' . $argv[1] . '/key.rsa'))
{
echo sprintf(
exit(
sprintf(
_('Key for host "%s" not found!') . PHP_EOL,
$host
$argv[1]
)
);
}
continue;
// Check host configured
if (!file_exists(__DIR__ . '/../host/' . $argv[1] . '/config.json'))
{
exit(
sprintf(
_('Host "%s" not configured!') . PHP_EOL,
$argv[1]
)
);
}
// Init config
$config = json_decode(
file_get_contents(
__DIR__ . '/../host/' . $host . '/config.json'
__DIR__ . '/../host/' . $argv[1] . '/config.json'
)
);
@ -64,11 +61,11 @@ foreach ((array) scandir(__DIR__ . '/../host') as $host)
@@ -64,11 +61,11 @@ foreach ((array) scandir(__DIR__ . '/../host') as $host)
$server = new \Yggverse\TitanII\Server();
$server->setCert(
__DIR__ . '/../host/' . $host . '/cert.pem'
__DIR__ . '/../host/' . $argv[1] . '/cert.pem'
);
$server->setKey(
__DIR__ . '/../host/' . $host . '/key.rsa'
__DIR__ . '/../host/' . $argv[1] . '/key.rsa'
);
$server->setHandler(
@ -276,7 +273,7 @@ foreach ((array) scandir(__DIR__ . '/../host') as $host)
@@ -276,7 +273,7 @@ foreach ((array) scandir(__DIR__ . '/../host') as $host)
// Start server
echo sprintf(
_('Server "%s" started on %s:%d') . PHP_EOL,
$host ,
$argv[1] ,
$config->gemini->server->host,
$config->gemini->server->port
);
@ -285,4 +282,3 @@ foreach ((array) scandir(__DIR__ . '/../host') as $host)
@@ -285,4 +282,3 @@ foreach ((array) scandir(__DIR__ . '/../host') as $host)
$config->gemini->server->host,
$config->gemini->server->port
);
}