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