arachni-reactor 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/LICENSE.md +1 -1
- data/README.md +2 -2
- data/lib/arachni/reactor.rb +5 -3
- data/lib/arachni/reactor/connection.rb +14 -8
- data/lib/arachni/reactor/connection/error.rb +1 -1
- data/lib/arachni/reactor/version.rb +1 -1
- data/spec/arachni/reactor/tasks/delayed_spec.rb +3 -1
- data/spec/arachni/reactor/tasks/periodic_spec.rb +3 -1
- data/spec/support/lib/servers.rb +1 -1
- data/spec/support/shared/reactor.rb +3 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6c421c44ae454d55db1adc102b4c9d0819375ff0
|
4
|
+
data.tar.gz: b05b9f1ddf6048d8e0df60684b738e879628e48c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 83ba17f94bed4e8d8d8b6125ed06288051a3bc59bd34733f355db80757e01f65d7074459670c1cedb95ffc2c0242dfc8219ea4988199f5fb0c63139152e6182c
|
7
|
+
data.tar.gz: e7a6690fa5d3c8f496e19a34e6d7d942548dc5dbb3ef62905a1e2c7a29c9fbd5b3923527ad2cf60c3ed707666ec6854577f6e135ef30eabe87ca9d3db50b18ec
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
# ChangeLog
|
2
2
|
|
3
|
+
## Version 0.1.1
|
4
|
+
|
5
|
+
- `Connection`
|
6
|
+
- `#_write` -- Use `String#byteslice` instead of `String#slice` and
|
7
|
+
`String#bytesize` instead of `String#size`.
|
8
|
+
- `Error.translate` -- Translate `Errno::ECONNABORTED` as `Error::Reset`.
|
9
|
+
|
3
10
|
## Version 0.1.0
|
4
11
|
|
5
12
|
- Cleaned up connection handling structure for JRuby support.
|
data/LICENSE.md
CHANGED
data/README.md
CHANGED
data/lib/arachni/reactor.rb
CHANGED
@@ -668,9 +668,11 @@ class Reactor
|
|
668
668
|
# So force a read for SSL sockets to cover all our bases.
|
669
669
|
#
|
670
670
|
# This is apparent especially on JRuby.
|
671
|
-
|
672
|
-
|
673
|
-
|
671
|
+
if readables.size != selected_sockets[0].size
|
672
|
+
(readables - selected_sockets[0]).each do |socket|
|
673
|
+
next if !socket.is_a?( OpenSSL::SSL::SSLSocket )
|
674
|
+
selected_sockets[0] << socket
|
675
|
+
end
|
674
676
|
end
|
675
677
|
|
676
678
|
if selected_sockets[0].empty? && selected_sockets[1].empty? &&
|
@@ -41,17 +41,21 @@ class Connection
|
|
41
41
|
# `true` when using a UNIX-domain socket, `nil` if no {#socket} is
|
42
42
|
# available, `false` otherwise.
|
43
43
|
def unix?
|
44
|
+
return @is_unix if !@is_unix.nil?
|
44
45
|
return if !to_io
|
45
46
|
return false if !Arachni::Reactor.supports_unix_sockets?
|
46
|
-
|
47
|
+
|
48
|
+
@is_unix = to_io.is_a?( UNIXServer ) || to_io.is_a?( UNIXSocket )
|
47
49
|
end
|
48
50
|
|
49
51
|
# @return [Bool]
|
50
52
|
# `true` when using an Internet socket, `nil` if no {#socket} is
|
51
53
|
# available, `false` otherwise.
|
52
54
|
def inet?
|
55
|
+
return @is_inet if !@is_inet.nil?
|
53
56
|
return if !to_io
|
54
|
-
|
57
|
+
|
58
|
+
@is_inet = to_io.is_a?( TCPServer ) || to_io.is_a?( TCPSocket ) || to_io.is_a?( Socket )
|
55
59
|
end
|
56
60
|
|
57
61
|
# @return [IO, nil]
|
@@ -64,8 +68,10 @@ class Connection
|
|
64
68
|
# @return [Bool]
|
65
69
|
# `true` if the connection is a server listener.
|
66
70
|
def listener?
|
71
|
+
return @is_listener if !@is_listener.nil?
|
67
72
|
return if !to_io
|
68
|
-
|
73
|
+
|
74
|
+
@is_listener = to_io.is_a?( TCPServer ) || (unix? && to_io.is_a?( UNIXServer ))
|
69
75
|
end
|
70
76
|
|
71
77
|
# @note The data will be buffered and sent in future {Reactor} ticks.
|
@@ -228,7 +234,7 @@ class Connection
|
|
228
234
|
socket.connect_nonblock( Socket.sockaddr_in( @port, @host ) )
|
229
235
|
end
|
230
236
|
# Already connected. :)
|
231
|
-
rescue Errno::EISCONN
|
237
|
+
rescue Errno::EISCONN, Errno::EALREADY
|
232
238
|
end
|
233
239
|
|
234
240
|
@connected = true
|
@@ -277,7 +283,7 @@ class Connection
|
|
277
283
|
def _write
|
278
284
|
return _connect if !connected?
|
279
285
|
|
280
|
-
chunk = write_buffer.
|
286
|
+
chunk = write_buffer.byteslice( 0, BLOCK_SIZE )
|
281
287
|
total_written = 0
|
282
288
|
|
283
289
|
begin
|
@@ -285,13 +291,13 @@ class Connection
|
|
285
291
|
# Send out the chunk, **all** of it, or at least try to.
|
286
292
|
loop do
|
287
293
|
total_written += written = @socket.write_nonblock( chunk )
|
288
|
-
write_buffer.
|
294
|
+
@write_buffer = @write_buffer.byteslice( written..-1 )
|
289
295
|
|
290
296
|
# Call #on_write every time any of the buffer is consumed.
|
291
297
|
on_write
|
292
298
|
|
293
|
-
break if written == chunk.
|
294
|
-
chunk.
|
299
|
+
break if written == chunk.bytesize
|
300
|
+
chunk = chunk.byteslice( written..-1 )
|
295
301
|
end
|
296
302
|
end
|
297
303
|
|
@@ -35,7 +35,7 @@ class Error < Arachni::Reactor::Error
|
|
35
35
|
# non-existent server.
|
36
36
|
Errno::EADDRINUSE => e
|
37
37
|
raise_with_proper_backtrace( e, Refused )
|
38
|
-
rescue Errno::ECONNRESET => e
|
38
|
+
rescue Errno::ECONNRESET, Errno::ECONNABORTED => e
|
39
39
|
raise_with_proper_backtrace( e, Reset )
|
40
40
|
rescue Errno::EACCES => e
|
41
41
|
raise_with_proper_backtrace( e, Permission )
|
@@ -35,7 +35,9 @@ describe Arachni::Reactor::Tasks::Delayed do
|
|
35
35
|
time = Time.now
|
36
36
|
task.call while called < 1
|
37
37
|
|
38
|
-
(Time.now - time).round(2)
|
38
|
+
elapsed = (Time.now - time).round(2)
|
39
|
+
elapsed.should >= 0.25
|
40
|
+
elapsed.should < 0.30
|
39
41
|
end
|
40
42
|
|
41
43
|
it 'calls #done' do
|
data/spec/support/lib/servers.rb
CHANGED
@@ -77,7 +77,7 @@ class Servers
|
|
77
77
|
return if !server_info[:pid]
|
78
78
|
|
79
79
|
begin
|
80
|
-
Process.kill(
|
80
|
+
Process.kill( 'KILL', server_info[:pid] ) while sleep 0.1
|
81
81
|
rescue Errno::ESRCH
|
82
82
|
server_info.delete(:pid)
|
83
83
|
|
@@ -816,6 +816,9 @@ shared_examples_for 'Arachni::Reactor' do
|
|
816
816
|
subject.listen( host, port, echo_server_handler, *options )
|
817
817
|
|
818
818
|
@socket = tcp_writer.call( host, port, data )
|
819
|
+
|
820
|
+
sleep 5
|
821
|
+
|
819
822
|
subject.connections.values.first.initialization_args.should == options
|
820
823
|
end
|
821
824
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: arachni-reactor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tasos Laskos
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-01-26 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: |2
|
14
14
|
Arachni::Reactor is a simple, lightweight, pure-Ruby implementation of the Reactor
|
@@ -98,7 +98,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
98
98
|
version: '0'
|
99
99
|
requirements: []
|
100
100
|
rubyforge_project:
|
101
|
-
rubygems_version: 2.
|
101
|
+
rubygems_version: 2.5.1
|
102
102
|
signing_key:
|
103
103
|
specification_version: 4
|
104
104
|
summary: A pure-Ruby implementation of the Reactor pattern.
|