util/cn-fileserver

cn-fileserver serves files from a directory over CNP.

It can also list directory contents as a CNM document.

Installation

cn-fileserver requires Go 1.8 or later.

Install it with:

go install contnet.org/util/cn-fileserver@latest

Usage

Run it with cn-fileserver [OPTIONS]

Available options:

  • -dir DIR: serve files from folder DIR (default .)

  • -listen HOST:PORT: listen on HOST:PORT (default localhost:25454; port is optional and defaults to 25454)

  • -select SELECTORS: comma-separated list of enabled selectors (default byte,info,cnm enables all selectors; -select= to disable selectors)

File matching rules:

  • If the requested path doesn't end with / but is a folder, it will be redirected to the same path with a slash appended.

  • If the requested path is a folder that contains a file named index.cnm, that file will be sent as the response.

  • If the requested path is a file, the file will be sent as the response.

  • If the requested path with .cnm appended is a file, that file will be sent as the response.

  • Otherwise the requested path does not exist and an error response is sent.

For example: cn-fileserver -listen 0.0.0.0 -dir /var/contnet/cnroot

A sample systemd service unit file is also provided with the source code.

Source

The cn-fileserver source code is available on https://git.clsr.net/contnet/cn-fileserver