@@ -418,28 +418,32 @@ def insync?(context, _name, property_name, is_hash, should_hash)
418418 when :dport , :sport , :state , :ctstate , :ctstatus
419419 is = is_hash [ property_name ]
420420 should = should_hash [ property_name ]
421+ ports = [ :dport , :sport ]
422+
423+ if is . is_a? ( Array ) && should . is_a? ( Array )
424+ # Ensure values are sorted
425+ # Ensure any negation includes only the first value
426+ is_negated = true if %r{^!\s } . match? ( is [ 0 ] . to_s )
427+ is . each_with_index do |_value , _index |
428+ is = is . map { |value | value . to_s . tr ( '! ' , '' ) } . sort
429+ end
430+ is [ 0 ] = [ '!' , is [ 0 ] ] . join ( ' ' ) if is_negated
421431
422- # Unique logic is only needed when both values are arrays
423- return nil unless is . is_a? ( Array ) && should . is_a? ( Array )
424-
425- # Ensure values are sorted
426- # Ensure any negation includes only the first value
427- is_negated = true if %r{^!\s } . match? ( is [ 0 ] . to_s )
428- is . each_with_index do |_value , _index |
429- is = is . map { |value | value . to_s . tr ( '! ' , '' ) } . sort
430- end
431- is [ 0 ] = [ '!' , is [ 0 ] ] . join ( ' ' ) if is_negated
432+ should_negated = true if %r{^!\s } . match? ( should [ 0 ] . to_s )
433+ should . each_with_index do |_value , _index |
434+ should = should . map { |value | value . to_s . tr ( '! ' , '' ) } . sort
435+ # Port range can be passed as `-` but will always be set/returned as `:`
436+ should = should . map { |value | value . to_s . tr ( '-' , ':' ) } . sort if ports . include? ( property_name )
437+ end
438+ should [ 0 ] = [ '!' , should [ 0 ] ] . join ( ' ' ) if should_negated
432439
433- should_negated = true if %r{^!\s } . match? ( should [ 0 ] . to_s )
434- should . each_with_index do |_value , _index |
435- should = should . map { |value | value . to_s . tr ( '! ' , '' ) } . sort
440+ is == should
441+ elsif is . is_a? ( String ) && should . is_a? ( String )
436442 # Port range can be passed as `-` but will always be set/returned as `:`
437- ports = [ :dport , :sport ]
438- should = should . map { |value | value . to_s . tr ( '-' , ':' ) } . sort if ports . include? ( property_name )
439- end
440- should [ 0 ] = [ '!' , should [ 0 ] ] . join ( ' ' ) if should_negated
443+ should = should . tr ( '-' , ':' ) if ports . include? ( property_name )
441444
442- is == should
445+ is == should
446+ end
443447 when :string_hex
444448 # Compare the values with any whitespace removed
445449 is = is_hash [ property_name ] . to_s . gsub ( %r{\s +} , '' )
0 commit comments