I don’t think this is a bug. The channel variable custom
is used by FreePBX dialplan to identify trunks of type custom. The fact that it is populated with the peer name of chan_sip trunks is a byproduct not its intent.
There is a supportable way to determine the trunk name without relying on custom
:
- Determine value of channel var DIAL_TRUNK, it will be an integer
- Determine value of global var OUT_${DIAL_TRUNK} this will be the trunk
tech/name
if SIP or IAX but will only be thetech
if PJSIP. - If value from 2 == “PJSIP” then the trunk name will be in global variable
OUT_${DIAL_TRUNK}_SUFFIX
in the format@trunkname
Distilling the above:
exten => s,n,ExecIF($["${OUT_${DIAL_TRUNK}_SUFFIX}"!=""]?Set(trunk_name=${OUT_${DIAL_TRUNK}_SUFFIX}):Set(trunk_name=${OUT_${DIAL_TRUNK}}))
exten => s,n,Noop(trunk name: ${trunk_name})