cleanup SSL handling

This commit is contained in:
2021-06-20 13:40:49 -04:00
parent 3fc70da932
commit b0e93fb295
+33 -33
View File
@@ -81,18 +81,18 @@ lastfm=["","",""]
tcss = """<script src="https://home.wrede.ca/pr/sorttable.js"></script>
<style>
#ntable {
border-collapse: collapse;
border-collapse: collapse;
}
#wide-ntable {
border-collapse: collapse;
width: 100%;
border-collapse: collapse;
width: 100%;
}
#ntable td, #ntable th {
border: 1px solid #ddd;
text-align: left;
padding: 1px;
border: 1px solid #ddd;
text-align: left;
padding: 1px;
}
#ntable tr:nth-child(even){background-color: #f2f2f2}
@@ -100,10 +100,10 @@ tcss = """<script src="https://home.wrede.ca/pr/sorttable.js"></script>
#ntable tr:hover {background-color: #ddd;}
#ntable th {
padding-top: 12px;
padding-bottom: 12px;
background-color: #9d9d9d;
color: white;
padding-top: 12px;
padding-bottom: 12px;
background-color: #9d9d9d;
color: white;
}
</style> """
@@ -268,25 +268,25 @@ RECIPIENT = "+14168226179"
def pushsignal(msg, title="hbd", recipient=RECIPIENT):
message = f'"{title}: {msg}"'
CLI = [
"/usr/bin/ssh", "andreas@w02",
"/usr/local/bin/signal-cli", "-u", USER,
"send", "-m", message,
# "-g", GROUP,
recipient,
]
message = f'"{title}: {msg}"'
CLI = [
"/usr/bin/ssh", "andreas@w02",
"/usr/local/bin/signal-cli", "-u", USER,
"send", "-m", message,
# "-g", GROUP,
recipient,
]
if verbose: print(f"DBG cli: {CLI}")
res = subprocess.run(CLI, shell=False, capture_output=True)
rc = res.returncode == 0
print(res.stdout.decode())
if verbose: print(f"DBG cli: {CLI}")
res = subprocess.run(CLI, shell=False, capture_output=True)
rc = res.returncode == 0
print(res.stdout.decode())
if not rc:
print(f"signalcli failed: {res.stderr.decode()}")
else:
if verbose: print(f"signalcli msg sent, res {res.stdout.decode()}")
return rc
if not rc:
print(f"signalcli failed: {res.stderr.decode()}")
else:
if verbose: print(f"signalcli msg sent, res {res.stdout.decode()}")
return rc
# nsupdate: set the DNS A record for a fqdn
@@ -855,22 +855,22 @@ async def ws_serve(websocket, path):
except (
websockets.exceptions.ConnectionClosedOK,
websockets.exceptions.ConnectionClosedError) as e:
print(f'ws closed: {e}')
if verbose: print(f'ws closed: {e}')
break
print(f"< {name} at {path}")
if verbose: print(f"initial {name} at {path}")
# send initial set of hosts and messages
# hosts in sorted order
for h in sorted(hbdclass.Host.hosts):
jmsg = json.dumps({'type': 'host', 'data': hbdclass.Host.hosts[h].stateinfo() })
await websocket.send(jmsg)
# messages in reverse order
for m in msgs[len(msgs)-20:]:
jmsg = json.dumps({'type': 'message', 'data': m })
await websocket.send(jmsg)
if verbose: print(f"DBG ws_serve: close {remote_address}")
await websocket.wait_closed()
# try:
# del ws_connections[websocket]
# except Exception as e:
# print(f"warning: failed to delete websocket: {e}")
def websocketupdater():
loop.run_forever()