eventmachine 1.2.0.1 → 1.2.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 +12 -0
- data/README.md +25 -23
- data/ext/ed.cpp +40 -65
- data/ext/ed.h +23 -8
- data/ext/em.cpp +23 -12
- data/ext/em.h +1 -1
- data/ext/rubymain.cpp +19 -15
- data/java/src/com/rubyeventmachine/EmReactor.java +18 -2
- data/lib/em/pool.rb +35 -35
- data/lib/em/protocols/linetext2.rb +18 -5
- data/lib/em/pure_ruby.rb +290 -52
- data/lib/em/version.rb +1 -1
- data/lib/eventmachine.rb +6 -0
- data/lib/jeventmachine.rb +2 -0
- data/rakelib/test_pure.rake +13 -0
- data/tests/em_test_helper.rb +3 -0
- data/tests/test_basic.rb +32 -0
- data/tests/test_ltp2.rb +24 -0
- data/tests/test_pure.rb +51 -0
- data/tests/test_ssl_dhparam.rb +2 -1
- data/tests/test_ssl_ecdh_curve.rb +2 -1
- data/tests/test_ssl_extensions.rb +1 -1
- data/tests/test_ssl_protocols.rb +3 -3
- data/tests/test_ssl_verify.rb +2 -0
- metadata +29 -28
data/lib/em/version.rb
CHANGED
data/lib/eventmachine.rb
CHANGED
@@ -1521,6 +1521,12 @@ module EventMachine
|
|
1521
1521
|
elsif opcode == ConnectionCompleted
|
1522
1522
|
c = @conns[conn_binding] or raise ConnectionNotBound, "received ConnectionCompleted for unknown signature: #{conn_binding}"
|
1523
1523
|
c.connection_completed
|
1524
|
+
elsif opcode == SslHandshakeCompleted
|
1525
|
+
c = @conns[conn_binding] or raise ConnectionNotBound, "received SslHandshakeCompleted for unknown signature: #{conn_binding}"
|
1526
|
+
c.ssl_handshake_completed
|
1527
|
+
elsif opcode == SslVerify
|
1528
|
+
c = @conns[conn_binding] or raise ConnectionNotBound, "received SslVerify for unknown signature: #{conn_binding}"
|
1529
|
+
c.close_connection if c.ssl_verify_peer(data) == false
|
1524
1530
|
elsif opcode == TimerFired
|
1525
1531
|
t = @timers.delete( data )
|
1526
1532
|
return if t == false # timer cancelled
|
data/lib/jeventmachine.rb
CHANGED
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'rake/testtask'
|
2
|
+
|
3
|
+
Rake::TestTask.new(:test_pure) do |t|
|
4
|
+
t.libs << 'tests'
|
5
|
+
t.libs << 'lib'
|
6
|
+
t.test_files = Dir.glob('tests/**/test_pure*.rb') + Dir.glob('tests/**/test_ssl*.rb')
|
7
|
+
t.warning = true
|
8
|
+
end
|
9
|
+
|
10
|
+
task :test_em_pure_ruby do
|
11
|
+
ENV['EM_PURE_RUBY'] = 'true'
|
12
|
+
Rake::Task['test_pure'].execute
|
13
|
+
end
|
data/tests/em_test_helper.rb
CHANGED
data/tests/test_basic.rb
CHANGED
@@ -171,6 +171,38 @@ class TestBasic < Test::Unit::TestCase
|
|
171
171
|
assert_equal local_ip, ip
|
172
172
|
end
|
173
173
|
|
174
|
+
def test_invalid_address_bind_connect_dst
|
175
|
+
e = nil
|
176
|
+
EM.run do
|
177
|
+
begin
|
178
|
+
EM.bind_connect('localhost', nil, 'invalid.invalid', 80)
|
179
|
+
rescue Exception => e
|
180
|
+
# capture the exception
|
181
|
+
ensure
|
182
|
+
EM.stop
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
186
|
+
assert_kind_of(EventMachine::ConnectionError, e)
|
187
|
+
assert_match(/unable to resolve address:.*not known/, e.message)
|
188
|
+
end
|
189
|
+
|
190
|
+
def test_invalid_address_bind_connect_src
|
191
|
+
e = nil
|
192
|
+
EM.run do
|
193
|
+
begin
|
194
|
+
EM.bind_connect('invalid.invalid', nil, 'localhost', 80)
|
195
|
+
rescue Exception => e
|
196
|
+
# capture the exception
|
197
|
+
ensure
|
198
|
+
EM.stop
|
199
|
+
end
|
200
|
+
end
|
201
|
+
|
202
|
+
assert_kind_of(EventMachine::ConnectionError, e)
|
203
|
+
assert_match(/invalid bind address:.*not known/, e.message)
|
204
|
+
end
|
205
|
+
|
174
206
|
def test_reactor_thread?
|
175
207
|
assert !EM.reactor_thread?
|
176
208
|
EM.run { assert EM.reactor_thread?; EM.stop }
|
data/tests/test_ltp2.rb
CHANGED
@@ -72,6 +72,30 @@ class TestLineText2 < Test::Unit::TestCase
|
|
72
72
|
assert_equal( ["Linea", "Lineb", "Linec", "Lined"], a.lines )
|
73
73
|
end
|
74
74
|
|
75
|
+
class RegexDelimiter
|
76
|
+
include EM::Protocols::LineText2
|
77
|
+
attr_reader :lines
|
78
|
+
def initialize *args
|
79
|
+
super
|
80
|
+
@delim = /[A-D]/
|
81
|
+
set_delimiter @delim
|
82
|
+
end
|
83
|
+
def receive_line line
|
84
|
+
(@lines ||= []) << line
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
def test_regex_delimiter
|
89
|
+
testdata = %Q(LineaALinebBLinecCLinedD)
|
90
|
+
|
91
|
+
a = RegexDelimiter.new
|
92
|
+
a.receive_data testdata
|
93
|
+
assert_equal( ["Linea", "Lineb", "Linec", "Lined"], a.lines )
|
94
|
+
|
95
|
+
a = RegexDelimiter.new
|
96
|
+
testdata.length.times {|i| a.receive_data( testdata[i...i+1] ) }
|
97
|
+
assert_equal( ["Linea", "Lineb", "Linec", "Lined"], a.lines )
|
98
|
+
end
|
75
99
|
|
76
100
|
#--
|
77
101
|
# Test two lines followed by an empty line, ten bytes of binary data, then
|
data/tests/test_pure.rb
CHANGED
@@ -85,4 +85,55 @@ class TestPure < Test::Unit::TestCase
|
|
85
85
|
assert a
|
86
86
|
end
|
87
87
|
|
88
|
+
module TLSServer
|
89
|
+
def post_init
|
90
|
+
start_tls
|
91
|
+
end
|
92
|
+
|
93
|
+
def ssl_handshake_completed
|
94
|
+
$server_handshake_completed = true
|
95
|
+
end
|
96
|
+
|
97
|
+
def receive_data(data)
|
98
|
+
$server_received_data = data
|
99
|
+
send_data(data)
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
module TLSClient
|
104
|
+
def post_init
|
105
|
+
start_tls
|
106
|
+
end
|
107
|
+
|
108
|
+
def ssl_handshake_completed
|
109
|
+
$client_handshake_completed = true
|
110
|
+
end
|
111
|
+
|
112
|
+
def connection_completed
|
113
|
+
send_data('Hello World!')
|
114
|
+
end
|
115
|
+
|
116
|
+
def receive_data(data)
|
117
|
+
$client_received_data = data
|
118
|
+
close_connection
|
119
|
+
end
|
120
|
+
|
121
|
+
def unbind
|
122
|
+
EM.stop_event_loop
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
def test_start_tls
|
127
|
+
$client_handshake_completed, $server_handshake_completed = false, false
|
128
|
+
$client_received_data, $server_received_data = nil, nil
|
129
|
+
EM.run do
|
130
|
+
EM.start_server("127.0.0.1", 16789, TLSServer)
|
131
|
+
EM.connect("127.0.0.1", 16789, TLSClient)
|
132
|
+
end
|
133
|
+
|
134
|
+
assert($client_handshake_completed)
|
135
|
+
assert($server_handshake_completed)
|
136
|
+
assert($client_received_data == "Hello World!")
|
137
|
+
assert($server_received_data == "Hello World!")
|
138
|
+
end
|
88
139
|
end
|
data/tests/test_ssl_dhparam.rb
CHANGED
@@ -7,7 +7,7 @@ class TestSslDhParam < Test::Unit::TestCase
|
|
7
7
|
end
|
8
8
|
|
9
9
|
module Client
|
10
|
-
def
|
10
|
+
def post_init
|
11
11
|
start_tls
|
12
12
|
end
|
13
13
|
|
@@ -46,6 +46,7 @@ class TestSslDhParam < Test::Unit::TestCase
|
|
46
46
|
|
47
47
|
def test_no_dhparam
|
48
48
|
omit_unless(EM.ssl?)
|
49
|
+
omit_if(EM.library_type == :pure_ruby) # DH will work with defaults
|
49
50
|
omit_if(rbx?)
|
50
51
|
|
51
52
|
$client_handshake_completed, $server_handshake_completed = false, false
|
@@ -2,7 +2,7 @@ require 'em_test_helper'
|
|
2
2
|
|
3
3
|
class TestSslEcdhCurve < Test::Unit::TestCase
|
4
4
|
module Client
|
5
|
-
def
|
5
|
+
def post_init
|
6
6
|
start_tls
|
7
7
|
end
|
8
8
|
|
@@ -56,6 +56,7 @@ class TestSslEcdhCurve < Test::Unit::TestCase
|
|
56
56
|
|
57
57
|
def test_ecdh_curve
|
58
58
|
omit_unless(EM.ssl?)
|
59
|
+
omit_if(EM.library_type == :pure_ruby && RUBY_VERSION < "2.3.0")
|
59
60
|
omit_if(rbx?)
|
60
61
|
|
61
62
|
$client_handshake_completed, $server_handshake_completed = false, false
|
data/tests/test_ssl_protocols.rb
CHANGED
@@ -25,21 +25,21 @@ if EM.ssl?
|
|
25
25
|
|
26
26
|
module ClientAny
|
27
27
|
include Client
|
28
|
-
def
|
28
|
+
def post_init
|
29
29
|
start_tls(:ssl_version => %w(sslv2 sslv3 tlsv1 tlsv1_1 tlsv1_2))
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
33
|
module ClientDefault
|
34
34
|
include Client
|
35
|
-
def
|
35
|
+
def post_init
|
36
36
|
start_tls
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
40
40
|
module ClientSSLv3
|
41
41
|
include Client
|
42
|
-
def
|
42
|
+
def post_init
|
43
43
|
start_tls(:ssl_version => %w(SSLv3))
|
44
44
|
end
|
45
45
|
end
|
data/tests/test_ssl_verify.rb
CHANGED
@@ -98,6 +98,7 @@ class TestSslVerify < Test::Unit::TestCase
|
|
98
98
|
|
99
99
|
def test_accept_server
|
100
100
|
omit_unless(EM.ssl?)
|
101
|
+
omit_if(EM.library_type == :pure_ruby) # Server has a default cert chain
|
101
102
|
omit_if(rbx?)
|
102
103
|
$client_handshake_completed, $server_handshake_completed = false, false
|
103
104
|
EM.run {
|
@@ -112,6 +113,7 @@ class TestSslVerify < Test::Unit::TestCase
|
|
112
113
|
|
113
114
|
def test_deny_server
|
114
115
|
omit_unless(EM.ssl?)
|
116
|
+
omit_if(EM.library_type == :pure_ruby) # Server has a default cert chain
|
115
117
|
omit_if(rbx?)
|
116
118
|
$client_handshake_completed, $server_handshake_completed = false, false
|
117
119
|
EM.run {
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: eventmachine
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Francis Cianfrocca
|
@@ -9,48 +9,48 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-
|
12
|
+
date: 2016-11-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: test-unit
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
|
-
- - ~>
|
18
|
+
- - "~>"
|
19
19
|
- !ruby/object:Gem::Version
|
20
20
|
version: '2.0'
|
21
21
|
type: :development
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
|
-
- - ~>
|
25
|
+
- - "~>"
|
26
26
|
- !ruby/object:Gem::Version
|
27
27
|
version: '2.0'
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: rake-compiler
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
|
-
- - ~>
|
32
|
+
- - "~>"
|
33
33
|
- !ruby/object:Gem::Version
|
34
34
|
version: 0.9.5
|
35
35
|
type: :development
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
|
-
- - ~>
|
39
|
+
- - "~>"
|
40
40
|
- !ruby/object:Gem::Version
|
41
41
|
version: 0.9.5
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: rake-compiler-dock
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
|
-
- - ~>
|
46
|
+
- - "~>"
|
47
47
|
- !ruby/object:Gem::Version
|
48
48
|
version: 0.5.1
|
49
49
|
type: :development
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
|
-
- - ~>
|
53
|
+
- - "~>"
|
54
54
|
- !ruby/object:Gem::Version
|
55
55
|
version: 0.5.1
|
56
56
|
description: |
|
@@ -106,6 +106,19 @@ files:
|
|
106
106
|
- docs/old/SMTP
|
107
107
|
- docs/old/SPAWNED_PROCESSES
|
108
108
|
- docs/old/TODO
|
109
|
+
- examples/guides/getting_started/01_eventmachine_echo_server.rb
|
110
|
+
- examples/guides/getting_started/02_eventmachine_echo_server_that_recognizes_exit_command.rb
|
111
|
+
- examples/guides/getting_started/03_simple_chat_server.rb
|
112
|
+
- examples/guides/getting_started/04_simple_chat_server_step_one.rb
|
113
|
+
- examples/guides/getting_started/05_simple_chat_server_step_two.rb
|
114
|
+
- examples/guides/getting_started/06_simple_chat_server_step_three.rb
|
115
|
+
- examples/guides/getting_started/07_simple_chat_server_step_four.rb
|
116
|
+
- examples/guides/getting_started/08_simple_chat_server_step_five.rb
|
117
|
+
- examples/old/ex_channel.rb
|
118
|
+
- examples/old/ex_queue.rb
|
119
|
+
- examples/old/ex_tick_loop_array.rb
|
120
|
+
- examples/old/ex_tick_loop_counter.rb
|
121
|
+
- examples/old/helper.rb
|
109
122
|
- ext/binder.cpp
|
110
123
|
- ext/binder.h
|
111
124
|
- ext/cmain.cpp
|
@@ -177,19 +190,7 @@ files:
|
|
177
190
|
- lib/jeventmachine.rb
|
178
191
|
- rakelib/package.rake
|
179
192
|
- rakelib/test.rake
|
180
|
-
-
|
181
|
-
- examples/guides/getting_started/02_eventmachine_echo_server_that_recognizes_exit_command.rb
|
182
|
-
- examples/guides/getting_started/03_simple_chat_server.rb
|
183
|
-
- examples/guides/getting_started/04_simple_chat_server_step_one.rb
|
184
|
-
- examples/guides/getting_started/05_simple_chat_server_step_two.rb
|
185
|
-
- examples/guides/getting_started/06_simple_chat_server_step_three.rb
|
186
|
-
- examples/guides/getting_started/07_simple_chat_server_step_four.rb
|
187
|
-
- examples/guides/getting_started/08_simple_chat_server_step_five.rb
|
188
|
-
- examples/old/ex_channel.rb
|
189
|
-
- examples/old/ex_queue.rb
|
190
|
-
- examples/old/ex_tick_loop_array.rb
|
191
|
-
- examples/old/ex_tick_loop_counter.rb
|
192
|
-
- examples/old/helper.rb
|
193
|
+
- rakelib/test_pure.rake
|
193
194
|
- tests/client.crt
|
194
195
|
- tests/client.key
|
195
196
|
- tests/dhparam.pem
|
@@ -264,29 +265,29 @@ licenses:
|
|
264
265
|
metadata: {}
|
265
266
|
post_install_message:
|
266
267
|
rdoc_options:
|
267
|
-
- --title
|
268
|
+
- "--title"
|
268
269
|
- EventMachine
|
269
|
-
- --main
|
270
|
+
- "--main"
|
270
271
|
- README.md
|
271
|
-
- -x
|
272
|
+
- "-x"
|
272
273
|
- lib/em/version
|
273
|
-
- -x
|
274
|
+
- "-x"
|
274
275
|
- lib/jeventmachine
|
275
276
|
require_paths:
|
276
277
|
- lib
|
277
278
|
required_ruby_version: !ruby/object:Gem::Requirement
|
278
279
|
requirements:
|
279
|
-
- -
|
280
|
+
- - ">="
|
280
281
|
- !ruby/object:Gem::Version
|
281
282
|
version: '0'
|
282
283
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
283
284
|
requirements:
|
284
|
-
- -
|
285
|
+
- - ">="
|
285
286
|
- !ruby/object:Gem::Version
|
286
287
|
version: '0'
|
287
288
|
requirements: []
|
288
289
|
rubyforge_project:
|
289
|
-
rubygems_version: 2.
|
290
|
+
rubygems_version: 2.5.1
|
290
291
|
signing_key:
|
291
292
|
specification_version: 4
|
292
293
|
summary: Ruby/EventMachine library
|