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
close, fg_system_msg2str, init_logger_mq, load_methods, log_id, syslog_system_msg2str, syslog_user_msg2str
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 |
# 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 klass.via_core = "SIP/2.0/WS #{uri_ip}:#{port}" klass.record_route = "<sip:#{uri_ip}:#{port};transport=ws;lr;ovid=#{OverSIP::SIP::Tags.value_for_route_ovid}>" klass.outbound_record_route_fragment = "@#{uri_ip}:#{port};transport=ws;lr;ovid=#{OverSIP::SIP::Tags.value_for_route_ovid}>" klass.outbound_path_fragment = "@#{uri_ip}:#{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 300 end end when klass == ::OverSIP::WebSocket::IPv6WsServer klass.via_core = "SIP/2.0/WS #{uri_ip}:#{port}" klass.record_route = "<sip:#{uri_ip}:#{port};transport=ws;lr;ovid=#{OverSIP::SIP::Tags.value_for_route_ovid}>" klass.outbound_record_route_fragment = "@#{uri_ip}:#{port};transport=ws;lr;ovid=#{OverSIP::SIP::Tags.value_for_route_ovid}>" klass.outbound_path_fragment = "@#{uri_ip}:#{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 300 end end when klass == ::OverSIP::WebSocket::IPv4WssServer klass.via_core = "SIP/2.0/WSS #{uri_ip}:#{port}" rr_host = ::OverSIP.configuration[:sip][:record_route_hostname_tls_ipv4] || uri_ip klass.record_route = "<sip:#{rr_host}:#{port};transport=wss;lr;ovid=#{OverSIP::SIP::Tags.value_for_route_ovid}>" klass.outbound_record_route_fragment = "@#{rr_host}:#{port};transport=wss;lr;ovid=#{OverSIP::SIP::Tags.value_for_route_ovid}>" klass.outbound_path_fragment = "@#{rr_host}:#{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 300 end end when klass == ::OverSIP::WebSocket::IPv6WssServer klass.via_core = "SIP/2.0/WSS #{uri_ip}:#{port}" rr_host = ::OverSIP.configuration[:sip][:record_route_hostname_tls_ipv6] || uri_ip klass.record_route = "<sips:#{rr_host}:#{port};transport=ws;lr;ovid=#{OverSIP::SIP::Tags.value_for_route_ovid}>" klass.outbound_record_route_fragment = "@#{rr_host}:#{port};transport=wss;lr;ovid=#{OverSIP::SIP::Tags.value_for_route_ovid}>" klass.outbound_path_fragment = "@#{rr_host}:#{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 300 end end when klass == ::OverSIP::WebSocket::IPv4WssTunnelServer klass.via_core = "SIP/2.0/WSS #{uri_virtual_ip}:#{virtual_port}" rr_host = ::OverSIP.configuration[:sip][:record_route_hostname_tls_ipv4] || uri_virtual_ip klass.record_route = "<sip:#{rr_host}:#{virtual_port};transport=wss;lr;ovid=#{OverSIP::SIP::Tags.value_for_route_ovid}>" klass.outbound_record_route_fragment = "@#{rr_host}:#{virtual_port};transport=wss;lr;ovid=#{OverSIP::SIP::Tags.value_for_route_ovid}>" klass.outbound_path_fragment = "@#{rr_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 300 end end when klass == ::OverSIP::WebSocket::IPv6WssTunnelServer klass.via_core = "SIP/2.0/WSS #{uri_virtual_ip}:#{virtual_port}" rr_host = ::OverSIP.configuration[:sip][:record_route_hostname_tls_ipv6] || uri_virtual_ip klass.record_route = "<sip:#{rr_host}:#{virtual_port};transport=wss;lr;ovid=#{OverSIP::SIP::Tags.value_for_route_ovid}>" klass.outbound_record_route_fragment = "@#{rr_host}:#{virtual_port};transport=wss;lr;ovid=#{OverSIP::SIP::Tags.value_for_route_ovid}>" klass.outbound_path_fragment = "@#{rr_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 300 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 |