Module: OverSIP::SIP::Modules::RegistrarWithoutPath

Extended by:
Logger
Defined in:
lib/oversip/sip/modules/registrar_without_path.rb

Constant Summary

Constants included from Logger

Logger::SYSLOG_POSIXMQ_MAPPING

Class Method Summary collapse

Methods included from Logger

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

Class Method Details

.add_outbound_to_contact(request) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/oversip/sip/modules/registrar_without_path.rb', line 12

def self.add_outbound_to_contact request
  unless request.sip_method == :REGISTER
    raise ::OverSIP::LogicError, "request must be a REGISTER"
  end

  if request.contact and request.connection_outbound_flow_token
    log_system_debug "performing Contact mangling (adding ;ov-ob Outbound param) for #{request.log_id}"  if $oversip_debug

    # Add the ;ov-ob param to the Contact URI.
    request.contact.set_param "ov-ob", request.connection_outbound_flow_token
    # TODO: This should be done automatically, right?
    request.set_header "Contact", "#{request.contact.to_s}#{request.contact_params}"

    return true

  else
    return false
  end
end

.extract_outbound_from_ruri(request) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/oversip/sip/modules/registrar_without_path.rb', line 32

def self.extract_outbound_from_ruri request
  # Do nothing if the request already contains a Route header with the Outbound flow token (so
  # the registrar *does* support Path.
  unless request.incoming_outbound_requested?
    if ov_ob = request.ruri.del_param("ov-ob")
      log_system_debug "incoming Outbound flow token extracted from ;ov-ob param in RURI for #{request.log_id}"  if $oversip_debug
      request.route_outbound_flow_token = ov_ob
      request.incoming_outbound_requested = true
      return true
    else
      return false
    end

    else
    # If the request already contains a proper Outbound Route header, then at least try to remove
    # the ;ov-ob param from the RURI.
    request.ruri.del_param("ov-ob")
    return false
  end
end

.log_idObject



8
9
10
# File 'lib/oversip/sip/modules/registrar_without_path.rb', line 8

def self.log_id
  @@log_id ||= "RegistrarWithoutPath module"
end

.remove_outbound_from_contact(message) ⇒ Object



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/oversip/sip/modules/registrar_without_path.rb', line 53

def self.remove_outbound_from_contact message
  unless message.is_a? ::OverSIP::SIP::Message
    raise ::OverSIP::LogicError, "message must be a OverSIP::SIP::Request or OverSIP::SIP::Response"
  end

  if (contacts = message.headers["Contact"])
    log_system_debug "reverting original Contact value (removing ;ov-ob Outbound param) for response"  if $oversip_debug

    contacts.each do |contact|
      contact.gsub! /;ov-ob=[_\-0-9A-Za-z]+/, ""
    end

    return true

  else
    return false
  end
end