一个在 Golang 中为 macOS、Linux 和 Windows 操作系统实现的 Hotline 服务器
Mobius is a cross-platform command line Hotline server implemented in Golang.
Mobius is distributed through a single binary.
Depending on your platform and preferences, you can acquire the binary in the following ways:
make serverSee Releases page.
To run a Hotline server with a default, sample configuration with ports forwarded from the host OS to the container:
docker run --rm -p 5500:5500 -p 5501:5501 ghcr.io/jhalter/mobius-hotline-server:latestYou can now connect to localhost:5500 with your favorite Hotline client and play around, but all changes will be lost on container restart.
To serve files from the host OS and persist configuration changes, you'll want to set up a bind mount that maps a directory from the host into the container.
To do this, create a directory in a location of your choice on the host OS. For clarity, we'll assign the path to the HLFILES environment variable and re-use it.
Then run the docker command with -v and -init like so:
export HLFILES=/home/myuser/hotline-files
mdkir $HLFILES
sudo docker run \
--pull=always \
--rm \
-p 5500:5500 \
-p 5501:5501 \
-v $HLFILES:/usr/local/var/mobius/config \
ghcr.io/jhalter/mobius-hotline-server:latest \
-initIt's a good security practice to run your server as a non-root user, which also happens to make editing the configuration files easier from the host OS.
To do this, add the --user flag to the docker run arguments with a user ID and group ID of a user on the host OS.
--user 1001:1001
For macOS the easiest path to installation is through Homebrew, as this works around Apple's notarization requirements for downloaded pre-compiled binaries by compiling the binary on your system during brew installation.
To install the server:
brew install jhalter/mobius-hotline-server/mobius-hotline-serverAfter installation mobius-hotline-server will be installed at $HOMEBREW_PREFIX/bin/mobius-hotline-server and should be in your $PATH.
The server config directory will be created under $HOMEBREW_PREFIX/var/mobius.
To start the service:
brew services start mobius-hotline-server
After you have a server binary, the next step is to configure the server.
Mobius stores its configuration and server state in a directory tree:
config
├── Agreement.txt
├── Files
│ └── hello.txt
├── MessageBoard.txt
├── ThreadedNews.yaml
├── Users
│ ├── admin.yaml
│ └── guest.yaml
├── banner.jpg
└── config.yamlIf you acquired the server binary by downloading it or compiling it, this directory doesn't exist yet! But you can generate it by running the the server with the -init flag:
./mobius-hotline-server -init -config example-config-dir
Brew users can find the config directory in $HOMEBREW_PREFIX/var/mobius.
Within this directory some files are intended to be edited to customize the server, while others are not.
️ Agreement.text - The server agreement sent to users after they join the server.
️ Files - Home of your warez or any other files you'd like to share.
⚠️ MessageBoard.txt - Plain text file containing the server's message board. No need to edit this.
⚠️ ThreadedNews.yaml - YAML file containing the server's threaded news. No need to edit this.
⚠️ Users - Directory containing user account YAML files. No need to edit this.
️ banner.jpg - Path to server banner image.
️ config.yaml - Edit to set your server name, description, and enable tracker registration.
An advanced NewsFeeds configuration can import RSS or Atom entries into an
existing ordinary news category, including Sparkle appcasts and GitHub release
feeds:
See Feed-backed threaded news for the complete administrator guide, including configuration rules, retention behavior, durable state, operational limits, and troubleshooting.
NewsFeeds:
- CategoryPath: ["Software Updates", "Afterglow"]
URL: "https://morphing.cloud/afterglow/appcast.xml"
- CategoryPath: ["Software Updates", "Mobius"]
URL: "https://github.com/jhalter/mobius/releases.atom"The full target path must already exist as an ordinary category. Whenever a
client opens it, Mobius conditionally checks the source and saves new entries
as ordinary root articles in ThreadedNews.yaml. Existing entries are never
rewritten, and deleted imports stay deleted. Feed failures are logged while the
current local articles remain available. RSS and Atom are detected
automatically; changes to NewsFeeds require restarting the server.
The default installation includes two users:
User administration should be performed from a Hotline client. Avoid editing the files under the Users directory.
By default running mobius-hotline-server will listen on ports 5500/5501 of all interfaces with info level logging to STDOUT.
Use the -h or -help flag for a list of options:
…To run as a systemd service, refer to this sample unit file: mobius-hotline-server.service
By default the file library is stored on the server's local disk. The -file-store flag selects an alternate backend:
os (default) — local filesystemmemory — in-memory, non-persistent (for testing)r2 — Cloudflare R2 object storageSee docs/r2-file-store.md for R2 setup instructions.
The Mobius server includes an optional HTTP API for server administration and user management.
To enable the API, use the --api-addr flag with an IP and port:
mobius-hotline-server --api-addr=127.0.0.1:5503The API supports optional authentication via API key. Set the --api-key flag:
mobius-hotline-server --api-addr=127.0.0.1:5503 --api-key=your-secret-keyInclude the API key in the X-API-Key header:
curl -H "X-API-Key: your-secret-key" localhost:5503/api/v1/statsComplete API documentation is available in the OpenAPI specification.
GET /api/v1/online - List currently online usersPOST /api/v1/ban - Ban a user by username, nickname, or IPPOST /api/v1/unban - Remove a banGET /api/v1/banned/ips - List banned IP addressesGET /api/v1/banned/usernames - List banned usernames GET /api/v1/banned/nicknames - List banned nicknamesGET /api/v1/stats - Get server statisticsPOST /api/v1/reload - Reload configurationPOST /api/v1/shutdown - Shutdown serverGet online users:
curl localhost:5503/api/v1/onlineBan a user:
curl -X POST -H "Content-Type: application/json" \
-d '{"username":"baduser"}' \
localhost:5503/api/v1/banGet server stats:
curl localhost:5503/api/v1/stats | jq .Shutdown server:
curl -X POST -d 'Server maintenance' localhost:5503/api/v1/shutdown暂无开放 Issues,或尚未同步最近议题。