disable rpc on relays by default (#1383)

* disable rpc on relays by default

* add default inbound link as service node

* throw if public-ip and public-port are not set
pull/1382/head
Jeff 4 years ago committed by GitHub
parent fbfa8ca89c
commit 0f7e848903
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -464,13 +464,10 @@ namespace llarp
void
ApiConfig::defineConfigOptions(ConfigDefinition& conf, const ConfigGenParameters& params)
{
(void)params;
constexpr bool DefaultRPCEnabled = true;
constexpr auto DefaultRPCBindAddr = "tcp://127.0.0.1:1190";
conf.defineOption<bool>(
"api", "enabled", false, DefaultRPCEnabled, AssignmentAcceptor(m_enableRPCServer));
"api", "enabled", false, not params.isRelay, AssignmentAcceptor(m_enableRPCServer));
conf.defineOption<std::string>(
"api", "bind", false, DefaultRPCBindAddr, [this](std::string arg) {

@ -568,8 +568,22 @@ namespace llarp
whitelistRouters,
m_isServiceNode);
std::vector<LinksConfig::LinkInfo> inboundLinks = conf.links.m_InboundLinks;
if (inboundLinks.empty() and m_isServiceNode)
{
const auto& publicAddr = conf.router.m_publicAddress;
if (publicAddr.isEmpty() or not publicAddr.hasPort())
{
throw std::runtime_error(
"service node enabled but could not find a public IP to bind to; you need to set the "
"public-ip= and public-port= options");
}
inboundLinks.push_back(LinksConfig::LinkInfo{"0.0.0.0", AF_INET, *publicAddr.getPort()});
}
// create inbound links, if we are a service node
for (const LinksConfig::LinkInfo& serverConfig : conf.links.m_InboundLinks)
for (const LinksConfig::LinkInfo& serverConfig : inboundLinks)
{
auto server = iwp::NewInboundLink(
m_keyManager,
@ -594,11 +608,6 @@ namespace llarp
_linkManager.AddLink(std::move(server), true);
}
if (conf.links.m_InboundLinks.empty() and m_isServiceNode)
{
throw std::runtime_error("service node enabled but have no inbound links");
}
// Network config
if (conf.network.m_enableProfiling.has_value() and not*conf.network.m_enableProfiling)
{

Loading…
Cancel
Save