oversip 1.2.1 → 1.3.0.dev1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +28 -4
- data/bin/oversip +1 -1
- data/etc/proxies.conf +10 -0
- data/etc/server.rb +13 -9
- data/ext/utils/haproxy_protocol.c +0 -3
- data/ext/utils/outbound_utils.c +1 -1
- data/ext/utils/utils_ruby.c +0 -1
- data/ext/websocket_http_parser/ws_http_parser.c +940 -1903
- data/ext/websocket_http_parser/ws_http_parser.h +1 -0
- data/lib/oversip/config_validators.rb +2 -2
- data/lib/oversip/launcher.rb +275 -240
- data/lib/oversip/master_process.rb +7 -2
- data/lib/oversip/proxies_config.rb +8 -1
- data/lib/oversip/sip/client.rb +304 -0
- data/lib/oversip/sip/client_transaction.rb +31 -36
- data/lib/oversip/sip/core.rb +7 -4
- data/lib/oversip/sip/launcher.rb +30 -30
- data/lib/oversip/sip/listeners/connection.rb +4 -0
- data/lib/oversip/sip/listeners/ipv4_tcp_server.rb +1 -0
- data/lib/oversip/sip/listeners/ipv4_tls_server.rb +1 -0
- data/lib/oversip/sip/listeners/ipv4_tls_tunnel_server.rb +1 -0
- data/lib/oversip/sip/listeners/ipv4_udp_server.rb +1 -0
- data/lib/oversip/sip/listeners/ipv6_tcp_server.rb +1 -0
- data/lib/oversip/sip/listeners/ipv6_tls_server.rb +1 -0
- data/lib/oversip/sip/listeners/ipv6_tls_tunnel_server.rb +1 -0
- data/lib/oversip/sip/listeners/ipv6_udp_server.rb +1 -0
- data/lib/oversip/sip/listeners/tcp_client.rb +26 -0
- data/lib/oversip/sip/listeners/tcp_connection.rb +7 -1
- data/lib/oversip/sip/listeners/tcp_server.rb +1 -1
- data/lib/oversip/sip/listeners/tls_client.rb +28 -24
- data/lib/oversip/sip/listeners/tls_server.rb +25 -8
- data/lib/oversip/sip/listeners/tls_tunnel_connection.rb +1 -24
- data/lib/oversip/sip/message.rb +2 -2
- data/lib/oversip/sip/message_processor.rb +23 -13
- data/lib/oversip/sip/{grammar/name_addr.rb → name_addr.rb} +11 -0
- data/lib/oversip/sip/proxy.rb +53 -227
- data/lib/oversip/sip/request.rb +15 -11
- data/lib/oversip/sip/response.rb +3 -3
- data/lib/oversip/sip/rfc3263.rb +2 -3
- data/lib/oversip/sip/tags.rb +1 -1
- data/lib/oversip/sip/transport_manager.rb +6 -5
- data/lib/oversip/sip/uac.rb +93 -0
- data/lib/oversip/sip/uac_request.rb +82 -0
- data/lib/oversip/sip/{grammar/uri.rb → uri.rb} +22 -0
- data/lib/oversip/version.rb +3 -3
- data/lib/oversip/websocket/launcher.rb +25 -25
- data/lib/oversip/websocket/listeners/connection.rb +4 -0
- data/lib/oversip/websocket/listeners/ipv4_ws_server.rb +1 -0
- data/lib/oversip/websocket/listeners/ipv4_wss_server.rb +1 -0
- data/lib/oversip/websocket/listeners/ipv4_wss_tunnel_server.rb +1 -0
- data/lib/oversip/websocket/listeners/ipv6_ws_server.rb +1 -0
- data/lib/oversip/websocket/listeners/ipv6_wss_server.rb +1 -0
- data/lib/oversip/websocket/listeners/ipv6_wss_tunnel_server.rb +1 -0
- data/lib/oversip/websocket/listeners/ws_server.rb +55 -26
- data/lib/oversip/websocket/listeners/wss_server.rb +26 -9
- data/lib/oversip/websocket/listeners/wss_tunnel_server.rb +14 -11
- data/lib/oversip/websocket/ws_framing.rb +6 -2
- data/lib/oversip.rb +3 -1
- data/test/test_http_parser.rb +3 -3
- data/test/test_uri.rb +18 -12
- metadata +91 -77
data/README.md
CHANGED
@@ -2,17 +2,41 @@
|
|
2
2
|
|
3
3
|
[![Build Status](https://secure.travis-ci.org/versatica/OverSIP.png?branch=master)](http://travis-ci.org/versatica/OverSIP)
|
4
4
|
|
5
|
-
|
5
|
+
## Website
|
6
|
+
|
7
|
+
* [www.oversip.net](http://www.oversip.net)
|
8
|
+
|
6
9
|
|
7
10
|
## Overview
|
8
11
|
|
9
|
-
OverSIP is a powerful and flexible SIP proxy & server:
|
12
|
+
OverSIP is a powerful and flexible SIP proxy & server by the authors of [draft-ietf-sipcore-sip-websocket](http://tools.ietf.org/html/draft-ietf-sipcore-sip-websocket) (*The WebSocket Protocol as a Transport for SIP*):
|
10
13
|
|
11
14
|
* Fully asynchronous event-based design, never block!
|
12
15
|
* Enjoy coding your SIP logic in Ruby language, feel free to code whatever you need!
|
13
16
|
* Fast: core and message parsers written in C language
|
14
|
-
* SIP over UDP, TCP, TLS and WebSocket (
|
17
|
+
* SIP over UDP, TCP, TLS and WebSocket (use true SIP in your web apps)
|
15
18
|
* Full support for IPv4, IPv6 and DNS resolution (NAPTR, SRV, A, AAAA)
|
16
19
|
* The perfect Outbound Edge Proxy
|
20
|
+
* Written by the authors of [draft-ietf-sipcore-sip-websocket](http://tools.ietf.org/html/draft-ietf-sipcore-sip-websocket) and [JsSIP](http://www.jssip.net)
|
21
|
+
|
22
|
+
|
23
|
+
## Documentation
|
24
|
+
|
25
|
+
* [www.oversip.net/documentation](http://www.oversip.net/documentation/)
|
26
|
+
|
27
|
+
|
28
|
+
## Authors
|
29
|
+
|
30
|
+
### Main Author
|
31
|
+
|
32
|
+
* Iñaki Baz Castillo (<ibc@aliax.net> | [github](https://github.com/ibc) | [twitter](https://twitter.com/ibc_tw))
|
33
|
+
|
34
|
+
### Contributors
|
35
|
+
|
36
|
+
* José Luis Millán (<jmillan@aliax.net> | [github](https://github.com/jmillan) | [twitter](https://twitter.com/jomivi))
|
37
|
+
* Saúl Ibarra Corretgé (<saghul@gmail.com> | [github](https://github.com/saghul) | [twitter](https://twitter.com/saghul))
|
38
|
+
* Jon Bonilla (<manwe@aholab.ehu.es> | [github](https://github.com/manwe) | [twitter](https://twitter.com/jbmanwe))
|
39
|
+
|
40
|
+
## License
|
17
41
|
|
18
|
-
|
42
|
+
OverSIP is released under the [MIT license](http://www.oversip.net/license).
|
data/bin/oversip
CHANGED
data/etc/proxies.conf
CHANGED
@@ -28,6 +28,16 @@ default_proxy:
|
|
28
28
|
#
|
29
29
|
dns_cache_time: 300
|
30
30
|
|
31
|
+
# Enable destination blacklist. When a destination (target) fails due to timeout, connection error
|
32
|
+
# or TLS validation error, the target is added to a temporal blacklist and requests to same
|
33
|
+
# targets are not tryed again until the entry in the blacklist expires. By default _yes_.
|
34
|
+
#
|
35
|
+
use_blacklist: yes
|
36
|
+
|
37
|
+
# Blacklist expiration time (in seconds). The time of live of failed targets within the blacklist.
|
38
|
+
#
|
39
|
+
blacklist_time: 400
|
40
|
+
|
31
41
|
# Use DNS NAPTR. If set, NAPTR query is performed when URI host is a domain, has no port nor
|
32
42
|
# ;transport param.
|
33
43
|
# Default value is _yes_.
|
data/etc/server.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
1
3
|
#
|
2
4
|
# OverSIP - Server Logic.
|
3
5
|
#
|
@@ -16,18 +18,20 @@
|
|
16
18
|
module MyExampleApp
|
17
19
|
extend ::OverSIP::Logger
|
18
20
|
|
19
|
-
|
21
|
+
class << self
|
22
|
+
attr_reader :do_outbound_mangling, :do_user_assertion
|
23
|
+
end
|
20
24
|
|
21
25
|
# Set this to _true_ if the SIP registrar behind OverSIP does not support Path.
|
22
26
|
# OverSIP::Modules::OutboundMangling methods will be used.
|
23
|
-
|
27
|
+
@do_outbound_mangling = true
|
24
28
|
|
25
29
|
# Set this to _true_ if the SIP proxy/server behind OverSIP performing the authentication
|
26
30
|
# is ready to accept a P-Asserted-Identity header from OverSIP indicating the already
|
27
31
|
# asserted SIP user of the client's connection (this avoids authenticating all the requests
|
28
32
|
# but the first one).
|
29
33
|
# OverSIP::Modules::UserAssertion methods will be used.
|
30
|
-
|
34
|
+
@do_user_assertion = true
|
31
35
|
end
|
32
36
|
|
33
37
|
|
@@ -118,7 +122,7 @@ def (OverSIP::SipEvents).on_request request
|
|
118
122
|
return
|
119
123
|
end
|
120
124
|
|
121
|
-
if MyExampleApp
|
125
|
+
if MyExampleApp.do_outbound_mangling
|
122
126
|
# Extract the Outbound flow token from the RURI.
|
123
127
|
::OverSIP::Modules::OutboundMangling.extract_outbound_from_ruri request
|
124
128
|
end
|
@@ -160,7 +164,7 @@ def (OverSIP::SipEvents).on_request request
|
|
160
164
|
|
161
165
|
when :INVITE, :MESSAGE, :OPTIONS, :SUBSCRIBE, :PUBLISH, :REFER
|
162
166
|
|
163
|
-
if MyExampleApp
|
167
|
+
if MyExampleApp.do_user_assertion
|
164
168
|
::OverSIP::Modules::UserAssertion.add_pai request
|
165
169
|
end
|
166
170
|
|
@@ -191,7 +195,7 @@ def (OverSIP::SipEvents).on_request request
|
|
191
195
|
|
192
196
|
when :REGISTER
|
193
197
|
|
194
|
-
if MyExampleApp
|
198
|
+
if MyExampleApp.do_outbound_mangling
|
195
199
|
# Contact mangling for the case in which the registrar does not support Path.
|
196
200
|
::OverSIP::Modules::OutboundMangling.add_outbound_to_contact request
|
197
201
|
end
|
@@ -199,13 +203,13 @@ def (OverSIP::SipEvents).on_request request
|
|
199
203
|
proxy = ::OverSIP::SIP::Proxy.new :proxy_out
|
200
204
|
|
201
205
|
proxy.on_success_response do |response|
|
202
|
-
if MyExampleApp
|
206
|
+
if MyExampleApp.do_outbound_mangling
|
203
207
|
# Undo changes done to the Contact header provided by the client, so it receives
|
204
208
|
# the same value in the 200 response from the registrar.
|
205
209
|
::OverSIP::Modules::OutboundMangling.remove_outbound_from_contact response
|
206
210
|
end
|
207
211
|
|
208
|
-
if MyExampleApp
|
212
|
+
if MyExampleApp.do_user_assertion
|
209
213
|
# The registrar replies 200 after a REGISTER with credentials so let's assert
|
210
214
|
# the current SIP user to this connection.
|
211
215
|
::OverSIP::Modules::UserAssertion.assert_connection response
|
@@ -213,7 +217,7 @@ def (OverSIP::SipEvents).on_request request
|
|
213
217
|
end
|
214
218
|
|
215
219
|
proxy.on_failure_response do |response|
|
216
|
-
if MyExampleApp
|
220
|
+
if MyExampleApp.do_user_assertion
|
217
221
|
# We don't add PAI for re-REGISTER, so 401 will be replied, and after it let's
|
218
222
|
# revoke the current user assertion (will be re-added upon REGISTER with credentials).
|
219
223
|
::OverSIP::Modules::UserAssertion.revoke_assertion response
|
@@ -6152,15 +6152,12 @@ case 374:
|
|
6152
6152
|
|
6153
6153
|
#line 77 "haproxy_protocol.rl"
|
6154
6154
|
|
6155
|
-
/* if(finished && len == p-str) */
|
6156
6155
|
if(finished)
|
6157
6156
|
haproxy_protocol.valid = 1;
|
6158
6157
|
|
6159
6158
|
/* Write the number of read bytes so the HAProxy Protocol line can be removed. */
|
6160
6159
|
haproxy_protocol.total_len = (int)(p - str);
|
6161
6160
|
|
6162
|
-
printf("**** haproxy_protocol.total_len = %i\n", haproxy_protocol.total_len);
|
6163
|
-
|
6164
6161
|
return haproxy_protocol;
|
6165
6162
|
}
|
6166
6163
|
|
data/ext/utils/outbound_utils.c
CHANGED
@@ -25,7 +25,7 @@ static const int utils_outbound_udp_flow_token_parser_en_main = 1;
|
|
25
25
|
|
26
26
|
/** exec **/
|
27
27
|
/*
|
28
|
-
* Expects a string like "1.2.3.4_5060" or "
|
28
|
+
* Expects a string like "1.2.3.4_5060" or "1af:43::ab_9090" (no "_" at the beginning).
|
29
29
|
*/
|
30
30
|
struct_outbound_udp_flow_token outbound_udp_flow_token_parser_execute(const char *str, size_t len)
|
31
31
|
{
|
data/ext/utils/utils_ruby.c
CHANGED
@@ -306,7 +306,6 @@ VALUE Utils_parser_outbound_udp_flow_token(VALUE self, VALUE string)
|
|
306
306
|
str = RSTRING_PTR(string);
|
307
307
|
len = RSTRING_LEN(string);
|
308
308
|
|
309
|
-
/* Remove the leading "_" from the string. */
|
310
309
|
outbound_udp_flow_token = outbound_udp_flow_token_parser_execute(str, len);
|
311
310
|
|
312
311
|
if (outbound_udp_flow_token.valid == 0)
|