drachtio / drachtio-server

A SIP call processing server that can be controlled via nodejs applications
https://drachtio.org
MIT License
233 stars 90 forks source link

Contact header contains private address not external address #319

Open tinpotnick opened 8 months ago

tinpotnick commented 8 months ago

When creating an outbound dialog using createUAC( "sip:1006@82.19.206.102:41826;transport=tcp", someheadersbutdefinitlynocontactheader )

The outbound INVITE contains the contact string, which uses the private address rather than the external address. This is causing the phone to send the BYE to the wrong location.

i.e. Contact: <sip:172.18.0.7:9997;transport=tcp> I expect it to be Contact: <sip:13.42.100.65:9997;transport=tcp>

Drachtio is started with

drachtio --stdout --loglevel debug --sofia-loglevel 9 --contact sip:172.18.0.7:9997;transport=udp,tcp --external-ip 13.42.100.65 --contact sips:172.18.0.7:443;transport=wss --external-ip 13.42.100.65 --contact sips:172.18.0.7:9998;transport=tls --external-ip 13.42.100.65

Start-up logs:

2023-11-17 15:52:40.413755 Starting drachtio version v0.8.22-1-g806d1cb
2023-11-17 15:52:40.413814 Logging threshold:                     5
2023-11-17 15:52:40.413825 DrachtioController::run: Main thread id: 281473410383936
2023-11-17 15:52:40.413832 DrachtioController::run: minTls version 1.2
2023-11-17 15:52:40.413836 DrachtioController::run tls key file:         /etc/letsencrypt/live/babblevoice.com/privkey.pem
2023-11-17 15:52:40.413841 DrachtioController::run tls certificate file: /etc/letsencrypt/live/babblevoice.com/cert.pem
2023-11-17 15:52:40.413845 DrachtioController::run tls chain file:       /etc/letsencrypt/live/babblevoice.com/fullchain.pem
2023-11-17 15:52:40.413850 DrachtioController::run listening for applications on tcp port 9022 only
2023-11-17 15:52:40.415387 ClientController::ClientController done setting tls options: 
2023-11-17 15:52:40.415415 Client controller initializing with tcp only
2023-11-17 15:52:40.415422 Client controller thread id: 281473410383936
2023-11-17 15:52:40.415481 ClientController::start_accept_tcp
2023-11-17 15:52:40.415519 DrachtioController::run - blacklist checking config
2023-11-17 15:52:40.415528 Client controller thread id: 281473410379456
2023-11-17 15:52:40.415568 ClientController::threadFunc - ClientController: io_context run loop started (or restarted)
2023-11-17 15:52:40.415540 responding to Prometheus on 0.0.0.0:8080
2023-11-17 15:52:40.416010 tcp keep alives will be sent to clients every 45 seconds
2023-11-17 15:52:40.416101 DrachtioController::run: starting sip stack on local address sip:172.18.0.7:9997;transport=udp,tcp (external address: 13.42.100.65)
2023-11-17 15:52:40.416120 SipTransport::getBindableContactUri: sip:13.42.100.65:9997;transport=udp,tcp;maddr=172.18.0.7
2023-11-17 15:52:40.416166 nta.c:979 nta_agent_create() nta_agent_create: initialized hash tables
2023-11-17 15:52:40.416254 tport.c:529 tport_tcreate() tport_create(): 0xaaaac9c14600
2023-11-17 15:52:40.416285 nta.c:2401 agent_create_master_transport() nta: master transport created
2023-11-17 15:52:40.416323 tport.c:1667 tport_bind_server() tport_bind_server(0xaaaac9c14600) to */172.18.0.7:9997
2023-11-17 15:52:40.416378 tport.c:1738 tport_bind_server() tport_bind_server(0xaaaac9c14600): calling tport_listen for udp
2023-11-17 15:52:40.416397 tport.c:651 tport_alloc_primary() tport_alloc_primary(0xaaaac9c14600): new primary tport 0xaaaac9c00500
2023-11-17 15:52:40.416472 tport.c:780 tport_listen() tport_listen(0xaaaac9c00500): listening at udp/172.18.0.7:9997
2023-11-17 15:52:40.416488 tport.c:1738 tport_bind_server() tport_bind_server(0xaaaac9c14600): calling tport_listen for tcp
2023-11-17 15:52:40.416495 tport.c:651 tport_alloc_primary() tport_alloc_primary(0xaaaac9c14600): new primary tport 0xaaaac9c00780
2023-11-17 15:52:40.416519 tport.c:780 tport_listen() tport_listen(0xaaaac9c00780): listening at tcp/172.18.0.7:9997
2023-11-17 15:52:40.416643 nta.c:2355 nta_agent_add_tport() nta: bound to (13.42.100.65:9997;transport=*;maddr=172.18.0.7)
2023-11-17 15:52:40.416671 nta.c:2497 agent_init_via() nta: agent_init_via: SIP/2.0/udp 13.42.100.65:9997 (*)
2023-11-17 15:52:40.416686 nta.c:2497 agent_init_via() nta: agent_init_via: SIP/2.0/tcp 13.42.100.65:9997 (*)
2023-11-17 15:52:40.416742 nta.c:2369 nta_agent_add_tport() nta: Via fields initialized
2023-11-17 15:52:40.416874 nta.c:2377 nta_agent_add_tport() nta: Contact header created
2023-11-17 15:52:40.416894 nta.c:986 nta_agent_create() nta_agent_create: initialized transports
2023-11-17 15:52:40.416901 nta.c:992 nta_agent_create() nta_agent_create: initialized random identifiers
2023-11-17 15:52:40.416957 nta.c:998 nta_agent_create() nta_agent_create: initialized timer
2023-11-17 15:52:40.417048 nta.c:1008 nta_agent_create() nta_agent_create: initialized resolver
2023-11-17 15:52:40.417528 SipTransport::addTransports - creating transport: 0xaaaac9c00500: udp/172.18.0.7:9997
2023-11-17 15:52:40.418015 SipTransport::addTransports - creating transport: 0xaaaac9c00780: tcp/172.18.0.7:9997
2023-11-17 15:52:40.418470 DrachtioController::run: adding additional internal sip address sips:172.18.0.7:443;transport=wss (external address: 13.42.100.65)
2023-11-17 15:52:40.418488 SipTransport::getBindableContactUri: sips:13.42.100.65:443;transport=wss;maddr=172.18.0.7
2023-11-17 15:52:40.418555 tport.c:1667 tport_bind_server() tport_bind_server(0xaaaac9c14600) to wss/172.18.0.7:443
2023-11-17 15:52:40.418580 tport.c:1738 tport_bind_server() tport_bind_server(0xaaaac9c14600): calling tport_listen for wss
2023-11-17 15:52:40.418625 tport.c:651 tport_alloc_primary() tport_alloc_primary(0xaaaac9c14600): new primary tport 0xaaaac9c00a00
2023-11-17 15:52:40.438697 tport.c:780 tport_listen() tport_listen(0xaaaac9c00a00): listening at wss/172.18.0.7:443
2023-11-17 15:52:40.438740 nta.c:2355 nta_agent_add_tport() nta: bound to (13.42.100.65:443;transport=wss;maddr=172.18.0.7)
2023-11-17 15:52:40.438751 nta.c:2497 agent_init_via() nta: agent_init_via: SIP/2.0/udp 13.42.100.65:9997 (*)
2023-11-17 15:52:40.438762 nta.c:2497 agent_init_via() nta: agent_init_via: SIP/2.0/tcp 13.42.100.65:9997 (*)
2023-11-17 15:52:40.438770 nta.c:2497 agent_init_via() nta: agent_init_via: SIP/2.0/wss 13.42.100.65:443 (*)
2023-11-17 15:52:40.438799 nta.c:2369 nta_agent_add_tport() nta: Via fields initialized
2023-11-17 15:52:40.438812 nta.c:2377 nta_agent_add_tport() nta: Contact header created
2023-11-17 15:52:40.439313 SipTransport::addTransports - creating transport: 0xaaaac9c00a00: wss/172.18.0.7:443
2023-11-17 15:52:40.439760 DrachtioController::run: adding additional internal sip address sips:172.18.0.7:9998;transport=tls (external address: 13.42.100.65)
2023-11-17 15:52:40.439772 SipTransport::getBindableContactUri: sips:13.42.100.65:9998;transport=tls;maddr=172.18.0.7
2023-11-17 15:52:40.439786 tport.c:1667 tport_bind_server() tport_bind_server(0xaaaac9c14600) to tls/172.18.0.7:9998
2023-11-17 15:52:40.439797 tport.c:1738 tport_bind_server() tport_bind_server(0xaaaac9c14600): calling tport_listen for tls
2023-11-17 15:52:40.439810 tport.c:651 tport_alloc_primary() tport_alloc_primary(0xaaaac9c14600): new primary tport 0xaaaac9c00c80
2023-11-17 15:52:40.439824 tport_type_tls.c:223 tport_tls_init_master() tport_tls_init_master(0xaaaac9c00c80): tls key file = /etc/letsencrypt/live/babblevoice.com/privkey.pem
2023-11-17 15:52:40.439862 tport_type_tls.c:234 tport_tls_init_master() tport_tls_init_master(0xaaaac9c00c80): tls cert file = /etc/letsencrypt/live/babblevoice.com/cert.pem
2023-11-17 15:52:40.439878 tport_type_tls.c:244 tport_tls_init_master() tport_tls_init_master(0xaaaac9c00c80): tls chain file = /etc/letsencrypt/live/babblevoice.com/fullchain.pem
2023-11-17 15:52:40.439889 tport_type_tls.c:252 tport_tls_init_master() tport_tls_init_master(0xaaaac9c00c80): tls_policy: 0, tls_verify: 0
2023-11-17 15:52:40.439901 tport_type_tls.c:253 tport_tls_init_master() tport_tls_init_master(0xaaaac9c00c80): tls_version: 16, tls_timeout: 300
2023-11-17 15:52:40.443781 tport_tls.c:429 tls_init_context() tls_init_context: tls->verify_incoming: 0
2023-11-17 15:52:40.443815 tport_tls.c:440 tls_init_context() tls: initialized ECDH
2023-11-17 15:52:40.444885 tport_type_tls.c:273 tport_tls_init_master() tport_tls_init_master(0xaaaac9c00c80): tls context initialized for [172.18.0.7]:9998
2023-11-17 15:52:40.444940 tport.c:780 tport_listen() tport_listen(0xaaaac9c00c80): listening at tls/172.18.0.7:9998
2023-11-17 15:52:40.444958 nta.c:2355 nta_agent_add_tport() nta: bound to (13.42.100.65:9998;transport=tls;maddr=172.18.0.7)
2023-11-17 15:52:40.444967 nta.c:2497 agent_init_via() nta: agent_init_via: SIP/2.0/udp 13.42.100.65:9997 (*)
2023-11-17 15:52:40.444982 nta.c:2497 agent_init_via() nta: agent_init_via: SIP/2.0/tcp 13.42.100.65:9997 (*)
2023-11-17 15:52:40.444990 nta.c:2497 agent_init_via() nta: agent_init_via: SIP/2.0/wss 13.42.100.65:443 (*)
2023-11-17 15:52:40.445003 nta.c:2497 agent_init_via() nta: agent_init_via: SIP/2.0/tls 13.42.100.65:9998 (*)
2023-11-17 15:52:40.445022 nta.c:2369 nta_agent_add_tport() nta: Via fields initialized
2023-11-17 15:52:40.445033 nta.c:2377 nta_agent_add_tport() nta: Contact header created
2023-11-17 15:52:40.445471 SipTransport::addTransports - creating transport: 0xaaaac9c00c80: tls/172.18.0.7:9998
2023-11-17 15:52:40.445918 SipTransport::logTransports - there are : 4 transports
2023-11-17 15:52:40.445931 SipTransport::logTransports - tls/172.18.0.7:9998 (sips:172.18.0.7:9998;transport=tls, external-ip: 13.42.100.65, local-net: )
2023-11-17 15:52:40.445937 SipTransport::logTransports - wss/172.18.0.7:443 (sips:172.18.0.7:443;transport=wss, external-ip: 13.42.100.65, local-net: )
2023-11-17 15:52:40.445942 SipTransport::logTransports - tcp/172.18.0.7:9997 (sip:172.18.0.7:9997;transport=udp,tcp, external-ip: 13.42.100.65, local-net: )
2023-11-17 15:52:40.445956 SipTransport::logTransports - udp/172.18.0.7:9997 (sip:172.18.0.7:9997;transport=udp,tcp, external-ip: 13.42.100.65, local-net: ), mtu size: 1300
2023-11-17 15:52:40.445982 DrachtioController::run - sip timers: T1: 500ms, T2: 4000ms, T4: 5000ms, T1X64: 32000ms
2023-11-17 15:52:40.446014 Starting sofia event loop in main thread: 281473410383936
2023-11-17 15:52:40.716785 tport.c:2818 tport_wakeup_pri() tport_wakeup_pri(0xaaaac9c00500): events IN
2023-11-17 15:52:40.716833 tport.c:2949 tport_recv_event() tport_recv_event(0xaaaac9c00500)
2023-11-17 15:52:40.716865 tport.c:3290 tport_recv_iovec() tport_recv_iovec(0xaaaac9c00500) msg 0xaaaac9cbc000 from (udp/172.18.0.7:9997) has 881 bytes, veclen = 1

