From 8cdc8ae7b5b120be093b3f1d69282f5808e1210a Mon Sep 17 00:00:00 2001 From: Pedro Amorim Date: Thu, 20 Nov 2025 15:54:44 +0000 Subject: [PATCH] Bug 41271: Fix pod_coverage for SIPServer.pm Because the file is now being properly checked for pod_coverage, it fails (because a lot of methods dont have pod coverage. Add here --- C4/SIP/SIPServer.pm | 92 +++++++++++++++++++++++++++++++++++++-------- 1 file changed, 76 insertions(+), 16 deletions(-) diff --git a/C4/SIP/SIPServer.pm b/C4/SIP/SIPServer.pm index 4cccd670af9..cd407fda738 100644 --- a/C4/SIP/SIPServer.pm +++ b/C4/SIP/SIPServer.pm @@ -243,8 +243,12 @@ sub _config_up_to_date { # Child # -# process_request is the callback used by Net::Server to handle -# an incoming connection request. +=head2 process_request + +process_request is the callback used by Net::Server to handle +an incoming connection request. + +=cut sub process_request { my $self = shift; @@ -304,6 +308,15 @@ sub process_request { # Transports # +=head2 raw_transport + +Manages the SIP login process for raw TCP connections. Clears any +previous session state, applies a timeout, reads the initial request, +and authenticates it. On success, sets up logging context and enters +the SIP protocol loop. Returns on EOF, timeout, or failed login. + +=cut + sub raw_transport { my $self = shift; my $input; @@ -365,6 +378,15 @@ sub raw_transport { return; } +=head2 get_clean_string + +Cleans a string by removing leading and trailing non-alphanumeric +characters. Logs the string before and after cleaning, or notes if +the input was undefined. Returns the cleaned string (or undef if no +string was provided). + +=cut + sub get_clean_string { my $string = shift; if ( defined $string ) { @@ -379,6 +401,14 @@ sub get_clean_string { return $string; } +=head2 get_clean_input + +Reads a single line from STDIN, normalizes it using +C, and discards any additional input lines, logging +them as errors. Returns the cleaned input line. + +=cut + sub get_clean_input { local $/ = "\012"; my $in = ; @@ -389,6 +419,17 @@ sub get_clean_input { return $in; } +=head2 telnet_transport + +Handles the login process for terminals connecting via the telnet +transport. Prompts for a username and password, applies a timeout to +protect against hung connections, and validates the credentials against +configured accounts. On successful authentication, initializes the SIP +session by invoking C. Dies on timeout or repeated +failed login attempts. + +=cut + sub telnet_transport { my $self = shift; my ( $uid, $pwd ); @@ -452,11 +493,15 @@ sub telnet_transport { return; } -# -# The terminal has logged in, using either the SIP login process -# over a raw socket, or via the pseudo-unix login provided by the -# telnet transport. From that point on, both the raw and the telnet -# processes are the same: +=head2 sip_protocol_loop + +The terminal has logged in, using either the SIP login process +over a raw socket, or via the pseudo-unix login provided by the +telnet transport. From that point on, both the raw and the telnet +processes are the same: + +=cut + sub sip_protocol_loop { my $self = shift; my $service = $self->{service}; @@ -514,6 +559,16 @@ sub sip_protocol_loop { return; } +=head2 read_request + +Reads a single SIP request line from STDIN using carriage return as the +record separator. Strips leading and trailing non-alphanumeric +characters, removes extra line breaks, and logs any trimming that +occurs. Also flushes Level-1 caches before processing each request. +Returns the cleaned request string, or undef on EOF. + +=cut + sub read_request { my $raw_length; local $/ = "\015"; @@ -552,15 +607,20 @@ sub read_request { return $buffer; } -# $server->get_timeout({ $type => 1, fallback => $fallback }); -# where $type is transport | client | policy -# -# Centralizes all timeout logic. -# Transport refers to login process, client to active connections. -# Policy timeout is transaction timeout (used in ACS status message). -# -# Fallback is optional. If you do not pass transport, client or policy, -# you will get fallback or hardcoded default. +=head2 get_timeout + + $server->get_timeout({ $type => 1, fallback => $fallback }); + +where $type is transport | client | policy + +Centralizes all timeout logic. +Transport refers to login process, client to active connections. +Policy timeout is transaction timeout (used in ACS status message). + +Fallback is optional. If you do not pass transport, client or policy, +you will get fallback or hardcoded default. + +=cut sub get_timeout { my ( $server, $params ) = @_; -- 2.39.5