@@ -416,22 +416,19 @@ def set_dst(self, dst):
416416 def get_in_interface (self ):
417417 intf = ""
418418 if self .entry .ipv6 .invflags & ip6t_ip6 .IP6T_INV_VIA_IN :
419- intf = "" . join ([ "!" , intf ])
420- iface = bytearray ( _IFNAMSIZ )
421- iface [: len ( self . entry . ipv6 . iniface )] = self .entry .ipv6 .iniface
422- mask = bytearray ( _IFNAMSIZ )
423- mask [: len ( self . entry . ipv6 . iniface_mask )] = self . entry . ipv6 . iniface_mask
424- if mask [ 0 ] == 0 :
419+ intf = "!"
420+
421+ iface = self .entry .ipv6 .iniface . decode ()
422+ mask = self . entry . ipv6 . iniface_mask
423+
424+ if len ( mask ) == 0 :
425425 return None
426- for i in range (_IFNAMSIZ ):
427- if mask [i ] != 0 :
428- intf = "" .join ([intf , chr (iface [i ])])
429- else :
430- if iface [i - 1 ] != 0 :
431- intf = "" .join ([intf , "+" ])
432- else :
433- intf = intf [:- 1 ]
434- break
426+
427+ intf += iface
428+ if len (iface ) == len (mask ):
429+ intf += '+'
430+ intf = intf [:_IFNAMSIZ ]
431+
435432 return intf
436433
437434 def set_in_interface (self , intf ):
@@ -460,23 +457,19 @@ def set_in_interface(self, intf):
460457 def get_out_interface (self ):
461458 intf = ""
462459 if self .entry .ipv6 .invflags & ip6t_ip6 .IP6T_INV_VIA_OUT :
463- intf = "" .join (["!" , intf ])
464- iface = bytearray (_IFNAMSIZ )
465- iface [:len (self .entry .ipv6 .outiface )] = self .entry .ipv6 .outiface
466- mask = bytearray (_IFNAMSIZ )
467- mask [:len (self .entry .ipv6 .outiface_mask )] = \
468- self .entry .ipv6 .outiface_mask
469- if mask [0 ] == 0 :
460+ intf = "!"
461+
462+ iface = self .entry .ipv6 .outiface .decode ()
463+ mask = self .entry .ipv6 .outiface_mask
464+
465+ if len (mask ) == 0 :
470466 return None
471- for i in range (_IFNAMSIZ ):
472- if mask [i ] != 0 :
473- intf = "" .join ([intf , chr (iface [i ])])
474- else :
475- if iface [i - 1 ] != 0 :
476- intf = "" .join ([intf , "+" ])
477- else :
478- intf = intf [:- 1 ]
479- break
467+
468+ intf += iface
469+ if len (iface ) == len (mask ):
470+ intf += '+'
471+ intf = intf [:_IFNAMSIZ ]
472+
480473 return intf
481474
482475 def set_out_interface (self , intf ):
0 commit comments