oversip 1.1.0.beta5 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (71) hide show
  1. data/etc/oversip.conf +16 -4
  2. data/etc/proxies.conf +8 -9
  3. data/etc/server.rb +59 -0
  4. data/ext/sip_parser/sip_parser.c +12066 -11975
  5. data/ext/sip_parser/sip_parser.h +1 -0
  6. data/ext/sip_parser/sip_parser_ruby.c +15 -4
  7. data/ext/utils/haproxy_protocol.c +4 -1
  8. data/ext/websocket_framing_utils/ws_framing_utils_ruby.c +2 -2
  9. data/lib/oversip/config.rb +50 -38
  10. data/lib/oversip/default_server.rb +12 -0
  11. data/lib/oversip/launcher.rb +10 -35
  12. data/lib/oversip/master_process.rb +2 -2
  13. data/lib/oversip/proxies_config.rb +2 -2
  14. data/lib/oversip/sip/client_transaction.rb +1 -7
  15. data/lib/oversip/sip/grammar/uri.rb +23 -1
  16. data/lib/oversip/sip/listeners/{reactor.rb → connection.rb} +16 -2
  17. data/lib/oversip/sip/listeners/ipv4_udp_server.rb +1 -1
  18. data/lib/oversip/sip/listeners/ipv6_udp_server.rb +1 -1
  19. data/lib/oversip/sip/listeners/tcp_client.rb +2 -3
  20. data/lib/oversip/sip/listeners/{tcp_reactor.rb → tcp_connection.rb} +14 -2
  21. data/lib/oversip/sip/listeners/tcp_server.rb +2 -5
  22. data/lib/oversip/sip/listeners/tls_client.rb +15 -12
  23. data/lib/oversip/sip/listeners/tls_server.rb +11 -11
  24. data/lib/oversip/sip/listeners/{tls_tunnel_reactor.rb → tls_tunnel_connection.rb} +20 -20
  25. data/lib/oversip/sip/listeners/tls_tunnel_server.rb +2 -5
  26. data/lib/oversip/sip/listeners/{udp_reactor.rb → udp_connection.rb} +4 -4
  27. data/lib/oversip/sip/listeners.rb +6 -10
  28. data/lib/oversip/sip/message.rb +4 -3
  29. data/lib/oversip/sip/message_processor.rb +17 -17
  30. data/lib/oversip/sip/modules/core.rb +18 -13
  31. data/lib/oversip/sip/modules/user_assertion.rb +7 -53
  32. data/lib/oversip/sip/proxy.rb +3 -3
  33. data/lib/oversip/sip/request.rb +2 -0
  34. data/lib/oversip/sip/rfc3263.rb +3 -3
  35. data/lib/oversip/sip/sip.rb +6 -0
  36. data/lib/oversip/sip/transport_manager.rb +8 -8
  37. data/lib/oversip/tls.rb +18 -22
  38. data/lib/oversip/version.rb +1 -1
  39. data/lib/oversip/websocket/constants.rb +0 -1
  40. data/lib/oversip/websocket/http_request.rb +4 -8
  41. data/lib/oversip/websocket/launcher.rb +83 -139
  42. data/lib/oversip/websocket/listeners/connection.rb +47 -0
  43. data/lib/oversip/websocket/{ws_apps/ipv4_ws_sip_app.rb → listeners/ipv4_ws_server.rb} +3 -3
  44. data/lib/oversip/websocket/{ws_apps/ipv4_wss_sip_app.rb → listeners/ipv4_wss_server.rb} +2 -2
  45. data/lib/oversip/websocket/listeners/ipv4_wss_tunnel_server.rb +21 -0
  46. data/lib/oversip/websocket/{ws_apps/ipv6_ws_sip_app.rb → listeners/ipv6_ws_server.rb} +3 -3
  47. data/lib/oversip/websocket/{ws_apps/ipv6_wss_sip_app.rb → listeners/ipv6_wss_server.rb} +2 -3
  48. data/lib/oversip/websocket/listeners/ipv6_wss_tunnel_server.rb +21 -0
  49. data/lib/oversip/websocket/listeners/{tcp_server.rb → ws_server.rb} +63 -43
  50. data/lib/oversip/websocket/listeners/{tls_server.rb → wss_server.rb} +14 -13
  51. data/lib/oversip/websocket/listeners/{tls_tunnel_server.rb → wss_tunnel_server.rb} +36 -10
  52. data/lib/oversip/websocket/listeners.rb +10 -9
  53. data/lib/oversip/websocket/websocket.rb +13 -0
  54. data/lib/oversip/websocket/ws_framing.rb +35 -97
  55. data/lib/oversip/websocket/ws_sip_app.rb +120 -0
  56. data/lib/oversip.rb +1 -1
  57. data/test/oversip_test_helper.rb +2 -2
  58. data/test/test_http_parser.rb +2 -2
  59. data/test/test_sip_parser.rb +18 -3
  60. data/test/test_uri.rb +44 -0
  61. metadata +39 -42
  62. data/lib/oversip/websocket/listeners/ipv4_tcp_server.rb +0 -15
  63. data/lib/oversip/websocket/listeners/ipv4_tls_server.rb +0 -15
  64. data/lib/oversip/websocket/listeners/ipv4_tls_tunnel_server.rb +0 -15
  65. data/lib/oversip/websocket/listeners/ipv6_tcp_server.rb +0 -15
  66. data/lib/oversip/websocket/listeners/ipv6_tls_server.rb +0 -15
  67. data/lib/oversip/websocket/listeners/ipv6_tls_tunnel_server.rb +0 -15
  68. data/lib/oversip/websocket/ws_app.rb +0 -77
  69. data/lib/oversip/websocket/ws_apps/ws_autobahn_app.rb +0 -23
  70. data/lib/oversip/websocket/ws_apps/ws_sip_app.rb +0 -156
  71. data/lib/oversip/websocket/ws_apps.rb +0 -9
