def __init__(self, vpnconfig, providerconfig, socket_host, socket_port, openvpn_verb, remotes, restartfun=None): """ :param vpnconfig: vpn configuration object :type vpnconfig: VPNConfig :param providerconfig: provider specific configuration :type providerconfig: ProviderConfig :param socket_host: either socket path (unix) or socket IP :type socket_host: str :param socket_port: either string "unix" if it's a unix socket, or port otherwise :type socket_port: str :param openvpn_verb: the desired level of verbosity in the openvpn invocation :type openvpn_verb: int """ _management.VPNManagement.__init__(self) self._vpnconfig = vpnconfig self._providerconfig = providerconfig self._socket_host = socket_host self._socket_port = socket_port self._launcher = get_vpn_launcher() self._last_state = None self._last_status = None self._alive = False # XXX use flags, maybe, instead of passing # the parameter around. self._openvpn_verb = openvpn_verb self._restartfun = restartfun self._status = _status.VPNStatus() self.restarting = False self._remotes = remotes
def __init__(self, vpnconfig, providerconfig, socket_host, socket_port, openvpn_verb, remotes, restartfun=None): """ :param vpnconfig: vpn configuration object :type vpnconfig: VPNConfig :param providerconfig: provider specific configuration :type providerconfig: ProviderConfig :param socket_host: either socket path (unix) or socket IP :type socket_host: str :param socket_port: either string "unix" if it's a unix socket, or port otherwise :type socket_port: str """ self._host = socket_host self._port = socket_port if socket_port == 'unix': folder = os.path.split(self._host)[0] if not os.path.isdir(folder): os.makedirs(folder) self._management_endpoint = clientFromString( reactor, b"unix:path=%s" % socket_host) else: raise ValueError('tcp endpoint not configured') self._vpnconfig = vpnconfig self._providerconfig = providerconfig self._launcher = get_vpn_launcher() self._restartfun = restartfun self.restarting = True self.failed = False self.errmsg = None self.proto = None self._remotes = remotes self._statelog = OrderedDict() self._turn_state_off()