1 parent
d146f11f02
commit
5c036d91fb
72 files changed
+5875
-1243
No files matched your search
@@ -13,6 +13,7 @@
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <optional>
|
||||
#include <set>
|
||||
#include <thread>
|
||||
#include <unordered_map>
|
||||
@@ -53,6 +54,13 @@ namespace Echoion::Core
|
||||
void removeAuthenticatedClient(uint64_t clientId);
|
||||
[[nodiscard]] bool isClientAuthenticated(uint64_t clientId);
|
||||
|
||||
// The client's effective network address: the X-Echoion-Client-Ip
|
||||
// header set by the web server's /rpc bridge (trusted only from
|
||||
// loopback peers), else the socket's remote address. Used for
|
||||
// address-based autologin.
|
||||
[[nodiscard]] std::optional<std::string>
|
||||
getClientAddress(uint64_t clientId) const;
|
||||
|
||||
// Server introspection (for GetServerInfo / GetAuditLog).
|
||||
struct AuditEntry {
|
||||
uint64_t clientId = 0;
|
||||
@@ -74,6 +82,8 @@ namespace Echoion::Core
|
||||
private:
|
||||
|
||||
void acceptLoop();
|
||||
void doAccept();
|
||||
void onAccept(asio::ip::tcp::socket socket);
|
||||
void handleClient(
|
||||
std::shared_ptr<websocket::stream<asio::ip::tcp::socket>> ws);
|
||||
void processMessage(uint64_t clientId, const std::string& message);
|
||||
@@ -93,6 +103,8 @@ namespace Echoion::Core
|
||||
uint64_t,
|
||||
std::shared_ptr<websocket::stream<asio::ip::tcp::socket>>>
|
||||
clients_;
|
||||
// clientId -> effective network address (see getClientAddress).
|
||||
std::unordered_map<uint64_t, std::string> clientAddresses_;
|
||||
mutable std::mutex clientsMutex_;
|
||||
std::atomic<uint64_t> nextClientId_{1};
|
||||
|
||||
|
||||
Reference in new issue
Block a user