2021-03-09 22:24:35 +00:00
|
|
|
#include <common.hpp>
|
|
|
|
#include <pybind11/stl.h>
|
|
|
|
#include <pybind11/iostream.h>
|
2020-03-03 00:42:06 +00:00
|
|
|
|
2021-03-09 22:24:35 +00:00
|
|
|
#include <llarp/tooling/router_hive.hpp>
|
|
|
|
#include <llarp/router/abstractrouter.hpp>
|
|
|
|
#include <llarp.hpp>
|
2020-06-17 21:42:22 +00:00
|
|
|
|
2020-02-27 21:30:45 +00:00
|
|
|
namespace tooling
|
|
|
|
{
|
|
|
|
void
|
|
|
|
RouterHive_Init(py::module& mod)
|
|
|
|
{
|
2020-04-07 18:38:56 +00:00
|
|
|
using RouterHive_ptr = std::shared_ptr<RouterHive>;
|
2020-07-06 23:40:42 +00:00
|
|
|
using Context_ptr = RouterHive::Context_ptr;
|
|
|
|
using ContextVisitor = std::function<void(Context_ptr)>;
|
|
|
|
|
2020-04-07 18:38:56 +00:00
|
|
|
py::class_<RouterHive, RouterHive_ptr>(mod, "RouterHive")
|
2020-02-27 21:30:45 +00:00
|
|
|
.def(py::init<>())
|
2020-03-02 22:10:01 +00:00
|
|
|
.def("AddRelay", &RouterHive::AddRelay)
|
|
|
|
.def("AddClient", &RouterHive::AddClient)
|
|
|
|
.def("StartRelays", &RouterHive::StartRelays)
|
|
|
|
.def("StartClients", &RouterHive::StartClients)
|
2020-02-28 04:01:14 +00:00
|
|
|
.def("StopAll", &RouterHive::StopRouters)
|
2020-07-06 23:40:42 +00:00
|
|
|
.def(
|
|
|
|
"ForEachRelay",
|
|
|
|
[](RouterHive& hive, ContextVisitor visit) {
|
|
|
|
hive.ForEachRelay([visit](Context_ptr ctx) {
|
|
|
|
py::gil_scoped_acquire acquire;
|
|
|
|
visit(std::move(ctx));
|
|
|
|
});
|
|
|
|
})
|
|
|
|
.def(
|
|
|
|
"ForEachClient",
|
|
|
|
[](RouterHive& hive, ContextVisitor visit) {
|
|
|
|
hive.ForEachClient([visit](Context_ptr ctx) {
|
|
|
|
py::gil_scoped_acquire acquire;
|
|
|
|
visit(std::move(ctx));
|
|
|
|
});
|
|
|
|
})
|
|
|
|
.def(
|
|
|
|
"ForEachRouter",
|
|
|
|
[](RouterHive& hive, ContextVisitor visit) {
|
|
|
|
hive.ForEachRouter([visit](Context_ptr ctx) {
|
|
|
|
py::gil_scoped_acquire acquire;
|
|
|
|
visit(std::move(ctx));
|
|
|
|
});
|
|
|
|
})
|
2020-03-03 00:42:06 +00:00
|
|
|
.def("GetNextEvent", &RouterHive::GetNextEvent)
|
2020-03-04 05:57:07 +00:00
|
|
|
.def("GetAllEvents", &RouterHive::GetAllEvents)
|
|
|
|
.def("RelayConnectedRelays", &RouterHive::RelayConnectedRelays)
|
2020-06-17 21:42:22 +00:00
|
|
|
.def("GetRelayRCs", &RouterHive::GetRelayRCs)
|
|
|
|
.def("GetRelay", &RouterHive::GetRelay);
|
2020-02-27 21:30:45 +00:00
|
|
|
}
|
2020-03-07 01:20:11 +00:00
|
|
|
} // namespace tooling
|