From 5c25bfd90817980e81e792375011ff69de3b19c8 Mon Sep 17 00:00:00 2001 From: adfoster-r7 Date: Thu, 25 Jan 2024 12:33:05 +0000 Subject: [PATCH] Fix flakey opt address local spec --- spec/lib/msf/core/opt_address_local_spec.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/spec/lib/msf/core/opt_address_local_spec.rb b/spec/lib/msf/core/opt_address_local_spec.rb index cc25b0deeba2..4f03fd6af744 100644 --- a/spec/lib/msf/core/opt_address_local_spec.rb +++ b/spec/lib/msf/core/opt_address_local_spec.rb @@ -8,11 +8,14 @@ IPAddr.new(addr).ipv4? && !addr[/^127.*/] rescue IPAddr::InvalidAddressError false + end.sort_by do |addr| + ip_addr = IPAddr.new(addr) + [ip_addr.ipv4? ? 0 : 1, ip_addr.to_i] end.first { name: iface, addr: ip_address } end.select { |name_addr| name_addr[:addr] }.sort_by do |name_addr| ip_addr = IPAddr.new(name_addr[:addr]) - [ip_addr.ipv4?, ip_addr.to_i] + [ip_addr.ipv4? ? 0 : 1, ip_addr.to_i] end.first valid_values = [