Example #1
0
    def formatPlatformSrcDst(self, platform_networks):
        if self.chain != u"OUTPUT":
            if self.acl.source_platforms:
                sources = formatNetworks(platform_networks, "-s")
            else:
                sources = formatNetworks(self.acl.sources, "-s")
        else:
            sources = ((None, None),)

        if self.chain != u"INPUT":
            if self.acl.destination_platforms:
                destinations = formatNetworks(platform_networks, "-d")
            else:
                destinations = formatNetworks(self.acl.destinations, "-d")
        else:
            destinations = ((None, None),)

        for source, src_args in sources:
            for destination, dst_args in destinations:
                arguments = Arguments()
                if src_args:
                    arguments += src_args
                if dst_args:
                    arguments += dst_args
                arguments += formatIPsec(source, destination)
                yield arguments
Example #2
0
def formatSrcDst(resources, nat, chain):
    if chain == 'PREROUTING':
        ipsec_direction = 'in'
    else:
        ipsec_direction = 'out'
    sources = formatNetworks(resources, nat, chain, True)
    destinations = formatNetworks(resources, nat, chain, False)
    for source, src_args in sources:
        for destination, dst_args in destinations:
            args = Arguments()
            if src_args:
                args += src_args
            if dst_args:
                args += dst_args
            args += formatIPsec(source, destination, ipsec_direction)
            yield args