data/etc/oversip.conf CHANGED
@@ -46,7 +46,7 @@ sip:
46
46
  #
47
47
  sip_tls: yes
48
48
 
49
- # Enable or dissable IPv4. By default _yes_.
49
+ # Enable or disable IPv4. By default _yes_.
50
50
  #
51
51
  enable_ipv4: yes
52
52
 
@@ -58,7 +58,7 @@ sip:
58
58
  #
59
59
  listen_ipv4: null
60
60
 
61
- # Enable or dissable IPv6. By default _yes_.
61
+ # Enable or disable IPv6. By default _yes_.
62
62
  #
63
63
  enable_ipv6: yes
64
64
 
@@ -93,6 +93,12 @@ sip:
93
93
  #
94
94
  listen_port_tls_tunnel: 5062
95
95
 
96
+ # Call the OverSIP::SipEvents.on_client_tls_handshake() callback when a SIP
97
+ # client attemps a TLS handshake with OverSIP.
98
+ # By default _yes_.
99
+ #
100
+ callback_on_client_tls_handshake: yes
101
+
96
102
  # Local domains OverSIP is responsible for. Value can be:
97
103
  # - A domain.
98
104
  # - An array of domains.
@@ -138,7 +144,7 @@ websocket:
138
144
  #
139
145
  sip_wss: yes
140
146
 
141
- # Enable or dissable IPv4. By default _yes_.
147
+ # Enable or disable IPv4. By default _yes_.
142
148
  #
143
149
  enable_ipv4: yes
144
150
 
@@ -150,7 +156,7 @@ websocket:
150
156
  #
151
157
  listen_ipv4: null
152
158
 
153
- # Enable or dissable IPv6. By default _yes_.
159
+ # Enable or disable IPv6. By default _yes_.
154
160
  #
155
161
  enable_ipv6: yes
156
162
 
@@ -185,6 +191,12 @@ websocket:
185
191
  #
186
192
  listen_port_tls_tunnel: 10444
187
193
 
194
+ # Call the OverSIP::WebSocketEvents.on_client_tls_handshake() callback when a WebSocket
195
+ # client attemps a TLS handshake with OverSIP.
196
+ # By default _yes_.
197
+ #
198
+ callback_on_client_tls_handshake: yes
199
+
188
200
  # WebSocket message max size (bytes). By default 65536.
189
201
  #
190
202
  max_ws_message_size: 65536
data/etc/proxies.conf CHANGED
@@ -65,8 +65,9 @@ default_proxy:
65
65
  ip_type_preference: ["ipv4", "ipv6"]
66
66
 
67
67
  # DNS failover on received 503.
68
- # RFC 3261 section 16.7 "Response Processing" states that a proxy receiving a 503 MUST
69
- # convert it into a 500 (unless certain cases). We make it optional.
68
+ # If a DNS query retrieves more than a single destinations and the first attempt
69
+ # receives a 503 response, then OverSIP tries the next destination (when this parameter
70
+ # is set) or replies a 500 error upstream (when not set).
70
71
  # Default value is _yes_.
