@@ -11,21 +11,21 @@ def flush_all(ipv6=False):
1111 for table in get_tables (ipv6 ):
1212 flush_table (table , ipv6 )
1313
14- def flush_table (table , ipv6 = False , silent = False ):
14+ def flush_table (table , ipv6 = False , raise_exc = True ):
1515 """ Flush a table """
1616 try :
1717 iptc_table = _iptc_gettable (table , ipv6 )
1818 iptc_table .flush ()
1919 except Exception as e :
20- if not silent : raise
20+ if raise_exc : raise
2121
22- def flush_chain (table , chain , ipv6 = False , silent = False ):
22+ def flush_chain (table , chain , ipv6 = False , raise_exc = True ):
2323 """ Flush a chain in table """
2424 try :
2525 iptc_chain = _iptc_getchain (table , chain , ipv6 )
2626 iptc_chain .flush ()
2727 except Exception as e :
28- if not silent : raise
28+ if raise_exc : raise
2929
3030def zero_all (table , ipv6 = False ):
3131 """ Zero all tables """
@@ -53,14 +53,14 @@ def has_rule(table, chain, rule_d, ipv6=False):
5353 iptc_rule = _encode_iptc_rule (rule_d , ipv6 )
5454 return iptc_rule in iptc_chain .rules
5555
56- def add_chain (table , chain , ipv6 = False , silent = False ):
56+ def add_chain (table , chain , ipv6 = False , raise_exc = True ):
5757 """ Return True if chain was added successfully to a table, raise Exception otherwise """
5858 try :
5959 iptc_table = _iptc_gettable (table , ipv6 )
6060 iptc_table .create_chain (chain )
6161 return True
6262 except Exception as e :
63- if not silent : raise
63+ if raise_exc : raise
6464 return False
6565
6666def add_rule (table , chain , rule_d , position = 0 , ipv6 = False ):
@@ -86,24 +86,24 @@ def insert_rule(table, chain, rule_d, ipv6=False):
8686 """ Add a rule to a chain in the 1st position """
8787 add_rule (table , chain , rule_d , position = 1 , ipv6 = ipv6 )
8888
89- def delete_chain (table , chain , ipv6 = False , flush = False , silent = False ):
89+ def delete_chain (table , chain , ipv6 = False , flush = False , raise_exc = True ):
9090 """ Delete a chain """
9191 try :
9292 if flush :
93- flush_chain (table , chain , ipv6 , silent )
93+ flush_chain (table , chain , ipv6 , raise_exc )
9494 iptc_table = _iptc_gettable (table , ipv6 )
9595 iptc_table .delete_chain (chain )
9696 except Exception as e :
97- if not silent : raise
97+ if raise_exc : raise
9898
99- def delete_rule (table , chain , rule_d , ipv6 = False , silent = False ):
99+ def delete_rule (table , chain , rule_d , ipv6 = False , raise_exc = True ):
100100 """ Delete a rule from a chain """
101101 try :
102102 iptc_chain = _iptc_getchain (table , chain , ipv6 )
103103 iptc_rule = _encode_iptc_rule (rule_d , ipv6 )
104104 iptc_chain .delete_rule (iptc_rule )
105105 except Exception as e :
106- if not silent : raise
106+ if raise_exc : raise
107107
108108def get_tables (ipv6 = False ):
109109 """ Get all tables """
@@ -115,7 +115,7 @@ def get_chains(table, ipv6=False):
115115 iptc_table = _iptc_gettable (table , ipv6 )
116116 return [iptc_chain .name for iptc_chain in iptc_table .chains ]
117117
118- def get_rule (table , chain , position = 0 , ipv6 = False , silent = False ):
118+ def get_rule (table , chain , position = 0 , ipv6 = False , raise_exc = True ):
119119 """ Get a rule from a chain in a given position. 0=all rules, 1=first, n=nth position """
120120 try :
121121 if position == 0 :
@@ -132,7 +132,7 @@ def get_rule(table, chain, position=0, ipv6=False, silent=False):
132132 iptc_rule = iptc_chain .rules [position ]
133133 return _decode_iptc_rule (iptc_rule , ipv6 )
134134 except Exception as e :
135- if not silent : raise
135+ if raise_exc : raise
136136
137137def replace_rule (table , chain , old_rule_d , new_rule_d , ipv6 = False ):
138138 """ Replaces an existing rule of a chain """
@@ -272,7 +272,7 @@ def batch_add_rules(table, batch_rules, ipv6=False):
272272 iptc_chain .insert_rule (iptc_rule , position + nof_rules )
273273 _batch_end_table (table , ipv6 )
274274
275- def batch_delete_rules (table , batch_rules , ipv6 = False , silent = True ):
275+ def batch_delete_rules (table , batch_rules , ipv6 = False , raise_exc = True ):
276276 """ Delete multiple rules from table with format (chain, rule_d) """
277277 try :
278278 iptc_table = _batch_begin_table (table , ipv6 )
@@ -282,7 +282,7 @@ def batch_delete_rules(table, batch_rules, ipv6=False, silent=True):
282282 iptc_chain .delete_rule (iptc_rule )
283283 _batch_end_table (table , ipv6 )
284284 except Exception as e :
285- if not silent : raise
285+ if raise_exc : raise
286286
287287
288288### INTERNAL FUNCTIONS ###
@@ -307,15 +307,15 @@ def _iptc_gettable(table, ipv6=False):
307307 iptc_table .refresh ()
308308 return iptc_table
309309
310- def _iptc_getchain (table , chain , ipv6 = False , silent = False ):
310+ def _iptc_getchain (table , chain , ipv6 = False , raise_exc = True ):
311311 """ Return an iptc_chain of an updated table """
312312 try :
313313 iptc_table = _iptc_gettable (table , ipv6 )
314314 if not iptc_table .is_chain (chain ):
315315 raise AttributeError ('Table <{}> has no chain <{}>' .format (table , chain ))
316316 return Chain (iptc_table , chain )
317317 except Exception as e :
318- if not silent : raise
318+ if raise_exc : raise
319319
320320def _iptc_setattr (object , name , value ):
321321 # Translate attribute name
0 commit comments