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.39k stars 1.56k forks source link

Download backup url from api not working #4947

Closed FireBall1725 closed 7 months ago

FireBall1725 commented 7 months ago

Current Behavior

Currently hitting the Pterodactyl user api to request a url to download a backup, the url is https://xxxxxxxxx/api/client/servers/b1107111/backups/106ad220-fa76-437b-ac63-a2bf051a6a38/download, I get back a 200 and json body containing the url. Looks something like this:

{"object":"signed_url","attributes":{"url":"https:\/\/xxxxxxxxxxxxxxx:8080\/download\/backup?token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiIsImp0aSI6IjNiNDNhYmE4MmVmOTQwY2EzNDA2YTM0YWUxZTdjNzIzIn0.eyJpc3MiOiJodHRwczovL21jcGFuZWwuZmlyZWJhbGwxNzI1LmNhIiwiYXVkIjpbImh0dHBzOi8vbWMuZmlyZWJhbGwxNzI1LmNhOjgwODAiXSwianRpIjoiM2I0M2FiYTgyZWY5NDBjYTM0MDZhMzRhZTFlN2M3MjMiLCJpYXQiOjE3MDIxNzc4NzEsIm5iZiI6MTcwMjE3NzU3MSwiZXhwIjoxNzAyMTc4NzcxLCJiYWNrdXBfdXVpZC..........AtNjZjNjJhYmVkOWI3IiwidW5pcXVlX2lkIjoiZk1vWFZrcHVVRmR0TDE1YyJ9.EZ6eqwdUakPqoEStHt8JHKIr81y8C_lXWjR4WRLjOAc"}}

However, when I go to the url provided, i get an error:

{"error":"The requested resource was not found on this server."}

However 2 times out of ~30 or so attempts have worked. I have 2 nodes, and run into the same issue with both nodes. The api key is generated from a user with admin and full access to all the servers.

Expected Behavior

I would expect the api would return a url that would work to download the backup file

Steps to Reproduce

Request download link using the Download backup API as described here: https://dashflo.net/docs/api/pterodactyl/v1/#req_7bb6192283af4a30b37663b82c260ad7

Panel Version

1.11.5

Wings Version

1.11.8

Games and/or Eggs Affected

Minecraft (Fabric), Minecraft (Forge)

Docker Image

ghcr.io/pterodactyl/yolks:java_17

Error Logs

not able to find anything in any of the logs that show an error when the url is accessed

Is there an existing issue for this?

matthewpi commented 7 months ago

Did you happen to transfer servers between nodes after the backups were created?

If so the backups wouldn't have been transferred https://github.com/pterodactyl/panel/issues/2623


Outside of that, could you check that the backups are actually on the node? By default they are stored in /var/lib/pterodactyl/backups.

FireBall1725 commented 7 months ago

I didn't transfer the server between nodes.

Also, the backup files are located in /var/lib/pterodactyl/backups. I'm also able to manually download the backup via the panel UI as well without issue, it just with the URL that is provided by the API is the issue.

FireBall1725 commented 7 months ago

I decoded the token that i'm being given and it returns:

{
  "iss": "https://xxxxxxxxxx.ca",
  "aud": [
    "https://gameserver01.xxxxxxxxxxxx.com:8080"
  ],
  "jti": "3b43aba82ef940ca3406a34ae1e7c723",
  "iat": 1702216350,
  "nbf": 1702216050,
  "exp": 1702217250,
  "backup_uuid": "deba5f1f-0455-4def-a98b-660c48151594",
  "server_uuid": "b1107111-8ef9-4536-8370-66c62abed9b7",
  "user_uuid": "b7b235ed-0040-47bd-a35c-96425f0f9516",
  "user_id": 1,
  "unique_id": "uxgiWpVckx6osDbb"
}

The server uuid is correct, and the backup uuid exists

root@gameserver01:/var/lib/pterodactyl/backups# ls | grep deba5f1f-0455-4def-a98b-660c48151594
deba5f1f-0455-4def-a98b-660c48151594.tar.gz

So its weird that the api says it can't find the file, it also doesn't log any errors that i can find

FireBall1725 commented 7 months ago

With the help of the debug logs and through trial and error i found out the download link is a one time use link. The message with the download link was being posted in discord by a bot, and as such discord was trying to load a preview which used up the one time link