When we create the new dialog - this is the output from Drachtio

2023-11-17 16:05:13.954150 tport.c:2363 tport_set_secondary_timer() tport(0xaaaac9c0b200): reset timer
2023-11-17 16:05:13.954160 ClientController::selectClientForRequestOutsideDialog - there are 1 possible clients, we are starting with offset 0
2023-11-17 16:05:13.954299 ClientController::route_request_outside_dialog - Selected client at offset 0
2023-11-17 16:05:13.954337 tport.c:1181 tport_ref() tport_ref(0xaaaac9c0b200): refcount is now 3
2023-11-17 16:05:13.954371 tport.c:1194 tport_unref() tport_unref(0xaaaac9c0b200): refcount is now 2
2023-11-17 16:05:13.954413 tport.c:1181 tport_ref() tport_ref(0xaaaac9c0b200): refcount is now 3
2023-11-17 16:05:13.954454 PendingRequestController::add - tport: 0xaaaac9c0b200, Call-ID: 2455df3e6fd42d124c22cb245353439c, transactionId 8dee5f0c-5eae-451a-a936-2a89e7b2520e
2023-11-17 16:05:13.954489 pending-request: Adding entry to go off in 64000ms
2023-11-17 16:05:13.954520 pending-request: Adding entry to the head (queue was empty), length: 1
2023-11-17 16:05:13.954567 tport.c:1181 tport_ref() tport_ref(0xaaaac9c0b200): refcount is now 4
2023-11-17 16:05:13.954602 tport.c:1194 tport_unref() tport_unref(0xaaaac9c0b200): refcount is now 3
2023-11-17 16:05:13.954642 ClientController::addNetTransaction: transactionId 8dee5f0c-5eae-451a-a936-2a89e7b2520e; size: 1
2023-11-17 16:05:13.954753 Client::write_handler - wrote 1690 bytes: system:0
2023-11-17 16:05:13.956700 No connected clients found to handle incoming cdr:attempt request
2023-11-17 16:05:13.956727 tport.c:1194 tport_unref() tport_unref(0xaaaac9c0b200): refcount is now 2
2023-11-17 16:05:13.956742 tport.c:2363 tport_set_secondary_timer() tport(0xaaaac9c0b200): reset timer
2023-11-17 16:05:13.966482 Client::read_handler read: a54b6afe-ec1c-464a-9f13-3efa7c922ebd|sip||
INVITE sip:1006@82.19.206.102:42582;transport=tcp SIP/2.0
Max-Forwards: 69
Remote-Party-ID: "Dr Theresa" <sip:1001@bling.babblevoice.com>
From: "Dr Theresa" <sip:1001@bling.babblevoice.com>
Allow-Events: talk, hold, presence, as-feature-event, dialog, call-info, sla, include-session-description, message-summary, refer
Allow: INVITE, ACK, BYE, CANCEL, OPTIONS, MESSAGE, INFO, UPDATE, REGISTER, REFER, NOTIFY, PUBLISH, SUBSCRIBE
Supported: timer, path, replaces
Content-Length: 293

