initial sweeping changes to call all usages of various interface related variables and functions (netif, interface, if, ifc, etc) to use a consistent name iface
This commit is contained in:
parent
0462c1b084
commit
0725199d6d
93 changed files with 1955 additions and 2156 deletions
|
@ -131,18 +131,18 @@ class Nat(CoreService):
|
|||
custom_needed = False
|
||||
|
||||
@classmethod
|
||||
def generateifcnatrule(cls, ifc, line_prefix=""):
|
||||
def generate_iface_nat_rule(cls, iface, line_prefix=""):
|
||||
"""
|
||||
Generate a NAT line for one interface.
|
||||
"""
|
||||
cfg = line_prefix + "iptables -t nat -A POSTROUTING -o "
|
||||
cfg += ifc.name + " -j MASQUERADE\n"
|
||||
cfg += iface.name + " -j MASQUERADE\n"
|
||||
|
||||
cfg += line_prefix + "iptables -A FORWARD -i " + ifc.name
|
||||
cfg += line_prefix + "iptables -A FORWARD -i " + iface.name
|
||||
cfg += " -m state --state RELATED,ESTABLISHED -j ACCEPT\n"
|
||||
|
||||
cfg += line_prefix + "iptables -A FORWARD -i "
|
||||
cfg += ifc.name + " -j DROP\n"
|
||||
cfg += iface.name + " -j DROP\n"
|
||||
return cfg
|
||||
|
||||
@classmethod
|
||||
|
@ -154,14 +154,12 @@ class Nat(CoreService):
|
|||
cfg += "# generated by security.py\n"
|
||||
cfg += "# NAT out the first interface by default\n"
|
||||
have_nat = False
|
||||
for ifc in node.netifs():
|
||||
if hasattr(ifc, "control") and ifc.control is True:
|
||||
continue
|
||||
for iface in node.get_ifaces(control=False):
|
||||
if have_nat:
|
||||
cfg += cls.generateifcnatrule(ifc, line_prefix="#")
|
||||
cfg += cls.generate_iface_nat_rule(iface, line_prefix="#")
|
||||
else:
|
||||
have_nat = True
|
||||
cfg += "# NAT out the " + ifc.name + " interface\n"
|
||||
cfg += cls.generateifcnatrule(ifc)
|
||||
cfg += "# NAT out the " + iface.name + " interface\n"
|
||||
cfg += cls.generate_iface_nat_rule(iface)
|
||||
cfg += "\n"
|
||||
return cfg
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue