noxxi / p5-net-sip

Net::SIP Perl Module
Other
15 stars 22 forks source link

Allow Leg.pm Contact header to be set to a callback or a string #20

Closed mfalkus closed 5 years ago

mfalkus commented 6 years ago

This PR primarily updates Net::SIP::Leg to allow $leg->{contact} to be set to either a string, as per current behavior, or a callback. The callback receives two arguments which are the leg itself plus the current packet that is being processed.

Existing code that relies on being able to reach in and get/set $leg->{contact} as a string will continue to work as before. New code that needs advanced contact header functionality can instead set this to a function and hook in to dynamically set the contact header value.

The reasoning for this change is integrating with an external PBX that requires the Contact header must use a subdomain of the domain used in the From header. The same PBX also enforces port 5061. This change allows multiple domains to use a single Leg in this situation, rather than requiring an IP per domain.

noxxi commented 6 years ago

I'm not really comfortable with this change since it looks like a hack for me. But I also don't think that I've really understood the use case where you need this behavior for.
Could you please explain the use case in more detail, ideally with example SIP messages and how your idea gets used to fix the problems you have in the use case? Maybe this helps me to either get more comfortable with your idea or to find a different way to solve your problem.

noxxi commented 5 years ago

closed for now because of no feedback