v=0
o=- 346 0 IN IP4 127.0.0.1
s=project
c=IN IP4 18.132.9.82
t=0 0
m=audio 10004 RTP/AVP 9 0 8 97 101
a=rtpmap:9 G722/8000
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:97 ilbc/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:97 mode=20
a=fmtp:101 0-16
a=ptime:20
a=sendrecv

2023-11-17 16:05:13.966524 Client::processMessage - got request with 4 tokens
2023-11-17 16:05:13.966534 Client::processMessage - request id a54b6afe-ec1c-464a-9f13-3efa7c922ebd, request type: sip transaction id: , dialog id: 
2023-11-17 16:05:13.966548 Client::processMessage - sending a request outside of a dialog
2023-11-17 16:05:13.966561 ClientController::addAppTransaction: transactionId c5121980-e1cd-49e9-9337-7447982c7976; size: 1
2023-11-17 16:05:13.966567 ClientController::addApiRequest: clientMsgId a54b6afe-ec1c-464a-9f13-3efa7c922ebd; size: 1
2023-11-17 16:05:13.966620 DrachtioController::findTportForSubscription: found transport for 1006@82.19.206.102
2023-11-17 16:05:13.966634 SipDialogController::doSendRequestOutsideDialog selecting existing secondary transport 0xaaaac9c0b800
2023-11-17 16:05:13.966642 SipDialogController::doSendRequestOutsideDialog - selected transport 0xaaaac9c0b800: tcp/82.19.206.102:42582 for request-uri sip:1006@82.19.206.102:42582;transport=tcp
2023-11-17 16:05:13.966719 makeTags - Adding well-known header 'Max-Forwards' with value '69'
2023-11-17 16:05:13.966730 makeTags - Adding well-known header 'Remote-Party-ID' with value '"Dr Theresa" <sip:1001@bling.babblevoice.com>'
2023-11-17 16:05:13.966736 makeTags - Adding well-known header 'From' with value '"Dr Theresa" <sip:1001@bling.babblevoice.com>'
2023-11-17 16:05:13.966742 makeTags - Adding well-known header 'Allow-Events' with value 'talk, hold, presence, as-feature-event, dialog, call-info, sla, include-session-description, message-summary, refer'
2023-11-17 16:05:13.966748 makeTags - Adding well-known header 'Allow' with value 'INVITE, ACK, BYE, CANCEL, OPTIONS, MESSAGE, INFO, UPDATE, REGISTER, REFER, NOTIFY, PUBLISH, SUBSCRIBE'
2023-11-17 16:05:13.966755 makeTags - Adding well-known header 'Supported' with value 'timer, path, replaces'
2023-11-17 16:05:13.966761 SipDialogController::doSendRequestOutsideDialog - from: "Dr Theresa" <sip:1001@bling.babblevoice.com>
2023-11-17 16:05:13.966766 SipDialogController::doSendRequestOutsideDialog - to: sip:1006@82.19.206.102:42582;transport=tcp
2023-11-17 16:05:13.966770 SipDialogController::doSendRequestOutsideDialog - contact: <sip:172.18.0.7:9997;transport=tcp>
2023-11-17 16:05:13.966775 SipDialogController::doSendRequestOutsideDialog - automatically detecting content-type as application/sdp
2023-11-17 16:05:13.966784 isLocalSipUri: checking to see if this is one of mine: sip:1006@82.19.206.102:42582;transport=tcp
2023-11-17 16:05:13.966811 nta.c:4604 nta_leg_tcreate() nta_leg_tcreate(0xaaaac9df7200)
2023-11-17 16:05:13.966858 tport.c:1181 tport_ref() tport_ref(0xaaaac9c0b800): refcount is now 2
2023-11-17 16:05:13.966869 tport.c:3343 tport_tsend() tport_tsend(0xaaaac9c0b800) tpn = tcp/82.19.206.102:42582
2023-11-17 16:05:13.966925 tport.c:3592 tport_send_msg() tport_vsend returned 1064
2023-11-17 16:05:13.966980 send 1064 bytes to tcp/[82.19.206.102]:42582 at 16:05:13.966887:
INVITE sip:1006@82.19.206.102:42582;transport=tcp SIP/2.0
Via: SIP/2.0/TCP 13.42.100.65:9997;branch=z9hG4bKZSecr5yBv7e6K
Max-Forwards: 69
From: "Dr Theresa" <sip:1001@bling.babblevoice.com>;tag=rtm8KjFXHXjDQ
To: <sip:1006@82.19.206.102:42582>;transport=tcp
Call-ID: eefe0847-0005-123d-439a-0242c0a80b8d
CSeq: 75564764 INVITE
Contact: <sip:172.18.0.7:9997;transport=tcp>
Allow: INVITE, ACK, BYE, CANCEL, OPTIONS, MESSAGE, INFO, UPDATE, REGISTER, REFER, NOTIFY, PUBLISH, SUBSCRIBE
Supported: timer, path, replaces
Allow-Events: talk, hold, presence, as-feature-event, dialog, call-info, sla, include-session-description, message-summary, refer
Content-Type: application/sdp
Content-Length: 293
Remote-Party-ID: "Dr Theresa" <sip:1001@bling.babblevoice.com>

