Net::S...sProxy(3pm)
π Net::SIP::StatelessProxy β the vibe
okay bestie, so this is Net::SIP::StatelessProxy, aka Simple implementation of a stateless proxy β¨ It's a Perl module, it lives in the User Contributed Perl Documentation part of your manual, and it is exactly what it says on the tin: a lil stateless SIP proxy that just... forwards stuff. No drama, no memory, no cap. π«Ά
πΈ SYNOPSIS πΈ
..
that's it. that's the synopsis. iconic behavior honestly. π
β¨ DESCRIPTION β¨
This package implements a simple stateless SIP proxy. The basic idea is that the proxy has either a single leg or two legs, and packets get exchanged between those legs β like, packets coming in on one leg get forwarded out through the other leg. Simple as. π¦
Because this is a stateless proxy, no retransmits will be done by the proxy. It does not remember anything. It is not keeping receipts. It forwards and moves on. periodt. π
If you want the proxy to work as a registrar too, it should be put after a Net::SIP::Registrar inside a Net::SIP::ReceiveChain. order matters, bestie.
While forwarding, the proxy will insert itself into the packet β meaning it adds Via and Record-Route headers while forwarding requests. main character energy, honestly. π
On top of that, it rewrites the Contact header while forwarding packets (more on that below). So if the Contact header points to some client, it rewrites it so it points to the proxy instead. And if it already points to the proxy, it rewrites it back so it points to the client again. it's giving β¨ reversible makeover β¨
π CONSTRUCTOR π
new ( %ARGS )β Creates a new stateless proxy. The%ARGSlet you influence the behavior, and here's every single knob:dispatcherβ TheNet::SIP::Dispatcherobject that manages the proxy. your manager, your bestie, your handler.rewrite_contactβ Callback used in rewritingContactheaders. If you putuser@hostin it, or if it's called withforce_rewrite, then it should rewrite it. And if you put in something without an'@', it should try to rewrite it back β or return()if it can't be rewritten back.
A working default implementation is provided, so you don't have to write this. But if you wanna implement your own: the callback gets the arguments contact, incoming_leg and outgoing_leg and force_rewrite.
For rewriting a contact of user@host, the legs will be Net::SIP::Leg objects. For rewriting the contact back, outgoing_leg can be either a leg object β and you should check if it's the expected leg β or it can be a scalar reference, which you should fill with the leg extracted from the contact.
The function should return the new contact, or nothing if there was nothing to rewrite or if the rewrite failed. π«
Note that some servers apply length limitations to the contact, so the function should not return too long values. keep it cute AND short, bestie.
rewrite_cryptβ If you want your own encryption for the rewritten contact, define a subroutine here. It gets"data"as the first parameter and"dir"as the second, and it should return the de/encrypted data. If"dir"is+1it should encrypt, and on-1it should decrypt. The optional third argument"add2mac"should be included in the calculation and verification of the MAC. The function should return the encrypted/decrypted data, orundefif decryption failed because the MAC did not match. π¨
If this is not defined, then RC4 will be used with a (pseudo)random key, a 4 byte (pseudo)random seed, and a 4 byte MAC (md5) over the seed and data. default slay. π₯
nathelperβ OptionalNet::SIP::NATHelper::*object. When you give it one, it'll be used to do NAT β like, if the incoming and outgoing legs are different, it will rewrite the SDP bodies to use local sockets, and the nathelper will transfer the RTP data between the local and the original sockets. π§force_rewriteβ Usually theContactheader will only be rewritten if the incoming and outgoing leg are different. With this option you can force the rewrite, even if they're the same. do it anyway, bestie. π
β METHODS β
receive ( PACKET, LEG, FROM )βPACKETis the incoming packet,LEGis theNet::SIP::Legwhere the packet arrived, andFROMis the"ip:port"of the sender.
Called from the dispatcher on incoming packets. The packet gets rewritten ("Via" and "Record-Route" headers added, Contact modified), and then the packet gets forwarded. bye bestie π
For requests, it can figure out the target of the forwarded packet by looking at the route β or if there's no route, it looks at the URI. For responses, it looks at the next Via header. iykyk. π¦
do_nat ( PACKET, INCOMING_LEG, OUTGOING_LEG )β This gets called fromreceivewhile forwarding data. Ifnathelperis defined, it'll be used to rewrite SDP bodies and update the nathelper's internal states so RTP data gets forwarded. π
Return values work like forward_outgoing in Net::SIP::Leg β meaning it returns "[code,text]" on error, or () on success. And "success" can mean either that the packet was rewritten, or that there was no need to touch it at all. either way, we're winning. π
π UNDOCUMENTED METHODS π
idside2hashβ no docs, no explanation, just vibes. we don't talk about it. π
and that's the whole page, bestie!! every flag, every arg, every callback, every byte accounted for. go forth and forward packets statelessly. π«Ά
this has been Net::S...sProxy(3pm) from the User Contributed Perl Documentation crew, running on perl v5.40.1, dated 2025-12-07. mwah. πβ¨π
π¦ where this page comes from
- ubuntu resolute: libnet-sip-perl 0.840-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libnet-sip-perl 0.840-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms