Module: OverSIP::WebSocket::Launcher
- Extended by:
- Logger
- Defined in:
- lib/oversip/websocket/launcher.rb
Constant Summary collapse
- IP_TYPE =
{ :ipv4 => "IPv4", :ipv6 => "IPv6" }
Class Method Summary collapse
Methods included from Logger
fg_system_msg2str, load_methods, log_id
Class Method Details
.run(enabled, ip_type, ip, port, transport, virtual_ip = nil, virtual_port = nil) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 |
# File 'lib/oversip/websocket/launcher.rb', line 16 def self.run enabled, ip_type, ip, port, transport, virtual_ip=nil, virtual_port=nil uri_ip = case ip_type when :ipv4 ; ip when :ipv6 ; "[#{ip}]" end if virtual_ip uri_virtual_ip = case ip_type when :ipv4 ; virtual_ip when :ipv6 ; "[#{virtual_ip}]" end end klass = case transport when :ws case ip_type when :ipv4 ; ::OverSIP::WebSocket::IPv4WsServer when :ipv6 ; ::OverSIP::WebSocket::IPv6WsServer end when :wss case ip_type when :ipv4 ; ::OverSIP::WebSocket::IPv4WssServer when :ipv6 ; ::OverSIP::WebSocket::IPv6WssServer end when :wss_tunnel case ip_type when :ipv4 ; ::OverSIP::WebSocket::IPv4WssTunnelServer when :ipv6 ; ::OverSIP::WebSocket::IPv6WssTunnelServer end end klass.ip = virtual_ip || ip klass.port = virtual_port || port case when klass == ::OverSIP::WebSocket::IPv4WsServer if ::OverSIP.configuration[:websocket][:advertised_ipv4] used_uri_host = ::OverSIP.configuration[:websocket][:advertised_ipv4] else used_uri_host = uri_ip end klass.via_core = "SIP/2.0/WS #{used_uri_host}:#{port}" klass.record_route = "<sip:#{used_uri_host}:#{port};transport=ws;lr;ovid=#{OverSIP::SIP::Tags.value_for_route_ovid}>" klass.outbound_record_route_fragment = "@#{used_uri_host}:#{port};transport=ws;lr;ovid=#{OverSIP::SIP::Tags.value_for_route_ovid}>" klass.outbound_path_fragment = "@#{used_uri_host}:#{port};transport=ws;lr;ovid=#{OverSIP::SIP::Tags.value_for_route_ovid};ob>" if enabled ::EM.start_server(ip, port, klass) do |conn| conn.post_connection conn.set_comm_inactivity_timeout 7200 end end when klass == ::OverSIP::WebSocket::IPv6WsServer if ::OverSIP.configuration[:websocket][:advertised_ipv6] used_uri_host = "[#{::OverSIP.configuration[:websocket][:advertised_ipv6]}]" else used_uri_host = uri_ip end klass.via_core = "SIP/2.0/WS #{used_uri_host}:#{port}" klass.record_route = "<sip:#{used_uri_host}:#{port};transport=ws;lr;ovid=#{OverSIP::SIP::Tags.value_for_route_ovid}>" klass.outbound_record_route_fragment = "@#{used_uri_host}:#{port};transport=ws;lr;ovid=#{OverSIP::SIP::Tags.value_for_route_ovid}>" klass.outbound_path_fragment = "@#{used_uri_host}:#{port};transport=ws;lr;ovid=#{OverSIP::SIP::Tags.value_for_route_ovid};ob>" if enabled ::EM.start_server(ip, port, klass) do |conn| conn.post_connection conn.set_comm_inactivity_timeout 7200 end end when klass == ::OverSIP::WebSocket::IPv4WssServer if ::OverSIP.configuration[:sip][:record_route_hostname_tls_ipv4] used_uri_host = ::OverSIP.configuration[:sip][:record_route_hostname_tls_ipv4] elsif ::OverSIP.configuration[:websocket][:advertised_ipv4] used_uri_host = ::OverSIP.configuration[:websocket][:advertised_ipv4] else used_uri_host = uri_ip end klass.via_core = "SIP/2.0/WS #{used_uri_host}:#{port}" klass.record_route = "<sip:#{used_uri_host}:#{port};transport=ws;lr;ovid=#{OverSIP::SIP::Tags.value_for_route_ovid}>" klass.outbound_record_route_fragment = "@#{used_uri_host}:#{port};transport=ws;lr;ovid=#{OverSIP::SIP::Tags.value_for_route_ovid}>" klass.outbound_path_fragment = "@#{used_uri_host}:#{port};transport=ws;lr;ovid=#{OverSIP::SIP::Tags.value_for_route_ovid};ob>" if enabled ::EM.start_server(ip, port, klass) do |conn| conn.post_connection conn.set_comm_inactivity_timeout 7200 end end when klass == ::OverSIP::WebSocket::IPv6WssServer if ::OverSIP.configuration[:sip][:record_route_hostname_tls_ipv6] used_uri_host = ::OverSIP.configuration[:sip][:record_route_hostname_tls_ipv6] elsif ::OverSIP.configuration[:websocket][:advertised_ipv6] used_uri_host = "[#{::OverSIP.configuration[:websocket][:advertised_ipv6]}]" else used_uri_host = uri_ip end klass.via_core = "SIP/2.0/WS #{used_uri_host}:#{port}" klass.record_route = "<sip:#{used_uri_host}:#{port};transport=ws;lr;ovid=#{OverSIP::SIP::Tags.value_for_route_ovid}>" klass.outbound_record_route_fragment = "@#{used_uri_host}:#{port};transport=ws;lr;ovid=#{OverSIP::SIP::Tags.value_for_route_ovid}>" klass.outbound_path_fragment = "@#{used_uri_host}:#{port};transport=ws;lr;ovid=#{OverSIP::SIP::Tags.value_for_route_ovid};ob>" if enabled ::EM.start_server(ip, port, klass) do |conn| conn.post_connection conn.set_comm_inactivity_timeout 7200 end end when klass == ::OverSIP::WebSocket::IPv4WssTunnelServer if ::OverSIP.configuration[:sip][:record_route_hostname_tls_ipv4] used_uri_host = ::OverSIP.configuration[:sip][:record_route_hostname_tls_ipv4] elsif ::OverSIP.configuration[:websocket][:advertised_ipv4] used_uri_host = ::OverSIP.configuration[:websocket][:advertised_ipv4] else used_uri_host = uri_virtual_ip end klass.via_core = "SIP/2.0/WSS #{used_uri_host}:#{virtual_port}" klass.record_route = "<sip:#{used_uri_host}:#{virtual_port};transport=wss;lr;ovid=#{OverSIP::SIP::Tags.value_for_route_ovid}>" klass.outbound_record_route_fragment = "@#{used_uri_host}:#{virtual_port};transport=wss;lr;ovid=#{OverSIP::SIP::Tags.value_for_route_ovid}>" klass.outbound_path_fragment = "@#{used_uri_host}:#{virtual_port};transport=wss;lr;ovid=#{OverSIP::SIP::Tags.value_for_route_ovid};ob>" if enabled ::EM.start_server(ip, port, klass) do |conn| conn.post_connection conn.set_comm_inactivity_timeout 7200 end end when klass == ::OverSIP::WebSocket::IPv6WssTunnelServer if ::OverSIP.configuration[:sip][:record_route_hostname_tls_ipv6] used_uri_host = ::OverSIP.configuration[:sip][:record_route_hostname_tls_ipv6] elsif ::OverSIP.configuration[:websocket][:advertised_ipv6] used_uri_host = "[#{::OverSIP.configuration[:websocket][:advertised_ipv6]}]" else used_uri_host = uri_virtual_ip end klass.via_core = "SIP/2.0/WSS #{used_uri_host}:#{virtual_port}" klass.record_route = "<sip:#{used_uri_host}:#{virtual_port};transport=wss;lr;ovid=#{OverSIP::SIP::Tags.value_for_route_ovid}>" klass.outbound_record_route_fragment = "@#{used_uri_host}:#{virtual_port};transport=wss;lr;ovid=#{OverSIP::SIP::Tags.value_for_route_ovid}>" klass.outbound_path_fragment = "@#{used_uri_host}:#{virtual_port};transport=wss;lr;ovid=#{OverSIP::SIP::Tags.value_for_route_ovid};ob>" if enabled ::EM.start_server(ip, port, klass) do |conn| conn.post_connection conn.set_comm_inactivity_timeout 7200 end end end # case transport_str = case transport when :tls_tunnel ; "TLS-Tunnel" else ; transport.to_s.upcase end if enabled log_system_info "WebSocket #{transport_str} server listening on #{IP_TYPE[ip_type]} #{uri_ip}:#{port} provides '#{::OverSIP::WebSocket::WS_SIP_PROTOCOL}' WS subprotocol" end end |