parent
8c3ee80b21
commit
d7b6967b6f
13
xP/xP.go
13
xP/xP.go
|
@ -22,6 +22,7 @@ import (
|
||||||
var (
|
var (
|
||||||
addressBind string
|
addressBind string
|
||||||
addressConnect string
|
addressConnect string
|
||||||
|
addressWS string
|
||||||
)
|
)
|
||||||
|
|
||||||
func clientToRelay(
|
func clientToRelay(
|
||||||
|
@ -163,18 +164,24 @@ func handleDefault(w http.ResponseWriter, r *http.Request) {
|
||||||
return
|
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 {
|
if err := page.Execute(w, wsURI); err != nil {
|
||||||
log.Println("Template execution failed: " + err.Error())
|
log.Println("Template execution failed: " + err.Error())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
if len(os.Args) != 3 {
|
if len(os.Args) < 3 || len(os.Args) > 4 {
|
||||||
log.Fatalf("usage: %s BIND CONNECT\n", os.Args[0])
|
log.Fatalf("usage: %s BIND CONNECT [WSURI]\n", os.Args[0])
|
||||||
}
|
}
|
||||||
|
|
||||||
addressBind, addressConnect = os.Args[1], os.Args[2]
|
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("/ws", websocket.Handler(handleWebSocket))
|
||||||
http.Handle("/", http.HandlerFunc(handleDefault))
|
http.Handle("/", http.HandlerFunc(handleDefault))
|
||||||
|
|
Loading…
Reference in New Issue