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.72k stars 1.71k forks source link

Parser "File" for Eggs is broken #2393

Closed gOOvER closed 4 years ago

gOOvER commented 4 years ago

DO NOT REPORT ISSUES CONFIGURING: SSL, PHP, APACHE, NGINX, YOUR MACHINE, SSH, SFTP, ETC. ON THIS GITHUB TRACKER.

For assistance installating this software, as well as debugging issues with dependencies, please use our discord server: https://discord.gg/pterodactyl

You MUST complete all of the below information when reporting a bug, failure to do so will result in closure of your issue. PLEASE stop spamming our tracker with "bugs" that are not related to this project.

STOP: READ FIRST, AND THEN DELETE THE ABOVE LINES

Background (please complete the following information):

Describe the bug A clear and concise description of what the bug is. Please provide additional information too, depending on what you have issues with: Panel: php -v (the php version in use). Daemon: uname -a and docker info (your kernel version and information regarding docker)

To Reproduce Steps to reproduce the behavior:

  1. Create an Egg and use "file" as Parser for Configuration
  2. Create Server

Expected behavior A clear and concise description of what you expected to happen. If applicable, add screenshots or a recording to help explain your problem.

The Parser "file" is broken.

Configuration is after Server install

ListenPort = 8087 ListListenHost=  "0.0.0.0" = "0.0.0.0"e/container/TeamSpeak3-Client-linux_amd64/ts3client_linux_amd64"
YoutubeDLPath = "/home/container/youtube-dl/youtube-dl"

Configuration should be:

ListenPort = 8087
ListenHost = "0.0.0.0"
TS3Path = "/opt/sinusbot/TeamSpeak3-Client-linux_amd64/ts3client_linux_amd64"

Configuration in the Egg

{
    "config.ini": {
        "parser": "file",
        "find": {
            "ListenPort=": "ListenPort= {{server.build.default.port}}",
            "ListenHost=": "ListenHost=  \"0.0.0.0\""
        }
    }
}
DaneEveritt commented 4 years ago

a.) fun b.) use the ini parser for an ini file. The file parser is a last ditch effort to support random file formats.

parkervcp commented 4 years ago

From what I am seeing though it's just missing a \n at the end of lines.

VibeGAMESNL commented 4 years ago

Have the same issue using the @parkervcp FiveM egg.

@parkervcp could you explain what we need to do? adding \n results in this:

image

Thank you

parkervcp commented 4 years ago

This is a bug in the daemon. It's not something just putting something in the egg.

VibeGAMESNL commented 4 years ago

This is a bug in the daemon. It's not something just putting something in the egg.

Yeah I understand but just tried your suggestion: :) From what I am seeing though it's just missing a \n at the end of lines.

Thanks for clearing it up

gOOvER commented 4 years ago

This is a bug in the daemon. It's not something just putting something in the egg.

Yeah I understand but just tried your suggestion: :)

This was not a suggetion for fixing this Bug ;)

VibeGAMESNL commented 4 years ago

I just have build wings myself so I had the lastest updates but this still doesnt fix the issue @DaneEveritt

image

parkervcp commented 4 years ago

So it looks like it was taking the /n off every line before not just ones it replaced.

gOOvER commented 4 years ago

In my Eye's should the whole Parsing Part should be reviewed. "Ini" also don't work as it should

DaneEveritt commented 4 years ago

Please open parser specific bugs as a new issue unless there is direct overlap between an issue across multiple parsers. Comments inside bug reports will not be noticed (or remembered) and will not end up getting fixed.

parkervcp commented 4 years ago

ini uses = this does not. @gOOvER fyi

gOOvER commented 4 years ago

ini uses = this does not. @gOOvER fyi

i know :)

VibeGAMESNL commented 4 years ago

I'm not familiar with golang but this fixed it for me. Please beautify it x) @DaneEveritt

func (f *ConfigurationFile) parseTextFile(path string) error {
    file, err := os.OpenFile(path, os.O_CREATE|os.O_RDWR, 0644)
    if err != nil {
        return err
    }
    defer file.Close()

    scanner := bufio.NewScanner(file)
    var lines []string

    for scanner.Scan() {
        t := scanner.Text()

        // Iterate over the potential replacements for the line and check if there are
        // any matches.
        var hasreplaced = false;

        for _, replace := range f.Replace {
            if !strings.HasPrefix(t, replace.Match) {
                continue;
            }

            hasreplaced = true
            lines = append(lines, replace.ReplaceWith.String() + "\n");
        }

        if !hasreplaced {
            lines = append(lines, t + "\n");
        }
    }

    if err := scanner.Err(); err != nil {
        return err
    }

    var x = []byte{}

    for i:=0; i<len(lines); i++{
        b := []byte(lines[i])
        for j:=0; j<len(b); j++{
            x = append(x,b[j])
        }
    }

    return ioutil.WriteFile(path, x, 0644)
}
parkervcp commented 4 years ago

This is still an issue

This
https://raw.githubusercontent.com/parkervcp/eggs/master/gta/fivem/server.cfg

Becomes
https://hastebin.com/ibulavisuw.properties

This is the parser config

{
    "server.cfg": {
        "parser": "file",
        "find": {
            "endpoint_add_tcp": "endpoint_add_tcp \"0.0.0.0:{{server.build.default.port}}\"",
            "endpoint_add_udp": "endpoint_add_udp \"0.0.0.0:{{server.build.default.port}}\"",
            "sv_hostname": "sv_hostname \"{{server.build.env.SERVER_HOSTNAME}}\"",
            "set sv_licenseKey": "set sv_licenseKey {{server.build.env.FIVEM_LICENSE}}",
            "set steam_webApiKey": "set steam_webApiKey {{server.build.env.STEAM_WEBAPIKEY}}",
            "sv_maxclients": "sv_maxclients {{server.build.env.MAX_PLAYERS}}"
        }
    }
}
VibeGAMESNL commented 4 years ago

This is still an issue

This https://raw.githubusercontent.com/parkervcp/eggs/master/gta/fivem/server.cfg

Becomes https://hastebin.com/ibulavisuw.properties

This is the parser config

{
    "server.cfg": {
        "parser": "file",
        "find": {
            "endpoint_add_tcp": "endpoint_add_tcp \"0.0.0.0:{{server.build.default.port}}\"",
            "endpoint_add_udp": "endpoint_add_udp \"0.0.0.0:{{server.build.default.port}}\"",
            "sv_hostname": "sv_hostname \"{{server.build.env.SERVER_HOSTNAME}}\"",
            "set sv_licenseKey": "set sv_licenseKey {{server.build.env.FIVEM_LICENSE}}",
            "set steam_webApiKey": "set steam_webApiKey {{server.build.env.STEAM_WEBAPIKEY}}",
            "sv_maxclients": "sv_maxclients {{server.build.env.MAX_PLAYERS}}"
        }
    }
}

Did you try my fix that I posted in my previous comment?

DaneEveritt commented 4 years ago

Closed by https://github.com/pterodactyl/wings/pull/64