ipscanner 0.1.2 → 0.1.3
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.
- data/lib/ipscanner.rb +6 -3
- metadata +2 -2
data/lib/ipscanner.rb
CHANGED
@@ -7,19 +7,22 @@ require 'net/ping'
|
|
7
7
|
class IPScanner
|
8
8
|
|
9
9
|
def initialize(ip_base='192.168.1.')
|
10
|
+
@ip_base = ip_base
|
10
11
|
@a = []
|
11
|
-
(1..254).
|
12
|
+
threads = (1..254).map{|i| Thread.new {ip = ip_base + i.to_s; @a << i if Net::Ping::TCP.new(ip, 'http').ping?}}
|
13
|
+
threads.join
|
12
14
|
end
|
13
15
|
|
14
16
|
def self.run(ip_base='192.168.1.')
|
15
17
|
a = []
|
16
|
-
(1..254).
|
18
|
+
threads = (1..254).map{|i| Thread.new {ip = ip_base + i.to_s; a << i if Net::Ping::TCP.new(ip, 'http').ping?}}
|
19
|
+
threads.join
|
17
20
|
a.sort.map{|x| ip_base + x.to_s}
|
18
21
|
end
|
19
22
|
|
20
23
|
def self.scan(ip_base='192.168.1.') self.run end
|
21
24
|
|
22
25
|
def to_a()
|
23
|
-
@a.sort.map{|x| ip_base + x.to_s}
|
26
|
+
@a.sort.map{|x| @ip_base + x.to_s}
|
24
27
|
end
|
25
28
|
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.
|
5
|
+
version: 0.1.3
|
6
6
|
platform: ruby
|
7
7
|
authors: []
|
8
8
|
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-04-
|
13
|
+
date: 2011-04-17 00:00:00 +01:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|