more introspection

pull/1184/head
Jeff Becker 4 years ago committed by Thomas Winget
parent 35bea37fd1
commit 78454f1cb4

@ -3,7 +3,9 @@ set(PYTHON_EXECUTABLE "python3")
find_package(pybind11 REQUIRED)
set(LLARP_PYBIND_SRC
module.cpp
llarp/context.cpp
llarp/router_contact.cpp
llarp/crypto/types.cpp
llarp/simulation/sim_context.cpp)
pybind11_add_module(pyllarp MODULE ${LLARP_PYBIND_SRC})

@ -8,6 +8,9 @@ namespace llarp
void
Context_Init(py::module &mod);
void
CryptoTypes_Init(py::module &mod);
void
RouterContact_Init(py::module &mod);

@ -0,0 +1,34 @@
#include <crypto/types.hpp>
#include "common.hpp"
namespace llarp
{
void
CryptoTypes_Init(py::module& mod)
{
py::class_< PubKey >(mod, "PubKey")
.def(py::init<>())
.def("FromHex", &PubKey::FromString)
.def("__repr__", &PubKey::ToString);
py::class_< RouterID >(mod, "RouterID")
.def(py::init<>())
.def("FromHex",
[](RouterID* r, const std::string& hex) -> bool {
return HexDecode(hex.c_str(), r->data(), r->size());
})
.def("__repr__", &RouterID::ToString);
py::class_< SecretKey >(mod, "SecretKey")
.def(py::init<>())
.def("LoadFile", &SecretKey::LoadFromFile)
.def("SaveFile", &SecretKey::SaveToFile)
.def("ToPublic", &SecretKey::toPublic);
py::class_< Signature >(mod, "Signature")
.def(py::init<>())
.def("__repr__", [](const Signature sig) -> std::string {
std::stringstream ss;
ss << sig;
return ss.str();
});
}
} // namespace llarp

@ -5,4 +5,6 @@ PYBIND11_MODULE(pyllarp, m)
{
llarp::simulate::SimContext_Init(m);
llarp::RouterContact_Init(m);
llarp::CryptoTypes_Init(m);
llarp::Context_Init(m);
}

Loading…
Cancel
Save