0x1949 Team - FAZEMRX - MANAGER
Edit File: Net::SIP::Dropper::ByIPPort.3pm
.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.42) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Net::SIP::Dropper::ByIPPort 3pm" .TH Net::SIP::Dropper::ByIPPort 3pm "2021-05-04" "perl v5.34.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Net::SIP::Dropper::ByIPPort \- drops SIP messages based on senders IP and port .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 7 \& use Net::SIP::Dropper::ByIPPort; \& my $drop_by_ipport = Net::SIP::Dropper::ByIPPort\->new( \& database => \*(Aq/path/to/database.drop\*(Aq, \& methods => [ \*(AqREGISTER\*(Aq, \*(Aq...\*(Aq, \*(Aq\*(Aq ], \& attempts => 10, \& interval => 60, \& ); \& \& my $dropper = Net::SIP::Dropper\->new( cb => $drop_by_ipport ); \& my $chain = Net::SIP::ReceiveChain\->new([ $dropper, ... ]); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" With \f(CW\*(C`Net::SIP::Dropper::ByIPPort\*(C'\fR one can drop packets, if too much packets are received from the same \s-1IP\s0 and port within a specific interval. This is to stop bad behaving clients. .SH "CONSTRUCTOR" .IX Header "CONSTRUCTOR" .IP "new ( \s-1ARGS\s0 )" 4 .IX Item "new ( ARGS )" \&\s-1ARGS\s0 is a hash with the following keys: .RS 4 .IP "database" 8 .IX Item "database" Optional file name of database or callback for storing/retrieving the data. .Sp If it is a callback it will be called with \f(CW\*(C`$callback\->(\e%data)\*(C'\fR to retrieve the data (\f(CW%data\fR will be updated) and \f(CW\*(C`$callback\->(\e%data,true)\*(C'\fR to save the data. No return value will be expected from the callback. .Sp \&\f(CW%data\fR contains the number of attempts from a specific \s-1IP,\s0 port at a specific time in the following format: \&\f(CW\*(C`$data{ip}{port}{time} = count\*(C'\fR .IP "attempts" 8 .IX Item "attempts" After how many attempts within the specific interval the packet will be dropped. Argument is required. .IP "interval" 8 .IX Item "interval" The interval for attempts. Argument is required. .IP "methods" 8 .IX Item "methods" Optional argument to restrict dropping to specific methods. .Sp 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. .RE .RS 4 .RE .SH "METHODS" .IX Header "METHODS" .IP "run ( \s-1PACKET, LEG, FROM\s0 )" 4 .IX Item "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. .IP "expire" 4 .IX Item "expire" This method is called from within \f(CW\*(C`run\*(C'\fR but can also be called by hand. It will expire all entries which are outside of the interval. .IP "savedb" 4 .IX Item "savedb" This method is called from \f(CW\*(C`expire\*(C'\fR and \f(CW\*(C`run\*(C'\fR for saving to the database after changes, but can be called by hand to, useful if you made manual changes using the \f(CW\*(C`data\*(C'\fR method. .IP "data" 4 .IX Item "data" This method gives access to the internal hash which stores the attempts. An attempt from a specific \s-1IP\s0 and port and a specific time (as int, like \fBtime()\fR gives) will be added to \f(CW\*(C`$self\->data\->{ip}{port}{time}\*(C'\fR. .Sp By manually manipulating the hash one can restrict a specific \s-1IP\s0,port forever (just set time to a large value and add a high number of attempts) or even restrict access for the whole \s-1IP\s0 (all ports) until time by using a port number of 0. .Sp After changes to the data it is advised to call \f(CW\*(C`savedb\*(C'\fR.