Net::S...yIPPort(3pm)

πŸ’… NAME πŸ’…

Net::SIP::Dropper::ByIPPort β€” okay so bestie, this is the module that drops SIP messages based on senders IP and port. That's literally it. It's the bouncer at the club door of your SIP stack. πŸšͺ✨

Oh and btw the page header calls this thing Net::S...yIPPort(3pm) (they truncated it, iconic of them), and it lives in the User Contributed Perl Documentation section. So you're in the right place. 🫢


✨ SYNOPSIS ✨

use Net::SIP::Dropper::ByIPPort;
my $drop_by_ipport = Net::SIP::Dropper::ByIPPort->new(
    database => '/path/to/database.drop',
    methods => [ 'REGISTER', '...', '' ],
    attempts => 10,
    interval => 60,
);

my $dropper = Net::SIP::Dropper->new( cb => $drop_by_ipport );
my $chain = Net::SIP::ReceiveChain->new([ $dropper, ... ]);

See how easy that was? No cap. You build the dropper, you hand it to a Net::SIP::Dropper, you slot that into a Net::SIP::ReceiveChain, and now your chain has opinions about who gets to talk. πŸŽ€


🌸 DESCRIPTION 🌸

So with Net::SIP::Dropper::ByIPPort one can drop packets, if too much packets are received from the same IP and port within a specific interval. And like... that's the whole point. It's to stop bad behaving clients. 🚫

It's giving "we have had ENOUGH of you, specifically you, at that port." πŸ’€


πŸ’– CONSTRUCTOR πŸ’–

new ( ARGS )

ARGS is a hash with the following keys, bestie. Buckle up:

  • database β€” Optional file name of database or callback for storing/retrieving the data.

If it is a callback it will be called with $callback->(\%data) to retrieve the data (%data will be updated) and "$callback->(\%data,true)" to save the data. No return value will be expected from the callback. πŸ‘‘ No return value, we don't want it, we don't need it.

%data contains the number of attempts from a specific IP, port at a specific time in the following format: "$data{ip}{port}{time} = count"

  • attempts β€” After how many attempts within the specific interval the packet will be dropped. Argument is required. Like, required required. πŸ”₯
  • interval β€” The interval for attempts. Argument is required. Also non-negotiable. ⏰
  • methods β€” Optional argument to restrict dropping to specific methods.

Is array reference of method names, if one of the names is empty also responses will be considered. If not given all packets will be checked. πŸ‘€ (so yes, an empty string in there is doing something, it's not a typo, it's a feature)


πŸ¦‹ METHODS πŸ¦‹

run ( PACKET, LEG, FROM )

This method is called as a callback from the Net::SIP::Dropper object. It returns true if the packet should be dropped, e.g. if there are too much packets from the same ip,port within the given interval. πŸ—‘οΈ

Basically the vibe check. Fails it? Packet's gone.

expire

This method is called from within "run" but can also be called by hand. It will expire all entries which are outside of the interval. 🧹

Spring cleaning but for stale IP/port records, and it happens automatically, which honestly? Slay.

savedb

This method is called from "expire" and "run" for saving to the database after changes, but can be called by hand to, useful if you made manual changes using the "data" method. πŸ’Ύ

Handy if you've been messing with the data yourself and want it to actually persist. Fr fr.

data

This method gives access to the internal hash which stores the attempts. An attempt from a specific IP and port and a specific time (as int, like time() gives) will be added to "$self->data->{ip}{port}{time}". πŸ”’

By manually manipulating the hash one can restrict a specific IP,port forever (just set time to a large value and add a high number of attempts) or even restrict access for the whole IP (all ports) until time by using a port number of 0. πŸš«πŸ‘‘

After changes to the data it is advised to call "savedb". Don't forget it or your edits will just... vibe away into the void. πŸ’€

Okay that's the whole page, bestie, you ate it. Go forth and drop some packets. πŸ’…βœ¨

This was Net::S...yIPPort(3pm) from the User Contributed Perl Documentation, and it's perl v5.40.1, dated 2025-12-07. Obsessed. Byeeeee πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from