MSH Flag parsing issues
BolverBlitz opened this issue Β· 22 comments
Current Behavior (π Bug)
Problem 1: Throws a error because of wrong logic.
If you start msh with default config but start parameters for folder and file you get the error
loadDefault: getVersionInfo: open {path\to\server\folder}\{server.jar}: The system cannot find the path specified. [03f101]
It will still work as usual. Still this should be avoided to not confuce users.
Problem 2: Bad parsing...
This is more complicated and mainly affects the pterodactyl egg becace the " are impossible to create. See my ptero help for that below
You can also replicate it on windows.
It first seems like it works because flags dosnΒ΄t add a tail ( flag.Args() ) but when MSH tryes to execute ms
go run minecraft-server-hibernation.go -d=3 -folder ./ -file "paper-1.19.3 359.jar"
...
[info β‘β‘β‘ ] MINECRAFT SERVER IS STARTING!
[serv β‘β‘ ] Error: Unable to access jarfile paper-1.19.3
[info β‘β‘β‘ ] MINECRAFT SERVER IS OFFLINE!
gets written. Indicating that it failed to parse at the [SPACE]
Case 1:
In the documentaion of flags its sugested to use = in such cases.
go run minecraft-server-hibernation.go -d=3 -folder=./ -file="paper-1.19.3 359.jar"
This now fails completly. Lets have a look.
The folder variable is just an emty string...
The file variable is its default value
And the tail contains our parameter [./ -p2=paper-1.19.3 359.jar]
Case 2:
Now lets also add " to our folder.
go run minecraft-server-hibernation.go -d=3 -folder="./" -file="paper-1.19.3 359.jar"
Flags output looks fine
Folder: ./
File: paper-1.19.3 359.jar
tail: []
But msh still trys to execute the wrong file?
[info β‘β‘β‘ ] MINECRAFT SERVER IS STARTING!
[serv β‘β‘ ] Error: Unable to access jarfile paper-1.19.3
[info β‘β‘β‘ ] MINECRAFT SERVER IS OFFLINE!
Pterodactyl Discord Question i explained the case and ask for help
# What i tryed, and the output:
./main.bin -p1= \"Hello World \" -p2=Marc
# p1: "Hello
# p2: bar
# tail: [World -p2=Marc]
./main.bin -p1="Hello World" -p2=Marc
# p1:Hello%20World
# p2: Marc
# tail: []
./main.bin $(echo '-p1="') Hello World$(echo '"') -p2=Marc
# p1: "Hello
# p2: bar
# tail: [World -p2=Marc]
# On windows(PS/CMD) and linux (BASH) it works.
./main.bin -p1="Hello World" -p2=Marc
# p1: Hello World
# p2: Marc
# tail: []
Expected Behavior
Solution 1:
Msh enters LoadConfig() as one of its first steps.
This will execute loadDefault()
Within the loadDefault() function it tryes to read the version of ms
With this line version, protocol, logMsh := c.getVersionInfo()
But at this point, we havent processed start parameters because those are loaded in loadRuntime() and thats ran after loadDefault() completion
Problem 2:
It shuld parse arguments with spaces no matter the used shell.
Steps to Reproduce
All described in the behavior box.
MSH Logs
No response
MSH-Version
2.4.10
Operating system
Ubuntu 21 & Windows
Minecraft Version
1.19.2
Minecraft Server Software
Paper
Is there an existing issue for this?
- I have searched the existing issues before opening this issue.
- I have provided all relevant details.
go run minecraft-server-hibernation.go -d=3 -folder ./ -file "paper-1.19.3 359.jar"
running on windows:
PS > .\msh.exe -d=3 -folder "C:\Users\Administrator\Desktop\minecraft server" -file "paper-1.19.3 359.jar"
βββββββββββββββββββββββββββββββββββββββββββββββ
β _ __ ___ ___| |__ β
β | '_ ` _ \/ __| '_ \ β
β | | | | | \__ \ | | | v2.4.10 β
β |_| |_| |_|___/_| |_| ------- β
β Copyright (C) 2019-2022 gekigek99 β
β github: https://github.com/gekigek99 β
β remember to give a star to this repository! β
βββββββββββββββββββββββββββββββββββββββββββββββ
2022/12/26 19:19:27 [info β‘ ] checking OS support...
2022/12/26 19:19:28 [info β‘ ] loading config...
2022/12/26 19:19:28 [info β‘ ] reading config file: "C:\Users\Administrator\Desktop\Administrator\informatica\programmazione\Β» Go\minecraft-server-hibernation\msh\msh-config.json"
2022/12/26 19:19:28 [info β‘ ] msh instance file exists
2022/12/26 19:19:28 [info β‘ ] msh instance loaded is healthy
2022/12/26 19:19:28 [info β‘β‘β‘β‘] setting log level to: 3
2022/12/26 19:19:28 [info β‘β‘β‘ ] eula.txt exist and is set to true
2022/12/26 19:19:28 [info β‘ ] msh proxy setup: 0.0.0.0:25555 --> 127.0.0.1:25565
2022/12/26 19:19:28 [info β‘ ] sending api2 request
2022/12/26 19:19:28 [info β‘ ] segment reset
2022/12/26 19:19:28 [info β‘β‘β‘ ] listening for new clients to connect on 0.0.0.0:25555 ...
2022/12/26 19:19:28 [info β‘ ] reading api2 response
2022/12/26 19:19:28 [warn β‘β‘β‘β‘] sgmMgr: msh (v2.4.10) is running a dev release [01f000]
PS > .\msh.exe -d=3 -folder=C:\Users\Administrator\Desktop\minecraftserver -file="paper-1.19.3 359.jar"
βββββββββββββββββββββββββββββββββββββββββββββββ
β _ __ ___ ___| |__ β
β | '_ ` _ \/ __| '_ \ β
β | | | | | \__ \ | | | v2.4.10 β
β |_| |_| |_|___/_| |_| ------- β
β Copyright (C) 2019-2022 gekigek99 β
β github: https://github.com/gekigek99 β
β remember to give a star to this repository! β
βββββββββββββββββββββββββββββββββββββββββββββββ
2022/12/26 19:23:25 [info β‘ ] checking OS support...
2022/12/26 19:23:25 [info β‘ ] loading config...
2022/12/26 19:23:25 [info β‘ ] reading config file: "C:\Users\Administrator\Desktop\Administrator\informatica\programmazione\Β» Go\minecraft-server-hibernation\msh\msh-config.json"
2022/12/26 19:23:25 [info β‘ ] msh instance file exists
2022/12/26 19:23:25 [info β‘ ] msh instance loaded is healthy
2022/12/26 19:23:25 [info β‘β‘β‘β‘] setting log level to: 3
2022/12/26 19:23:25 [info β‘β‘β‘ ] eula.txt exist and is set to true
2022/12/26 19:23:25 [info β‘ ] msh proxy setup: 0.0.0.0:25555 --> 127.0.0.1:25565
2022/12/26 19:23:25 [info β‘ ] sending api2 request
2022/12/26 19:23:25 [info β‘ ] segment reset
2022/12/26 19:23:25 [info β‘β‘β‘ ] listening for new clients to connect on 0.0.0.0:25555 ...
2022/12/26 19:23:25 [info β‘ ] reading api2 response
2022/12/26 19:23:25 [warn β‘β‘β‘β‘] sgmMgr: msh (v2.4.10) is running a dev release [01f000]
PS > .\msh.exe -d=3 -folder="C:\Users\Administrator\Desktop\minecraft server" -file="paper-1.19.3 359.jar"
βββββββββββββββββββββββββββββββββββββββββββββββ
β _ __ ___ ___| |__ β
β | '_ ` _ \/ __| '_ \ β
β | | | | | \__ \ | | | v2.4.10 β
β |_| |_| |_|___/_| |_| ------- β
β Copyright (C) 2019-2022 gekigek99 β
β github: https://github.com/gekigek99 β
β remember to give a star to this repository! β
βββββββββββββββββββββββββββββββββββββββββββββββ
2022/12/26 19:21:21 [info β‘ ] checking OS support...
2022/12/26 19:21:21 [info β‘ ] loading config...
2022/12/26 19:21:21 [info β‘ ] reading config file: "C:\Users\Administrator\Desktop\Administrator\informatica\programmazione\Β» Go\minecraft-server-hibernation\msh\msh-config.json"
2022/12/26 19:21:21 [info β‘ ] msh instance file exists
2022/12/26 19:21:21 [info β‘ ] msh instance loaded is healthy
2022/12/26 19:21:21 [info β‘β‘β‘β‘] setting log level to: 3
2022/12/26 19:21:21 [info β‘β‘β‘ ] eula.txt exist and is set to true
2022/12/26 19:21:21 [info β‘ ] msh proxy setup: 0.0.0.0:25555 --> 127.0.0.1:25565
2022/12/26 19:21:21 [info β‘ ] sending api2 request
2022/12/26 19:21:22 [info β‘ ] segment reset
2022/12/26 19:21:22 [info β‘β‘β‘ ] listening for new clients to connect on 0.0.0.0:25555 ...
2022/12/26 19:21:22 [info β‘ ] reading api2 response
2022/12/26 19:21:22 [warn β‘β‘β‘β‘] sgmMgr: msh (v2.4.10) is running a dev release [01f000]
I really can't reproduce the bug
idk what about adding a replace function to replace [space]
to " "
so that in egg config you can write [space]
?
In nither of your shared logs you tryed to start ms or added extra flags logging like i did.
Please type ms start
to see the error
what extra flags do I have to add?
Please type ms start to see the error
ah ops lol
what extra flags do I have to add?
Not adding extra flags, i wrote extra flags logging
Thats saves you from running msh start
because it will log what i posted in my original logs. IN SOME CASES, NOT ALL!
minecraft-server-hibernation/lib/config/config.go
Lines 177 to 184 in bff5cf0
fmt.Println("Folder:", *c.Server.Folder)
fmt.Println("File:", *c.Server.FileName)
fmt.Println("tail:", flag.Args())
minecraft-server-hibernation/lib/config/config.go
Lines 186 to 190 in bff5cf0
It does solve the example i made here, would you be able do build linux x86 for me. IΒ΄m not in a place where i can do it rn.
Because the main reason i opend the issue still is This is more complicated and mainly affects the pterodactyl egg becace the " are impossible to create.
and i canΒ΄t see any attemt this got fixed ^^
here you go: msh-v2.4.10-6398dd9.zip
Thank you. Yeah as i expected.
container@pterodactyl~ ./msh_server.bin -port 10037 -d 3 -file server.jar -allowkill 30 -timeout 120 -SuspendRefresh 30 -wlimport -SuspendAllow -msparam "-Xms128M -Xmx2354M"
βββββββββββββββββββββββββββββββββββββββββββββββ
β _ __ ___ ___| |__ β
β | '_ ` _ \/ __| '_ \ β
β | | | | | \__ \ | | | v2.4.10 β
β |_| |_| |_|___/_| |_| 6398dd9 β
β Copyright (C) 2019-2022 gekigek99 β
β github: https://github.com/gekigek99 β
β remember to give a star to this repository! β
βββββββββββββββββββββββββββββββββββββββββββββββ
2022/12/27 01:39:19 [info β‘ ] checking OS support...
2022/12/27 01:39:19 [info β‘ ] loading config...
2022/12/27 01:39:19 [info β‘ ] reading config file: "/home/container/msh-config.json"
2022/12/27 01:39:19 [info β‘ ] msh instance file exists
2022/12/27 01:39:19 [error β‘ ] okV0: machineid: machineid: open /etc/machine-id: no such file or directory [03f003]
2022/12/27 01:39:19 [info β‘ ] msh instance loaded is healthy
flag provided but not defined: -Xmx2354M"
......
I tryed and you fixed the windows example i toled you, but MSH still parses arguments incorectly for the egg...
I thought the windows bug i found was the same, looking at your fix i see now it wasnΒ΄t. Just happend to have the same result.
Sorry for that. At least thats fixed now. Egg still dosnΒ΄t work :/
Affected: Hib Message, Start Message and the memory start command (as seen in my example)
I tryed and you fixed the windows example i toled you, but MSH still parses arguments incorectly for the egg...
I think that ptero has kinda the same issue with spaces that msh parsing had.
ok can you tell me a simple example command to use as a debug test?
maybe even setup an egg just for it so I can test on that
what does -batchmode
do?
ok can you tell me a simple example command to use as a debug test?
https://panel.ebg.pw/server/d5528abf
How to use:
1: Delete old msh_server.bin
2: Upload new msh_server.bin (Needs to be Linux x86(_64)
3: Click on "Settings" click on "Reinsall Server
4: Start the Server, will be running your uploaded Binary
maybe even setup an egg just for it so I can test on that
Added a debug egg here.
gekware/minecraft-server-hibernation-pterodactyl-egg@3d87d3d
what does -batchmode do?
Tells the server to run without a GUI
I found 2 alternative ways to parse arguments.
https://github.com/spf13/cobra
https://github.com/jessevdk/go-flags
Example using https://github.com/jessevdk/go-flags
go.mod
module clitester
go 1.19
require (
github.com/jessevdk/go-flags v1.5.0 // indirect
golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4 // indirect
)
main.go
package main
import (
"fmt"
"os"
"github.com/jessevdk/go-flags"
)
type Optionen struct {
Username string `short:"u" long:"username" description:"Username"`
}
func main() {
var opt Optionen
_, err := flags.Parse(&opt)
if err != nil {
os.Exit(1)
}
fmt.Println(opt.Username)
}
As MSH currently does, it works on windows. Escaped chars " on windows work kinda... Ver ystrange
On Pterodactyl:
Ptero command:
./msh_server.bin -u=\"-Xms128M -Xmx{{SERVER_MEMORY}}M\"
In Shell:
./msh_server.bin -u="-Xms128M -Xmx4096M"
invalid argument for flag -u, --username' (expected string): invalid syntax`
I found 2 issues that might help with this issue: jessevdk/go-flags#185
Added a debug egg here.
gekware/minecraft-server-hibernation-pterodactyl-egg@3d87d3d
can you add a modifiable variable -msparam
and -infoHibe
so I can play around with them?
on the test egg I demostrated that even with a bash executable the arguments are splitted by a space... this should indicate that it's the internal ptero terminal that it's passing the wrongly splitted parameters.
#!/bin/bash
for i; do
echo -n $i"|"
done
./msh_server.bin -port 10039 -d 3 -file 'ser ver.jar' -allowkill 30 -timeout 120 -SuspendRefresh 30 -wlimport -SuspendAllow -msparam "-Xms128M -Xmx4096M"
-port|10039|-d|3|-file|'ser|ver.jar'|-allowkill|30|-timeout|120|-SuspendRefresh|30|-wlimport|-SuspendAllow|-msparam|"-Xms128M|-Xmx4096M"|
I could manually create a parser to unify the spitted parameters |'ser|ver.jar'|
and |"-Xms128M|-Xmx4096M"|
but I would really prefer to use less "handmade" solutions...
can you add a modifiable variable -msparam and -infoHibe so I can play around with them?
No, variables are not parsed the same. I made it so its " as all other eggs do it and its also kinda standart.
it's the internal ptero terminal that it's passing the wrongly splitted parameters.
Well then open a issue, i asked 2 times on the ptero and got igonored ^^
removing the label 2.5.0 update
from the issue as it's not related to msh itself