aboutsummaryrefslogtreecommitdiff
path: root/src/ext_distribution.cpp
diff options
context:
space:
mode:
authorOsmium Sorcerer <os@sof.beauty>2026-03-22 18:56:58 +0000
committerOsmium Sorcerer <os@sof.beauty>2026-03-29 22:22:25 +0000
commitd6352bc889638b82a887e0a1a138f2b8086dbbdb (patch)
tree35f7bb8b5b6641f69930bd8485260bc8594e5fe9 /src/ext_distribution.cpp
parenta124f46861d549ddc13485536962e34d80de939a (diff)
Handle extension packets using binary frames
The subprotocol shall use binary frames, and AO protocol stays separated within the text frames.
Diffstat (limited to 'src/ext_distribution.cpp')
-rw-r--r--src/ext_distribution.cpp51
1 files changed, 51 insertions, 0 deletions
diff --git a/src/ext_distribution.cpp b/src/ext_distribution.cpp
new file mode 100644
index 0000000..42f4156
--- /dev/null
+++ b/src/ext_distribution.cpp
@@ -0,0 +1,51 @@
+// Copyright 2026 Osmium Sorcerer
+// SPDX-License-Identifier: MIT
+
+#include "ext_packet.h"
+
+#include "aoapplication.h"
+#include "auth_flow.h"
+#include "courtroom.h"
+#include "networkmanager.h"
+
+#include <QHeaderView>
+#include <QVBoxLayout>
+
+static void handleAuthChallenge(QByteArrayView body, AOApplication *ao)
+{
+ if (ao->ex_auth_username.isEmpty())
+ {
+ // We're not authenticating, ignore.
+ return;
+ }
+
+ AuthChallenge challenge;
+ if (!parseAuthChallenge(body, challenge))
+ {
+ qWarning() << "Invalid AuthChallenge message";
+ return;
+ }
+
+ new AuthFlow(ao, challenge);
+}
+
+void AOApplication::ex_message_received(QByteArrayView message)
+{
+ ExMsgType type = (ExMsgType)message[0];
+ QByteArrayView body = message.sliced(1);
+ switch (type)
+ {
+ case ExMsgType::auth_challenge:
+ handleAuthChallenge(body, this);
+ break;
+ default:
+ qWarning() << "Unknown message type:" << (int)type;
+ break;
+ }
+}
+
+void AOApplication::send_ex_message(const QByteArray &msg)
+{
+ // Why indirection?
+ net_manager->ship_ex_message(msg);
+}