Module: OverSIP::SIP::Launcher
- Extended by:
- Logger
- Defined in:
- lib/oversip/sip/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
15 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 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 |
# File 'lib/oversip/sip/launcher.rb', line 15 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 :udp case ip_type when :ipv4 ; ::OverSIP::SIP::IPv4UdpServer when :ipv6 ; ::OverSIP::SIP::IPv6UdpServer end when :tcp case ip_type when :ipv4 ; ::OverSIP::SIP::IPv4TcpServer when :ipv6 ; ::OverSIP::SIP::IPv6TcpServer end when :tls case ip_type when :ipv4 ; ::OverSIP::SIP::IPv4TlsServer when :ipv6 ; ::OverSIP::SIP::IPv6TlsServer end when :tls_tunnel case ip_type when :ipv4 ; ::OverSIP::SIP::IPv4TlsTunnelServer when :ipv6 ; ::OverSIP::SIP::IPv6TlsTunnelServer end end klass.ip = virtual_ip || ip klass.port = virtual_port || port case when klass == ::OverSIP::SIP::IPv4UdpServer if ::OverSIP.configuration[:sip][:advertised_ipv4] used_uri_host = ::OverSIP.configuration[:sip][:advertised_ipv4] else used_uri_host = uri_ip end klass.via_core = "SIP/2.0/UDP #{used_uri_host}:#{port}" klass.record_route = "<sip:#{used_uri_host}:#{port};transport=udp;lr;ovid=#{OverSIP::SIP::Tags.value_for_route_ovid}>" klass.outbound_record_route_fragment = "@#{used_uri_host}:#{port};transport=udp;lr;ovid=#{OverSIP::SIP::Tags.value_for_route_ovid}>" klass.outbound_path_fragment = "@#{used_uri_host}:#{port};transport=udp;lr;ovid=#{OverSIP::SIP::Tags.value_for_route_ovid};ob>" if enabled ::EM::open_datagram_socket(ip, port, klass) do |conn| klass.connections = conn end end when klass == ::OverSIP::SIP::IPv6UdpServer if ::OverSIP.configuration[:sip][:advertised_ipv6] used_uri_host = "[#{::OverSIP.configuration[:sip][:advertised_ipv6]}]" else used_uri_host = uri_ip end klass.via_core = "SIP/2.0/UDP #{used_uri_host}:#{port}" klass.record_route = "<sip:#{used_uri_host}:#{port};transport=udp;lr;ovid=#{OverSIP::SIP::Tags.value_for_route_ovid}>" klass.outbound_record_route_fragment = "@#{used_uri_host}:#{port};transport=udp;lr;ovid=#{OverSIP::SIP::Tags.value_for_route_ovid}>" klass.outbound_path_fragment = "@#{used_uri_host}:#{port};transport=udp;lr;ovid=#{OverSIP::SIP::Tags.value_for_route_ovid};ob>" if enabled ::EM::open_datagram_socket(ip, port, klass) do |conn| klass.connections = conn end end when klass == ::OverSIP::SIP::IPv4TcpServer if ::OverSIP.configuration[:sip][:advertised_ipv4] used_uri_host = ::OverSIP.configuration[:sip][:advertised_ipv4] else used_uri_host = uri_ip end klass.via_core = "SIP/2.0/TCP #{used_uri_host}:#{port}" klass.record_route = "<sip:#{used_uri_host}:#{port};transport=tcp;lr;ovid=#{OverSIP::SIP::Tags.value_for_route_ovid}>" klass.outbound_record_route_fragment = "@#{used_uri_host}:#{port};transport=tcp;lr;ovid=#{OverSIP::SIP::Tags.value_for_route_ovid}>" klass.outbound_path_fragment = "@#{used_uri_host}:#{port};transport=tcp;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::SIP::IPv6TcpServer if ::OverSIP.configuration[:sip][:advertised_ipv6] used_uri_host = "[#{::OverSIP.configuration[:sip][:advertised_ipv6]}]" else used_uri_host = uri_ip end klass.via_core = "SIP/2.0/TCP #{used_uri_host}:#{port}" klass.record_route = "<sip:#{used_uri_host}:#{port};transport=tcp;lr;ovid=#{OverSIP::SIP::Tags.value_for_route_ovid}>" klass.outbound_record_route_fragment = "@#{used_uri_host}:#{port};transport=tcp;lr;ovid=#{OverSIP::SIP::Tags.value_for_route_ovid}>" klass.outbound_path_fragment = "@#{used_uri_host}:#{port};transport=tcp;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::SIP::IPv4TlsServer if ::OverSIP.configuration[:sip][:record_route_hostname_tls_ipv4] used_uri_host = ::OverSIP.configuration[:sip][:record_route_hostname_tls_ipv4] elsif ::OverSIP.configuration[:sip][:advertised_ipv4] used_uri_host = ::OverSIP.configuration[:sip][:advertised_ipv4] else used_uri_host = uri_ip end klass.via_core = "SIP/2.0/TLS #{used_uri_host}:#{port}" klass.record_route = "<sip:#{used_uri_host}:#{port};transport=tls;lr;ovid=#{OverSIP::SIP::Tags.value_for_route_ovid}>" klass.outbound_record_route_fragment = "@#{used_uri_host}:#{port};transport=tls;lr;ovid=#{OverSIP::SIP::Tags.value_for_route_ovid}>" klass.outbound_path_fragment = "@#{used_uri_host}:#{port};transport=tls;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::SIP::IPv6TlsServer if ::OverSIP.configuration[:sip][:record_route_hostname_tls_ipv6] used_uri_host = ::OverSIP.configuration[:sip][:record_route_hostname_tls_ipv6] elsif ::OverSIP.configuration[:sip][:advertised_ipv6] used_uri_host = "[#{::OverSIP.configuration[:sip][:advertised_ipv6]}]" else used_uri_host = uri_ip end klass.via_core = "SIP/2.0/TLS #{used_uri_host}:#{port}" klass.record_route = "<sip:#{used_uri_host}:#{port};transport=tls;lr;ovid=#{OverSIP::SIP::Tags.value_for_route_ovid}>" klass.outbound_record_route_fragment = "@#{used_uri_host}:#{port};transport=tls;lr;ovid=#{OverSIP::SIP::Tags.value_for_route_ovid}>" klass.outbound_path_fragment = "@#{used_uri_host}:#{port};transport=tls;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::SIP::IPv4TlsTunnelServer if ::OverSIP.configuration[:sip][:record_route_hostname_tls_ipv4] used_uri_host = ::OverSIP.configuration[:sip][:record_route_hostname_tls_ipv4] elsif ::OverSIP.configuration[:sip][:advertised_ipv4] used_uri_host = ::OverSIP.configuration[:sip][:advertised_ipv4] else used_uri_host = uri_virtual_ip end klass.via_core = "SIP/2.0/TLS #{used_uri_host}:#{virtual_port}" klass.record_route = "<sip:#{used_uri_host}:#{virtual_port};transport=tls;lr;ovid=#{OverSIP::SIP::Tags.value_for_route_ovid}>" klass.outbound_record_route_fragment = "@#{used_uri_host}:#{virtual_port};transport=tls;lr;ovid=#{OverSIP::SIP::Tags.value_for_route_ovid}>" klass.outbound_path_fragment = "@#{used_uri_host}:#{virtual_port};transport=tls;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::SIP::IPv6TlsTunnelServer if ::OverSIP.configuration[:sip][:record_route_hostname_tls_ipv6] used_uri_host = ::OverSIP.configuration[:sip][:record_route_hostname_tls_ipv6] elsif ::OverSIP.configuration[:sip][:advertised_ipv6] used_uri_host = "[#{::OverSIP.configuration[:sip][:advertised_ipv6]}]" else used_uri_host = uri_virtual_ip end klass.via_core = "SIP/2.0/TLS #{used_uri_host}:#{virtual_port}" klass.record_route = "<sip:#{used_uri_host}:#{virtual_port};transport=tls;lr;ovid=#{OverSIP::SIP::Tags.value_for_route_ovid}>" klass.outbound_record_route_fragment = "@#{used_uri_host}:#{virtual_port};transport=tls;lr;ovid=#{OverSIP::SIP::Tags.value_for_route_ovid}>" klass.outbound_path_fragment = "@#{used_uri_host}:#{virtual_port};transport=tls;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 "SIP #{transport_str} server listening on #{IP_TYPE[ip_type]} #{uri_ip}:#{port}" end end |