From cf7f92451f527edb45bf001dc93daee3f621e0eb Mon Sep 17 00:00:00 2001 From: Doug Hoyte Date: Fri, 20 Jan 2023 14:17:00 -0500 Subject: [PATCH] log connection compression status, bugfix --- src/RelayWebsocket.cpp | 11 +++++++++-- src/WriterPipeline.h | 2 +- src/events.h | 2 ++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/RelayWebsocket.cpp b/src/RelayWebsocket.cpp index 729d166..c67e90d 100644 --- a/src/RelayWebsocket.cpp +++ b/src/RelayWebsocket.cpp @@ -46,7 +46,7 @@ static std::string renderSize(uint64_t si) { unit = 'T'; } while(0); - ::snprintf(buf, sizeof(buf), "%.2f %c", s, unit); + ::snprintf(buf, sizeof(buf), "%.2f%c", s, unit); return std::string(buf); } @@ -125,7 +125,14 @@ void RelayServer::runWebsocket(ThreadPool::Thread &thr) { hubGroup->onConnection([&](uWS::WebSocket *ws, uWS::HttpRequest req) { std::string addr = ws->getAddress().address; uint64_t connId = nextConnectionId++; - LI << "[" << connId << "] Connect from " << addr; + + bool compEnabled, compSlidingWindow; + ws->getCompressionState(compEnabled, compSlidingWindow); + LI << "[" << connId << "] Connect from " << addr + << " compression=" << (compEnabled ? 'Y' : 'N') + << " sliding=" << (compSlidingWindow ? 'Y' : 'N') + ; + Connection *c = new Connection(ws, connId); c->ipAddr = addr; ws->setUserData((void*)c); diff --git a/src/WriterPipeline.h b/src/WriterPipeline.h index 85a81fa..de82c7f 100644 --- a/src/WriterPipeline.h +++ b/src/WriterPipeline.h @@ -29,7 +29,7 @@ struct WriterPipeline { for (auto &m : msgs) { if (m.is_null()) { - writerInbox.push_move({ "", "", 0 }); + writerInbox.push_move({}); break; } diff --git a/src/events.h b/src/events.h index 70d208e..8d73531 100644 --- a/src/events.h +++ b/src/events.h @@ -75,6 +75,8 @@ struct EventToWrite { uint64_t nodeId = 0; EventWriteStatus status = EventWriteStatus::Pending; + EventToWrite() {} + EventToWrite(std::string flatStr, std::string jsonStr, uint64_t receivedAt, void *userData = nullptr) : flatStr(flatStr), jsonStr(jsonStr), receivedAt(receivedAt), userData(userData) { const NostrIndex::Event *flat = flatbuffers::GetRoot(flatStr.data()); quadKey = flatEventToQuadrableKey(flat);