Subject: | Allow extending of StatelessProxy __forward_packet_final method |
Date: | Tue, 29 Aug 2017 13:34:44 +0000 |
To: | "bug-Net-SIP [...] rt.cpan.org" <bug-Net-SIP [...] rt.cpan.org> |
From: | Richard Carver <richard.carver [...] cloudmont.co.uk> |
Net::SIP::StatelessProxy doesn't call __forward_packet_final in a way that allows it to be overridden in an inherited class. The following patch makes this possible.
The reason I need this is that one side of my SIP proxy uses a URI which has multiple AAAA records for load balancing, and often my CANCEL requests are sent to a different IP address to the INVITE and are not recognised. In order to fix this I am caching the DNS results for the URI lookup on a per-call basis so that all requests for a call-id go to the same IP, but each new call does a fresh DNS lookup. To do this I have a class that inherits from Net::SIP::StatelessProxy. It overrides __forward_packet_final to cache the result and overrides __forward_request_getdaddr to use the cached value if needed.
--- /usr/local/share/perl5/Net/SIP/StatelessProxy.pm.orig 2017-08-29 11:52:38.207617148 +0000
+++ /usr/local/share/perl5/Net/SIP/StatelessProxy.pm 2017-08-29 11:53:58.815522681 +0000
@@ -339,7 +339,7 @@
ip_parts2string($entry->{dst_addr}[0]));
return;
}
- __forward_packet_final( $self,$entry );
+ $self->__forward_packet_final( $entry );
}
@@ -457,7 +457,7 @@
[ \&__forward_request_2,$self,$entry ]
);
} else {
- __forward_packet_final($self,$entry);
+ $self->__forward_packet_final($entry);
}
}
@@ -483,7 +483,7 @@
return unless @$dst_addr; # nothing could be resolved
- __forward_packet_final( $self,$entry );
+ $self->__forward_packet_final( $entry );
}