MCPcopy Create free account
hub / github.com/OpenVPN/openvpn3-linux / LogCallback

Method LogCallback

src/python/openvpn3/SessionManager.py:288–315  ·  view source on GitHub ↗
(self, cbfnc)

Source from the content-addressed store, hash-verified

286 #
287 #
288 def LogCallback(self, cbfnc):
289 if cbfnc is not None and self.__log_callback is not None:
290 # In this case, the program must first disable the
291 # current LogCallback() before setting a new one.
292 raise RuntimeError('LogCallback() is already enabled')
293
294 if cbfnc is None and self.__log_callback is None:
295 # This is fine: disabling a callback when there is no
296 # callback is a simple no-op.
297 return
298
299 if cbfnc is not None:
300 # Subscribe to Log signals, which will be processed
301 # by the callback function
302 self.__log_callback = cbfnc
303 self.__dbuscon.add_signal_receiver(cbfnc,
304 signal_name='Log',
305 dbus_interface='net.openvpn.v3.backends',
306 bus_name='net.openvpn.v3.log',
307 path=self.__session_path)
308 else:
309 # Only remove the callback if there actually *is* a callback
310 # currently.
311 if self.__log_callback is not None:
312 self.__dbuscon.remove_signal_receiver(self.__log_callback, 'Log')
313 self.__log_callback = None
314
315 self.__set_log_forward()
316
317 ##
318 # Subscribes to the StatusChange signals for this session and register

Callers 1

__del__Method · 0.95

Calls 1

__set_log_forwardMethod · 0.95

Tested by

no test coverage detected