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 }}

+
+

+

+

+ + {{ if .Dark }}Light Mode{{ else }}Dark Mode{{ end }} + +
+
+ + {{ if .ExtendedShown }}Hide Extended Information{{ else }}Show Extended Information{{ end }} + +
+

+

+ + + + + + + + + + {{ if (and .ExtendedShown .Queried.Port6) }} + + + + + {{ end }} + {{ if and .ExtendedShown .Data.AllowDisplayActualAddress }} + {{ if .Queried.ActualHost }} + + + + + {{ end }} + {{ if .Queried.ActualPort }} + + + + + {{ end }} + {{ end }} + {{ if .Data.AllowDisplayState }} + + + + + {{ end }} + {{ if ne .Data.ServerDescription "" }} + + + + + {{ end }} + {{ if .Online }} + {{ if .Data.AllowDisplayVersion }} + + + + + {{ if .Queried.Edition }} + + + + + {{ end }} + {{ if .Queried.Version }} + + + + + {{ end }} + {{ if (and .ExtendedShown .Queried.ProtocolVersion) }} + + + + + {{ end }} + {{ end }} + {{ if and .Data.AllowPlayerCountDisplay (and .Queried.PlayerCount .Queried.MaxPlayers) }} + + + + + {{ end }} + {{ if .Data.AllowMOTDDisplay }} + {{ if ne .Queried.MOTD "" }} + + + + + {{ end }} + {{ end }} + {{ if .ExtendedShown }} + {{ if and .Data.AllowFaviconDisplay .Queried.Favicon }} + + + + + {{ end }} + {{ if and .Data.AllowDisplayModded (gt .Queried.ModCount 0) }} + + + + + {{ end }} + {{ if and .Data.AllowSecureProfileModeDisplay .Queried.SecureProfilesEnforced }} + + + + + {{ end }} + {{ if and .Data.AllowPreviewChatModeDisplay .Queried.PreviewChatEnforced }} + + + + + {{ end }} + + + + + {{ end }} + {{ end }} +
Server Address{{ if .Online }}{{ .Queried.Address }}{{ else }}{{ .Data.MCAddress }}{{ end }}
Server Port{{ if .Online }}{{ .Queried.Port }}{{ else }}{{ .Data.MCPort }}{{ end }}
Server IPv6 Port{{ .Queried.Port6 }}
Actual Address{{ .Queried.ActualHost }}
Actual Port{{ .Queried.ActualPort }}
Server State{{ if .Online }}Online{{ else }}Offline{{ end }}
Server Description{{ .Data.ServerDescription }}
Type{{ .Data.GetCleanMCType }}
Edition{{ .Queried.Edition }}
Version{{ .Queried.Version }}
Protocol Version{{ .Queried.ProtocolVersion }}
Player Count{{ if .Data.AllowPlayerListing }}{{ end }} {{ .Queried.PlayerCount }} / {{ .Queried.MaxPlayers }} {{ if .Data.AllowPlayerListing }}{{ end }}
MOTD{{ .Queried.MOTD }}
Icon + Icon +
Mod Count{{ if .Data.AllowModListing }}{{ end }}{{ .Queried.ModCount }}{{ if .Data.AllowModListing }}{{ end }}
Secure Profiles Enforced{{ .Queried.SecureProfilesEnforced }}
Preview Chat Enforced{{ .Queried.PreviewChatEnforced }}
Last Update Time{{ .Queried.GetTimestamp }}
+

+{{ if and (and .PlayersShown .Online) (and .Data.AllowPlayerCountDisplay .Data.AllowPlayerListing) }} +

+ + + + + + + + {{ if gt (len (.Queried.GetPlayers .Data.ShowAnonymousPlayers)) 0 }} + {{ range .Queried.Players }} + + + + {{ end }} + {{ else }} + + + + {{ end }} + + + +
Player List{{ if .Queried.PlayerCount }} ({{ .Queried.PlayerCount }}) {{ end }}
Collapse Player List
{{ if or .Data.ShowAnonymousPlayers (ne . "Anonymous Player") }}{{ . }}{{ end }}
No Detectable Players.
Collapse Player List
+

+{{ end }} +{{ if and (and .ModsShown .Online) (and .ExtendedShown (and .Data.AllowDisplayModded .Data.AllowModListing)) }} +

+ + + + + + + + {{ if gt (len .Queried.Mods) 0 }} + {{ range .Queried.Mods }} + + + + {{ end }} + {{ else }} + + + + {{ end }} + + + +
Mod List ({{ .Queried.PlayerCount }})
Collapse Mod List
{{ . }}
No Detectable Mods.
Collapse Mod List
+

+{{ end }} +

+

+ + {{ if .ExtendedShown }}Hide Extended Information{{ else }}Show Extended Information{{ end }} + +
+
+ + {{ if .Dark }}Light Mode{{ else }}Dark Mode{{ 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 +}