quaff 0.6.4 → 0.7.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a895465f0bde96df434080696bd6714559094e1e
4
- data.tar.gz: 374f06b143b8a8521b74190ecb62f2d94ed46c3b
3
+ metadata.gz: 949d3d3297af3698c62260c05c9df90cddd4746f
4
+ data.tar.gz: 9dfd7365fa83aa3496e4899e350147aa835304f5
5
5
  SHA512:
6
- metadata.gz: 53df81ef519babdb433ba3c50cc79de84b2db8943d57ca866750523db78ae0ddc51c932ba02271edb7bf81576a4f56813214b861dd855f9de27f7aacd3b20255
7
- data.tar.gz: f4ade0985a3d7067eabbd2504a2a1eb759be9e472efd69b8ea27e39cf1bca1491331088dfb129daf833395cc37a03763bfc434dca8fbdf970e6202a847049058
6
+ metadata.gz: 64042022ef1b3a688894d32b0ada0fea9724dc0ea6e8c92cf2219a9e28bf4ae72197176ec44f65e2d794d087e96812b09290e8e4b512d3648fa29e86e5f28085
7
+ data.tar.gz: 25116f133f345cde8ecba6dd6c964dcc628e2ee501980ec1abc1bd8b32e892ee14b5c99194c35baa97ef42b66d30a9499807c525305f3b24fd4b1baf497cfd92
data/lib/call.rb CHANGED
@@ -22,7 +22,7 @@ module Quaff
22
22
  def to_s
23
23
  "#{@num.to_s} #{@method}"
24
24
  end
25
- end
25
+ end
26
26
 
27
27
  class Call
28
28
  attr_reader :cid
data/lib/endpoint.rb CHANGED
@@ -11,7 +11,7 @@ require 'digest/md5'
11
11
 
12
12
  module Quaff
13
13
  class BaseEndpoint
14
- attr_accessor :msg_trace, :uri, :sdp_port, :sdp_socket, :contact_header
14
+ attr_accessor :msg_trace, :uri, :sdp_port, :sdp_socket
15
15
  attr_reader :msg_log, :local_port, :instance_id
16
16
 
17
17
  # Creates an SDP socket bound to an ephemeral port
@@ -36,9 +36,24 @@ module Quaff
36
36
  def add_sock sock
37
37
  end
38
38
 
39
+ def add_contact_param name, value
40
+ @contact_params[name] = value
41
+ end
42
+
43
+ def add_contact_uri_param name, value
44
+ @contact_uri_params[name] = value
45
+ end
46
+
47
+ def remove_contact_param name
48
+ @contact_params.delete name
49
+ end
50
+
51
+ def remove_contact_uri_param name
52
+ @contact_uri_params.delete name
53
+ end
54
+
39
55
  def instance_id= id
40
- @instance_id = id
41
- @contact_header += ";+sip.instance=\"<urn:uuid:"+@instance_id+">\""
56
+ add_contact_param "+sip.instance", "\"<urn:uuid:#{id}>\""
42
57
  end
43
58
 
44
59
  # Retrieves the next unhandled call for this endpoint and returns
@@ -96,11 +111,19 @@ module Quaff
96
111
  @outbound_connection = new_connection(outbound_proxy, outbound_port)
97
112
  end
98
113
  @hashes = []
99
- @contact_header = "<sip:quaff@#{Utils::local_ip}:#{@local_port};transport=#{transport};ob>"
114
+ @contact_params = {}
115
+ @contact_uri_params = {"transport" => transport, "ob" => true}
116
+ @terminated = false
100
117
  initialize_queues
101
118
  start
102
119
  end
103
120
 
121
+ def contact_header
122
+ param_str = Utils.paramhash_to_str(@contact_params)
123
+ uri_param_str = Utils.paramhash_to_str(@contact_uri_params)
124
+ "<sip:quaff@#{Utils::local_ip}:#{@local_port}#{uri_param_str}>#{param_str}"
125
+ end
126
+
104
127
  def send_msg(data, source) # :nodoc:
