Class: FastPortScanner
- Inherits:
-
Object
- Object
- FastPortScanner
- Defined in:
- lib/fast_port_scanner.rb
Class Method Summary collapse
Class Method Details
.scan(ip = '127.0.0.1', ports: 1..1000, wait: 1.25) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/fast_port_scanner.rb', line 11 def self.scan(ip='127.0.0.1', ports: 1..1000, wait: 1.25) a = [] ports.map do |port| Thread.new do begin Timeout::timeout(1){TCPSocket.new(ip, port)} rescue #puts "closed : #{port}" else #puts "open : #{port}" a << port end end end.join sleep wait @to_a = a.sort end |