Open jhead opened 4 years ago
An example
POST /api/servers/myServer
{
"name": "Test Server",
"prefs": {
"bindAddress": "0.0.0.0",
"bindPort": 0,
"remoteServer": "lax.mcbr.cubed.host:19132",
"idleTimeout": 0,
"ipv6": false
}
}
^ would create a new server and store it in phantom.json
automatically. That file also contains settings, etc., and you could edit it manually.
POST /api/servers/myServer/start
would start a proxy for that server, just like running phantom from the CLI normally.
POST api/servers/myServer/stop
would stop the proxy for that server.
Not all the endpoints are implemented yet but they should be soon.
@jhead awesome! I'll look into that, since I never worked with that kind of API. Do i just send a POST request to "/api/..." (instead an URL) with a JSON as parameters? Does this work on window aswell (since the file system is different than an UNIX like Systems)?
EDIT: NVM
but:
when I send a post request to "http://localhost:7377/api/servers/MyServer" with your example json, I get
[90m12:45PM[0m [31mWRN[0m Received invalid server object [31merror=[0m[31m"schema: converter not found for proxy.ProxyPrefs"[0m
in the commandline of phantom (ignore the wierd commandline formatting for the timestamp, seems to be a problem with my system)
EDIT2:
NVM again, I'm apparently just to dumb to use the requests-library of python.
@jhead Is there something in the API to remove a server from the JSON without having to fiddle with the JSON directly and overwriting it?
Is there something in the API to remove a server from the JSON without having to fiddle with the JSON directly and overwriting it?
You can use an HTTP DELETE request, for example: DELETE http://localhost:7377/api/servers/MyServer
would stop and delete the MyServer
server.
Does this work on window aswell (since the file system is different than an UNIX like Systems)?
It should, but let me know if you run into any issues 🙂
@jhead it indeed deletes the server, but it does not alter the JSON file and thus, when restarting the application, the server is back in the list
@WhatWheatleySaid thanks, fixed in 12e0418
@jhead another Bug I encountered is, that only the most recent started server seems to show up in minecraft in your newest version (when using the JSON REST API)
I don't know how closely related this could be connection-wise, but with the way this is connecting people over LAN would it be possible to make something like BungeeCord for bedrock (connecting multiple servers through portals)
I don't know how closely related this could be connection-wise, but with the way this is connecting people over LAN would it be possible to make something like BungeeCord for bedrock (connecting multiple servers through portals)
Hey @BRadHoc! Cool idea. I’m not sure if I want to build it into phantom though, since you could just setup phantom with one of the existing Bedrock proxies like DragonProxy, etc. Don’t reinvent the wheel, right?
existing Bedrock proxies like DragonProxy
DragonProxy is an abandoned project for joining Java Edition servers that was replaced by Geyser, you're probably thinking of things like WaterDog
Branch: feature/api
Here's an umbrella issue tracking work on providing an (optional) HTTP-based API for phantom. The goal is to provide an API that's sufficient for powering a UI or web app.
Goals
Features
-api
flag on the command lineservers
+ start/stop API to control the proxy for each serverphantom.json
for easy manual configurationLet me know if you have ideas for features!
A fair warning: a lot of the code and APIs could change from commit to commit, so if you build anything against this right now, expect it to break.