pterodactyl / panel

Pterodactyl® is a free, open-source game server management panel built with PHP, React, and Go. Designed with security in mind, Pterodactyl runs all game servers in isolated Docker containers while exposing a beautiful and intuitive UI to end users.
https://pterodactyl.io
Other
6.61k stars 1.66k forks source link

Allow accessing the console websocket from other origins than the panel #3735

Closed cozyGalvinism closed 2 years ago

cozyGalvinism commented 2 years ago

Is there an existing feature request for this?

Describe the feature you would like to see.

Currently it is only possible to connect to the websocket returned by https://pterodactyl.file.properties/api/client/servers/1a7ce997/websocket when passing an additional Origin header which is set to the URL of the panel. This makes it impossible to connect to the websocket server with JavaScript in a browser or with a websocket client that doesn't allow setting headers.

Since the websocket endpoint is listed in the documentation, it should be accessible to external websocket clients too, so my request is simply to remove the requirement for the Origin header.

This would allow more external clients to connect to the node and parse the console output. My personal example is that I'm currently writing a script for iOS's Scriptable app, which should get the connected players and return them in a Shortcut, basically allowing to ask Siri for stuff like "how many players are on server xyz?" and Siri returning the proper player count. Another example (even though I can set headers there) is a Python script I'm running, which changes the password of a Terraria server every time someone joins (which is realized using the websocket), basically creating OTPs to prevent accessing the server without getting the new password first (in this case, a Twitch viewer who follows a certain channel has to send a command to receive the password). Like I mentioned, the Python library allows for extra headers, but not every client does, so this makes accessing the websocket endpoint pretty limited.

Describe the solution you'd like.

Remove the check on the Origin header when connecting to the node's websocket.

Additional context to this request.

No response

yesBad commented 2 years ago

Wings Config (/etc/pterodactyl/config.yml) allowed-origins: []

That's prolly what you are looking for.

cozyGalvinism commented 2 years ago

Yup, I actually just found that in the wings router code. Though I feel like this should at least be documented on the API page. I keep tripping over that header ^^

Something like "by default, wings is configured to only allow the panel to connect to the Websocket server. If you need to connect from a different origin, please configure wings using the allowed-origins setting".

yesBad commented 2 years ago

Yup, I actually just found that in the wings router code. Though I feel like this should at least be documented on the API page. I keep tripping over that header ^^

Prolly should /shrug. The API page is unofficial tho 😛

cozyGalvinism commented 2 years ago

Oh wait it is? In that case, I'm sorry and I'll close this ^^

yesBad commented 2 years ago

Oh wait it is? In that case, I'm sorry and I'll close this ^^ chrome_x6LvMIpIEj

But yeah, good that you figured it out! Have fun with the app.