rex-socket 0.1.21 → 0.1.22
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.tar.gz.sig +0 -0
- data/.travis.yml +1 -1
- data/lib/rex/socket/parameters.rb +81 -52
- data/lib/rex/socket/version.rb +1 -1
- metadata +2 -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: 314afb7251f312c317eca7741cdd3ce3e5136ce02ac0faccec827f0124b8b253
|
4
|
+
data.tar.gz: 61a2d745cfe3d490fb3114945e8d4b8033e521b9e037efe9c407abc3a9306dca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 71fb7ba1ea13d3b0a92a503397c3a0ad2f59994bc3f8c0cd0b425a827ccca876f5aa3f44c2320b37be7443268a6851a4da0ab6623c5d7af257b48dc13a5ae839
|
7
|
+
data.tar.gz: b542007ef2c4b31a28873304120180f17c7604a0a773da475c154af0f01a2371d3ccb74746f60452a7000829bc4d699b4f06b3a9623512c636ffd5a36dc71b88
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/.travis.yml
CHANGED
@@ -77,45 +77,33 @@ class Rex::Socket::Parameters
|
|
77
77
|
# retried.
|
78
78
|
# @option hash [Fixnum] 'Timeout' The number of seconds before a connection
|
79
79
|
# should time out
|
80
|
-
def initialize(hash)
|
80
|
+
def initialize(hash = {})
|
81
81
|
if (hash['PeerHost'])
|
82
82
|
self.peerhost = hash['PeerHost']
|
83
83
|
elsif (hash['PeerAddr'])
|
84
84
|
self.peerhost = hash['PeerAddr']
|
85
|
-
else
|
86
|
-
self.peerhost = nil
|
87
85
|
end
|
88
86
|
|
89
87
|
if (hash['LocalHost'])
|
90
88
|
self.localhost = hash['LocalHost']
|
91
89
|
elsif (hash['LocalAddr'])
|
92
90
|
self.localhost = hash['LocalAddr']
|
93
|
-
else
|
94
|
-
self.localhost = '0.0.0.0'
|
95
91
|
end
|
96
92
|
|
97
93
|
if (hash['PeerPort'])
|
98
94
|
self.peerport = hash['PeerPort'].to_i
|
99
|
-
else
|
100
|
-
self.peerport = 0
|
101
95
|
end
|
102
96
|
|
103
97
|
if (hash['LocalPort'])
|
104
98
|
self.localport = hash['LocalPort'].to_i
|
105
|
-
else
|
106
|
-
self.localport = 0
|
107
99
|
end
|
108
100
|
|
109
101
|
if (hash['Bare'])
|
110
102
|
self.bare = hash['Bare']
|
111
|
-
else
|
112
|
-
self.bare = false
|
113
103
|
end
|
114
104
|
|
115
105
|
if (hash['SSL'] and hash['SSL'].to_s =~ /^(t|y|1)/i)
|
116
106
|
self.ssl = true
|
117
|
-
else
|
118
|
-
self.ssl = false
|
119
107
|
end
|
120
108
|
|
121
109
|
if hash['SSLContext']
|
@@ -179,33 +167,16 @@ class Rex::Socket::Parameters
|
|
179
167
|
# The protocol this socket will be using
|
180
168
|
if (hash['Proto'])
|
181
169
|
self.proto = hash['Proto'].downcase
|
182
|
-
else
|
183
|
-
self.proto = 'tcp'
|
184
170
|
end
|
185
171
|
|
186
172
|
# Whether or not the socket should be a server
|
187
|
-
self.server = hash['Server']
|
173
|
+
self.server = hash['Server']
|
188
174
|
|
189
175
|
# The communication subsystem to use to create the socket
|
190
176
|
self.comm = hash['Comm']
|
191
177
|
|
192
178
|
# The context that was passed in, if any.
|
193
|
-
self.context = hash['Context']
|
194
|
-
|
195
|
-
# If no comm was supplied, try to use the comm that is best fit to
|
196
|
-
# handle the provided host based on the current routing table.
|
197
|
-
if( self.server )
|
198
|
-
if (self.comm == nil and self.localhost)
|
199
|
-
self.comm = Rex::Socket::SwitchBoard.best_comm(self.localhost)
|
200
|
-
end
|
201
|
-
else
|
202
|
-
if (self.comm == nil and self.peerhost)
|
203
|
-
self.comm = Rex::Socket::SwitchBoard.best_comm(self.peerhost)
|
204
|
-
end
|
205
|
-
end
|
206
|
-
|
207
|
-
# If we still haven't found a comm, we default to the local comm.
|
208
|
-
self.comm = Rex::Socket::Comm::Local if (self.comm == nil)
|
179
|
+
self.context = hash['Context']
|
209
180
|
|
210
181
|
# If we are a UDP server, turn off the server flag as it was only set when
|
211
182
|
# creating the UDP socket in order to avail of the switch board above.
|
@@ -216,19 +187,29 @@ class Rex::Socket::Parameters
|
|
216
187
|
# The number of connection retries to make (client only)
|
217
188
|
if hash['Retries']
|
218
189
|
self.retries = hash['Retries'].to_i
|
219
|
-
else
|
220
|
-
self.retries = 0
|
221
190
|
end
|
222
191
|
|
223
192
|
# The number of seconds before a connect attempt times out (client only)
|
224
193
|
if hash['Timeout']
|
225
194
|
self.timeout = hash['Timeout'].to_i
|
226
|
-
else
|
227
|
-
self.timeout = 5
|
228
195
|
end
|
229
196
|
|
230
197
|
# Whether to force IPv6 addressing
|
231
|
-
self.v6 = hash['IPv6']
|
198
|
+
self.v6 = hash['IPv6']
|
199
|
+
end
|
200
|
+
|
201
|
+
def merge(other)
|
202
|
+
self.dup.merge!(other)
|
203
|
+
end
|
204
|
+
|
205
|
+
def merge!(other)
|
206
|
+
other = self.class.new(other) if other.is_a? Hash
|
207
|
+
|
208
|
+
other.instance_variables.each do |name|
|
209
|
+
value = other.instance_variable_get(name)
|
210
|
+
instance_variable_set(name, value) unless value.nil?
|
211
|
+
end
|
212
|
+
self
|
232
213
|
end
|
233
214
|
|
234
215
|
##
|
@@ -294,7 +275,6 @@ class Rex::Socket::Parameters
|
|
294
275
|
return v6
|
295
276
|
end
|
296
277
|
|
297
|
-
|
298
278
|
##
|
299
279
|
#
|
300
280
|
# Attributes
|
@@ -308,50 +288,94 @@ class Rex::Socket::Parameters
|
|
308
288
|
|
309
289
|
# The remote port. Equivalent to the PeerPort parameter hash key.
|
310
290
|
# @return [Fixnum]
|
311
|
-
|
291
|
+
attr_writer :peerport
|
292
|
+
def peerport
|
293
|
+
@peerport || 0
|
294
|
+
end
|
312
295
|
|
313
296
|
# The local host. Equivalent to the LocalHost parameter hash key.
|
314
297
|
# @return [String]
|
315
|
-
|
298
|
+
attr_writer :localhost
|
299
|
+
def localhost
|
300
|
+
@localhost || '0.0.0.0'
|
301
|
+
end
|
316
302
|
|
317
303
|
# The local port. Equivalent to the LocalPort parameter hash key.
|
318
304
|
# @return [Fixnum]
|
319
|
-
|
305
|
+
attr_writer :localport
|
306
|
+
def localport
|
307
|
+
@localport || 0
|
308
|
+
end
|
320
309
|
|
321
310
|
# The protocol to to use, such as TCP. Equivalent to the Proto parameter
|
322
311
|
# hash key.
|
323
312
|
# @return [String]
|
324
|
-
|
313
|
+
attr_writer :proto
|
314
|
+
def proto
|
315
|
+
@proto || 'tcp'
|
316
|
+
end
|
325
317
|
|
326
318
|
# Whether or not this is a server. Equivalent to the Server parameter
|
327
319
|
# hash key.
|
328
320
|
# @return [Bool]
|
329
|
-
|
321
|
+
attr_writer :server
|
322
|
+
def server
|
323
|
+
@server || false
|
324
|
+
end
|
330
325
|
|
331
326
|
# The {Comm} instance that should be used to create the underlying socket.
|
332
327
|
# @return [Comm]
|
333
|
-
|
328
|
+
attr_writer :comm
|
329
|
+
def comm
|
330
|
+
return @comm unless @comm.nil?
|
331
|
+
|
332
|
+
best_comm = nil
|
333
|
+
# If no comm was explicitly specified, try to use the comm that is best fit
|
334
|
+
# to handle the provided host based on the current routing table.
|
335
|
+
if server and localhost
|
336
|
+
best_comm = Rex::Socket::SwitchBoard.best_comm(localhost)
|
337
|
+
elsif peerhost
|
338
|
+
best_comm = Rex::Socket::SwitchBoard.best_comm(peerhost)
|
339
|
+
end
|
340
|
+
|
341
|
+
best_comm || Rex::Socket::Comm::Local
|
342
|
+
end
|
334
343
|
|
335
344
|
# The context hash that was passed in to the structure. (default: {})
|
336
345
|
# @return [Hash]
|
337
|
-
|
346
|
+
attr_writer :context
|
347
|
+
def context
|
348
|
+
@context || {}
|
349
|
+
end
|
338
350
|
|
339
351
|
# The number of attempts that should be made.
|
340
352
|
# @return [Fixnum]
|
341
|
-
|
353
|
+
attr_writer :retries
|
354
|
+
def retries
|
355
|
+
@retries || 0
|
356
|
+
end
|
342
357
|
|
343
358
|
# The number of seconds before a connection attempt should time out.
|
344
359
|
# @return [Fixnum]
|
345
|
-
|
360
|
+
attr_writer :timeout
|
361
|
+
def timeout
|
362
|
+
@timeout || 5
|
363
|
+
end
|
346
364
|
|
347
365
|
# Whether or not this is a bare (non-extended) socket instance that should
|
348
366
|
# be created.
|
349
367
|
# @return [Bool]
|
350
|
-
|
368
|
+
attr_writer :bare
|
369
|
+
def bare
|
370
|
+
@comm || false
|
371
|
+
end
|
351
372
|
|
352
373
|
# Whether or not SSL should be used to wrap the connection.
|
353
374
|
# @return [Bool]
|
354
|
-
|
375
|
+
attr_writer :ssl
|
376
|
+
def ssl
|
377
|
+
@ssl || false
|
378
|
+
end
|
355
379
|
|
356
380
|
# Pre configured SSL Context to use
|
357
381
|
# @return [OpenSSL::SSL::SSLContext]
|
@@ -384,21 +408,26 @@ class Rex::Socket::Parameters
|
|
384
408
|
# The client SSL certificate
|
385
409
|
#
|
386
410
|
attr_accessor :ssl_client_cert
|
411
|
+
|
387
412
|
#
|
388
413
|
# The client SSL key
|
389
414
|
#
|
390
415
|
attr_accessor :ssl_client_key
|
416
|
+
|
391
417
|
#
|
392
418
|
# SSL certificate verification mode for SSL context
|
393
419
|
attr_accessor :ssl_verify_mode
|
420
|
+
|
394
421
|
#
|
395
422
|
# Whether we should use IPv6
|
396
423
|
# @return [Bool]
|
397
|
-
|
398
|
-
|
424
|
+
attr_writer :v6
|
425
|
+
def v6
|
426
|
+
@v6 || false
|
427
|
+
end
|
399
428
|
|
400
429
|
# List of proxies to use
|
401
|
-
# @return [
|
430
|
+
# @return [Array]
|
402
431
|
attr_accessor :proxies
|
403
432
|
|
404
433
|
alias peeraddr peerhost
|
data/lib/rex/socket/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rex-socket
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.22
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Maloney
|
@@ -93,7 +93,7 @@ cert_chain:
|
|
93
93
|
JI/W23RbIRksG2pioMhd4dCXq3FLLlkOV1YfCwWixNB+iIhQPPZVaPNfgPhCn4Dt
|
94
94
|
DeGjje/qA4fkLtRmOtb9PUBq3ToRDE4=
|
95
95
|
-----END CERTIFICATE-----
|
96
|
-
date:
|
96
|
+
date: 2020-03-04 00:00:00.000000000 Z
|
97
97
|
dependencies:
|
98
98
|
- !ruby/object:Gem::Dependency
|
99
99
|
name: bundler
|
metadata.gz.sig
CHANGED
Binary file
|