mirror of
https://github.com/DarrylNixon/drawbridge
synced 2024-04-22 12:17:07 -07:00
Swap back to MANGLE table, and remove extraneous
packet payload check since .mangle() accepts unchanged packets
This commit is contained in:
parent
7b487db1b2
commit
07decd8707
2 changed files with 11 additions and 10 deletions
|
@ -36,15 +36,16 @@ class DrawBridge:
|
|||
def run(self):
|
||||
asyncio.run(self.raise_bridges())
|
||||
|
||||
async def _listen(self, listener, callback: Callable) -> None:
|
||||
for packet in listener:
|
||||
original = packet.payload
|
||||
if asyncio.iscoroutinefunction(callback):
|
||||
packet.payload = await callback(packet.payload)
|
||||
else:
|
||||
packet.payload = callback(packet.payload)
|
||||
if packet.payload != original:
|
||||
async def _listen(self, connection, callback: Callable) -> None:
|
||||
try:
|
||||
for packet in connection:
|
||||
if asyncio.iscoroutinefunction(callback):
|
||||
packet.payload = await callback(packet.payload)
|
||||
else:
|
||||
packet.payload = callback(packet.payload)
|
||||
packet.mangle()
|
||||
except fnfqueue.BufferOverflowException:
|
||||
logger.warning("Packets arriving too quickly")
|
||||
|
||||
def _delete_rules(self):
|
||||
for queue in self.net_queues:
|
||||
|
|
|
@ -44,12 +44,12 @@ class NetQueue:
|
|||
return rule
|
||||
|
||||
def write_rule(self):
|
||||
table = iptc.Table(iptc.Table.NAT)
|
||||
table = iptc.Table(iptc.Table.MANGLE)
|
||||
chain = iptc.Chain(table, "PREROUTING")
|
||||
chain.insert_rule(self.rule)
|
||||
|
||||
def delete_rule(self):
|
||||
table = iptc.Table(iptc.Table.NAT)
|
||||
table = iptc.Table(iptc.Table.MANGLE)
|
||||
chain = iptc.Chain(table, "PREROUTING")
|
||||
try:
|
||||
chain.delete_rule(self.rule)
|
||||
|
|
Loading…
Reference in a new issue