From 3ab7794d1731bfad0683df0b3fb1c2535a0e6501 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BD=D0=B4=D1=80=D0=B5=D0=B9=20=D0=92=D0=BB=D0=B0?= =?UTF-8?q?=D0=B4=D0=B8=D0=BC=D0=B8=D1=80=D0=BE=D0=B2=D0=B8=D1=87?= Date: Thu, 18 Feb 2016 18:46:06 +0300 Subject: [PATCH] upd tox --- src/tox.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/tox.py b/src/tox.py index 7e0b570..b25ad7d 100644 --- a/src/tox.py +++ b/src/tox.py @@ -115,6 +115,28 @@ class Tox(object): elif tox_err_bootstrap == TOX_ERR_BOOTSTRAP['TOX_ERR_BOOTSTRAP_BAD_PORT']: raise ArgumentError('The port passed was invalid. The valid port range is (1, 65535).') + def add_tcp_relay(self, address, port, public_key): + tox_err_bootstrap = c_int() + result = self.libtoxcore.tox_add_tcp_relay(self._tox_pointer, c_char_p(address), c_uint16(port), + c_char_p(public_key), addressof(tox_err_bootstrap)) + if tox_err_bootstrap == TOX_ERR_BOOTSTRAP['TOX_ERR_BOOTSTRAP_OK']: + return bool(result) + elif tox_err_bootstrap == TOX_ERR_BOOTSTRAP['TOX_ERR_BOOTSTRAP_NULL']: + raise ArgumentError('One of the arguments to the function was NULL when it was not expected.') + elif tox_err_bootstrap == TOX_ERR_BOOTSTRAP['TOX_ERR_BOOTSTRAP_BAD_HOST']: + raise ArgumentError('The address could not be resolved to an IP ' + 'address, or the IP address passed was invalid.') + elif tox_err_bootstrap == TOX_ERR_BOOTSTRAP['TOX_ERR_BOOTSTRAP_BAD_PORT']: + raise ArgumentError('The port passed was invalid. The valid port range is (1, 65535).') + + def self_get_connection_status(self): + return self.libtoxcore.tox_self_get_connection_status(self._tox_pointer) + + def callback_self_connection_status(self, callback, user_data): + tox_self_connection_status_cb = CFUNCTYPE(None, c_void_p, c_int, c_void_p) + c_callback = tox_self_connection_status_cb(callback) + self.libtoxcore.tox_callback_self_connection_status(self._tox_pointer, c_callback, c_void_p(user_data)) + def __del__(self): self.libtoxcore.tox_kill(self._tox_pointer) self.libtoxcore.tox_options_free(self.tox_options)