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
@@ -0,0 +1,120 @@
1
+ module OverSIP::WebSocket
2
+
3
+ class WsSipApp
4
+
5
+ include ::OverSIP::Logger
6
+ include ::OverSIP::SIP::MessageProcessor
7
+
8
+ def self.class_init
9
+ @@max_message_size = ::OverSIP.configuration[:websocket][:max_ws_message_size]
10
+ @@ws_keepalive_interval = ::OverSIP.configuration[:websocket][:ws_keepalive_interval]
11
+ end
12
+
13
+
14
+ LOG_ID = "WsSipApp"
15
+ def log_id
16
+ LOG_ID
17
+ end
18
+
19
+
20
+ def initialize connection, ws_framing
21
+ @connection = connection
22
+ @ws_framing = ws_framing
23
+ @ws_message = ::IO::Buffer.new
24
+
25
+ # Mantain WebSocket keepalive.
26
+ @ws_framing.do_keep_alive @@ws_keepalive_interval if @@ws_keepalive_interval
27
+
28
+ # WebSocket is message boundary so we just need a SIP parser instance.
29
+ @@parser ||= ::OverSIP::SIP::MessageParser.new
30
+ @parser = @@parser
31
+ end
32
+
33
+
34
+ def receive_payload_data payload_data
35
+ # payload_data is always Encoding::BINARY so also @ws_message.to_str.
36
+ @ws_message << payload_data
37
+
38
+ # Check max message size.
39
+ return false if @ws_message.size > @@max_message_size
40
+ true
41
+ end
42
+
43
+
44
+ def message_done type
45
+ log_system_debug "received WS message: type=#{type}, length=#{@ws_message.size}" if $oversip_debug
46
+
47
+ # Better to encode it as BINARY (to later extract the body).
48
+ process_sip_message @ws_message.to_str.force_encoding ::Encoding::BINARY
49
+
50
+ @ws_message.clear
51
+ true
52
+ end
53
+
54
+
55
+ def process_sip_message ws_message
56
+ # Just a single SIP message allowed per WS message.
57
+ @parser.reset
58
+
59
+ unless parser_nbytes = @parser.execute(ws_message, 0)
60
+ if wrong_message = @parser.parsed
61
+ log_system_warn "SIP parsing error for #{MSG_TYPE[wrong_message.class]}: \"#{@parser.error}\""
62
+ else
63
+ log_system_warn "SIP parsing error: \"#{@parser.error}\""
64
+ end
65
+ @connection.close 4000, "SIP message parsing error"
66
+ return
67
+ end
68
+
69
+ unless @parser.finished?
70
+ log_system_warn "SIP parsing error: message not completed"
71
+
72
+ @connection.close 4001, "SIP message incomplete"
73
+ return
74
+ end
75
+
76
+ # At this point we've got a SIP::Request, SIP::Response or :outbound_keepalive symbol.
77
+ @msg = @parser.parsed
78
+
79
+ # Received data is a SIP Outbound keealive (double CRLF). Reply with single CRLF.
80
+ if @msg == :outbound_keepalive
81
+ log_system_debug "Outbound keepalive received, replying single CRLF" if $oversip_debug
82
+ @ws_framing.send_text_frame(CRLF)
83
+ return
84
+ end
85
+
86
+ @parser.post_parsing
87
+
88
+ @msg.connection = @connection
89
+ @msg.transport = @connection.class.transport
90
+ @msg.source_ip = @connection.remote_ip
91
+ @msg.source_port = @connection.remote_port
92
+ @msg.source_ip_type = @connection.remote_ip_type
93
+
94
+ return unless valid_message? @parser
95
+ # TODO: Make it configurable:
96
+ #add_via_received_rport if @msg.request?
97
+ return unless check_via_branch
98
+
99
+ # Get the body.
100
+ if parser_nbytes != ws_message.bytesize
101
+ @msg.body = ws_message[parser_nbytes..-1]
102
+
103
+ if @msg.content_length and @msg.content_length != @msg.body.bytesize
104
+ log_system_warn "SIP message body size (#{@msg.body.bytesize}) does not match Content-Length (#{@msg.content_length.inspect}), ignoring message"
105
+ @connection.close 4002, "SIP message body size does not match Content-Length"
106
+ return
107
+ end
108
+ end
109
+
110
+ if @msg.request?
111
+ process_request
112
+ else
113
+ process_response
114
+ end
115
+
116
+ end
117
+
118
+ end
119
+
120
+ end
data/lib/oversip.rb CHANGED
@@ -40,7 +40,7 @@ module OverSIP
40
40
  :syslogger_pid, :syslogger_mq_name,
