2020-02-27 22:05:25 +00:00
|
|
|
#include "common.hpp"
|
|
|
|
#include "config/config.hpp"
|
2020-02-28 09:50:33 +00:00
|
|
|
|
|
|
|
#include <netinet/in.h>
|
|
|
|
|
2020-02-27 22:05:25 +00:00
|
|
|
namespace llarp
|
|
|
|
{
|
2020-02-28 09:50:33 +00:00
|
|
|
void
|
2020-04-07 18:38:56 +00:00
|
|
|
in_addr_set(in_addr* addr, const char* str)
|
2020-02-28 09:50:33 +00:00
|
|
|
{
|
|
|
|
inet_aton(str, addr);
|
|
|
|
}
|
|
|
|
|
2020-02-27 22:05:25 +00:00
|
|
|
void
|
2020-04-07 18:38:56 +00:00
|
|
|
Config_Init(py::module& mod)
|
2020-02-27 22:05:25 +00:00
|
|
|
{
|
2020-04-07 18:38:56 +00:00
|
|
|
using Config_ptr = std::shared_ptr<Config>;
|
|
|
|
py::class_<Config, Config_ptr>(mod, "Config")
|
2020-03-07 01:20:11 +00:00
|
|
|
.def(py::init<>())
|
|
|
|
.def_readwrite("router", &Config::router)
|
|
|
|
.def_readwrite("network", &Config::network)
|
|
|
|
.def_readwrite("connect", &Config::connect)
|
|
|
|
.def_readwrite("links", &Config::links)
|
|
|
|
.def_readwrite("api", &Config::api)
|
|
|
|
.def_readwrite("lokid", &Config::lokid)
|
|
|
|
.def_readwrite("bootstrap", &Config::bootstrap)
|
|
|
|
.def_readwrite("logging", &Config::logging)
|
2020-04-24 17:10:05 +00:00
|
|
|
.def("LoadFile", &Config::Load)
|
|
|
|
.def("LoadDefault", [](Config& self, bool isRelay, std::string dir) {
|
|
|
|
return self.LoadDefault(isRelay, dir);
|
|
|
|
});
|
2020-03-07 01:20:11 +00:00
|
|
|
|
2020-04-07 18:38:56 +00:00
|
|
|
py::class_<RouterConfig>(mod, "RouterConfig")
|
2020-03-07 01:20:11 +00:00
|
|
|
.def(py::init<>())
|
2020-04-07 18:38:56 +00:00
|
|
|
.def_readwrite("minConnectedRouters", &RouterConfig::m_minConnectedRouters)
|
|
|
|
.def_readwrite("maxConnectedRouters", &RouterConfig::m_maxConnectedRouters)
|
2020-03-07 01:20:11 +00:00
|
|
|
.def_readwrite("netid", &RouterConfig::m_netId)
|
|
|
|
.def_readwrite("nickname", &RouterConfig::m_nickname)
|
2020-04-07 23:50:50 +00:00
|
|
|
.def_property(
|
|
|
|
"dataDir",
|
|
|
|
[](RouterConfig& self) { return self.m_dataDir.c_str(); },
|
|
|
|
[](RouterConfig& self, std::string dir) { self.m_dataDir = dir; })
|
2020-03-07 01:20:11 +00:00
|
|
|
.def_readwrite("blockBogons", &RouterConfig::m_blockBogons)
|
2020-04-07 18:38:56 +00:00
|
|
|
.def(
|
|
|
|
"overrideAddress",
|
2020-06-08 19:15:54 +00:00
|
|
|
[](RouterConfig& self, std::string addr) {
|
|
|
|
self.m_publicAddress = llarp::IpAddress(addr);
|
2020-04-07 18:38:56 +00:00
|
|
|
})
|
2020-03-07 01:20:11 +00:00
|
|
|
.def_readwrite("workerThreads", &RouterConfig::m_workerThreads)
|
|
|
|
.def_readwrite("numNetThreads", &RouterConfig::m_numNetThreads)
|
2020-04-07 23:50:50 +00:00
|
|
|
.def_readwrite("JobQueueSize", &RouterConfig::m_JobQueueSize);
|
2020-03-07 01:20:11 +00:00
|
|
|
|
2020-04-07 18:38:56 +00:00
|
|
|
py::class_<NetworkConfig>(mod, "NetworkConfig")
|
2020-03-07 01:20:11 +00:00
|
|
|
.def(py::init<>())
|
|
|
|
.def_readwrite("enableProfiling", &NetworkConfig::m_enableProfiling)
|
2020-04-07 18:38:56 +00:00
|
|
|
.def_readwrite("routerProfilesFile", &NetworkConfig::m_routerProfilesFile)
|
2020-05-06 14:45:30 +00:00
|
|
|
.def_readwrite("endpointType", &NetworkConfig::m_endpointType)
|
|
|
|
.def_readwrite("keyfile", &NetworkConfig::m_keyfile)
|
|
|
|
.def_readwrite("endpointType", &NetworkConfig::m_endpointType)
|
|
|
|
.def_readwrite("reachable", &NetworkConfig::m_reachable)
|
2020-06-08 19:15:54 +00:00
|
|
|
.def_readwrite("hops", &NetworkConfig::m_Hops)
|
|
|
|
.def_readwrite("paths", &NetworkConfig::m_Paths)
|
2020-05-06 14:45:30 +00:00
|
|
|
.def_readwrite("snodeBlacklist", &NetworkConfig::m_snodeBlacklist)
|
2020-06-08 19:15:54 +00:00
|
|
|
.def_readwrite("mapAddr", &NetworkConfig::m_mapAddrs)
|
2020-05-06 14:45:30 +00:00
|
|
|
.def_readwrite("strictConnect", &NetworkConfig::m_strictConnect);
|
2020-03-07 01:20:11 +00:00
|
|
|
|
2020-04-07 18:38:56 +00:00
|
|
|
py::class_<ConnectConfig>(mod, "ConnectConfig")
|
2020-03-07 01:20:11 +00:00
|
|
|
.def(py::init<>())
|
|
|
|
.def_readwrite("routers", &ConnectConfig::routers);
|
|
|
|
|
2020-05-06 14:45:30 +00:00
|
|
|
py::class_<DnsConfig>(mod, "DnsConfig").def(py::init<>());
|
2020-03-07 01:20:11 +00:00
|
|
|
|
2020-04-07 18:38:56 +00:00
|
|
|
py::class_<LinksConfig>(mod, "LinksConfig")
|
2020-03-07 01:20:11 +00:00
|
|
|
.def(py::init<>())
|
2020-04-24 17:10:05 +00:00
|
|
|
.def(
|
|
|
|
"setOutboundLink",
|
|
|
|
[](LinksConfig& self, std::string interface, int family, uint16_t port) {
|
|
|
|
LinksConfig::LinkInfo info;
|
|
|
|
info.interface = std::move(interface);
|
|
|
|
info.addressFamily = family;
|
|
|
|
info.port = port;
|
|
|
|
self.m_OutboundLink = std::move(info);
|
|
|
|
})
|
2020-04-07 23:50:50 +00:00
|
|
|
.def(
|
|
|
|
"addInboundLink",
|
|
|
|
[](LinksConfig& self, std::string interface, int family, uint16_t port) {
|
|
|
|
LinksConfig::LinkInfo info;
|
|
|
|
info.interface = std::move(interface);
|
|
|
|
info.addressFamily = family;
|
|
|
|
info.port = port;
|
|
|
|
self.m_InboundLinks.push_back(info);
|
|
|
|
});
|
2020-03-07 01:20:11 +00:00
|
|
|
|
2020-04-07 18:38:56 +00:00
|
|
|
py::class_<ApiConfig>(mod, "ApiConfig")
|
2020-03-07 01:20:11 +00:00
|
|
|
.def(py::init<>())
|
|
|
|
.def_readwrite("enableRPCServer", &ApiConfig::m_enableRPCServer)
|
|
|
|
.def_readwrite("rpcBindAddr", &ApiConfig::m_rpcBindAddr);
|
|
|
|
|
2020-04-07 18:38:56 +00:00
|
|
|
py::class_<LokidConfig>(mod, "LokidConfig")
|
2020-03-07 01:20:11 +00:00
|
|
|
.def(py::init<>())
|
|
|
|
.def_readwrite("usingSNSeed", &LokidConfig::usingSNSeed)
|
|
|
|
.def_readwrite("whitelistRouters", &LokidConfig::whitelistRouters)
|
|
|
|
.def_readwrite("ident_keyfile", &LokidConfig::ident_keyfile)
|
|
|
|
.def_readwrite("lokidRPCAddr", &LokidConfig::lokidRPCAddr)
|
|
|
|
.def_readwrite("lokidRPCUser", &LokidConfig::lokidRPCUser)
|
|
|
|
.def_readwrite("lokidRPCPassword", &LokidConfig::lokidRPCPassword);
|
|
|
|
|
2020-04-07 18:38:56 +00:00
|
|
|
py::class_<BootstrapConfig>(mod, "BootstrapConfig")
|
2020-03-07 01:20:11 +00:00
|
|
|
.def(py::init<>())
|
2020-06-08 19:15:54 +00:00
|
|
|
.def_property(
|
|
|
|
"routers",
|
|
|
|
[](BootstrapConfig& self) {
|
|
|
|
std::vector<std::string> args;
|
|
|
|
for (const auto& arg : self.routers)
|
|
|
|
args.emplace_back(arg.string());
|
|
|
|
return args;
|
|
|
|
},
|
|
|
|
[](BootstrapConfig& self, std::vector<std::string> args) {
|
|
|
|
self.routers.clear();
|
|
|
|
for (const auto& arg : args)
|
|
|
|
{
|
|
|
|
self.routers.emplace_back(arg);
|
|
|
|
}
|
|
|
|
});
|
2020-03-07 01:20:11 +00:00
|
|
|
|
2020-04-07 18:38:56 +00:00
|
|
|
py::class_<LoggingConfig>(mod, "LoggingConfig")
|
2020-03-07 01:20:11 +00:00
|
|
|
.def(py::init<>())
|
2020-04-07 23:50:50 +00:00
|
|
|
.def_readwrite("m_logType", &LoggingConfig::m_logType)
|
|
|
|
.def_readwrite("m_logFile", &LoggingConfig::m_logFile);
|
2020-03-07 01:20:11 +00:00
|
|
|
|
2020-04-07 18:38:56 +00:00
|
|
|
py::class_<sockaddr_in>(mod, "sockaddr_in")
|
2020-03-07 01:20:11 +00:00
|
|
|
.def_readwrite("sin_family", &sockaddr_in::sin_family)
|
|
|
|
.def_readwrite("sin_port", &sockaddr_in::sin_port)
|
|
|
|
.def_readwrite("sin_addr", &sockaddr_in::sin_addr);
|
|
|
|
|
2020-04-07 18:38:56 +00:00
|
|
|
py::class_<in_addr>(mod, "in_addr").def("set", &in_addr_set);
|
2020-02-27 22:05:25 +00:00
|
|
|
}
|
2020-03-07 01:20:11 +00:00
|
|
|
} // namespace llarp
|