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.84k stars 1.75k forks source link

API automatic port range determination & egg config addition #1653

Open danir-de opened 5 years ago

danir-de commented 5 years ago

Is your feature request related to a problem? Please describe. A clear and concise description of what the problem is.

We want to auto assign multiple ports for an WHMCS order, but the WHMCS module seems to only assign static port ranges. The problem seems to be, that the API doesn't allow for an automatic assignment of multiple ports, without stating a static point range. For example, we have a customer buying a ARMA III server, we need a port for the basic game, one steam port and one RCON port, that's a total of three ports needed. Currently that's not easibly doable, you're only able to assign static port ranges.

Describe the solution you'd like A clear and concise description of what you want to happen.

What we would need, would be a possibility on the api to state that we need 3 ports in a row, while the panel / api automatically chooses a free port range and assigns it to the newly installed server. In order for the panel to be able to determine, how many ports are needed, you could expand the egg template configuration with a desired port amount.

Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.

Trixter from crident.com stated in the public support channel that :

the api doesn't really allow me to do it without having tens of requests per single deployment

Additional information May be similar, but not the same as #1012 #8

parkervcp commented 5 years ago

I believe this is similar to something I requested here https://github.com/pterodactyl/panel/issues/1204

parkervcp commented 5 years ago

That is to basically add the ability for an egg to specify that port and port+1 is required as a set.

DaneEveritt commented 5 years ago

I'm just gonna leave both open and linked together since they're effectively the same but could be accomplished differently and because its more likely to be found in a search by users. 👍

danir-de commented 5 years ago

I think it's something different and has another focus. This is not related to the chosen node, but rather means to expand the possibilities of dynamic and automatic port assignments.

Just read @DaneEveritt 's response. Thank you.

engel102030 commented 5 years ago

Unfortunately I have the same problem. Most server hosts that I sell need more than one port. Unfortunately, the whmcs module is practically useless for me, as we cannot define multiple ports for one server, so I have to manually release all servers. It would be helpful to add some feature that allows us to select more than one port for a server.

iamkubi commented 5 years ago

I've been looking at solutions to this as well, and I've come up with a rough idea of a change I'd like to implement for this. I'm relatively new to Pterodactyl, so any feedback would be appreciated. I don't have a great sense of advanced use cases for Allocations (especially assigning the Build Configuration -> Assign Additional Ports), but my impression is that assigning any port other than Game Port is fully manual.

A new optional field would be added to allocations called Group. Groups could then be referenced when creating a new Server to identify a desired type of allocation. As an example you could define an allocation that looks something like:

IP Address: 1.1.1.1, Ports: 27015, 7777, 7778, 27020, Group: Ark IP Address: 1.1.1.1, Ports: 27016, 7779, 7780, 27021, Group: Ark IP Address: 1.1.1.1, Ports: 27017, 27022, Group: CSGO IP Address: 1.1.1.1, Ports: 27018, 27023, Group: CSGO

The AllocationSelectionService would be updated to allow admins to specify a Group when creating a server, which would allow you to select from an allocation that is created with the ports needed for a specific egg.

I'd also like a way to indicate the purpose of the port to Pterodactyl, since the ports end up with specific purposes. For example, it appears to me that Build Config -> Game Port ends up in an environment variable used in Startup called {{SERVER_PORT}}. Startup for some games rely on {{RCON_PORT}}, however this can only be modified from the Startup page and not as part of the Build Configuration, which makes it impossible(?) to handle with an automated Allocation selection.

One way to accomplish this might be to use an associative array for the ports list in an Allocation. Something like: array( 'QUERY_PORT' => 27015, 'GAME_PORT' => 7777, 'GAME_PORT_RAW' => 7778, 'RCON_PORT' => 27020)

The keys will be populated as environment variables that can be used in the Startup config. If an indexed array is found it would maintain the current behavior.

This is still a very rough idea and I haven't fully read through all of the involved code. It's possible I'll discovery my proposed implementation is flawed, but I'm going to start hacking something together and see how it turns out. It looks like @DaneEveritt is the sole contributor for most of this code, so if you could provide any feedback I'd appreciate it.

