diff --git a/src/device/input/parse/v01/testdata/v01.yaml b/src/device/input/parse/v01/testdata/v01.yaml
index 4dd6362..ae71f84 100644
--- a/src/device/input/parse/v01/testdata/v01.yaml
+++ b/src/device/input/parse/v01/testdata/v01.yaml
@@ -1,27 +1,20 @@
feedback:
addr: :17071
ttsurl: http://localhost:15002
-broadcast:
- message: hi
users:
bel:
+ meta:
+ lasttsms: 1681062770999
+ lastlag: 12
state:
player: 0
- message: "hi"
- alias: driver
- meta:
- tsms: 1
- lastlag: 2
+ message: hi
+ gm:
+ alias: ""
+ lastalias: ""
+ vote: ""
players:
-- buttons:
- up: "w"
- down: "s"
- left: "a"
- right: "d"
- l: "q"
- r: "e"
- a: "1"
- b: "2"
- x: "3"
- y: "4"
+- transformation: {}
quiet: false
+broadcast:
+ message: hi
diff --git a/src/device/input/raw/public/root.html b/src/device/input/raw/public/root.html
index fa3ba35..f12d5ec 100644
--- a/src/device/input/raw/public/root.html
+++ b/src/device/input/raw/public/root.html
@@ -27,10 +27,10 @@
function noopcallback(responseBody, responseStatus) {
}
setInterval(() => {
- http("GET", `/proxy?user=${document.getElementById("user")}`, (b, s) => {
+ http("GET", `/proxy?user=${document.getElementById("user").value}`, (b, s) => {
if (s != 200)
return
- document.getElementById("ntfy").innerHTML = b.replace("\n", "
")
+ document.getElementById("ntfy").innerHTML = b.replaceAll("\n", "
")
}, null)
}, 1500)
diff --git a/src/device/input/raw/ws.go b/src/device/input/raw/ws.go
index e5887ae..cc9548e 100644
--- a/src/device/input/raw/ws.go
+++ b/src/device/input/raw/ws.go
@@ -6,11 +6,18 @@ import (
"fmt"
"log"
"net/http"
+ "net/http/httputil"
+ "net/url"
"os"
+ "strings"
"github.com/gorilla/websocket"
)
+var (
+ FlagWSProxy = os.Getenv("RAW_WS_PROXY_URL")
+)
+
type WS struct {
ctx context.Context
can context.CancelFunc
@@ -72,10 +79,27 @@ func (ws WS) serveHTTP(w http.ResponseWriter, r *http.Request) error {
case "/api/ws":
return ws.serveWS(w, r)
}
+ if strings.HasPrefix(r.URL.Path, "/proxy") {
+ return ws.serveProxy(w, r)
+ }
http.NotFound(w, r)
return nil
}
+func (ws WS) serveProxy(w http.ResponseWriter, r *http.Request) error {
+ u, err := url.Parse(FlagWSProxy)
+ if err != nil {
+ return err
+ }
+ r.URL.Path = strings.TrimPrefix(r.URL.Path, "/proxy")
+ if r.URL.Path == "" {
+ r.URL.Path = "/"
+ }
+ proxy := httputil.NewSingleHostReverseProxy(u)
+ proxy.ServeHTTP(w, r)
+ return nil
+}
+
//go:embed public/root.html
var rootHTML string