aboutsummaryrefslogtreecommitdiff
path: root/xP
diff options
context:
space:
mode:
authorPřemysl Eric Janouch <p@janouch.name>2022-09-08 15:13:20 +0200
committerPřemysl Eric Janouch <p@janouch.name>2022-09-08 17:11:01 +0200
commitd7b6967b6f16d9d953c2627232ca194ec08da942 (patch)
tree71931cb45546feebee567f74726742010206a987 /xP
parent8c3ee80b21278eaa6fb29f73b79c16d443923dfa (diff)
downloadxK-d7b6967b6f16d9d953c2627232ca194ec08da942.tar.gz
xK-d7b6967b6f16d9d953c2627232ca194ec08da942.tar.xz
xK-d7b6967b6f16d9d953c2627232ca194ec08da942.zip
xP: allow setting a fixed WS URI
For reverse proxies.
Diffstat (limited to 'xP')
-rw-r--r--xP/xP.go13
1 files changed, 10 insertions, 3 deletions
diff --git a/xP/xP.go b/xP/xP.go
index b9ab73c..9428501 100644
--- a/xP/xP.go
+++ b/xP/xP.go
@@ -22,6 +22,7 @@ import (
var (
addressBind string
addressConnect string
+ addressWS string
)
func clientToRelay(
@@ -163,18 +164,24 @@ func handleDefault(w http.ResponseWriter, r *http.Request) {
return
}
- wsURI := fmt.Sprintf("ws://%s/ws", r.Host)
+ wsURI := addressWS
+ if wsURI == "" {
+ wsURI = fmt.Sprintf("ws://%s/ws", r.Host)
+ }
if err := page.Execute(w, wsURI); err != nil {
log.Println("Template execution failed: " + err.Error())
}
}
func main() {
- if len(os.Args) != 3 {
- log.Fatalf("usage: %s BIND CONNECT\n", os.Args[0])
+ if len(os.Args) < 3 || len(os.Args) > 4 {
+ log.Fatalf("usage: %s BIND CONNECT [WSURI]\n", os.Args[0])
}
addressBind, addressConnect = os.Args[1], os.Args[2]
+ if len(os.Args) > 3 {
+ addressWS = os.Args[3]
+ }
http.Handle("/ws", websocket.Handler(handleWebSocket))
http.Handle("/", http.HandlerFunc(handleDefault))