From 13385ba650dd7fe06bcc6b40b299999948f399ed Mon Sep 17 00:00:00 2001 From: iDigitalFlame Date: Fri, 30 Nov 2018 21:42:03 +0000 Subject: [PATCH] Remove the string replacement of the bind address/port Removes the bind address in favor of using JS to auto detect the location and use instead. "window.location.host" will point to the proper endpoint. If the server is at "10.10.10.10", 'new WebSocket("ws://" + window.location.host + "/socket");' would be created at "ws://10.10.10.10". The "window.location.host" property also includes the port number as well. This should fix the current open issue with websockets on HTML not rendering properly when the "-bind" option is omitted. --- handlers/html.go | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/handlers/html.go b/handlers/html.go index 9b9ad3a..00a305d 100644 --- a/handlers/html.go +++ b/handlers/html.go @@ -15,18 +15,11 @@ type HTML struct { // NewHTML returns new HTML handler. func NewHTML(bind string, width, height float64, nogl bool) *HTML { h := &HTML{} - - b := strings.Split(bind, ":") - if b[0] == "" { - bind = "127.0.0.1" + bind - } - + tpl := htmlWebGL if nogl { tpl = html } - - tpl = strings.Replace(tpl, "{BIND}", bind, -1) tpl = strings.Replace(tpl, "{WIDTH}", fmt.Sprintf("%.0f", width), -1) tpl = strings.Replace(tpl, "{HEIGHT}", fmt.Sprintf("%.0f", height), -1) @@ -52,7 +45,7 @@ var html = ` cam2ip