OMG IT DOES STUFF :DDDDDD

pull/1184/head
Jeff Becker 4 years ago committed by Thomas Winget
parent 1bb3fba31b
commit a5dc41b049

@ -1,7 +1,10 @@
#!/usr/bin/env python3
import pyllarp
def main():
hive = pyllarp.RouterHive()
config = pyllarp.Config()
hive.AddRouter(config)
hive.StartAll()
hive.StopAll()

@ -13,6 +13,8 @@
#include <vector>
#include <unordered_set>
struct llarp_config;
namespace llarp
{
struct ConfigParser;
@ -256,6 +258,9 @@ namespace llarp
bool
LoadFromStr(string_view str);
llarp_config *
Copy() const;
};
fs::path

@ -327,6 +327,17 @@ struct llarp_config
}
};
namespace llarp
{
llarp_config *
Config::Copy() const
{
llarp_config * ptr = new llarp_config();
ptr->impl = *this;
return ptr;
}
}
extern "C"
{
size_t

@ -15,11 +15,14 @@ namespace tooling
}
void
RouterHive::AddRouter(llarp_config* conf)
RouterHive::AddRouter(const std::shared_ptr<llarp::Config> & config)
{
llarp_main* ctx = llarp_main_init_from_config(conf);
llarp::Context::Get(ctx)->InjectHive(this);
routers.push_back(ctx);
llarp_main* ctx = llarp_main_init_from_config(config->Copy());
if(llarp_main_setup(ctx) == 0)
{
llarp::Context::Get(ctx)->InjectHive(this);
routers.push_back(ctx);
}
}
void

@ -3,6 +3,7 @@
#include <tooling/router_event.hpp>
#include <llarp.h>
#include <config/config.hpp>
#include <util/thread/queue.hpp>
#include <vector>
@ -21,7 +22,7 @@ namespace tooling
RouterHive(size_t eventQueueSize = MAX_EVENT_QUEUE_SIZE);
void
AddRouter(llarp_config* conf);
AddRouter(const std::shared_ptr<llarp::Config> & conf);
void
StartRouters();

@ -6,6 +6,7 @@ set(LLARP_PYBIND_SRC
llarp/context.cpp
llarp/router_contact.cpp
llarp/crypto/types.cpp
llarp/config.cpp
llarp/tooling/router_hive.cpp
)

@ -14,6 +14,9 @@ namespace llarp
void
RouterContact_Init(py::module &mod);
void
Config_Init(py::module & mod);
} // namespace llarp
namespace tooling

@ -0,0 +1,13 @@
#include "common.hpp"
#include "config/config.hpp"
namespace llarp
{
void
Config_Init(py::module & mod)
{
using Config_ptr = std::shared_ptr<Config>;
py::class_<Config, Config_ptr>(mod, "Config")
.def(py::init<>())
.def("LoadFile", &Config::Load);
}
}

@ -9,6 +9,7 @@ namespace tooling
using RouterHive_ptr = std::shared_ptr< RouterHive >;
py::class_< RouterHive, RouterHive_ptr >(mod, "RouterHive")
.def(py::init<>())
.def("AddRouter", &RouterHive::AddRouter)
.def("StartAll", &RouterHive::StartRouters)
.def("StopAll", &RouterHive::StopRouters);

@ -7,4 +7,5 @@ PYBIND11_MODULE(pyllarp, m)
llarp::RouterContact_Init(m);
llarp::CryptoTypes_Init(m);
llarp::Context_Init(m);
llarp::Config_Init(m);
}

Loading…
Cancel
Save