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 +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/rex/core/version.rb +1 -1
- data/lib/rex/exceptions.rb +31 -18
- data/lib/rex/io/stream.rb +15 -15
- data/lib/rex/stopwatch.rb +23 -0
- data.tar.gz.sig +0 -0
- metadata +3 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cacc2616718c8056c7ff5ecf2626562f71ac9efd0a6ae69c80cd21565824b666
|
4
|
+
data.tar.gz: e6ed793586462b6cc826be77b533030e45a7bce1ae4fd0bdb2cbaf62ed6e17dd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a7367cb540a9638f4f64e5756f3c9761e3ebe05f15444ee2d4ae8e6f6af94888f50e2813cc89e7ef3bc7492335f20c31ccc98c8c3ba4b2a55e61995b174c8497
|
7
|
+
data.tar.gz: 4dbd3f07ec237c23ca088bbbdc2f67e2a59bcf5167bcebe841550877fc99f1e81ef3a9c763ddb9c7d8478844676e08ee3f706188c721049be00fbe2b3350ef89
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/lib/rex/core/version.rb
CHANGED
data/lib/rex/exceptions.rb
CHANGED
@@ -145,9 +145,10 @@ end
|
|
145
145
|
#
|
146
146
|
###
|
147
147
|
module HostCommunicationError
|
148
|
-
def initialize(addr = nil, port = nil)
|
149
|
-
|
150
|
-
|
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
|
-
|
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
|
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
|
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.
|
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-
|
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
|