41
41
  :configuration,
42
42
  :proxies,
43
- :tls, :tls_public_cert, :tls_private_cert, :tls_proxy_ipv4, :tls_proxy_ipv6,
43
+ :tls_public_cert, :tls_private_cert,
44
44
  :stud_pids
45
45
 
46
46
  def master?
@@ -6,11 +6,11 @@ require "oversip/master_process"
6
6
  class OverSIPTest < Test::Unit::TestCase
7
7
 
8
8
  def assert_true(object, message="")
9
- assert_equal(object, true, message)
9
+ assert_equal(true, object, message)
10
10
  end
11
11
 
12
12
  def assert_false(object, message="")
13
- assert_equal(object, false, message)
13
+ assert_equal(false, object, message)
14
14
  end
15
15
 
16
16
  def assert_equal_options(options, element)
@@ -42,7 +42,7 @@ Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==\r
42
42
  Sec-WebSocket-protocol: foo , chat.lalala.com\r
43
43
  Sec-WebSocket-protocol: xmpp.nonaino.org\r
44
44
  Origin: http://example.Com\r
45
- Sec-WebSocket-Version: 8\r
45
+ Sec-WebSocket-Version: 13\r
46
46
  noNaino-lALA : qwe\r
47
47
  NOnaino-lala: asd\r
48
48
  \r
@@ -62,7 +62,7 @@ END
62
62
  assert_nil request.content_length
63
63
  assert request.hdr_connection.include?("upgrade")
64
64
  assert_equal "websocket", request.hdr_upgrade
65
- assert_equal 8, request.hdr_sec_websocket_version
65
+ assert_equal 13, request.hdr_sec_websocket_version
66
66
  assert_equal "dGhlIHNhbXBsZSBub25jZQ==", request.hdr_sec_websocket_key
67
67
  assert_equal "http://example.com", request.hdr_origin
68
68
  assert_equal ["foo", "chat.lalala.com", "xmpp.nonaino.org"], request.hdr_sec_websocket_protocol
@@ -39,6 +39,7 @@ class TestSipParser < OverSIPTest
39
39
  parser, msg = parse <<-END
40
40
  INVITE sip:sips%3Auser%40example.com@example.NET.;transport=tcp;FOO=baz?Subject=lalala SIP/2.0\r
41
41
  via: SIP/2.0/UDP host5.example.net;branch=z9hG4bKkdjuw ; Rport\r
42
+ v: SIP/2.0/TCP 1.2.3.4;branch=z9hG4bKkdjuw\r
42
43
  To: <tel:+(34)-94-499-44-22;lalala=lololo>\r
43
44
  from: <sips:I%20have%20spaces@[2001:123:Ab:0:0::123]:9999> ;\r
44
45
  tag=938\r
@@ -48,8 +49,14 @@ Max-Forwards: 87\r
48
49
  _i: esc01.239409asdfakjkn23onasd0-3234\r
49
50
  CSeq: 234234 INVITE\r
50
51
  C: application/sdp\r
52
+ Require: AAA, Bbb\r
53
+ Require: ccc\r
54
+ Proxy-Require: AAA, Bbb\r
55
+ Proxy-Require: ccc\r
56
+ Supported: AAA, Bbb\r
57
+ k: ccc\r
51
58
  Contact:\r
52
- <sip:cal%6Cer@host5.example.net;%6C%72;n%61me=v%61lue%25%34%31>\r
59
+ <sip:cal%6Cer@host5.example.net;%6C%72;n%61me=v%61lue%25%34%31;ob>;p1=foo;P2=BAR;+sip-instance=qweqwe;reg-id=1\r
53
60
  Content-Length: 150\r
54
61
  \r
55
62
  v=0\r
@@ -70,13 +77,14 @@ END
70
77
  assert_false parser.duplicated_core_header?
71
78
  assert_equal parser.missing_core_header?, "Call-ID"
72
79
 
73
- assert_equal msg.num_vias, 1
80
+ assert_equal msg.num_vias, 2
74
81
  assert_equal msg.via_sent_by_host, "host5.example.net"
75
82
  assert_nil msg.via_sent_by_port
76
83
  assert_nil msg.via_received
77
84
  assert_true msg.via_rport?
