From dd2a2b3ced3871ccae9deabbbd6b1a0f2ec85e73 Mon Sep 17 00:00:00 2001 From: leandrofars Date: Thu, 5 Sep 2024 13:14:49 -0300 Subject: [PATCH] fix(ws): usp 1.3 version breaking changes --- .../mtp/ws/internal/ws/handler/client.go | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/backend/services/mtp/ws/internal/ws/handler/client.go b/backend/services/mtp/ws/internal/ws/handler/client.go index f26c8cb..8f70456 100644 --- a/backend/services/mtp/ws/internal/ws/handler/client.go +++ b/backend/services/mtp/ws/internal/ws/handler/client.go @@ -3,7 +3,6 @@ package handler import ( "log" "net/http" - "strings" "time" "github.com/OktopUSP/oktopus/ws/internal/usp_record" @@ -203,7 +202,7 @@ func ServeAgent( "Sec-Websocket-Version": {wsVersion}, } - deviceid := extractDeviceId(r.Header) + deviceid := r.URL.Query().Get("eid") if deviceid == "" { w.WriteHeader(http.StatusBadRequest) log.Println("Device id not found") @@ -244,18 +243,21 @@ func ServeAgent( go client.readPump(cEID) } -// gets device id from websockets header +/* + sec-websocket-extensions where deprecated at USP version 1.3 + https://usp.technology/specification/index.htm#r-ws.10a + That is why the function below is commented +*/ +/* func extractDeviceId(header http.Header) string { - - // Header must be like that: bbf-usp-protocol; eid="" is the same ar the record.FromId/record.ToId - // log.Println("Header sec-websocket-extensions:", header.Get("sec-websocket-extensions")) + Header must be like that: bbf-usp-protocol; eid="" is the same ar the record.FromId/record.ToId + log.Println("Header sec-websocket-extensions:", header.Get("sec-websocket-extensions")) wsHeaderExtension := header.Get("sec-websocket-extensions") - // Split the input string by double quotes + Split the input string by double quotes deviceid := strings.Split(wsHeaderExtension, "\"") if len(deviceid) < 2 { return "" } - return deviceid[1] -} +}*/