pstream 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1f289cf0eedd318903ec265932fd3e3779e4745e
4
- data.tar.gz: d4264b9311f20607bce36781efd16e39873ea934
3
+ metadata.gz: 317b451646cd84872f05c59d592c0ffb57cc2f9b
4
+ data.tar.gz: 4b65c4f947e2f27384383a5bfc54bcb718bd67bb
5
5
  SHA512:
6
- metadata.gz: 6d6038f01b788a5fab2cde585580d4b17d4fc439ef9164ef4b8755559b555969adf0fd63f57f53cfc08beb1aab91180aedd768191c95093cfe5159208fa23f12
7
- data.tar.gz: 5449e1fa140f5ee3942caf67c14aa7ab4d0814098f861b51ef17eb637c6865dbec4561fcb7ace8aba4003155c31818357455d94f006f7f6dd7617fc920462980
6
+ metadata.gz: c1718f9134683f46ae6167197b8d1cdfa87f45529b1378cbb8a2a3d3aa842eb9d1774e88360c7bcd5fad5e0dbdf5866c71cac061026a437c86cc8ae81a567060
7
+ data.tar.gz: 22bd61ba3713ba428992a0f0895845494a52d2a82b5b74cc801f79bc614e2371e995b69129c3df62bc0f5e54392c33732196d067db34ed4fc3511a5a0c2e54bd
data/lib/pstream.rb CHANGED
@@ -63,8 +63,7 @@ class PStream
63
63
  self,
64
64
  ipv,
65
65
  src,
66
- dst,
67
- @colorize
66
+ dst
68
67
  )
69
68
  end
70
69
  end
@@ -78,8 +77,13 @@ class PStream
78
77
  return negotiations.values
79
78
  end
80
79
 
80
+ def self.colorize?
81
+ @@colorize ||= false
82
+ return @@colorize
83
+ end
84
+
81
85
  def colorize_cipher_suite(suite)
82
- return suite if (!@colorize)
86
+ return suite if (!@@colorize)
83
87
 
84
88
  case suite
85
89
  when /Unknown/
@@ -98,12 +102,12 @@ class PStream
98
102
  end
99
103
 
100
104
  def colorize_header(header)
101
- return header if (!@colorize)
105
+ return header if (!@@colorize)
102
106
  return header.light_cyan
103
107
  end
104
108
 
105
109
  def colorize_stream(stream)
106
- if (!@colorize)
110
+ if (!@@colorize)
107
111
  return "#{stream.id} | #{stream.desc} | #{stream.frames}"
108
112
  end
109
113
  return [
@@ -159,14 +163,7 @@ class PStream
159
163
  ).split("\n").each do |line|
160
164
  desc, frames = line.split(" | ")
161
165
  streams.push(
162
- Stream.new(
163
- @pcap,
164
- prot,
165
- count,
166
- desc,
167
- frames,
168
- @colorize
169
- )
166
+ Stream.new(@pcap, prot, count, desc, frames)
170
167
  )
171
168
  count += 1
172
169
  end
@@ -176,12 +173,11 @@ class PStream
176
173
  private :get_streams
177
174
 
178
175
  def initialize(pcap, colorize = false)
179
- @colorize = colorize
180
-
181
176
  if (ScoobyDoo.where_are_you("tshark").nil?)
182
177
  raise PStream::Error::TsharkNotFound.new
183
178
  end
184
179
 
180
+ @@colorize = colorize
185
181
  @pcap = Pathname.new(pcap).expand_path
186
182
 
187
183
  if (!@pcap.exist?)
@@ -9,12 +9,12 @@ class PStream::CipherNegotiation
9
9
  attr_reader :src
10
10
 
11
11
  def colorize_hosts(src, dst)
12
- return "#{src} <-> #{dst}" if (!@colorize)
12
+ return "#{src} <-> #{dst}" if (!PStream.colorize?)
13
13
  return "#{src} <-> #{dst}".light_cyan
14
14
  end
15
15
 
16
16
  def colorize_ipv(ipv)
17
- return "IPv#{ipv}" if (!@colorize)
17
+ return "IPv#{ipv}" if (!PStream.colorize?)
18
18
  return "IPv#{ipv}".light_cyan
19
19
  end
20
20
 
@@ -26,8 +26,7 @@ class PStream::CipherNegotiation
26
26
  ].join(" ")
27
27
  end
28
28
 
29
- def initialize(pstream, ipv, src, dst, colorize)
30
- @colorize = colorize
29
+ def initialize(pstream, ipv, src, dst)
31
30
  @dst = dst
32
31
  @ipv = ipv
33
32
  @length = nil
@@ -4,17 +4,17 @@ class PStream::Stream
4
4
  attr_reader :id
5
5
 
6
6
  def colorize_address(address)
7
- return address if (!@colorize)
7
+ return address if (!PStream.colorize?)
8
8
  return address.light_blue
9
9
  end
10
10
 
11
11
  def colorize_ascii(ascii)
12
- return ascii if (!@colorize)
12
+ return ascii if (!PStream.colorize?)
13
13
  return ascii.light_white
14
14
  end
15
15
 
16
16
  def colorize_hex(hex)
17
- return hex if (!@colorize)
17
+ return hex if (!PStream.colorize?)
18
18
  return hex.light_green
19
19
  end
20
20
 
@@ -46,8 +46,7 @@ class PStream::Stream
46
46
  return ret.join("\n")
47
47
  end
48
48
 
49
- def initialize(pcap, prot, id, desc, frames, colorize = false)
50
- @colorize = colorize
49
+ def initialize(pcap, prot, id, desc, frames)
51
50
  @desc = desc
52
51
  @frames = frames
53
52
  @id = id
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pstream
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miles Whittaker
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-08 00:00:00.000000000 Z
11
+ date: 2016-03-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake