diff options
Diffstat (limited to 'src/leap/bitmask')
-rw-r--r-- | src/leap/bitmask/vpn/_state.py | 13 | ||||
-rw-r--r-- | src/leap/bitmask/vpn/process.py | 20 |
2 files changed, 18 insertions, 15 deletions
diff --git a/src/leap/bitmask/vpn/_state.py b/src/leap/bitmask/vpn/_state.py index 53877735..b0af9870 100644 --- a/src/leap/bitmask/vpn/_state.py +++ b/src/leap/bitmask/vpn/_state.py @@ -20,6 +20,7 @@ VPN State. """ import time +from twisted.logger import Logger class State(object): @@ -29,6 +30,8 @@ class State(object): OpenVPN Management documentation. """ + log = Logger() + CONNECTING = 'CONNECTING' WAIT = 'WAIT' AUTH = 'AUTH' @@ -54,6 +57,7 @@ class State(object): 'ADD_ROUTES': 'Adding routes to system', 'CONNECTED': 'Initialization Sequence Completed', 'RECONNECTING': 'A restart has occurred', + 'TCP_CONNECT': 'Stablishing tcp connection', 'EXITING': 'A graceful exit is in progress', 'OFF': 'Disconnected', 'FAILED': 'A failure has occurred', @@ -68,6 +72,7 @@ class State(object): 'ADD_ROUTES': STARTING, 'CONNECTED': ON, 'RECONNECTING': STARTING, + 'TCP_CONNECT': STARTING, 'EXITING': STOPPING, 'OFF': OFF, 'FAILED': OFF @@ -79,11 +84,15 @@ class State(object): @classmethod def get_legend(cls, state): - return cls._legend.get(state) + return cls._legend.get(state, '') @classmethod def get_simple(cls, state): - return cls._simple.get(state) + simple = cls._simple.get(state) + if not simple: + cls.log.warn('Unkown openvpn state: %s' % state) + simple = cls.FAILED + return simple @property def simple(self): diff --git a/src/leap/bitmask/vpn/process.py b/src/leap/bitmask/vpn/process.py index d1d929d7..7150410e 100644 --- a/src/leap/bitmask/vpn/process.py +++ b/src/leap/bitmask/vpn/process.py @@ -250,19 +250,13 @@ class _VPNProcess(protocol.ProcessProtocol): def status(self): if self.failed: return {'status': 'failed', 'error': self.errmsg} - try: - state = self.getState() - if state: - _status = state.simple.lower() - status = {'status': _status, 'error': None} - except AttributeError: - raise - # BUG -- glitch due to proto.state transition? - # still needed? - # state = self.getState() - # if state: - # _status = state.simple.lower() - # status = {'status': _status, 'error': None} + + state = self.getState() + if state: + _status = state.simple.lower() + else: + _status = None + status = {'status': _status, 'error': None} if self.proto and self.proto.traffic: remote = self.proto.remote |