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.
- data/etc/oversip.conf +16 -4
- data/etc/proxies.conf +8 -9
- data/etc/server.rb +59 -0
- data/ext/sip_parser/sip_parser.c +12066 -11975
- data/ext/sip_parser/sip_parser.h +1 -0
- data/ext/sip_parser/sip_parser_ruby.c +15 -4
- data/ext/utils/haproxy_protocol.c +4 -1
- data/ext/websocket_framing_utils/ws_framing_utils_ruby.c +2 -2
- data/lib/oversip/config.rb +50 -38
- data/lib/oversip/default_server.rb +12 -0
- data/lib/oversip/launcher.rb +10 -35
- data/lib/oversip/master_process.rb +2 -2
- data/lib/oversip/proxies_config.rb +2 -2
- data/lib/oversip/sip/client_transaction.rb +1 -7
- data/lib/oversip/sip/grammar/uri.rb +23 -1
- data/lib/oversip/sip/listeners/{reactor.rb → connection.rb} +16 -2
- data/lib/oversip/sip/listeners/ipv4_udp_server.rb +1 -1
- data/lib/oversip/sip/listeners/ipv6_udp_server.rb +1 -1
- data/lib/oversip/sip/listeners/tcp_client.rb +2 -3
- data/lib/oversip/sip/listeners/{tcp_reactor.rb → tcp_connection.rb} +14 -2
- data/lib/oversip/sip/listeners/tcp_server.rb +2 -5
- data/lib/oversip/sip/listeners/tls_client.rb +15 -12
- data/lib/oversip/sip/listeners/tls_server.rb +11 -11
- data/lib/oversip/sip/listeners/{tls_tunnel_reactor.rb → tls_tunnel_connection.rb} +20 -20
- data/lib/oversip/sip/listeners/tls_tunnel_server.rb +2 -5
- data/lib/oversip/sip/listeners/{udp_reactor.rb → udp_connection.rb} +4 -4
- data/lib/oversip/sip/listeners.rb +6 -10
- data/lib/oversip/sip/message.rb +4 -3
- data/lib/oversip/sip/message_processor.rb +17 -17
- data/lib/oversip/sip/modules/core.rb +18 -13
- data/lib/oversip/sip/modules/user_assertion.rb +7 -53
- data/lib/oversip/sip/proxy.rb +3 -3
- data/lib/oversip/sip/request.rb +2 -0
- data/lib/oversip/sip/rfc3263.rb +3 -3
- data/lib/oversip/sip/sip.rb +6 -0
- data/lib/oversip/sip/transport_manager.rb +8 -8
- data/lib/oversip/tls.rb +18 -22
- data/lib/oversip/version.rb +1 -1
- data/lib/oversip/websocket/constants.rb +0 -1
- data/lib/oversip/websocket/http_request.rb +4 -8
- data/lib/oversip/websocket/launcher.rb +83 -139
- data/lib/oversip/websocket/listeners/connection.rb +47 -0
- data/lib/oversip/websocket/{ws_apps/ipv4_ws_sip_app.rb → listeners/ipv4_ws_server.rb} +3 -3
- data/lib/oversip/websocket/{ws_apps/ipv4_wss_sip_app.rb → listeners/ipv4_wss_server.rb} +2 -2
- data/lib/oversip/websocket/listeners/ipv4_wss_tunnel_server.rb +21 -0
- data/lib/oversip/websocket/{ws_apps/ipv6_ws_sip_app.rb → listeners/ipv6_ws_server.rb} +3 -3
- data/lib/oversip/websocket/{ws_apps/ipv6_wss_sip_app.rb → listeners/ipv6_wss_server.rb} +2 -3
- data/lib/oversip/websocket/listeners/ipv6_wss_tunnel_server.rb +21 -0
- data/lib/oversip/websocket/listeners/{tcp_server.rb → ws_server.rb} +63 -43
- data/lib/oversip/websocket/listeners/{tls_server.rb → wss_server.rb} +14 -13
- data/lib/oversip/websocket/listeners/{tls_tunnel_server.rb → wss_tunnel_server.rb} +36 -10
- data/lib/oversip/websocket/listeners.rb +10 -9
- data/lib/oversip/websocket/websocket.rb +13 -0
- data/lib/oversip/websocket/ws_framing.rb +35 -97
- data/lib/oversip/websocket/ws_sip_app.rb +120 -0
- data/lib/oversip.rb +1 -1
- data/test/oversip_test_helper.rb +2 -2
- data/test/test_http_parser.rb +2 -2
- data/test/test_sip_parser.rb +18 -3
- data/test/test_uri.rb +44 -0
- metadata +39 -42
- data/lib/oversip/websocket/listeners/ipv4_tcp_server.rb +0 -15
- data/lib/oversip/websocket/listeners/ipv4_tls_server.rb +0 -15
- data/lib/oversip/websocket/listeners/ipv4_tls_tunnel_server.rb +0 -15
- data/lib/oversip/websocket/listeners/ipv6_tcp_server.rb +0 -15
- data/lib/oversip/websocket/listeners/ipv6_tls_server.rb +0 -15
- data/lib/oversip/websocket/listeners/ipv6_tls_tunnel_server.rb +0 -15
- data/lib/oversip/websocket/ws_app.rb +0 -77
- data/lib/oversip/websocket/ws_apps/ws_autobahn_app.rb +0 -23
- data/lib/oversip/websocket/ws_apps/ws_sip_app.rb +0 -156
- data/lib/oversip/websocket/ws_apps.rb +0 -9
data/lib/oversip/tls.rb
CHANGED
@@ -16,20 +16,10 @@ module OverSIP
|
|
16
16
|
configuration = ::OverSIP.configuration
|
17
17
|
if configuration[:tls][:public_cert] and configuration[:tls][:private_cert]
|
18
18
|
log_system_info "TLS enabled"
|
19
|
-
|
20
|
-
::OverSIP.tls = true
|
21
19
|
::OverSIP.tls_public_cert = configuration[:tls][:public_cert]
|
22
20
|
::OverSIP.tls_private_cert = configuration[:tls][:private_cert]
|
23
|
-
|
24
|
-
if (::OverSIP.tls_proxy_ipv4 = configuration[:tls][:tls_proxy_ipv4])
|
25
|
-
log_system_info "TLS proxy enabled from IPv4 #{::OverSIP.tls_proxy_ipv4}"
|
26
|
-
end
|
27
|
-
if (::OverSIP.tls_proxy_ipv6 = configuration[:tls][:tls_proxy_ipv6])
|
28
|
-
log_system_info "TLS proxy enabled from IPv6 #{::OverSIP.tls_proxy_ipv6}"
|
29
|
-
end
|
30
|
-
|
31
21
|
else
|
32
|
-
log_system_info "TLS
|
22
|
+
log_system_info "TLS disabled"
|
33
23
|
return
|
34
24
|
end
|
35
25
|
|
@@ -86,7 +76,7 @@ module OverSIP
|
|
86
76
|
end
|
87
77
|
|
88
78
|
if num_certs_added == 0
|
89
|
-
log_system_notice "zero public certificates found in '#{ca_dir}' directory,
|
79
|
+
log_system_notice "zero public certificates found in '#{ca_dir}' directory, disabling TLS validation"
|
90
80
|
@store = nil
|
91
81
|
end
|
92
82
|
log_system_info "#{num_certs_added} public certificates available for TLS validation"
|
@@ -96,18 +86,21 @@ module OverSIP
|
|
96
86
|
|
97
87
|
|
98
88
|
# Return an array with the result of the TLS certificate validation as follows:
|
99
|
-
#
|
89
|
+
# cert, validated, tls_error, tls_error_string
|
100
90
|
# where:
|
91
|
+
# - cert: the ::OpenSSL::X509::Certificate instance of the first PEM provided by
|
92
|
+
# the peer, nil otherwise.
|
101
93
|
# - validated: true if the given certificate(s) have been validated, false otherwise
|
102
94
|
# and nil if no certificate is provided by peer or no CA's were configured
|
103
95
|
# for TLS validation.
|
104
|
-
# - cert: the ::OpenSSL::X509::Certificate instance of the first PEM provided by
|
105
|
-
# the peer, nil otherwise.
|
106
96
|
# - tls_error: OpenSSL validation error code (Fixnum) in case of validation error.
|
107
97
|
# - tls_error_string: OpenSSL validation error string in case of validation error.
|
108
|
-
def self.validate
|
109
|
-
return nil, nil, nil, "no CAs provided, validation
|
110
|
-
return nil,
|
98
|
+
def self.validate pems
|
99
|
+
return nil, nil, nil, "no CAs provided, validation disabled" unless @store
|
100
|
+
return nil, false, nil, "no certificate provided by peer" unless pems.any?
|
101
|
+
|
102
|
+
pem = pems.pop
|
103
|
+
intermediate_pems = pems
|
111
104
|
|
112
105
|
begin
|
113
106
|
cert = ::OpenSSL::X509::Certificate.new pem
|
@@ -122,19 +115,21 @@ module OverSIP
|
|
122
115
|
end
|
123
116
|
|
124
117
|
if @store.verify cert, intermediate_certs
|
125
|
-
return
|
118
|
+
return cert, true
|
126
119
|
else
|
127
|
-
return
|
120
|
+
return cert, false, @store.error, @store.error_string
|
128
121
|
end
|
129
122
|
|
130
123
|
rescue => e
|
131
124
|
log_system_error "exception validating a certificate: #{e.class}: #{e.message}"
|
132
|
-
return
|
125
|
+
return nil, false, e.class, e.message
|
133
126
|
end
|
134
127
|
end # def self.validate
|
135
128
|
|
136
129
|
|
137
130
|
def self.get_sip_identities cert
|
131
|
+
return [] unless cert
|
132
|
+
|
138
133
|
verify_subjectAltName_DNS = true
|
139
134
|
verify_CN = true
|
140
135
|
subjectAltName_URI_sip_entries = []
|
@@ -171,7 +166,8 @@ module OverSIP
|
|
171
166
|
end
|
172
167
|
end
|
173
168
|
|
174
|
-
|
169
|
+
# Return an array with the SIP identities (domains) in the certificate.
|
170
|
+
return sip_identities.keys
|
175
171
|
end
|
176
172
|
|
177
173
|
end
|
data/lib/oversip/version.rb
CHANGED
@@ -4,11 +4,6 @@ module OverSIP::WebSocket
|
|
4
4
|
|
5
5
|
include ::OverSIP::Logger
|
6
6
|
|
7
|
-
# HTTP related attributes.
|
8
|
-
attr_accessor :transport
|
9
|
-
attr_accessor :source_ip
|
10
|
-
attr_accessor :source_ip_type
|
11
|
-
attr_accessor :source_port
|
12
7
|
attr_accessor :connection
|
13
8
|
|
14
9
|
# HTTP request attributes.
|
@@ -30,8 +25,9 @@ module OverSIP::WebSocket
|
|
30
25
|
attr_reader :hdr_sec_websocket_protocol
|
31
26
|
|
32
27
|
|
28
|
+
LOG_ID = "HTTP WS Request"
|
33
29
|
def log_id
|
34
|
-
|
30
|
+
LOG_ID
|
35
31
|
end
|
36
32
|
|
37
33
|
def unknown_method? ; @is_unknown_method end
|
@@ -50,7 +46,7 @@ module OverSIP::WebSocket
|
|
50
46
|
log_system_debug "replying #{status_code} \"#{reason_phrase}\"" if $oversip_debug
|
51
47
|
|
52
48
|
if @connection.error?
|
53
|
-
log_system_warn "cannot send response,
|
49
|
+
log_system_warn "cannot send response, connection is closed"
|
54
50
|
return false
|
55
51
|
end
|
56
52
|
|
@@ -58,6 +54,6 @@ module OverSIP::WebSocket
|
|
58
54
|
return true
|
59
55
|
end
|
60
56
|
|
61
|
-
end
|
57
|
+
end
|
62
58
|
|
63
59
|
end
|
@@ -15,7 +15,7 @@ module OverSIP::WebSocket
|
|
15
15
|
end
|
16
16
|
|
17
17
|
|
18
|
-
def self.run enabled, ip_type, ip, port, transport,
|
18
|
+
def self.run enabled, ip_type, ip, port, transport, virtual_ip=nil, virtual_port=nil
|
19
19
|
uri_ip = case ip_type
|
20
20
|
when :ipv4 ; ip
|
21
21
|
when :ipv6 ; "[#{ip}]"
|
@@ -29,167 +29,111 @@ module OverSIP::WebSocket
|
|
29
29
|
end
|
30
30
|
|
31
31
|
klass = case transport
|
32
|
-
when :
|
32
|
+
when :ws
|
33
33
|
case ip_type
|
34
|
-
when :ipv4 ; OverSIP::WebSocket::
|
35
|
-
when :ipv6 ; OverSIP::WebSocket::
|
34
|
+
when :ipv4 ; OverSIP::WebSocket::IPv4WsServer
|
35
|
+
when :ipv6 ; OverSIP::WebSocket::IPv6WsServer
|
36
36
|
end
|
37
|
-
when :
|
37
|
+
when :wss
|
38
38
|
case ip_type
|
39
|
-
when :ipv4 ; OverSIP::WebSocket::
|
40
|
-
when :ipv6 ; OverSIP::WebSocket::
|
39
|
+
when :ipv4 ; OverSIP::WebSocket::IPv4WssServer
|
40
|
+
when :ipv6 ; OverSIP::WebSocket::IPv6WssServer
|
41
41
|
end
|
42
|
-
when :
|
42
|
+
when :wss_tunnel
|
43
43
|
case ip_type
|
44
|
-
when :ipv4 ; OverSIP::WebSocket::
|
45
|
-
when :ipv6 ; OverSIP::WebSocket::
|
44
|
+
when :ipv4 ; OverSIP::WebSocket::IPv4WssTunnelServer
|
45
|
+
when :ipv6 ; OverSIP::WebSocket::IPv6WssTunnelServer
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
49
|
-
|
50
|
-
|
51
|
-
when OverSIP::WebSocket::WS_SIP_PROTOCOL
|
52
|
-
|
53
|
-
ws_app_klass = case transport
|
54
|
-
when :tcp
|
55
|
-
case ip_type
|
56
|
-
when :ipv4 ; OverSIP::WebSocket::IPv4WsSipApp
|
57
|
-
when :ipv6 ; OverSIP::WebSocket::IPv6WsSipApp
|
58
|
-
end
|
59
|
-
when :tls, :tls_tunnel
|
60
|
-
case ip_type
|
61
|
-
when :ipv4 ; OverSIP::WebSocket::IPv4WssSipApp
|
62
|
-
when :ipv6 ; OverSIP::WebSocket::IPv6WssSipApp
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
ws_app_klass.ip = virtual_ip || ip
|
67
|
-
ws_app_klass.port = virtual_port || port
|
49
|
+
klass.ip = virtual_ip || ip
|
50
|
+
klass.port = virtual_port || port
|
68
51
|
|
69
|
-
|
52
|
+
case
|
70
53
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
54
|
+
when klass == OverSIP::WebSocket::IPv4WsServer
|
55
|
+
klass.via_core = "SIP/2.0/WS #{uri_ip}:#{port}"
|
56
|
+
klass.record_route = "<sip:#{uri_ip}:#{port};transport=ws;lr;ovid=#{OverSIP::SIP::Tags.value_for_route_ovid}>"
|
57
|
+
klass.outbound_record_route_fragment = "@#{uri_ip}:#{port};transport=ws;lr;ovid=#{OverSIP::SIP::Tags.value_for_route_ovid}>"
|
58
|
+
klass.outbound_path_fragment = "@#{uri_ip}:#{port};transport=ws;lr;ovid=#{OverSIP::SIP::Tags.value_for_route_ovid};ob>"
|
76
59
|
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
conn.post_connection
|
82
|
-
conn.set_comm_inactivity_timeout 3600 # TODO
|
83
|
-
end
|
60
|
+
if enabled
|
61
|
+
EM.start_server(ip, port, klass) do |conn|
|
62
|
+
conn.post_connection
|
63
|
+
conn.set_comm_inactivity_timeout 3600 # TODO
|
84
64
|
end
|
65
|
+
end
|
85
66
|
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
if enabled
|
93
|
-
EM.start_server(ip, port, klass) do |conn|
|
94
|
-
conn.ws_protocol = ws_protocol
|
95
|
-
conn.ws_app_klass = ws_app_klass
|
96
|
-
conn.post_connection
|
97
|
-
conn.set_comm_inactivity_timeout 3600 # TODO
|
98
|
-
end
|
99
|
-
end
|
67
|
+
when klass == OverSIP::WebSocket::IPv6WsServer
|
68
|
+
klass.via_core = "SIP/2.0/WS #{uri_ip}:#{port}"
|
69
|
+
klass.record_route = "<sip:#{uri_ip}:#{port};transport=ws;lr;ovid=#{OverSIP::SIP::Tags.value_for_route_ovid}>"
|
70
|
+
klass.outbound_record_route_fragment = "@#{uri_ip}:#{port};transport=ws;lr;ovid=#{OverSIP::SIP::Tags.value_for_route_ovid}>"
|
71
|
+
klass.outbound_path_fragment = "@#{uri_ip}:#{port};transport=ws;lr;ovid=#{OverSIP::SIP::Tags.value_for_route_ovid};ob>"
|
100
72
|
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
ws_app_klass.outbound_record_route_fragment = "@#{rr_host}:#{port};transport=wss;lr;ovid=#{OverSIP::SIP::Tags.value_for_route_ovid}>"
|
106
|
-
ws_app_klass.outbound_path_fragment = "@#{rr_host}:#{port};transport=wss;lr;ovid=#{OverSIP::SIP::Tags.value_for_route_ovid};ob>"
|
107
|
-
|
108
|
-
if enabled
|
109
|
-
EM.start_server(ip, port, klass) do |conn|
|
110
|
-
conn.ws_protocol = ws_protocol
|
111
|
-
conn.ws_app_klass = ws_app_klass
|
112
|
-
conn.post_connection
|
113
|
-
conn.set_comm_inactivity_timeout 3600 # TODO
|
114
|
-
end
|
73
|
+
if enabled
|
74
|
+
EM.start_server(ip, port, klass) do |conn|
|
75
|
+
conn.post_connection
|
76
|
+
conn.set_comm_inactivity_timeout 3600 # TODO
|
115
77
|
end
|
78
|
+
end
|
116
79
|
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
conn.post_connection
|
129
|
-
conn.set_comm_inactivity_timeout 3600 # TODO
|
130
|
-
end
|
80
|
+
when klass == OverSIP::WebSocket::IPv4WssServer
|
81
|
+
klass.via_core = "SIP/2.0/WSS #{uri_ip}:#{port}"
|
82
|
+
rr_host = ::OverSIP.configuration[:sip][:record_route_hostname_tls_ipv4] || uri_ip
|
83
|
+
klass.record_route = "<sip:#{rr_host}:#{port};transport=wss;lr;ovid=#{OverSIP::SIP::Tags.value_for_route_ovid}>"
|
84
|
+
klass.outbound_record_route_fragment = "@#{rr_host}:#{port};transport=wss;lr;ovid=#{OverSIP::SIP::Tags.value_for_route_ovid}>"
|
85
|
+
klass.outbound_path_fragment = "@#{rr_host}:#{port};transport=wss;lr;ovid=#{OverSIP::SIP::Tags.value_for_route_ovid};ob>"
|
86
|
+
|
87
|
+
if enabled
|
88
|
+
EM.start_server(ip, port, klass) do |conn|
|
89
|
+
conn.post_connection
|
90
|
+
conn.set_comm_inactivity_timeout 3600 # TODO
|
131
91
|
end
|
92
|
+
end
|
132
93
|
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
conn.post_connection
|
145
|
-
conn.set_comm_inactivity_timeout 3600 # TODO
|
146
|
-
end
|
94
|
+
when klass == OverSIP::WebSocket::IPv6WssServer
|
95
|
+
klass.via_core = "SIP/2.0/WSS #{uri_ip}:#{port}"
|
96
|
+
rr_host = ::OverSIP.configuration[:sip][:record_route_hostname_tls_ipv6] || uri_ip
|
97
|
+
klass.record_route = "<sips:#{rr_host}:#{port};transport=ws;lr;ovid=#{OverSIP::SIP::Tags.value_for_route_ovid}>"
|
98
|
+
klass.outbound_record_route_fragment = "@#{rr_host}:#{port};transport=wss;lr;ovid=#{OverSIP::SIP::Tags.value_for_route_ovid}>"
|
99
|
+
klass.outbound_path_fragment = "@#{rr_host}:#{port};transport=wss;lr;ovid=#{OverSIP::SIP::Tags.value_for_route_ovid};ob>"
|
100
|
+
|
101
|
+
if enabled
|
102
|
+
EM.start_server(ip, port, klass) do |conn|
|
103
|
+
conn.post_connection
|
104
|
+
conn.set_comm_inactivity_timeout 3600 # TODO
|
147
105
|
end
|
106
|
+
end
|
148
107
|
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
conn.post_connection
|
161
|
-
conn.set_comm_inactivity_timeout 3600 # TODO
|
162
|
-
end
|
108
|
+
when klass == OverSIP::WebSocket::IPv4WssTunnelServer
|
109
|
+
klass.via_core = "SIP/2.0/WSS #{uri_virtual_ip}:#{virtual_port}"
|
110
|
+
rr_host = ::OverSIP.configuration[:sip][:record_route_hostname_tls_ipv4] || uri_virtual_ip
|
111
|
+
klass.record_route = "<sip:#{rr_host}:#{virtual_port};transport=wss;lr;ovid=#{OverSIP::SIP::Tags.value_for_route_ovid}>"
|
112
|
+
klass.outbound_record_route_fragment = "@#{rr_host}:#{virtual_port};transport=wss;lr;ovid=#{OverSIP::SIP::Tags.value_for_route_ovid}>"
|
113
|
+
klass.outbound_path_fragment = "@#{rr_host}:#{virtual_port};transport=wss;lr;ovid=#{OverSIP::SIP::Tags.value_for_route_ovid};ob>"
|
114
|
+
|
115
|
+
if enabled
|
116
|
+
EM.start_server(ip, port, klass) do |conn|
|
117
|
+
conn.post_connection
|
118
|
+
conn.set_comm_inactivity_timeout 3600 # TODO
|
163
119
|
end
|
164
|
-
|
165
|
-
end # case
|
166
|
-
|
167
|
-
|
168
|
-
when OverSIP::WebSocket::WS_AUTOBAHN_PROTOCOL
|
169
|
-
|
170
|
-
ws_app_klass = case transport
|
171
|
-
when :tcp
|
172
|
-
case ip_type
|
173
|
-
when :ipv4 ; OverSIP::WebSocket::WsAutobahnApp
|
174
|
-
end
|
175
|
-
when :tls
|
176
|
-
case ip_type
|
177
|
-
when :ipv4 ; OverSIP::WebSocket::WsAutobahnApp
|
178
|
-
end
|
179
120
|
end
|
180
121
|
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
122
|
+
when klass == OverSIP::WebSocket::IPv6WssTunnelServer
|
123
|
+
klass.via_core = "SIP/2.0/WSS #{uri_virtual_ip}:#{virtual_port}"
|
124
|
+
rr_host = ::OverSIP.configuration[:sip][:record_route_hostname_tls_ipv6] || uri_virtual_ip
|
125
|
+
klass.record_route = "<sip:#{rr_host}:#{virtual_port};transport=wss;lr;ovid=#{OverSIP::SIP::Tags.value_for_route_ovid}>"
|
126
|
+
klass.outbound_record_route_fragment = "@#{rr_host}:#{virtual_port};transport=wss;lr;ovid=#{OverSIP::SIP::Tags.value_for_route_ovid}>"
|
127
|
+
klass.outbound_path_fragment = "@#{rr_host}:#{virtual_port};transport=wss;lr;ovid=#{OverSIP::SIP::Tags.value_for_route_ovid};ob>"
|
128
|
+
|
129
|
+
if enabled
|
130
|
+
EM.start_server(ip, port, klass) do |conn|
|
131
|
+
conn.post_connection
|
132
|
+
conn.set_comm_inactivity_timeout 3600 # TODO
|
133
|
+
end
|
134
|
+
end
|
191
135
|
|
192
|
-
|
136
|
+
end # case
|
193
137
|
|
194
138
|
transport_str = case transport
|
195
139
|
when :tls_tunnel ; "TLS-Tunnel"
|
@@ -197,7 +141,7 @@ module OverSIP::WebSocket
|
|
197
141
|
end
|
198
142
|
|
199
143
|
if enabled
|
200
|
-
log_system_info "WebSocket #{transport_str} server listening on #{IP_TYPE[ip_type]} #{uri_ip}:#{port} provides '#{
|
144
|
+
log_system_info "WebSocket #{transport_str} server listening on #{IP_TYPE[ip_type]} #{uri_ip}:#{port} provides '#{::OverSIP::WebSocket::WS_SIP_PROTOCOL}' WS subprotocol"
|
201
145
|
end
|
202
146
|
|
203
147
|
end # def self.run
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module OverSIP::WebSocket
|
2
|
+
|
3
|
+
class Connection < ::EM::Connection
|
4
|
+
|
5
|
+
include ::OverSIP::Logger
|
6
|
+
include ::OverSIP::SIP::MessageProcessor
|
7
|
+
|
8
|
+
class << self
|
9
|
+
attr_accessor :ip_type, :ip, :port, :transport,
|
10
|
+
:via_core,
|
11
|
+
:record_route,
|
12
|
+
:outbound_record_route_fragment, :outbound_path_fragment,
|
13
|
+
:connections,
|
14
|
+
:invite_server_transactions, :non_invite_server_transactions,
|
15
|
+
:invite_client_transactions, :non_invite_client_transactions
|
16
|
+
|
17
|
+
def reliable_transport_listener?
|
18
|
+
@is_reliable_transport_listener
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
|
23
|
+
attr_reader :cvars
|
24
|
+
|
25
|
+
def initialize
|
26
|
+
@buffer = ::IO::Buffer.new
|
27
|
+
@state = :init
|
28
|
+
@cvars = {}
|
29
|
+
end
|
30
|
+
|
31
|
+
def open?
|
32
|
+
! error?
|
33
|
+
end
|
34
|
+
|
35
|
+
def close status=nil, reason=nil
|
36
|
+
# When in WebSocket protocol send a close control frame before closing
|
37
|
+
# the connection.
|
38
|
+
if @state == :websocket
|
39
|
+
@ws_framing.send_close_frame status, reason
|
40
|
+
end
|
41
|
+
|
42
|
+
close_connection_after_writing
|
43
|
+
@state = :ignore
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module OverSIP::WebSocket
|
2
2
|
|
3
|
-
class
|
3
|
+
class IPv4WsServer < WsServer
|
4
4
|
|
5
5
|
@ip_type = :ipv4
|
6
6
|
@transport = :ws
|
@@ -11,11 +11,11 @@ module OverSIP::WebSocket
|
|
11
11
|
@non_invite_client_transactions = {}
|
12
12
|
@is_reliable_transport_listener = true
|
13
13
|
|
14
|
-
LOG_ID = "WS IPv4
|
14
|
+
LOG_ID = "SIP WS IPv4 server"
|
15
15
|
def log_id
|
16
16
|
LOG_ID
|
17
17
|
end
|
18
18
|
|
19
19
|
end
|
20
20
|
|
21
|
-
end
|
21
|
+
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module OverSIP::WebSocket
|
2
2
|
|
3
|
-
class
|
3
|
+
class IPv4WssServer < WssServer
|
4
4
|
|
5
5
|
@ip_type = :ipv4
|
6
6
|
@transport = :wss
|
@@ -11,7 +11,7 @@ module OverSIP::WebSocket
|
|
11
11
|
@non_invite_client_transactions = {}
|
12
12
|
@is_reliable_transport_listener = true
|
13
13
|
|
14
|
-
LOG_ID = "WSS IPv4
|
14
|
+
LOG_ID = "SIP WSS IPv4 server"
|
15
15
|
def log_id
|
16
16
|
LOG_ID
|
17
17
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module OverSIP::WebSocket
|
2
|
+
|
3
|
+
class IPv4WssTunnelServer < WssTunnelServer
|
4
|
+
|
5
|
+
@ip_type = :ipv4
|
6
|
+
@transport = :wss
|
7
|
+
@connections = {}
|
8
|
+
@invite_server_transactions = {}
|
9
|
+
@non_invite_server_transactions = {}
|
10
|
+
@invite_client_transactions = {}
|
11
|
+
@non_invite_client_transactions = {}
|
12
|
+
@is_reliable_transport_listener = true
|
13
|
+
|
14
|
+
LOG_ID = "SIP WSS-Tunnel IPv4 server"
|
15
|
+
def log_id
|
16
|
+
LOG_ID
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module OverSIP::WebSocket
|
2
2
|
|
3
|
-
class
|
3
|
+
class IPv6WsServer < WsServer
|
4
4
|
|
5
5
|
@ip_type = :ipv6
|
6
6
|
@transport = :ws
|
@@ -11,11 +11,11 @@ module OverSIP::WebSocket
|
|
11
11
|
@non_invite_client_transactions = {}
|
12
12
|
@is_reliable_transport_listener = true
|
13
13
|
|
14
|
-
LOG_ID = "WS IPv6
|
14
|
+
LOG_ID = "SIP WS IPv6 server"
|
15
15
|
def log_id
|
16
16
|
LOG_ID
|
17
17
|
end
|
18
18
|
|
19
19
|
end
|
20
20
|
|
21
|
-
end
|
21
|
+
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module OverSIP::WebSocket
|
2
2
|
|
3
|
-
class
|
3
|
+
class IPv6WssServer < WssServer
|
4
4
|
|
5
5
|
@ip_type = :ipv6
|
6
6
|
@transport = :wss
|
@@ -11,7 +11,7 @@ module OverSIP::WebSocket
|
|
11
11
|
@non_invite_client_transactions = {}
|
12
12
|
@is_reliable_transport_listener = true
|
13
13
|
|
14
|
-
LOG_ID = "WSS IPv6
|
14
|
+
LOG_ID = "SIP WSS IPv6 server"
|
15
15
|
def log_id
|
16
16
|
LOG_ID
|
17
17
|
end
|
@@ -19,4 +19,3 @@ module OverSIP::WebSocket
|
|
19
19
|
end
|
20
20
|
|
21
21
|
end
|
22
|
-
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module OverSIP::WebSocket
|
2
|
+
|
3
|
+
class IPv6WssTunnelServer < WssTunnelServer
|
4
|
+
|
5
|
+
@ip_type = :ipv6
|
6
|
+
@transport = :wss
|
7
|
+
@connections = {}
|
8
|
+
@invite_server_transactions = {}
|
9
|
+
@non_invite_server_transactions = {}
|
10
|
+
@invite_client_transactions = {}
|
11
|
+
@non_invite_client_transactions = {}
|
12
|
+
@is_reliable_transport_listener = true
|
13
|
+
|
14
|
+
LOG_ID = "SIP WSS-Tunnel IPv6 server"
|
15
|
+
def log_id
|
16
|
+
LOG_ID
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|