JoeJoeTV / AstroTuxLauncher

Launcher and management utility for running an Astroneer Dedicated Server on Linux using WINE
GNU General Public License v3.0
23 stars 4 forks source link

Add a port field to launcher.toml #5

Closed ImKringle closed 5 months ago

ImKringle commented 6 months ago

As of now (basing on -> https://github.com/ImKringle/Ptero-Things/tree/main/astrotuxlauncher) Parsing the url port field is not possible through Pterodactyl before the game server installs without handling that in the entrypoint. If possible getting this in the launcher.toml file would be ideal, as that way it can automatically assign itself to a set port similar to how the PublicIP Variable does

Overall for hosting purposes its much cleaner in this fashion so that we can use any port and arent forced to use 7777 / manually edit the Engine.ini any time a server is spun up

JoeJoeTV commented 5 months ago

@ImKringle I just saw this issue and it seems like I dodn't get an email about it. I don't think I fully understand, why a port field in the launcher.toml would be beneficial. Do you need to read the assigned port to use it in Pterodactly? Is it not possible to have a default value, if none is present in the Engine.ini file. If I were to add a separate port field to the launcher.toml, the only thing it would do is write the same value to the Engine.ini file that was written into the launcher.toml. This probably also should not write it into the file, if the port is 7777, because default values like that get removed from the Engine.ini file by the Astroneer Dedicated Server.

ImKringle commented 5 months ago

@ImKringle I just saw this issue and it seems like I dodn't get an email about it. I don't think I fully understand, why a port field in the launcher.toml would be beneficial. Do you need to read the assigned port to use it in Pterodactly? Is it not possible to have a default value, if none is present in the Engine.ini file. If I were to add a separate port field to the launcher.toml, the only thing it would do is write the same value to the Engine.ini file that was written into the launcher.toml. This probably also should not write it into the file, if the port is 7777, because default values like that get removed from the Engine.ini file by the Astroneer Dedicated Server.

Yeah, the issue is even if I supply AstroTux with a completely pre-created file with only write permissions on install / game update the Engine.ini is reset (and removes the Core PAKS from being added to the file) - The main Astroneer egg gets around this since the Engine.ini is included in the install before the install/update is even attempted, but your process just overwrites whatever is already present Engine.ini side (from what I can see)

Generally I can just have it edit url.Port={{server.build.default.port}} but with this file specifically it just breaks. Having something in the launcher.toml that can be easily edited w/o messing with the install process is preferred, since its all ran through the one config by your launcher rather than supplying the installer 4 different config files that may or may not be used

ImKringle commented 5 months ago

Its more so so I can use a port that isnt 7777, the only time I really use default ports is to test functionality; I prefer to use the range I have opened for my servers (27000-28000) but can't exactly do that when the game forces 7777 without me manually editing the file xD

JoeJoeTV commented 5 months ago

@ImKringle AstroTuxLauncher should not overwrite the Port field at all and should be usable to change the port. AstroTuxLauncher explicitly reads the fields for Port, AllowEncryption, MaxClientRate, MaxInternalClientRate and all the "Paths" and rewrites them while adding stuff that is missing. I just tried it with my server and changing the port does indeed work as normal. The one thing to keep in mind, is as mentioned above, that the dedicated server itself, not AstroTuxLauncher removes the URL section, if the Port is set to the default, which is 7777. Also be careful with just reading the ini files, as some entried like the "Paths" appear multiple times with different values, which normally isn't possible in ini files AFAIK.

ImKringle commented 5 months ago

@ImKringle AstroTuxLauncher should not overwrite the Port field at all and should be usable to change the port. AstroTuxLauncher explicitly reads the fields for Port, AllowEncryption, MaxClientRate, MaxInternalClientRate and all the "Paths" and rewrites them while adding stuff that is missing. I just tried it with my server and changing the port does indeed work as normal. The one thing to keep in mind, is as mentioned above, that the dedicated server itself, not AstroTuxLauncher removes the URL section, if the Port is set to the default, which is 7777. Also be careful with just reading the ini files, as some entried like the "Paths" appear multiple times with different values, which normally isn't possible in ini files AFAIK.

Just tested with a non-default port; as soon as the install triggers from AstroTux the file is wiped

New File:

[URL]
Port=7777

[SystemSettings]
net.AllowEncryption=False

[Core.System]
Paths=../../../Engine/Plugins/Media/MediaCompositing/Content

[/Script/OnlineSubsystemUtils.IpNetDriver]
MaxClientRate=1000000
MaxInternetClientRate=1000000

Console:

[10:04:03] [DedicatedServer/DEBUG] Engine configuration (including overrides):
{
    "Port": 7777,
    "AllowEncryption": false,
    "Paths": "../../../Engine/Plugins/Media/MediaCompositing/Content",
    "MaxClientRate": 1000000,
    "MaxInternetClientRate": 1000000
}

The only thing im editing in here through the panel is the port, exact same formatting with the base Astroneer egg w/o AstroTux this doesnt happen:

    "AstroneerServer/Astro/Saved/Config/WindowsServer/Engine.ini": {
        "parser": "ini",
        "find": {
            "[url].Port": "{{server.build.default.port}}"

Original file: https://raw.githubusercontent.com/ImKringle/Ptero-Things/update-tux/Games-Eggs/SteamCMD-Games/astrotuxlauncher/Engine.ini

ImKringle commented 5 months ago

Note this is being changed through python3 AstroTuxLauncher.py -l install not python3 AstroTuxLauncher.py start - this is why I posted the issue, just having a Port field in launcher.toml would make sure this stuff can't happen; since it'll override it itself rather than the panel needing to handle it; if it can change the IP entry why not the port ya kno 🤷🏼

Plus after testing its not from my image, same behavior occurs on the base Python image

The config parse I have set to edit the port occurs after the entrypoint runs (which handles the install of the game) and right before it starts using python3 AstroTuxLauncher.py start .-.

ImKringle commented 5 months ago

I just tried it with my server and changing the port does indeed work as normal.

At a guess, this is because it was edited by hand rather than handled by the panel/entrypoint which is what I'd rather. The setup is to limit how often you need to manually change files, not encourage it

JoeJoeTV commented 5 months ago

The difference between install and start is simply, that install basically just runs depotdownloader to either download or update the dedicated server from steam. start performs some additional checks (like network and plafab) and starts the server process, but else is just like install. I am trying to find out, what the actual issue with your setup is, since manually editing a file and editing it with a texteditor normally produce the same result. So what you are trying to to is to write an Engine.ini with Port already set, right? That would be the same work as writing the port field to launcher.toml, or am I missing something. The IP changing was pretty much just brought over from AstroLauncher, since that was my general basis and I am currently rewriting parts of AstroTuxLauncher in the dev branch. With my Pufferpanel template, I literally just write out the Engine.ini with the port value, which is no different, than manually editing it, so I'm not sure what the exact issue is here.

ImKringle commented 5 months ago

I am trying to find out, what the actual issue with your setup is, since manually editing a file and editing it with a texteditor normally produce the same result. So what you are trying to to is to write an Engine.ini with Port already set, right? That would be the same work as writing the port field to launcher.toml, or am I missing something.

Basically, yeah - Just would rather the launcher.toml file edit the Port field rather than rely on the panel to do it. Providing it a precreated Engine.ini doesn't seem to do anything outside of break the install (or if I use sed it just resets itself to 7777 on Install

With my Pufferpanel template, I literally just write out the Engine.ini with the port value, which is no different, than manually editing it, so I'm not sure what the exact issue is here.

I could do the same through the entrypoint, its just messier that way

ImKringle commented 5 months ago

The only things that touches that file in any capacity is the config parse (assuming I use it)

{
    "launcher.toml": {
        "parser": "file",
        "find": {
            "AutoUpdateServer": "AutoUpdateServer = {{server.build.env.GAME_UPDATE}}",
            "CheckNetwork": "CheckNetwork = {{server.build.env.CHECK_NETWORK}}",
            "LogDebugMessages": "LogDebugMessages = {{server.build.env.DEBUG_LOG}}",
            "DisableEncryption": "DisableEncryption = {{server.build.env.ENCRYPTION_TOGGLE}}"
        }
    },
    "AstroneerServer/Astro/Saved/Config/WindowsServer/AstroServerSettings.ini": {
        "parser": "ini",
        "find": {
            "[/Script/Astro.AstroServerSettings].OwnerName": "{{env.OWNER_NAME}}",
            "[/Script/Astro.AstroServerSettings].OwnerGuid": "{{env.OWNER_STEAMID}}",
            "[/Script/Astro.AstroServerSettings].ServerPassword": "{{env.SERVER_PWD}}",
            "[/Script/Astro.AstroServerSettings].ServerName": "{{env.SERVER_NAME}}",
            "[/Script/Astro.AstroServerSettings].AutoSaveGameInterval": "{{env.AUTO_SAVE}}"
        }
    },
    "AstroneerServer/Astro/Saved/Config/WindowsServer/Engine.ini": {
        "parser": "ini",
        "find": {
            "[URL].Port": "{{server.build.default.port}}"
     }
}

That's it, even if I use file (to just overwrite whatever matches the entry of Port= it resets itself to 7777 on startup/install

JoeJoeTV commented 5 months ago

I am currently not 100% sure, but can you try writing url in uppercase instead of lowercase. It may be the case that my config parser sees this as case-sensitive and thus, discards the section, since it doesn't match.

ImKringle commented 5 months ago

I am currently not 100% sure, but can you try writing url in uppercase instead of lowercase. It may be the case that my config parser sees this as case-sensitive and thus, discards the section, since it doesn't match.

Tried that too, no dice

JoeJoeTV commented 5 months ago

Can you send the contents of the file before it gets overwritten and afterwards exactly?

ImKringle commented 5 months ago

Can you send the contents of the file before it gets overwritten and afterwards exactly?

Did earlier:

File after overwrite:

[URL]
Port=7777

[SystemSettings]
net.AllowEncryption=False

[Core.System]
Paths=../../../Engine/Plugins/Media/MediaCompositing/Content

[/Script/OnlineSubsystemUtils.IpNetDriver]
MaxClientRate=1000000
MaxInternetClientRate=1000000

File pre overwrite: https://raw.githubusercontent.com/ImKringle/Ptero-Things/update-tux/Games-Eggs/SteamCMD-Games/astrotuxlauncher/Engine.ini

JoeJoeTV commented 5 months ago

And you said it also gets reset when simply starting the server right?

ImKringle commented 5 months ago

Yeup, right when the image finishes its update check; nearly instant. Bit confused myself

JoeJoeTV commented 5 months ago

Also are you sure that the ini parser in Pterodactyl supports multiple keys with the same name, as I see that Paths gets reduced to only one entry, which normally is not a problem of the parser which I use, since it's the same custom one from AstroLauncher

JoeJoeTV commented 5 months ago

Can you send the log file with debug logging when the issue happens?

ImKringle commented 5 months ago

Also are you sure that the ini parser in Pterodactyl supports multiple keys with the same name, as I see that Paths gets reduced to only one entry, which normally is not a problem of the parser which I use, since it's the same custom one from AstroLauncher

Sure am, tried another parse type and instead of removing the Paths the Port entry is just reset on startup (Checked just about everything that could be basic user error in setup)

ImKringle commented 5 months ago

Can you send the log file with debug logging when the issue happens?

It happens before debug logging can even be enabled, thats the problem >.>

JoeJoeTV commented 5 months ago

Can you send the log file with debug logging when the issue happens?

It happens before debug logging can even be enabled, thats the problem >.>

What do you mean, you can pass the flag to AstroTuxLauncher or set in in the config before starting it.

ImKringle commented 5 months ago

-> Hit Start -> Config Reset -> Install prompt starts -> Install finishes -> Config Parse -> Server fully boots

Passing a flag doesn't do much if it can't use it

Either way, figured it out. For some reason the file parse type works, but only if I put it at the top of the file instead of the bottom of it (for the parser) - so issue resolved. The addition to launcher.toml would be nice either way