@@ -412,22 +412,19 @@ def set_dst(self, dst):
412412 def get_in_interface (self ):
413413 intf = ""
414414 if self .entry .ipv6 .invflags & ip6t_ip6 .IP6T_INV_VIA_IN :
415- intf = "" . join ([ "!" , intf ])
416- iface = bytearray ( _IFNAMSIZ )
417- iface [: len ( self . entry . ipv6 . iniface )] = self .entry .ipv6 .iniface
418- mask = bytearray ( _IFNAMSIZ )
419- mask [: len ( self . entry . ipv6 . iniface_mask )] = self . entry . ipv6 . iniface_mask
420- if mask [ 0 ] == 0 :
415+ intf = "!"
416+
417+ iface = self .entry .ipv6 .iniface . decode ()
418+ mask = self . entry . ipv6 . iniface_mask
419+
420+ if len ( mask ) == 0 :
421421 return None
422- for i in range (_IFNAMSIZ ):
423- if mask [i ] != 0 :
424- intf = "" .join ([intf , chr (iface [i ])])
425- else :
426- if iface [i - 1 ] != 0 :
427- intf = "" .join ([intf , "+" ])
428- else :
429- intf = intf [:- 1 ]
430- break
422+
423+ intf += iface
424+ if len (iface ) == len (mask ):
425+ intf += '+'
426+ intf = intf [:_IFNAMSIZ ]
427+
431428 return intf
432429
433430 def set_in_interface (self , intf ):
@@ -456,23 +453,19 @@ def set_in_interface(self, intf):
456453 def get_out_interface (self ):
457454 intf = ""
458455 if self .entry .ipv6 .invflags & ip6t_ip6 .IP6T_INV_VIA_OUT :
459- intf = "" .join (["!" , intf ])
460- iface = bytearray (_IFNAMSIZ )
461- iface [:len (self .entry .ipv6 .outiface )] = self .entry .ipv6 .outiface
462- mask = bytearray (_IFNAMSIZ )
463- mask [:len (self .entry .ipv6 .outiface_mask )] = \
464- self .entry .ipv6 .outiface_mask
465- if mask [0 ] == 0 :
456+ intf = "!"
457+
458+ iface = self .entry .ipv6 .outiface .decode ()
459+ mask = self .entry .ipv6 .outiface_mask
460+
461+ if len (mask ) == 0 :
466462 return None
467- for i in range (_IFNAMSIZ ):
468- if mask [i ] != 0 :
469- intf = "" .join ([intf , chr (iface [i ])])
470- else :
471- if iface [i - 1 ] != 0 :
472- intf = "" .join ([intf , "+" ])
473- else :
474- intf = intf [:- 1 ]
475- break
463+
464+ intf += iface
465+ if len (iface ) == len (mask ):
466+ intf += '+'
467+ intf = intf [:_IFNAMSIZ ]
468+
476469 return intf
477470
478471 def set_out_interface (self , intf ):
0 commit comments