Rip out link type spec and factory

We only support IWP now, so this is all effectively dead code.
pull/1186/head
Stephen Shelton 4 years ago
parent 176c1e3cbd
commit 6fd270ba09
No known key found for this signature in database
GPG Key ID: EE4BADACCE8B631C

@ -143,7 +143,6 @@ set(LIB_SRC
iwp/linklayer.cpp
iwp/message_buffer.cpp
iwp/session.cpp
link/factory.cpp
link/link_manager.cpp
link/server.cpp
messages/dht_immediate.cpp

@ -50,10 +50,6 @@ namespace llarp
m_JobQueueSize = arg;
});
// TODO: we don't support other protocols now; remove
conf.defineOption<std::string>("router", "default-protocol", false, m_DefaultLinkProto,
AssignmentAcceptor(m_DefaultLinkProto));
conf.defineOption<std::string>("router", "netid", true, m_netId,
[this](std::string arg) {
if(arg.size() > NetID::size())

@ -52,8 +52,6 @@ namespace llarp
size_t m_JobQueueSize = size_t{1024 * 8};
std::string m_DefaultLinkProto = "iwp";
void
defineConfigOptions(Configuration& conf, const ConfigGenParameters& params);
};

@ -386,14 +386,6 @@ namespace llarp
// reset netid in our rc
_rc.netID = llarp::NetID();
}
// TODO: dead code, rip this out. we only support IWP now.
const auto linktypename = conf->router.m_DefaultLinkProto;
_defaultLinkType = LinkFactory::TypeFromName(linktypename);
if(_defaultLinkType == LinkFactory::LinkType::eLinkUnknown)
{
LogError("failed to set link type to '", linktypename, "' as that is invalid");
return false;
}
// IWP config
m_OutboundPort = conf->links.m_OutboundLink.port;
@ -531,14 +523,8 @@ namespace llarp
// create inbound links, if we are a service node
for(const LinksConfig::LinkInfo &serverConfig : conf->links.m_InboundLinks)
{
// get default factory
// TODO: this is dead code, as is everything related to _defaultLinkType,
// also review LinkFactory for dead code
auto inboundLinkFactory = LinkFactory::Obtain(_defaultLinkType, true);
auto server = inboundLinkFactory(
m_keyManager,
util::memFn(&AbstractRouter::rc, this),
auto server = iwp::NewInboundLink(
m_keyManager, util::memFn(&AbstractRouter::rc, this),
util::memFn(&AbstractRouter::HandleRecvLinkMessageBuffer, this),
util::memFn(&AbstractRouter::Sign, this),
util::memFn(&IOutboundSessionMaker::OnSessionEstablished, &_outboundSessionMaker),
@ -1262,29 +1248,20 @@ namespace llarp
bool
Router::InitOutboundLinks()
{
const auto linkTypeName = LinkFactory::NameFromType(_defaultLinkType);
LogInfo("initialize outbound link: ", linkTypeName);
auto factory = LinkFactory::Obtain(_defaultLinkType, false);
if (factory == nullptr)
{
LogError(
"cannot initialize outbound link of type '",
linkTypeName,
"' as it has no implementation");
return false;
}
auto link = factory(
auto link = iwp::NewOutboundLink(
m_keyManager,
util::memFn(&AbstractRouter::rc, this),
util::memFn(&AbstractRouter::HandleRecvLinkMessageBuffer, this),
util::memFn(&AbstractRouter::Sign, this),
util::memFn(&IOutboundSessionMaker::OnSessionEstablished, &_outboundSessionMaker),
util::memFn(&IOutboundSessionMaker::OnSessionEstablished,
&_outboundSessionMaker),
util::memFn(&AbstractRouter::CheckRenegotiateValid, this),
util::memFn(&IOutboundSessionMaker::OnConnectTimeout, &_outboundSessionMaker),
util::memFn(&IOutboundSessionMaker::OnConnectTimeout,
&_outboundSessionMaker),
util::memFn(&AbstractRouter::SessionClosed, this),
util::memFn(&AbstractRouter::PumpLL, this));
if (!link)
if(!link)
return false;
const auto afs = {AF_INET, AF_INET6};

@ -10,7 +10,6 @@
#include <ev/ev.h>
#include <exit/context.hpp>
#include <handlers/tun.hpp>
#include <link/factory.hpp>
#include <link/link_manager.hpp>
#include <link/server.hpp>
#include <messages/link_message_parser.hpp>
@ -176,8 +175,6 @@ namespace llarp
struct sockaddr_in ip4addr;
AddressInfo addrInfo;
LinkFactory::LinkType _defaultLinkType;
llarp_ev_loop_ptr _netloop;
std::shared_ptr<llarp::thread::ThreadPool> cryptoworker;
std::shared_ptr<Logic> _logic;

Loading…
Cancel
Save