mirror of
https://github.com/YGGverse/next.git
synced 2025-03-12 05:31:04 +00:00
implement startup mode, init nex filesystem server
This commit is contained in:
parent
1ec4b61970
commit
5d8c8b122b
@ -11,6 +11,10 @@ Based on [Ratchet](https://github.com/ratchetphp/Ratchet) asynchronous socket li
|
||||
* Multi-protocol:
|
||||
* [x] [NEX](https://nightfall.city/nex/info/specification.txt)
|
||||
* [ ] [Gemini](https://geminiprotocol.net)
|
||||
* Multi-mode:
|
||||
* [x] Static filesystem
|
||||
* [ ] Dynamic application
|
||||
* [ ] Reverse proxy
|
||||
* Connection event log
|
||||
* Optional:
|
||||
* file navigation on directory request
|
||||
@ -71,6 +75,8 @@ Provide arguments in `key=value` format, separated by space
|
||||
|
||||
###### Optional
|
||||
|
||||
* `mode` - server implementation variant, `fs` (filesystem) by default
|
||||
* `fs` - static files hosting for the `root` location
|
||||
* `host` - default is `127.0.0.1` e.g. `localhost` connections only
|
||||
* `port` - default value depends of server `type` selected, for example `1900` for `nex` or `1965` for `gemini`
|
||||
* `file` - index **file name** that server try to open on directory path requested, disabled by default
|
||||
|
@ -1,5 +1,6 @@
|
||||
{
|
||||
"host":"127.0.0.1",
|
||||
"mode":"fs",
|
||||
"list":true,
|
||||
"dump":true
|
||||
}
|
@ -1,10 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace Yggverse\Next\Controller;
|
||||
namespace Yggverse\Next\Controller\Nex;
|
||||
|
||||
use \Ratchet\MessageComponentInterface;
|
||||
|
||||
class Nex implements MessageComponentInterface
|
||||
class Filesystem implements MessageComponentInterface
|
||||
{
|
||||
private \Yggverse\Next\Model\Environment $_environment;
|
||||
private \Yggverse\Next\Model\Filesystem $_filesystem;
|
||||
@ -43,7 +43,7 @@ class Nex implements MessageComponentInterface
|
||||
(string) $this->_environment->get('port'),
|
||||
(string) $this->_filesystem->root()
|
||||
],
|
||||
_('[{time}] [init] server started at {host}:{port}{root}')
|
||||
_('[{time}] [init] filesystem server started at nex://{host}:{port}{root}')
|
||||
) . PHP_EOL
|
||||
);
|
||||
}
|
@ -31,11 +31,26 @@ try
|
||||
{
|
||||
case 'nex':
|
||||
|
||||
switch ($environment->get('mode'))
|
||||
{
|
||||
case 'fs':
|
||||
|
||||
$controller = new \Yggverse\Next\Controller\Nex\Filesystem(
|
||||
$environment,
|
||||
$filesystem
|
||||
);
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
throw new \Exception(
|
||||
_('unsupported mode for nex server type!')
|
||||
);
|
||||
}
|
||||
|
||||
$server = \Ratchet\Server\IoServer::factory(
|
||||
new \Yggverse\Next\Controller\Nex(
|
||||
$environment,
|
||||
$filesystem
|
||||
),
|
||||
$controller,
|
||||
$environment->get('port'),
|
||||
$environment->get('host')
|
||||
);
|
||||
@ -56,4 +71,7 @@ try
|
||||
catch (\Exception $exception)
|
||||
{
|
||||
// @TODO
|
||||
print(
|
||||
$exception->getMessage()
|
||||
) . PHP_EOL;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user