From c8f4cfa22099fb95a4281805da5538d8da282abe Mon Sep 17 00:00:00 2001
From: Captain ALM
Date: Mon, 14 Aug 2023 19:01:00 +0100
Subject: [PATCH] Add index content, update build file, patch .gitignore
---
.gitignore | 3 +
Makefile | 8 +-
goinfo.go.html | 4 +
index.go.html | 267 ++++++++++++++++++++++++++++++++
pageHandler/go-info-page.go | 9 +-
pageHandler/pages/index/data.go | 1 +
pageHandler/pages/index/mc.go | 14 ++
7 files changed, 299 insertions(+), 7 deletions(-)
create mode 100644 index.go.html
diff --git a/.gitignore b/.gitignore
index c5a21c3..7059d6b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -19,3 +19,6 @@ cnf/
cnf
cnf_/
cnf_
+
+# Go YAML Page Config -- For This Repo
+*.go.yml
diff --git a/Makefile b/Makefile
index cafd211..666186a 100644
--- a/Makefile
+++ b/Makefile
@@ -34,19 +34,19 @@ clean:
rm -r -f dist/
deploy: build
- sudo systemctl stop wappcityuni
+ sudo systemctl stop ${PRODUCT_NAME}
sudo cp "${BIN}" /usr/local/bin
sudo cp *.go.html cnf
sudo cp *.go.yml cnf
sudo cp *.css cdn
sudo cp *.js cdn
- sudo systemctl start wappcityuni
+ sudo systemctl start ${PRODUCT_NAME}
d: build
- sudo systemctl stop wappcityuni_
+ sudo systemctl stop ${DNAME}
sudo cp "${BIN}" "/usr/local/bin/${DNAME}"
sudo cp *.go.html cnf_
sudo cp *.go.yml cnf_
sudo cp *.css cdn_
sudo cp *.js cdn_
- sudo systemctl start wappcityuni_
+ sudo systemctl start ${DNAME}
diff --git a/goinfo.go.html b/goinfo.go.html
index 740966a..e09f3a9 100644
--- a/goinfo.go.html
+++ b/goinfo.go.html
@@ -150,6 +150,10 @@
Memory Page Size |
{{ .PageSize }} |
+
+ System Time |
+ {{ .CurrentTime }} |
+
diff --git a/index.go.html b/index.go.html
new file mode 100644
index 0000000..ba0a7e3
--- /dev/null
+++ b/index.go.html
@@ -0,0 +1,267 @@
+
+
+
+
+
+
+
+
+ {{ .Data.PageTitle }}
+
+
+
+
+
+
{{ .Data.PageTitle }}
+
+
+
+
+
+
+
+
+
+ Server Address |
+ {{ if .Online }}{{ .Queried.Address }}{{ else }}{{ .Data.MCAddress }}{{ end }} |
+
+
+ Server Port |
+ {{ if .Online }}{{ .Queried.Port }}{{ else }}{{ .Data.MCPort }}{{ end }} |
+
+ {{ if (and .ExtendedShown .Queried.Port6) }}
+
+ Server IPv6 Port |
+ {{ .Queried.Port6 }} |
+
+ {{ end }}
+ {{ if and .ExtendedShown .Data.AllowDisplayActualAddress }}
+ {{ if .Queried.ActualHost }}
+
+ Actual Address |
+ {{ .Queried.ActualHost }} |
+
+ {{ end }}
+ {{ if .Queried.ActualPort }}
+
+ Actual Port |
+ {{ .Queried.ActualPort }} |
+
+ {{ end }}
+ {{ end }}
+ {{ if .Data.AllowDisplayState }}
+
+ Server State |
+ {{ if .Online }}Online{{ else }}Offline{{ end }} |
+
+ {{ end }}
+ {{ if ne .Data.ServerDescription "" }}
+
+ Server Description |
+ {{ .Data.ServerDescription }} |
+
+ {{ end }}
+ {{ if .Online }}
+ {{ if .Data.AllowDisplayVersion }}
+
+ Type |
+ {{ .Data.GetCleanMCType }} |
+
+ {{ if .Queried.Edition }}
+
+ Edition |
+ {{ .Queried.Edition }} |
+
+ {{ end }}
+ {{ if .Queried.Version }}
+
+ Version |
+ {{ .Queried.Version }} |
+
+ {{ end }}
+ {{ if (and .ExtendedShown .Queried.ProtocolVersion) }}
+
+ Protocol Version |
+ {{ .Queried.ProtocolVersion }} |
+
+ {{ end }}
+ {{ end }}
+ {{ if and .Data.AllowPlayerCountDisplay (and .Queried.PlayerCount .Queried.MaxPlayers) }}
+
+ Player Count |
+ {{ if .Data.AllowPlayerListing }}{{ end }} {{ .Queried.PlayerCount }} / {{ .Queried.MaxPlayers }} {{ if .Data.AllowPlayerListing }}{{ end }} |
+
+ {{ end }}
+ {{ if .Data.AllowMOTDDisplay }}
+ {{ if ne .Queried.MOTD "" }}
+
+ MOTD |
+ {{ .Queried.MOTD }} |
+
+ {{ end }}
+ {{ end }}
+ {{ if .ExtendedShown }}
+ {{ if and .Data.AllowFaviconDisplay .Queried.Favicon }}
+
+ Icon |
+
+
+ |
+
+ {{ end }}
+ {{ if and .Data.AllowDisplayModded (gt .Queried.ModCount 0) }}
+
+ Mod Count |
+ {{ if .Data.AllowModListing }}{{ end }}{{ .Queried.ModCount }}{{ if .Data.AllowModListing }}{{ end }} |
+
+ {{ end }}
+ {{ if and .Data.AllowSecureProfileModeDisplay .Queried.SecureProfilesEnforced }}
+
+ Secure Profiles Enforced |
+ {{ .Queried.SecureProfilesEnforced }} |
+
+ {{ end }}
+ {{ if and .Data.AllowPreviewChatModeDisplay .Queried.PreviewChatEnforced }}
+
+ Preview Chat Enforced |
+ {{ .Queried.PreviewChatEnforced }} |
+
+ {{ end }}
+
+ Last Update Time |
+ {{ .Queried.GetTimestamp }} |
+
+ {{ end }}
+ {{ end }}
+
+
+{{ if and (and .PlayersShown .Online) (and .Data.AllowPlayerCountDisplay .Data.AllowPlayerListing) }}
+
+
+
+ Player List{{ if .Queried.PlayerCount }} ({{ .Queried.PlayerCount }}) {{ end }} |
+
+
+ Collapse Player List |
+
+ {{ if gt (len (.Queried.GetPlayers .Data.ShowAnonymousPlayers)) 0 }}
+ {{ range .Queried.Players }}
+
+ {{ if or .Data.ShowAnonymousPlayers (ne . "Anonymous Player") }}{{ . }}{{ end }} |
+
+ {{ end }}
+ {{ else }}
+
+ No Detectable Players. |
+
+ {{ end }}
+
+ Collapse Player List |
+
+
+
+{{ end }}
+{{ if and (and .ModsShown .Online) (and .ExtendedShown (and .Data.AllowDisplayModded .Data.AllowModListing)) }}
+
+
+
+ Mod List ({{ .Queried.PlayerCount }}) |
+
+
+ Collapse Mod List |
+
+ {{ if gt (len .Queried.Mods) 0 }}
+ {{ range .Queried.Mods }}
+
+ {{ . }} |
+
+ {{ end }}
+ {{ else }}
+
+ No Detectable Mods. |
+
+ {{ end }}
+
+ Collapse Mod List |
+
+
+
+{{ end }}
+
+
+
+
+
+
+ {{ .Data.Footer }}
+
+
+
+
\ No newline at end of file
diff --git a/pageHandler/go-info-page.go b/pageHandler/go-info-page.go
index 524a3fb..189c5ae 100644
--- a/pageHandler/go-info-page.go
+++ b/pageHandler/go-info-page.go
@@ -1,9 +1,6 @@
package pageHandler
import (
- "golang.captainalm.com/mc-webserver/conf"
- "golang.captainalm.com/mc-webserver/utils/info"
- "golang.captainalm.com/mc-webserver/utils/io"
"html/template"
"net/url"
"os"
@@ -11,6 +8,10 @@ import (
"runtime"
"sync"
"time"
+
+ "golang.captainalm.com/mc-webserver/conf"
+ "golang.captainalm.com/mc-webserver/utils/info"
+ "golang.captainalm.com/mc-webserver/utils/io"
)
const templateName = "goinfo.go.html"
@@ -45,6 +46,7 @@ func (gipg *goInfoPage) GetCacheIDExtension(urlParameters url.Values) string {
type goInfoTemplateMarshal struct {
FullOutput bool
+ CurrentTime time.Time
RegisteredPages []string
CachedPages []string
ProcessID int
@@ -98,6 +100,7 @@ func (gipg *goInfoPage) GetContents(urlParameters url.Values) (contentType strin
theBuffer := &io.BufferedWriter{}
err = theTemplate.ExecuteTemplate(theBuffer, templateName, &goInfoTemplateMarshal{
FullOutput: urlParameters.Has("full"),
+ CurrentTime: time.Now(),
RegisteredPages: regPages,
CachedPages: cacPages,
ProcessID: os.Getpid(),
diff --git a/pageHandler/pages/index/data.go b/pageHandler/pages/index/data.go
index 23b36f5..2b302c9 100644
--- a/pageHandler/pages/index/data.go
+++ b/pageHandler/pages/index/data.go
@@ -28,6 +28,7 @@ type DataYaml struct {
AllowPreviewChatModeDisplay bool `yaml:"allowPreviewChatModeDisplay"`
AllowDisplayModded bool `yaml:"allowDisplayModded"`
AllowModListing bool `yaml:"allowModListing"`
+ ShowAnonymousPlayers bool `yaml:"showAnonymousPlayers"`
}
func (dy DataYaml) GetCleanMCType() string {
diff --git a/pageHandler/pages/index/mc.go b/pageHandler/pages/index/mc.go
index 79353d8..92a5260 100644
--- a/pageHandler/pages/index/mc.go
+++ b/pageHandler/pages/index/mc.go
@@ -34,3 +34,17 @@ func (m MC) GetFaviconSRC() template.HTMLAttr {
toReturn += "\""
return template.HTMLAttr(toReturn)
}
+
+func (m MC) GetTimestamp() string {
+ return m.Timestamp.Format(time.RFC822)
+}
+
+func (m MC) GetPlayers(aap bool) []string {
+ toReturn := make([]string, 0)
+ for _, cpl := range m.Players {
+ if aap || cpl != "Anonymous Player" {
+ toReturn = append(toReturn, cpl)
+ }
+ }
+ return toReturn
+}