move up chain

This commit is contained in:
Stefan Midjich 2017-09-29 19:19:12 +02:00
parent 0356a57ba4
commit 88acc7752a
1 changed files with 9 additions and 10 deletions

View File

@ -8,7 +8,7 @@ from datetime import datetime, timedelta
import iptc import iptc
from errors import * from errors import StorageNotFound, IPTCRuleNotFound
class Client(object): class Client(object):
@ -32,11 +32,14 @@ class Client(object):
self.ip_address = kw.pop('ip_address') self.ip_address = kw.pop('ip_address')
self.protocol = kw.pop('protocol') self.protocol = kw.pop('protocol')
if self.ip_address and self.protocol: client_data = self.storage.get_client(
client_data = self.storage.get_client( self._ip_address,
self._ip_address, self.protocol
self.protocol )
)
# Init iptables
self.table = iptc.Table(iptc.Table.MANGLE)
self.chain = iptc.Chain(self.table, self._chain)
if client_data: if client_data:
self.load_client(client_data) self.load_client(client_data)
@ -50,10 +53,6 @@ class Client(object):
self.last_activity = None self.last_activity = None
self.expires = datetime.now() + timedelta(days=1) self.expires = datetime.now() + timedelta(days=1)
# Init iptables
self.table = iptc.Table(iptc.Table.MANGLE)
self.chain = iptc.Chain(self.table, self._chain)
def load_client(self, data): def load_client(self, data):
self.client_id = data.get('client_id') self.client_id = data.get('client_id')