// PORT: networking is prepared by the native transport, independently of the login UI. #include #ifdef MT_HAS_MESHPORT #include "transport.h" #include "MeshPortConfig.h" #include #include #include namespace { PyObject* event(PyObject*,PyObject*) { return PyInt_FromLong(mt::meshport::take_event()); } PyObject* local(PyObject*,PyObject* args) { const char* ip;if(!PyArg_ParseTuple(args,"s",&ip))return nullptr; return PyBool_FromLong(mt::meshport::same_subnet(ip)); } PyMethodDef methods[]={ {"event",event,METH_NOARGS,nullptr},{"same_subnet",local,METH_VARARGS,nullptr}, {nullptr,nullptr,0,nullptr} }; } void initMeshPort() { std::string config=kMeshPortConfig; if(const char* path=std::getenv("MT_MESHPORT_CONFIG")) { std::ifstream input(path,std::ios::binary); config.assign(std::istreambuf_iterator(input),{}); } if(config.size()>65536)config.clear(); mt::meshport::configure(config); Py_InitModule("_mt_meshport",methods); } #endif