speed + more config
This commit is contained in:
@@ -1,9 +1,6 @@
|
|||||||
.boxes-container {
|
.boxes-container {
|
||||||
max-width: 800px;
|
|
||||||
margin: 0 auto;
|
|
||||||
border: #4a7c59 1px dotted;
|
border: #4a7c59 1px dotted;
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
|
|
||||||
}
|
}
|
||||||
.boxes input{
|
.boxes input{
|
||||||
margin: 0;
|
margin: 0;
|
||||||
@@ -53,3 +50,10 @@
|
|||||||
.counter-label {
|
.counter-label {
|
||||||
color: #4a7c59;
|
color: #4a7c59;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.users-container {
|
||||||
|
border: #4a7c59 1px dotted;
|
||||||
|
margin-top:50px;
|
||||||
|
color:#4a7c59;
|
||||||
|
font-size: 0.5rem; /* Adjust font size as needed */
|
||||||
|
}
|
||||||
@@ -32,3 +32,7 @@ a:hover {
|
|||||||
nav li {
|
nav li {
|
||||||
list-style: none;
|
list-style: none;
|
||||||
}
|
}
|
||||||
|
main{
|
||||||
|
max-width: 800px;
|
||||||
|
margin: 0 auto;
|
||||||
|
}
|
||||||
@@ -16,7 +16,6 @@
|
|||||||
const box = deserializeBox(i);
|
const box = deserializeBox(i);
|
||||||
const el = document.getElementById("box-" + box.id);
|
const el = document.getElementById("box-" + box.id);
|
||||||
el.checked = box.value;
|
el.checked = box.value;
|
||||||
// console.log(i,box,el)
|
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -24,8 +23,8 @@
|
|||||||
const items = instruction.split(":");
|
const items = instruction.split(":");
|
||||||
const el = document.getElementById("counter");
|
const el = document.getElementById("counter");
|
||||||
el.innerText = items[1];
|
el.innerText = items[1];
|
||||||
const el2 = document.getElementById("ips");
|
const el2 = document.getElementById("users");
|
||||||
el2.innerText = items[2].replaceAll(",", "\n");
|
el2.innerText = items[2].replaceAll(",,,", "\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ type Box = {
|
|||||||
|
|
||||||
const el = document.getElementById("box-" + box.id) as CheckboxEl;
|
const el = document.getElementById("box-" + box.id) as CheckboxEl;
|
||||||
el.checked = box.value;
|
el.checked = box.value;
|
||||||
// console.log(i,box,el)
|
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -34,8 +33,8 @@ type Box = {
|
|||||||
|
|
||||||
const el = document.getElementById("counter") as CheckboxEl;
|
const el = document.getElementById("counter") as CheckboxEl;
|
||||||
el.innerText = items[1];
|
el.innerText = items[1];
|
||||||
const el2 = document.getElementById("ips") as CheckboxEl;
|
const el2 = document.getElementById("users") as CheckboxEl;
|
||||||
el2.innerText = items[2].replaceAll(",", "<br/>");
|
el2.innerText = items[2].replaceAll(",,,", "\n");
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -161,13 +161,13 @@ func handleMessage(msg string, ws *websocket.Conn) error {
|
|||||||
func InitWs(c echo.Context) error {
|
func InitWs(c echo.Context) error {
|
||||||
websocket.Handler(func(ws *websocket.Conn) {
|
websocket.Handler(func(ws *websocket.Conn) {
|
||||||
wsMutex.Lock()
|
wsMutex.Lock()
|
||||||
wsConnections[ws] = c.RealIP()
|
wsConnections[ws] = c.Request().UserAgent()
|
||||||
wsMutex.Unlock()
|
wsMutex.Unlock()
|
||||||
|
|
||||||
boxes := GetBoxes()
|
boxes := GetBoxes()
|
||||||
msg := "u:" + strconv.Itoa(len(wsConnections)) + ":"
|
msg := "u:" + strconv.Itoa(len(wsConnections)) + ":"
|
||||||
for _, addr := range wsConnections {
|
for _, addr := range wsConnections {
|
||||||
msg += addr + ","
|
msg += addr + ",,,"
|
||||||
}
|
}
|
||||||
msg += "\n"
|
msg += "\n"
|
||||||
|
|
||||||
|
|||||||
15
src/main.go
15
src/main.go
@@ -3,6 +3,9 @@ package main
|
|||||||
import (
|
import (
|
||||||
"html/template"
|
"html/template"
|
||||||
"io"
|
"io"
|
||||||
|
"net/http"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/labstack/echo/v4"
|
"github.com/labstack/echo/v4"
|
||||||
"github.com/labstack/echo/v4/middleware"
|
"github.com/labstack/echo/v4/middleware"
|
||||||
@@ -47,9 +50,21 @@ func main() {
|
|||||||
|
|
||||||
e.Logger.SetLevel(log.DEBUG)
|
e.Logger.SetLevel(log.DEBUG)
|
||||||
e.Use(middleware.Logger())
|
e.Use(middleware.Logger())
|
||||||
|
e.Use(middleware.Gzip())
|
||||||
|
e.Use(middleware.HTTPSRedirect())
|
||||||
|
|
||||||
e.GET("/health", healthCheck)
|
e.GET("/health", healthCheck)
|
||||||
|
|
||||||
|
e.Use(func(next echo.HandlerFunc) echo.HandlerFunc {
|
||||||
|
return func(c echo.Context) error {
|
||||||
|
if strings.HasPrefix(c.Request().URL.Path, "/css/") || strings.HasPrefix(c.Request().URL.Path, "/js/") {
|
||||||
|
c.Response().Header().Set("Cache-Control", "public, max-age=31536000") // 1 year
|
||||||
|
c.Response().Header().Set("Expires", time.Now().AddDate(1, 0, 0).Format(http.TimeFormat))
|
||||||
|
}
|
||||||
|
return next(c)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
e.Static("/css", "css")
|
e.Static("/css", "css")
|
||||||
e.Static("/js", "js")
|
e.Static("/js", "js")
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
|
|
||||||
|
|
||||||
<span class="counter-label">Currently Online: <span id="counter"></span></span>
|
<span class="counter-label">Currently Online: <span id="counter"></span></span>
|
||||||
<div id="ips" class="ips-container"></div>
|
|
||||||
|
|
||||||
<div class="boxes-container">
|
<div class="boxes-container">
|
||||||
<div class="boxes">
|
<div class="boxes">
|
||||||
@@ -19,6 +18,9 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div id="users" class="users-container"></div>
|
||||||
|
|
||||||
|
|
||||||
<script src="js/ws.js?v={{.BuildNumber}}"></script>
|
<script src="js/ws.js?v={{.BuildNumber}}"></script>
|
||||||
<script src="js/boxes.js?v={{.BuildNumber}}"></script>
|
<script src="js/boxes.js?v={{.BuildNumber}}"></script>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|||||||
Reference in New Issue
Block a user