78
85
  assert_equal msg.via_core_value, "SIP/2.0/UDP host5.example.net"
79
86
  assert_nil msg.via_params
87
+ assert_equal ["SIP/2.0/UDP host5.example.net;branch=z9hG4bKkdjuw ; Rport", "SIP/2.0/TCP 1.2.3.4;branch=z9hG4bKkdjuw"], msg.hdr_via
80
88
 
81
89
  assert_equal msg.cseq, 234234
82
90
  assert_equal msg.max_forwards, 87
@@ -114,7 +122,10 @@ END
114
122
  assert_equal "host5.example.net", msg.contact.host
115
123
  assert_equal :domain, msg.contact.host_type
116
124
  assert_nil msg.contact.port
117
- assert_equal({"%6c%72" => nil, "n%61me" => "v%61lue%25%34%31"}, msg.contact.params)
125
+ assert_true msg.contact.ob_param?
126
+ assert_equal({"%6c%72" => nil, "n%61me" => "v%61lue%25%34%31", "ob" => nil}, msg.contact.params)
127
+ assert_equal ";p1=foo;P2=BAR;+sip-instance=qweqwe;reg-id=1", msg.contact_params
128
+ assert_true msg.contact_reg_id?
118
129
 
119
130
  assert_equal 2, msg.routes.size
120
131
 
@@ -134,6 +145,10 @@ END
134
145
  assert_equal :ipv6_reference, msg.routes[1].host_type
135
146
  assert_equal 6666, msg.routes[1].port
136
147
  assert_true msg.routes[1].lr_param?
148
+
149
+ assert_equal ["aaa", "bbb", "ccc"], msg.require
150
+ assert_equal ["aaa", "bbb", "ccc"], msg.proxy_require
151
+ assert_equal ["aaa", "bbb", "ccc"], msg.supported
137
152
  end
138
153
 
139
154
  end
data/test/test_uri.rb ADDED
@@ -0,0 +1,44 @@
1
+ # coding: utf-8
2
+
3
+ require "oversip_test_helper"
4
+
5
+
6
+ class TestUri < OverSIPTest
7
+
8
+ def test_sip_uri
9
+ full_uri = "sip:alice@atlanta.com:5060;transport=tcp;foo=123;baz?X-Header-1=qwe&X-Header-2=asd"
10
+
11
+ uri = ::OverSIP::SIP::Uri.new
12
+ uri.instance_variable_set :@scheme, :sip
13
+ uri.user = "alice"
14
+ uri.host = "atlanta.com"
15
+ uri.host_type = :domain
16
+ uri.port = 5060
17
+ uri.transport_param = :tcp
18
+ uri.instance_variable_set :@params, {"transport"=>"tcp", "foo"=>"123", "baz"=>nil}
19
+ uri.headers = "?X-Header-1=qwe&X-Header-2=asd"
20
+
21
+ assert_equal full_uri, uri.to_s
22
+ end
23
+
24
+ def test_tel_uri
25
+ full_uri = "tel:944991212;foo=bar;phone-context=+34"
26
+
27
+ uri = ::OverSIP::SIP::Uri.new
28
+ uri.instance_variable_set :@scheme, :tel
29
+ uri.user = "944991212"
30
+ uri.instance_variable_set :@params, {"foo"=>"bar"}
31
+ uri.phone_context_param = "+34"
32
+
33
+ assert_equal full_uri, uri.to_s
34
+ end
35
+
36
+ def test_http_uri
37
+ full_uri = "http://oversip.net/authors/"
38
+
39
+ uri = ::OverSIP::SIP::Uri.new
40
+ uri.instance_variable_set :@uri, full_uri
41
+
42
+ assert_equal full_uri, uri.to_s
43
+ end
44
+ end
metadata CHANGED
@@ -1,19 +1,19 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oversip
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0.beta5
5
- prerelease: 6
4
+ version: 1.1.0
5
+ prerelease:
6
6
  platform: ruby
7
7
  authors:
