cloudscopes 0.8.4 → 0.8.5

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6371f55a201b9ad741cdf6493457b360fa95b458
4
- data.tar.gz: 231dc3c897202760f506708dd6000f72d4766c0a
3
+ metadata.gz: 896860a3ed3e33fa6b4579ddd4ca42e2b6a4e538
4
+ data.tar.gz: 4085d36fc4bbed8cd1139f52f293960bda48779a
5
5
  SHA512:
6
- metadata.gz: 4094a791c39815e682bee734575155b9d483c66726647ff9c89bfc891c60d15dad019889ab3fe1f07f9a354dfff5d94a50ababb3a15f62e4865bb4dd66107ccb
7
- data.tar.gz: 8469285fe88ba5f1b3dd006806ea6234481bfa1e3494adc19e4498986385b4f7af09676240f849d6086d6c9e1910410273b26658067cc4bda4d93fec66488425
6
+ metadata.gz: a87ec652859080d22b716f18a7ad2538f8a230411ba1e3181e5ba58ba02cadc8023d662269d7362b27e290f3909ecd305ef6c50d41b9efb0893c764ffb5f03bf
7
+ data.tar.gz: f04c864b934dac1299ca1997e7252fb1abb23576c3b26fd5b8724b0178f07c859c83ab6961f800f974911e439e9db821fb7f109b07aab711eb768614feaca10c
@@ -24,6 +24,31 @@ module Cloudscopes
24
24
  end
25
25
  end
26
26
 
27
+ def proc_ip_hex_to_dotted(hexstr)
28
+ hexstr.scan(/../).map(&:hex).reverse*"."
29
+ end
30
+
31
+ def sockets
32
+ File.read("/proc/net/tcp").split("\n").drop(1).collect do |l|
33
+ l.strip.split(/\s+/)
34
+ end.collect do |s|
35
+ s[1..2] = s[1].split(/:/) + s[2].split(/:/) # split local/remote addresses to ip and port as separate fields
36
+ s[1] = proc_ip_hex_to_dotted(s[1])
37
+ s[2] = s[2].to_i(16)
38
+ s[3] = proc_ip_hex_to_dotted(s[3])
39
+ s[4] = s[4].to_i(16)
40
+ s.drop(1) # drop the index
41
+ end
42
+ end
43
+
44
+ def open_server_ports(port)
45
+ sockets.select do |s|
46
+ s[4].to_i == 1 # only established sockets
47
+ end.select do |s|
48
+ s[1] == port
49
+ end
50
+ end
51
+
27
52
  end
28
53
 
29
- end
54
+ end
@@ -1,3 +1,3 @@
1
1
  module Cloudscopes
2
- VERSION = "0.8.4"
2
+ VERSION = "0.8.5"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cloudscopes
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.4
4
+ version: 0.8.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oded Arbel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-28 00:00:00.000000000 Z
11
+ date: 2014-09-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk