(net_if, cmd)
return False
Check if an iptables rule for UDP is already configured

    Args:
        net_if : network interface name
        cmd    : list with iptables command

    Returns:
        True if rule is already set, False otherwise.
Check if an iptables rule for UDP is already configured
Check if an iptables rule for UDP is already configured
def _is_iptables_udp_rule_set(net_if, cmd):
    """Check if an iptables rule for UDP is already configured

    Args:
        net_if : network interface name
        cmd    : list with iptables command

    Returns:
        True if rule is already set, False otherwise.

    """
    assert (cmd[0] != "sudo")
    for rule in _get_iptables_rules(net_if):
        if (rule['rule'][3] == "ACCEPT" and rule['rule'][6] == cmd[6]
                and rule['rule'][4] == "udp" and rule['rule'][12] == cmd[10]):
            print("\nFirewall rule already configured\n")
            print(rule['header1'])
            print(rule['header2'])
            print(" ".join(rule['rule']))
            print("\nSkipping...")
            return True

    return False
def _is_iptables_udp_rule_set ( net_if , cmd ) : assert ( cmd [ 0 ] != "sudo" ) for rule in _get_iptables_rules ( net_if ) : if ( rule [ 'rule' ] [ 3 ] == "ACCEPT" and rule [ 'rule' ] [ 6 ] == cmd [ 6 ] and rule [ 'rule' ] [ 4 ] == "udp" and rule [ 'rule' ] [ 12 ] == cmd [ 10 ] ) : print ( "\nFirewall rule already configured\n" ) print ( rule [ 'header1' ] ) print ( rule [ 'header2' ] ) print ( " " . join ( rule [ 'rule' ] ) ) print ( "\nSkipping..." ) return True return False