Get full contact uri by contact name

I use PJSIP stack for call with WebRTC. Everything is working well!
I decided to use only 1 sip public account with no outgoing calls. For example account is 808.
Many browsers (clients) has registered from this account at once, but has different contacts name.
The output of pjsip show aor 808 is:

      Aor:  <Aor..............................................>  <MaxContact>
    Contact:  <Aor/ContactUri............................> <Hash....> <Status> <RTT(ms)..>
==========================================================================================

      Aor:  808                                                999
    Contact:  808/sip:username1@someDynamicIpAndPort;transport=wss Avail        59.986
    Contact:  808/sip:username2@someDynamicIpAndPort;transport=wss Avail        74.212
    Contact:  808/sip:username3@someDynamicIpAndPort;transport=wss Avail        59.986
    Contact:  808/sip:username4@someDynamicIpAndPort;transport=wss Avail        74.212
    Contact:  808/sip:username5@someDynamicIpAndPort;transport=wss Avail        59.986
    Contact:  808/sip:username6@someDynamicIpAndPort;transport=wss Avail        74.212


 ParameterName        : ParameterValue
 =====================================================================
 authenticate_qualify : false
 contact              : sip:808/sip:username1@someDynamicIpAndPort;transport=wss
 contact              : sip:808/sip:username2@someDynamicIpAndPort;transport=wss
 contact              : sip:808/sip:username3@someDynamicIpAndPort;transport=wss
 contact              : sip:808/sip:username4@someDynamicIpAndPort;transport=wss
 contact              : sip:808/sip:username5@someDynamicIpAndPort;transport=wss
 contact              : sip:808/sip:username6@someDynamicIpAndPort;transport=wss
 default_expiration   : 3600
 mailboxes            : 
 max_contacts         : 999
 maximum_expiration   : 7200
 minimum_expiration   : 60
 outbound_proxy       : 
 qualify_frequency    : 60
 qualify_timeout      : 3.000000
 remove_existing      : false
 remove_unavailable   : false
 support_path         : false
 voicemail_extension  :

Now I have to programmatically call to username5 for example. I don’t know his full contact uri (sip:username@ip:port etc.). I just know his username (contact name before @ symbol in uri).

How I can do that easily from dialplan?

At this moment I’m using in dialplan PJSIP_DIAL_CONTACTS function, and then parsing his full uri by username5 with & symbol and only then call him like Dial(PJSIP/808/sip:username5@1.2.3.4:22317;transport=wss).

Is there any PJSIP function in dialplan to parse his full contact uri quickly only with username (with content before @ symbol)?

For example something like:
Dial({PJSIP_DIAL_CONTACTS(808,,username5)})

There isn’t something to do exactly that, because it’s not meant to be used that way generally. A single endpoint is for a single entity/user, but you’re using it differently. There may be primitives in the dialplan to allow easier parsing, but that’s about it.

Yep. :grinning_face_with_smiling_eyes:
Different way to prevent Asterisk pjsip programmatically accounts creating when user opens web page.
I decided to use 1 SIP account with closed outbound calls (also with no features codes etc.) but with different Contact headers and call them if needed.
Even if someone steal sip authname and password from WebRTC phone - he can’t do anything. Because 5060-5061 ports are closed in firewall (just 8089 is open for wss) and in the user context there is no outbound calls.
I think he just can spam my Asterisk, but it will easily be banned with fail2ban.