gripcontrol 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/gripcontrol.rb +22 -25
- data/lib/websocketmessageformat.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9b62afb4338b37256758b58f1e959e40c5f45212
|
4
|
+
data.tar.gz: 21ffa0c1927a93ce093d5315d5d0eaae6b12ed58
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1aedadcb5d5559803db3fd53c7c91d4b46b47918bf9b2fc513f2d1ed611520155f295b36ca5208e00b47c1773c80f29844a80b99b69ec65713073a5ac39f2045
|
7
|
+
data.tar.gz: d3dd7823ac5e8c2a481e0daaaf0258f59e96e422668e257ccf45ccd833e4ed7c2e1ebfa4a54b5655b148a5c0deaa0b50329ecf532288e33325e85f69b2173cea
|
data/lib/gripcontrol.rb
CHANGED
@@ -87,12 +87,18 @@ class GripControl
|
|
87
87
|
if !key.nil? and key.start_with?('base64:')
|
88
88
|
key = Base64.decode64(key[7..-1])
|
89
89
|
end
|
90
|
-
qs =
|
90
|
+
qs = []
|
91
|
+
params.map do |name,values|
|
92
|
+
values.map do |value|
|
93
|
+
qs.push('#{CGI.escape name}=#{CGI.escape value}')
|
94
|
+
end
|
95
|
+
end
|
96
|
+
qs = qs.join('&')
|
91
97
|
path = uri.path
|
92
98
|
if path.end_with?('/')
|
93
99
|
path = path[0..-2]
|
94
100
|
end
|
95
|
-
control_uri =
|
101
|
+
control_uri = uri.scheme + '://' + uri.host + path
|
96
102
|
if !qs.nil? and !qs.empty?
|
97
103
|
control_uri += '?' + qs
|
98
104
|
end
|
@@ -109,14 +115,14 @@ class GripControl
|
|
109
115
|
def self.validate_sig(token, key)
|
110
116
|
token = token.encode('utf-8')
|
111
117
|
begin
|
112
|
-
claim = JWT.decode(token, key, verify_expiration
|
118
|
+
claim = JWT.decode(token, key, true, {verify_expiration: false})
|
113
119
|
rescue
|
114
120
|
return false
|
115
121
|
end
|
116
|
-
if !claim.key?('exp')
|
122
|
+
if claim.length == 0 or !claim[0].key?('exp')
|
117
123
|
return false
|
118
124
|
end
|
119
|
-
if Time.now.utc.to_i >= claim['exp']
|
125
|
+
if Time.now.utc.to_i >= claim[0]['exp']
|
120
126
|
return false
|
121
127
|
end
|
122
128
|
return true
|
@@ -152,23 +158,24 @@ class GripControl
|
|
152
158
|
out = []
|
153
159
|
start = 0
|
154
160
|
while start < body.length do
|
155
|
-
at = body.index(
|
156
|
-
if
|
161
|
+
at = body.index("\r\n", start)
|
162
|
+
if at.nil?
|
157
163
|
raise 'bad format'
|
158
164
|
end
|
159
165
|
typeline = body[start..at - 1]
|
160
166
|
start = at + 2
|
161
167
|
at = typeline.index(' ')
|
168
|
+
event = nil
|
162
169
|
if !at.nil?
|
163
170
|
etype = typeline[0..at - 1]
|
164
|
-
clen = ('0x' + typeline[at + 1..-1]).
|
165
|
-
content = body[start
|
171
|
+
clen = ('0x' + typeline[at + 1..-1]).to_i(16)
|
172
|
+
content = body[start..start + clen - 1]
|
166
173
|
start += clen + 2
|
167
|
-
|
174
|
+
event = WebSocketEvent.new(etype, content)
|
168
175
|
else
|
169
|
-
|
176
|
+
event = WebSocketEvent.new(typeline)
|
170
177
|
end
|
171
|
-
out.push(
|
178
|
+
out.push(event)
|
172
179
|
end
|
173
180
|
return out
|
174
181
|
end
|
@@ -177,9 +184,10 @@ class GripControl
|
|
177
184
|
out = ''
|
178
185
|
events.each do |event|
|
179
186
|
if !event.content.nil?
|
180
|
-
out +=
|
187
|
+
out += "%s %x\r\n%s\r\n" % [event.type, event.content.length,
|
188
|
+
event.content]
|
181
189
|
else
|
182
|
-
out +=
|
190
|
+
out += "%s\r\n" % [event.type]
|
183
191
|
end
|
184
192
|
end
|
185
193
|
return out
|
@@ -194,15 +202,4 @@ class GripControl
|
|
194
202
|
out['type'] = type
|
195
203
|
return out.to_json
|
196
204
|
end
|
197
|
-
|
198
|
-
private
|
199
|
-
|
200
|
-
def build_query_string(params)
|
201
|
-
params.map do |name,values|
|
202
|
-
values.map do |value|
|
203
|
-
'#{CGI.escape name}=#{CGI.escape value}'
|
204
|
-
end
|
205
|
-
end.flatten.join('&')
|
206
|
-
end
|
207
|
-
|
208
205
|
end
|
@@ -22,9 +22,9 @@ class WebSocketMessageFormat < Format
|
|
22
22
|
def export
|
23
23
|
out = Hash.new
|
24
24
|
if @content.encoding.name == 'ASCII-8BIT'
|
25
|
-
out['
|
25
|
+
out['content-bin'] = Base64.encode64(@content)
|
26
26
|
else
|
27
|
-
out['
|
27
|
+
out['content'] = @content
|
28
28
|
end
|
29
29
|
return out
|
30
30
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gripcontrol
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Konstantin Bokarius
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-01-
|
11
|
+
date: 2015-01-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pubcontrol
|