Class: OverSIP::SIP::TlsTunnelServer

Inherits:
TlsTunnelConnection show all
Defined in:
lib/oversip/sip/listeners/tls_tunnel_server.rb

Direct Known Subclasses

IPv4TlsTunnelServer, IPv6TlsTunnelServer

Constant Summary

Constants inherited from TlsTunnelConnection

OverSIP::SIP::TlsTunnelConnection::HEADERS_MAX_SIZE

Constants inherited from TcpConnection

OverSIP::SIP::TcpConnection::HEADERS_MAX_SIZE

Constants included from MessageProcessor

MessageProcessor::MSG_TYPE

Instance Attribute Summary collapse

Attributes inherited from Connection

#cvars

Instance Method Summary collapse

Methods inherited from TlsTunnelConnection

#parse_haproxy_protocol, #process_received_data

Methods inherited from TcpConnection

#get_body, #parse_headers, #process_received_data, #receive_data, #remote_ip, #remote_ip_type, #remote_port, #send_sip_msg

Methods inherited from Connection

#initialize, #open?, outbound_listener?, #receive_senderror, reliable_transport_listener?, #transport

Methods included from Logger

close, 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::Connection

Instance Attribute Details

#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

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

  log_system_debug ("connection from the TLS tunnel " << remote_desc)  if $oversip_debug
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 unless $!
end