From fc5436417b8f431c8635b6a785b024859eedd223 Mon Sep 17 00:00:00 2001 From: Lutz Wolf Date: Sat, 24 May 2014 23:45:21 +0200 Subject: [PATCH] Simplification --- lib/rex/socket.rb | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/lib/rex/socket.rb b/lib/rex/socket.rb index db8206ce75..e4aeb660ca 100644 --- a/lib/rex/socket.rb +++ b/lib/rex/socket.rb @@ -514,13 +514,13 @@ module Socket # Build ports array from port specification pspec.split(/,/).each do |item| + target = ports + item.strip! - if item.starts_with? '!' then - negate = true + if item.start_with? '!' item.delete! '!' - else - negate = false + target = remove end start, stop = item.split(/-/).map { |p| p.to_i } @@ -530,11 +530,7 @@ module Socket start, stop = stop, start if stop < start - if negate then - start.upto(stop) { |p| remove << p } - else - start.upto(stop) { |p| ports << p } - end + start.upto(stop) { |p| target << p } end if ports.empty? and not remove.empty? then