From 88acc7752ab61b98c5d5b136cee7883ec614b062 Mon Sep 17 00:00:00 2001 From: Stefan Midjich Date: Fri, 29 Sep 2017 19:19:12 +0200 Subject: [PATCH] move up chain --- tools/client.py | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/tools/client.py b/tools/client.py index 1028b02..b693e4b 100644 --- a/tools/client.py +++ b/tools/client.py @@ -8,7 +8,7 @@ from datetime import datetime, timedelta import iptc -from errors import * +from errors import StorageNotFound, IPTCRuleNotFound class Client(object): @@ -32,11 +32,14 @@ class Client(object): self.ip_address = kw.pop('ip_address') self.protocol = kw.pop('protocol') - if self.ip_address and self.protocol: - client_data = self.storage.get_client( - self._ip_address, - self.protocol - ) + client_data = self.storage.get_client( + self._ip_address, + self.protocol + ) + + # Init iptables + self.table = iptc.Table(iptc.Table.MANGLE) + self.chain = iptc.Chain(self.table, self._chain) if client_data: self.load_client(client_data) @@ -50,10 +53,6 @@ class Client(object): self.last_activity = None 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): self.client_id = data.get('client_id')