diff --git a/docs/proto_v0.txt b/docs/proto_v0.txt index fdd47e405..3a50e4acc 100644 --- a/docs/proto_v0.txt +++ b/docs/proto_v0.txt @@ -431,69 +431,60 @@ transfer one or more dht messages directly without a previously made path. } -link immediate SML message (LISM) +link immediate state message (LISM) -transfer an SML message between nodes +transfer a state message between nodes { a: "s", - s: SMLMessage, + s: state_message, v: 0 } ----- +--- -Stateles Mesh Layer (SML) +state message: -As a censor circumvention method layer 4 (udp) or layer 2 (ethernet) -network bridges are used to stateless route messages to the main onion -routing network in a stateless manner such that these network bridges -can be cacsaded many layers deep. The incentive to run these would be -the ability to hide your traffic shape in the shape of others without -the need to excess node churn. - -stateless mesh discovery protocol (SMDP) - -protocol for detecting and discovering mesh local -topology and where the mainline network is. - -TODO: implement me - -stateless mesh layer (SML) - -similar to link layer messeages but sent over the connectivity mesh layer that -uses ethernet. - -SML messages MUST be contained inside a LISM when not over ethernet. - -SML message MUST be routed to the recipiant if we are not the recipiant based -on the currently unspecified stateless routing protocol. - -TODO: implement routing protocol :^) +service node joined network { - a: protocol_id_uint16, - r: "<32 bytes public identity key of recipiant>", - s: "<32 bytes public identity key of sender>", - t: "<1280 bytes payload>", - v: 0, - z: "<64 bytes signature generated by sender>" + A: "J", + R: "<32 bytes public key>", + V: 0 } -protocol values: +service node parted network -0 - mesh discovery -t is a SMDP frame (todo: specify me) +{ + A: "P", + R: "<32 bytes public key>", + V: 0 +} -1 - direct chat -t is a NUL padded plaintext chat message for node opers to communicate between -nodes. +service node list request -2 - relayed data packet -t is a udp packet relayed from a client behind a client. +request the service node list starting at index O containing R entries -3 - snode to snode direct ip traffic -t is an ip packet for "0 hop" direct ip traffic between service nodes +{ + A: "R", + O: starting_offset_int, + R: number_of_entires_to_request_int, + V: 0 +} + +service node list response + +response to service node list request + +{ + A: "L", + S: { + "<32 bytes pubkey>" : first_seen_time_uint64, + "<32 bytes pubkey>" : first_seen_time_uint64, + .... + }, + V: 0 +} --- diff --git a/llarp/dht/context.cpp b/llarp/dht/context.cpp index 590fe87ed..c9ef6cf11 100644 --- a/llarp/dht/context.cpp +++ b/llarp/dht/context.cpp @@ -18,6 +18,7 @@ #include #include #include +#include #include @@ -207,6 +208,12 @@ namespace llarp return router; } + bool + GetRCFromNodeDB(const Key_t& k, llarp::RouterContact& rc) const override + { + return router->nodedb()->Get(k.as_array(), rc); + } + PendingIntrosetLookups _pendingIntrosetLookups; PendingTagLookups _pendingTagLookups; PendingRouterLookups _pendingRouterLookups; diff --git a/llarp/dht/context.hpp b/llarp/dht/context.hpp index 9977ee3b3..148496bf0 100644 --- a/llarp/dht/context.hpp +++ b/llarp/dht/context.hpp @@ -130,6 +130,9 @@ namespace llarp virtual llarp::AbstractRouter* GetRouter() const = 0; + virtual bool + GetRCFromNodeDB(const Key_t& k, llarp::RouterContact& rc) const = 0; + virtual const Key_t& OurKey() const = 0; diff --git a/llarp/dht/messages/findrouter.cpp b/llarp/dht/messages/findrouter.cpp index d749cecad..bd6785501 100644 --- a/llarp/dht/messages/findrouter.cpp +++ b/llarp/dht/messages/findrouter.cpp @@ -167,7 +167,7 @@ namespace llarp replies.emplace_back(new GotRouterMessage(k, txid, {found}, false)); return true; } - else if(dht.GetRouter()->nodedb()->Get(K, found)) + else if(dht.GetRCFromNodeDB(k, found)) { replies.emplace_back(new GotRouterMessage(k, txid, {found}, false)); return true; diff --git a/llarp/dht/serviceaddresslookup.cpp b/llarp/dht/serviceaddresslookup.cpp index 4421c0e29..9eb8b7f30 100644 --- a/llarp/dht/serviceaddresslookup.cpp +++ b/llarp/dht/serviceaddresslookup.cpp @@ -39,8 +39,8 @@ namespace llarp ServiceAddressLookup::GetNextPeer(Key_t &next, const std::set< Key_t > &exclude) { - Key_t k = target.ToKey(); - auto nodes = parent->Nodes(); + Key_t k = target.ToKey(); + const auto &nodes = parent->Nodes(); if(nodes) { return nodes->FindCloseExcluding(k, next, exclude); diff --git a/llarp/dht/txholder.hpp b/llarp/dht/txholder.hpp index 8420b63e6..f537e4f5b 100644 --- a/llarp/dht/txholder.hpp +++ b/llarp/dht/txholder.hpp @@ -140,21 +140,15 @@ namespace llarp TXHolder< K, V, K_Hash, requestTimeoutMS >::NotFound( const TXOwner& from, const std::unique_ptr< Key_t >& next) { - bool sendReply = true; - auto txitr = tx.find(from); + auto txitr = tx.find(from); if(txitr == tx.end()) { return; } // ask for next peer - if(txitr->second->AskNextPeer(from.node, next)) - { - sendReply = false; - } - - llarp::LogWarn("Target key ", txitr->second->target); - Inform(from, txitr->second->target, {}, sendReply, sendReply); + if(!txitr->second->AskNextPeer(from.node, next)) + Inform(from, txitr->second->target, {}, true, true); } template < typename K, typename V, typename K_Hash, diff --git a/test/dht/mock_context.hpp b/test/dht/mock_context.hpp index 7183816ec..c8d4d2e88 100644 --- a/test/dht/mock_context.hpp +++ b/test/dht/mock_context.hpp @@ -62,6 +62,9 @@ namespace llarp MOCK_METHOD2(RelayRequestForPath, bool(const PathID_t& localPath, const dht::IMessage* msg)); + MOCK_CONST_METHOD2(GetRCFromNodeDB, + bool(const dht::Key_t& k, RouterContact& rc)); + MOCK_METHOD6(PropagateIntroSetTo, void(const dht::Key_t& source, uint64_t sourceTX, const service::IntroSet& introset,