summaryrefslogtreecommitdiff
path: root/src/leap/base/checks.py
diff options
context:
space:
mode:
authorkali <kali@leap.se>2013-01-16 00:59:54 +0900
committerkali <kali@leap.se>2013-01-16 00:59:54 +0900
commit9c260efd6f9821f5d97cc426f501203bfc8a1fde (patch)
tree3a0a31077cb6cb1e4ec1bbcfc2cd08e6b08adf4b /src/leap/base/checks.py
parentf90f9df1d09e12ba64e9401530684d5a36220ad3 (diff)
parentbf39c45eddc62733fdb72b4f46cdb81ec649cb30 (diff)
Merge branch 'feature/openvpn_logs_mgmt_interface' into develop
Diffstat (limited to 'src/leap/base/checks.py')
-rw-r--r--src/leap/base/checks.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/leap/base/checks.py b/src/leap/base/checks.py
index 4d4a5d8b..e5767018 100644
--- a/src/leap/base/checks.py
+++ b/src/leap/base/checks.py
@@ -12,6 +12,9 @@ from leap.base import exceptions
logger = logging.getLogger(name=__name__)
+#EVENTS OF NOTE
+EVENT_CONNECT_REFUSED = "[ECONNREFUSED]: Connection refused (code=111)"
+
class LeapNetworkChecker(object):
"""
@@ -34,6 +37,8 @@ class LeapNetworkChecker(object):
if self.provider_gateway:
checker.ping_gateway(self.provider_gateway)
+ checker.parse_log_and_react([], ())
+
def check_internet_connection(self):
try:
# XXX remove this hardcoded random ip
@@ -136,3 +141,21 @@ class LeapNetworkChecker(object):
return True
except socket.gaierror:
raise exceptions.CannotResolveDomainError
+
+ def parse_log_and_react(self, log, error_matrix=None):
+ """
+ compares the recent openvpn status log to
+ strings passed in and executes the callbacks passed in.
+ @param log: openvpn log
+ @type log: list of strings
+ @param error_matrix: tuples of strings and tuples of callbacks
+ @type error_matrix: tuples strings and call backs
+ """
+ for line in log:
+ # we could compile a regex here to save some cycles up -- kali
+ for each in error_matrix:
+ error, callbacks = each
+ if error in line:
+ for cb in callbacks:
+ if callable(cb):
+ cb()