From 2fb044d81ca685cd959e26d1822b9bdd52becdbc Mon Sep 17 00:00:00 2001 From: kikimor Date: Sat, 6 Mar 2021 23:33:30 +0500 Subject: [PATCH] endpoint nat support --- Device.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Device.go b/Device.go index 5a77e04a..a2e175fc 100644 --- a/Device.go +++ b/Device.go @@ -6,6 +6,7 @@ import ( "fmt" "io/ioutil" "net/http" + "net/url" "reflect" "strconv" "strings" @@ -195,6 +196,13 @@ func (dev *Device) addEndpoint(Key, Value string) { //use lowCaseKey //make key having ability to handle Mixed Case for Different vendor devcie (e.g. Events EVENTS, events) lowCaseKey := strings.ToLower(Key) + + // Replace host with host from device params. + if u, err := url.Parse(Value); err == nil { + u.Host = dev.params.Xaddr + Value = u.String() + } + dev.endpoints[lowCaseKey] = Value }