Class: OverSIP::SIP::TlsTunnelServer

Inherits:
TlsTunnelReactor show all
Defined in:
lib/oversip/sip/modules/user_assertion.rb,
lib/oversip/sip/listeners/tls_tunnel_server.rb

Direct Known Subclasses

IPv4TlsTunnelServer, IPv6TlsTunnelServer

Constant Summary

Constants inherited from TlsTunnelReactor

OverSIP::SIP::TlsTunnelReactor::HEADERS_MAX_SIZE

Constants inherited from TcpReactor

OverSIP::SIP::TcpReactor::HEADERS_MAX_SIZE

Constants included from MessageProcessor

MessageProcessor::MSG_TYPE

Constants included from Logger

Logger::SYSLOG_POSIXMQ_MAPPING

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from TlsTunnelReactor

#parse_client_pems, #parse_haproxy_protocol, #receive_data

Methods inherited from TcpReactor

#get_body, #parse_headers, #receive_data, #send_sip_msg

Methods inherited from Reactor

#initialize, #receive_senderror, reliable_transport_listener?

Methods included from Logger

close, #fatal, fg_system_msg2str, init_logger_mq, load_methods, #log_id, syslog_system_msg2str, syslog_user_msg2str

Constructor Details

This class inherits a constructor from OverSIP::SIP::Reactor

Instance Attribute Details

#asserted_userObject

Returns the value of attribute asserted_user.



109
110
111
# File 'lib/oversip/sip/modules/user_assertion.rb', line 109

def asserted_user
  @asserted_user
end

#outbound_flow_tokenObject (readonly)

Returns the value of attribute outbound_flow_token.



5
6
7
# File 'lib/oversip/sip/listeners/tls_tunnel_server.rb', line 5

def outbound_flow_token
  @outbound_flow_token
end

Instance Method Details

#post_connectionObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/oversip/sip/listeners/tls_tunnel_server.rb', line 7

def post_connection
  begin
    # Temporal @remote_ip and @remote_port until the HAProxy protocol line is parsed.
    @remote_port, @remote_ip = ::Socket.unpack_sockaddr_in(get_peername)
  rescue => e
    log_system_error "error obtaining remote IP/port (#{e.class}: #{e.message}), closing connection"
    close_connection
    @state = :ignore
    return
  end

  log_system_debug "connection from the TLS tunnel " << remote_desc

  # Create an Outbound (RFC 5626) flow token for this connection.
  @outbound_flow_token = ::OverSIP::SIP::TransportManager.add_outbound_connection self
end

#remote_desc(force = nil) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/oversip/sip/listeners/tls_tunnel_server.rb', line 24

def remote_desc force=nil
  if force
    @remote_desc = case @remote_ip_type
      when :ipv4  ; "#{@remote_ip}:#{@remote_port.to_s}"
      when :ipv6  ; "[#{@remote_ip}]:#{@remote_port.to_s}"
      end
  else
    @remote_desc ||= case self.class.ip_type
      when :ipv4  ; "#{@remote_ip}:#{@remote_port.to_s}"
      when :ipv6  ; "[#{@remote_ip}]:#{@remote_port.to_s}"
      end
  end
end

#unbind(cause = nil) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/oversip/sip/listeners/tls_tunnel_server.rb', line 39

def unbind cause=nil
  @state = :ignore

  # Remove the connection.
  self.class.connections.delete @connection_id  if @connection_id

  # Remove the Outbound token flow.
  ::OverSIP::SIP::TransportManager.delete_outbound_connection @outbound_flow_token

  @local_closed = true  if cause == ::Errno::ETIMEDOUT

  if $oversip_debug
    log_msg = "connection from the TLS tunnel #{remote_desc} "
    log_msg << ( @local_closed ? "locally closed" : "remotely closed" )
    log_msg << " (cause: #{cause.inspect})"  if cause
    log_system_debug log_msg
  end
end