Skip to content

Make HTTP server host configurable to support dedicated servers/VPS#2

Draft
Copilot wants to merge 1 commit into
masterfrom
copilot/add-support-for-dedicated-servers
Draft

Make HTTP server host configurable to support dedicated servers/VPS#2
Copilot wants to merge 1 commit into
masterfrom
copilot/add-support-for-dedicated-servers

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 2, 2026

The HTTP server host was hardcoded to 127.0.0.1, making the API inaccessible from outside localhost — unusable on dedicated servers or VPS environments.

Changes

  • config.yml — adds host field (default 0.0.0.0) with inline comments explaining 0.0.0.0 vs 127.0.0.1
  • CommandApiPlugin.kt — reads host from config instead of hardcoding; falls back to 0.0.0.0 if unset; reflects actual host in startup log
# Use "0.0.0.0" to listen on all interfaces (required for dedicated servers / VPS).
# Use "127.0.0.1" to restrict access to localhost only.
host: "0.0.0.0"

Security note: With 0.0.0.0, the API is publicly reachable — ensure api-key is strong and consider firewall rules to restrict access to trusted IPs.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Makes the embedded Ktor HTTP server bind address configurable (instead of hardcoded localhost) so the API can be reachable when running on dedicated servers/VPS.

Changes:

  • Added host to config.yml (default 0.0.0.0) with explanatory comments.
  • Updated CommandApiPlugin to read host from config and use it when starting the Netty server.
  • Updated startup log to print the configured host.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
src/main/resources/config.yml Adds host setting and guidance for binding to all interfaces vs localhost.
src/main/kotlin/com/sentrysmp/CommandApiPlugin.kt Uses configured host for embeddedServer(...) and logs the chosen bind address.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +3 to +4
# Use "0.0.0.0" to listen on all interfaces (required for dedicated servers / VPS).
# Use "127.0.0.1" to restrict access to localhost only.
override fun onEnable() {
saveDefaultConfig()
val port = config.getInt("port", 8080)
val host = config.getString("host") ?: "0.0.0.0"
override fun onEnable() {
saveDefaultConfig()
val port = config.getInt("port", 8080)
val host = config.getString("host") ?: "0.0.0.0"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants