summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRuben Pollan <meskio@sindominio.net>2018-07-23 16:48:12 +0200
committerRuben Pollan <meskio@sindominio.net>2018-07-23 16:48:12 +0200
commitd6e1d9c1cef028e267e70875f706b9378564ddef (patch)
tree907720d826d97b008d56aa3455162e17c4c4e8a6 /src
parent1bb23d6cb31b0b3ce4fa3e4bf8f71589726cccf7 (diff)
[bug] return allways a valid state from openvpn
Even if we don't recognize the state that openvpn is providing. Add TCP_CONNECT state as well.
Diffstat (limited to 'src')
-rw-r--r--src/leap/bitmask/vpn/_state.py13
-rw-r--r--src/leap/bitmask/vpn/process.py20
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