Ozmo930 #9

Merged
bmartin5692 merged 5 commits from Ozmo930 into master 2019-02-27 15:10:14 +01:00
4 changed files with 27 additions and 13 deletions
Showing only changes of commit e97b28a5c8 - Show all commits

View file

@ -89,7 +89,7 @@ class VacBotDevice(object):
resource="", resource="",
name="", name="",
nick="", nick="",
company="eco-ng", company="",
): ):
self.vac_bot_device_class = vac_bot_device_class self.vac_bot_device_class = vac_bot_device_class
self.company = company self.company = company
@ -132,13 +132,14 @@ def check_authcode(uid, authcode):
return False return False
def add_bot(sn, did, devclass, resource): def add_bot(sn, did, devclass, resource, company):
newbot = VacBotDevice() newbot = VacBotDevice()
newbot.did = did newbot.did = did
newbot.name = sn newbot.name = sn
newbot.vac_bot_device_class = devclass newbot.vac_bot_device_class = devclass
newbot.resource = resource newbot.resource = resource
newbot.company = company
bots = bumper_bots_var.get() bots = bumper_bots_var.get()
existingbot = False existingbot = False

View file

@ -584,6 +584,8 @@ class ConfServer:
confserverlog.debug( confserverlog.debug(
"\r\n POST: {} \r\n Response: {}".format(postbody, body) "\r\n POST: {} \r\n Response: {}".format(postbody, body)
) )
return web.json_response(body) return web.json_response(body)
except Exception as e: except Exception as e:
@ -606,11 +608,11 @@ class ConfServer:
if todo == "FindBest": if todo == "FindBest":
service = postbody["service"] service = postbody["service"]
if service == "EcoMsgNew": if service == "EcoMsgNew":
body = { confserverlog.debug(
"result": "ok", "\r\n POST: {} \r\n Response: {}".format(postbody, body)
"ip": socket.gethostbyname(socket.gethostname()), )
"port": 5223, 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": elif service == "EcoUpdate":
body = {"result": "ok", "ip": "47.88.66.164", "port": 8005} body = {"result": "ok", "ip": "47.88.66.164", "port": 8005}

View file

@ -333,7 +333,7 @@ class BumperMQTTServer_Plugin:
): ):
tmpbotdetail = str(didsplit[1]).split("/") tmpbotdetail = str(didsplit[1]).split("/")
bumper.add_bot( bumper.add_bot(
username, didsplit[0], tmpbotdetail[0], tmpbotdetail[1] username, didsplit[0], tmpbotdetail[0], tmpbotdetail[1], "eco-ng"
) )
mqttserverlog.debug( mqttserverlog.debug(
"new bot authenticated SN: {} DID: {}".format( "new bot authenticated SN: {} DID: {}".format(

View file

@ -193,6 +193,7 @@ class Client(threading.Thread):
self.connection = connection self.connection = connection
self.address = client_address[0] self.address = client_address[0]
self.clientresource = "" self.clientresource = ""
self.devclass = ""
self.uid = "" self.uid = ""
self.log_sent_message = False # Set to true to log sends self.log_sent_message = False # Set to true to log sends
self.log_incoming_data = True # 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 # Client first connecting, send our features
if data.decode("utf-8").find("jabber:client") > -1: 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 # ack jabbr:client
# no STARTTLS # no STARTTLS
self.send( self.send(
@ -527,13 +532,19 @@ class Client(threading.Thread):
username = saslauth[0] username = saslauth[0]
username = saslauth[0].split("\x00")[1] username = saslauth[0].split("\x00")[1]
self.uid = username self.uid = username
resource = saslauth[1] if len(saslauth) > 1:
self.clientresource = resource resource = saslauth[1]
authcode = saslauth[2] 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"): if not self.uid.startswith("fuid"):
# Need sample data to see details here # 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)) xmppserverlog.info("bot authenticated {}".format(self.uid))
# Send response # Send response
self.send( self.send(