def add_local_bypass(table, chain, ipv6):
    """Add rules to skip anything destined for a local address
    to avoid breaking connections to ourselves, otherwise we might break
    SSH and that would be bad if ngtf is running on a remote server.
    """
    run_iptables_cmd(
            "-t %s -A %s -p tcp -m socket -j RETURN" % (table, chain), ipv6=ipv6)

    v4_addrs, v6_addrs = get_interface_addresses()
    for addr in v4_addrs:
        run_iptables_cmd(
                "-t %s -A %s -p tcp -d %s -j RETURN" % (table, chain, addr),
                ipv6=False)
    for addr in v6_addrs:
        run_iptables_cmd(
                "-t %s -A %s -p tcp -d %s -j RETURN" % (table, chain, addr),
                ipv4=False, ipv6=ipv6)
dataset/ETHPy150Open google/nogotofail/nogotofail/mitm/util/routing.py/add_local_bypass/original