Loading go-apps/meep-sss/server/meep-sss.go +13 −7 Original line number Diff line number Diff line Loading @@ -615,12 +615,17 @@ func startIotPlatformDiscoveryTicker() { continue } log.Debug("startIotPlatformDiscoveryTicker: uri: ", u) log.Debug("startIotPlatformDiscoveryTicker: host: ", u.Host) log.Debug("startIotPlatformDiscoveryTicker: port: ", u.Port()) log.Debug("startIotPlatformDiscoveryTicker: path: ", u.Path) log.Debug("startIotPlatformDiscoveryTicker: query: ", u.Query()) log.Debug("startIotPlatformDiscoveryTicker: scheme: ", u.Scheme) log.Debug("startIotPlatformDiscoveryTicker: raw: ", u.RawQuery) port := u.Port() u.Host = u.Scheme + "://" + u.Hostname() log.Debug("startIotPlatformDiscoveryTicker: address: ", u.Host) log.Debug("startIotPlatformDiscoveryTicker: port: ", port) // Need to send request...... p = sbi.IotPlatformInfo{ /* For HTTP */ Host: u.Host, Loading @@ -636,9 +641,10 @@ func startIotPlatformDiscoveryTicker() { Protocol: v.UserTransportInfo[0].Protocol, */ } p.Port, err = strconv.Atoi(u.Port()) p.Port, err = strconv.Atoi(port) if err != nil { log.Error("startIotPlatformDiscoveryTicker: Port comversion: ", err.Error()) // if u.Scheme == "https" { p.Port = 443 log.Debug("startIotPlatformDiscoveryTicker: Force port to 443") Loading go-packages/meep-sss-mgr/SssMgrBindingProtocol.go +1 −0 Original line number Diff line number Diff line Loading @@ -9,6 +9,7 @@ type SssMgrBindingProtocol interface { type SssMgrBindingProtocolContext struct { host string port int scheme string path string name string hostId string Loading go-packages/meep-sss-mgr/http.go +19 −9 Original line number Diff line number Diff line Loading @@ -138,14 +138,23 @@ func (http_mgr *SssMgrHttp) send(p_ctx SssMgrBindingProtocolContext) (err error, if to != p_ctx.name && !strings.Contains(to, "/") && p_ctx.name != "" { to = p_ctx.name + "/" + to } scheme := "https://" if p_ctx.port != 443 { scheme = "http://" } if p_ctx.path != "" { url = scheme + p_ctx.host + ":" + strconv.Itoa(p_ctx.port) + "/" + p_ctx.path + "/" + to scheme := p_ctx.scheme // if p_ctx.scheme == "https" { // scheme = "https://" // } if p_ctx.path != "" && scheme != "" && p_ctx.host != "" && p_ctx.port != 0 { if strings.HasPrefix(p_ctx.path, "/") { p_ctx.path = p_ctx.path[1:len(p_ctx.path)] } url = scheme + "://" + p_ctx.host + ":" + strconv.Itoa(p_ctx.port) + "/" + p_ctx.path + "/" + to } else if scheme != "" && p_ctx.host != "" && p_ctx.port != 0 { url = scheme + "://" + p_ctx.host + ":" + strconv.Itoa(p_ctx.port) + "/" + to } else if p_ctx.host != "" && p_ctx.port != 0 { url = p_ctx.host + ":" + strconv.Itoa(p_ctx.port) + "/" + to } else { url = scheme + p_ctx.host + ":" + strconv.Itoa(p_ctx.port) + "/" + to err := errors.New("Invalid p_ctx") log.Error("send: ", err.Error()) return err, nil } // Set the method method := "" Loading Loading @@ -203,6 +212,7 @@ func sendRequest(method string, url string, headers http.Header, body io.Reader, log.Debug(">>> sendRequest: url: ", url) log.Debug(">>> sendRequest: headers: ", headers) // var bodyBytes []byte var err error if body != nil { Loading go-packages/meep-sss-mgr/onem2m-mgr.go +25 −0 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ import ( "strings" "sync" "time" // "net" log "github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-logger" Loading @@ -40,6 +41,7 @@ type SssMgr struct { protocol SssMgrBindingProtocol host string port int scheme string path string cse_name string hostId string Loading Loading @@ -214,6 +216,7 @@ func NewSssMgr_with_uri(name string, namespace string, bindingProtocol string, u tm.host = u.Hostname() tm.port, err = strconv.Atoi(u.Port()) tm.path = u.Path tm.scheme = u.Scheme if err != nil { tm.port = 443 log.Debug("NewSssMgr_with_uri: Force port to ", tm.port) Loading Loading @@ -391,6 +394,7 @@ func (tm *SssMgr) GetSensor(sensorIdentifier string) (sensor SensorDiscoveryInfo */ func (tm *SssMgr) populateDevicesPerIotPlatforms() error { log.Debug(">>> populateDevicesPerIotPlatforms (go-packages/meep-sss-mgr/onem2m-mgr.go)") if profiling { profilingTimers["populateDevicesPerIotPlatforms"] = time.Now() } Loading @@ -401,6 +405,20 @@ func (tm *SssMgr) populateDevicesPerIotPlatforms() error { // Refresh the list of devices for all registered Iot platform for _, iotPlatform := range registeredIotPlatformsMap { // address := iotPlatform.Address // if iotPlatform.Port != 0 { // if host, _, err := net.SplitHostPort(address); err == nil { // address = host // } // } // if !strings.HasPrefix(address, "mqtt") && // !strings.HasPrefix(address, "wss") && // !strings.HasPrefix(address, "http://") && // !strings.HasPrefix(address, "https://") { // address = tm.scheme + "://" + address // } // log.Debug("populateDevicesPerIotPlatforms: processing: ", tm.scheme) // iotPlatform.Address = address log.Debug("populateDevicesPerIotPlatforms: processing: ", iotPlatform.Address) err := tm.populateSensors(iotPlatform, "3") if err != nil { Loading Loading @@ -446,6 +464,7 @@ func (tm *SssMgr) populateSensors(iotPlatformInfo IotPlatformInfo, type_ string) host: iotPlatformInfo.Address, port: iotPlatformInfo.Port, path: tm.path, scheme: tm.scheme, name: iotPlatformInfo.Name, hostId: iotPlatformInfo.IotPlatformId, to: iotPlatformInfo.Name, Loading Loading @@ -669,6 +688,7 @@ func (tm *SssMgr) OneM2M_create(sensor SensorDiscoveryInfo, path string, origina host: registeredIotPlatformsMap[sensor.IotPlatformId].Address, port: registeredIotPlatformsMap[sensor.IotPlatformId].Port, path: tm.path, scheme: tm.scheme, name: registeredIotPlatformsMap[sensor.IotPlatformId].Name, hostId: sensor.IotPlatformId, to: registeredIotPlatformsMap[sensor.IotPlatformId].Name, Loading Loading @@ -778,6 +798,7 @@ func (tm *SssMgr) OneM2M_discovery(type_ string, iotPlatformId string, originato host: registeredIotPlatformsMap[iotPlatformId].Address, port: registeredIotPlatformsMap[iotPlatformId].Port, path: tm.path, scheme: tm.scheme, name: registeredIotPlatformsMap[iotPlatformId].Name, hostId: iotPlatformId, to: registeredIotPlatformsMap[iotPlatformId].Name, Loading Loading @@ -871,6 +892,7 @@ func (tm *SssMgr) OneM2M_get(path string, iotPlatformId string, originator strin host: registeredIotPlatformsMap[iotPlatformId].Address, port: registeredIotPlatformsMap[iotPlatformId].Port, path: tm.path, scheme: tm.scheme, name: registeredIotPlatformsMap[iotPlatformId].Name, hostId: iotPlatformId, to: path, Loading Loading @@ -935,6 +957,7 @@ func (tm *SssMgr) OneM2M_subscribe(iotPlatformId string, path string, originator host: registeredIotPlatformsMap[iotPlatformId].Address, port: registeredIotPlatformsMap[iotPlatformId].Port, path: tm.path, scheme: tm.scheme, name: registeredIotPlatformsMap[iotPlatformId].Name, hostId: iotPlatformId, to: path, Loading Loading @@ -1040,6 +1063,7 @@ func (tm *SssMgr) OneM2M_delete(sensor SensorDiscoveryInfo, originator string) ( host: registeredIotPlatformsMap[sensor.IotPlatformId].Address, port: registeredIotPlatformsMap[sensor.IotPlatformId].Port, path: tm.path, scheme: tm.scheme, name: registeredIotPlatformsMap[sensor.IotPlatformId].Name, hostId: sensor.IotPlatformId, to: sensor.SensorIdentifier, Loading Loading @@ -1092,6 +1116,7 @@ func (tm *SssMgr) OneM2M_delete_subscription(subId string, originator string) (e host: registeredIotPlatformsMap[subscriptionListPerSubId[subId].IotPlatformId].Address, port: registeredIotPlatformsMap[subscriptionListPerSubId[subId].IotPlatformId].Port, path: tm.path, scheme: tm.scheme, name: registeredIotPlatformsMap[subscriptionListPerSubId[subId].IotPlatformId].Name, hostId: subscriptionListPerSubId[subId].IotPlatformId, to: subscriptionListPerSubId[subId].SensorIdentifier, Loading Loading
go-apps/meep-sss/server/meep-sss.go +13 −7 Original line number Diff line number Diff line Loading @@ -615,12 +615,17 @@ func startIotPlatformDiscoveryTicker() { continue } log.Debug("startIotPlatformDiscoveryTicker: uri: ", u) log.Debug("startIotPlatformDiscoveryTicker: host: ", u.Host) log.Debug("startIotPlatformDiscoveryTicker: port: ", u.Port()) log.Debug("startIotPlatformDiscoveryTicker: path: ", u.Path) log.Debug("startIotPlatformDiscoveryTicker: query: ", u.Query()) log.Debug("startIotPlatformDiscoveryTicker: scheme: ", u.Scheme) log.Debug("startIotPlatformDiscoveryTicker: raw: ", u.RawQuery) port := u.Port() u.Host = u.Scheme + "://" + u.Hostname() log.Debug("startIotPlatformDiscoveryTicker: address: ", u.Host) log.Debug("startIotPlatformDiscoveryTicker: port: ", port) // Need to send request...... p = sbi.IotPlatformInfo{ /* For HTTP */ Host: u.Host, Loading @@ -636,9 +641,10 @@ func startIotPlatformDiscoveryTicker() { Protocol: v.UserTransportInfo[0].Protocol, */ } p.Port, err = strconv.Atoi(u.Port()) p.Port, err = strconv.Atoi(port) if err != nil { log.Error("startIotPlatformDiscoveryTicker: Port comversion: ", err.Error()) // if u.Scheme == "https" { p.Port = 443 log.Debug("startIotPlatformDiscoveryTicker: Force port to 443") Loading
go-packages/meep-sss-mgr/SssMgrBindingProtocol.go +1 −0 Original line number Diff line number Diff line Loading @@ -9,6 +9,7 @@ type SssMgrBindingProtocol interface { type SssMgrBindingProtocolContext struct { host string port int scheme string path string name string hostId string Loading
go-packages/meep-sss-mgr/http.go +19 −9 Original line number Diff line number Diff line Loading @@ -138,14 +138,23 @@ func (http_mgr *SssMgrHttp) send(p_ctx SssMgrBindingProtocolContext) (err error, if to != p_ctx.name && !strings.Contains(to, "/") && p_ctx.name != "" { to = p_ctx.name + "/" + to } scheme := "https://" if p_ctx.port != 443 { scheme = "http://" } if p_ctx.path != "" { url = scheme + p_ctx.host + ":" + strconv.Itoa(p_ctx.port) + "/" + p_ctx.path + "/" + to scheme := p_ctx.scheme // if p_ctx.scheme == "https" { // scheme = "https://" // } if p_ctx.path != "" && scheme != "" && p_ctx.host != "" && p_ctx.port != 0 { if strings.HasPrefix(p_ctx.path, "/") { p_ctx.path = p_ctx.path[1:len(p_ctx.path)] } url = scheme + "://" + p_ctx.host + ":" + strconv.Itoa(p_ctx.port) + "/" + p_ctx.path + "/" + to } else if scheme != "" && p_ctx.host != "" && p_ctx.port != 0 { url = scheme + "://" + p_ctx.host + ":" + strconv.Itoa(p_ctx.port) + "/" + to } else if p_ctx.host != "" && p_ctx.port != 0 { url = p_ctx.host + ":" + strconv.Itoa(p_ctx.port) + "/" + to } else { url = scheme + p_ctx.host + ":" + strconv.Itoa(p_ctx.port) + "/" + to err := errors.New("Invalid p_ctx") log.Error("send: ", err.Error()) return err, nil } // Set the method method := "" Loading Loading @@ -203,6 +212,7 @@ func sendRequest(method string, url string, headers http.Header, body io.Reader, log.Debug(">>> sendRequest: url: ", url) log.Debug(">>> sendRequest: headers: ", headers) // var bodyBytes []byte var err error if body != nil { Loading
go-packages/meep-sss-mgr/onem2m-mgr.go +25 −0 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ import ( "strings" "sync" "time" // "net" log "github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-logger" Loading @@ -40,6 +41,7 @@ type SssMgr struct { protocol SssMgrBindingProtocol host string port int scheme string path string cse_name string hostId string Loading Loading @@ -214,6 +216,7 @@ func NewSssMgr_with_uri(name string, namespace string, bindingProtocol string, u tm.host = u.Hostname() tm.port, err = strconv.Atoi(u.Port()) tm.path = u.Path tm.scheme = u.Scheme if err != nil { tm.port = 443 log.Debug("NewSssMgr_with_uri: Force port to ", tm.port) Loading Loading @@ -391,6 +394,7 @@ func (tm *SssMgr) GetSensor(sensorIdentifier string) (sensor SensorDiscoveryInfo */ func (tm *SssMgr) populateDevicesPerIotPlatforms() error { log.Debug(">>> populateDevicesPerIotPlatforms (go-packages/meep-sss-mgr/onem2m-mgr.go)") if profiling { profilingTimers["populateDevicesPerIotPlatforms"] = time.Now() } Loading @@ -401,6 +405,20 @@ func (tm *SssMgr) populateDevicesPerIotPlatforms() error { // Refresh the list of devices for all registered Iot platform for _, iotPlatform := range registeredIotPlatformsMap { // address := iotPlatform.Address // if iotPlatform.Port != 0 { // if host, _, err := net.SplitHostPort(address); err == nil { // address = host // } // } // if !strings.HasPrefix(address, "mqtt") && // !strings.HasPrefix(address, "wss") && // !strings.HasPrefix(address, "http://") && // !strings.HasPrefix(address, "https://") { // address = tm.scheme + "://" + address // } // log.Debug("populateDevicesPerIotPlatforms: processing: ", tm.scheme) // iotPlatform.Address = address log.Debug("populateDevicesPerIotPlatforms: processing: ", iotPlatform.Address) err := tm.populateSensors(iotPlatform, "3") if err != nil { Loading Loading @@ -446,6 +464,7 @@ func (tm *SssMgr) populateSensors(iotPlatformInfo IotPlatformInfo, type_ string) host: iotPlatformInfo.Address, port: iotPlatformInfo.Port, path: tm.path, scheme: tm.scheme, name: iotPlatformInfo.Name, hostId: iotPlatformInfo.IotPlatformId, to: iotPlatformInfo.Name, Loading Loading @@ -669,6 +688,7 @@ func (tm *SssMgr) OneM2M_create(sensor SensorDiscoveryInfo, path string, origina host: registeredIotPlatformsMap[sensor.IotPlatformId].Address, port: registeredIotPlatformsMap[sensor.IotPlatformId].Port, path: tm.path, scheme: tm.scheme, name: registeredIotPlatformsMap[sensor.IotPlatformId].Name, hostId: sensor.IotPlatformId, to: registeredIotPlatformsMap[sensor.IotPlatformId].Name, Loading Loading @@ -778,6 +798,7 @@ func (tm *SssMgr) OneM2M_discovery(type_ string, iotPlatformId string, originato host: registeredIotPlatformsMap[iotPlatformId].Address, port: registeredIotPlatformsMap[iotPlatformId].Port, path: tm.path, scheme: tm.scheme, name: registeredIotPlatformsMap[iotPlatformId].Name, hostId: iotPlatformId, to: registeredIotPlatformsMap[iotPlatformId].Name, Loading Loading @@ -871,6 +892,7 @@ func (tm *SssMgr) OneM2M_get(path string, iotPlatformId string, originator strin host: registeredIotPlatformsMap[iotPlatformId].Address, port: registeredIotPlatformsMap[iotPlatformId].Port, path: tm.path, scheme: tm.scheme, name: registeredIotPlatformsMap[iotPlatformId].Name, hostId: iotPlatformId, to: path, Loading Loading @@ -935,6 +957,7 @@ func (tm *SssMgr) OneM2M_subscribe(iotPlatformId string, path string, originator host: registeredIotPlatformsMap[iotPlatformId].Address, port: registeredIotPlatformsMap[iotPlatformId].Port, path: tm.path, scheme: tm.scheme, name: registeredIotPlatformsMap[iotPlatformId].Name, hostId: iotPlatformId, to: path, Loading Loading @@ -1040,6 +1063,7 @@ func (tm *SssMgr) OneM2M_delete(sensor SensorDiscoveryInfo, originator string) ( host: registeredIotPlatformsMap[sensor.IotPlatformId].Address, port: registeredIotPlatformsMap[sensor.IotPlatformId].Port, path: tm.path, scheme: tm.scheme, name: registeredIotPlatformsMap[sensor.IotPlatformId].Name, hostId: sensor.IotPlatformId, to: sensor.SensorIdentifier, Loading Loading @@ -1092,6 +1116,7 @@ func (tm *SssMgr) OneM2M_delete_subscription(subId string, originator string) (e host: registeredIotPlatformsMap[subscriptionListPerSubId[subId].IotPlatformId].Address, port: registeredIotPlatformsMap[subscriptionListPerSubId[subId].IotPlatformId].Port, path: tm.path, scheme: tm.scheme, name: registeredIotPlatformsMap[subscriptionListPerSubId[subId].IotPlatformId].Name, hostId: subscriptionListPerSubId[subId].IotPlatformId, to: subscriptionListPerSubId[subId].SensorIdentifier, Loading