Browse Source

auto update script executed

Toby Chui 1 year ago
parent
commit
1190905b90
1 changed files with 4 additions and 7 deletions
  1. 4 7
      mod/sshprox/sshprox.go

+ 4 - 7
mod/sshprox/sshprox.go

@@ -85,11 +85,8 @@ func (m *Manager) HandleHttpByInstanceId(instanceId string, w http.ResponseWrite
 	if r.Header["Upgrade"] != nil && strings.ToLower(r.Header["Upgrade"][0]) == "websocket" {
 		//Handle WebSocket request. Forward the custom Upgrade header and rewrite origin
 		r.Header.Set("A-Upgrade", "websocket")
-		if len(requestURL) > 0 && requestURL[:1] == "/" {
-			//Remove starting / from request URL if exists
-			requestURL = requestURL[1:]
-		}
-		u, _ := url.Parse("ws://127.0.0.1:" + strconv.Itoa(targetInstance.AssignedPort) + requestURL)
+		requestURL = strings.TrimPrefix(requestURL, "/")
+		u, _ := url.Parse("ws://127.0.0.1:" + strconv.Itoa(targetInstance.AssignedPort) + "/" + requestURL)
 		wspHandler := websocketproxy.NewProxy(u)
 		wspHandler.ServeHTTP(w, r)
 		return
@@ -157,9 +154,9 @@ func (i *Instance) CreateNewConnection(listenPort int, remoteIpAddr string, remo
 		return err
 	}
 
-	//Create a new proxy object to the proxy
+	//Create new proxy objects to the proxy
 	proxy := reverseproxy.NewReverseProxy(path)
-	i.conn = proxy
 
+	i.conn = proxy
 	return nil
 }