8
8
  - Inaki Baz Castillo
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-08-19 00:00:00.000000000 Z
12
+ date: 2012-08-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: eventmachine-le
16
- requirement: &19987280 !ruby/object:Gem::Requirement
16
+ requirement: &20560580 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 1.1.2
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *19987280
24
+ version_requirements: *20560580
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: iobuffer
27
- requirement: &19986780 !ruby/object:Gem::Requirement
27
+ requirement: &20560040 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 1.1.2
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *19986780
35
+ version_requirements: *20560040
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: em-posixmq
38
- requirement: &19986300 !ruby/object:Gem::Requirement
38
+ requirement: &20559520 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 0.2.3
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *19986300
46
+ version_requirements: *20559520
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: em-udns
49
- requirement: &19985820 !ruby/object:Gem::Requirement
49
+ requirement: &20559040 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 0.3.6
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *19985820
57
+ version_requirements: *20559040
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: escape_utils
60
- requirement: &19985360 !ruby/object:Gem::Requirement
60
+ requirement: &20558560 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: 0.2.4
66
66
  type: :runtime
67
67
  prerelease: false
68
- version_requirements: *19985360
68
+ version_requirements: *20558560
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: term-ansicolor
71
- requirement: &19984980 !ruby/object:Gem::Requirement
71
+ requirement: &20558180 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: '0'
77
77
  type: :runtime
78
78
  prerelease: false
79
- version_requirements: *19984980
79
+ version_requirements: *20558180
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: posix-spawn
82
- requirement: &19984260 !ruby/object:Gem::Requirement
82
+ requirement: &20557640 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,10 +87,10 @@ dependencies:
87
87
  version: 0.3.6
88
88
  type: :runtime
89
89
  prerelease: false
90
- version_requirements: *19984260
90
+ version_requirements: *20557640
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: rake
93
- requirement: &19983760 !ruby/object:Gem::Requirement
93
+ requirement: &20557020 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ~>
@@ -98,7 +98,7 @@ dependencies:
98
98
  version: 0.9.2
99
99
  type: :development
100
100
  prerelease: false
101
- version_requirements: *19983760
101
+ version_requirements: *20557020
102
102
  description: ! 'OverSIP is an async SIP proxy/server programmable in Ruby language.
103
103
  Some features of OverSIP are:
104
104
 
@@ -167,13 +167,12 @@ files:
167
167
  - lib/oversip/sip/constants.rb
168
168
  - lib/oversip/sip/launcher.rb
169
169
  - lib/oversip/sip/listeners/tls_server.rb
170
- - lib/oversip/sip/listeners/tcp_reactor.rb
170
+ - lib/oversip/sip/listeners/udp_connection.rb
171
+ - lib/oversip/sip/listeners/connection.rb
171
172
  - lib/oversip/sip/listeners/ipv4_tls_server.rb
172
173
  - lib/oversip/sip/listeners/ipv6_udp_server.rb
173
174
  - lib/oversip/sip/listeners/ipv6_tcp_server.rb
174
- - lib/oversip/sip/listeners/reactor.rb
175
175
  - lib/oversip/sip/listeners/ipv4_udp_server.rb
176
- - lib/oversip/sip/listeners/udp_reactor.rb
177
176
  - lib/oversip/sip/listeners/tcp_server.rb
178
177
  - lib/oversip/sip/listeners/tcp_client.rb
179
178
  - lib/oversip/sip/listeners/tls_client.rb
@@ -183,37 +182,33 @@ files:
183
182
  - lib/oversip/sip/listeners/tls_tunnel_server.rb
184
183
  - lib/oversip/sip/listeners/ipv4_tls_client.rb
185
184
  - lib/oversip/sip/listeners/ipv6_tls_server.rb
186
- - lib/oversip/sip/listeners/tls_tunnel_reactor.rb
187
185
  - lib/oversip/sip/listeners/ipv6_tls_tunnel_server.rb
186
+ - lib/oversip/sip/listeners/tcp_connection.rb
188
187
  - lib/oversip/sip/listeners/ipv6_tls_client.rb
189
188
  - lib/oversip/sip/listeners/ipv4_tls_tunnel_server.rb
189
+ - lib/oversip/sip/listeners/tls_tunnel_connection.rb
190
190
  - lib/oversip/sip/grammar/uri.rb
191
191
  - lib/oversip/sip/grammar/name_addr.rb
192
192
  - lib/oversip/sip/modules/registrar_without_path.rb
193
193
  - lib/oversip/sip/modules/core.rb
194
194
  - lib/oversip/sip/modules/user_assertion.rb
195
195
  - lib/oversip/websocket/listeners.rb
196
- - lib/oversip/websocket/ws_app.rb
197
196
  - lib/oversip/websocket/http_request.rb
198
197
  - lib/oversip/websocket/ws_framing.rb
198
+ - lib/oversip/websocket/websocket.rb
199
199
  - lib/oversip/websocket/constants.rb