v=0
o=- 346 0 IN IP4 127.0.0.1
s=project
c=IN IP4 18.132.9.82
t=0 0
m=audio 10004 RTP/AVP 9 0 8 97 101
a=rtpmap:9 G722/8000
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:97 ilbc/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:97 mode=20
a=fmtp:101 0-16
a=ptime:20
a=sendrecv 
2023-11-17 16:05:13.966993 tport.c:2363 tport_set_secondary_timer() tport(0xaaaac9c0b800): reset timer
2023-11-17 16:05:13.967001 nta.c:8519 outgoing_send() nta: sent INVITE (75564764) to tcp/82.19.206.102:42582
2023-11-17 16:05:13.967007 tport.c:4257 tport_pend() tport_pend(0xaaaac9c0b800): pending 0xaaaac9e7b400 for tcp/82.19.206.102:42582 (already 0)
2023-11-17 16:05:13.967013 SipDialogController::doSendRequestOutsideDialog - created orq 0xaaaac9cb51e0 call-id eefe0847-0005-123d-439a-0242c0a80b8d / transaction id: c5121980-e1cd-49e9-9337-7447982c7976
2023-11-17 16:05:13.967026 tport.c:1181 tport_ref() tport_ref(0xaaaac9c0b800): refcount is now 3
2023-11-17 16:05:13.967034 SipDialog::SipDialog - creating dialog for outbound INVITE sent from tcp/82.19.206.102:42582 to 82.19.206.102:42582
2023-11-17 16:05:13.967040 SipDialogController::addOutgoingInviteTransaction:  adding leg 0xaaaac9df7200
2023-11-17 16:05:13.967045 adding IIP outbound tid:c5121980-e1cd-49e9-9337-7447982c7976 alive:0s leg:0xaaaac9df7200 irq:0 orq:0xaaaac9cb51e0 rel:0
2023-11-17 16:05:13.967051 IIP_Insert outgoing - ref count: 1 inserting outbound tid:c5121980-e1cd-49e9-9337-7447982c7976 alive:0s leg:0xaaaac9df7200 irq:0 orq:0xaaaac9cb51e0 rel:0
2023-11-17 16:05:13.967063 No connected clients found to handle incoming cdr:attempt request
2023-11-17 16:05:13.967071 tport.c:1181 tport_ref() tport_ref(0xaaaac9c0b800): refcount is now 4
2023-11-17 16:05:13.967078 tport.c:1194 tport_unref() tport_unref(0xaaaac9c0b800): refcount is now 3
2023-11-17 16:05:13.967086 ClientController::removeApiRequest: clientMsgId a54b6afe-ec1c-464a-9f13-3efa7c922ebd; size: 0
2023-11-17 16:05:13.967140 Client::write_handler - wrote 1261 bytes: system:0
2023-11-17 16:05:14.137285 tport.c:2845 tport_wakeup() tport_wakeup(0xaaaac9c0b800): events IN
2023-11-17 16:05:14.137337 tport.c:2949 tport_recv_event() tport_recv_event(0xaaaac9c0b800)
2023-11-17 16:05:14.137355 tport.c:3290 tport_recv_iovec() tport_recv_iovec(0xaaaac9c0b800) msg 0xaaaac9df1c00 from (tcp/82.19.206.102:42582) has 455 bytes, veclen = 1
2023-11-17 16:05:14.137427 recv 455 bytes from tcp/[82.19.206.102]:42582 at 16:05:14.137370:
SIP/2.0 100 Trying
Via: SIP/2.0/TCP 13.42.100.65:9997;branch=z9hG4bKZSecr5yBv7e6K
From: "Dr Theresa" <sip:1001@bling.babblevoice.com>;tag=rtm8KjFXHXjDQ
To: "Nick Knight" <sip:1006@82.19.206.102:42582>;transport=tcp;tag=29A2E0CE-D6110CDF
CSeq: 75564764 INVITE
Call-ID: eefe0847-0005-123d-439a-0242c0a80b8d
Contact: <sip:1006@82.19.206.102:55486;transport=tcp>
User-Agent: PolyEdge-Edge_E350-UA/8.0.0.15602
Accept-Language: en
Content-Length: 0
byoungdale commented 8 months ago

