ozmo xmpp authentication

ozmo auths and shows up in the app
This commit is contained in:
Brian Martin 2019-02-24 02:29:40 -05:00
parent 95b4b05633
commit e97b28a5c8
4 changed files with 27 additions and 13 deletions

View file

@ -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

View file

@ -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,11 +608,11 @@ 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}

View file

@ -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(

View file

@ -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(