summaryrefslogtreecommitdiff
path: root/src/network.cpp
diff options
context:
space:
mode:
authorRoman Smrž <roman.smrz@seznam.cz>2023-08-27 21:52:29 +0200
committerRoman Smrž <roman.smrz@seznam.cz>2023-08-30 20:30:51 +0200
commitd0c48bf9b90dfbd55908a88a5aba411ca9b8e600 (patch)
tree7b23ed2b7159f7a96e4f9d34a06009f4581de9bc /src/network.cpp
parent3407f97096fd66aeb25f1cd26ba002d3f8a23127 (diff)
Network: connection initiation with cookie
Diffstat (limited to 'src/network.cpp')
-rw-r--r--src/network.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/network.cpp b/src/network.cpp
index a3d1130..da480c3 100644
--- a/src/network.cpp
+++ b/src/network.cpp
@@ -221,7 +221,7 @@ bool Peer::send(UUID uuid, const Ref & ref, const Object & obj) const
NetworkProtocol::Header::ServiceType { uuid },
NetworkProtocol::Header::ServiceRef { ref.digest() },
});
- speer->connection.send(speer->partStorage, header, { obj }, true);
+ speer->connection.send(speer->partStorage, move(header), { obj }, true);
return true;
}
@@ -363,6 +363,11 @@ void Server::Priv::doListen()
if (holds_alternative<NetworkProtocol::ProtocolClosed>(res))
break;
+ if (const auto * ann = get_if<NetworkProtocol::ReceivedAnnounce>(&res)) {
+ if (not isSelfAddress(ann->addr))
+ getPeer(ann->addr);
+ }
+
if (holds_alternative<NetworkProtocol::NewConnection>(res)) {
auto & conn = get<NetworkProtocol::NewConnection>(res).conn;
if (not isSelfAddress(conn.peerAddress()))
@@ -693,7 +698,8 @@ void Server::Peer::updateChannel(ReplyBuilder & reply)
if (!holds_alternative<Identity>(identity))
return;
- if (holds_alternative<monostate>(connection.channel())) {
+ if (holds_alternative<monostate>(connection.channel()) ||
+ holds_alternative<NetworkProtocol::Cookie>(connection.channel())) {
auto req = Channel::generateRequest(tempStorage,
server.self, std::get<Identity>(identity));
connection.channel().emplace<Stored<ChannelRequest>>(req);