ipscanner 0.1.0 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. data/lib/ipscanner.rb +9 -0
  2. metadata +1 -1
@@ -6,6 +6,11 @@ require 'net/ping'
6
6
 
7
7
  class IPScanner
8
8
 
9
+ def initialize(ip_base='192.168.1.')
10
+ @a = []
11
+ (1..254).each{|i| Thread.new {ip = ip_base + i.to_s; a << i if Net::Ping::TCP.new(ip, 'http').ping?}}
12
+ end
13
+
9
14
  def self.run(ip_base='192.168.1.')
10
15
  a = []
11
16
  (1..254).each{|i| Thread.new {ip = ip_base + i.to_s; a << i if Net::Ping::TCP.new(ip, 'http').ping?}}
@@ -13,4 +18,8 @@ class IPScanner
13
18
  end
14
19
 
15
20
  def self.scan(ip_base='192.168.1.') self.run end
21
+
22
+ def to_a()
23
+ @a.sort.map{|x| ip_base + x.to_s}
24
+ end
16
25
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: ipscanner
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.0
5
+ version: 0.1.2
6
6
  platform: ruby
7
7
  authors: []
8
8