rex-core 0.1.16 → 0.1.20

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
  SHA256:
3
- metadata.gz: 17110a74336ae634771add814eed9e60a711005641b6424a482d057bbb7314bd
4
- data.tar.gz: 788d7cb8332f1cd817fbbf6de0da93ef7dbc92906f4c31706ca38de433812ef8
3
+ metadata.gz: cacc2616718c8056c7ff5ecf2626562f71ac9efd0a6ae69c80cd21565824b666
4
+ data.tar.gz: e6ed793586462b6cc826be77b533030e45a7bce1ae4fd0bdb2cbaf62ed6e17dd
5
5
  SHA512:
6
- metadata.gz: 6873be6d3d89644c9285d06e6966aa05f0604b09564b865ebf9fd70339c99d9b3fb0320e92ebedc3e378983956faed6cb5089c69d1bb0fe6d751252d0bfc45ab
7
- data.tar.gz: 678096caf324f23b4937f4607ed336c66ac7916fd7417197288b6c07ef70d18cc870b8780f5d119d74b2a1eb9d2d0274fe9df38b8033bcfa989b7c0d3be9bb0c
6
+ metadata.gz: a7367cb540a9638f4f64e5756f3c9761e3ebe05f15444ee2d4ae8e6f6af94888f50e2813cc89e7ef3bc7492335f20c31ccc98c8c3ba4b2a55e61995b174c8497
7
+ data.tar.gz: 4dbd3f07ec237c23ca088bbbdc2f67e2a59bcf5167bcebe841550877fc99f1e81ef3a9c763ddb9c7d8478844676e08ee3f706188c721049be00fbe2b3350ef89
checksums.yaml.gz.sig CHANGED
Binary file
@@ -1,5 +1,5 @@
1
1
  module Rex
2
2
  module Core
3
- VERSION = "0.1.16"
3
+ VERSION = "0.1.20"
4
4
  end
5
5
  end
@@ -145,9 +145,10 @@ end
145
145
  #
146
146
  ###
147
147
  module HostCommunicationError
148
- def initialize(addr = nil, port = nil)
149
- self.host = addr
150
- self.port = port
148
+ def initialize(addr = nil, port = nil, reason: nil)
149
+ @host = addr
150
+ @port = port
151
+ @reason = reason
151
152
  end
152
153
 
153
154
  #
@@ -156,7 +157,7 @@ module HostCommunicationError
156
157
  #
157
158
  def addr_to_s
158
159
  if host and port
159
- "(#{host}:#{port})"
160
+ host.include?(':') ? "([#{host}]:#{port})" : "(#{host}:#{port})"
160
161
  elsif host
161
162
  "(#{host})"
162
163
  else
@@ -164,7 +165,13 @@ module HostCommunicationError
164
165
  end
165
166
  end
166
167
 
167
- attr_accessor :host, :port
168
+ def to_s
169
+ str = super
170
+ str << " #{@reason}" if @reason
171
+ str
172
+ end
173
+
174
+ attr_accessor :host, :port, :reason
168
175
  end
169
176
 
170
177
 
@@ -186,7 +193,9 @@ end
186
193
  ###
187
194
  class ConnectionRefused < ConnectionError
188
195
  def to_s
189
- "The connection was refused by the remote host #{addr_to_s}."
196
+ str = "The connection was refused by the remote host #{addr_to_s}."
197
+ str << " #{@reason}" unless @reason.nil?
198
+ str
190
199
  end
191
200
  end
192
201
 
@@ -198,7 +207,9 @@ end
198
207
  ###
199
208
  class HostUnreachable < ConnectionError
200
209
  def to_s
201
- "The host #{addr_to_s} was unreachable."
210
+ str = "The host #{addr_to_s} was unreachable."
211
+ str << " #{@reason}" unless @reason.nil?
212
+ str
202
213
  end
203
214
  end
204
215
 
@@ -209,7 +220,9 @@ end
209
220
  ###
210
221
  class ConnectionTimeout < ConnectionError
211
222
  def to_s
212
- "The connection timed out #{addr_to_s}."
223
+ str = "The connection with #{addr_to_s} timed out."
224
+ str << " #{@reason}" unless @reason.nil?
225
+ str
213
226
  end
214
227
  end
215
228
 
@@ -220,18 +233,17 @@ end
220
233
  #
221
234
  ###
222
235
  class InvalidDestination < ConnectionError
223
- include SocketError
224
- include HostCommunicationError
225
-
226
236
  def to_s
227
- "The destination is invalid: #{addr_to_s}."
237
+ str = "The destination is invalid: #{addr_to_s}."
238
+ str << " #{@reason}" unless @reason.nil?
239
+ str
228
240
  end
229
241
  end
230
242
 
231
243
  ###
232
244
  #
233
245
  # This exception is raised when an attempt to use an address or port that is
234
- # already in use or onot available occurs. such as binding to a host on a
246
+ # already in use or not available occurs. such as binding to a host on a
235
247
  # given port that is already in use, or when a bind address is specified that
