mirror of https://github.com/oxen-io/lokinet
pybind config object, working
This commit is contained in:
parent
9b3bf833e0
commit
0f34a950a9
|
@ -1,17 +1,17 @@
|
|||
#!/usr/bin/env python3
|
||||
import pyllarp
|
||||
from time import sleep
|
||||
|
||||
def main():
|
||||
|
||||
def main(conf):
|
||||
hive = pyllarp.RouterHive()
|
||||
config = pyllarp.Config()
|
||||
print("loading config: {}".format(conf))
|
||||
if not config.LoadFile(conf):
|
||||
print("failed to load {}".format(conf))
|
||||
return
|
||||
config.router.netid = "gamma"
|
||||
config.netdb.nodedbDir = "/home/tom/.lokinet/netdb"
|
||||
hive.AddRouter(config)
|
||||
hive.StartAll()
|
||||
sleep(10)
|
||||
hive.StopAll()
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys
|
||||
main(sys.argv[1])
|
||||
main()
|
||||
|
|
|
@ -35,7 +35,7 @@ namespace llarp
|
|||
|
||||
class RouterConfig
|
||||
{
|
||||
private:
|
||||
public:
|
||||
/// always maintain this many connections to other routers
|
||||
size_t m_minConnectedRouters = 2;
|
||||
|
||||
|
@ -98,7 +98,7 @@ namespace llarp
|
|||
public:
|
||||
using NetConfig = std::unordered_multimap< std::string, std::string >;
|
||||
|
||||
private:
|
||||
public:
|
||||
nonstd::optional< bool > m_enableProfiling;
|
||||
std::string m_routerProfilesFile = "profiles.dat";
|
||||
std::string m_strictConnect;
|
||||
|
@ -118,7 +118,7 @@ namespace llarp
|
|||
|
||||
class NetdbConfig
|
||||
{
|
||||
private:
|
||||
public:
|
||||
std::string m_nodedbDir;
|
||||
|
||||
public:
|
||||
|
@ -150,7 +150,7 @@ namespace llarp
|
|||
using LinkInfo = std::tuple< std::string, int, uint16_t, ServerOptions >;
|
||||
using Links = std::vector< LinkInfo >;
|
||||
|
||||
private:
|
||||
public:
|
||||
LinkInfo m_OutboundLink;
|
||||
Links m_InboundLinks;
|
||||
|
||||
|
@ -190,7 +190,7 @@ namespace llarp
|
|||
|
||||
class ApiConfig
|
||||
{
|
||||
private:
|
||||
public:
|
||||
bool m_enableRPCServer = false;
|
||||
std::string m_rpcBindAddr = "127.0.0.1:1190";
|
||||
|
||||
|
@ -235,7 +235,7 @@ namespace llarp
|
|||
|
||||
struct Config
|
||||
{
|
||||
private:
|
||||
public:
|
||||
bool
|
||||
parse(const ConfigParser& parser);
|
||||
|
||||
|
|
|
@ -313,6 +313,7 @@ namespace llarp
|
|||
llarp_ev_loop_stop(_netloop);
|
||||
disk->stop();
|
||||
disk->shutdown();
|
||||
_running.store(false);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -32,8 +32,7 @@ namespace tooling
|
|||
|
||||
for (llarp_main* ctx : routers)
|
||||
{
|
||||
std::thread t{std::bind(&llarp_main_run, ctx, opts)};
|
||||
routerMainThreads.emplace_back(std::move(t));
|
||||
routerMainThreads.emplace_back([=](){ llarp_main_run(ctx, opts); });
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -54,6 +53,16 @@ namespace tooling
|
|||
std::this_thread::sleep_for(10ms);
|
||||
}
|
||||
}
|
||||
|
||||
for (auto& thread : routerMainThreads)
|
||||
{
|
||||
while (not thread.joinable())
|
||||
{
|
||||
llarp::LogWarn("Waiting for router thread to be joinable");
|
||||
std::this_thread::sleep_for(500ms);
|
||||
}
|
||||
thread.join();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -8,6 +8,93 @@ namespace llarp
|
|||
using Config_ptr = std::shared_ptr<Config>;
|
||||
py::class_<Config, Config_ptr>(mod, "Config")
|
||||
.def(py::init<>())
|
||||
.def_readwrite("router", &Config::router)
|
||||
.def_readwrite("network", &Config::network)
|
||||
.def_readwrite("connect", &Config::connect)
|
||||
.def_readwrite("netdb", &Config::netdb)
|
||||
.def_readwrite("dns", &Config::dns)
|
||||
.def_readwrite("links", &Config::links)
|
||||
.def_readwrite("services", &Config::services)
|
||||
.def_readwrite("system", &Config::system)
|
||||
.def_readwrite("api", &Config::api)
|
||||
.def_readwrite("lokid", &Config::lokid)
|
||||
.def_readwrite("bootstrap", &Config::bootstrap)
|
||||
.def_readwrite("logging", &Config::logging)
|
||||
.def("LoadFile", &Config::Load);
|
||||
|
||||
py::class_<RouterConfig>(mod, "RouterConfig")
|
||||
.def(py::init<>())
|
||||
.def_readwrite("minConnectedRouters", &RouterConfig::m_minConnectedRouters)
|
||||
.def_readwrite("maxConnectedRouters", &RouterConfig::m_maxConnectedRouters)
|
||||
.def_readwrite("netid", &RouterConfig::m_netId)
|
||||
.def_readwrite("nickname", &RouterConfig::m_nickname)
|
||||
.def_readwrite("encryptionKeyfile", &RouterConfig::m_encryptionKeyfile)
|
||||
.def_readwrite("ourRcFile", &RouterConfig::m_ourRcFile)
|
||||
.def_readwrite("transportKeyfile", &RouterConfig::m_transportKeyfile)
|
||||
.def_readwrite("identKeyfile", &RouterConfig::m_identKeyfile)
|
||||
.def_readwrite("blockBogons", &RouterConfig::m_blockBogons)
|
||||
.def_readwrite("publicOverride", &RouterConfig::m_publicOverride)
|
||||
.def_readwrite("ip4addr", &RouterConfig::m_ip4addr)
|
||||
.def_readwrite("addrInfo", &RouterConfig::m_addrInfo)
|
||||
.def_readwrite("workerThreads", &RouterConfig::m_workerThreads)
|
||||
.def_readwrite("numNetThreads", &RouterConfig::m_numNetThreads)
|
||||
.def_readwrite("JobQueueSize", &RouterConfig::m_JobQueueSize)
|
||||
.def_readwrite("DefaultLinkProto", &RouterConfig::m_DefaultLinkProto);
|
||||
|
||||
py::class_<NetworkConfig>(mod, "NetworkConfig")
|
||||
.def(py::init<>())
|
||||
.def_readwrite("enableProfiling", &NetworkConfig::m_enableProfiling)
|
||||
.def_readwrite("routerProfilesFile", &NetworkConfig::m_routerProfilesFile)
|
||||
.def_readwrite("strictConnect", &NetworkConfig::m_strictConnect)
|
||||
.def_readwrite("netConfig", &NetworkConfig::m_netConfig);
|
||||
|
||||
py::class_<ConnectConfig>(mod, "ConnectConfig")
|
||||
.def(py::init<>())
|
||||
.def_readwrite("routers", &ConnectConfig::routers);
|
||||
|
||||
py::class_<NetdbConfig>(mod, "NetdbConfig")
|
||||
.def(py::init<>())
|
||||
.def_readwrite("nodedbDir", &NetdbConfig::m_nodedbDir);
|
||||
|
||||
py::class_<DnsConfig>(mod, "DnsConfig")
|
||||
.def(py::init<>())
|
||||
.def_readwrite("netConfig", &DnsConfig::netConfig);
|
||||
|
||||
py::class_<LinksConfig>(mod, "LinksConfig")
|
||||
.def(py::init<>())
|
||||
.def_readwrite("OutboundLink", &LinksConfig::m_OutboundLink)
|
||||
.def_readwrite("InboundLinks", &LinksConfig::m_InboundLinks);
|
||||
|
||||
py::class_<ServicesConfig>(mod, "ServicesConfig")
|
||||
.def(py::init<>())
|
||||
.def_readwrite("services", &ServicesConfig::services);
|
||||
|
||||
py::class_<SystemConfig>(mod, "SystemConfig")
|
||||
.def(py::init<>())
|
||||
.def_readwrite("pidfile", &SystemConfig::pidfile);
|
||||
|
||||
py::class_<ApiConfig>(mod, "ApiConfig")
|
||||
.def(py::init<>())
|
||||
.def_readwrite("enableRPCServer", &ApiConfig::m_enableRPCServer)
|
||||
.def_readwrite("rpcBindAddr", &ApiConfig::m_rpcBindAddr);
|
||||
|
||||
py::class_<LokidConfig>(mod, "LokidConfig")
|
||||
.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);
|
||||
|
||||
py::class_<BootstrapConfig>(mod, "BootstrapConfig")
|
||||
.def(py::init<>())
|
||||
.def_readwrite("routers", &BootstrapConfig::routers);
|
||||
|
||||
py::class_<LoggingConfig>(mod, "LoggingConfig")
|
||||
.def(py::init<>())
|
||||
.def_readwrite("LogJSON", &LoggingConfig::m_LogJSON)
|
||||
.def_readwrite("LogFile", &LoggingConfig::m_LogFile);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue