1
1
Fork 0
mirror of https://github.com/oxen-io/lokinet synced 2023-12-14 06:53:00 +01:00

updated pk emplace loop to pre-parse key addr

- error logging update to newer log::warning
This commit is contained in:
dan 2023-02-14 08:53:18 -08:00
parent c9c37c874b
commit 29180a32a7
2 changed files with 17 additions and 9 deletions

View file

@ -3,6 +3,7 @@
#include "ini.hpp"
#include <oxenmq/address.h>
#include <oxenmq/oxenmq.h>
#include <llarp/constants/files.hpp>
#include <llarp/constants/platform.hpp>
#include <llarp/constants/version.hpp>
@ -1174,9 +1175,10 @@ namespace llarp
key = "tcp://" + key;
auto pubkeys = split(values, ",", true);
oxenmq::address key_addr{key};
for (auto& pk : pubkeys)
m_rpcEncryptedAddresses[oxenmq::address{key}].emplace(pk);
m_rpcEncryptedAddresses[key_addr].emplace(pk);
},
Comment{
"Specify encrypted listener addresses and comma-delimited public keys to be accepted ",

View file

@ -1,5 +1,7 @@
#include "rpc_server.hpp"
#include "llarp/rpc/rpc_request_definitions.hpp"
#include "llarp/util/logging.hpp"
#include "oxen/log.hpp"
#include "rpc_request.hpp"
#include "llarp/service/address.hpp"
#include <cmath>
@ -106,18 +108,22 @@ namespace llarp::rpc
for (const auto& addr : r.GetConfig()->api.m_rpcBindAddresses)
{
m_LMQ->listen_plain(addr.zmq_address());
LogInfo("Bound RPC server to ", addr.full_address());
log::info(logcat, "Bound RPC server to {}", addr.full_address());
}
for (const auto& [address, allowed_keys] : r->GetConfig()->api.m_rpcEncryptedAddresses)
for (const auto& [address, allowed_keys] : r.GetConfig()->api.m_rpcEncryptedAddresses)
{
m_LMQ->listen_curve(address.zmq_address(), [allowed_keys = allowed_keys](auto pk, ...) {
if (std::find(allowed_keys.begin(), allowed_keys.end(), pk) != allowed_keys.end())
return oxenmq::AuthLevel::admin;
m_LMQ->listen_curve(
address.zmq_address(), [allowed_keys = allowed_keys](auto addr, auto pk, ...) {
if (allowed_keys.count(std::string{pk}))
return oxenmq::AuthLevel::admin;
LogInfo("Curve pubkey not found in whitelist");
return oxenmq::AuthLevel::denied;
});
log::warning(
logcat,
"Curve pubkey not in whitelist, denying incoming RPC connection from {}",
addr);
return oxenmq::AuthLevel::denied;
});
}
AddCategories();