Net::SIP::Dropper::ByIPPort(3pm) | User Contributed Perl Documentation | Net::SIP::Dropper::ByIPPort(3pm) |
Net::SIP::Dropper::ByIPPort - drops SIP messages based on senders IP and port
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, ... ]);
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. This is to stop bad behaving clients.
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.
%data contains the number of attempts from a specific IP, port at a specific time in the following format: "$data{ip}{port}{time} = count"
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.
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".
2023-02-04 | perl v5.36.0 |