105
128
  @msg_log.push "Endpoint on #{@local_port} sending:\n\n#{data.strip}\n\nto #{source.inspect}"
106
129
  puts "Endpoint on #{@local_port} sending #{data} to #{source.inspect}" if @msg_trace
data/lib/sip_parser.rb CHANGED
@@ -137,7 +137,7 @@ module Quaff
137
137
  end
138
138
 
139
139
  def hostname
140
- Repetition.new([:at_least, 1], Alternate.new(alphanum, Char.new(?.)))
140
+ Repetition.new([:at_least, 1], Alternate.new(alphanum, Char.new(?.), Char.new(?-)))
141
141
  end
142
142
 
143
143
  def port
@@ -223,7 +223,7 @@ module Quaff
223
223
  end
224
224
 
225
225
  def to_spec
226
- Concat.new(Alternate.new(addr_spec, name_addr), Repetition.new(:any, Concat.new(Char.new(?;), from_param)))
226
+ Concat.new(Alternate.new(addr_spec, name_addr), Repetition.new(:any, Concat.new(Char.new(?;), to_param)))
227
227
  end
228
228
  end
229
229
 
@@ -242,7 +242,7 @@ module Quaff
242
242
  end
243
243
 
244
244
  def display_name
245
- super.set_block {|p| @display_name = p; @is_nameaddr = true}
245
+ super.set_block {|p| @displayname = p.strip; @is_nameaddr = true}
246
246
  end
247
247
 
248
248
  def addr_spec
@@ -258,7 +258,7 @@ module Quaff
258
258
  end
259
259
 
260
260
  def to_s
261
- paramstr = @params.collect {|k, v| if (v == true) then ";#{k}" else ";#{k}=#{v}" end}.join("")
261
+ paramstr = Utils.paramhash_to_str(@params)
262
262
  if @is_nameaddr
263
263
  "#{@displayname} <#{@uri}>#{paramstr}"
264
264
  else
data/lib/utils.rb CHANGED
@@ -1,11 +1,18 @@
1
1
  require 'socket'
2
- require 'facter'
2
+ require 'system/getifaddrs'
3
3
 
4
4
  module Quaff
5
5
 
6
6
  module Utils #:nodoc:
7
7
  def Utils.local_ip
8
- Facter.value("ipaddress")
8
+ addrs = System.get_ifaddrs
9
+ if addrs.empty?
10
+ "0.0.0.0"
11
+ elsif (addrs.size == 1)
12
+ addrs[0][:inet_addr]
13
+ else
14
+ addrs.select {|k, v| k != :lo}.shift[1][:inet_addr]
15
+ end
9
16
  end
10
17
 
11
18
  def Utils.pid
@@ -19,5 +26,10 @@ end
19
26
  def Utils.new_branch
20
27
  "z9hG4bK#{Time.new.to_f}"
21
28
  end
29
+
30
+ def Utils.paramhash_to_str params
31
+ params.collect {|k, v| if (v == true) then ";#{k}" else ";#{k}=#{v}" end}.join("")
32
+ end
33
+
22
34
  end
23
35
  end
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: quaff
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.4
4
+ version: 0.7.0
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-08-21 00:00:00.000000000 Z
11
+ date: 2014-09-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: facter
14
+ name: system-getifaddrs
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - '>='
18
18
  - !ruby/object:Gem::Version
19
- version: 1.7.3
19
+ version: 0.2.1
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '>='
25
25
  - !ruby/object:Gem::Version
26
- version: 1.7.3
26
+ version: 0.2.1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: milenage
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -58,10 +58,10 @@ executables: []
58
58
  extensions: []
59
59
  extra_rdoc_files: []
60
60
  files:
61
- - lib/call.rb
62
61
  - lib/endpoint.rb
63
- - lib/message.rb
62
+ - lib/call.rb
64
63
  - lib/quaff.rb
64
+ - lib/message.rb
65
65
  - lib/sources.rb
66
66
  - lib/utils.rb
67
67
  - lib/sip_parser.rb