Skip to content

Commit

Permalink
Merge pull request #220 from A-wels/dev
Browse files Browse the repository at this point in the history
Implement #219: Arguments for ServPort and ServPortQuery
  • Loading branch information
gekigek99 authored Mar 16, 2023
2 parents 344b172 + e0b3cd9 commit f59f15f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 12 deletions.
11 changes: 4 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +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
- \* HibernationInfo and StartingInfo
- \* 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/))
Expand All @@ -67,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
Expand Down Expand Up @@ -105,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
"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
Expand Down Expand Up @@ -166,7 +164,6 @@ _for debug purposes (debug level 3 required)_
```

-----

### CREDITS:

Author: [gekigek99](https://github.com/gekigek99)
Expand Down
14 changes: 11 additions & 3 deletions lib/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
Expand Down Expand Up @@ -298,17 +300,23 @@ 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

// ServHost defined in global definition
if ServPort, logMsh = c.ParsePropertiesInt("server-port"); logMsh != nil {
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)
}
if ServPortQuery, logMsh = c.ParsePropertiesInt("query.port"); logMsh != nil {
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")
Expand Down
4 changes: 2 additions & 2 deletions msh-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"NotifyMessage": true,
"Whitelist": [],
"WhitelistImport": false,
"ShowResourceUsage": false,
"ShowInternetUsage": false
"ShowResourceUsage": false,
"ShowInternetUsage": false
}
}

0 comments on commit f59f15f

Please sign in to comment.