From ab86a1f0c3b86050e65fc5b7ac1e88a00f0d228c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Smr=C5=BE?= Date: Mon, 27 Jan 2020 21:25:39 +0100 Subject: Encrypted channels --- src/network.h | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) (limited to 'src/network.h') diff --git a/src/network.h b/src/network.h index bb32323..e07e020 100644 --- a/src/network.h +++ b/src/network.h @@ -2,6 +2,8 @@ #include +#include "channel.h" + #include #include #include @@ -26,23 +28,30 @@ using chrono::steady_clock; namespace erebos { -struct Peer +struct Server::Peer { Peer(const Peer &) = delete; Peer & operator=(const Peer &) = delete; - const int sock; + Priv & server; const sockaddr_in addr; variant, Identity> identity; + variant, + shared_ptr, + Stored, + Stored> channel; + Storage tempStorage; PartialStorage partStorage; void send(const struct TransportHeader &, const vector &) const; - void updateIdentity(); + void updateIdentity(struct ReplyBuilder &); + void updateChannel(struct ReplyBuilder &); }; struct TransportHeader @@ -76,12 +85,18 @@ struct WaitingRef { const Storage storage; const PartialRef ref; - const Peer & peer; + const Server::Peer & peer; vector missing; optional check(vector * request = nullptr); }; +struct ReplyBuilder +{ + vector header; + vector body; +}; + struct Server::Priv { Priv(const Identity & self); @@ -90,7 +105,7 @@ struct Server::Priv void doAnnounce(); Peer & getPeer(const sockaddr_in & paddr); - void handlePacket(Peer &, const TransportHeader &); + void handlePacket(Peer &, const TransportHeader &, ReplyBuilder &); constexpr static uint16_t discoveryPort { 29665 }; constexpr static chrono::seconds announceInterval { 60 }; -- cgit v1.2.3