diff --git a/bumper/__init__.py b/bumper/__init__.py index 77e54be..3ae2598 100644 --- a/bumper/__init__.py +++ b/bumper/__init__.py @@ -89,7 +89,7 @@ class VacBotDevice(object): resource="", name="", nick="", - company="eco-ng", + company="", ): self.vac_bot_device_class = vac_bot_device_class self.company = company @@ -132,13 +132,14 @@ def check_authcode(uid, authcode): return False -def add_bot(sn, did, devclass, resource): +def add_bot(sn, did, devclass, resource, company): newbot = VacBotDevice() newbot.did = did newbot.name = sn newbot.vac_bot_device_class = devclass newbot.resource = resource + newbot.company = company bots = bumper_bots_var.get() existingbot = False diff --git a/bumper/confserver.py b/bumper/confserver.py index 70c37d8..62a4cca 100644 --- a/bumper/confserver.py +++ b/bumper/confserver.py @@ -584,6 +584,8 @@ class ConfServer: confserverlog.debug( "\r\n POST: {} \r\n Response: {}".format(postbody, body) ) + + return web.json_response(body) except Exception as e: @@ -606,18 +608,18 @@ class ConfServer: if todo == "FindBest": service = postbody["service"] if service == "EcoMsgNew": - body = { - "result": "ok", - "ip": socket.gethostbyname(socket.gethostname()), - "port": 5223, - } + confserverlog.debug( + "\r\n POST: {} \r\n Response: {}".format(postbody, body) + ) + msgserver = '{"ip":"{}","port":5223,"result":"ok"}'.format(socket.gethostbyname(socket.gethostname())) #bot seems to be very picky about having no spaces, only way was with text + return web.json_response(text=msgserver) elif service == "EcoUpdate": body = {"result": "ok", "ip": "47.88.66.164", "port": 8005} confserverlog.debug( "\r\n POST: {} \r\n Response: {}".format(postbody, body) ) - return web.json_response(body) + return web.json_response(body) except Exception as e: confserverlog.exception("{}".format(e)) diff --git a/bumper/mqttserver.py b/bumper/mqttserver.py index 35285b2..6dc3f10 100644 --- a/bumper/mqttserver.py +++ b/bumper/mqttserver.py @@ -333,7 +333,7 @@ class BumperMQTTServer_Plugin: ): tmpbotdetail = str(didsplit[1]).split("/") bumper.add_bot( - username, didsplit[0], tmpbotdetail[0], tmpbotdetail[1] + username, didsplit[0], tmpbotdetail[0], tmpbotdetail[1], "eco-ng" ) mqttserverlog.debug( "new bot authenticated SN: {} DID: {}".format( diff --git a/bumper/xmppserver.py b/bumper/xmppserver.py index f20081f..366715a 100644 --- a/bumper/xmppserver.py +++ b/bumper/xmppserver.py @@ -193,6 +193,7 @@ class Client(threading.Thread): self.connection = connection self.address = client_address[0] self.clientresource = "" + self.devclass = "" self.uid = "" self.log_sent_message = False # Set to true to log sends self.log_incoming_data = True # Set to true to log sends @@ -372,6 +373,10 @@ class Client(threading.Thread): # Client first connecting, send our features if data.decode("utf-8").find("jabber:client") > -1: + sc = data.decode("utf-8").find("to=") + ec = data.decode("utf-8").find(".ecorobot.net") + if ec > -1: + self.devclass = data.decode("utf-8")[sc+4:ec] # ack jabbr:client # no STARTTLS self.send( @@ -527,13 +532,19 @@ class Client(threading.Thread): username = saslauth[0] username = saslauth[0].split("\x00")[1] self.uid = username - resource = saslauth[1] - self.clientresource = resource - authcode = saslauth[2] + if len(saslauth) > 1: + resource = saslauth[1] + self.clientresource = resource + elif len(saslauth[0].split("\x00")) > 2: + resource = saslauth[0].split("\x00")[2] + self.clientresource = resource + + if len(saslauth) > 2: + authcode = saslauth[2] if not self.uid.startswith("fuid"): # Need sample data to see details here - bumper.add_bot("", self.uid, "", resource) + bumper.add_bot(self.uid, self.uid, self.devclass, "atom","eco-legacy") xmppserverlog.info("bot authenticated {}".format(self.uid)) # Send response self.send(