faye-websocket 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of faye-websocket might be problematic. Click here for more details.
@@ -0,0 +1,21 @@
|
|
1
|
+
defaults
|
2
|
+
mode http
|
3
|
+
timeout client 5s
|
4
|
+
timeout connect 5s
|
5
|
+
timeout server 5s
|
6
|
+
|
7
|
+
frontend all 0.0.0.0:3000
|
8
|
+
mode http
|
9
|
+
timeout client 120s
|
10
|
+
|
11
|
+
option forwardfor
|
12
|
+
option http-server-close
|
13
|
+
option http-pretend-keepalive
|
14
|
+
|
15
|
+
default_backend sockets
|
16
|
+
|
17
|
+
backend sockets
|
18
|
+
balance uri depth 2
|
19
|
+
timeout server 120s
|
20
|
+
server socket1 127.0.0.1:7000
|
21
|
+
|
data/lib/faye/websocket.rb
CHANGED
@@ -80,7 +80,10 @@ module Faye
|
|
80
80
|
event.init_event('open', false, false)
|
81
81
|
dispatch_event(event)
|
82
82
|
|
83
|
-
@env[Thin::Request::WEBSOCKET_RECEIVE_CALLBACK] =
|
83
|
+
@env[Thin::Request::WEBSOCKET_RECEIVE_CALLBACK] = lambda do |data|
|
84
|
+
response = @parser.parse(data)
|
85
|
+
@stream.write(response) if response
|
86
|
+
end
|
84
87
|
end
|
85
88
|
|
86
89
|
private
|
@@ -8,16 +8,7 @@ module Faye
|
|
8
8
|
|
9
9
|
def handshake_response
|
10
10
|
env = @socket.env
|
11
|
-
|
12
|
-
key1 = env['HTTP_SEC_WEBSOCKET_KEY1']
|
13
|
-
value1 = number_from_key(key1) / spaces_in_key(key1)
|
14
|
-
|
15
|
-
key2 = env['HTTP_SEC_WEBSOCKET_KEY2']
|
16
|
-
value2 = number_from_key(key2) / spaces_in_key(key2)
|
17
|
-
|
18
|
-
hash = Digest::MD5.digest(big_endian(value1) +
|
19
|
-
big_endian(value2) +
|
20
|
-
env['rack.input'].read)
|
11
|
+
signature = handshake_signature(env['rack.input'].read)
|
21
12
|
|
22
13
|
upgrade = "HTTP/1.1 101 Web Socket Protocol Handshake\r\n"
|
23
14
|
upgrade << "Upgrade: WebSocket\r\n"
|
@@ -25,10 +16,32 @@ module Faye
|
|
25
16
|
upgrade << "Sec-WebSocket-Origin: #{env['HTTP_ORIGIN']}\r\n"
|
26
17
|
upgrade << "Sec-WebSocket-Location: #{@socket.url}\r\n"
|
27
18
|
upgrade << "\r\n"
|
28
|
-
upgrade <<
|
19
|
+
upgrade << signature if signature
|
29
20
|
upgrade
|
30
21
|
end
|
31
22
|
|
23
|
+
def handshake_signature(head)
|
24
|
+
return nil if head.empty?
|
25
|
+
@handshake_complete = true
|
26
|
+
|
27
|
+
env = @socket.env
|
28
|
+
|
29
|
+
key1 = env['HTTP_SEC_WEBSOCKET_KEY1']
|
30
|
+
value1 = number_from_key(key1) / spaces_in_key(key1)
|
31
|
+
|
32
|
+
key2 = env['HTTP_SEC_WEBSOCKET_KEY2']
|
33
|
+
value2 = number_from_key(key2) / spaces_in_key(key2)
|
34
|
+
|
35
|
+
Digest::MD5.digest(big_endian(value1) +
|
36
|
+
big_endian(value2) +
|
37
|
+
head)
|
38
|
+
end
|
39
|
+
|
40
|
+
def parse(data)
|
41
|
+
return super if @handshake_complete
|
42
|
+
handshake_signature(data)
|
43
|
+
end
|
44
|
+
|
32
45
|
private
|
33
46
|
|
34
47
|
def number_from_key(key)
|
metadata
CHANGED
@@ -1,109 +1,144 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: faye-websocket
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 31
|
5
5
|
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
- 2
|
10
|
+
version: 0.1.2
|
6
11
|
platform: ruby
|
7
|
-
authors:
|
12
|
+
authors:
|
8
13
|
- James Coglan
|
9
14
|
autorequire:
|
10
15
|
bindir: bin
|
11
16
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
17
|
+
|
18
|
+
date: 2011-12-05 00:00:00 Z
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
15
21
|
name: eventmachine
|
16
|
-
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
17
24
|
none: false
|
18
|
-
requirements:
|
19
|
-
- -
|
20
|
-
- !ruby/object:Gem::Version
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
hash: 47
|
29
|
+
segments:
|
30
|
+
- 0
|
31
|
+
- 12
|
32
|
+
- 0
|
21
33
|
version: 0.12.0
|
22
34
|
type: :runtime
|
23
|
-
|
24
|
-
|
25
|
-
- !ruby/object:Gem::Dependency
|
35
|
+
version_requirements: *id001
|
36
|
+
- !ruby/object:Gem::Dependency
|
26
37
|
name: thin
|
27
|
-
|
38
|
+
prerelease: false
|
39
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
28
40
|
none: false
|
29
|
-
requirements:
|
41
|
+
requirements:
|
30
42
|
- - ~>
|
31
|
-
- !ruby/object:Gem::Version
|
32
|
-
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
hash: 11
|
45
|
+
segments:
|
46
|
+
- 1
|
47
|
+
- 2
|
48
|
+
version: "1.2"
|
33
49
|
type: :runtime
|
34
|
-
|
35
|
-
|
36
|
-
- !ruby/object:Gem::Dependency
|
50
|
+
version_requirements: *id002
|
51
|
+
- !ruby/object:Gem::Dependency
|
37
52
|
name: rspec
|
38
|
-
|
53
|
+
prerelease: false
|
54
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
39
55
|
none: false
|
40
|
-
requirements:
|
56
|
+
requirements:
|
41
57
|
- - ~>
|
42
|
-
- !ruby/object:Gem::Version
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
hash: 27
|
60
|
+
segments:
|
61
|
+
- 2
|
62
|
+
- 5
|
63
|
+
- 0
|
43
64
|
version: 2.5.0
|
44
65
|
type: :development
|
45
|
-
|
46
|
-
|
47
|
-
- !ruby/object:Gem::Dependency
|
66
|
+
version_requirements: *id003
|
67
|
+
- !ruby/object:Gem::Dependency
|
48
68
|
name: rack
|
49
|
-
|
69
|
+
prerelease: false
|
70
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
50
71
|
none: false
|
51
|
-
requirements:
|
52
|
-
- -
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
hash: 3
|
76
|
+
segments:
|
77
|
+
- 0
|
78
|
+
version: "0"
|
55
79
|
type: :development
|
56
|
-
|
57
|
-
version_requirements: *5558480
|
80
|
+
version_requirements: *id004
|
58
81
|
description:
|
59
82
|
email: jcoglan@gmail.com
|
60
83
|
executables: []
|
84
|
+
|
61
85
|
extensions: []
|
62
|
-
|
86
|
+
|
87
|
+
extra_rdoc_files:
|
63
88
|
- README.rdoc
|
64
|
-
files:
|
89
|
+
files:
|
65
90
|
- README.rdoc
|
91
|
+
- examples/autobahn_client.rb
|
66
92
|
- examples/client.rb
|
67
|
-
- examples/
|
93
|
+
- examples/haproxy.conf
|
68
94
|
- examples/index.html
|
69
|
-
- examples/
|
70
|
-
- lib/faye/
|
95
|
+
- examples/server.rb
|
96
|
+
- lib/faye/thin_extensions.rb
|
97
|
+
- lib/faye/websocket/api.rb
|
71
98
|
- lib/faye/websocket/client.rb
|
72
|
-
- lib/faye/websocket/
|
99
|
+
- lib/faye/websocket/draft75_parser.rb
|
73
100
|
- lib/faye/websocket/draft76_parser.rb
|
74
|
-
- lib/faye/websocket/
|
101
|
+
- lib/faye/websocket/protocol8_parser.rb
|
75
102
|
- lib/faye/websocket.rb
|
76
|
-
- lib/faye/thin_extensions.rb
|
77
|
-
- spec/faye/websocket/draft75_parser_spec.rb
|
78
103
|
- spec/faye/websocket/client_spec.rb
|
104
|
+
- spec/faye/websocket/draft75_parser_spec.rb
|
79
105
|
- spec/faye/websocket/protocol8_parser_spec.rb
|
80
|
-
- spec/server.key
|
81
106
|
- spec/server.crt
|
107
|
+
- spec/server.key
|
82
108
|
- spec/spec_helper.rb
|
83
109
|
homepage: http://github.com/jcoglan/faye-websocket-ruby
|
84
110
|
licenses: []
|
111
|
+
|
85
112
|
post_install_message:
|
86
|
-
rdoc_options:
|
113
|
+
rdoc_options:
|
87
114
|
- --main
|
88
115
|
- README.rdoc
|
89
|
-
require_paths:
|
116
|
+
require_paths:
|
90
117
|
- lib
|
91
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
118
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
92
119
|
none: false
|
93
|
-
requirements:
|
94
|
-
- -
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
|
97
|
-
|
120
|
+
requirements:
|
121
|
+
- - ">="
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
hash: 3
|
124
|
+
segments:
|
125
|
+
- 0
|
126
|
+
version: "0"
|
127
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
98
128
|
none: false
|
99
|
-
requirements:
|
100
|
-
- -
|
101
|
-
- !ruby/object:Gem::Version
|
102
|
-
|
129
|
+
requirements:
|
130
|
+
- - ">="
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
hash: 3
|
133
|
+
segments:
|
134
|
+
- 0
|
135
|
+
version: "0"
|
103
136
|
requirements: []
|
137
|
+
|
104
138
|
rubyforge_project:
|
105
139
|
rubygems_version: 1.8.10
|
106
140
|
signing_key:
|
107
141
|
specification_version: 3
|
108
142
|
summary: Robust general-purpose WebSocket server and client
|
109
143
|
test_files: []
|
144
|
+
|