71
72
  #
72
73
  dns_failover_on_503: yes
@@ -92,13 +93,11 @@ default_proxy:
92
93
  #
93
94
  timer_F: 32
94
95
 
95
- # Validate TLS certificate from the contacted server (just when using TLS transport).
96
- # If set to _yes_, the contacted server MUST present a valid certificate. The connection
97
- # will be inmediately closed otherwise and a 500 error locally generated.
98
- # NOTE: This does not match the SIP request destination host against the hosts asserted by
99
- # the certificate. This just performs TLS certificate pure validation.
100
- # Default value is _no_.
101
- tls_validation: no
96
+ # Call the OverSIP::SIP.on_server_tls_handshake() callback when
97
+ # establishing an outbound SIP TLS connection with a remote SIP peer.
98
+ # By default _yes_.
99
+ #
100
+ callback_on_server_tls_handshake: yes
102
101
 
103
102
 
104
103
  # Proxy configuration for routing in-dialog requests.
data/etc/server.rb CHANGED
@@ -171,6 +171,10 @@ def (OverSIP::SipEvents).on_request request
171
171
  log_notice "on_error: #{status} '#{reason}'"
172
172
  end
173
173
 
174
+ proxy.on_invite_timeout do
175
+ log_notice "INVITE timeout, no final response before Timer C expires."
176
+ end
177
+
174
178
  proxy.route request
175
179
  return
176
180
 
@@ -215,6 +219,43 @@ def (OverSIP::SipEvents).on_request request
215
219
  return
216
220
 
217
221
  end
222
+
223
+ end
224
+
225
+
226
+ # This callback is called when a client initiates a SIP TLS handshake.
227
+ def (OverSIP::SipEvents).on_client_tls_handshake connection, pems
228
+
229
+ log_info "validating TLS connection from IP #{connection.remote_ip} and port #{connection.remote_port}"
230
+
231
+ cert, validated, tls_error, tls_error_string = ::OverSIP::TLS.validate pems
232
+ identities = ::OverSIP::TLS.get_sip_identities cert
233
+
234
+ if validated
235
+ log_info "client provides a valid TLS certificate with SIP identities #{identities}"
236
+ else
237
+ log_notice "client provides an invalid TLS certificate with SIP identities #{identities} (TLS error: #{tls_error.inspect}, description: #{tls_error_string.inspect})"
238
+ #connection.close
239
+ end
240
+
241
+ end
242
+
243
+
244
+ # This callback is called when conntacting a SIP TLS server and the TLS handshake takes place.
245
+ def (OverSIP::SipEvents).on_server_tls_handshake connection, pems
246
+
247
+ log_info "validating TLS connection to IP #{connection.remote_ip} and port #{connection.remote_port}"
248
+
249
+ cert, validated, tls_error, tls_error_string = ::OverSIP::TLS.validate pems
250
+ identities = ::OverSIP::TLS.get_sip_identities cert
251
+
252
+ if validated
253
+ log_info "server provides a valid TLS certificate with SIP identities #{identities}"
254
+ else
255
+ log_notice "server provides an invalid TLS certificate with SIP identities #{identities} (TLS error: #{tls_error.inspect}, description: #{tls_error_string.inspect})"
256
+ #connection.close
257
+ end
258
+
218
259
  end
219
260
 
220
261
 
@@ -245,3 +286,21 @@ end
245
286
  # def (OverSIP::WebSocketEvents).on_disconnection connection, client_closed
246
287
  # [...]
247
288
  # end
289
+
290
+
291
+ # This callback is called when a client initiates a WebSocket TLS handshake.
292
+ def (OverSIP::WebSocketEvents).on_client_tls_handshake connection, pems
293
+
294
+ log_info "validating TLS connection from IP #{connection.remote_ip} and port #{connection.remote_port}"
295
+
296
+ cert, validated, tls_error, tls_error_string = ::OverSIP::TLS.validate pems
297
+ identities = ::OverSIP::TLS.get_sip_identities cert
298
+
299
+ if validated
300
+ log_info "client provides a valid TLS certificate with SIP identities #{identities}"
301
+ else
302
+ log_notice "client provides an invalid TLS certificate with SIP identities #{identities} (TLS error: #{tls_error.inspect}, description: #{tls_error_string.inspect})"
303
+ #connection.close
304
+ end
305
+
306
+ end