Browse Source

implement startup mode, init nex filesystem server

main
yggverse 2 weeks ago
parent
commit
5d8c8b122b
  1. 6
      README.md
  2. 1
      default.json
  3. 6
      src/Controller/Nex/Filesystem.php
  4. 26
      src/server.php

6
README.md

@ -11,6 +11,10 @@ Based on [Ratchet](https://github.com/ratchetphp/Ratchet) asynchronous socket li @@ -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 @@ -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
default.json

@ -1,5 +1,6 @@ @@ -1,5 +1,6 @@
{
"host":"127.0.0.1",
"mode":"fs",
"list":true,
"dump":true
}

6
src/Controller/Nex.php → src/Controller/Nex/Filesystem.php

@ -1,10 +1,10 @@ @@ -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 @@ -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
);
}

26
src/server.php

@ -31,11 +31,26 @@ try @@ -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 @@ -56,4 +71,7 @@ try
catch (\Exception $exception)
{
// @TODO
print(
$exception->getMessage()
) . PHP_EOL;
}

Loading…
Cancel
Save