Skip to content
This repository has been archived by the owner on Aug 14, 2020. It is now read-only.

Error when trying to change sip destination domain prior proxying #55

Open
ti24horas opened this issue Nov 23, 2013 · 1 comment
Open
Labels
Milestone

Comments

@ti24horas
Copy link

Hi guys,

I found an issue with sip destination domain change in "To" request attribute.

The use case in which I found the bug is:

def (OverSIP::SipEvents).on_request request
# the whole file is from the sample
...
  case request.sip_method

  when :INVITE, :MESSAGE, :OPTIONS, :SUBSCRIBE, :PUBLISH, :REFER
    if MyExampleApp.do_user_assertion
      ::OverSIP::Modules::UserAssertion.add_pai request
    end

    request.to.host = 'my.custom_gateway.com'

    request.ruri.host = 'my.custom_gateway.com'

    proxy = ::OverSIP::SIP::Proxy.new 

    proxy.on_provisional_response do |response|
      log_info "on_provisional_response: #{response.status_code} '#{response.reason_phrase}'"
    end

    proxy.on_success_response do |response|
      log_info "on_success_response: #{response.status_code} '#{response.reason_phrase}'"
    end

    proxy.on_failure_response do |response|
      log_info "on_failure_response: #{response.status_code} '#{response.reason_phrase}'"
    end

    proxy.on_error do |status, reason|
      log_notice "on_error: #{status} '#{reason}'"
    end

    proxy.on_invite_timeout do
      log_notice "INVITE timeout, no final response before Timer C expires."
    end
    log_info "doing route request"
    log_info "request ruri: #{request.ruri}"

    # if accessing request.to.to_s, request.to_s wont change "To" variable due to to_was_modified going false after to.to_s
    log_info "debug_to: #{request.to}."
    log_info "debug_to(2): #{request.to}."
#    log_info "new request to: #{request.to}. Modified: #{request.to.modified?}"
#    log_info request.to_s
    proxy.route request, 'my.custom_gateway.com', 5060, :tcp
    return

Resuming:

If we access request.to.to_s before proxying, the request.to.host is gone

Should I create a pull request for this? I would comment the to_was_modified in request.to_s so it allways change 'To' header

@ibc
Copy link
Member

ibc commented Mar 24, 2014

Sorry for the delay. Good catch.
Anyhow I don't want to remove the "to_was_modified" check as it is there for performance. Let me think about it.

@ibc ibc added the bug label Mar 24, 2014
@ibc ibc added this to the Version 1.4.x milestone Mar 24, 2014
@ibc ibc modified the milestones: Version 1.4.x, Version 2.0.X Sep 24, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

No branches or pull requests

2 participants