PHP 8 Server for Nex Protocol
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

128 lines
4.4 KiB

7 months ago
# next
7 months ago
PHP 8 server for different protocols
7 months ago
7 months ago
Based on [Ratchet](https://github.com/ratchetphp/Ratchet) asynchronous socket library
## Features
7 months ago
* Async socket
* Multi-host
7 months ago
* Multi-protocol:
* [x] [NEX](https://nightfall.city/nex/info/specification.txt)
* [ ] [Gemini](https://geminiprotocol.net)
* Multi-mode:
7 months ago
* [x] Static file hosting
7 months ago
* [x] filesystem navigation on directory request
7 months ago
* [x] optional `gemfeed` file modification date
* [x] unicode filenames support
7 months ago
* [x] filter hidden context (started with dot)
7 months ago
* [ ] sort order settings (currently dir first, asc)
* [x] custom index file name
7 months ago
* [x] custom failure template
7 months ago
* [x] custom data directory location
7 months ago
* [ ] KevaCoin storage browser
7 months ago
* [ ] Dynamic application
* [ ] Reverse proxy
7 months ago
* [ ] Stream server
7 months ago
* Connection event log
7 months ago
* Simple and flexible server configuration by CLI arguments
7 months ago
## Install
7 months ago
### Environment
``` bash
apt install git composer php-fpm php-mbstring
```
### Stable
Project under development, use [repository](#repository) version!
### Repository
* `git clone https://github.com/YGGverse/next.git`
* `cd next` - navigate into the project directory
7 months ago
* `composer update` - grab latest dependencies
7 months ago
## Launch
7 months ago
### Start
7 months ago
7 months ago
Create as many servers as wanted by providing different `type`, `host`, `port`, `type`, `mode` and other arguments!
7 months ago
7 months ago
* for security reasons, file server prevents any access to the hidden files (started with dot)
7 months ago
* also, clients can't access any data out the `root` path, that defined on server startup
7 months ago
7 months ago
#### Startup example
7 months ago
``` bash
7 months ago
php src/server.php host=127.0.0.1 port=1900 type=nex mode=fs root=/target/dir
7 months ago
```
7 months ago
* `host` and `port` - optional arguments, read [Arguments documentation](#arguments) for details!
7 months ago
#### Arguments
7 months ago
Optional arguments auto-defined by server protocol `type` selected
7 months ago
7 months ago
Some arguments also defined in [default.json](https://github.com/YGGverse/next/blob/main/default.json) - do not change it without understanding, use [CLI](#cli) instead!
7 months ago
7 months ago
##### CLI
7 months ago
Provide arguments in `key=value` format, separated by space
7 months ago
7 months ago
Children nodes dependent of parent arguments defined and would be skipped in other combinations!
7 months ago
7 months ago
Following list explains `key` dependencies and it `value` options (started with `=`)
7 months ago
7 months ago
* `type` - required, server protocol, also auto-defines default `port`, supported options:
7 months ago
* = `nex` - [NEX Protocol](https://nightfall.city/nex/info/specification.txt)
7 months ago
* `mode` - optional, server implementation variant, `fs` (filesystem) by default
7 months ago
* = `fs` - static files hosting for the `root` location
7 months ago
* `root` - **absolute path** to the public directory, where browser navigation starting from
7 months ago
* `file` - **file name** that server try to open on directory path requested, disabled by default
* `list` - show listing in directory requested (on index `file` not found), enabled by default
7 months ago
* `date` - show file modification date (as gemfeed) in directory listing, disabled by default
7 months ago
* = `kevacoin` - [KevaCoin](https://github.com/kevacoin-project) storage browser by RPC connection to the wallet (see `kevacoin.conf`)
7 months ago
* `rpcscheme` - required, for example `http`
* `rpcport` - required, default is `9992`
* `rpchost` - required, remote or `localhost`
* `rpcuser` - required
* `rpcpassword` - required
* `namespace` - required, namespace identifier for data listing (started with `N`)
7 months ago
* `host` - optional, default is `127.0.0.1` e.g. `localhost` connections only
* `port` - optional, default value depends of server `type` selected e.g. `1900` for `nex` or `1965` for `gemini`
7 months ago
* `fail` - optional, **absolute path** to the failure template (e.g. `/path/to/error.gmi`), disabled by default
* `dump` - optional, `enable` or `disable` server debug feature, enabled by default
### Autostart
#### systemd
Following example mean you have `next` server installed into home directory of `next` user (`useradd -m next`)
``` next.service
# /etc/systemd/system/next.service
[Unit]
After=network.target
[Service]
Type=simple
User=next
Group=next
7 months ago
ExecStart=/usr/bin/php /home/next/next/src/server.php type=nex mode=fs root=/home/next/public
StandardOutput=file:/home/next/debug.log
StandardError=file:/home/next/error.log
Restart=on-failure
[Install]
WantedBy=multi-user.target
```
* `systemctl daemon-reload` - reload systemd configuration
* `systemctl enable next` - enable service on system startup
* `systemctl start next` - start server