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):
|
def run(self):
|
||||||
asyncio.run(self.raise_bridges())
|
asyncio.run(self.raise_bridges())
|
||||||
|
|
||||||
async def _listen(self, listener, callback: Callable) -> None:
|
async def _listen(self, connection, callback: Callable) -> None:
|
||||||
for packet in listener:
|
try:
|
||||||
original = packet.payload
|
for packet in connection:
|
||||||
if asyncio.iscoroutinefunction(callback):
|
if asyncio.iscoroutinefunction(callback):
|
||||||
packet.payload = await callback(packet.payload)
|
packet.payload = await callback(packet.payload)
|
||||||
else:
|
else:
|
||||||
packet.payload = callback(packet.payload)
|
packet.payload = callback(packet.payload)
|
||||||
if packet.payload != original:
|
|
||||||
packet.mangle()
|
packet.mangle()
|
||||||
|
except fnfqueue.BufferOverflowException:
|
||||||
|
logger.warning("Packets arriving too quickly")
|
||||||
|
|
||||||
def _delete_rules(self):
|
def _delete_rules(self):
|
||||||
for queue in self.net_queues:
|
for queue in self.net_queues:
|
||||||
|
|
|
@ -44,12 +44,12 @@ class NetQueue:
|
||||||
return rule
|
return rule
|
||||||
|
|
||||||
def write_rule(self):
|
def write_rule(self):
|
||||||
table = iptc.Table(iptc.Table.NAT)
|
table = iptc.Table(iptc.Table.MANGLE)
|
||||||
chain = iptc.Chain(table, "PREROUTING")
|
chain = iptc.Chain(table, "PREROUTING")
|
||||||
chain.insert_rule(self.rule)
|
chain.insert_rule(self.rule)
|
||||||
|
|
||||||
def delete_rule(self):
|
def delete_rule(self):
|
||||||
table = iptc.Table(iptc.Table.NAT)
|
table = iptc.Table(iptc.Table.MANGLE)
|
||||||
chain = iptc.Chain(table, "PREROUTING")
|
chain = iptc.Chain(table, "PREROUTING")
|
||||||
try:
|
try:
|
||||||
chain.delete_rule(self.rule)
|
chain.delete_rule(self.rule)
|
||||||
|
|
Loading…
Reference in a new issue