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