200
200
  - lib/oversip/websocket/launcher.rb
201
- - lib/oversip/websocket/ws_apps.rb
202
- - lib/oversip/websocket/listeners/tls_server.rb
203
- - lib/oversip/websocket/listeners/ipv4_tls_server.rb
204
- - lib/oversip/websocket/listeners/ipv6_tcp_server.rb
205
- - lib/oversip/websocket/listeners/tcp_server.rb
206
- - lib/oversip/websocket/listeners/ipv4_tcp_server.rb
207
- - lib/oversip/websocket/listeners/tls_tunnel_server.rb
208
- - lib/oversip/websocket/listeners/ipv6_tls_server.rb
209
- - lib/oversip/websocket/listeners/ipv6_tls_tunnel_server.rb
210
- - lib/oversip/websocket/listeners/ipv4_tls_tunnel_server.rb
211
- - lib/oversip/websocket/ws_apps/ipv6_wss_sip_app.rb
212
- - lib/oversip/websocket/ws_apps/ipv4_ws_sip_app.rb
213
- - lib/oversip/websocket/ws_apps/ipv4_wss_sip_app.rb
214
- - lib/oversip/websocket/ws_apps/ipv6_ws_sip_app.rb
215
- - lib/oversip/websocket/ws_apps/ws_autobahn_app.rb
216
- - lib/oversip/websocket/ws_apps/ws_sip_app.rb
201
+ - lib/oversip/websocket/ws_sip_app.rb
202
+ - lib/oversip/websocket/listeners/ws_server.rb
203
+ - lib/oversip/websocket/listeners/ipv4_wss_server.rb
204
+ - lib/oversip/websocket/listeners/connection.rb
205
+ - lib/oversip/websocket/listeners/ipv6_ws_server.rb
206
+ - lib/oversip/websocket/listeners/ipv4_wss_tunnel_server.rb
207
+ - lib/oversip/websocket/listeners/ipv6_wss_tunnel_server.rb
208
+ - lib/oversip/websocket/listeners/wss_server.rb
209
+ - lib/oversip/websocket/listeners/ipv4_ws_server.rb
210
+ - lib/oversip/websocket/listeners/ipv6_wss_server.rb
211
+ - lib/oversip/websocket/listeners/wss_tunnel_server.rb
217
212
  - ext/common/ruby_c_util.h
218
213
  - ext/common/c_util.h
219
214
  - ext/sip_parser/extconf.rb
@@ -262,6 +257,7 @@ files:
262
257
  - test/oversip_test_helper.rb
263
258
  - test/test_sip_parser.rb
264
259
  - test/test_http_parser.rb
260
+ - test/test_uri.rb
265
261
  - bin/oversip
266
262
  homepage: http://www.oversip.net
267
263
  licenses: []
@@ -278,9 +274,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
278
274
  required_rubygems_version: !ruby/object:Gem::Requirement
279
275
  none: false
280
276
  requirements:
281
- - - ! '>'
277
+ - - ! '>='
282
278
  - !ruby/object:Gem::Version
283
- version: 1.3.1
279
+ version: '0'
284
280
  requirements: []
285
281
  rubyforge_project:
286
282
  rubygems_version: 1.8.11
@@ -291,4 +287,5 @@ test_files:
291
287
  - test/oversip_test_helper.rb
292
288
  - test/test_sip_parser.rb
293
289
  - test/test_http_parser.rb
290
+ - test/test_uri.rb
294
291
  has_rdoc: false
