oversip 1.3.8 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +1 -1
- data/etc/oversip.conf +28 -0
- data/ext/sip_parser/{sip_parser.c → sip_message_parser.c} +119 -119
- data/ext/sip_parser/sip_parser.h +24 -2
- data/ext/sip_parser/sip_parser_ruby.c +84 -27
- data/ext/sip_parser/sip_uri_parser.c +39699 -0
- data/lib/oversip/config.rb +14 -0
- data/lib/oversip/errors.rb +3 -0
- data/lib/oversip/modules/outbound_mangling.rb +20 -24
- data/lib/oversip/sip/client.rb +135 -11
- data/lib/oversip/sip/launcher.rb +82 -38
- data/lib/oversip/sip/name_addr.rb +8 -0
- data/lib/oversip/sip/proxy.rb +22 -13
- data/lib/oversip/sip/request.rb +31 -1
- data/lib/oversip/sip/uac.rb +9 -13
- data/lib/oversip/sip/uac_request.rb +11 -10
- data/lib/oversip/sip/uri.rb +24 -0
- data/lib/oversip/version.rb +3 -3
- data/lib/oversip/websocket/launcher.rb +64 -30
- data/lib/oversip.rb +6 -0
- data/test/test_name_addr_parser.rb +24 -0
- data/test/{test_sip_parser.rb → test_sip_message_parser.rb} +15 -1
- data/test/test_sip_uri_parser.rb +56 -0
- data/test/test_uri.rb +11 -0
- data/thirdparty/stud/stud.tar.gz +0 -0
- metadata +10 -5
data/lib/oversip/sip/request.rb
CHANGED
@@ -104,6 +104,36 @@ module OverSIP::SIP
|
|
104
104
|
end
|
105
105
|
|
106
106
|
|
107
|
+
# RFC 6228 (199 response).
|
108
|
+
def reply_199 response
|
109
|
+
# Store the previous internal To-tag (if set).
|
110
|
+
internal_to_tag = @internal_to_tag
|
111
|
+
|
112
|
+
# Set it with the To-tag of the response for which a 199 must eb generated.
|
113
|
+
@internal_to_tag = response.to_tag
|
114
|
+
|
115
|
+
# Send the 199 response.
|
116
|
+
reply 199, "Early Dialog Terminated", [ "Reason: SIP ;cause=#{response.status_code} ;text=\"#{response.reason_phrase}\"" ]
|
117
|
+
|
118
|
+
# Restore the previous internal To-tag.
|
119
|
+
@internal_to_tag = internal_to_tag
|
120
|
+
true
|
121
|
+
end
|
122
|
+
private :reply_199
|
123
|
+
|
124
|
+
|
125
|
+
def ruri= ruri
|
126
|
+
case ruri
|
127
|
+
when ::OverSIP::SIP::Uri, ::OverSIP::SIP::NameAddr
|
128
|
+
@ruri = ruri
|
129
|
+
when ::String
|
130
|
+
@ruri = OverSIP::SIP::Uri.parse ruri
|
131
|
+
else
|
132
|
+
raise ::OverSIP::RuntimeError, "invalid URI #{ruri.inspect}"
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
|
107
137
|
def send_response(response)
|
108
138
|
unless (case @transport
|
109
139
|
when :udp
|
@@ -118,7 +148,7 @@ module OverSIP::SIP
|
|
118
148
|
|
119
149
|
|
120
150
|
def to_s
|
121
|
-
msg = "#{@sip_method.to_s} #{
|
151
|
+
msg = "#{@sip_method.to_s} #{@ruri.uri} SIP/2.0\r\n"
|
122
152
|
|
123
153
|
# Update From/To/Contact headers if modified.
|
124
154
|
if @from.modified?
|
data/lib/oversip/sip/uac.rb
CHANGED
@@ -2,7 +2,6 @@ module OverSIP::SIP
|
|
2
2
|
|
3
3
|
class Uac < Client
|
4
4
|
|
5
|
-
|
6
5
|
def route request, dst_host=nil, dst_port=nil, dst_transport=nil
|
7
6
|
unless (@request = request).is_a? ::OverSIP::SIP::UacRequest or @request.is_a? ::OverSIP::SIP::Request
|
8
7
|
raise ::OverSIP::RuntimeError, "request must be a OverSIP::SIP::UacRequest or OverSIP::SIP::Request instance"
|
@@ -10,11 +9,8 @@ module OverSIP::SIP
|
|
10
9
|
|
11
10
|
# The destination of the request is taken from:
|
12
11
|
# - dst_xxx fields if given.
|
13
|
-
# - The request.ruri
|
12
|
+
# - The request.ruri (which is an OverSIP::SIP::Uri or OverSIP::SIP::NameAddr).
|
14
13
|
# Otherwise raise an exception.
|
15
|
-
unless dst_host or request.ruri.is_a?(::OverSIP::SIP::Uri) or request.ruri.is_a?(::OverSIP::SIP::NameAddr)
|
16
|
-
raise ::OverSIP::RuntimeError, "if dst_host is not given then request.ruri must be an OverSIP::SIP::Uri or OverSIP::SIP::NameAddr instance"
|
17
|
-
end
|
18
14
|
|
19
15
|
@log_id = "UAC (proxy #{@conf[:name]})"
|
20
16
|
|
@@ -49,26 +45,26 @@ module OverSIP::SIP
|
|
49
45
|
do_dns result, @request.via_branch_id, dst_scheme, dst_host, dst_host_type, dst_port, dst_transport
|
50
46
|
end
|
51
47
|
|
52
|
-
end # def
|
48
|
+
end # def route
|
53
49
|
|
54
50
|
|
55
51
|
def receive_response response
|
56
52
|
log_system_debug "received response #{response.status_code}" if $oversip_debug
|
57
53
|
|
58
54
|
if response.status_code < 200
|
59
|
-
|
55
|
+
run_on_provisional_response_cbs response
|
60
56
|
elsif response.status_code >= 200 && response.status_code <= 299
|
61
|
-
|
57
|
+
run_on_success_response_cbs response
|
62
58
|
elsif response.status_code >= 300
|
63
59
|
if response.status_code == 503
|
64
60
|
if @conf[:dns_failover_on_503]
|
65
61
|
try_next_target nil, nil, response
|
66
62
|
return
|
67
63
|
else
|
68
|
-
|
64
|
+
run_on_failure_response_cbs response
|
69
65
|
end
|
70
66
|
else
|
71
|
-
|
67
|
+
run_on_failure_response_cbs response
|
72
68
|
end
|
73
69
|
end
|
74
70
|
end
|
@@ -79,12 +75,12 @@ module OverSIP::SIP
|
|
79
75
|
|
80
76
|
|
81
77
|
def no_more_targets status, reason, full_response, code
|
82
|
-
# If we have received a [3456]XX response from downstream then run @
|
78
|
+
# If we have received a [3456]XX response from downstream then run @on_failure_response_cbs.
|
83
79
|
if full_response
|
84
|
-
|
80
|
+
run_on_failure_response_cbs full_response
|
85
81
|
# If not, generate the response according to the given status and reason.
|
86
82
|
else
|
87
|
-
|
83
|
+
run_on_error_cbs status, reason, code
|
88
84
|
end
|
89
85
|
end
|
90
86
|
|
@@ -15,10 +15,19 @@ module OverSIP::SIP
|
|
15
15
|
unless (@sip_method = data[:sip_method])
|
16
16
|
raise ::OverSIP::RuntimeError, "no data[:sip_method] given"
|
17
17
|
end
|
18
|
-
unless (
|
18
|
+
unless (ruri = data[:ruri])
|
19
19
|
raise ::OverSIP::RuntimeError, "no data[:ruri] given"
|
20
20
|
end
|
21
21
|
|
22
|
+
case ruri
|
23
|
+
when ::OverSIP::SIP::Uri, ::OverSIP::SIP::NameAddr
|
24
|
+
@ruri = ruri
|
25
|
+
when ::String
|
26
|
+
@ruri = OverSIP::SIP::Uri.parse ruri
|
27
|
+
else
|
28
|
+
raise ::OverSIP::RuntimeError, "invalid URI #{ruri.inspect}"
|
29
|
+
end
|
30
|
+
|
22
31
|
@from = data[:from] || DEFAULT_FROM
|
23
32
|
@from_tag = data[:from_tag] || ::SecureRandom.hex(4)
|
24
33
|
@to = data[:to] || @ruri
|
@@ -47,15 +56,7 @@ module OverSIP::SIP
|
|
47
56
|
|
48
57
|
|
49
58
|
def to_s
|
50
|
-
|
51
|
-
ruri = case @ruri
|
52
|
-
when ::String
|
53
|
-
@ruri
|
54
|
-
when ::OverSIP::SIP::Uri, ::OverSIP::SIP::NameAddr
|
55
|
-
@ruri.uri
|
56
|
-
end
|
57
|
-
|
58
|
-
msg = "#{@sip_method.to_s} #{ruri} SIP/2.0\r\n"
|
59
|
+
msg = "#{@sip_method.to_s} #{@ruri.uri} SIP/2.0\r\n"
|
59
60
|
|
60
61
|
@headers.each do |name, value|
|
61
62
|
msg << name << ": #{value}\r\n"
|
data/lib/oversip/sip/uri.rb
CHANGED
@@ -3,6 +3,14 @@ module OverSIP::SIP
|
|
3
3
|
class Uri
|
4
4
|
attr_reader :scheme, :user, :host, :host_type, :port, :params, :transport_param, :phone_context_param, :ovid_param, :headers
|
5
5
|
|
6
|
+
|
7
|
+
def self.parse value
|
8
|
+
uri = ::OverSIP::SIP::MessageParser.parse_uri value, false
|
9
|
+
raise ::OverSIP::ParsingError, "invalid URI #{value.inspect}" unless uri.is_a? (::OverSIP::SIP::Uri)
|
10
|
+
uri
|
11
|
+
end
|
12
|
+
|
13
|
+
|
6
14
|
def initialize scheme=:sip, user=nil, host=nil, port=nil
|
7
15
|
@scheme = scheme.to_sym
|
8
16
|
@user = user
|
@@ -63,7 +71,13 @@ module OverSIP::SIP
|
|
63
71
|
@params ||= {}
|
64
72
|
end
|
65
73
|
|
74
|
+
def has_param? k
|
75
|
+
return nil if unknown_scheme?
|
76
|
+
params.include? k.to_s.downcase
|
77
|
+
end
|
78
|
+
|
66
79
|
def get_param k
|
80
|
+
return nil if unknown_scheme?
|
67
81
|
params[k.to_s.downcase]
|
68
82
|
end
|
69
83
|
|
@@ -84,6 +98,16 @@ module OverSIP::SIP
|
|
84
98
|
false
|
85
99
|
end
|
86
100
|
|
101
|
+
def clear_params
|
102
|
+
return nil if unknown_scheme?
|
103
|
+
return false unless @params
|
104
|
+
@params.clear
|
105
|
+
@transport_param = nil
|
106
|
+
@phone_context_param = nil
|
107
|
+
@uri_modified = true
|
108
|
+
true
|
109
|
+
end
|
110
|
+
|
87
111
|
def transport_param= value
|
88
112
|
return nil unless @scheme == :sip or @scheme == :sips
|
89
113
|
if value
|
data/lib/oversip/version.rb
CHANGED
@@ -4,8 +4,8 @@ module OverSIP
|
|
4
4
|
|
5
5
|
module Version
|
6
6
|
MAJOR = 1
|
7
|
-
MINOR =
|
8
|
-
TINY =
|
7
|
+
MINOR = 4
|
8
|
+
TINY = 0
|
9
9
|
DEVEL = nil # Set to nil for stable releases.
|
10
10
|
end
|
11
11
|
|
@@ -16,6 +16,6 @@ module OverSIP
|
|
16
16
|
AUTHOR_EMAIL = "ibc@aliax.net"
|
17
17
|
HOMEPAGE = "http://www.oversip.net"
|
18
18
|
year = "2012-2013"
|
19
|
-
DESCRIPTION = "#{PROGRAM_NAME} #{VERSION}\n#{HOMEPAGE}\n#{year}, #{AUTHOR} <#{AUTHOR_EMAIL}
|
19
|
+
DESCRIPTION = "#{PROGRAM_NAME} #{VERSION}\n#{HOMEPAGE}\n#{year}, #{AUTHOR} <#{AUTHOR_EMAIL}>\nSoftware by Versatica: http://www.versatica.com"
|
20
20
|
|
21
21
|
end
|
@@ -50,11 +50,16 @@ module OverSIP::WebSocket
|
|
50
50
|
case
|
51
51
|
|
52
52
|
when klass == ::OverSIP::WebSocket::IPv4WsServer
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
53
|
+
if ::OverSIP.configuration[:websocket][:advertised_ipv4]
|
54
|
+
used_uri_host = ::OverSIP.configuration[:websocket][:advertised_ipv4]
|
55
|
+
else
|
56
|
+
used_uri_host = uri_ip
|
57
|
+
end
|
58
|
+
klass.via_core = "SIP/2.0/WS #{used_uri_host}:#{port}"
|
59
|
+
klass.record_route = "<sip:#{used_uri_host}:#{port};transport=ws;lr;ovid=#{OverSIP::SIP::Tags.value_for_route_ovid}>"
|
60
|
+
klass.outbound_record_route_fragment = "@#{used_uri_host}:#{port};transport=ws;lr;ovid=#{OverSIP::SIP::Tags.value_for_route_ovid}>"
|
61
|
+
klass.outbound_path_fragment = "@#{used_uri_host}:#{port};transport=ws;lr;ovid=#{OverSIP::SIP::Tags.value_for_route_ovid};ob>"
|
62
|
+
|
58
63
|
if enabled
|
59
64
|
::EM.start_server(ip, port, klass) do |conn|
|
60
65
|
conn.post_connection
|
@@ -63,10 +68,15 @@ module OverSIP::WebSocket
|
|
63
68
|
end
|
64
69
|
|
65
70
|
when klass == ::OverSIP::WebSocket::IPv6WsServer
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
71
|
+
if ::OverSIP.configuration[:websocket][:advertised_ipv6]
|
72
|
+
used_uri_host = "[#{::OverSIP.configuration[:websocket][:advertised_ipv6]}]"
|
73
|
+
else
|
74
|
+
used_uri_host = uri_ip
|
75
|
+
end
|
76
|
+
klass.via_core = "SIP/2.0/WS #{used_uri_host}:#{port}"
|
77
|
+
klass.record_route = "<sip:#{used_uri_host}:#{port};transport=ws;lr;ovid=#{OverSIP::SIP::Tags.value_for_route_ovid}>"
|
78
|
+
klass.outbound_record_route_fragment = "@#{used_uri_host}:#{port};transport=ws;lr;ovid=#{OverSIP::SIP::Tags.value_for_route_ovid}>"
|
79
|
+
klass.outbound_path_fragment = "@#{used_uri_host}:#{port};transport=ws;lr;ovid=#{OverSIP::SIP::Tags.value_for_route_ovid};ob>"
|
70
80
|
|
71
81
|
if enabled
|
72
82
|
::EM.start_server(ip, port, klass) do |conn|
|
@@ -76,11 +86,17 @@ module OverSIP::WebSocket
|
|
76
86
|
end
|
77
87
|
|
78
88
|
when klass == ::OverSIP::WebSocket::IPv4WssServer
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
89
|
+
if ::OverSIP.configuration[:sip][:record_route_hostname_tls_ipv4]
|
90
|
+
used_uri_host = ::OverSIP.configuration[:sip][:record_route_hostname_tls_ipv4]
|
91
|
+
elsif ::OverSIP.configuration[:websocket][:advertised_ipv4]
|
92
|
+
used_uri_host = ::OverSIP.configuration[:websocket][:advertised_ipv4]
|
93
|
+
else
|
94
|
+
used_uri_host = uri_ip
|
95
|
+
end
|
96
|
+
klass.via_core = "SIP/2.0/WS #{used_uri_host}:#{port}"
|
97
|
+
klass.record_route = "<sip:#{used_uri_host}:#{port};transport=ws;lr;ovid=#{OverSIP::SIP::Tags.value_for_route_ovid}>"
|
98
|
+
klass.outbound_record_route_fragment = "@#{used_uri_host}:#{port};transport=ws;lr;ovid=#{OverSIP::SIP::Tags.value_for_route_ovid}>"
|
99
|
+
klass.outbound_path_fragment = "@#{used_uri_host}:#{port};transport=ws;lr;ovid=#{OverSIP::SIP::Tags.value_for_route_ovid};ob>"
|
84
100
|
|
85
101
|
if enabled
|
86
102
|
::EM.start_server(ip, port, klass) do |conn|
|
@@ -90,11 +106,17 @@ module OverSIP::WebSocket
|
|
90
106
|
end
|
91
107
|
|
92
108
|
when klass == ::OverSIP::WebSocket::IPv6WssServer
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
109
|
+
if ::OverSIP.configuration[:sip][:record_route_hostname_tls_ipv6]
|
110
|
+
used_uri_host = ::OverSIP.configuration[:sip][:record_route_hostname_tls_ipv6]
|
111
|
+
elsif ::OverSIP.configuration[:websocket][:advertised_ipv6]
|
112
|
+
used_uri_host = "[#{::OverSIP.configuration[:websocket][:advertised_ipv6]}]"
|
113
|
+
else
|
114
|
+
used_uri_host = uri_ip
|
115
|
+
end
|
116
|
+
klass.via_core = "SIP/2.0/WS #{used_uri_host}:#{port}"
|
117
|
+
klass.record_route = "<sip:#{used_uri_host}:#{port};transport=ws;lr;ovid=#{OverSIP::SIP::Tags.value_for_route_ovid}>"
|
118
|
+
klass.outbound_record_route_fragment = "@#{used_uri_host}:#{port};transport=ws;lr;ovid=#{OverSIP::SIP::Tags.value_for_route_ovid}>"
|
119
|
+
klass.outbound_path_fragment = "@#{used_uri_host}:#{port};transport=ws;lr;ovid=#{OverSIP::SIP::Tags.value_for_route_ovid};ob>"
|
98
120
|
|
99
121
|
if enabled
|
100
122
|
::EM.start_server(ip, port, klass) do |conn|
|
@@ -104,11 +126,17 @@ module OverSIP::WebSocket
|
|
104
126
|
end
|
105
127
|
|
106
128
|
when klass == ::OverSIP::WebSocket::IPv4WssTunnelServer
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
129
|
+
if ::OverSIP.configuration[:sip][:record_route_hostname_tls_ipv4]
|
130
|
+
used_uri_host = ::OverSIP.configuration[:sip][:record_route_hostname_tls_ipv4]
|
131
|
+
elsif ::OverSIP.configuration[:websocket][:advertised_ipv4]
|
132
|
+
used_uri_host = ::OverSIP.configuration[:websocket][:advertised_ipv4]
|
133
|
+
else
|
134
|
+
used_uri_host = uri_virtual_ip
|
135
|
+
end
|
136
|
+
klass.via_core = "SIP/2.0/WSS #{used_uri_host}:#{virtual_port}"
|
137
|
+
klass.record_route = "<sip:#{used_uri_host}:#{virtual_port};transport=wss;lr;ovid=#{OverSIP::SIP::Tags.value_for_route_ovid}>"
|
138
|
+
klass.outbound_record_route_fragment = "@#{used_uri_host}:#{virtual_port};transport=wss;lr;ovid=#{OverSIP::SIP::Tags.value_for_route_ovid}>"
|
139
|
+
klass.outbound_path_fragment = "@#{used_uri_host}:#{virtual_port};transport=wss;lr;ovid=#{OverSIP::SIP::Tags.value_for_route_ovid};ob>"
|
112
140
|
|
113
141
|
if enabled
|
114
142
|
::EM.start_server(ip, port, klass) do |conn|
|
@@ -118,12 +146,18 @@ module OverSIP::WebSocket
|
|
118
146
|
end
|
119
147
|
|
120
148
|
when klass == ::OverSIP::WebSocket::IPv6WssTunnelServer
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
149
|
+
if ::OverSIP.configuration[:sip][:record_route_hostname_tls_ipv6]
|
150
|
+
used_uri_host = ::OverSIP.configuration[:sip][:record_route_hostname_tls_ipv6]
|
151
|
+
elsif ::OverSIP.configuration[:websocket][:advertised_ipv6]
|
152
|
+
used_uri_host = "[#{::OverSIP.configuration[:websocket][:advertised_ipv6]}]"
|
153
|
+
else
|
154
|
+
used_uri_host = uri_virtual_ip
|
155
|
+
end
|
156
|
+
klass.via_core = "SIP/2.0/WSS #{used_uri_host}:#{virtual_port}"
|
157
|
+
klass.record_route = "<sip:#{used_uri_host}:#{virtual_port};transport=wss;lr;ovid=#{OverSIP::SIP::Tags.value_for_route_ovid}>"
|
158
|
+
klass.outbound_record_route_fragment = "@#{used_uri_host}:#{virtual_port};transport=wss;lr;ovid=#{OverSIP::SIP::Tags.value_for_route_ovid}>"
|
159
|
+
klass.outbound_path_fragment = "@#{used_uri_host}:#{virtual_port};transport=wss;lr;ovid=#{OverSIP::SIP::Tags.value_for_route_ovid};ob>"
|
160
|
+
|
127
161
|
if enabled
|
128
162
|
::EM.start_server(ip, port, klass) do |conn|
|
129
163
|
conn.post_connection
|
data/lib/oversip.rb
CHANGED
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
require "oversip_test_helper"
|
4
|
+
|
5
|
+
|
6
|
+
class TestNameAddrParser < OverSIPTest
|
7
|
+
|
8
|
+
def test_parse_name_addr
|
9
|
+
name_addr_str = '"Iñaki" <sips:i%C3%B1aki@aliax.net:5060;transport=tcp;foo=123;baz?X-Header-1=qwe&X-Header-2=asd>'
|
10
|
+
aor = "sip:i%C3%B1aki@aliax.net"
|
11
|
+
|
12
|
+
name_addr = ::OverSIP::SIP::NameAddr.parse name_addr_str
|
13
|
+
|
14
|
+
assert_equal ::OverSIP::SIP::NameAddr, name_addr.class
|
15
|
+
assert_equal "Iñaki", name_addr.display_name
|
16
|
+
assert_true name_addr.sip?
|
17
|
+
assert_false name_addr.unknown_scheme?
|
18
|
+
assert_equal "iñaki", name_addr.user
|
19
|
+
assert_equal "123", name_addr.get_param("Foo")
|
20
|
+
assert_equal aor, name_addr.aor
|
21
|
+
assert_equal name_addr_str, name_addr.to_s
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
@@ -3,7 +3,7 @@
|
|
3
3
|
require "oversip_test_helper"
|
4
4
|
|
5
5
|
|
6
|
-
class
|
6
|
+
class TestSipMessageParser < OverSIPTest
|
7
7
|
|
8
8
|
def parse data
|
9
9
|
parser = OverSIP::SIP::MessageParser.new
|
@@ -149,6 +149,20 @@ END
|
|
149
149
|
assert_equal ["aaa", "bbb", "ccc"], msg.require
|
150
150
|
assert_equal ["aaa", "bbb", "ccc"], msg.proxy_require
|
151
151
|
assert_equal ["aaa", "bbb", "ccc"], msg.supported
|
152
|
+
|
153
|
+
# Change the full RURI and test again.
|
154
|
+
msg.ruri = ::OverSIP::SIP::Uri.new :sips, "iñaki", "aliax.net", 7070
|
155
|
+
|
156
|
+
assert_equal :sips, msg.ruri.scheme
|
157
|
+
assert_equal "iñaki", msg.ruri.user
|
158
|
+
assert_equal "aliax.net", msg.ruri.host
|
159
|
+
assert_equal :domain, msg.ruri.host_type
|
160
|
+
assert_equal 7070, msg.ruri.port
|
161
|
+
assert_equal({}, msg.ruri.params)
|
162
|
+
assert_nil msg.ruri.headers
|
163
|
+
assert_nil msg.ruri.transport_param
|
164
|
+
assert_nil msg.ruri.phone_context_param
|
165
|
+
assert_equal "sips:i%C3%B1aki@aliax.net:7070", msg.ruri.to_s
|
152
166
|
end
|
153
167
|
|
154
168
|
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
require "oversip_test_helper"
|
4
|
+
|
5
|
+
|
6
|
+
class TestSipUriParser < OverSIPTest
|
7
|
+
|
8
|
+
def test_parse_sip_uri
|
9
|
+
uri_str = "sips:i%C3%B1aki@aliax.net:5060;transport=tcp;foo=123;baz?X-Header-1=qwe&X-Header-2=asd"
|
10
|
+
aor = "sip:i%C3%B1aki@aliax.net"
|
11
|
+
|
12
|
+
uri = ::OverSIP::SIP::Uri.parse uri_str
|
13
|
+
|
14
|
+
assert_equal ::OverSIP::SIP::Uri, uri.class
|
15
|
+
assert_true uri.sip?
|
16
|
+
assert_false uri.unknown_scheme?
|
17
|
+
assert_equal "iñaki", uri.user
|
18
|
+
assert_true uri.has_param? "FOO"
|
19
|
+
assert_false uri.has_param? "LALALA"
|
20
|
+
assert_equal "123", uri.get_param("Foo")
|
21
|
+
assert_equal aor, uri.aor
|
22
|
+
assert_equal uri_str, uri.to_s
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_parse_tel_uri
|
26
|
+
uri_str = "tel:944991212;foo=bar;phone-context=+34"
|
27
|
+
aor = "tel:944991212"
|
28
|
+
|
29
|
+
uri = ::OverSIP::SIP::Uri.parse uri_str
|
30
|
+
|
31
|
+
assert_equal ::OverSIP::SIP::Uri, uri.class
|
32
|
+
assert_true uri.tel?
|
33
|
+
assert_false uri.unknown_scheme?
|
34
|
+
assert_equal "944991212", uri.number
|
35
|
+
assert_true uri.has_param? "FOO"
|
36
|
+
assert_false uri.has_param? "LALALA"
|
37
|
+
assert_equal "bar", uri.get_param("Foo")
|
38
|
+
assert_equal aor, uri.aor
|
39
|
+
assert_equal uri_str, uri.to_s
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_parse_http_uri
|
43
|
+
uri_str = "http://oversip.net/authors/"
|
44
|
+
aor = nil
|
45
|
+
|
46
|
+
uri = ::OverSIP::SIP::Uri.parse uri_str
|
47
|
+
|
48
|
+
assert_equal ::OverSIP::SIP::Uri, uri.class
|
49
|
+
assert_false uri.sip?
|
50
|
+
assert_false uri.tel?
|
51
|
+
assert_true uri.unknown_scheme?
|
52
|
+
assert_nil uri.has_param? "FOO"
|
53
|
+
assert_nil uri.aor
|
54
|
+
assert_equal uri_str, uri.to_s
|
55
|
+
end
|
56
|
+
end
|
data/test/test_uri.rb
CHANGED
@@ -22,6 +22,11 @@ class TestUri < OverSIPTest
|
|
22
22
|
assert_equal "123", uri.get_param("Foo")
|
23
23
|
assert_equal aor, uri.aor
|
24
24
|
assert_equal full_uri, uri.to_s
|
25
|
+
|
26
|
+
uri.clear_params
|
27
|
+
|
28
|
+
assert_equal({}, uri.params)
|
29
|
+
assert_equal "sips:i%C3%B1aki@aliax.net:5060?X-Header-1=qwe&X-Header-2=asd", uri.to_s
|
25
30
|
end
|
26
31
|
|
27
32
|
def test_tel_uri
|
@@ -39,6 +44,11 @@ class TestUri < OverSIPTest
|
|
39
44
|
assert_equal "bar", uri.get_param("Foo")
|
40
45
|
assert_equal aor, uri.aor
|
41
46
|
assert_equal full_uri, uri.to_s
|
47
|
+
|
48
|
+
uri.clear_params
|
49
|
+
|
50
|
+
assert_equal({}, uri.params)
|
51
|
+
assert_equal aor, uri.to_s
|
42
52
|
end
|
43
53
|
|
44
54
|
def test_http_uri
|
@@ -53,5 +63,6 @@ class TestUri < OverSIPTest
|
|
53
63
|
assert_true uri.unknown_scheme?
|
54
64
|
assert_nil uri.aor
|
55
65
|
assert_equal full_uri, uri.to_s
|
66
|
+
assert_nil uri.clear_params
|
56
67
|
end
|
57
68
|
end
|
data/thirdparty/stud/stud.tar.gz
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: oversip
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-09-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: eventmachine-le
|
@@ -292,8 +292,9 @@ files:
|
|
292
292
|
- ext/sip_parser/sip_parser.h
|
293
293
|
- ext/sip_parser/ext_help.h
|
294
294
|
- ext/sip_parser/common_headers.h
|
295
|
-
- ext/sip_parser/
|
295
|
+
- ext/sip_parser/sip_uri_parser.c
|
296
296
|
- ext/sip_parser/sip_parser_ruby.c
|
297
|
+
- ext/sip_parser/sip_message_parser.c
|
297
298
|
- ext/stun/extconf.rb
|
298
299
|
- ext/stun/ext_help.h
|
299
300
|
- ext/stun/stun_ruby.c
|
@@ -332,10 +333,12 @@ files:
|
|
332
333
|
- AUTHORS
|
333
334
|
- LICENSE
|
334
335
|
- test/oversip_test_helper.rb
|
335
|
-
- test/
|
336
|
+
- test/test_name_addr_parser.rb
|
337
|
+
- test/test_sip_uri_parser.rb
|
336
338
|
- test/test_http_parser.rb
|
337
339
|
- test/test_name_addr.rb
|
338
340
|
- test/test_uri.rb
|
341
|
+
- test/test_sip_message_parser.rb
|
339
342
|
- bin/oversip
|
340
343
|
homepage: http://www.oversip.net
|
341
344
|
licenses: []
|
@@ -363,8 +366,10 @@ specification_version: 3
|
|
363
366
|
summary: OverSIP (the SIP framework you dreamed about)
|
364
367
|
test_files:
|
365
368
|
- test/oversip_test_helper.rb
|
366
|
-
- test/
|
369
|
+
- test/test_name_addr_parser.rb
|
370
|
+
- test/test_sip_uri_parser.rb
|
367
371
|
- test/test_http_parser.rb
|
368
372
|
- test/test_name_addr.rb
|
369
373
|
- test/test_uri.rb
|
374
|
+
- test/test_sip_message_parser.rb
|
370
375
|
has_rdoc: false
|