Compare commits
3 Commits
0cd8bd2b72
...
62355023fa
Author | SHA1 | Date | |
---|---|---|---|
62355023fa | |||
b13fbf536f | |||
682c0116dd |
|
@ -1,22 +0,0 @@
|
||||||
-----BEGIN CERTIFICATE-----
|
|
||||||
MIIDjjCCAnYCFFfe134gzLKm3ieNbeoxCvOhwsGwMA0GCSqGSIb3DQEBCwUAMIGE
|
|
||||||
MQswCQYDVQQGEwJVUzELMAkGA1UECAwCTlkxETAPBgNVBAcMCE5ldyBZb3JrMRUw
|
|
||||||
EwYDVQQKDAxFeGFtcGxlIEluYy4xHDAaBgNVBAMME2NhLm1xdHQuZXhhbXBsZS5j
|
|
||||||
b20xIDAeBgkqhkiG9w0BCQEWEWFkbWluQGV4YW1wbGUuY29tMB4XDTIwMTAwNjEx
|
|
||||||
MDE1M1oXDTMwMTAwNDExMDE1M1owgYExCzAJBgNVBAYTAlVTMQswCQYDVQQIDAJO
|
|
||||||
WTERMA8GA1UEBwwITmV3IFlvcmsxFTATBgNVBAoMDEV4YW1wbGUgSW5jLjEZMBcG
|
|
||||||
A1UEAwwQbXF0dC5leGFtcGxlLmNvbTEgMB4GCSqGSIb3DQEJARYRYWRtaW5AZXhh
|
|
||||||
bXBsZS5jb20wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC8/EqoeDGr
|
|
||||||
42rM2rkEhV8Qrv8aihCKurDcE+e8OXM5GTSP+1NomatGXLWAfF6PY5N8sA3NxlRG
|
|
||||||
gnPhpX9O+NrCMrSHZIfBoU+6GwcPBrn1zD9Le1kRDYZhOQ4Ofj5atxUwePqZo2rx
|
|
||||||
F+BK7D1+GEi1nFiVRmPOVNGI3J96i0KlC4EsVG9aNPwDRpnRB/rP/dersgpu4oFV
|
|
||||||
xUKx2n09vEEKVBwaT6oYilwoM8mw5Q0YBKIolQGIErYj9oFqimXH1e9Wit+551tr
|
|
||||||
T8+ipDhJW8a/CdlbV/8HFLg62542X5sXusTePhPUgU6StRxENf/2Q2ppVQAWgnQo
|
|
||||||
EkWKrVNNJNdbAgMBAAEwDQYJKoZIhvcNAQELBQADggEBAAOowXrxWHpjtrfdkpwG
|
|
||||||
gG4HJD79gkIHYjnXYKaH/RrmlEwdDnjG6OQHsXc9eKAJ1WHaJBUz1fwNCFz3E0Ry
|
|
||||||
cUTATZIBBXlqxZhbZXdBjQslEIvgjlkEcO29iJ5N3aTH92iuGrXgYYZl+c1d0RGo
|
|
||||||
1bXkj7G5AFRGBFGY7PPIjtMmTYE7DB4bZ7HcxYbmXC7IqLXQoUN2A2ITuAdUcK2T
|
|
||||||
5pMZzkQGpUiHFIR3NUiDf2jYx7YTTt16I73TVlXHtb0qzo5oNLZKeogrKWlpb6uy
|
|
||||||
71wRdbgTtRpbdMDu+D65G5aZYVN36a223K7xiR5b75V6PeFgPQXhkLSJjCBBapct
|
|
||||||
mEo=
|
|
||||||
-----END CERTIFICATE-----
|
|
|
@ -1,27 +0,0 @@
|
||||||
-----BEGIN RSA PRIVATE KEY-----
|
|
||||||
MIIEpAIBAAKCAQEAvPxKqHgxq+NqzNq5BIVfEK7/GooQirqw3BPnvDlzORk0j/tT
|
|
||||||
aJmrRly1gHxej2OTfLANzcZURoJz4aV/TvjawjK0h2SHwaFPuhsHDwa59cw/S3tZ
|
|
||||||
EQ2GYTkODn4+WrcVMHj6maNq8RfgSuw9fhhItZxYlUZjzlTRiNyfeotCpQuBLFRv
|
|
||||||
WjT8A0aZ0Qf6z/3Xq7IKbuKBVcVCsdp9PbxBClQcGk+qGIpcKDPJsOUNGASiKJUB
|
|
||||||
iBK2I/aBaoplx9XvVorfuedba0/PoqQ4SVvGvwnZW1f/BxS4OtueNl+bF7rE3j4T
|
|
||||||
1IFOkrUcRDX/9kNqaVUAFoJ0KBJFiq1TTSTXWwIDAQABAoIBAGm/wwcCOsk0OE7p
|
|
||||||
FR6ygr+TLKxtFVSLouuDN+jbPN52fDMVL1cYpf55YhbDgSY7Ugwzd4XttLq/xJg/
|
|
||||||
Qz2tgruoI9y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
|
||||||
Tb0q8wKBgQCh61d7FfhtUbKQbd8lQMrxXUDDd8tP9NkmZJ0y1Qg10s5Pl80wZo6H
|
|
||||||
3PS0ivyxDWBygcxrHOFV26kfMiBrPNtA3HY5ZWFAq1JZ7Yajseg83KSbli6V/+dE
|
|
||||||
BekdMwQk9MrLELEc1IgqgZU46yrRcKB+6Zh5MJM3bH3qzWpVCXIKCw==
|
|
||||||
-----END RSA PRIVATE KEY-----
|
|
|
@ -1,21 +0,0 @@
|
||||||
-----BEGIN CERTIFICATE-----
|
|
||||||
MIIDhzCCAm8CFFfe134gzLKm3ieNbeoxCvOhwsGyMA0GCSqGSIb3DQEBCwUAMIGE
|
|
||||||
MQswCQYDVQQGEwJVUzELMAkGA1UECAwCTlkxETAPBgNVBAcMCE5ldyBZb3JrMRUw
|
|
||||||
EwYDVQQKDAxFeGFtcGxlIEluYy4xHDAaBgNVBAMME2NhLm1xdHQuZXhhbXBsZS5j
|
|
||||||
b20xIDAeBgkqhkiG9w0BCQEWEWFkbWluQGV4YW1wbGUuY29tMB4XDTIwMTAwNjEx
|
|
||||||
MDYwM1oXDTMwMTAwNDExMDYwM1owezELMAkGA1UEBhMCVVMxCzAJBgNVBAgMAk5Z
|
|
||||||
MREwDwYDVQQHDAhOZXcgWW9yazEVMBMGA1UECgwMRXhhbXBsZSBJbmMuMRMwEQYD
|
|
||||||
VQQDDApzdWJzY3JpYmVyMSAwHgYJKoZIhvcNAQkBFhFhZG1pbkBleGFtcGxlLmNv
|
|
||||||
bTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAPuE9XvVpmvnFAj2ZCMv
|
|
||||||
UWpE4yea69f4XtZ64Bw+Kp2B9NF+1lU7OTpnP+1Xubx7GX2Fy4E7w+jKwrC4+R+Z
|
|
||||||
qtZh9UCLj7IEin6NoaKgLSXd75A9UFZbI9Vug7VSxm581J8qDzVNnflTwRBPvnC6
|
|
||||||
1B1noXZRZGUbVjtC7ciIJ33bHktlTBbVvZwdZIB0upXe3iDeXE8I1izU+FB0EbCr
|
|
||||||
gmneo3mPW/5IPDGGJy1YI9HNa/h3gnZ5uomQ2/rhUB46Zr2+9/bGQHknIBMISWx6
|
|
||||||
UR0FlkdCu4ezm377IjBATBXaEoqoWfyRSuLDgkAAiHbtp+IQpIL+soOczMjUhvhg
|
|
||||||
FyECAwEAATANBgkqhkiG9w0BAQsFAAOCAQEACFy4ioFB5jeW+vMrTGfcwbq0qFW4
|
|
||||||
9zupWVKG4H+l4N/bjiwTpKy8oP7STBS94BbA6fYE8Y+Jcibas1zX78HFIk/A9Dh1
|
|
||||||
q9lysu7Biv4JbaXVPHxy9SzadUPym3bYAJtVRWsC1N2siI1NlalttDU1y+RnllUL
|
|
||||||
jixHf2/EghYgJydN7yoTWD7rbGD2GB4ADhohhMx5NL3h/7wge4qhvBIVEoa093hV
|
|
||||||
0rzctNrP0bDsZIei3RV6mat6teR4MUK7PQSmiwTPoFmbNB+T+sl/hT22B7utooQT
|
|
||||||
h5H39zpLiorQEUMF7qJff/7+KXs7YUGUFyAQyGnxhMhAQ7zWrkrR50sFwg==
|
|
||||||
-----END CERTIFICATE-----
|
|
|
@ -1,27 +0,0 @@
|
||||||
-----BEGIN RSA PRIVATE KEY-----
|
|
||||||
MIIEpQIBAAKCAQEA+4T1e9Wma+cUCPZkIy9RakTjJ5rr1/he1nrgHD4qnYH00X7W
|
|
||||||
VTs5Omc/7Ve5vHsZfYXLgTvD6MrCsLj5H5mq1mH1QIuPsgSKfo2hoqAtJd3vkD1Q
|
|
||||||
Vlsj1W6DtVLGbnzUnyoPNU2d+VPBEE++cLrUHWehdlFkZRtWO0LtyIgnfdseS2VM
|
|
||||||
FtW9nB1kgHS6ld7eIN5cTwjWLNT4UHQRsKuCad6jeY9b/kg8MYYnLVgj0c1r+HeC
|
|
||||||
dnm6iZDb+uFQHjpmvb739sZAeScgEwhJbHpRHQWWR0K7h7ObfvsiMEBMFdoSiqhZ
|
|
||||||
/JFK4sOCQACIdu2n4hCk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||||||
rFlUsJBY+6iOxaTT+s31fw5nNsxtsTmCXD7WyjWznquv1n0oaQ4dKIhp4+ymIsyk
|
|
||||||
TY32afYNgQbiJByBm1Rdu2QYQo9epXwgZvftuGdA4yTddGOaQeist7oBLUyNmP6h
|
|
||||||
UKBcw4MCgYEArWhvqZUvklgmTJi8bSyJaCuZrd7l4HxoajceQ7ujyl/N2zX+HAio
|
|
||||||
8uw46NUvsiyIk3OCI/59G5BrBtOIYq5KUTNhDdz6q0HMz1MSDRCH5Zt0Cokam+jX
|
|
||||||
j7QGOQnhTHkGv8Mabo6gmLPifPuYboFzivFGMJH8ur+38YOyGxbwvqI=
|
|
||||||
-----END RSA PRIVATE KEY-----
|
|
|
@ -1,21 +0,0 @@
|
||||||
-----BEGIN CERTIFICATE-----
|
|
||||||
MIIDhDCCAmwCFFfe134gzLKm3ieNbeoxCvOhwsGxMA0GCSqGSIb3DQEBCwUAMIGE
|
|
||||||
MQswCQYDVQQGEwJVUzELMAkGA1UECAwCTlkxETAPBgNVBAcMCE5ldyBZb3JrMRUw
|
|
||||||
EwYDVQQKDAxFeGFtcGxlIEluYy4xHDAaBgNVBAMME2NhLm1xdHQuZXhhbXBsZS5j
|
|
||||||
b20xIDAeBgkqhkiG9w0BCQEWEWFkbWluQGV4YW1wbGUuY29tMB4XDTIwMTAwNjEx
|
|
||||||
MDQxMVoXDTMwMTAwNDExMDQxMVoweDELMAkGA1UEBhMCVVMxCzAJBgNVBAgMAk5Z
|
|
||||||
MREwDwYDVQQHDAhOZXcgWW9yazEVMBMGA1UECgwMRXhhbXBsZSBJbmMuMRAwDgYD
|
|
||||||
VQQDDAd2YWdyYW50MSAwHgYJKoZIhvcNAQkBFhFhZG1pbkBleGFtcGxlLmNvbTCC
|
|
||||||
ASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALBR3WYBUoSM9taDBWn8MSU3
|
|
||||||
WW7z9EmutaWRKlNCf8rAVXrEGf3shtBb6MWdRjAKHcBDZaTtmW6o0XoXkKdGeWcm
|
|
||||||
6X0o4TwaROPE7HR8OtKsmPTxQ09gKfkwB+sb8+fIPrKq6VLWiSJqvc6RbZvoKXIa
|
|
||||||
WU/BV4q3HG9MvFB2AMNx9pmzLeeP/m323pAEU28oR/kGvuDJHSLO3cNd1U5ZKFFt
|
|
||||||
J1hHYugKM3uHlyQ44ozu6l2AexGgIYjA5/y1D/RuWaybdpppLS3RerhKDrvTkwWD
|
|
||||||
UALgTdxHnIT90NFCtGsZTzwmbqs/ibq1NtkHGiS0tGhJjftIiPJZfuNArVsoYF0C
|
|
||||||
AwEAATANBgkqhkiG9w0BAQsFAAOCAQEAeOEgOA8dJZGo/bT+2vnKm7VnJYrNgAax
|
|
||||||
B/X2kG3vLiayFgPYarQq8AjlqQCr8Dm1EqbUtnAhzSbQTX+v3oQBd7sRdlwfTYKa
|
|
||||||
bFEjhMeXhBgp/bWobq9FcwAL02wsAZh/gcbHAVrIwWmb42sbHTmrWY2jgJbX65jg
|
|
||||||
ameIn9p1j2CSJnC4Ju3B+btaCmksHI6uhuJVef/+pL53hs1z5MfehNvJaBkUzsya
|
|
||||||
nYAiCvrEQIzKlxROdBApZeQs0WFv0ktu6itzA3YsCMct1p3TNGwDUZ+cQqkTPhkB
|
|
||||||
KNT0VcmDNdavD59WsEfrgZe5/DXY+Q1yHzGmaq70y0U6SgTfOsslmQ==
|
|
||||||
-----END CERTIFICATE-----
|
|
|
@ -1,27 +0,0 @@
|
||||||
-----BEGIN RSA PRIVATE KEY-----
|
|
||||||
MIIEpAIBAAKCAQEAsFHdZgFShIz21oMFafwxJTdZbvP0Sa61pZEqU0J/ysBVesQZ
|
|
||||||
/eyG0FvoxZ1GMAodwENlpO2ZbqjReheQp0Z5ZybpfSjhPBpE48TsdHw60qyY9PFD
|
|
||||||
T2Ap+TAH6xvz58g+sqrpUtaJImq9zpFtm+gpchpZT8FXirccb0y8UHYAw3H2mbMt
|
|
||||||
54/+bfbekARTbyhH+Qa+4MkdIs7dw13VTlkoU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cMEf5nif7CxWaklvleIOJOq9mq9hvRDiGUSaoJJHXZUioAxLUNDoqdbKFG24a
|
|
||||||
8ZENBSGDzzACBF11v/TGP0ECgYEAp+WCeOUo4jaBlGx2RIMRaNPTXpZ+u5T0SDm1
|
|
||||||
5XMvKkCIH7LT8ANe3ysppM/zO+1nnl+l3i2C/Dg7QUZbt0A5f0JdXTGa9IStx8n6
|
|
||||||
KTd7arDRMB67jr+86/YJJwMkfAuGl5zd4jDRC6Qrbzzkjq2mHLOuDpuOUPufSl/9
|
|
||||||
O6Im5GkCgYA4zFE3ztSV6nq5EH3A7VmAsLiyRXBJfOlLXIBApv46/t4ivS4C3Esu
|
|
||||||
8LR+Vvx2XLWkpkrm9kR1wIutNx6x1pRkSGDKyRXn5+cU4A2Lw9y2BbwDhj+WiHkM
|
|
||||||
zCuL+8l2px2f3K1YPE3oGWHZZJScDwa03yjVzrSPDr766XBtH7W4vg==
|
|
||||||
-----END RSA PRIVATE KEY-----
|
|
|
@ -55,13 +55,13 @@ def publish(client_id, onion_hostname, use_tls=True):
|
||||||
|
|
||||||
class GivenBroker(TestCase):
|
class GivenBroker(TestCase):
|
||||||
def setUp(self) -> None:
|
def setUp(self) -> None:
|
||||||
if os.path.exists(torch_sub.database_file):
|
if os.path.exists(torch_sub.database_filename):
|
||||||
os.remove(torch_sub.database_file)
|
os.remove(torch_sub.database_filename)
|
||||||
|
|
||||||
def tearDown(self) -> None:
|
def tearDown(self) -> None:
|
||||||
os.system("docker container stop mosquitto")
|
os.system("docker container stop mosquitto")
|
||||||
if os.path.exists(torch_sub.database_file):
|
if os.path.exists(torch_sub.database_filename):
|
||||||
os.remove(torch_sub.database_file)
|
os.remove(torch_sub.database_filename)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def run_broker(tls):
|
def run_broker(tls):
|
||||||
|
@ -95,7 +95,7 @@ class GivenBroker(TestCase):
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def loadDatabase():
|
def loadDatabase():
|
||||||
with open(torch_sub.database_file, "r") as database_file:
|
with open(torch_sub.database_filename, "r") as database_file:
|
||||||
return json.load(database_file)
|
return json.load(database_file)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,29 +1,34 @@
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
|
import threading
|
||||||
|
|
||||||
import paho.mqtt.subscribe as mqtt
|
import paho.mqtt.subscribe as mqtt
|
||||||
|
|
||||||
database_file = "clients.json"
|
database_filename = "clients.json"
|
||||||
|
database_lock = threading.Lock()
|
||||||
|
|
||||||
# noinspection PyUnusedLocal
|
# noinspection PyUnusedLocal
|
||||||
def update_client_record(client, userdata, message):
|
def update_client_record(client, userdata, message):
|
||||||
|
|
||||||
if not os.path.exists(database_file):
|
database_lock.acquire()
|
||||||
with open(database_file, 'w') as database_blank:
|
|
||||||
database_blank.write("{}")
|
|
||||||
|
|
||||||
with open(database_file, 'r') as infile:
|
if not os.path.exists(database_filename):
|
||||||
database = json.loads(infile.read())
|
with open(database_filename, 'w') as database_blank:
|
||||||
|
json.dump({}, database_blank)
|
||||||
|
|
||||||
|
with open(database_filename, 'r') as infile:
|
||||||
|
database = json.load(infile)
|
||||||
|
|
||||||
payload = message.payload.decode('utf-8')
|
payload = message.payload.decode('utf-8')
|
||||||
response = json.loads(payload)
|
response = json.loads(payload)
|
||||||
|
|
||||||
database[response['clientId']] = response
|
database[response['clientId']] = response
|
||||||
|
|
||||||
with open(database_file, 'w') as outfile:
|
with open(database_filename, 'w') as outfile:
|
||||||
json.dump(database, outfile)
|
json.dump(database, outfile)
|
||||||
|
|
||||||
|
database_lock.release()
|
||||||
|
|
||||||
|
|
||||||
def subscribe(broker_hostname, broker_port, topic="torch", tls=None, auth=None):
|
def subscribe(broker_hostname, broker_port, topic="torch", tls=None, auth=None):
|
||||||
mqtt.callback(update_client_record,
|
mqtt.callback(update_client_record,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user