diff --git a/README.md b/README.md index dc47adf4..b424dd8c 100644 --- a/README.md +++ b/README.md @@ -41,17 +41,14 @@ go build . ----- ### INSTRUCTIONS: 1. Install the Minecraft server you want -2. Edit the parameters in `msh-config.json` as needed (*check definitions*): +2. Edit `msh-config.json` as needed (*check definitions*): - Folder - FileName - StartServerParam - StopServer - Whitelist - - \* StopServerAllowKill - - \* ServPort and ServPortQuery - - \* InfoHibernation and InfoStarting - \* TimeBeforeStoppingEmptyServer - - \* NotifyUpdate + - \* [others...](#DEFINITIONS) 3. \* put the frozen icon you want in `path/to/server.jar/folder` (must be called `server-icon-frozen`, supported formats: `.png`, `.jpg`) 4. on the router (to which the server is connected): forward port 25555 to server ([tutorial](https://www.wikihow.com/Open-Ports#Opening-Router-Firewall-Ports)) 5. on the server: open port 25555 (example: [ufw firewall](https://www.configserverfirewall.com/ufw-ubuntu-firewall/ubuntu-firewall-open-port/)) @@ -68,7 +65,7 @@ _\* = it's not compulsory to modify this parameter_ ----- ### DEFINITIONS: -- _Some of these parameters can be configured with command-line arguments (--help to know which)_ +- _Some of these parameters can be configured with command-line arguments (`msh --help` to know more) (user supplied arguments will override config)_ Location of server folder and executable. You can find protocol/version [here](https://wiki.vg/Protocol_version_numbers) (but msh should set them automatically): ```yaml @@ -106,7 +103,7 @@ Ports configuration - _msh enables query handling if `enable-query=true` in `server.properties`_ ```yaml "MshPort": 25555 # port to which players can join -"MshPortQuery": 25555 # port to which stats query requests are performed from players +"MshPortQuery": 25555 # port to which stats query requests are performed from clients ``` TimeBeforeStoppingEmptyServer sets the time (after the last player disconnected) that msh waits before hibernating the minecraft server @@ -167,61 +164,6 @@ _for debug purposes (debug level 3 required)_ ``` ----- -#### Command-line parameters -These parameters can be applied when running the executable. Supplying these parameters overwrites the values specified in `msh-config.json` - -```yaml - -SuspendAllow - Enables minecraft server process suspension. - -SuspendRefresh int - Specify how often the suspended minecraft server process must be refreshed. (default -1) - -allowKill int - Specify after how many seconds the server should be killed (if stop command fails). (default 10) - -allowkill int - Specify after how many seconds the server should be killed (if stop command fails). (default 10) - -d int - Specify debug level. (default 1) - -file string - Specify minecraft server file name. (default "{server.jar}") - -folder string - Specify minecraft server folder path. (default "{path/to/server/folder}") - -infohibe string - Specify hibernation info. (default " §fserver status:\n §b§lHIBERNATING") - -infostar string - Specify starting info. (default " §fserver status:\n §6§lWARMING UP") - -msparam string - Specify start server parameters. (default "-Xmx1024M -Xms1024M") - -notifymes - Enables message notifications. (default true) - -notifyupd - Enables update notifications. (default true) - -port int - Specify msh port. (default 25555) - -protocol int - Specify minecraft server protocol. (default 760) - -servport int - Specify the port that msh connects to. - -servportquery int - Specify ServPortQuery that msh connects to. - -showint - Enables logging of msh interent usage (->clients / ->server). - -showres - Enables logging of msh resource usage (cpu / mem percentage). - -suspendallow - Enables minecraft server process suspension. - -suspendrefresh int - Specify how often the suspended minecraft server process must be refreshed. (default -1) - -timeout int - Specify time to wait before stopping minecraft server. (default 30) - -version string - Specify minecraft server version. (default "1.19.2") - -wlimport - Enables minecraft server whitelist import. - -``` - ------ - ### CREDITS: Author: [gekigek99](https://github.com/gekigek99) diff --git a/lib/config/config.go b/lib/config/config.go index 2573f397..1510f4b7 100644 --- a/lib/config/config.go +++ b/lib/config/config.go @@ -192,6 +192,8 @@ func (c *Configuration) loadRuntime(confdef *Configuration) *errco.MshLog { flag.IntVar(&c.Msh.Debug, "d", c.Msh.Debug, "Specify debug level.") // c.Msh.ID should not be set by a flag flag.IntVar(&c.Msh.MshPort, "port", c.Msh.MshPort, "Specify msh port.") + flag.IntVar(&ServPort, "servport", ServPort, "Specify the minecraft server port.") + flag.IntVar(&ServPortQuery, "servportquery", ServPortQuery, "Specify minecraft server port for queries.") flag.Int64Var(&c.Msh.TimeBeforeStoppingEmptyServer, "timeout", c.Msh.TimeBeforeStoppingEmptyServer, "Specify time to wait before stopping minecraft server.") flag.BoolVar(&c.Msh.SuspendAllow, "suspendallow", c.Msh.SuspendAllow, "Enables minecraft server process suspension.") flag.IntVar(&c.Msh.SuspendRefresh, "suspendrefresh", c.Msh.SuspendRefresh, "Specify how often the suspended minecraft server process must be refreshed.") @@ -209,10 +211,6 @@ func (c *Configuration) loadRuntime(confdef *Configuration) *errco.MshLog { flag.BoolVar(&c.Msh.SuspendAllow, "SuspendAllow", c.Msh.SuspendAllow, "Enables minecraft server process suspension.") // msh pterodactyl egg flag.IntVar(&c.Msh.SuspendRefresh, "SuspendRefresh", c.Msh.SuspendRefresh, "Specify how often the suspended minecraft server process must be refreshed.") // msh pterodactyl egg - // flags for ServPort and ServPortQuery - flag.IntVar(&c.Msh.ServPort, "servport", c.Msh.ServPort, "Specify the port that msh connects to.") - flag.IntVar(&c.Msh.ServPortQuery, "servportquery", c.Msh.ServPortQuery, "Specify ServPortQuery that msh connects to.") - // specify the usage when there is an error in the arguments flag.Usage = func() { // not using errco.NewLogln since log time is not needed @@ -302,34 +300,27 @@ func (c *Configuration) loadRuntime(confdef *Configuration) *errco.MshLog { // ---------------- setup load ----------------- // // load ports - // MshHost defined in global definition + + // MshHost defined in global definition MshPort = c.Msh.MshPort MshPortQuery = c.Msh.MshPortQuery - // load ServPort and ServPortQuery from launch parameters. Will be updated if set to default of 0 - ServPort = c.Msh.ServPort - ServPortQuery = c.Msh.ServPortQuery - // ServHost defined in global definition - - // read server port from server.properties if not set via flag - if ServPort == 0 { - if ServPort, logMsh = c.ParsePropertiesInt("server-port"); logMsh != nil { - logMsh.Log(true) - } else if ServPort == c.Msh.MshPort { - logMsh := errco.NewLogln(errco.TYPE_ERR, errco.LVL_1, errco.ERROR_CONFIG_LOAD, "ServPort and MshPort appear to be the same, please change one of them") - servstats.Stats.SetMajorError(logMsh) - } + if ServPort != 0 { + // ServPort defined in msh start arguments + } else if ServPort, logMsh = c.ParsePropertiesInt("server-port"); logMsh != nil { + logMsh.Log(true) + } else if ServPort == c.Msh.MshPort { + logMsh := errco.NewLogln(errco.TYPE_ERR, errco.LVL_1, errco.ERROR_CONFIG_LOAD, "ServPort and MshPort appear to be the same, please change one of them") + servstats.Stats.SetMajorError(logMsh) } - - // read server query port from server.properties if not set via flag - if ServPortQuery == 0 { - if ServPortQuery, logMsh = c.ParsePropertiesInt("query.port"); logMsh != nil { - logMsh.Log(true) - } else if ServPortQuery == c.Msh.MshPortQuery { - logMsh := errco.NewLogln(errco.TYPE_ERR, errco.LVL_1, errco.ERROR_CONFIG_LOAD, "ServPortQuery and MshPortQuery appear to be the same, please change one of them") - servstats.Stats.SetMajorError(logMsh) - } + if ServPortQuery != 0 { + // ServPortQuery defined in msh start arguments + } else if ServPortQuery, logMsh = c.ParsePropertiesInt("query.port"); logMsh != nil { + logMsh.Log(true) + } else if ServPortQuery == c.Msh.MshPortQuery { + logMsh := errco.NewLogln(errco.TYPE_ERR, errco.LVL_1, errco.ERROR_CONFIG_LOAD, "ServPortQuery and MshPortQuery appear to be the same, please change one of them") + servstats.Stats.SetMajorError(logMsh) } errco.NewLogln(errco.TYPE_INF, errco.LVL_3, errco.ERROR_NIL, "msh connection proxy setup: %s:%d --> %s:%d", MshHost, MshPort, ServHost, ServPort) diff --git a/lib/model/model.go b/lib/model/model.go index 7fc7f590..7716528e 100644 --- a/lib/model/model.go +++ b/lib/model/model.go @@ -19,8 +19,6 @@ type Configuration struct { ID string `json:"ID"` MshPort int `json:"MshPort"` MshPortQuery int `json:"MshPortQuery"` - ServPort int `json:"ServPort"` - ServPortQuery int `json:"ServPortQuery"` TimeBeforeStoppingEmptyServer int64 `json:"TimeBeforeStoppingEmptyServer"` SuspendAllow bool `json:"SuspendAllow"` // specify if msh should suspend java server process SuspendRefresh int `json:"SuspendRefresh"` // specify if msh should refresh java server process suspension and every how many seconds