Browse Source

disable undefined ipfilter construction

disable-ipfilter
ghost 11 months ago
parent
commit
3ffc59b886
  1. 12
      pymaster.py

12
pymaster.py

@ -12,7 +12,7 @@ from ipaddress import ip_address, ip_network
from server_entry import ServerEntry from server_entry import ServerEntry
from protocol import MasterProtocol from protocol import MasterProtocol
import ipfilter # import ipfilter
LOG_FILENAME = 'pymaster.log' LOG_FILENAME = 'pymaster.log'
MAX_SERVERS_FOR_IP = 14 MAX_SERVERS_FOR_IP = 14
@ -66,7 +66,7 @@ class PyMaster:
self.serverList = [] self.serverList = []
self.serverRL = IPRateLimit('server', 60, 30) self.serverRL = IPRateLimit('server', 60, 30)
self.clientRL = IPRateLimit('client', 60, 120) self.clientRL = IPRateLimit('client', 60, 120)
self.ipfilterRL = IPRateLimit('filterlog', 60, 10) # self.ipfilterRL = IPRateLimit('filterlog', 60, 10)
self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
self.sock.bind((ip, port)) self.sock.bind((ip, port))
@ -77,10 +77,10 @@ class PyMaster:
def serverLoop(self): def serverLoop(self):
data, addr = self.sock.recvfrom(1024) data, addr = self.sock.recvfrom(1024)
if ip_address(addr[0]) in ipfilter.ipfilter: # if ip_address(addr[0]) in ipfilter.ipfilter:
if not self.ipfilterRL.ratelimit(addr[0]): # if not self.ipfilterRL.ratelimit(addr[0]):
log('Filter: %s:%d' % (addr[0], addr[1])) # log('Filter: %s:%d' % (addr[0], addr[1]))
return # return
if len(data) == 0: if len(data) == 0:
return return

Loading…
Cancel
Save