summaryrefslogtreecommitdiff
path: root/src/leap/base/checks.py
diff options
context:
space:
mode:
authorantialias <antialias@leap.se>2012-11-19 16:16:01 -0800
committerkali <kali@leap.se>2013-01-15 22:42:17 +0900
commit14f433c16de60753d122d5946df68e8e82285ca3 (patch)
tree14ad5d77836d4458855737740f42fd089035dda0 /src/leap/base/checks.py
parent348eb0852d6f1b8b2b72baba8a236bc30a6f2a4e (diff)
implemented abstracted layer with matching and passed callback.
tests as well.
Diffstat (limited to 'src/leap/base/checks.py')
-rw-r--r--src/leap/base/checks.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/leap/base/checks.py b/src/leap/base/checks.py
index 4d4a5d8b..587012fb 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,19 @@ 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:
+ for each in error_matrix:
+ error, callbacks = each
+ if error in line:
+ for cb in callbacks:
+ cb()