Improvements to language binding facilities

This commit is contained in:
Joseph Henry
2021-03-01 22:34:12 -08:00
parent 66da0495a4
commit 62354e142e
3 changed files with 36 additions and 86 deletions

View File

@@ -25,9 +25,11 @@
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
#ifdef ZTS_ENABLE_PYTHON #ifdef ZTS_ENABLE_PYTHON
/* In some situations (Python comes to mind) a signal may not make its /**
way to libzt, for this reason we make sure to define a custom signal handler * In some situations (Python comes to mind) a signal may not make its
that can at least process SIGTERMs */ * way to libzt, for this reason we make sure to define a custom signal
* handler that can at least process SIGTERMs
*/
#define ZTS_ENABLE_CUSTOM_SIGNAL_HANDLERS 1 #define ZTS_ENABLE_CUSTOM_SIGNAL_HANDLERS 1
#endif #endif
@@ -842,7 +844,7 @@ struct zts_peer_list
}; };
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
// Python bits // // Python Bindings (Subset of regular socket API) //
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
#ifdef ZTS_ENABLE_PYTHON #ifdef ZTS_ENABLE_PYTHON
@@ -867,67 +869,15 @@ public:
extern PythonDirectorCallbackClass *_userEventCallback; extern PythonDirectorCallbackClass *_userEventCallback;
/** int zts_py_bind(int fd, int family, int type, PyObject *addro);
* @brief int zts_py_connect(int fd, int family, int type, PyObject *addro);
* PyObject * zts_py_accept(int fd);
* @param fd int zts_py_listen(int fd, int backlog);
* @param PyObject * zts_py_recv(int fd, int len, int flags);
* @param int zts_py_send(int fd, PyObject *buf, int len, int flags);
* @param int zts_py_close(int fd);
*
* @return
*/
int zts_sock_bind(int fd, int family, int type, PyObject *addro);
/** #endif // ZTS_ENABLE_PYTHON
* @brief
*
* @param fd
* @param
* @param
* @param
*
* @return
*/
int zts_sock_connect(int fd, int family, int type, PyObject *addro);
/**
* @brief
*
* @param fd
* @param
* @param
* @param
*
* @return
*/
PyObject * zts_sock_accept(int fd);
/**
* @brief
*
* @param fd
* @param
* @param
* @param
*
* @return
*/
PyObject * zts_sock_recv(int fd, int len, int flags);
/**
* @brief
*
* @param fd
* @param
* @param
* @param
*
* @return
*/
int zts_sock_send(int fd, PyObject *buf, int len, int flags);
#endif
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
// ZeroTier Service Controls // // ZeroTier Service Controls //
@@ -1436,8 +1386,6 @@ struct zts_stats {
struct zts_stats_proto nd6; struct zts_stats_proto nd6;
}; };
#endif
/** /**
* @brief Return all statistical counters for all protocols (inefficient) * @brief Return all statistical counters for all protocols (inefficient)
* *
@@ -1455,6 +1403,8 @@ ZTS_API int ZTCALL zts_get_all_stats(struct zts_stats *statsDest);
*/ */
ZTS_API int ZTCALL zts_get_protocol_stats(int protocolType, void *protoStatsDest); ZTS_API int ZTCALL zts_get_protocol_stats(int protocolType, void *protoStatsDest);
#endif // ZTS_ENABLE_STATS
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
// Socket API // // Socket API //
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////

View File

@@ -135,9 +135,9 @@ int zts_start_with_identity(const char *key_pair_str, uint16_t key_buf_len,
return ZTS_ERR_ARG; return ZTS_ERR_ARG;
} }
Mutex::Lock _l(serviceLock); Mutex::Lock _l(serviceLock);
//#ifdef ZTS_ENABLE_CUSTOM_SIGNAL_HANDLERS #ifdef ZTS_ENABLE_CUSTOM_SIGNAL_HANDLERS
_install_signal_handlers(); _install_signal_handlers();
//#endif // ZTS_ENABLE_CUSTOM_SIGNAL_HANDLERS #endif // ZTS_ENABLE_CUSTOM_SIGNAL_HANDLERS
_lwip_driver_init(); _lwip_driver_init();
if (service || _getState(ZTS_STATE_NODE_RUNNING)) { if (service || _getState(ZTS_STATE_NODE_RUNNING)) {
// Service is already initialized // Service is already initialized
@@ -254,9 +254,9 @@ int zts_start(const char *path, void (*callback)(void *), uint16_t port)
#endif #endif
{ {
Mutex::Lock _l(serviceLock); Mutex::Lock _l(serviceLock);
//#ifdef ZTS_ENABLE_CUSTOM_SIGNAL_HANDLERS #ifdef ZTS_ENABLE_CUSTOM_SIGNAL_HANDLERS
_install_signal_handlers(); _install_signal_handlers();
//#endif // ZTS_ENABLE_CUSTOM_SIGNAL_HANDLERS #endif // ZTS_ENABLE_CUSTOM_SIGNAL_HANDLERS
_lwip_driver_init(); _lwip_driver_init();
if (service || _getState(ZTS_STATE_NODE_RUNNING)) { if (service || _getState(ZTS_STATE_NODE_RUNNING)) {
// Service is already initialized // Service is already initialized