Skip to content

Commit

Permalink
Fixing iptc import issue
Browse files Browse the repository at this point in the history
  • Loading branch information
jeeva-duplo committed Nov 26, 2024
1 parent 1406973 commit e99f1b7
Showing 1 changed file with 0 additions and 40 deletions.
40 changes: 0 additions & 40 deletions AgentUbuntu22/NetworkAgentV2.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import json
import argparse
import logging
import iptc
import sys
import traceback
import os
Expand Down Expand Up @@ -150,45 +149,6 @@ def updateTunnels(aInRemoteMinions, aInLocalMinion):

return

def addNetfilter(aInChain, aInRule, aInBlock):
rule = iptc.Rule()
match = rule.create_match("comment")
match.comment = aInRule['Name']

rule.dst = aInRule['DestAddress']

if aInRule['SrcAddress']:
rule.src = aInRule['SrcAddress']
if aInRule['Protocol']:
rule.protocol = aInRule['Protocol']
if aInRule['BeginPort']:
match = iptc.Match(rule, aInRule['Protocol'])
match.dport = aInRule['BeginPort'] + ":" + aInRule['EndPort']
rule.add_match(match)

if aInBlock:
rule.target = rule.create_target("DROP")
aInChain.append_rule(rule)
else:
rule.target = rule.create_target("ACCEPT")
aInChain.insert_rule(rule)

def deleteNetfilter(aInRuleName):
table = iptc.Table(iptc.Table.FILTER)

for chain in table.chains:
if not str(chain.name) == 'FORWARD':
continue
for rule in chain.rules:
for match in rule.matches:
if str(match.name) == 'comment':
lRName = str(match.comment)
if lRName == aInRuleName:
logger.debug('DELETING RULE: ' + lRName)
chain.delete_rule(rule)
break
break

def updateTopology():
global TenantID
global NetworkProvider
Expand Down

0 comments on commit e99f1b7

Please sign in to comment.