fix(ws): usp 1.3 version breaking changes
This commit is contained in:
parent
05dcca4d82
commit
dd2a2b3ced
|
|
@ -3,7 +3,6 @@ package handler
|
||||||
import (
|
import (
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/OktopUSP/oktopus/ws/internal/usp_record"
|
"github.com/OktopUSP/oktopus/ws/internal/usp_record"
|
||||||
|
|
@ -203,7 +202,7 @@ func ServeAgent(
|
||||||
"Sec-Websocket-Version": {wsVersion},
|
"Sec-Websocket-Version": {wsVersion},
|
||||||
}
|
}
|
||||||
|
|
||||||
deviceid := extractDeviceId(r.Header)
|
deviceid := r.URL.Query().Get("eid")
|
||||||
if deviceid == "" {
|
if deviceid == "" {
|
||||||
w.WriteHeader(http.StatusBadRequest)
|
w.WriteHeader(http.StatusBadRequest)
|
||||||
log.Println("Device id not found")
|
log.Println("Device id not found")
|
||||||
|
|
@ -244,18 +243,21 @@ func ServeAgent(
|
||||||
go client.readPump(cEID)
|
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 {
|
func extractDeviceId(header http.Header) string {
|
||||||
|
Header must be like that: bbf-usp-protocol; eid="<endpoint-id>" <endpoint-id> is the same ar the record.FromId/record.ToId
|
||||||
// Header must be like that: bbf-usp-protocol; eid="<endpoint-id>" <endpoint-id> is the same ar the record.FromId/record.ToId
|
log.Println("Header sec-websocket-extensions:", header.Get("sec-websocket-extensions"))
|
||||||
// log.Println("Header sec-websocket-extensions:", header.Get("sec-websocket-extensions"))
|
|
||||||
wsHeaderExtension := 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, "\"")
|
deviceid := strings.Split(wsHeaderExtension, "\"")
|
||||||
if len(deviceid) < 2 {
|
if len(deviceid) < 2 {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
return deviceid[1]
|
return deviceid[1]
|
||||||
}
|
}*/
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user