quaff 0.6.1 → 0.6.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/endpoint.rb +29 -9
- 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: 74ddf7205f6389ce8025f6f4603efcb2c96802bf
|
4
|
+
data.tar.gz: 53d6859c95082cfb58a6aa1f65641041f2a9db32
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4c2bd36727ba79e1c1108938d944fa1a0907a3bb3e139541aab08fdf8f785eac5c645017fb980adfa1f8c9c762c6432c5848da73ac30af9561d2eba9e6edcc0b
|
7
|
+
data.tar.gz: 67a217de9d2bcf196f5cdc910ea7fb6c2065492180abd68d9134356960999057487d47fedfb98c3bfccb54195744ba2b812835359476b022462e9c2e19a72837
|
data/lib/endpoint.rb
CHANGED
@@ -7,6 +7,7 @@ require 'securerandom'
|
|
7
7
|
#require 'milenage'
|
8
8
|
require_relative './sip_parser.rb'
|
9
9
|
require_relative './sources.rb'
|
10
|
+
require 'digest/md5'
|
10
11
|
|
11
12
|
module Quaff
|
12
13
|
class BaseEndpoint
|
@@ -20,9 +21,14 @@ module Quaff
|
|
20
21
|
@sdp_port = @sdp_socket.addr[1]
|
21
22
|
end
|
22
23
|
|
24
|
+
def terminate
|
25
|
+
@terminated = true
|
26
|
+
terminate_specific
|
27
|
+
end
|
28
|
+
|
23
29
|
# Cleans up the endpoint - designed to be overriden by
|
24
30
|
# per-transport subclasses
|
25
|
-
def
|
31
|
+
def terminate_specific
|
26
32
|
end
|
27
33
|
|
28
34
|
# Adds a socket connection to another UA - designed to be
|
@@ -38,7 +44,7 @@ module Quaff
|
|
38
44
|
rescue Timeout::Error
|
39
45
|
raise "#{ @uri } timed out waiting for new incoming call"
|
40
46
|
end
|
41
|
-
|
47
|
+
|
42
48
|
puts "Call-Id for endpoint on #{@local_port} is #{call_id}" if @msg_trace
|
43
49
|
Call.new(self, call_id, @instance_id, @uri)
|
44
50
|
end
|
@@ -84,6 +90,7 @@ module Quaff
|
|
84
90
|
if outbound_proxy
|
85
91
|
@outbound_connection = new_connection(outbound_proxy, outbound_port)
|
86
92
|
end
|
93
|
+
@hashes = []
|
87
94
|
initialize_queues
|
88
95
|
start
|
89
96
|
end
|
@@ -178,16 +185,27 @@ module Quaff
|
|
178
185
|
|
179
186
|
def start
|
180
187
|
Thread.new do
|
181
|
-
|
188
|
+
until @terminated do
|
182
189
|
recv_msg
|
183
190
|
end
|
184
191
|
end
|
185
192
|
end
|
186
193
|
|
194
|
+
def is_retransmission? msg
|
195
|
+
@hashes.include? Digest::MD5.hexdigest(msg.to_s)
|
196
|
+
end
|
197
|
+
|
187
198
|
def queue_msg(msg, source)
|
199
|
+
if is_retransmission? msg
|
200
|
+
@msg_log.push "Endpoint on #{@local_port} received retransmission"
|
201
|
+
puts "Endpoint on #{@local_port} received retransmission" if @msg_trace
|
202
|
+
return
|
203
|
+
end
|
204
|
+
|
205
|
+
@hashes.push Digest::MD5.hexdigest(msg.to_s)
|
206
|
+
|
188
207
|
@msg_log.push "Endpoint on #{@local_port} received:\n\n#{msg.to_s.strip}\n\nfrom #{source.inspect}"
|
189
|
-
puts "Endpoint on #{@local_port} received #{msg} from
|
190
|
-
##{source.inspect}" if @msg_trace
|
208
|
+
puts "Endpoint on #{@local_port} received #{msg} from #{source.inspect}" if @msg_trace
|
191
209
|
msg.source = source
|
192
210
|
cid = @parser.message_identifier msg
|
193
211
|
if cid and not @dead_calls.has_key? cid then
|
@@ -215,7 +233,7 @@ module Quaff
|
|
215
233
|
@sockets.push sock
|
216
234
|
end
|
217
235
|
|
218
|
-
def
|
236
|
+
def terminate_specific
|
219
237
|
oldsockets = @sockets.dup
|
220
238
|
@sockets = []
|
221
239
|
oldsockets.each do |s| s.close unless s.closed? end
|
@@ -242,8 +260,10 @@ module Quaff
|
|
242
260
|
|
243
261
|
|
244
262
|
def recv_msg
|
263
|
+
warn "recv_msg called for an endpoint with no sockets - will tight-loop" if (@sockets.empty? and @cxn.nil?)
|
245
264
|
select_response = IO.select(@sockets, [], [], 0) || [[]]
|
246
265
|
readable = select_response[0]
|
266
|
+
|
247
267
|
for sock in readable do
|
248
268
|
recv_msg_from_sock sock
|
249
269
|
end
|
@@ -258,13 +278,13 @@ module Quaff
|
|
258
278
|
end
|
259
279
|
|
260
280
|
def recv_msg_from_sock(sock)
|
261
|
-
|
262
|
-
|
281
|
+
@parser.parse_start
|
282
|
+
msg = nil
|
263
283
|
while msg.nil? and not sock.closed? do
|
264
284
|
line = sock.gets
|
265
285
|
msg = @parser.parse_partial line
|
266
286
|
end
|
267
|
-
|
287
|
+
queue_msg msg, TCPSourceFromSocket.new(sock)
|
268
288
|
end
|
269
289
|
end
|
270
290
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: quaff
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rob Day
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-08-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: facter
|