236
248
  # is not available to the host.
237
249
  #
@@ -241,7 +253,9 @@ class BindFailed < ::ArgumentError
241
253
  include HostCommunicationError
242
254
 
243
255
  def to_s
244
- "The address is already in use or unavailable: #{addr_to_s}."
256
+ str = "The address is already in use or unavailable: #{addr_to_s}."
257
+ str << " #{@reason}" unless @reason.nil?
258
+ str
245
259
  end
246
260
  end
247
261
 
@@ -255,11 +269,10 @@ end
255
269
  #
256
270
  ##
257
271
  class AddressInUse < ConnectionError
258
- include SocketError
259
- include HostCommunicationError
260
-
261
272
  def to_s
262
- "The address is already in use or unavailable: #{addr_to_s}."
273
+ str = "The address is already in use or unavailable: #{addr_to_s}."
274
+ str << " #{@reason}" unless @reason.nil?
275
+ str
263
276
  end
264
277
  end
265
278
 
data/lib/rex/io/stream.rb CHANGED
@@ -325,21 +325,6 @@ module Stream
325
325
  16384
326
326
  end
327
327
 
328
- protected
329
-
330
- #
331
- # The read-write lock used to synchronize access to the stream. This is only
332
- # set when synchronization has been initialized as performed by
333
- # #initialize_synchronization.
334
- #
335
- attr_accessor :stream_lock
336
-
337
- #
338
- # A boolean flag indicating that the resource is to be closed. Blocking
339
- # operations that are synchronized (such as #read and #write) should evaluate
340
- # this flag and exit appropriately when there is no data to be processed.
341
- attr_accessor :close_resource
342
-
343
328
  #
344
329
  # Synchronize non-state changing access to the stream such as read and write
345
330
  # operations. If synchronization has not been initialized, this doesn't do
@@ -366,6 +351,21 @@ protected
366
351
  self.stream_lock.unlock_write unless self.stream_lock.nil?
367
352
  end
368
353
  end
354
+
355
+ protected
356
+
357
+ #
358
+ # The read-write lock used to synchronize access to the stream. This is only
359
+ # set when synchronization has been initialized as performed by
360
+ # #initialize_synchronization.
361
+ #
362
+ attr_accessor :stream_lock
363
+
364
+ #
365
+ # A boolean flag indicating that the resource is to be closed. Blocking
366
+ # operations that are synchronized (such as #read and #write) should evaluate
367
+ # this flag and exit appropriately when there is no data to be processed.
368
+ attr_accessor :close_resource
369
369
  end
370
370
 
371
371
  end end
@@ -0,0 +1,23 @@
1
+ module Rex::Stopwatch
2
+
3
+ # This provides a correct way to time an operation provided within a block.
4
+ #
5
+ # @see https://blog.dnsimple.com/2018/03/elapsed-time-with-ruby-the-right-way/
6
+ # @see https://ruby-doc.org/core-2.7.1/Process.html#method-c-clock_gettime
7
+ #
8
+ # @param [Symbol] unit The unit of time in which to measure the duration. The
9
+ # argument is passed to Process.clock_gettime which defines the acceptable
10
+ # values.
11
+ #
12
+ # @yield [] The block whose operation should be timed.
13
+ #
14
+ # @return Returns the result of the block and the elapsed time in the specified unit.
15
+ def self.elapsed_time(unit: :float_second)
16
+ start = Process.clock_gettime(Process::CLOCK_MONOTONIC, unit)
17
+ ret = yield
18
+ elapsed = Process.clock_gettime(Process::CLOCK_MONOTONIC, unit) - start
19
+
20
+ [ret, elapsed]
21
+ end
22
+
23
+ end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rex-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.16
4
+ version: 0.1.20
5
5
  platform: ruby
6
6
  authors:
7
7
  - Metasploit Hackers
@@ -93,7 +93,7 @@ cert_chain:
93
93
  EknWpNgVhohbot1lfVAMmIhdtOVaRVcQQixWPwprDj/ydB8ryDMDosIMcw+fkoXU
94
94
  9GJsSaSRRYQ9UUkVL27b64okU8D48m8=
95
95
  -----END CERTIFICATE-----
96
- date: 2021-02-12 00:00:00.000000000 Z
96
+ date: 2021-11-16 00:00:00.000000000 Z
97
97
  dependencies:
98
98
  - !ruby/object:Gem::Dependency
99
99
  name: rake
@@ -151,6 +151,7 @@ files:
151
151
  - lib/rex/io/stream.rb
152
152
  - lib/rex/io/stream_abstraction.rb
153
153
  - lib/rex/io/stream_server.rb
154
+ - lib/rex/stopwatch.rb
154
155
  - lib/rex/sync.rb
155
156
  - lib/rex/sync/event.rb
156
157
  - lib/rex/sync/read_write_lock.rb
metadata.gz.sig CHANGED
Binary file