added enforced source_ip parameter in case the providers are sharing the same interface
This commit is contained in:
@@ -94,6 +94,8 @@ One section for each provider, named the same as in the shorewall **http://shore
|
|||||||
|led | 1,2,3 | on Alix router, power on/off led depending of availability |
|
|led | 1,2,3 | on Alix router, power on/off led depending of availability |
|
||||||
|openvpn_master | 0,1 | is provider used by openvpn (openvpn is restarted if vpn is running on provider)|
|
|openvpn_master | 0,1 | is provider used by openvpn (openvpn is restarted if vpn is running on provider)|
|
||||||
|fallback | 0,1 | is provider a fallback provider, in this case, it is never disabled. |
|
|fallback | 0,1 | is provider a fallback provider, in this case, it is never disabled. |
|
||||||
|
|source_ip | 1.2.3.4 | optional source_ip fo rthe provider in cas the providers are sharing the same physical interface |
|
||||||
|
|
||||||
|
|
||||||
Typical setup on debian wheezy
|
Typical setup on debian wheezy
|
||||||
==============================
|
==============================
|
||||||
|
|||||||
+7
-2
@@ -1,3 +1,4 @@
|
|||||||
|
|
||||||
#! /usr/bin/python
|
#! /usr/bin/python
|
||||||
# -*- coding: UTF-8 -*-
|
# -*- coding: UTF-8 -*-
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
@@ -144,6 +145,7 @@ class Provider(object):
|
|||||||
self.device_type=None
|
self.device_type=None
|
||||||
self.device_mac=None
|
self.device_mac=None
|
||||||
self.last_ip=None
|
self.last_ip=None
|
||||||
|
self.source_ip=None
|
||||||
|
|
||||||
self._gateway=gateway
|
self._gateway=gateway
|
||||||
|
|
||||||
@@ -185,7 +187,7 @@ conntrack v1.2.1 (conntrack-tools): 1 flow entries have been shown.
|
|||||||
|
|
||||||
|
|
||||||
def read_config(self,config_file):
|
def read_config(self,config_file):
|
||||||
for attrib in ['target_ip','device','gateway']:
|
for attrib in ['target_ip','device','gateway','source_ip']:
|
||||||
if config_file.has_option(self.provider_name,attrib):
|
if config_file.has_option(self.provider_name,attrib):
|
||||||
if attrib == 'gateway':
|
if attrib == 'gateway':
|
||||||
setattr(self,'_gateway',config_file.get(self.provider_name,attrib))
|
setattr(self,'_gateway',config_file.get(self.provider_name,attrib))
|
||||||
@@ -306,7 +308,9 @@ available == True if actual rtt and loss are below the max_rtt and max_loss
|
|||||||
IPV4ADDR = re.compile(r'\sinet\s+(?P<ipv4>\d+.\d+.\d+.\d+)[/\s]')
|
IPV4ADDR = re.compile(r'\sinet\s+(?P<ipv4>\d+.\d+.\d+.\d+)[/\s]')
|
||||||
MACADDR = re.compile(r'link/(?P<type>\S+)(\s(?P<mac>\S+))?')
|
MACADDR = re.compile(r'link/(?P<type>\S+)(\s(?P<mac>\S+))?')
|
||||||
ipaddr = IPV4ADDR.search(output)
|
ipaddr = IPV4ADDR.search(output)
|
||||||
if ipaddr:
|
if self.source_ip:
|
||||||
|
self.last_ip = self.source_ip
|
||||||
|
elif ipaddr:
|
||||||
self.last_ip = ipaddr.groupdict()['ipv4']
|
self.last_ip = ipaddr.groupdict()['ipv4']
|
||||||
else:
|
else:
|
||||||
self.last_ip = None
|
self.last_ip = None
|
||||||
@@ -476,6 +480,7 @@ available == True if actual rtt and loss are below the max_rtt and max_loss
|
|||||||
status = self.status,
|
status = self.status,
|
||||||
last_check_time = self.last_check_time,
|
last_check_time = self.last_check_time,
|
||||||
last_ip = self.last_ip,
|
last_ip = self.last_ip,
|
||||||
|
source_ip = self.source_ip,
|
||||||
device_mac = self.device_mac,
|
device_mac = self.device_mac,
|
||||||
device_type = self.device_type,
|
device_type = self.device_type,
|
||||||
gateway_alive = self.gateway_alive,
|
gateway_alive = self.gateway_alive,
|
||||||
|
|||||||
Reference in New Issue
Block a user