@@ -1,15 +0,0 @@
1
- module OverSIP::WebSocket
2
-
3
- class IPv4TcpServer < TcpServer
4
-
5
- @ip_type = :ipv4
6
- @transport = :tcp
7
-
8
- LOG_ID = "WS TCP IPv4 server"
9
- def log_id
10
- LOG_ID
11
- end
12
-
13
- end
14
-
15
- end
@@ -1,15 +0,0 @@
1
- module OverSIP::WebSocket
2
-
3
- class IPv4TlsServer < TlsServer
4
-
5
- @ip_type = :ipv4
6
- @transport = :tls
7
-
8
- LOG_ID = "WS TLS IPv4 server"
9
- def log_id
10
- LOG_ID
11
- end
12
-
13
- end
14
-
15
- end
@@ -1,15 +0,0 @@
1
- module OverSIP::WebSocket
2
-
3
- class IPv4TlsTunnelServer < TlsTunnelServer
4
-
5
- @ip_type = :ipv4
6
- @transport = :tls
7
-
8
- LOG_ID = "WS TLS-Tunnel IPv4 server"
9
- def log_id
10
- LOG_ID
11
- end
12
-
13
- end
14
-
15
- end
@@ -1,15 +0,0 @@
1
- module OverSIP::WebSocket
2
-
3
- class IPv6TcpServer < TcpServer
4
-
5
- @ip_type = :ipv6
6
- @transport = :tcp
7
-
8
- LOG_ID = "WS TCP IPv6 server"
9
- def log_id
10
- LOG_ID
11
- end
12
-
13
- end
14
-
15
- end
@@ -1,15 +0,0 @@
1
- module OverSIP::WebSocket
2
-
3
- class IPv6TlsServer < TlsServer
4
-
5
- @ip_type = :ipv6
6
- @transport = :tls
7
-
8
- LOG_ID = "WS TLS IPv6 server"
9
- def log_id
10
- LOG_ID
11
- end
12
-
13
- end
14
-
15
- end
@@ -1,15 +0,0 @@
1
- module OverSIP::WebSocket
2
-
3
- class IPv6TlsTunnelServer < TlsTunnelServer
4
-
5
- @ip_type = :ipv6
6
- @transport = :tls
7
-
8
- LOG_ID = "WS TLS-Tunnel IPv6 server"
9
- def log_id
10
- LOG_ID
11
- end
12
-
13
- end
14
-
15
- end
@@ -1,77 +0,0 @@
1
- module OverSIP::WebSocket
2
-
3
- class WsApp
4
-
5
- include ::OverSIP::Logger
6
-
7
-
8
- def self.class_init
9
- @@max_message_size = ::OverSIP.configuration[:websocket][:max_ws_message_size]
10
- @@ws_keepalive_interval = ::OverSIP.configuration[:websocket][:ws_keepalive_interval]
11
- end
12
-
13
-
14
- def initialize connection, ws_framing
15
- @connection = connection
16
- @ws_framing = ws_framing
17
- @ws_message = ::IO::Buffer.new
18
- @cvars = connection.cvars
19
-
20
- # Mantain WebSocket keepalive.
21
- @ws_framing.do_keep_alive @@ws_keepalive_interval if @@ws_keepalive_interval
22
- end
23
-
24
-
25
- def close_connection status=nil, reason=nil
26
- @ws_framing.send_close_frame status, reason
27
- @connection.ws_locally_closed = true
28
- end
29
-
30
-
31
- def receive_payload_data payload_data
32
- # payload_data is always Encoding::BINARY so also @ws_message.to_str.
33
- @ws_message << payload_data
34
-
35
- # Check max message size.
36
- if @ws_message.size > @@max_message_size
37
- close_connection 1009, "message too big"
38
- return false
39
- end
40
- true
41
- end
42
-
43
-
44
- def message_done type
45
- log_system_debug "received WS message: length=#{@ws_message.size}" if $oversip_debug
46
-
47
- case type
48
-
49
- when :text
50
- ws_message = @ws_message.to_str.force_encoding ::Encoding::UTF_8
51
- process_text_message ws_message
52
-
53
- when :binary
54
- process_binary_message @ws_message.to_str # As IO::Buffer#to_str always generates Encoding::BINARY.
55
- end
56
-
57
- @ws_message.clear
58
- true
59
- end
60
-
61
-
62
- def tcp_closed
63
- nil
64
- end
65
-
66
-
67
- # Methods to be overriden by child classes.
68
- def process_text_message ws_message
69
- end
70
-
71
- def process_binary_message ws_message
72
- end
73
-
74
-
75
- end # WsApp
76
-
77
- end
@@ -1,23 +0,0 @@
1
- module OverSIP::WebSocket
2
-
3
- class WsAutobahnApp < WsApp
4
-
5
- LOG_ID = "WS IPv4 AutoBahn app"
6
- def log_id
7
- LOG_ID
8
- end
9
-
10
- def process_text_message ws_message
11
- #log_system_info "received WS text message: length=#{ws_message.bytesize}, replying the same..."
12
- @ws_framing.send_text_frame ws_message
13
- end
14
-
15
-
16
- def process_binary_message ws_message
17
- #log_system_info "received WS binary message: length=#{ws_message.bytesize}, replying the same..."
18
- @ws_framing.send_binary_frame ws_message
19
- end
20
-
21
- end # WsAutobahnApp
22
-
23
- end