Also @parkervcp as this relates to your issue #1204. It's possible eggs could add config entry that looked something like: "requested_ports": ["QUERY_PORT", "GAME_PORT", "GAME_PORT_RAW", "RCON_PORT"] The AllocationSelectionService could then search for Allocations that have requested_ports as keys in their port list.

parkervcp commented 5 years ago

you would more likely need a table assigned in the egg itself.

json formatted example, because eggs are stored in json.

{
    "ports":[{
            "port":{
                "variable":"GAME_PORT",
                "default": 7777,
                "range": 2
            }
        },
        {
            "port":{
                "variable":"QUERY_PORT",
                "default": 27015
            }
        },
        {
            "port":{
                "variable":"RCON_PORT",
                "default": 27020
            }
        }
    ]
}

Instead of adding the GAME_PORT_RAW value I made it a range so it would be game+1 essentially. Range of 1 would be the starting port (7777). A range of 2 would be the starting port and the next port (7777 and 7778 in this example). Default would be 0/1 and would just be the port itself.

This is could be expanded to more than just this of course. This is just the base layout.

iamkubi commented 5 years ago

After chatting with @parkervcp some I'm scrapping the idea of Allocation Groups to have this managed purely by the egg config. This won't require any UI changes and can still be customized by modifying the egg configs.

This should allow allocating multiple ports to work in a fully automated fashion without any additional configuration required on the admin's part. I see that as a big upside to this solution.

tmunsch commented 5 years ago

This is exactly what I need. Could someone provide me with an example? I am trying to do this for RUST so that it sets the RCON port to one above the GAME Port. How would i accomplish this? Call the variable GAME_PORT within the Default section of the RCON PORT? "port":{ "variable":"RCON_PORT", "default": {{GAME_PORT}} +1????

iamkubi commented 5 years ago

@tmunsch you can't. Today, to the best of my knowledge, there is no way to create a server with more than one allocation currently, you have to wait until the install has completed and go back to add the additional allocation (either manually or via custom automation). I have the logic for automatic allocation mostly implemented, I just need to write some tests and validate that it works, then work on updating the eggs to support automatic allocation.

I imagine I won't have time to wrap this up for at least another month.

caponeaus commented 5 years ago

Hey there, any update on this? Or any other way to allocate server port, then rcon port (server port+1) on server setup?

iamkubi commented 5 years ago

I decided to write a new WHMCS module that handles this. It's working well but I'm not quite ready to release it yet. Feel free to DM me (kubi#8194) on Discord for more details.

iamkubi commented 4 years ago

My WHMCS addon has been released and is running well. You can find it in the #third-party pins on Discord.

DAThosting commented 4 years ago

My WHMCS addon has been released and is running well. You can find it in the #third-party pins on Discord.

Your module is quite perfect. But how to add two extra ports to a product, I only find the port range (which set hardcoded ports)?

iamkubi commented 4 years ago

PteroBill doesn't use port range, instead it uses port array. There are examples in the setup guide.

DAThosting commented 4 years ago

I know, but this doesn't fix the problem. I just want to add two or more ports to a specific game. e.g. ARK needs three ports, a gamserver port, a query port and a rcon port. In order to use the game I have to assign two adittional ports to the game manually?!

//EDIT: I read over the first word in your answer and checked PteroBill a second ago. I'll check your module! Thought the normal WHMCS module on github will be the same.

ronaldvaneede commented 3 years ago

Is this still something that is being considered for building into Pterodactyl? I'm really interested in this feature. Currently I am using the 'Auto Allocation Adder' addon which does what I want but using that makes it more difficult to update the panel when a new version comes out. If I understood correctly PteroBill is a module for WHMCS but I/we are not using WHMCS so that is not an option for me.

mfoster978 commented 9 months ago

My WHMCS addon has been released and is running well. You can find it in the #third-party pins on Discord.

I can't message you on discord how can I try this out? If greatly appreciate it.

Boy132 commented 9 months ago

My WHMCS addon has been released and is running well. You can find it in the #third-party pins on Discord.

I can't message you on discord how can I try this out? If greatly appreciate it.

You can find it online. Search for "Pterobill".