<blockquote style="border-left: 1px solid #aaa; margin: 10px 0; padding: 0 10px;"><p style="white-space: pre-wrap; word-wrap: break-word;">Patch Set 4:</p><blockquote style="border-left: 1px solid #aaa; margin: 10px 0; padding: 0 10px;"><p style="white-space: pre-wrap; word-wrap: break-word;">Patch Set 4:</p><blockquote style="border-left: 1px solid #aaa; margin: 10px 0; padding: 0 10px;"><p style="white-space: pre-wrap; word-wrap: break-word;">Patch Set 4:</p><p style="white-space: pre-wrap; word-wrap: break-word;">One more issue.<br>I don't know why, but this patch is not working if the active contact record already exists in realtime table ps_contacts.</p><p style="white-space: pre-wrap; word-wrap: break-word;">If contact exists in ps_contacts then debug only<br>Saving contact<br>got contact <br>So when "got contact" the x-ast-orig-host not found and it's not saved into realtime table ps_contacts,<br>the uri field is 'sip:endpoint@endpoint-public-ip:endpoint-public-port'</p><p style="white-space: pre-wrap; word-wrap: break-word;">If contact not  exists in ps_contacts then debug<br>Saving contact<br>got contact<br>Found orig host:<br>The x-ast-orig-host is found and it's saved into realtime table ps_contacts<br>the uri field is 'sip:endpoint@endpoint-public-ip:endpoint-public-port;x-ast-orig-host=endpoint-private-ip:endpoint-private-port'</p></blockquote><p style="white-space: pre-wrap; word-wrap: break-word;"><br>Could you, please, look at res_pjsip_registrar.c function register_aor_core<br>starting with line 804.<br>It seems if contact URI:PORT from request is found in sorcery then this sorcery's contact will be used in response (so we lost x-ast-orig-host)</p></blockquote><p style="white-space: pre-wrap; word-wrap: break-word;">I don't think so.  We get a copy of the existing contact object, which has the x-ast-orig-host parameter, the modify a few fields like expiration time, then put it back in the contacts container with the parameter preserved.  I just tested it and it works as expected.</p></blockquote><p style="white-space: pre-wrap; word-wrap: break-word;"><br>Wrong.<br>The existing contact object doesn't have x-ast-orig-host parameter.<br>Please, look at <br>contact_update = ast_sorcery_copy(ast_sip_get_sorcery(), contact);<br>The contact_update object doesn't have x-ast-orig-host.<br>Then we set some parameters (expiration_time,qualify_frequency,authenticate_qualify,path,user_agent and reg_server) on this object.<br>But doesn't set the uri (leave the old value) in this object.<br>Then we update sorcery (in my case record in DB table ps_contacts) with this object.<br>Then we use this object to form a response.<br>The response will not contain the x-ast-orig-host parameter because contact_update object does not contain. The sorcery object (in my case record in ps_contacts) will not contain too, so next time again we will get the contact from sorcery which doesn't have x-ast-orig-host parameter.</p><p style="white-space: pre-wrap; word-wrap: break-word;">I tested it, without<br>ast_string_field_set(contact_update, uri, contact_uri);<br>the response Contact URI contains the wrong (rewritten) host/port.<br>With ast_string_field_set it contains original host/port.<br></p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/12824">View Change</a></p><ul style="list-style: none; padding: 0;"></ul><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/12824">change 12824</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/c/asterisk/+/12824"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 13 </div>
<div style="display:none"> Gerrit-Change-Id: Idc263ad2d2d7bd8faa047e5804d96a5fe1cd282e </div>
<div style="display:none"> Gerrit-Change-Number: 12824 </div>
<div style="display:none"> Gerrit-PatchSet: 4 </div>
<div style="display:none"> Gerrit-Owner: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Alexei Gradinari <alex2grad@gmail.com> </div>
<div style="display:none"> Gerrit-Reviewer: Friendly Automation </div>
<div style="display:none"> Gerrit-Reviewer: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Kevin Harwell <kharwell@digium.com> </div>
<div style="display:none"> Gerrit-Comment-Date: Mon, 16 Sep 2019 14:33:14 +0000 </div>
<div style="display:none"> Gerrit-HasComments: No </div>
<div style="display:none"> Gerrit-Has-Labels: No </div>
<div style="display:none"> Gerrit-MessageType: comment </div>