mirror of https://github.com/asterisk/asterisk
With rewrite_contact enabled, the Contact received from a device behind NAT is changed to the source address and port. Requests built from that contact (INVITE to a registered contact, ACK/BYE/re-INVITE to the dialog remote target, NOTIFY, OPTIONS) then carry the NAT address in the Request-URI and To header. Some devices refuse them because the request is not addressed to them (RFC 3261 8.2.2.1): a Cisco CP-8941 answers 404 Not Found to the INVITE and ignores the ACK of an answered call. When the new endpoint option is enabled together with rewrite_contact, the host and port announced in the Contact are saved in an internal "x-ast-restore-host" URI parameter before the rewrite, both for REGISTER and for dialog messages. On transmit, the Request-URI and To header get that host and port back and the internal parameters are removed. The destination was already resolved from the rewritten URI, so requests are still delivered to the source address and port. This follows RFC 3261 10.3, 16.5 and 12.2.1.1, as chan_sip did with nat=force_rport. WebSocket transports are not affected. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Resolves: #2312 UserNote: The new "restore_orig_contact_host" endpoint option, used with rewrite_contact, keeps the host and port the device announced in its Contact in the Request-URI and To header of requests sent to it, while still delivering them to the source address. This helps devices behind NAT that refuse requests addressed to the NAT address. UpgradeNote: The alembic script adds the "restore_orig_contact_host" column to the ps_endpoints table of the realtime database schema.pull/2313/head
parent
35be64cbed
commit
5b5de8b52b
@ -0,0 +1,30 @@
|
||||
"""Add restore_orig_contact_host to ps_endpoints
|
||||
|
||||
Revision ID: 7c3f9a1e2b6d
|
||||
Revises: 2b45fd748a4f
|
||||
Create Date: 2026-11-18 20:00:00.000000
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '7c3f9a1e2b6d'
|
||||
down_revision = '2b45fd748a4f'
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects.postgresql import ENUM
|
||||
|
||||
YESNO_NAME = 'yesno_values'
|
||||
YESNO_VALUES = ['yes', 'no']
|
||||
|
||||
|
||||
def upgrade():
|
||||
yesno_values = ENUM(*YESNO_VALUES, name=YESNO_NAME, create_type=False)
|
||||
|
||||
op.add_column('ps_endpoints', sa.Column('restore_orig_contact_host', yesno_values))
|
||||
|
||||
|
||||
def downgrade():
|
||||
if op.get_context().bind.dialect.name == 'mssql':
|
||||
op.drop_constraint('ck_ps_endpoints_restore_orig_contact_host_yesno_values', 'ps_endpoints')
|
||||
op.drop_column('ps_endpoints', 'restore_orig_contact_host')
|
||||
Loading…
Reference in new issue