View | Details | Raw Unified | Return to bug 41271
Collapse All | Expand All

(-)a/C4/SIP/SIPServer.pm (-17 / +76 lines)
Lines 243-250 sub _config_up_to_date { Link Here
243
# Child
243
# Child
244
#
244
#
245
245
246
# process_request is the callback used by Net::Server to handle
246
=head2 process_request
247
# an incoming connection request.
247
248
process_request is the callback used by Net::Server to handle
249
an incoming connection request.
250
251
=cut
248
252
249
sub process_request {
253
sub process_request {
250
    my $self = shift;
254
    my $self = shift;
Lines 304-309 sub process_request { Link Here
304
# Transports
308
# Transports
305
#
309
#
306
310
311
=head2 raw_transport
312
313
Manages the SIP login process for raw TCP connections. Clears any
314
previous session state, applies a timeout, reads the initial request,
315
and authenticates it. On success, sets up logging context and enters
316
the SIP protocol loop. Returns on EOF, timeout, or failed login.
317
318
=cut
319
307
sub raw_transport {
320
sub raw_transport {
308
    my $self = shift;
321
    my $self = shift;
309
    my $input;
322
    my $input;
Lines 365-370 sub raw_transport { Link Here
365
    return;
378
    return;
366
}
379
}
367
380
381
=head2 get_clean_string
382
383
Cleans a string by removing leading and trailing non-alphanumeric
384
characters. Logs the string before and after cleaning, or notes if
385
the input was undefined. Returns the cleaned string (or undef if no
386
string was provided).
387
388
=cut
389
368
sub get_clean_string {
390
sub get_clean_string {
369
    my $string = shift;
391
    my $string = shift;
370
    if ( defined $string ) {
392
    if ( defined $string ) {
Lines 379-384 sub get_clean_string { Link Here
379
    return $string;
401
    return $string;
380
}
402
}
381
403
404
=head2 get_clean_input
405
406
Reads a single line from STDIN, normalizes it using
407
C<get_clean_string>, and discards any additional input lines, logging
408
them as errors. Returns the cleaned input line.
409
410
=cut
411
382
sub get_clean_input {
412
sub get_clean_input {
383
    local $/ = "\012";
413
    local $/ = "\012";
384
    my $in = <STDIN>;
414
    my $in = <STDIN>;
Lines 389-394 sub get_clean_input { Link Here
389
    return $in;
419
    return $in;
390
}
420
}
391
421
422
=head2 telnet_transport
423
424
Handles the login process for terminals connecting via the telnet
425
transport. Prompts for a username and password, applies a timeout to
426
protect against hung connections, and validates the credentials against
427
configured accounts. On successful authentication, initializes the SIP
428
session by invoking C<sip_protocol_loop>.  Dies on timeout or repeated
429
failed login attempts.
430
431
=cut
432
392
sub telnet_transport {
433
sub telnet_transport {
393
    my $self = shift;
434
    my $self = shift;
394
    my ( $uid, $pwd );
435
    my ( $uid, $pwd );
Lines 452-462 sub telnet_transport { Link Here
452
    return;
493
    return;
453
}
494
}
454
495
455
#
496
=head2 sip_protocol_loop
456
# The terminal has logged in, using either the SIP login process
497
457
# over a raw socket, or via the pseudo-unix login provided by the
498
The terminal has logged in, using either the SIP login process
458
# telnet transport.  From that point on, both the raw and the telnet
499
over a raw socket, or via the pseudo-unix login provided by the
459
# processes are the same:
500
telnet transport. From that point on, both the raw and the telnet
501
processes are the same:
502
503
=cut
504
460
sub sip_protocol_loop {
505
sub sip_protocol_loop {
461
    my $self    = shift;
506
    my $self    = shift;
462
    my $service = $self->{service};
507
    my $service = $self->{service};
Lines 514-519 sub sip_protocol_loop { Link Here
514
    return;
559
    return;
515
}
560
}
516
561
562
=head2 read_request
563
564
Reads a single SIP request line from STDIN using carriage return as the
565
record separator. Strips leading and trailing non-alphanumeric
566
characters, removes extra line breaks, and logs any trimming that
567
occurs. Also flushes Level-1 caches before processing each request.
568
Returns the cleaned request string, or undef on EOF.
569
570
=cut
571
517
sub read_request {
572
sub read_request {
518
    my $raw_length;
573
    my $raw_length;
519
    local $/ = "\015";
574
    local $/ = "\015";
Lines 552-566 sub read_request { Link Here
552
    return $buffer;
607
    return $buffer;
553
}
608
}
554
609
555
# $server->get_timeout({ $type => 1, fallback => $fallback });
610
=head2 get_timeout
556
#     where $type is transport | client | policy
611
557
#
612
    $server->get_timeout({ $type => 1, fallback => $fallback });
558
# Centralizes all timeout logic.
613
559
# Transport refers to login process, client to active connections.
614
where $type is transport | client | policy
560
# Policy timeout is transaction timeout (used in ACS status message).
615
561
#
616
Centralizes all timeout logic.
562
# Fallback is optional. If you do not pass transport, client or policy,
617
Transport refers to login process, client to active connections.
563
# you will get fallback or hardcoded default.
618
Policy timeout is transaction timeout (used in ACS status message).
619
620
Fallback is optional. If you do not pass transport, client or policy,
621
you will get fallback or hardcoded default.
622
623
=cut
564
624
565
sub get_timeout {
625
sub get_timeout {
566
    my ( $server, $params ) = @_;
626
    my ( $server, $params ) = @_;
567
- 

Return to bug 41271