If you want the contact to masquerade as the external ip, then I believe you need to do --contact sip:13.42.100.65:9997;transport=udp,tcp.

spointer commented 6 months ago

I think @tinpotnick sets a proper argument(--external-ip to 13.42.100.65). If drachtio is set external-ip, i think drachtio is intended to replace the host part of well-known headers to that external-ip.

I found drachtio does not replace the host part of a contact header to the external ip inside the doRespondToSipRequest function.

// external ip is not set when calling makeTags function. tags = makeTags( headers, transportDesc ) ;

My issue is similar to @tinpotnick and here is the log i found.

2024-01-24 11:32:19.017153 Client::processMessage - got request with 4 tokens 2024-01-24 11:32:19.017166 Client::processMessage - request id bafe06b3-e132-4fbd-9111-e0ba6d5cfb74, request type: sip transaction id: 3e13bfcd-493a-4868-a143-a7e46bab0247, dialog id: 2024-01-24 11:32:19.017178 ClientController::addApiRequest: clientMsgId bafe06b3-e132-4fbd-9111-e0ba6d5cfb74; size: 1 2024-01-24 11:32:19.017226 SipDialogController::doRespondToSipRequest thread 140192544079552 2024-01-24 11:32:19.017264 SipDialogController::findAndRemoveTransactionIdForIncomingRequest - searching transactionId 3e13bfcd-493a-4868-a143-a7e46bab0247 2024-01-24 11:32:19.017276 SipDialogController::findAndRemoveTransactionIdForIncomingRequest - failed to find transactionId 3e13bfcd-493a-4868-a143-a7e46bab0247, most likely this is a response to an invite we sent 2024-01-24 11:32:19.017304 pending-request: removing entry, prior to removal length: 1 2024-01-24 11:32:19.017324 pending-request: removed entry, timer not set (queue is empty after removal), length: 0 2024-01-24 11:32:19.017347 nta.c:1428 set_timeout() nta: timer shortened to 200 ms 2024-01-24 11:32:19.017366 tport.c:1181 tport_ref() tport_ref(0x55f7b1dda500): refcount is now 5 2024-01-24 11:32:19.017403 nta.c:4604 nta_leg_tcreate() nta_leg_tcreate(0x55f7b1e06780) 2024-01-24 11:32:19.017422 DrachtioController::setupLegForIncomingRequest - created leg: 0x55f7b1e06780, irq: 0x55f7b1dfc8c0, for transactionId: 3e13bfcd-493a-4868-a143-a7e46bab0247, tag: 2024-01-24 11:32:19.017443 tport.c:1181 tport_ref() tport_ref(0x55f7b1dda500): refcount is now 6 2024-01-24 11:32:19.017458 SipDialog::SipDialog - (UAS) detected client behind nat, using 10.178.104.101:28504 as route for requests within this dialog 2024-01-24 11:32:19.017480 SipDialog::SipDialog - creating dialog for inbound INVITE sent from UDP/172.16.177.234:3417 2024-01-24 11:32:19.017502 adding IIP inbound tid:3e13bfcd-493a-4868-a143-a7e46bab0247 alive:0s leg:0x55f7b1e06780 irq:0x55f7b1dfc8c0 orq:0 rel:0 2024-01-24 11:32:19.017527 IIP_Insert incoming - ref count: 1 inserting inbound tid:3e13bfcd-493a-4868-a143-a7e46bab0247 alive:0s leg:0x55f7b1e06780 irq:0x55f7b1dfc8c0 orq:0 rel:0 2024-01-24 11:32:19.017546 tport.c:1194 tport_unref() tport_unref(0x55f7b1dda500): refcount is now 5 2024-01-24 11:32:19.017565 SipDialogController::doRespondToSipRequest found invite or subscribe in progress 0x55f7b1dde9a0 2024-01-24 11:32:19.017582 tport.c:1181 tport_ref() tport_ref(0x55f7b1dda500): refcount is now 6 2024-01-24 11:32:19.017601 SipTransport::getContactUri - created Contact header: sip:10.3.15.184:3417 2024-01-24 11:32:19.017625 tport.c:1194 tport_unref() tport_unref(0x55f7b1dda500): refcount is now 5 2024-01-24 11:32:19.017711 makeTags - Adding well-known header 'Call-ID' with value '008B4552-9279-1368-B6B9-B368B20AAA77-332971@10.178.104.101' 2024-01-24 11:32:19.017739 makeTags - Adding well-known header 'cseq' with value '1 INVITE' 2024-01-24 11:32:19.017759 makeTags - Adding well-known header 'from' with value 'sip:1111@test.com;user=phone;tag=008B4570-9279-1368-B6B9-B368B20AAA77-433212' 2024-01-24 11:32:19.017778 makeTags - Adding well-known header 'to' with value 'sip:1111205@10.178.104.101:5060' 2024-01-24 11:32:19.017797 makeTags - hdr 'contact' replacing host with 172.16.177.234 2024-01-24 11:32:19.017815 makeTags - Adding well-known header 'contact' with value 'sip:2412@172.16.177.234:3417' 2024-01-24 11:32:19.017853 SipDialogController::doRespondToSipRequest - client provided contact header so we wont include our internally-generated one 2024-01-24 11:32:19.017871 SipDialogController::doRespondToSipRequest - UAC is refresher, interval will be 180 2024-01-24 11:32:19.017884 SipDialog::setSessionTimer: 008B4552-9279-1368-B6B9-B368B20AAA77-332971@10.178.104.101 Session expires has been set to 180 seconds and refresher is them