From 366c1cd93685759128a2e57d89291bb03512f5fd Mon Sep 17 00:00:00 2001 From: Edward Emelianov Date: Fri, 30 Oct 2020 16:03:05 +0300 Subject: [PATCH] fixed bug with websockets list; added
to pass/login --- netproto.c | 6 ++++-- static/auth.js | 4 +++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/netproto.c b/netproto.c index 22f3b00..ffdddb6 100644 --- a/netproto.c +++ b/netproto.c @@ -98,17 +98,18 @@ void register_WS(onion_websocket *ws){ void send_all_WS(char *data){ if(strlen(data) == 0) return; // zero length WSlist *l = wslist; + if(!l) return; int cnt = 0; unregister_WS(); // check for dead ws while(l){ - DBG("try to send"); + //DBG("try to send"); if(onion_websocket_printf(l->ws, "%s", data) <= 0){ // dead websocket? remove it from list DBG("Error printing - check for dead"); unregister_WS(); }else ++cnt; l = l->next; } - DBG("Send message %s to %d clients", data, cnt); + //DBG("Send message %s to %d clients", data, cnt); } void unregister_WS(){ @@ -128,6 +129,7 @@ void unregister_WS(){ wslist->last = l->prev; // we should delete last element } WSlist *nxt = l->next; + if(l == wslist) wslist = nxt; // delete the first element FREE(l); l = nxt; continue; diff --git a/static/auth.js b/static/auth.js index 6bec214..794889f 100644 --- a/static/auth.js +++ b/static/auth.js @@ -43,7 +43,9 @@ auth = function(){ s.type = 'text/css'; s.innerHTML = '.shadow{position:absolute;text-align:center;vertical-align:center;top:0;display:none;left:0;width:100%;height:100%;background-color:lightGrey;opacity:0.9;}'; document.body.appendChild(s); - d.innerHTML = "
Login:
Password:
"; + d.innerHTML = "
Login:
" + + "
Password:
" + + "
"; d.className = "shadow"; document.body.appendChild(d); }