| 1 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | # This library is free software; you can redistribute it and/or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | # modify it under the terms of the GNU Library General Public | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | # License as published by the Free Software Foundation; either | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | # version 2 of the License, or (at your option) any later version. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | # This library is distributed in the hope that it will be useful, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | # Library General Public License for more details. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | # You should have received a copy of the GNU Library General Public | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | # License along with this library; if not, write to the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | # Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | # Boston, MA 02111-1307, USA. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | # Jabber | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | # Copyright (C) 1998-2004 Jabber Software Foundation http://jabber.org/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | package XML::Stream; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | XML::Stream - Creates an XML Stream connection and parses return data | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | XML::Stream is an attempt at solidifying the use of XML via streaming. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | This module provides the user with methods to connect to a remote | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | server, send a stream of XML to the server, and receive/parse an XML | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | stream from the server. It is primarily based work for the Etherx XML | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | router developed by the Jabber Development Team. For more information | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | about this project visit http://xmpp.org/protocols/streams/. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | XML::Stream gives the user the ability to define a central callback | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | that will be used to handle the tags received from the server. These | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | tags are passed in the format defined at instantiation time. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | the closing tag of an object is seen, the tree is finished and passed | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | to the call back function. What the user does with it from there is up | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | to them. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | For a detailed description of how this module works, and about the data | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | structure that it returns, please view the source of Stream.pm and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | look at the detailed description at the end of the file. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | NOTE: The parser that XML::Stream::Parser provides, as are most Perl | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | parsers, is synchronous. If you are in the middle of parsing a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | packet and call a user defined callback, the Parser is blocked until | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | your callback finishes. This means you cannot be operating on a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | packet, send out another packet and wait for a response to that packet. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | It will never get to you. Threading might solve this, but as we all | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | know threading in Perl is not quite up to par yet. This issue will be | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | revisted in the future. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | =head1 METHODS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 12 | ▶ | use 5.008; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 12 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 12 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 12 | ▶ | use Sys::Hostname; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 12 | ▶ | use IO::Socket; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 12 | ▶ | use IO::Select; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 12 | ▶ | use FileHandle; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 12 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 12 | ▶ | use POSIX; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 12 | ▶ | use Authen::SASL; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 12 | ▶ | use MIME::Base64; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 12 | ▶ | use utf8; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 12 | ▶ | use Encode; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 12 | ▶ | use Scalar::Util qw(weaken); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 12 | ▶ | use XML::Stream::IO::Select::Win32; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 12 | ▶ | use XML::Stream::Tools; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 12 | $SIG{PIPE} = "IGNORE"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 12 | ▶ | use vars qw($VERSION $PAC $SSL $NONBLOCKING %HANDLERS $NETDNS %XMLNS ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | # Define the namespaces in an easy/constant manner. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | # 0.9 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 12 | $XMLNS{'stream'} = "http://etherx.jabber.org/streams"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | # 1.0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 12 | $XMLNS{'xmppstreams'} = "urn:ietf:params:xml:ns:xmpp-streams"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 12 | $XMLNS{'xmpp-bind'} = "urn:ietf:params:xml:ns:xmpp-bind"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 12 | $XMLNS{'xmpp-sasl'} = "urn:ietf:params:xml:ns:xmpp-sasl"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 12 | $XMLNS{'xmpp-session'} = "urn:ietf:params:xml:ns:xmpp-session"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 12 | $XMLNS{'xmpp-tls'} = "urn:ietf:params:xml:ns:xmpp-tls"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 12 | ▶ | if (eval "require Net::DNS;" ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | require Net::DNS; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | import Net::DNS; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | $NETDNS = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 12 | $NETDNS = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 12 | $VERSION = "1.23_06"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 12 | $NONBLOCKING = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | #use XML::Stream::Namespace; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 12 | ▶ | use XML::Stream::Parser; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 12 | ▶ | use XML::Stream::XPath; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | # Setup the exportable objects | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 12 | my @EXPORT_OK = qw(Tree Node); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | sub import | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 12 | ▶ | my $class = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
import: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 12 | foreach my $module (@_) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 10 | ▶ | eval "use XML::Stream::$module;"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 14 | ▶ | die($@) if ($@); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 14 | my $lc = lc($module); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 14 | eval("\$HANDLERS{\$lc}->{startElement} = \\&XML::Stream::${module}::_handle_element;"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 14 | eval("\$HANDLERS{\$lc}->{endElement} = \\&XML::Stream::${module}::_handle_close;"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 14 | eval("\$HANDLERS{\$lc}->{characters} = \\&XML::Stream::${module}::_handle_cdata;"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | =pod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | =head2 new | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | debug => string, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | debugfh => FileHandle, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | debuglevel => 0|1|N, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | debugtime => 0|1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | style => string) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | Creates the XML::Stream object. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | B<debug> should be set to the path for the debug log | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | to be written. If set to "stdout" then the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | debug will go there. Also, you can specify | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | a filehandle that already exists by using | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | B<debugfh>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | B<debuglevel> determines the amount of debug to generate. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 0 is the least, 1 is a little more, N is the limit you want. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | B<debugtime> determines wether a timestamp should be preappended | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | to the entry. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | B<style> defines the way the data structure is | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | returned. The two available styles are: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | tree - L<XML::Parser> Tree format | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | node - L<XML::Stream::Node> format | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | For more information see the respective man pages. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | sub new | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 8 | ▶ | my $proto = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=10 SCAR=23.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 8 | my $self = { }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 8 | bless($self,$proto); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 8 | my %args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 8 | ▶ | while($#_ >= 0) { $args{ lc pop(@_) } = pop(@_); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 8 | $self->{DATASTYLE} = "tree"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 8 | ▶ | $self->{DATASTYLE} = delete($args{style}) if exists($args{style}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 8 | ▶ | if ((($self->{DATASTYLE} eq "tree") && !defined($XML::Stream::Tree::LOADED)) || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition55%5/9
$self->{"DATASTYLE"} eq "tree" and not defined $XML::Stream::Tree::LOADED or $self->{"DATASTYLE"} eq "node" and not defined $XML::Stream::Node::LOADED
$self->{"DATASTYLE"} eq "tree" and not defined $XML::Stream::Tree::LOADED
$self->{"DATASTYLE"} eq "node" and not defined $XML::Stream::Node::LOADED
MC/DC0%0/4
$self->{"DATASTYLE"} eq "tree" and not defined $XML::Stream::Tree::LOADED or $self->{"DATASTYLE"} eq "node" and not defined $XML::Stream::Node::LOADED
$self->{"DATASTYLE"} eq "tree"
not defined $XML::Stream::Tree::LOADED
$self->{"DATASTYLE"} eq "node"
not defined $XML::Stream::Node::LOADED
Truth table14%1/7
A and not(B) or C and not(D)
A= $self->{"DATASTYLE"} eq "tree"B= not defined $XML::Stream::Tree::LOADEDC= $self->{"DATASTYLE"} eq "node"D= not defined $XML::Stream::Node::LOADED
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | (($self->{DATASTYLE} eq "node") && !defined($XML::Stream::Node::LOADED)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | croak( qq{The style that you have chosen was not defined when you "use"d the module.\n} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 8 | $self->{DEBUGARGS} = \%args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 8 | XML::Stream::Tools::setup_debug($self, %args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 8 | my $hostname = hostname(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 8 | ▶ | my $address = gethostbyname($hostname) || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
gethostbyname $hostname || die("Cannot resolve ${hostname}: $!")
MC/DC0%0/1
gethostbyname $hostname || die("Cannot resolve ${hostname}: $!")
gethostbyname $hostname
Truth table50%1/2
A
A= gethostbyname $hostname
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | die("Cannot resolve $hostname: $!"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 8 | ▶ | my $fullname = gethostbyaddr($address,AF_INET) || $hostname; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
gethostbyaddr($address, 2) || $hostname
MC/DC0%0/2
gethostbyaddr($address, 2) || $hostname
gethostbyaddr($address, 2)
$hostname
Truth table33%1/3
A || B
A= gethostbyaddr($address, 2)B= $hostname
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 8 | $self->debug(1,"new: hostname = ($fullname)"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | #--------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | # Setup the defaults that the module will work with. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | #--------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 8 | $self->{SIDS}->{default}->{hostname} = ""; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 8 | $self->{SIDS}->{default}->{port} = ""; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 8 | $self->{SIDS}->{default}->{sock} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 8 | $self->{SIDS}->{default}->{ssl} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 8 | $self->{SIDS}->{default}->{_tls} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 8 | $self->{SIDS}->{default}->{ssl_verify} = 0x01; # verify peer by default | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 8 | $self->{SIDS}->{default}->{ssl_ca_path} = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 8 | $self->{SIDS}->{default}->{namespace} = ""; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 8 | $self->{SIDS}->{default}->{myhostname} = $fullname; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 8 | $self->{SIDS}->{default}->{derivedhostname} = $fullname; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 8 | $self->{SIDS}->{default}->{id} = ""; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | #--------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | # We are only going to use one callback, let the user call other callbacks | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | # on his own. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | #--------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 8 | my $weak = $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 8 | weaken $weak; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 8 | ▶ | $self->SetCallBacks(node=>sub { $weak->_node(@_) }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 8 | ▶ | weaken $self->{CB} if $self->{CB}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 8 | $self->{IDCOUNT} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 8 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | #+---------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | #| | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | #| Incoming Connection Functions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | #| | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | #+---------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | =pod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | =head2 Listen | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | Starts the stream by listening on a port for someone to connect, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | and send the opening stream tag, and then sending a response based | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | on if the received header was correct for this stream. Server | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | name, port, and namespace are required otherwise we don't know | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | where to listen and what namespace to accept. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | sub Listen | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Listen: not called CC=10 SCAR=47.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 0 | my %args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 0 | ▶ | while($#_ >= 0) { $args{ lc pop(@_) } = pop(@_); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 0 | my $serverid = "server$args{port}"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 0 | ▶ | return if exists($self->{SIDS}->{$serverid}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 0 | push(@{$self->{SIDS}->{server}},$serverid); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 0 | foreach my $key (keys(%{$self->{SIDS}->{default}})) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 0 | $self->{SIDS}->{$serverid}->{$key} = $self->{SIDS}->{default}->{$key}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 0 | foreach my $key (keys(%args)) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 0 | $self->{SIDS}->{$serverid}->{$key} = $args{$key}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 0 | $self->debug(1,"Listen: start"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 0 | ▶ | if ($self->{SIDS}->{$serverid}->{namespace} eq "") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 0 | $self->SetErrorCode($serverid,"Namespace not specified"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | #--------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | # Check some things that we have to know in order get the connection up | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | # and running. Server hostname, port number, namespace, etc... | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | #--------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 0 | ▶ | if ($self->{SIDS}->{$serverid}->{hostname} eq "") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 0 | $self->SetErrorCode("$serverid","Server hostname not specified"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 0 | ▶ | if ($self->{SIDS}->{$serverid}->{port} eq "") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 0 | $self->SetErrorCode("$serverid","Server port not specified"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 0 | ▶ | if ($self->{SIDS}->{$serverid}->{myhostname} eq "") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 0 | $self->{SIDS}->{$serverid}->{myhostname} = $self->{SIDS}->{$serverid}->{derivedhostname}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | #------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | # Open the connection to the listed server and port. If that fails then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | # abort ourselves and let the user check $! on his own. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | #------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 0 | ▶ | while($self->{SIDS}->{$serverid}->{sock} == 0) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | $self->{SIDS}->{$serverid}->{sock} = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | IO::Socket::INET->new(LocalHost=>$self->{SIDS}->{$serverid}->{hostname}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | LocalPort=>$self->{SIDS}->{$serverid}->{port}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 0 | Reuse=>1, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | Listen=>10, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | Proto=>'tcp'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 0 | select(undef,undef,undef,.1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 0 | $self->{SIDS}->{$serverid}->{status} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 0 | $self->nonblock($self->{SIDS}->{$serverid}->{sock}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 0 | $self->{SIDS}->{$serverid}->{sock}->autoflush(1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | $self->{SELECT} = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 0 | IO::Select->new($self->{SIDS}->{$serverid}->{sock}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | $self->{SIDS}->{$serverid}->{select} = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 0 | IO::Select->new($self->{SIDS}->{$serverid}->{sock}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 0 | $self->{SOCKETS}->{$self->{SIDS}->{$serverid}->{sock}} = "$serverid"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 0 | return $serverid; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | =pod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | =head2 ConnectionAccept | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | Accept an incoming connection. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | sub ConnectionAccept | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ConnectionAccept: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 0 | my $serverid = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 0 | my $sid = $self->NewSID(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 0 | $self->debug(1,"ConnectionAccept: sid($sid)"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 0 | $self->{SIDS}->{$sid}->{sock} = $self->{SIDS}->{$serverid}->{sock}->accept(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | 0 | $self->nonblock($self->{SIDS}->{$sid}->{sock}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 0 | $self->{SIDS}->{$sid}->{sock}->autoflush(1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 0 | $self->debug(3,"ConnectionAccept: sid($sid) client($self->{SIDS}->{$sid}->{sock}) server($self->{SIDS}->{$serverid}->{sock})"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 0 | $self->{SELECT}->add($self->{SIDS}->{$sid}->{sock}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | #------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | # Create the XML::Stream::Parser and register our callbacks | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | #------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 0 | my $weak = $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 0 | weaken $weak; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | $self->{SIDS}->{$sid}->{parser} = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | 0 | XML::Stream::Parser->new(%{$self->{DEBUGARGS}}, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | nonblocking=>$NONBLOCKING, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | sid=>$sid, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | style=>$self->{DATASTYLE}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | Handlers=>{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | 0 | ▶ | startElement=>sub{ $weak->_handle_root(@_) }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 0 | ▶ | endElement=>sub{ &{$HANDLERS{$weak->{DATASTYLE}}->{endElement}}($weak,@_) }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 0 | ▶ | characters=>sub{ &{$HANDLERS{$weak->{DATASTYLE}}->{characters}}($weak,@_) }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 0 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | $self->{SIDS}->{$sid}->{select} = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | 0 | IO::Select->new($self->{SIDS}->{$sid}->{sock}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 0 | $self->{SIDS}->{$sid}->{connectiontype} = "tcpip"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | 0 | $self->{SOCKETS}->{$self->{SIDS}->{$sid}->{sock}} = $sid; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | 0 | $self->InitConnection($sid,$serverid); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | #--------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | # Grab the init time so that we can check if we get data in the timeout | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | # period or not. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | #--------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 0 | $self->{SIDS}->{$sid}->{activitytimeout} = time; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | 0 | return $sid; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | =pod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | =head2 Respond | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | If this is a listening socket then we need to respond to the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | opening <stream:stream/>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | sub Respond | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Respond: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | 0 | my $sid = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | 0 | my $serverid = $self->{SIDS}->{$sid}->{serverid}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | 0 | my $root = $self->GetRoot($sid); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 0 | ▶ | if ($root->{xmlns} ne $self->{SIDS}->{$serverid}->{namespace}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | 0 | my $error = $self->StreamError($sid,"invalid-namespace","Invalid namespace specified"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | 0 | $self->Send($sid,$error); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | 0 | $self->{SIDS}->{$sid}->{sock}->flush(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | 0 | select(undef,undef,undef,1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | 0 | $self->Disconnect($sid); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | #--------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | # Next, we build the opening handshake. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | #--------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | 0 | my %stream_args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | $stream_args{from} = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | (exists($self->{SIDS}->{$serverid}->{from}) ? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | $self->{SIDS}->{$serverid}->{from} : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | $self->{SIDS}->{$serverid}->{hostname} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | 0 | ▶ | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | 0 | $stream_args{to} = $self->GetRoot($sid)->{from}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | 0 | $stream_args{id} = $sid; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | 0 | $stream_args{namespaces} = $self->{SIDS}->{$serverid}->{namespaces}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | my $stream = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | $self->StreamHeader( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | xmlns=>$self->{SIDS}->{$serverid}->{namespace}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | 0 | xmllang=>"en", | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | %stream_args | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | #--------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | # Then we send the opening handshake. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | #--------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | 0 | $self->Send($sid,$stream); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | 0 | delete($self->{SIDS}->{$sid}->{activitytimeout}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | #+---------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | #| | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | #| Outgoing Connection Functions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | #| | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | #+---------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | =pod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | =head2 Connect | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | Starts the stream by connecting to the server, sending the opening | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | stream tag, and then waiting for a response and verifying that it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | is correct for this stream. Server name, port, and namespace are | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | required otherwise we don't know where to send the stream to... | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | Connect(hostname=>string, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | port=>integer, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | to=>string, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | from=>string, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | myhostname=>string, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | namespace=>string, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | namespaces=>array, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | connectiontype=>string, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | ssl=>0|1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | ssl_verify =>0x00|0x01|0x02|0x04, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | ssl_ca_path=>string, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | srv=>string) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | Opens a tcp connection to the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | specified server and sends the proper | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | opening XML Stream tag. C<hostname>, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | C<port>, and C<namespace> are required. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | namespaces allows you to use | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | XML::Stream::Namespace objects. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | C<to> is needed if you want the stream | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | to attribute to be something other | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | than the hostname you are connecting | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | to. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | C<from> is needed if you want the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | stream from attribute to be something | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | other than the hostname you are | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | connecting from. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | C<myhostname> should | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | not be needed but if the module | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | cannot determine your hostname | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | properly (check the debug log), set | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | this to the correct value, or if you | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | want the other side of the stream to | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | think that you are someone else. The | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | type determines the kind of | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | connection that is made: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | "tcpip" - TCP/IP (default) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | "stdinout" - STDIN/STDOUT | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | "http" - HTTP | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | HTTP recognizes proxies if the ENV | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | variables http_proxy or https_proxy | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | are set. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | C<ssl> specifies whether an SSL socket | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | should be used for encrypted co- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | mmunications. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | C<ssl_verify> determines whether peer | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | certificate verification takes place. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | See the documentation for the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | SSL_verify_mode parameter to | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | L<IO::Socket::SSL->new()|IO::Socket::SSL>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | The default value is 0x01 causing the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | server certificate to be verified, and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | requiring that ssl_ca_path be set. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | C<ssl_ca_path> should be set to the path to | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | either a directory containing hashed CA | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | certificates, or a single file containing | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | acceptable CA certifictes concatenated | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | together. This parameter is required if | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | ssl_verify is set to anything other than | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | 0x00 (no verification). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | If srv is specified AND Net::DNS is | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | installed and can be loaded, then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | an SRV query is sent to srv.hostname | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | and the results processed to replace | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | the hostname and port. If the lookup | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | fails, or Net::DNS cannot be loaded, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | then hostname and port are left alone | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | as the defaults. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | This function returns the same hash from GetRoot() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | below. Make sure you get the SID | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | (Session ID) since you have to use it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | to call most other functions in here. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | sub Connect | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | 3 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Connect: called CC=68 SCAR=79.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | 3 | foreach my $key (keys(%{$self->{SIDS}->{default}})) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | 33 | $self->{SIDS}->{newconnection}->{$key} = $self->{SIDS}->{default}->{$key}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | 3 | ▶ | while($#_ >= 0) { $self->{SIDS}->{newconnection}->{ lc pop(@_) } = pop(@_); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | my $timeout = exists($self->{SIDS}->{newconnection}->{timeout}) ? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | 3 | ▶ | delete($self->{SIDS}->{newconnection}->{timeout}) : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | ""; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | 3 | $self->debug(4,"Connect: timeout($timeout)"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | 3 | ▶ | if (exists($self->{SIDS}->{newconnection}->{srv})) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | 0 | $self->debug(1,"Connect: srv requested"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | 0 | ▶ | if ($NETDNS) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | 0 | my $res = Net::DNS::Resolver->new(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | 0 | my $query = $res->query($self->{SIDS}->{newconnection}->{srv}.".".$self->{SIDS}->{newconnection}->{hostname},"SRV"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | 0 | ▶ | if ($query) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | 0 | $self->{SIDS}->{newconnection}->{hostname} = ($query->answer)[0]->target(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | 0 | $self->{SIDS}->{newconnection}->{port} = ($query->answer)[0]->port(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | 0 | $self->debug(1,"Connect: srv host: $self->{SIDS}->{newconnection}->{hostname}"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | 0 | $self->debug(1,"Connect: srv post: $self->{SIDS}->{newconnection}->{port}"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | 0 | $self->debug(1,"Connect: srv query failed"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | 0 | $self->debug(1,"Connect: srv query failed"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | 0 | delete($self->{SIDS}->{newconnection}->{srv}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | $self->{SIDS}->{newconnection}->{connectiontype} = "tcpip" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | 3 | ▶ | unless exists($self->{SIDS}->{newconnection}->{connectiontype}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | 3 | $self->debug(1,"Connect: type($self->{SIDS}->{newconnection}->{connectiontype})"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | 3 | ▶ | if ($self->{SIDS}->{newconnection}->{namespace} eq "") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | 0 | $self->SetErrorCode("newconnection","Namespace not specified"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | # Set ssl_params for newconnection ssl or tls is set | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | 3 | ▶ | if ( 1 == $self->{SIDS}->{newconnection}->{ssl} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
1 == $self->{"SIDS"}{"newconnection"}{"ssl"} or 1 == $self->{"SIDS"}{"newconnection"}{"_tls"}
MC/DC100%2/2
1 == $self->{"SIDS"}{"newconnection"}{"ssl"} or 1 == $self->{"SIDS"}{"newconnection"}{"_tls"}
1 == $self->{"SIDS"}{"newconnection"}{"ssl"}
1 == $self->{"SIDS"}{"newconnection"}{"_tls"}
Truth table100%3/3
A or B
A= 1 == $self->{"SIDS"}{"newconnection"}{"ssl"}B= 1 == $self->{"SIDS"}{"newconnection"}{"_tls"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | || 1 == $self->{SIDS}->{newconnection}->{_tls} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | my %ssl_params = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | SSL_verify_mode => $self->{SIDS}->{newconnection}->{ssl_verify}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | 2 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | 2 | ▶ | if ( 0x00 != $self->{SIDS}->{newconnection}->{ssl_verify} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | die ("Invalid or unreadable path specified for ssl_ca_path.") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | 0 | ▶ | unless -e -r $self->{SIDS}->{newconnection}->{ssl_ca_path}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | 0 | ▶ | if (-f $self->{SIDS}->{newconnection}->{ssl_ca_path} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | 0 | $ssl_params{'SSL_ca_file'} = $self->{SIDS}->{newconnection}->{ssl_ca_path}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | 0 | $ssl_params{'SSL_ca_path'} = $self->{SIDS}->{newconnection}->{ssl_ca_path}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | 2 | $self->{SIDS}->{newconnection}->{ssl_params} = \%ssl_params; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | #--------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | # TCP/IP | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | #--------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | 3 | ▶ | if ($self->{SIDS}->{newconnection}->{connectiontype} eq "tcpip") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | #----------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | # Check some things that we have to know in order get the connection up | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | # and running. Server hostname, port number, namespace, etc... | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | #----------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | 3 | ▶ | if ($self->{SIDS}->{newconnection}->{hostname} eq "") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | 0 | $self->SetErrorCode("newconnection","Server hostname not specified"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | 3 | ▶ | if ($self->{SIDS}->{newconnection}->{port} eq "") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | 0 | $self->SetErrorCode("newconnection","Server port not specified"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | 3 | ▶ | if ($self->{SIDS}->{newconnection}->{myhostname} eq "") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | 0 | $self->{SIDS}->{newconnection}->{myhostname} = $self->{SIDS}->{newconnection}->{derivedhostname}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | #----------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | # Open the connection to the listed server and port. If that fails then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | # abort ourselves and let the user check $! on his own. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | #----------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | $self->{SIDS}->{newconnection}->{sock} = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | IO::Socket::INET->new(PeerAddr=>$self->{SIDS}->{newconnection}->{hostname}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | PeerPort=>$self->{SIDS}->{newconnection}->{port}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | 3 | ▶ | Proto=>"tcp", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 688 | (($timeout ne "") ? ( Timeout=>$timeout ) : ()), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 690 | 3 | ▶ | return unless $self->{SIDS}->{newconnection}->{sock}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 692 | 1 | ▶ | if ($self->{SIDS}->{newconnection}->{ssl} == 1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 693 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 694 | 0 | $self->debug(1,"Connect: Convert normal socket to SSL"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 695 | 0 | $self->debug(1,"Connect: sock($self->{SIDS}->{newconnection}->{sock})"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 696 | 0 | $self->LoadSSL(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 697 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 698 | $self->{SIDS}->{newconnection}->{sock} = IO::Socket::SSL::socketToSSL( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 699 | $self->{SIDS}->{newconnection}->{sock}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 700 | $self->{SIDS}->{newconnection}->{ssl_params} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 701 | 0 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 702 | 0 | $self->debug(1,"Connect: ssl_sock($self->{SIDS}->{newconnection}->{sock})"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 703 | 0 | ▶ | $self->debug(1,"Connect: SSL: We are secure") if ($self->{SIDS}->{newconnection}->{sock}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 704 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 705 | 1 | ▶ | return unless $self->{SIDS}->{newconnection}->{sock}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 706 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 707 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 708 | #--------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 709 | # STDIN/OUT | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 710 | #--------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 711 | 1 | ▶ | if ($self->{SIDS}->{newconnection}->{connectiontype} eq "stdinout") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 712 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 713 | $self->{SIDS}->{newconnection}->{sock} = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 714 | 0 | FileHandle->new(">&STDOUT"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 715 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 716 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 717 | #--------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 718 | # HTTP | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 719 | #--------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 720 | 1 | ▶ | if ($self->{SIDS}->{newconnection}->{connectiontype} eq "http") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 721 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 722 | #----------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 723 | # Check some things that we have to know in order get the connection up | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 724 | # and running. Server hostname, port number, namespace, etc... | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 725 | #----------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 726 | 0 | ▶ | if ($self->{SIDS}->{newconnection}->{hostname} eq "") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 727 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 728 | 0 | $self->SetErrorCode("newconnection","Server hostname not specified"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 729 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 730 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 731 | 0 | ▶ | if ($self->{SIDS}->{newconnection}->{port} eq "") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 732 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 733 | 0 | $self->SetErrorCode("newconnection","Server port not specified"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 734 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 735 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 736 | 0 | ▶ | if ($self->{SIDS}->{newconnection}->{myhostname} eq "") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 737 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 738 | 0 | $self->{SIDS}->{newconnection}->{myhostname} = $self->{SIDS}->{newconnection}->{derivedhostname}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 739 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 740 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 741 | 0 | ▶ | if (!defined($PAC)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 742 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 743 | 0 | eval("use HTTP::ProxyAutoConfig;"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 744 | 0 | ▶ | if ($@) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 745 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 746 | 0 | $PAC = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 747 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 748 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 749 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 750 | 0 | require HTTP::ProxyAutoConfig; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 751 | 0 | $PAC = HTTP::ProxyAutoConfig->new(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 752 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 753 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 754 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 755 | 0 | ▶ | if ($PAC eq "0") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 756 | 0 | ▶ | if (exists($ENV{"http_proxy"})) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 757 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 758 | 0 | my($host,$port) = ($ENV{"http_proxy"} =~ /^(\S+)\:(\d+)$/); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 759 | 0 | $self->{SIDS}->{newconnection}->{httpproxyhostname} = $host; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 760 | 0 | $self->{SIDS}->{newconnection}->{httpproxyport} = $port; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 761 | 0 | $self->{SIDS}->{newconnection}->{httpproxyhostname} =~ s/^http\:\/\///; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 762 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 763 | 0 | ▶ | if (exists($ENV{"https_proxy"})) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 764 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 765 | 0 | my($host,$port) = ($ENV{"https_proxy"} =~ /^(\S+)\:(\d+)$/); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 766 | 0 | $self->{SIDS}->{newconnection}->{httpsproxyhostname} = $host; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 767 | 0 | $self->{SIDS}->{newconnection}->{httpsproxyport} = $port; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 768 | 0 | $self->{SIDS}->{newconnection}->{httpsproxyhostname} =~ s/^https?\:\/\///; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 769 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 770 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 771 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 772 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 773 | 0 | my $proxy = $PAC->FindProxy("http://".$self->{SIDS}->{newconnection}->{hostname}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 774 | 0 | ▶ | if ($proxy ne "DIRECT") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 775 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 776 | 0 | ($self->{SIDS}->{newconnection}->{httpproxyhostname},$self->{SIDS}->{newconnection}->{httpproxyport}) = ($proxy =~ /^PROXY ([^:]+):(\d+)$/); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 777 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 778 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 779 | 0 | $proxy = $PAC->FindProxy("https://".$self->{SIDS}->{newconnection}->{hostname}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 780 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 781 | 0 | ▶ | if ($proxy ne "DIRECT") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 782 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 783 | 0 | ($self->{SIDS}->{newconnection}->{httpsproxyhostname},$self->{SIDS}->{newconnection}->{httpsproxyport}) = ($proxy =~ /^PROXY ([^:]+):(\d+)$/); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 784 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 785 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 786 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 787 | $self->debug(1,"Connect: http_proxy($self->{SIDS}->{newconnection}->{httpproxyhostname}:$self->{SIDS}->{newconnection}->{httpproxyport})") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 788 | if (exists($self->{SIDS}->{newconnection}->{httpproxyhostname}) && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 789 | defined($self->{SIDS}->{newconnection}->{httpproxyhostname}) && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 790 | exists($self->{SIDS}->{newconnection}->{httpproxyport}) && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 791 | 0 | ▶ | defined($self->{SIDS}->{newconnection}->{httpproxyport})); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/9
exists $self->{"SIDS"}{"newconnection"}{"httpproxyhostname"} and defined $self->{"SIDS"}{"newconnection"}{"httpproxyhostname"} and exists $self->{"SIDS"}{"newconnection"}{"httpproxyport"} and defined $self->{"SIDS"}{"newconnection"}{"httpproxyport"}
exists $self->{"SIDS"}{"newconnection"}{"httpproxyhostname"} and defined $self->{"SIDS"}{"newconnection"}{"httpproxyhostname"} and exists $self->{"SIDS"}{"newconnection"}{"httpproxyport"}
exists $self->{"SIDS"}{"newconnection"}{"httpproxyhostname"} and defined $self->{"SIDS"}{"newconnection"}{"httpproxyhostname"}
MC/DC0%0/4
exists $self->{"SIDS"}{"newconnection"}{"httpproxyhostname"} and defined $self->{"SIDS"}{"newconnection"}{"httpproxyhostname"} and exists $self->{"SIDS"}{"newconnection"}{"httpproxyport"} and defined $self->{"SIDS"}{"newconnection"}{"httpproxyport"}
exists $self->{"SIDS"}{"newconnection"}{"httpproxyhostname"}
defined $self->{"SIDS"}{"newconnection"}{"httpproxyhostname"}
exists $self->{"SIDS"}{"newconnection"}{"httpproxyport"}
defined $self->{"SIDS"}{"newconnection"}{"httpproxyport"}
Truth table0%0/5
A and B and C and D
A= exists $self->{"SIDS"}{"newconnection"}{"httpproxyhostname"}B= defined $self->{"SIDS"}{"newconnection"}{"httpproxyhostname"}C= exists $self->{"SIDS"}{"newconnection"}{"httpproxyport"}D= defined $self->{"SIDS"}{"newconnection"}{"httpproxyport"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 792 | $self->debug(1,"Connect: https_proxy($self->{SIDS}->{newconnection}->{httpsproxyhostname}:$self->{SIDS}->{newconnection}->{httpsproxyport})") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 793 | if (exists($self->{SIDS}->{newconnection}->{httpsproxyhostname}) && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 794 | defined($self->{SIDS}->{newconnection}->{httpsproxyhostname}) && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 795 | exists($self->{SIDS}->{newconnection}->{httpsproxyport}) && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 796 | 0 | ▶ | defined($self->{SIDS}->{newconnection}->{httpsproxyport})); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/9
exists $self->{"SIDS"}{"newconnection"}{"httpsproxyhostname"} and defined $self->{"SIDS"}{"newconnection"}{"httpsproxyhostname"} and exists $self->{"SIDS"}{"newconnection"}{"httpsproxyport"} and defined $self->{"SIDS"}{"newconnection"}{"httpsproxyport"}
exists $self->{"SIDS"}{"newconnection"}{"httpsproxyhostname"} and defined $self->{"SIDS"}{"newconnection"}{"httpsproxyhostname"} and exists $self->{"SIDS"}{"newconnection"}{"httpsproxyport"}
exists $self->{"SIDS"}{"newconnection"}{"httpsproxyhostname"} and defined $self->{"SIDS"}{"newconnection"}{"httpsproxyhostname"}
MC/DC0%0/4
exists $self->{"SIDS"}{"newconnection"}{"httpsproxyhostname"} and defined $self->{"SIDS"}{"newconnection"}{"httpsproxyhostname"} and exists $self->{"SIDS"}{"newconnection"}{"httpsproxyport"} and defined $self->{"SIDS"}{"newconnection"}{"httpsproxyport"}
exists $self->{"SIDS"}{"newconnection"}{"httpsproxyhostname"}
defined $self->{"SIDS"}{"newconnection"}{"httpsproxyhostname"}
exists $self->{"SIDS"}{"newconnection"}{"httpsproxyport"}
defined $self->{"SIDS"}{"newconnection"}{"httpsproxyport"}
Truth table0%0/5
A and B and C and D
A= exists $self->{"SIDS"}{"newconnection"}{"httpsproxyhostname"}B= defined $self->{"SIDS"}{"newconnection"}{"httpsproxyhostname"}C= exists $self->{"SIDS"}{"newconnection"}{"httpsproxyport"}D= defined $self->{"SIDS"}{"newconnection"}{"httpsproxyport"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 797 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 798 | #----------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 799 | # Open the connection to the listed server and port. If that fails then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 800 | # abort ourselves and let the user check $! on his own. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 801 | #----------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 802 | 0 | my $connect = "CONNECT $self->{SIDS}->{newconnection}->{hostname}:$self->{SIDS}->{newconnection}->{port} HTTP/1.1\r\nHost: $self->{SIDS}->{newconnection}->{hostname}\r\n\r\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 803 | 0 | my $put = "PUT http://$self->{SIDS}->{newconnection}->{hostname}:$self->{SIDS}->{newconnection}->{port} HTTP/1.1\r\nHost: $self->{SIDS}->{newconnection}->{hostname}\r\nProxy-Connection: Keep-Alive\r\n\r\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 804 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 805 | 0 | my $connected = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 806 | #----------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 807 | # Combo #0 - The user didn't specify a proxy | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 808 | #----------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 809 | 0 | ▶ | if (!exists($self->{SIDS}->{newconnection}->{httpproxyhostname}) && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
exists $self->{"SIDS"}{"newconnection"}{"httpproxyhostname"} or exists $self->{"SIDS"}{"newconnection"}{"httpsproxyhostname"}
MC/DC0%0/2
exists $self->{"SIDS"}{"newconnection"}{"httpproxyhostname"} or exists $self->{"SIDS"}{"newconnection"}{"httpsproxyhostname"}
exists $self->{"SIDS"}{"newconnection"}{"httpproxyhostname"}
exists $self->{"SIDS"}{"newconnection"}{"httpsproxyhostname"}
Truth table0%0/3
A or B
A= exists $self->{"SIDS"}{"newconnection"}{"httpproxyhostname"}B= exists $self->{"SIDS"}{"newconnection"}{"httpsproxyhostname"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 810 | !exists($self->{SIDS}->{newconnection}->{httpsproxyhostname})) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 811 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 812 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 813 | 0 | $self->debug(1,"Connect: Combo #0: User did not specify a proxy... connecting DIRECT"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 814 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 815 | 0 | $self->debug(1,"Connect: Combo #0: Create normal socket"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 816 | $self->{SIDS}->{newconnection}->{sock} = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 817 | IO::Socket::INET->new(PeerAddr=>$self->{SIDS}->{newconnection}->{hostname}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 818 | PeerPort=>$self->{SIDS}->{newconnection}->{port}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 819 | 0 | ▶ | Proto=>"tcp", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 820 | (($timeout ne "") ? ( Timeout=>$timeout ) : ()), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 821 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 822 | 0 | $connected = defined($self->{SIDS}->{newconnection}->{sock}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 823 | 0 | $self->debug(1,"Connect: Combo #0: connected($connected)"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 824 | # if ($connected) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 825 | # { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 826 | # $self->{SIDS}->{newconnection}->{sock}->syswrite($put,length($put),0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 827 | # my $buff; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 828 | # $self->{SIDS}->{newconnection}->{sock}->sysread($buff,4*POSIX::BUFSIZ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 829 | # my ($code) = ($buff =~ /^\S+\s+(\S+)\s+/); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 830 | # $self->debug(1,"Connect: Combo #1: buff($buff)"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 831 | # $connected = 0 if ($code !~ /2\d\d/); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 832 | # } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 833 | # $self->debug(1,"Connect: Combo #0: connected($connected)"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 834 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 835 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 836 | #----------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 837 | # Combo #1 - PUT through http_proxy | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 838 | #----------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 839 | 0 | ▶ | if (!$connected && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
not $connected and exists $self->{"SIDS"}{"newconnection"}{"httpproxyhostname"} and $self->{"SIDS"}{"newconnection"}{"ssl"} == 0
not $connected and exists $self->{"SIDS"}{"newconnection"}{"httpproxyhostname"}
MC/DC0%0/3
not $connected and exists $self->{"SIDS"}{"newconnection"}{"httpproxyhostname"} and $self->{"SIDS"}{"newconnection"}{"ssl"} == 0
not $connected
exists $self->{"SIDS"}{"newconnection"}{"httpproxyhostname"}
$self->{"SIDS"}{"newconnection"}{"ssl"} == 0
Truth table0%0/4
not(A) and B and C
A= not $connectedB= exists $self->{"SIDS"}{"newconnection"}{"httpproxyhostname"}C= $self->{"SIDS"}{"newconnection"}{"ssl"} == 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 840 | exists($self->{SIDS}->{newconnection}->{httpproxyhostname}) && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 841 | ($self->{SIDS}->{newconnection}->{ssl} == 0)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 842 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 843 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 844 | 0 | $self->debug(1,"Connect: Combo #1: PUT through http_proxy"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 845 | $self->{SIDS}->{newconnection}->{sock} = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 846 | IO::Socket::INET->new(PeerAddr=>$self->{SIDS}->{newconnection}->{httpproxyhostname}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 847 | PeerPort=>$self->{SIDS}->{newconnection}->{httpproxyport}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 848 | 0 | ▶ | Proto=>"tcp", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 849 | (($timeout ne "") ? ( Timeout=>$timeout ) : ()), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 850 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 851 | 0 | $connected = defined($self->{SIDS}->{newconnection}->{sock}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 852 | 0 | $self->debug(1,"Connect: Combo #1: connected($connected)"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 853 | 0 | ▶ | if ($connected) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 854 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 855 | 0 | $self->debug(1,"Connect: Combo #1: send($put)"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 856 | 0 | $self->{SIDS}->{newconnection}->{sock}->syswrite($put,length($put),0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 857 | 0 | my $buff; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 858 | 0 | $self->{SIDS}->{newconnection}->{sock}->sysread($buff,4*POSIX::BUFSIZ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 859 | 0 | my ($code) = ($buff =~ /^\S+\s+(\S+)\s+/); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 860 | 0 | $self->debug(1,"Connect: Combo #1: buff($buff)"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 861 | 0 | ▶ | $connected = 0 if ($code !~ /2\d\d/); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 862 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 863 | 0 | $self->debug(1,"Connect: Combo #1: connected($connected)"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 864 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 865 | #----------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 866 | # Combo #2 - CONNECT through http_proxy | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 867 | #----------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 868 | 0 | ▶ | if (!$connected && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
not $connected and exists $self->{"SIDS"}{"newconnection"}{"httpproxyhostname"} and $self->{"SIDS"}{"newconnection"}{"ssl"} == 0
not $connected and exists $self->{"SIDS"}{"newconnection"}{"httpproxyhostname"}
MC/DC0%0/3
not $connected and exists $self->{"SIDS"}{"newconnection"}{"httpproxyhostname"} and $self->{"SIDS"}{"newconnection"}{"ssl"} == 0
not $connected
exists $self->{"SIDS"}{"newconnection"}{"httpproxyhostname"}
$self->{"SIDS"}{"newconnection"}{"ssl"} == 0
Truth table0%0/4
not(A) and B and C
A= not $connectedB= exists $self->{"SIDS"}{"newconnection"}{"httpproxyhostname"}C= $self->{"SIDS"}{"newconnection"}{"ssl"} == 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 869 | exists($self->{SIDS}->{newconnection}->{httpproxyhostname}) && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 870 | ($self->{SIDS}->{newconnection}->{ssl} == 0)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 871 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 872 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 873 | 0 | $self->debug(1,"Connect: Combo #2: CONNECT through http_proxy"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 874 | $self->{SIDS}->{newconnection}->{sock} = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 875 | IO::Socket::INET->new(PeerAddr=>$self->{SIDS}->{newconnection}->{httpproxyhostname}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 876 | PeerPort=>$self->{SIDS}->{newconnection}->{httpproxyport}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 877 | 0 | ▶ | Proto=>"tcp", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 878 | (($timeout ne "") ? ( Timeout=>$timeout ) : ()), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 879 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 880 | 0 | $connected = defined($self->{SIDS}->{newconnection}->{sock}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 881 | 0 | $self->debug(1,"Connect: Combo #2: connected($connected)"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 882 | 0 | ▶ | if ($connected) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 883 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 884 | 0 | $self->{SIDS}->{newconnection}->{sock}->syswrite($connect,length($connect),0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 885 | 0 | my $buff; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 886 | 0 | $self->{SIDS}->{newconnection}->{sock}->sysread($buff,4*POSIX::BUFSIZ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 887 | 0 | my ($code) = ($buff =~ /^\S+\s+(\S+)\s+/); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 888 | 0 | $self->debug(1,"Connect: Combo #2: buff($buff)"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 889 | 0 | ▶ | $connected = 0 if ($code !~ /2\d\d/); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 890 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 891 | 0 | $self->debug(1,"Connect: Combo #2: connected($connected)"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 892 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 893 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 894 | #----------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 895 | # Combo #3 - CONNECT through https_proxy | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 896 | #----------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 897 | 0 | ▶ | if (!$connected && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not $connected and exists $self->{"SIDS"}{"newconnection"}{"httpsproxyhostname"}
MC/DC0%0/2
not $connected and exists $self->{"SIDS"}{"newconnection"}{"httpsproxyhostname"}
not $connected
exists $self->{"SIDS"}{"newconnection"}{"httpsproxyhostname"}
Truth table0%0/3
not(A) and B
A= not $connectedB= exists $self->{"SIDS"}{"newconnection"}{"httpsproxyhostname"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 898 | exists($self->{SIDS}->{newconnection}->{httpsproxyhostname})) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 899 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 900 | 0 | $self->debug(1,"Connect: Combo #3: CONNECT through https_proxy"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 901 | $self->{SIDS}->{newconnection}->{sock} = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 902 | IO::Socket::INET->new(PeerAddr=>$self->{SIDS}->{newconnection}->{httpsproxyhostname}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 903 | PeerPort=>$self->{SIDS}->{newconnection}->{httpsproxyport}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 904 | 0 | Proto=>"tcp"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 905 | 0 | $connected = defined($self->{SIDS}->{newconnection}->{sock}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 906 | 0 | $self->debug(1,"Connect: Combo #3: connected($connected)"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 907 | 0 | ▶ | if ($connected) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 908 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 909 | 0 | $self->{SIDS}->{newconnection}->{sock}->syswrite($connect,length($connect),0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 910 | 0 | my $buff; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 911 | 0 | $self->{SIDS}->{newconnection}->{sock}->sysread($buff,4*POSIX::BUFSIZ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 912 | 0 | my ($code) = ($buff =~ /^\S+\s+(\S+)\s+/); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 913 | 0 | $self->debug(1,"Connect: Combo #3: buff($buff)"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 914 | 0 | ▶ | $connected = 0 if ($code !~ /2\d\d/); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 915 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 916 | 0 | $self->debug(1,"Connect: Combo #3: connected($connected)"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 917 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 918 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 919 | #----------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 920 | # We have failed | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 921 | #----------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 922 | 0 | ▶ | if (!$connected) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 923 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 924 | 0 | $self->debug(1,"Connect: No connection... I have failed... I.. must... end it all..."); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 925 | 0 | $self->SetErrorCode("newconnection","Unable to open a connection to destination. Please check your http_proxy and/or https_proxy environment variables."); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 926 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 927 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 928 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 929 | 0 | ▶ | return unless $self->{SIDS}->{newconnection}->{sock}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 930 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 931 | 0 | $self->debug(1,"Connect: We are connected"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 932 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 933 | 0 | ▶ | if (($self->{SIDS}->{newconnection}->{ssl} == 1) && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->{"SIDS"}{"newconnection"}{"ssl"} == 1 and ref $self->{"SIDS"}{"newconnection"}{"sock"} eq "IO::Socket::INET"
MC/DC0%0/2
$self->{"SIDS"}{"newconnection"}{"ssl"} == 1 and ref $self->{"SIDS"}{"newconnection"}{"sock"} eq "IO::Socket::INET"
$self->{"SIDS"}{"newconnection"}{"ssl"} == 1
ref $self->{"SIDS"}{"newconnection"}{"sock"} eq "IO::Socket::INET"
Truth table0%0/3
A and B
A= $self->{"SIDS"}{"newconnection"}{"ssl"} == 1B= ref $self->{"SIDS"}{"newconnection"}{"sock"} eq "IO::Socket::INET"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 934 | (ref($self->{SIDS}->{newconnection}->{sock}) eq "IO::Socket::INET")) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 935 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 936 | 0 | $self->debug(1,"Connect: Convert normal socket to SSL"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 937 | 0 | $self->debug(1,"Connect: sock($self->{SIDS}->{newconnection}->{sock})"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 938 | 0 | $self->LoadSSL(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 939 | $self->{SIDS}->{newconnection}->{sock} = IO::Socket::SSL::socketToSSL( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 940 | $self->{SIDS}->{newconnection}->{sock}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 941 | $self->{SIDS}->{newconnection}->{ssl_params} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 942 | 0 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 943 | 0 | $self->debug(1,"Connect: ssl_sock($self->{SIDS}->{newconnection}->{sock})"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 944 | 0 | ▶ | $self->debug(1,"Connect: SSL: We are secure") if ($self->{SIDS}->{newconnection}->{sock}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 945 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 946 | 0 | ▶ | return unless $self->{SIDS}->{newconnection}->{sock}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 947 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 948 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 949 | 1 | $self->debug(1,"Connect: Got a connection"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 950 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 951 | 1 | $self->{SIDS}->{newconnection}->{sock}->autoflush(1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 952 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 953 | 1 | return $self->OpenStream("newconnection",$timeout); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 954 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 955 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 956 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 957 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 958 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 959 | =pod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 960 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 961 | =head2 OpenStream | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 962 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 963 | Send the opening stream and save the root element info. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 964 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 965 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 966 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 967 | sub OpenStream | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 968 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 969 | 1 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
OpenStream: called CC=35 SCAR=47.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 970 | 1 | my $currsid = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 971 | 1 | my $timeout = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 972 | 1 | ▶ | $timeout = "" unless defined($timeout); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 973 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 974 | 1 | $self->InitConnection($currsid,$currsid); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 975 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 976 | #--------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 977 | # Next, we build the opening handshake. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 978 | #--------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 979 | 1 | my %stream_args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 980 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 981 | 1 | ▶ | if (($self->{SIDS}->{$currsid}->{connectiontype} eq "tcpip") || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->{"SIDS"}{$currsid}{"connectiontype"} eq "tcpip" or $self->{"SIDS"}{$currsid}{"connectiontype"} eq "http"
MC/DC0%0/2
$self->{"SIDS"}{$currsid}{"connectiontype"} eq "tcpip" or $self->{"SIDS"}{$currsid}{"connectiontype"} eq "http"
$self->{"SIDS"}{$currsid}{"connectiontype"} eq "tcpip"
$self->{"SIDS"}{$currsid}{"connectiontype"} eq "http"
Truth table33%1/3
A or B
A= $self->{"SIDS"}{$currsid}{"connectiontype"} eq "tcpip"B= $self->{"SIDS"}{$currsid}{"connectiontype"} eq "http"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 982 | ($self->{SIDS}->{$currsid}->{connectiontype} eq "http")) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 983 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 984 | $stream_args{to}= $self->{SIDS}->{$currsid}->{hostname} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 985 | 1 | ▶ | unless exists($self->{SIDS}->{$currsid}->{to}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 986 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 987 | $stream_args{to} = $self->{SIDS}->{$currsid}->{to} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 988 | 1 | ▶ | if exists($self->{SIDS}->{$currsid}->{to}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 989 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 990 | $stream_args{from} = $self->{SIDS}->{$currsid}->{myhostname} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 991 | if (!exists($self->{SIDS}->{$currsid}->{from}) && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 992 | 1 | ▶ | ($self->{SIDS}->{$currsid}->{myhostname} ne "") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not exists $self->{"SIDS"}{$currsid}{"from"} and $self->{"SIDS"}{$currsid}{"myhostname"} ne ""
MC/DC0%0/2
not exists $self->{"SIDS"}{$currsid}{"from"} and $self->{"SIDS"}{$currsid}{"myhostname"} ne ""
not exists $self->{"SIDS"}{$currsid}{"from"}
$self->{"SIDS"}{$currsid}{"myhostname"} ne ""
Truth table33%1/3
not(A) and B
A= not exists $self->{"SIDS"}{$currsid}{"from"}B= $self->{"SIDS"}{$currsid}{"myhostname"} ne ""
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 993 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 994 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 995 | $stream_args{from} = $self->{SIDS}->{$currsid}->{from} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 996 | 1 | ▶ | if exists($self->{SIDS}->{$currsid}->{from}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 997 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 998 | $stream_args{id} = $self->{SIDS}->{$currsid}->{id} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 999 | if (exists($self->{SIDS}->{$currsid}->{id}) && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1000 | 1 | ▶ | ($self->{SIDS}->{$currsid}->{id} ne "") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
exists $self->{"SIDS"}{$currsid}{"id"} and $self->{"SIDS"}{$currsid}{"id"} ne ""
MC/DC0%0/2
exists $self->{"SIDS"}{$currsid}{"id"} and $self->{"SIDS"}{$currsid}{"id"} ne ""
exists $self->{"SIDS"}{$currsid}{"id"}
$self->{"SIDS"}{$currsid}{"id"} ne ""
Truth table33%1/3
A and B
A= exists $self->{"SIDS"}{$currsid}{"id"}B= $self->{"SIDS"}{$currsid}{"id"} ne ""
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1001 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1002 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1003 | 1 | $stream_args{namespaces} = $self->{SIDS}->{$currsid}->{namespaces}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1004 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1005 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1006 | my $stream = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1007 | $self->StreamHeader( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1008 | xmlns=>$self->{SIDS}->{$currsid}->{namespace}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1009 | 1 | xmllang=>"en", | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1010 | %stream_args | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1011 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1012 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1013 | #--------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1014 | # Create the XML::Stream::Parser and register our callbacks | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1015 | #--------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1016 | 1 | my $weak = $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1017 | 1 | weaken $weak; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1018 | $self->{SIDS}->{$currsid}->{parser} = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1019 | 1 | XML::Stream::Parser->new(%{$self->{DEBUGARGS}}, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1020 | nonblocking=>$NONBLOCKING, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1021 | sid=>$currsid, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1022 | style=>$self->{DATASTYLE}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1023 | Handlers=>{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1024 | 1 | ▶ | startElement=>sub{ $weak->_handle_root(@_) }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1025 | 0 | ▶ | endElement=>sub{ &{$HANDLERS{$weak->{DATASTYLE}}->{endElement}}($weak, @_) }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1026 | 0 | ▶ | characters=>sub{ &{$HANDLERS{$weak->{DATASTYLE}}->{characters}}($weak, @_) }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1027 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1028 | 1 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1029 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1030 | $self->{SIDS}->{$currsid}->{select} = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1031 | 1 | IO::Select->new($self->{SIDS}->{$currsid}->{sock}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1032 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1033 | 1 | ▶ | if (($self->{SIDS}->{$currsid}->{connectiontype} eq "tcpip") || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->{"SIDS"}{$currsid}{"connectiontype"} eq "tcpip" or $self->{"SIDS"}{$currsid}{"connectiontype"} eq "http"
MC/DC0%0/2
$self->{"SIDS"}{$currsid}{"connectiontype"} eq "tcpip" or $self->{"SIDS"}{$currsid}{"connectiontype"} eq "http"
$self->{"SIDS"}{$currsid}{"connectiontype"} eq "tcpip"
$self->{"SIDS"}{$currsid}{"connectiontype"} eq "http"
Truth table33%1/3
A or B
A= $self->{"SIDS"}{$currsid}{"connectiontype"} eq "tcpip"B= $self->{"SIDS"}{$currsid}{"connectiontype"} eq "http"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1034 | ($self->{SIDS}->{$currsid}->{connectiontype} eq "http")) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1035 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1036 | 1 | $self->{SELECT} = IO::Select->new($self->{SIDS}->{$currsid}->{sock}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1037 | 1 | $self->{SOCKETS}->{$self->{SIDS}->{$currsid}->{sock}} = "newconnection"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1038 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1039 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1040 | 1 | ▶ | if ($self->{SIDS}->{$currsid}->{connectiontype} eq "stdinout") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1041 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1042 | 0 | $self->{SELECT} = IO::Select->new(*STDIN); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1043 | 0 | $self->{SOCKETS}->{$self->{SIDS}->{$currsid}->{sock}} = $currsid; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1044 | 0 | $self->{SOCKETS}->{*STDIN} = $currsid; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1045 | 0 | $self->{SIDS}->{$currsid}->{select}->add(*STDIN); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1046 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1047 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1048 | 1 | $self->{SIDS}->{$currsid}->{status} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1049 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1050 | #--------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1051 | # Then we send the opening handshake. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1052 | #--------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1053 | 1 | ▶ | $self->Send($currsid,$stream) || return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1054 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1055 | #--------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1056 | # Before going on let's make sure that the server responded with a valid | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1057 | # root tag and that the stream is open. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1058 | #--------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1059 | 1 | my $buff = ""; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1060 | 1 | ▶ | my $timeEnd = ($timeout eq "") ? "" : time + $timeout; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1061 | 1 | ▶ | while($self->{SIDS}->{$currsid}->{status} == 0) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1062 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1063 | 1 | my $now = time; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1064 | 1 | ▶ | my $wait = (($timeEnd eq "") || ($timeEnd - $now > 10)) ? 10 : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$timeEnd eq "" or $timeEnd - $now > 10
MC/DC0%0/2
$timeEnd eq "" or $timeEnd - $now > 10
$timeEnd eq ""
$timeEnd - $now > 10
Truth table33%1/3
A or B
A= $timeEnd eq ""B= $timeEnd - $now > 10
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1065 | $timeEnd - $now; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1066 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1067 | 1 | $self->debug(5,"Connect: can_read(",join(",",$self->{SIDS}->{$currsid}->{select}->can_read(0)),")"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1068 | 1 | ▶ | if ($self->{SIDS}->{$currsid}->{select}->can_read($wait)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1069 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1070 | 1 | ▶ | $self->{SIDS}->{$currsid}->{status} = -1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1071 | unless defined($buff = $self->Read($currsid)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1072 | 1 | ▶ | return unless($self->{SIDS}->{$currsid}->{status} == 0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1073 | 1 | ▶ | return unless($self->ParseStream($currsid,$buff) == 1); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1074 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1075 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1076 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1077 | 0 | ▶ | if ($timeout ne "") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1078 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1079 | 0 | ▶ | if (time >= $timeEnd) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1080 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1081 | 0 | $self->SetErrorCode($currsid,"Timeout limit reached"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1082 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1083 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1084 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1085 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1086 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1087 | 1 | ▶ | return if($self->{SIDS}->{$currsid}->{select}->has_exception(0)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1088 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1089 | 1 | ▶ | return if($self->{SIDS}->{$currsid}->{status} != 1); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1090 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1091 | 1 | $self->debug(3,"Connect: status($self->{SIDS}->{$currsid}->{status})"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1092 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1093 | 1 | my $sid = $self->GetRoot($currsid)->{id}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1094 | 1 | $| = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1095 | 1 | foreach my $key (keys(%{$self->{SIDS}->{$currsid}})) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1096 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1097 | 25 | $self->{SIDS}->{$sid}->{$key} = $self->{SIDS}->{$currsid}->{$key}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1098 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1099 | 1 | $self->{SIDS}->{$sid}->{parser}->setSID($sid); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1100 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1101 | 1 | ▶ | if (($self->{SIDS}->{$sid}->{connectiontype} eq "tcpip") || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->{"SIDS"}{$sid}{"connectiontype"} eq "tcpip" or $self->{"SIDS"}{$sid}{"connectiontype"} eq "http"
MC/DC0%0/2
$self->{"SIDS"}{$sid}{"connectiontype"} eq "tcpip" or $self->{"SIDS"}{$sid}{"connectiontype"} eq "http"
$self->{"SIDS"}{$sid}{"connectiontype"} eq "tcpip"
$self->{"SIDS"}{$sid}{"connectiontype"} eq "http"
Truth table33%1/3
A or B
A= $self->{"SIDS"}{$sid}{"connectiontype"} eq "tcpip"B= $self->{"SIDS"}{$sid}{"connectiontype"} eq "http"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1102 | ($self->{SIDS}->{$sid}->{connectiontype} eq "http")) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1103 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1104 | 1 | $self->{SOCKETS}->{$self->{SIDS}->{$currsid}->{sock}} = $sid; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1105 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1106 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1107 | 1 | ▶ | if ($self->{SIDS}->{$sid}->{connectiontype} eq "stdinout") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1108 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1109 | 0 | $self->{SOCKETS}->{$self->{SIDS}->{$currsid}->{sock}} = $sid; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1110 | 0 | $self->{SOCKETS}->{*STDIN} = $sid; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1111 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1112 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1113 | 1 | ▶ | delete($self->{SIDS}->{$currsid}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1114 | unless $currsid eq $sid; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1115 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1116 | 1 | ▶ | if (exists($self->GetRoot($sid)->{version}) && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
exists $self->GetRoot($sid)->{"version"} and $self->GetRoot($sid)->{"version"} ne ""
MC/DC0%0/2
exists $self->GetRoot($sid)->{"version"} and $self->GetRoot($sid)->{"version"} ne ""
exists $self->GetRoot($sid)->{"version"}
$self->GetRoot($sid)->{"version"} ne ""
Truth table33%1/3
A and B
A= exists $self->GetRoot($sid)->{"version"}B= $self->GetRoot($sid)->{"version"} ne ""
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1117 | ($self->GetRoot($sid)->{version} ne "")) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1118 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1119 | 1 | ▶ | while(!$self->ReceivedStreamFeatures($sid)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1120 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1121 | 0 | $self->Process(1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1122 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1123 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1124 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1125 | 1 | return $self->GetRoot($sid); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1126 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1127 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1128 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1129 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1130 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1131 | =pod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1132 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1133 | =head2 OpenFile | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1134 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1135 | Starts the stream by opening a file and setting it up so that | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1136 | Process reads from the filehandle to get the incoming stream. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1137 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1138 | OpenFile(string) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1139 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1140 | Opens a filehandle to the argument specified, and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1141 | pretends that it is a stream. It will ignore the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1142 | outer tag, and not check if it was a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1143 | <stream:stream/>. This is useful for writing a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1144 | program that has to parse any XML file that is | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1145 | basically made up of small packets (like RDF). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1146 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1147 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1148 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1149 | sub OpenFile | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1150 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1151 | 4 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
OpenFile: called CC=11 SCAR=25.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1152 | 4 | my $file = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1153 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1154 | 4 | $self->debug(1,"OpenFile: file($file)"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1155 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1156 | 4 | $self->{SIDS}->{newconnection}->{connectiontype} = "file"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1157 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1158 | 4 | $self->{SIDS}->{newconnection}->{sock} = FileHandle->new($file); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1159 | 4 | $self->{SIDS}->{newconnection}->{sock}->autoflush(1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1160 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1161 | 4 | $self->RegisterPrefix("newconnection",&ConstXMLNS("stream"),"stream"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1162 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1163 | #--------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1164 | # Create the XML::Stream::Parser and register our callbacks | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1165 | #--------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1166 | 4 | my $weak = $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1167 | 4 | weaken $weak; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1168 | $self->{SIDS}->{newconnection}->{parser} = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1169 | 4 | XML::Stream::Parser->new(%{$self->{DEBUGARGS}}, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1170 | nonblocking=>$NONBLOCKING, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1171 | sid=>"newconnection", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1172 | style=>$self->{DATASTYLE}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1173 | Handlers=>{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1174 | 4 | ▶ | startElement=>sub{ $weak->_handle_root(@_) }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1175 | 0 | ▶ | endElement=>sub{ &{$HANDLERS{$weak->{DATASTYLE}}->{endElement}}($weak, @_) }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1176 | 0 | ▶ | characters=>sub{ &{$HANDLERS{$weak->{DATASTYLE}}->{characters}}($weak, @_) }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1177 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1178 | 4 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1179 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1180 | # select is not implemented for filehandles on win32 (see perlport) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1181 | # so we fake it out using XML::Stream::IO::Select::Win32 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1182 | 4 | ▶ | if ( $^O =~ /mswin32/i ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1183 | $self->{SIDS}->{newconnection}->{select} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1184 | = XML::Stream::IO::Select::Win32->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1185 | 0 | $self->{SIDS}->{newconnection}->{sock}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1186 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1187 | $self->{SELECT} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1188 | = XML::Stream::IO::Select::Win32->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1189 | 0 | $self->{SIDS}->{newconnection}->{sock}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1190 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1191 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1192 | $self->{SIDS}->{newconnection}->{select} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1193 | 4 | = IO::Select->new($self->{SIDS}->{newconnection}->{sock}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1194 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1195 | $self->{SELECT} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1196 | 4 | = IO::Select->new($self->{SIDS}->{newconnection}->{sock}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1197 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1198 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1199 | 4 | $self->{SIDS}->{newconnection}->{status} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1200 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1201 | 4 | my $buff = ""; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1202 | 4 | ▶ | while($self->{SIDS}->{newconnection}->{status} == 0) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1203 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1204 | 4 | $self->debug(5,"OpenFile: can_read(",join(",",$self->{SIDS}->{newconnection}->{select}->can_read(0)),")"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1205 | 4 | ▶ | if ($self->{SIDS}->{newconnection}->{select}->can_read(0)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1206 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1207 | 4 | ▶ | $self->{SIDS}->{newconnection}->{status} = -1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1208 | unless defined($buff = $self->Read("newconnection")); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1209 | 4 | ▶ | return unless($self->{SIDS}->{newconnection}->{status} == 0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1210 | 4 | ▶ | return unless($self->ParseStream("newconnection",$buff) == 1); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1211 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1212 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1213 | return if($self->{SIDS}->{newconnection}->{select}->has_exception(0) && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1214 | 4 | ▶ | $self->{SIDS}->{newconnection}->{sock}->error()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->{"SIDS"}{"newconnection"}{"select"}->has_exception(0) and $self->{"SIDS"}{"newconnection"}{"sock"}->error
MC/DC0%0/2
$self->{"SIDS"}{"newconnection"}{"select"}->has_exception(0) and $self->{"SIDS"}{"newconnection"}{"sock"}->error
$self->{"SIDS"}{"newconnection"}{"select"}->has_exception(0)
$self->{"SIDS"}{"newconnection"}{"sock"}->error
Truth table33%1/3
A and B
A= $self->{"SIDS"}{"newconnection"}{"select"}->has_exception(0)B= $self->{"SIDS"}{"newconnection"}{"sock"}->error
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1215 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1216 | 4 | ▶ | return if($self->{SIDS}->{newconnection}->{status} != 1); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1217 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1218 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1219 | 4 | my $sid = $self->NewSID(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1220 | 4 | foreach my $key (keys(%{$self->{SIDS}->{newconnection}})) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1221 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1222 | 44 | $self->{SIDS}->{$sid}->{$key} = $self->{SIDS}->{newconnection}->{$key}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1223 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1224 | 4 | $self->{SIDS}->{$sid}->{parser}->setSID($sid); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1225 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1226 | 4 | $self->{SOCKETS}->{$self->{SIDS}->{newconnection}->{sock}} = $sid; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1227 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1228 | 4 | delete($self->{SIDS}->{newconnection}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1229 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1230 | 4 | return $sid; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1231 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1232 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1233 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1234 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1235 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1236 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1237 | #+---------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1238 | #| | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1239 | #| Common Functions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1240 | #| | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1241 | #+---------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1242 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1243 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1244 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1245 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1246 | =pod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1247 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1248 | =head2 Disconnect | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1249 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1250 | Sends the closing XML tag and shuts down the socket. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1251 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1252 | Disconnect(sid) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1253 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1254 | Sends the proper closing XML tag and closes the specified socket down. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1255 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1256 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1257 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1258 | sub Disconnect | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1259 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1260 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Disconnect: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1261 | 0 | my $sid = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1262 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1263 | 0 | $self->Send($sid,"</stream:stream>"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1264 | close($self->{SIDS}->{$sid}->{sock}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1265 | if (($self->{SIDS}->{$sid}->{connectiontype} eq "tcpip") || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1266 | 0 | ▶ | ($self->{SIDS}->{$sid}->{connectiontype} eq "http")); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->{"SIDS"}{$sid}{"connectiontype"} eq "tcpip" or $self->{"SIDS"}{$sid}{"connectiontype"} eq "http"
MC/DC0%0/2
$self->{"SIDS"}{$sid}{"connectiontype"} eq "tcpip" or $self->{"SIDS"}{$sid}{"connectiontype"} eq "http"
$self->{"SIDS"}{$sid}{"connectiontype"} eq "tcpip"
$self->{"SIDS"}{$sid}{"connectiontype"} eq "http"
Truth table0%0/3
A or B
A= $self->{"SIDS"}{$sid}{"connectiontype"} eq "tcpip"B= $self->{"SIDS"}{$sid}{"connectiontype"} eq "http"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1267 | 0 | delete($self->{SOCKETS}->{$self->{SIDS}->{$sid}->{sock}}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1268 | 0 | foreach my $key (keys(%{$self->{SIDS}->{$sid}})) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1269 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1270 | 0 | delete($self->{SIDS}->{$sid}->{$key}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1271 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1272 | 0 | delete($self->{SIDS}->{$sid}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1273 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1274 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1275 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1276 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1277 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1278 | =pod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1279 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1280 | =head2 InitConnection | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1281 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1282 | Initialize the connection data structure | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1283 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1284 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1285 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1286 | sub InitConnection | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1287 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1288 | 1 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
InitConnection: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1289 | 1 | my $sid = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1290 | 1 | my $serverid = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1291 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1292 | #--------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1293 | # Set the default STATUS so that we can keep track of it throughout the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1294 | # session. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1295 | # 1 = no errors | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1296 | # 0 = no data has been received yet | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1297 | # -1 = error from handlers | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1298 | # -2 = error but keep the connection alive so that we can send some info. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1299 | #--------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1300 | 1 | $self->{SIDS}->{$sid}->{status} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1301 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1302 | #--------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1303 | # A storage place for when we don't have a callback registered and we need | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1304 | # to stockpile the nodes we receive until Process is called and we return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1305 | # them. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1306 | #--------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1307 | 1 | $self->{SIDS}->{$sid}->{nodes} = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1308 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1309 | #--------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1310 | # If there is an error on the stream, then we need a place to indicate that. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1311 | #--------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1312 | 1 | $self->{SIDS}->{$sid}->{streamerror} = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1313 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1314 | #--------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1315 | # Grab the init time so that we can keep the connection alive by sending " " | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1316 | #--------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1317 | 1 | $self->{SIDS}->{$sid}->{keepalive} = time; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1318 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1319 | #--------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1320 | # Keep track of the "server" we are connected to so we can check stuff | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1321 | # later. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1322 | #--------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1323 | 1 | $self->{SIDS}->{$sid}->{serverid} = $serverid; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1324 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1325 | #--------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1326 | # Mark the stream:features as MIA. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1327 | #--------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1328 | 1 | $self->{SIDS}->{$sid}->{streamfeatures}->{received} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1329 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1330 | #--------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1331 | # First acitivty is the connection... duh. =) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1332 | #--------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1333 | 1 | $self->MarkActivity($sid); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1334 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1335 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1336 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1337 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1338 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1339 | =pod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1340 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1341 | =head2 ParseStream | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1342 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1343 | Takes the incoming stream and makes sure that only full | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1344 | XML tags gets passed to the parser. If a full tag has not | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1345 | read yet, then the Stream saves the incomplete part and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1346 | sends the rest to the parser. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1347 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1348 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1349 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1350 | sub ParseStream | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1351 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1352 | 9 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ParseStream: called CC=3 SCAR=12.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1353 | 9 | my $sid = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1354 | 9 | my $stream = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1355 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1356 | 9 | ▶ | $stream = "" unless defined($stream); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1357 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1358 | 9 | $self->debug(3,"ParseStream: sid($sid) stream($stream)"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1359 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1360 | 9 | $self->{SIDS}->{$sid}->{parser}->parse($stream); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1361 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1362 | 9 | ▶ | if (exists($self->{SIDS}->{$sid}->{streamerror}->{type})) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1363 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1364 | 0 | $self->debug(3,"ParseStream: ERROR($self->{SIDS}->{$sid}->{streamerror}->{type})"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1365 | 0 | $self->SetErrorCode($sid,$self->{SIDS}->{$sid}->{streamerror}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1366 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1367 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1368 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1369 | 9 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1370 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1371 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1372 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1373 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1374 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1375 | =pod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1376 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1377 | =head2 Process | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1378 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1379 | Checks for data on the socket and returns a status code depending | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1380 | on if there was data or not. If a timeout is not defined in the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1381 | call then the timeout defined in Connect() is used. If a timeout | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1382 | of 0 is used then the call blocks until it gets some data, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1383 | otherwise it returns after the timeout period. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1384 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1385 | Process(integer) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1386 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1387 | Waits for data to be available on the socket. If | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1388 | a timeout is specified then the Process function | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1389 | waits that period of time before returning nothing. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1390 | If a timeout period is not specified then the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1391 | function blocks until data is received. The | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1392 | function returns a hash with session ids as the key, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1393 | and status values or data as the hash values. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1394 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1395 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1396 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1397 | sub Process | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1398 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1399 | 4 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Process: called CC=47 SCAR=53.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1400 | 4 | my $timeout = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1401 | 4 | ▶ | $timeout = "" unless defined($timeout); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1402 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1403 | 4 | $self->debug(4,"Process: timeout($timeout)"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1404 | #--------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1405 | # We need to keep track of what's going on in the function and tell the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1406 | # outside world about it so let's return something useful. We track this | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1407 | # information based on sid: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1408 | # -1 connection closed and error | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1409 | # 0 connection open but no data received. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1410 | # 1 connection open and data received. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1411 | # array connection open and the data that has been collected | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1412 | # over time (No CallBack specified) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1413 | #--------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1414 | 4 | my %status; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1415 | 4 | foreach my $sid (keys(%{$self->{SIDS}})) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1416 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1417 | 8 | ▶ | next if ($sid eq "default"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1418 | 4 | $self->debug(5,"Process: initialize sid($sid) status to 0"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1419 | 4 | $status{$sid} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1420 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1421 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1422 | #--------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1423 | # Either block until there is data and we have parsed it all, or wait a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1424 | # certain period of time and then return control to the user. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1425 | #--------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1426 | 4 | my $block = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1427 | 4 | ▶ | my $timeEnd = ($timeout eq "") ? "" : time + $timeout; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1428 | 4 | ▶ | while($block == 1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1429 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1430 | 4 | $self->debug(4,"Process: let's wait for data"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1431 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1432 | 4 | my $now = time; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1433 | 4 | ▶ | my $wait = (($timeEnd eq "") || ($timeEnd - $now > 10)) ? 10 : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$timeEnd eq "" or $timeEnd - $now > 10
MC/DC0%0/2
$timeEnd eq "" or $timeEnd - $now > 10
$timeEnd eq ""
$timeEnd - $now > 10
Truth table33%1/3
A or B
A= $timeEnd eq ""B= $timeEnd - $now > 10
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1434 | $timeEnd - $now; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1435 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1436 | 4 | foreach my $connection ($self->{SELECT}->can_read($wait)) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1437 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1438 | 4 | $self->debug(4,"Process: connection($connection)"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1439 | 4 | $self->debug(4,"Process: sid($self->{SOCKETS}->{$connection})"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1440 | 4 | $self->debug(4,"Process: connection_status($self->{SIDS}->{$self->{SOCKETS}->{$connection}}->{status})"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1441 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1442 | next unless (($self->{SIDS}->{$self->{SOCKETS}->{$connection}}->{status} == 1) || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1443 | 4 | ▶ | exists($self->{SIDS}->{$self->{SOCKETS}->{$connection}}->{activitytimeout})); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->{"SIDS"}{$self->{"SOCKETS"}{$connection}}{"status"} == 1 or exists $self->{"SIDS"}{$self->{"SOCKETS"}{$connection}}{"activitytimeout"}
MC/DC0%0/2
$self->{"SIDS"}{$self->{"SOCKETS"}{$connection}}{"status"} == 1 or exists $self->{"SIDS"}{$self->{"SOCKETS"}{$connection}}{"activitytimeout"}
$self->{"SIDS"}{$self->{"SOCKETS"}{$connection}}{"status"} == 1
exists $self->{"SIDS"}{$self->{"SOCKETS"}{$connection}}{"activitytimeout"}
Truth table33%1/3
A or B
A= $self->{"SIDS"}{$self->{"SOCKETS"}{$connection}}{"status"} == 1B= exists $self->{"SIDS"}{$self->{"SOCKETS"}{$connection}}{"activitytimeout"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1444 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1445 | 4 | my $processit = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1446 | 4 | ▶ | if (exists($self->{SIDS}->{server})) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1447 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1448 | 0 | foreach my $serverid (@{$self->{SIDS}->{server}}) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1449 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1450 | 0 | ▶ | if (exists($self->{SIDS}->{$serverid}->{sock}) && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
exists $self->{"SIDS"}{$serverid}{"sock"} and $connection == $self->{"SIDS"}{$serverid}{"sock"}
MC/DC0%0/2
exists $self->{"SIDS"}{$serverid}{"sock"} and $connection == $self->{"SIDS"}{$serverid}{"sock"}
exists $self->{"SIDS"}{$serverid}{"sock"}
$connection == $self->{"SIDS"}{$serverid}{"sock"}
Truth table0%0/3
A and B
A= exists $self->{"SIDS"}{$serverid}{"sock"}B= $connection == $self->{"SIDS"}{$serverid}{"sock"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1451 | ($connection == $self->{SIDS}->{$serverid}->{sock})) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1452 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1453 | 0 | my $sid = $self->ConnectionAccept($serverid); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1454 | 0 | $status{$sid} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1455 | 0 | $processit = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1456 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1457 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1458 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1459 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1460 | 4 | ▶ | if ($processit == 1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1461 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1462 | 4 | my $sid = $self->{SOCKETS}->{$connection}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1463 | 4 | $self->debug(4,"Process: there's something to read"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1464 | 4 | $self->debug(4,"Process: connection($connection) sid($sid)"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1465 | 4 | my $buff; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1466 | 4 | $self->debug(4,"Process: read"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1467 | 4 | $status{$sid} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1468 | 4 | ▶ | $self->{SIDS}->{$sid}->{status} = -1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1469 | if (!defined($buff = $self->Read($sid))); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1470 | 4 | ▶ | $buff = "" unless defined($buff); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1471 | 4 | $self->debug(4,"Process: connection_status($self->{SIDS}->{$sid}->{status})"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1472 | 4 | ▶ | $status{$sid} = -1 unless($self->{SIDS}->{$sid}->{status} == 1); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1473 | 4 | $self->debug(4,"Process: parse($buff)"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1474 | 4 | ▶ | $status{$sid} = -1 unless($self->ParseStream($sid,$buff) == 1); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1475 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1476 | 4 | $block = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1477 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1478 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1479 | 4 | ▶ | if ($timeout ne "") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1480 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1481 | 0 | ▶ | if (time >= $timeEnd) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1482 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1483 | 0 | $self->debug(4,"Process: Everyone out of the pool! Time to stop blocking."); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1484 | 0 | $block = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1485 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1486 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1487 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1488 | 4 | $self->debug(4,"Process: timeout($timeout)"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1489 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1490 | 4 | ▶ | if (exists($self->{CB}->{update})) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1491 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1492 | 0 | $self->debug(4,"Process: Calling user defined update function"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1493 | 0 | &{$self->{CB}->{update}}(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1494 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1495 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1496 | 4 | ▶ | $block = 1 if $self->{SELECT}->can_read(0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1497 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1498 | #--------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1499 | # Check for connections that need to be kept alive | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1500 | #--------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1501 | 4 | $self->debug(4,"Process: check for keepalives"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1502 | 4 | foreach my $sid (keys(%{$self->{SIDS}})) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1503 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1504 | 8 | ▶ | next if ($sid eq "default"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1505 | 4 | ▶ | next if ($sid =~ /^server/); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1506 | 4 | ▶ | next if ($status{$sid} == -1); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1507 | 0 | ▶ | if ((time - $self->{SIDS}->{$sid}->{keepalive}) > 10) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1508 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1509 | 0 | $self->IgnoreActivity($sid,1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1510 | 0 | ▶ | $self->{SIDS}->{$sid}->{status} = -1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1511 | if !defined($self->Send($sid," ")); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1512 | 0 | ▶ | $status{$sid} = -1 unless($self->{SIDS}->{$sid}->{status} == 1); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1513 | 0 | ▶ | if ($status{$sid} == -1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1514 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1515 | 0 | $self->debug(2,"Process: Keep-Alive failed. What the hell happened?!?!"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1516 | 0 | $self->debug(2,"Process: connection_status($self->{SIDS}->{$sid}->{status})"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1517 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1518 | 0 | $self->IgnoreActivity($sid,0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1519 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1520 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1521 | #--------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1522 | # Check for connections that have timed out. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1523 | #--------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1524 | 4 | $self->debug(4,"Process: check for timeouts"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1525 | 4 | foreach my $sid (keys(%{$self->{SIDS}})) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1526 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1527 | 8 | ▶ | next if ($sid eq "default"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1528 | 4 | ▶ | next if ($sid =~ /^server/); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1529 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1530 | 4 | ▶ | if (exists($self->{SIDS}->{$sid}->{activitytimeout})) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1531 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1532 | 0 | $self->debug(4,"Process: sid($sid) time(",time,") timeout($self->{SIDS}->{$sid}->{activitytimeout})"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1533 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1534 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1535 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1536 | 4 | $self->debug(4,"Process: sid($sid) time(",time,") timeout(undef)"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1537 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1538 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1539 | $self->Respond($sid) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1540 | 4 | ▶ | if (exists($self->{SIDS}->{$sid}->{activitytimeout}) && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
exists $self->{"SIDS"}{$sid}{"activitytimeout"} and defined $self->GetRoot($sid)
MC/DC0%0/2
exists $self->{"SIDS"}{$sid}{"activitytimeout"} and defined $self->GetRoot($sid)
exists $self->{"SIDS"}{$sid}{"activitytimeout"}
defined $self->GetRoot($sid)
Truth table33%1/3
A and B
A= exists $self->{"SIDS"}{$sid}{"activitytimeout"}B= defined $self->GetRoot($sid)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1541 | defined($self->GetRoot($sid))); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1542 | $self->Disconnect($sid) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1543 | if (exists($self->{SIDS}->{$sid}->{activitytimeout}) && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1544 | ((time - $self->{SIDS}->{$sid}->{activitytimeout}) > 10) && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1545 | 4 | ▶ | ($self->{SIDS}->{$sid}->{status} != 1)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
exists $self->{"SIDS"}{$sid}{"activitytimeout"} and time - $self->{"SIDS"}{$sid}{"activitytimeout"} > 10 and $self->{"SIDS"}{$sid}{"status"} != 1
exists $self->{"SIDS"}{$sid}{"activitytimeout"} and time - $self->{"SIDS"}{$sid}{"activitytimeout"} > 10
MC/DC0%0/3
exists $self->{"SIDS"}{$sid}{"activitytimeout"} and time - $self->{"SIDS"}{$sid}{"activitytimeout"} > 10 and $self->{"SIDS"}{$sid}{"status"} != 1
exists $self->{"SIDS"}{$sid}{"activitytimeout"}
time - $self->{"SIDS"}{$sid}{"activitytimeout"} > 10
$self->{"SIDS"}{$sid}{"status"} != 1
Truth table25%1/4
A and B and C
A= exists $self->{"SIDS"}{$sid}{"activitytimeout"}B= time - $self->{"SIDS"}{$sid}{"activitytimeout"} > 10C= $self->{"SIDS"}{$sid}{"status"} != 1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1546 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1547 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1548 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1549 | #--------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1550 | # If any of the connections have status == -1 then return so that the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1551 | # user can handle it. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1552 | #--------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1553 | 4 | foreach my $sid (keys(%status)) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1554 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1555 | 4 | ▶ | if ($status{$sid} == -1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1556 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1557 | 4 | $self->debug(4,"Process: sid($sid) is broken... let's tell someone and watch it hit the fan... =)"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1558 | 4 | $block = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1559 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1560 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1561 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1562 | 4 | $self->debug(2,"Process: block($block)"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1563 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1564 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1565 | #--------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1566 | # If the Select has an error then shut this party down. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1567 | #--------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1568 | 4 | foreach my $connection ($self->{SELECT}->has_exception(0)) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1569 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1570 | 0 | $self->debug(4,"Process: has_exception sid($self->{SOCKETS}->{$connection})"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1571 | 0 | $status{$self->{SOCKETS}->{$connection}} = -1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1572 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1573 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1574 | #--------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1575 | # If there are data structures that have not been collected return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1576 | # those, otherwise return the status which indicates if nodes were read or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1577 | # not. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1578 | #--------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1579 | 4 | foreach my $sid (keys(%status)) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1580 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1581 | $status{$sid} = $self->{SIDS}->{$sid}->{nodes} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1582 | if (($status{$sid} == 1) && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1583 | 4 | ▶ | ($#{$self->{SIDS}->{$sid}->{nodes}} > -1)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$status{$sid} == 1 and $#{$$self{"SIDS"}{$sid}{"nodes"};} > -1
MC/DC0%0/2
$status{$sid} == 1 and $#{$$self{"SIDS"}{$sid}{"nodes"};} > -1
$status{$sid} == 1
$#{$$self{"SIDS"}{$sid}{"nodes"};} > -1
Truth table33%1/3
A and B
A= $status{$sid} == 1B= $#{$$self{"SIDS"}{$sid}{"nodes"};} > -1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1584 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1585 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1586 | 4 | return %status; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1587 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1588 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1589 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1590 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1591 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1592 | =pod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1593 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1594 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1595 | =head2 Read | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1596 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1597 | Takes the data from the server and returns a string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1598 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1599 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1600 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1601 | sub Read | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1602 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1603 | 9 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Read: called CC=15 SCAR=29.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1604 | 9 | my $sid = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1605 | 9 | my $buff; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1606 | 9 | my $status = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1607 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1608 | 9 | $self->debug(3,"Read: sid($sid)"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1609 | 9 | $self->debug(3,"Read: connectionType($self->{SIDS}->{$sid}->{connectiontype})"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1610 | 9 | $self->debug(3,"Read: socket($self->{SIDS}->{$sid}->{sock})"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1611 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1612 | 9 | ▶ | return if ($self->{SIDS}->{$sid}->{status} == -1); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1613 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1614 | 9 | ▶ | if (!defined($self->{SIDS}->{$sid}->{sock})) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1615 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1616 | 0 | $self->{SIDS}->{$sid}->{status} = -1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1617 | 0 | $self->SetErrorCode($sid,"Socket does not defined."); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1618 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1619 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1620 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1621 | 9 | $self->{SIDS}->{$sid}->{sock}->flush(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1622 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1623 | $status = $self->{SIDS}->{$sid}->{sock}->sysread($buff,4*POSIX::BUFSIZ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1624 | if (($self->{SIDS}->{$sid}->{connectiontype} eq "tcpip") || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1625 | ($self->{SIDS}->{$sid}->{connectiontype} eq "http") || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1626 | 9 | ▶ | ($self->{SIDS}->{$sid}->{connectiontype} eq "file")); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
$self->{"SIDS"}{$sid}{"connectiontype"} eq "tcpip" or $self->{"SIDS"}{$sid}{"connectiontype"} eq "http" or $self->{"SIDS"}{$sid}{"connectiontype"} eq "file"
$self->{"SIDS"}{$sid}{"connectiontype"} eq "tcpip" or $self->{"SIDS"}{$sid}{"connectiontype"} eq "http"
MC/DC0%0/3
$self->{"SIDS"}{$sid}{"connectiontype"} eq "tcpip" or $self->{"SIDS"}{$sid}{"connectiontype"} eq "http" or $self->{"SIDS"}{$sid}{"connectiontype"} eq "file"
$self->{"SIDS"}{$sid}{"connectiontype"} eq "tcpip"
$self->{"SIDS"}{$sid}{"connectiontype"} eq "http"
$self->{"SIDS"}{$sid}{"connectiontype"} eq "file"
Truth table50%2/4
A or B or C
A= $self->{"SIDS"}{$sid}{"connectiontype"} eq "tcpip"B= $self->{"SIDS"}{$sid}{"connectiontype"} eq "http"C= $self->{"SIDS"}{$sid}{"connectiontype"} eq "file"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1627 | $status = sysread(STDIN,$buff,1024) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1628 | 9 | ▶ | if ($self->{SIDS}->{$sid}->{connectiontype} eq "stdinout"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1629 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1630 | 9 | ▶ | $buff =~ s/^HTTP[\S\s]+\n\n// if ($self->{SIDS}->{$sid}->{connectiontype} eq "http"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1631 | 9 | $self->debug(1,"Read: buff($buff)"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1632 | 9 | ▶ | $self->debug(3,"Read: status($status)") if defined($status); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1633 | 9 | ▶ | $self->debug(3,"Read: status(undef)") unless defined($status); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1634 | $self->{SIDS}->{$sid}->{keepalive} = time | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1635 | 9 | ▶ | unless (($buff eq "") || !defined($status) || ($status == 0)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
$buff eq "" or not defined $status or $status == 0
$buff eq "" or not defined $status
MC/DC33%1/3
$buff eq "" or not defined $status or $status == 0
$buff eq ""
not defined $status
$status == 0
Truth table50%2/4
A or not(B) or C
A= $buff eq ""B= not defined $statusC= $status == 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1636 | 9 | ▶ | if (defined($status) && ($status != 0)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $status and $status != 0
MC/DC50%1/2
defined $status and $status != 0
defined $status
$status != 0
Truth table66%2/3
A and B
A= defined $statusB= $status != 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1637 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1638 | 5 | $buff = Encode::decode_utf8($buff); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1639 | 5 | return $buff; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1640 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1641 | #return $buff unless (!defined($status) || ($status == 0)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1642 | 4 | $self->debug(1,"Read: ERROR"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1643 | 4 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1644 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1645 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1646 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1647 | ############################################################################# | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1648 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1649 | =pod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1650 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1651 | =head2 Send | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1652 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1653 | Takes the data string and sends it to the server | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1654 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1655 | Send(sid, string); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1656 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1657 | Sends the string over the specified connection as is. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1658 | This does no checking if valid XML was sent or not. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1659 | Best behavior when sending information. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1660 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1661 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1662 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1663 | sub Send | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1664 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1665 | 1 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Send: called CC=7 SCAR=21.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1666 | 1 | my $sid = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1667 | 1 | $self->debug(1,"Send: (@_)"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1668 | 1 | $self->debug(3,"Send: sid($sid)"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1669 | 1 | $self->debug(3,"Send: status($self->{SIDS}->{$sid}->{status})"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1670 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1671 | 1 | $self->{SIDS}->{$sid}->{keepalive} = time; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1672 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1673 | 1 | ▶ | return if ($self->{SIDS}->{$sid}->{status} == -1); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1674 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1675 | 1 | ▶ | if (!defined($self->{SIDS}->{$sid}->{sock})) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1676 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1677 | 0 | $self->debug(3,"Send: socket not defined"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1678 | 0 | $self->{SIDS}->{$sid}->{status} = -1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1679 | 0 | $self->SetErrorCode($sid,"Socket not defined."); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1680 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1681 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1682 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1683 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1684 | 1 | $self->debug(3,"Send: socket($self->{SIDS}->{$sid}->{sock})"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1685 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1686 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1687 | 1 | $self->{SIDS}->{$sid}->{sock}->flush(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1688 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1689 | 1 | ▶ | if ($self->{SIDS}->{$sid}->{select}->can_write(0)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1690 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1691 | 1 | $self->debug(3,"Send: can_write"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1692 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1693 | 1 | $self->{SENDSTRING} = Encode::encode_utf8(join("",@_)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1694 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1695 | 1 | $self->{SENDWRITTEN} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1696 | 1 | $self->{SENDOFFSET} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1697 | 1 | $self->{SENDLENGTH} = length($self->{SENDSTRING}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1698 | 1 | ▶ | while ($self->{SENDLENGTH}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1699 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1700 | 1 | $self->{SENDWRITTEN} = $self->{SIDS}->{$sid}->{sock}->syswrite($self->{SENDSTRING},$self->{SENDLENGTH},$self->{SENDOFFSET}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1701 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1702 | 1 | ▶ | if (!defined($self->{SENDWRITTEN})) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1703 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1704 | 0 | $self->debug(4,"Send: SENDWRITTEN(undef)"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1705 | 0 | $self->debug(4,"Send: Ok... what happened? Did we lose the connection?"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1706 | 0 | $self->{SIDS}->{$sid}->{status} = -1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1707 | 0 | $self->SetErrorCode($sid,"Socket died for an unknown reason."); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1708 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1709 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1710 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1711 | 1 | $self->debug(4,"Send: SENDWRITTEN($self->{SENDWRITTEN})"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1712 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1713 | 1 | $self->{SENDLENGTH} -= $self->{SENDWRITTEN}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1714 | 1 | $self->{SENDOFFSET} += $self->{SENDWRITTEN}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1715 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1716 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1717 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1718 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1719 | 0 | $self->debug(3,"Send: can't write..."); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1720 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1721 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1722 | 1 | ▶ | return if($self->{SIDS}->{$sid}->{select}->has_exception(0)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1723 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1724 | 1 | $self->debug(3,"Send: no exceptions"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1725 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1726 | 1 | $self->{SIDS}->{$sid}->{keepalive} = time; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1727 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1728 | 1 | $self->MarkActivity($sid); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1729 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1730 | 1 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1731 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1732 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1733 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1734 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1735 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1736 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1737 | #+---------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1738 | #| | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1739 | #| Feature Functions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1740 | #| | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1741 | #+---------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1742 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1743 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1744 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1745 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1746 | =pod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1747 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1748 | =head2 ProcessStreamFeatures | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1749 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1750 | Process the <stream:featutres/> block. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1751 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1752 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1753 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1754 | sub ProcessStreamFeatures | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1755 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1756 | 1 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ProcessStreamFeatures: called CC=8 SCAR=24.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1757 | 1 | my $sid = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1758 | 1 | my $node = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1759 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1760 | 1 | $self->{SIDS}->{$sid}->{streamfeatures}->{received} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1761 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1762 | #------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1763 | # SASL - 1.0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1764 | #------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1765 | 1 | my @sasl = &XPath($node,'*[@xmlns="'.&ConstXMLNS('xmpp-sasl').'"]'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1766 | 1 | ▶ | if ($#sasl > -1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1767 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1768 | 0 | ▶ | if (&XPath($sasl[0],"name()") eq "mechanisms") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1769 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1770 | 0 | my @mechanisms = &XPath($sasl[0],"mechanism/text()"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1771 | 0 | $self->{SIDS}->{$sid}->{streamfeatures}->{'xmpp-sasl'} = \@mechanisms; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1772 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1773 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1774 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1775 | #------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1776 | # XMPP-TLS - 1.0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1777 | #------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1778 | 1 | my @tls = &XPath($node,'*[@xmlns="'.&ConstXMLNS('xmpp-tls').'"]'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1779 | 1 | ▶ | if ($#tls > -1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1780 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1781 | 1 | ▶ | if (&XPath($tls[0],"name()") eq "starttls") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1782 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1783 | 1 | $self->{SIDS}->{$sid}->{streamfeatures}->{'xmpp-tls'} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1784 | 1 | my @required = &XPath($tls[0],"required"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1785 | 1 | ▶ | if ($#required > -1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1786 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1787 | 1 | $self->{SIDS}->{$sid}->{streamfeatures}->{'xmpp-tls'} = "required"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1788 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1789 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1790 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1791 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1792 | #------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1793 | # XMPP-Bind - 1.0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1794 | #------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1795 | 1 | my @bind = &XPath($node,'*[@xmlns="'.&ConstXMLNS('xmpp-bind').'"]'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1796 | 1 | ▶ | if ($#bind > -1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1797 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1798 | 0 | $self->{SIDS}->{$sid}->{streamfeatures}->{'xmpp-bind'} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1799 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1800 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1801 | #------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1802 | # XMPP-Session - 1.0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1803 | #------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1804 | 1 | my @session = &XPath($node,'*[@xmlns="'.&ConstXMLNS('xmpp-session').'"]'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1805 | 1 | ▶ | if ($#session > -1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1806 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1807 | 0 | $self->{SIDS}->{$sid}->{streamfeatures}->{'xmpp-session'} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1808 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1809 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1810 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1811 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1812 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1813 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1814 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1815 | =pod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1816 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1817 | =head2 GetStreamFeature | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1818 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1819 | Return the value of the stream feature (if any). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1820 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1821 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1822 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1823 | sub GetStreamFeature | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1824 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1825 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
GetStreamFeature: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1826 | 0 | my $sid = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1827 | 0 | my $feature = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1828 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1829 | 0 | ▶ | return unless exists($self->{SIDS}->{$sid}->{streamfeatures}->{$feature}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1830 | 0 | return $self->{SIDS}->{$sid}->{streamfeatures}->{$feature}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1831 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1832 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1833 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1834 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1835 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1836 | =pod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1837 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1838 | =head2 ReceivedStreamFeatures | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1839 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1840 | Have we received the stream:features yet? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1841 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1842 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1843 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1844 | sub ReceivedStreamFeatures | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1845 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1846 | 1 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ReceivedStreamFeatures: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1847 | 1 | my $sid = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1848 | 1 | my $feature = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1849 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1850 | 1 | return $self->{SIDS}->{$sid}->{streamfeatures}->{received}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1851 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1852 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1853 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1854 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1855 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1856 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1857 | #+---------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1858 | #| | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1859 | #| TLS Functions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1860 | #| | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1861 | #+---------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1862 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1863 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1864 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1865 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1866 | =pod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1867 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1868 | =head2 ProcessTLSPacket | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1869 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1870 | Process a TLS based packet. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1871 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1872 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1873 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1874 | sub ProcessTLSPacket | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1875 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1876 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ProcessTLSPacket: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1877 | 0 | my $sid = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1878 | 0 | my $node = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1879 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1880 | 0 | my $tag = &XPath($node,"name()"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1881 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1882 | 0 | ▶ | if ($tag eq "failure") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1883 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1884 | 0 | $self->TLSClientFailure($sid,$node); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1885 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1886 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1887 | 0 | ▶ | if ($tag eq "proceed") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1888 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1889 | 0 | $self->TLSClientProceed($sid,$node); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1890 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1891 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1892 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1893 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1894 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1895 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1896 | =pod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1897 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1898 | =head2 StartTLS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1899 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1900 | Client function to have the socket start TLS. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1901 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1902 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1903 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1904 | sub StartTLS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1905 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1906 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
StartTLS: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1907 | 0 | my $sid = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1908 | 0 | my $timeout = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1909 | 0 | ▶ | $timeout = 120 unless defined($timeout); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1910 | 0 | ▶ | $timeout = 120 if ($timeout eq ""); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1911 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1912 | 0 | $self->TLSStartTLS($sid); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1913 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1914 | 0 | my $endTime = time + $timeout; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1915 | 0 | ▶ | while(!$self->TLSClientDone($sid) && ($endTime >= time)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not $self->TLSClientDone($sid) and $endTime >= time
MC/DC0%0/2
not $self->TLSClientDone($sid) and $endTime >= time
not $self->TLSClientDone($sid)
$endTime >= time
Truth table0%0/3
not(A) and B
A= not $self->TLSClientDone($sid)B= $endTime >= time
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1916 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1917 | 0 | $self->Process(1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1918 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1919 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1920 | 0 | ▶ | if (!$self->TLSClientSecure($sid)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1921 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1922 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1923 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1924 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1925 | 0 | return $self->OpenStream($sid,$timeout); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1926 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1927 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1928 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1929 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1930 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1931 | =pod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1932 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1933 | =head2 TLSStartTLS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1934 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1935 | Send a <starttls/> in the TLS namespace. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1936 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1937 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1938 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1939 | sub TLSStartTLS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1940 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1941 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
TLSStartTLS: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1942 | 0 | my $sid = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1943 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1944 | 0 | $self->Send($sid,"<starttls xmlns='".&ConstXMLNS('xmpp-tls')."'/>"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1945 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1946 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1947 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1948 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1949 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1950 | =pod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1951 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1952 | =head2 TLSClientProceed | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1953 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1954 | Handle a <proceed/> packet. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1955 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1956 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1957 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1958 | sub TLSClientProceed | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1959 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1960 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
TLSClientProceed: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1961 | 0 | my $sid = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1962 | 0 | my $node = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1963 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1964 | 0 | $self->debug(1,"TLSClientProceed: Convert normal socket to SSL"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1965 | 0 | $self->debug(1,"TLSClientProceed: sock($self->{SIDS}->{$sid}->{sock})"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1966 | 0 | ▶ | if (!$self->LoadSSL()) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1967 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1968 | 0 | $self->{SIDS}->{$sid}->{tls}->{error} = "Could not load IO::Socket::SSL."; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1969 | 0 | $self->{SIDS}->{$sid}->{tls}->{done} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1970 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1971 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1972 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1973 | IO::Socket::SSL->start_SSL( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1974 | $self->{SIDS}->{$sid}->{sock}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1975 | $self->{SIDS}->{$sid}->{ssl_params} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1976 | 0 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1977 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1978 | 0 | $self->debug(1,"TLSClientProceed: ssl_sock($self->{SIDS}->{$sid}->{sock})"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1979 | $self->debug(1,"TLSClientProceed: SSL: We are secure") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1980 | 0 | ▶ | if ($self->{SIDS}->{$sid}->{sock}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1981 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1982 | 0 | $self->{SIDS}->{$sid}->{tls}->{done} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1983 | 0 | $self->{SIDS}->{$sid}->{tls}->{secure} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1984 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1985 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1986 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1987 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1988 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1989 | =pod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1990 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1991 | =head2 TLSClientSecure | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1992 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1993 | Return 1 if the socket is secure, 0 otherwise. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1994 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1995 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1996 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1997 | sub TLSClientSecure | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1998 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1999 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
TLSClientSecure: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2000 | 0 | my $sid = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2001 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2002 | 0 | return $self->{SIDS}->{$sid}->{tls}->{secure}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2003 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2004 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2005 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2006 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2007 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2008 | =pod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2009 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2010 | =head2 TLSClientDone | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2011 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2012 | Return 1 if the TLS process is done | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2013 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2014 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2015 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2016 | sub TLSClientDone | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2017 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2018 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
TLSClientDone: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2019 | 0 | my $sid = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2020 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2021 | 0 | return $self->{SIDS}->{$sid}->{tls}->{done}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2022 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2023 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2024 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2025 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2026 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2027 | =pod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2028 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2029 | =head2 TLSClientError | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2030 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2031 | return the TLS error if any | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2032 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2033 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2034 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2035 | sub TLSClientError | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2036 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2037 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
TLSClientError: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2038 | 0 | my $sid = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2039 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2040 | 0 | return $self->{SIDS}->{$sid}->{tls}->{error}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2041 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2042 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2043 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2044 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2045 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2046 | =pod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2047 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2048 | =head2 TLSClientFailure | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2049 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2050 | Handle a <failure/> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2051 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2052 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2053 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2054 | sub TLSClientFailure | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2055 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2056 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
TLSClientFailure: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2057 | 0 | my $sid = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2058 | 0 | my $node = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2059 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2060 | 0 | my $type = &XPath($node,"*/name()"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2061 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2062 | 0 | $self->{SIDS}->{$sid}->{tls}->{error} = $type; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2063 | 0 | $self->{SIDS}->{$sid}->{tls}->{done} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2064 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2065 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2066 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2067 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2068 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2069 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2070 | =pod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2071 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2072 | =head2 TLSFailure | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2073 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2074 | Send a <failure/> in the TLS namespace | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2075 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2076 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2077 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2078 | sub TLSFailure | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2079 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2080 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
TLSFailure: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2081 | 0 | my $sid = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2082 | 0 | my $type = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2083 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2084 | 0 | $self->Send($sid,"<failure xmlns='".&ConstXMLNS('xmpp-tls')."'><${type}/></failure>"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2085 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2086 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2087 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2088 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2089 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2090 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2091 | #+---------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2092 | #| | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2093 | #| SASL Functions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2094 | #| | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2095 | #+---------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2096 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2097 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2098 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2099 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2100 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2101 | =pod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2102 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2103 | =head2 ProcessSASLPacket | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2104 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2105 | Process a SASL based packet. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2106 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2107 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2108 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2109 | sub ProcessSASLPacket | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2110 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2111 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ProcessSASLPacket: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2112 | 0 | my $sid = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2113 | 0 | my $node = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2114 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2115 | 0 | my $tag = &XPath($node,"name()"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2116 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2117 | 0 | ▶ | if ($tag eq "challenge") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2118 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2119 | 0 | $self->SASLAnswerChallenge($sid,$node); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2120 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2121 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2122 | 0 | ▶ | if ($tag eq "failure") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2123 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2124 | 0 | $self->SASLClientFailure($sid,$node); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2125 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2126 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2127 | 0 | ▶ | if ($tag eq "success") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2128 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2129 | 0 | $self->SASLClientSuccess($sid,$node); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2130 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2131 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2132 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2133 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2134 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2135 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2136 | =pod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2137 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2138 | =head2 SASLAnswerChallenge | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2139 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2140 | When we get a <challenge/> we need to do the grunt | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2141 | work to return a <response/>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2142 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2143 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2144 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2145 | sub SASLAnswerChallenge | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2146 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2147 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
SASLAnswerChallenge: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2148 | 0 | my $sid = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2149 | 0 | my $node = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2150 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2151 | 0 | my $challenge64 = &XPath($node,"text()"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2152 | 0 | my $challenge = MIME::Base64::decode_base64($challenge64); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2153 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2154 | #------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2155 | # As far as I can tell, if the challenge contains rspauth, then we authed. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2156 | # If you try to send that to Authen::SASL, it will spew warnings about | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2157 | # the missing qop, nonce, etc... However, in order for jabberd2 to think | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2158 | # that you answered, you have to send back an empty response. Not sure | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2159 | # which approach is right... So let's hack for now. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2160 | #------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2161 | 0 | my $response = ""; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2162 | 0 | ▶ | if ($challenge !~ /rspauth\=/) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2163 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2164 | 0 | $response = $self->{SIDS}->{$sid}->{sasl}->{client}->client_step($challenge); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2165 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2166 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2167 | 0 | my $response64 = MIME::Base64::encode_base64($response,""); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2168 | 0 | $self->SASLResponse($sid,$response64); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2169 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2170 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2171 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2172 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2173 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2174 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2175 | =pod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2176 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2177 | =head2 SASLAuth | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2178 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2179 | Send an <auth/> in the SASL namespace | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2180 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2181 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2182 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2183 | sub SASLAuth | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2184 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2185 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
SASLAuth: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2186 | 0 | my $sid = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2187 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2188 | 0 | my $first_step = $self->{SIDS}->{$sid}->{sasl}->{client}->client_start(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2189 | 0 | my $first_step64 = MIME::Base64::encode_base64($first_step,""); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2190 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2191 | $self->Send($sid, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2192 | "<auth xmlns='" . &ConstXMLNS('xmpp-sasl') . | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2193 | 0 | "' mechanism='" . $self->{SIDS}->{$sid}->{sasl}->{client}->mechanism() . | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2194 | # from http://blogs.perl.org/users/marco_fontani/2010/03/google-talk-with-perl.html | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2195 | # not yet in use | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2196 | # "' " . | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2197 | # q{xmlns:ga='http://www.google.com/talk/protocol/auth' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2198 | # ga:client-uses-full-bind-result='true'} . # JID | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2199 | "'>" . $first_step64 . "</auth>"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2200 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2201 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2202 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2203 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2204 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2205 | =pod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2206 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2207 | =head2 SASLChallenge | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2208 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2209 | Send a <challenge/> in the SASL namespace | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2210 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2211 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2212 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2213 | sub SASLChallenge | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2214 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2215 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
SASLChallenge: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2216 | 0 | my $sid = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2217 | 0 | my $challenge = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2218 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2219 | 0 | $self->Send($sid,"<challenge xmlns='".&ConstXMLNS('xmpp-sasl')."'>${challenge}</challenge>"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2220 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2221 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2222 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2223 | ############################################################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2224 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2225 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2226 | =pod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2227 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2228 | =head2 SASLClient | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2229 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2230 | This is a helper function to perform all of the required steps for doing SASL with the server. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2231 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2232 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2233 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2234 | sub SASLClient | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2235 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2236 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
SASLClient: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2237 | 0 | my $sid = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2238 | 0 | my $username = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2239 | 0 | my $password = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2240 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2241 | 0 | my $mechanisms = $self->GetStreamFeature($sid,"xmpp-sasl"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2242 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2243 | 0 | ▶ | return unless defined($mechanisms); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2244 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2245 | # Here we assume that if 'to' is available, then a domain is being | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2246 | # specified that does not match the hostname of the jabber server | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2247 | # and that we should use that to form the bare JID for SASL auth. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2248 | my $domain .= $self->{SIDS}->{$sid}->{to} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2249 | ? $self->{SIDS}->{$sid}->{to} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2250 | 0 | ▶ | : $self->{SIDS}->{$sid}->{hostname}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2251 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2252 | 0 | my $authname = $username . '@' . $domain; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2253 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2254 | 0 | my $sasl = Authen::SASL->new(mechanism=>join(" ",@{$mechanisms}), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2255 | callback=>{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2256 | authname => $authname, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2257 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2258 | user => $username, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2259 | pass => $password | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2260 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2261 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2262 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2263 | 0 | $self->{SIDS}->{$sid}->{sasl}->{client} = $sasl->client_new('xmpp', $domain); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2264 | 0 | $self->{SIDS}->{$sid}->{sasl}->{username} = $username; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2265 | 0 | $self->{SIDS}->{$sid}->{sasl}->{password} = $password; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2266 | 0 | $self->{SIDS}->{$sid}->{sasl}->{authed} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2267 | 0 | $self->{SIDS}->{$sid}->{sasl}->{done} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2268 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2269 | 0 | $self->SASLAuth($sid); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2270 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2271 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2272 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2273 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2274 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2275 | =pod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2276 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2277 | =head2 SASLClientAuthed | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2278 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2279 | Return 1 if we authed via SASL, 0 otherwise | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2280 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2281 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2282 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2283 | sub SASLClientAuthed | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2284 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2285 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
SASLClientAuthed: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2286 | 0 | my $sid = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2287 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2288 | 0 | return $self->{SIDS}->{$sid}->{sasl}->{authed}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2289 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2290 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2291 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2292 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2293 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2294 | =pod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2295 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2296 | =head2 SASLClientDone | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2297 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2298 | Return 1 if the SASL process is finished | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2299 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2300 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2301 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2302 | sub SASLClientDone | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2303 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2304 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
SASLClientDone: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2305 | 0 | my $sid = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2306 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2307 | 0 | return $self->{SIDS}->{$sid}->{sasl}->{done}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2308 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2309 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2310 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2311 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2312 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2313 | =pod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2314 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2315 | =head2 SASLClientError | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2316 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2317 | Return the error if any | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2318 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2319 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2320 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2321 | sub SASLClientError | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2322 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2323 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
SASLClientError: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2324 | 0 | my $sid = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2325 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2326 | 0 | return $self->{SIDS}->{$sid}->{sasl}->{error}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2327 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2328 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2329 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2330 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2331 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2332 | =pod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2333 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2334 | =head2 SASLClientFailure | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2335 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2336 | Handle a received <failure/> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2337 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2338 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2339 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2340 | sub SASLClientFailure | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2341 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2342 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
SASLClientFailure: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2343 | 0 | my $sid = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2344 | 0 | my $node = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2345 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2346 | 0 | my $type = &XPath($node,"*/name()"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2347 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2348 | 0 | $self->{SIDS}->{$sid}->{sasl}->{error} = $type; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2349 | 0 | $self->{SIDS}->{$sid}->{sasl}->{done} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2350 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2351 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2352 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2353 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2354 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2355 | =pod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2356 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2357 | =head2 SASLClientSuccess | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2358 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2359 | handle a received <success/> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2360 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2361 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2362 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2363 | sub SASLClientSuccess | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2364 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2365 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
SASLClientSuccess: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2366 | 0 | my $sid = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2367 | 0 | my $node = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2368 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2369 | 0 | $self->{SIDS}->{$sid}->{sasl}->{authed} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2370 | 0 | $self->{SIDS}->{$sid}->{sasl}->{done} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2371 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2372 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2373 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2374 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2375 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2376 | =pod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2377 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2378 | =head2 SASLFailure | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2379 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2380 | Send a <failure/> tag in the SASL namespace | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2381 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2382 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2383 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2384 | sub SASLFailure | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2385 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2386 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
SASLFailure: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2387 | 0 | my $sid = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2388 | 0 | my $type = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2389 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2390 | 0 | $self->Send($sid,"<failure xmlns='".&ConstXMLNS('xmpp-sasl')."'><${type}/></failure>"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2391 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2392 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2393 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2394 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2395 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2396 | =pod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2397 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2398 | =head2 SASLResponse | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2399 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2400 | Send a <response/> tag in the SASL namespace | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2401 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2402 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2403 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2404 | sub SASLResponse | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2405 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2406 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
SASLResponse: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2407 | 0 | my $sid = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2408 | 0 | my $response = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2409 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2410 | 0 | $self->Send($sid,"<response xmlns='".&ConstXMLNS('xmpp-sasl')."'>${response}</response>"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2411 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2412 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2413 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2414 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2415 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2416 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2417 | #+---------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2418 | #| | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2419 | #| Packet Handlers | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2420 | #| | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2421 | #+---------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2422 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2423 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2424 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2425 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2426 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2427 | # ProcessStreamPacket - process the <stream:XXXX/> packet | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2428 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2429 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2430 | sub ProcessStreamPacket | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2431 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2432 | 1 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ProcessStreamPacket: called CC=3 SCAR=11.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2433 | 1 | my $sid = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2434 | 1 | my $node = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2435 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2436 | 1 | my $tag = &XPath($node,"name()"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2437 | 1 | my $stream_prefix = $self->StreamPrefix($sid); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2438 | 1 | my ($type) = ($tag =~ /^${stream_prefix}\:(.+)$/); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2439 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2440 | 1 | ▶ | $self->ProcessStreamError($sid,$node) if ($type eq "error"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2441 | 1 | ▶ | $self->ProcessStreamFeatures($sid,$node) if ($type eq "features"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2442 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2443 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2444 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2445 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2446 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2447 | # _handle_root - handles a root tag and checks that it is a stream:stream tag | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2448 | # with the proper namespace. If not then it sets the STATUS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2449 | # to -1 and let's the outer code know that an error occurred. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2450 | # Then it changes the Start tag handlers to the methond listed | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2451 | # in $self->{DATASTYLE} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2452 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2453 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2454 | sub _handle_root | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2455 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2456 | 5 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_handle_root: called CC=10 SCAR=24.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2457 | 5 | my ($sax, $tag, %att) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2458 | 5 | my $sid = $sax->getSID(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2459 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2460 | 5 | $self->debug(2,"_handle_root: sid($sid) sax($sax) tag($tag) att(",%att,")"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2461 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2462 | 5 | $self->{SIDS}->{$sid}->{rootTag} = $tag; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2463 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2464 | 5 | ▶ | if ($self->{SIDS}->{$sid}->{connectiontype} ne "file") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2465 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2466 | #--------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2467 | # Make sure we are receiving a valid stream on the same namespace. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2468 | #--------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2469 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2470 | 1 | $self->debug(3,"_handle_root: ($self->{SIDS}->{$self->{SIDS}->{$sid}->{serverid}}->{namespace})"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2471 | $self->{SIDS}->{$sid}->{status} = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2472 | ((($tag eq "stream:stream") && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2473 | exists($att{'xmlns'}) && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2474 | ($att{'xmlns'} eq $self->{SIDS}->{$self->{SIDS}->{$sid}->{serverid}}->{namespace}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2475 | 1 | ▶ | ) ? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
$tag eq "stream:stream" and exists $att{"xmlns"} and $att{"xmlns"} eq $self->{"SIDS"}{$self->{"SIDS"}{$sid}{"serverid"}}{"namespace"}
$tag eq "stream:stream" and exists $att{"xmlns"}
MC/DC0%0/3
$tag eq "stream:stream" and exists $att{"xmlns"} and $att{"xmlns"} eq $self->{"SIDS"}{$self->{"SIDS"}{$sid}{"serverid"}}{"namespace"}
$tag eq "stream:stream"
exists $att{"xmlns"}
$att{"xmlns"} eq $self->{"SIDS"}{$self->{"SIDS"}{$sid}{"serverid"}}{"namespace"}
Truth table25%1/4
A and B and C
A= $tag eq "stream:stream"B= exists $att{"xmlns"}C= $att{"xmlns"} eq $self->{"SIDS"}{$self->{"SIDS"}{$sid}{"serverid"}}{"namespace"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2476 | 1 : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2477 | -1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2478 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2479 | 1 | $self->debug(3,"_handle_root: status($self->{SIDS}->{$sid}->{status})"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2480 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2481 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2482 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2483 | 4 | $self->{SIDS}->{$sid}->{status} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2484 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2485 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2486 | #------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2487 | # Get the root tag attributes and save them for later. You never know when | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2488 | # you'll need to check the namespace or the from attributes sent by the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2489 | # server. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2490 | #------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2491 | 5 | $self->{SIDS}->{$sid}->{root} = \%att; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2492 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2493 | #------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2494 | # Run through the various xmlns:*** attributes and register the namespace | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2495 | # to prefix map. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2496 | #------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2497 | 5 | foreach my $key (keys(%att)) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2498 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2499 | 7 | ▶ | if ($key =~ /^xmlns\:(.+?)$/) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2500 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2501 | 1 | $self->debug(5,"_handle_root: RegisterPrefix: prefix($att{$key}) ns($1)"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2502 | 1 | $self->RegisterPrefix($sid,$att{$key},$1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2503 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2504 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2505 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2506 | #------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2507 | # Sometimes we will get an error, so let's parse the tag assuming that we | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2508 | # got a stream:error | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2509 | #------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2510 | 5 | my $stream_prefix = $self->StreamPrefix($sid); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2511 | 5 | $self->debug(5,"_handle_root: stream_prefix($stream_prefix)"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2512 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2513 | 5 | ▶ | if ($tag eq $stream_prefix.":error") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2514 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2515 | &XML::Stream::Tree::_handle_element($self,$sax,$tag,%att) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2516 | 0 | ▶ | if ($self->{DATASTYLE} eq "tree"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2517 | &XML::Stream::Node::_handle_element($self,$sax,$tag,%att) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2518 | 0 | ▶ | if ($self->{DATASTYLE} eq "node"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2519 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2520 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2521 | #--------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2522 | # Now that we have gotten a root tag, let's look for the tags that make up | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2523 | # the stream. Change the handler for a Start tag to another function. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2524 | #--------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2525 | 5 | my $weak = $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2526 | 5 | weaken $weak; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2527 | 238 | ▶ | $sax->setHandlers(startElement=>sub{ &{$HANDLERS{$weak->{DATASTYLE}}->{startElement}}($weak, @_) }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2528 | 242 | ▶ | endElement=>sub{ &{$HANDLERS{$weak->{DATASTYLE}}->{endElement}}($weak, @_) }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2529 | 346 | ▶ | characters=>sub{ &{$HANDLERS{$weak->{DATASTYLE}}->{characters}}($weak, @_) }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2530 | 5 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2531 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2532 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2533 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2534 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2535 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2536 | # _node - internal callback for nodes. All it does is place the nodes in a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2537 | # list so that Process() can return them later. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2538 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2539 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2540 | sub _node | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2541 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2542 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_node: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2543 | 0 | my $sid = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2544 | 0 | my @node = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2545 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2546 | 0 | ▶ | if (ref($node[0]) eq "XML::Stream::Node") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2547 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2548 | 0 | push(@{$self->{SIDS}->{$sid}->{nodes}},$node[0]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2549 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2550 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2551 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2552 | 0 | push(@{$self->{SIDS}->{$sid}->{nodes}},\@node); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2553 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2554 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2555 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2556 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2557 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2558 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2559 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2560 | #+---------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2561 | #| | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2562 | #| Error Functions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2563 | #| | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2564 | #+---------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2565 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2566 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2567 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2568 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2569 | =pod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2570 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2571 | =head2 GetErrorCode | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2572 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2573 | if you are returned an undef, you can call this function | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2574 | and hopefully learn more information about the problem. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2575 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2576 | GetErrorCode(sid) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2577 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2578 | returns a string for the specified session that | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2579 | will hopefully contain some useful information | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2580 | about why Process or Connect returned an undef | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2581 | to you. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2582 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2583 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2584 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2585 | sub GetErrorCode | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2586 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2587 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
GetErrorCode: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2588 | 0 | my $sid = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2589 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2590 | 0 | ▶ | $sid = "newconnection" unless defined($sid); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2591 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2592 | 0 | $self->debug(3,"GetErrorCode: sid($sid)"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2593 | return ((exists($self->{SIDS}->{$sid}->{errorcode}) && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2594 | (ref($self->{SIDS}->{$sid}->{errorcode}) eq "HASH")) ? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2595 | $self->{SIDS}->{$sid}->{errorcode} : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2596 | 0 | ▶ | { type=>"system", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
exists $self->{"SIDS"}{$sid}{"errorcode"} and ref $self->{"SIDS"}{$sid}{"errorcode"} eq "HASH"
MC/DC0%0/2
exists $self->{"SIDS"}{$sid}{"errorcode"} and ref $self->{"SIDS"}{$sid}{"errorcode"} eq "HASH"
exists $self->{"SIDS"}{$sid}{"errorcode"}
ref $self->{"SIDS"}{$sid}{"errorcode"} eq "HASH"
Truth table0%0/3
A and B
A= exists $self->{"SIDS"}{$sid}{"errorcode"}B= ref $self->{"SIDS"}{$sid}{"errorcode"} eq "HASH"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2597 | text=>$!, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2598 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2599 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2600 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2601 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2602 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2603 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2604 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2605 | # SetErrorCode - sets the error code so that the caller can find out more | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2606 | # information about the problem | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2607 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2608 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2609 | sub SetErrorCode | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2610 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2611 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
SetErrorCode: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2612 | 0 | my $sid = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2613 | 0 | my $errorcode = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2614 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2615 | 0 | $self->{SIDS}->{$sid}->{errorcode} = $errorcode; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2616 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2617 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2618 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2619 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2620 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2621 | # ProcessStreamError - Take the XML packet and extract out the error. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2622 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2623 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2624 | sub ProcessStreamError | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2625 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2626 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ProcessStreamError: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2627 | 0 | my $sid = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2628 | 0 | my $node = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2629 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2630 | 0 | $self->{SIDS}->{$sid}->{streamerror}->{type} = "unknown"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2631 | 0 | $self->{SIDS}->{$sid}->{streamerror}->{node} = $node; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2632 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2633 | #------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2634 | # Check for older 0.9 streams and handle the errors for them. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2635 | #------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2636 | 0 | ▶ | if (!exists($self->{SIDS}->{$sid}->{root}->{version}) || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
not exists $self->{"SIDS"}{$sid}{"root"}{"version"} or $self->{"SIDS"}{$sid}{"root"}{"version"} eq "" or $self->{"SIDS"}{$sid}{"root"}{"version"} < 1
not exists $self->{"SIDS"}{$sid}{"root"}{"version"} or $self->{"SIDS"}{$sid}{"root"}{"version"} eq ""
MC/DC0%0/3
not exists $self->{"SIDS"}{$sid}{"root"}{"version"} or $self->{"SIDS"}{$sid}{"root"}{"version"} eq "" or $self->{"SIDS"}{$sid}{"root"}{"version"} < 1
not exists $self->{"SIDS"}{$sid}{"root"}{"version"}
$self->{"SIDS"}{$sid}{"root"}{"version"} eq ""
$self->{"SIDS"}{$sid}{"root"}{"version"} < 1
Truth table0%0/4
not(A) or B or C
A= not exists $self->{"SIDS"}{$sid}{"root"}{"version"}B= $self->{"SIDS"}{$sid}{"root"}{"version"} eq ""C= $self->{"SIDS"}{$sid}{"root"}{"version"} < 1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2637 | ($self->{SIDS}->{$sid}->{root}->{version} eq "") || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2638 | ($self->{SIDS}->{$sid}->{root}->{version} < 1.0) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2639 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2640 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2641 | $self->{SIDS}->{$sid}->{streamerror}->{text} = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2642 | 0 | &XPath($node,"text()"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2643 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2644 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2645 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2646 | #------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2647 | # Otherwise we are in XMPP land with real stream errors. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2648 | #------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2649 | 0 | my @errors = &XPath($node,'*[@xmlns="'.&ConstXMLNS("xmppstreams").'"]'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2650 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2651 | 0 | my $type; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2652 | my $text; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2653 | 0 | foreach my $error (@errors) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2654 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2655 | 0 | ▶ | if (&XPath($error,"name()") eq "text") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2656 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2657 | $self->{SIDS}->{$sid}->{streamerror}->{text} = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2658 | 0 | &XPath($error,"text()"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2659 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2660 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2661 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2662 | $self->{SIDS}->{$sid}->{streamerror}->{type} = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2663 | 0 | &XPath($error,"name()"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2664 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2665 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2666 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2667 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2668 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2669 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2670 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2671 | =pod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2672 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2673 | =head2 StreamError | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2674 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2675 | Given a type and text, generate a <stream:error/> packet to | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2676 | send back to the other side. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2677 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2678 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2679 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2680 | sub StreamError | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2681 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2682 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
StreamError: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2683 | 0 | my $sid = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2684 | 0 | my $type = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2685 | 0 | my $text = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2686 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2687 | 0 | my $root = $self->GetRoot($sid); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2688 | 0 | my $stream_base = $self->StreamPrefix($sid); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2689 | 0 | my $error = "<${stream_base}:error>"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2690 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2691 | 0 | ▶ | if (exists($root->{version}) && ($root->{version} ne "")) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
exists $root->{"version"} and $root->{"version"} ne ""
MC/DC0%0/2
exists $root->{"version"} and $root->{"version"} ne ""
exists $root->{"version"}
$root->{"version"} ne ""
Truth table0%0/3
A and B
A= exists $root->{"version"}B= $root->{"version"} ne ""
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2692 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2693 | 0 | $error .= "<${type} xmlns='".&ConstXMLNS('xmppstreams')."'/>"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2694 | 0 | ▶ | if (defined($text)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2695 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2696 | 0 | $error .= "<text xmlns='".&ConstXMLNS('xmppstreams')."'>"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2697 | 0 | $error .= $text; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2698 | 0 | $error .= "</text>"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2699 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2700 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2701 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2702 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2703 | 0 | $error .= $text; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2704 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2705 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2706 | 0 | $error .= "</${stream_base}:error>"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2707 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2708 | 0 | return $error; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2709 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2710 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2711 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2712 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2713 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2714 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2715 | #+---------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2716 | #| | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2717 | #| Activity Monitoring Functions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2718 | #| | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2719 | #+---------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2720 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2721 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2722 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2723 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2724 | # IgnoreActivity - Set the flag that will ignore the activity monitor. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2725 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2726 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2727 | sub IgnoreActivity | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2728 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2729 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
IgnoreActivity: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2730 | 0 | my $sid = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2731 | 0 | my $ignoreActivity = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2732 | 0 | ▶ | $ignoreActivity = 1 unless defined($ignoreActivity); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2733 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2734 | 0 | $self->debug(3,"IgnoreActivity: ignoreActivity($ignoreActivity)"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2735 | 0 | $self->debug(4,"IgnoreActivity: sid($sid)"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2736 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2737 | 0 | $self->{SIDS}->{$sid}->{ignoreActivity} = $ignoreActivity; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2738 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2739 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2740 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2741 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2742 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2743 | # LastActivity - Return the time of the last activity. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2744 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2745 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2746 | sub LastActivity | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2747 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2748 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
LastActivity: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2749 | 0 | my $sid = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2750 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2751 | 0 | $self->debug(3,"LastActivity: sid($sid)"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2752 | 0 | $self->debug(1,"LastActivity: lastActivity($self->{SIDS}->{$sid}->{lastActivity})"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2753 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2754 | 0 | return $self->{SIDS}->{$sid}->{lastActivity}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2755 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2756 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2757 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2758 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2759 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2760 | # MarkActivity - Record the current time for this sid. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2761 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2762 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2763 | sub MarkActivity | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2764 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2765 | 2 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
MarkActivity: called CC=3 SCAR=11.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2766 | 2 | my $sid = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2767 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2768 | return if (exists($self->{SIDS}->{$sid}->{ignoreActivity}) && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2769 | 2 | ▶ | ($self->{SIDS}->{$sid}->{ignoreActivity} == 1)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
exists $self->{"SIDS"}{$sid}{"ignoreActivity"} and $self->{"SIDS"}{$sid}{"ignoreActivity"} == 1
MC/DC0%0/2
exists $self->{"SIDS"}{$sid}{"ignoreActivity"} and $self->{"SIDS"}{$sid}{"ignoreActivity"} == 1
exists $self->{"SIDS"}{$sid}{"ignoreActivity"}
$self->{"SIDS"}{$sid}{"ignoreActivity"} == 1
Truth table33%1/3
A and B
A= exists $self->{"SIDS"}{$sid}{"ignoreActivity"}B= $self->{"SIDS"}{$sid}{"ignoreActivity"} == 1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2770 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2771 | 2 | $self->debug(3,"MarkActivity: sid($sid)"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2772 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2773 | 2 | $self->{SIDS}->{$sid}->{lastActivity} = time; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2774 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2775 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2776 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2777 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2778 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2779 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2780 | #+---------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2781 | #| | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2782 | #| XML Node Interface functions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2783 | #| | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2784 | #| These are generic wrappers around the Tree and Node data types. The | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2785 | #| problem being that the Tree class cannot support methods. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2786 | #| | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2787 | #+---------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2788 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2789 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2790 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2791 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2792 | =pod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2793 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2794 | =head2 SetXMLData | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2795 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2796 | Takes a host of arguments and sets a portion of the specified | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2797 | data strucure with that data. The function works in two | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2798 | modes "single" or "multiple". "single" denotes that the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2799 | function should locate the current tag that matches this | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2800 | data and overwrite it's contents with data passed in. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2801 | "multiple" denotes that a new tag should be created even if | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2802 | others exist. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2803 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2804 | type - single or multiple | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2805 | XMLTree - pointer to XML::Stream data object (tree or node) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2806 | tag - name of tag to create/modify (if blank assumes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2807 | working with top level tag) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2808 | data - CDATA to set for tag | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2809 | attribs - attributes to ADD to tag | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2810 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2811 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2812 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2813 | sub SetXMLData | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2814 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2815 | 0 | ▶ | return &XML::Stream::Node::SetXMLData(@_) if (ref($_[1]) eq "XML::Stream::Node"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
SetXMLData: not called CC=3 SCAR=24.8
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2816 | 0 | ▶ | return &XML::Stream::Tree::SetXMLData(@_) if (ref($_[1]) eq "ARRAY"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2817 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2818 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2819 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2820 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2821 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2822 | =pod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2823 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2824 | =head2 GetXMLData | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2825 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2826 | Takes a host of arguments and returns various data structures | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2827 | that match them. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2828 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2829 | type C<existence> - returns 1 or 0 if the tag exists in the top level. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2830 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2831 | C<value> - returns either the CDATA of the tag, or the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2832 | value of the attribute depending on which is | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2833 | sought. This ignores any mark ups to the data | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2834 | and just returns the raw CDATA. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2835 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2836 | C<value array> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2837 | returns an array of strings representing | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2838 | all of the CDATA in the specified tag. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2839 | This ignores any mark ups to the data | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2840 | and just returns the raw CDATA. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2841 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2842 | C<tree> - returns a data structure that represents the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2843 | XML with the specified tag as the root tag. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2844 | Depends on the format that you are working with. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2845 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2846 | C<tree array> returns an array of data structures each | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2847 | with the specified tag as the root tag. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2848 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2849 | C<child array> - returns a list of all children nodes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2850 | not including CDATA nodes. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2851 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2852 | C<attribs> - returns a hash with the attributes, and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2853 | their values, for the things that match | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2854 | the parameters | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2855 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2856 | C<count> - returns the number of things that match | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2857 | the arguments | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2858 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2859 | C<tag> - returns the root tag of this tree | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2860 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2861 | XMLTree - pointer to XML::Stream data structure | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2862 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2863 | C<tag> - tag to pull data from. If blank then the top level | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2864 | tag is accessed. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2865 | C<attrib> - attribute value to retrieve. Ignored for types | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2866 | "value array", "tree", "tree array". If paired | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2867 | with value can be used to filter tags based on | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2868 | attributes and values. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2869 | C<value> - only valid if an attribute is supplied. Used to | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2870 | filter for tags that only contain this attribute. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2871 | Useful to search through multiple tags that all | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2872 | reference different name spaces. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2873 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2874 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2875 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2876 | sub GetXMLData | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2877 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2878 | 1778 | ▶ | return &XML::Stream::Node::GetXMLData(@_) if (ref($_[1]) eq "XML::Stream::Node"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
GetXMLData: called CC=3 SCAR=11.1
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2879 | 873 | ▶ | return &XML::Stream::Tree::GetXMLData(@_) if (ref($_[1]) eq "ARRAY"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2880 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2881 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2882 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2883 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2884 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2885 | =pod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2886 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2887 | =head2 XPath | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2888 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2889 | Run an xpath query on a node and return back the result. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2890 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2891 | XPath(node,path) returns an array of results that match the xpath. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2892 | node can be any of the three types (Tree, Node). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2893 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2894 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2895 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2896 | sub XPath | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2897 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2898 | 105 | ▶ | my $tree = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
XPath: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2899 | 105 | my $path = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2900 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2901 | 105 | my $query = XML::Stream::XPath::Query->new($path); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2902 | 105 | my $result = $query->execute($tree); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2903 | 105 | ▶ | if ($result->check()) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2904 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2905 | 34 | my %attribs = $result->getAttribs(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2906 | 34 | ▶ | return %attribs if (scalar(keys(%attribs)) > 0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2907 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2908 | 32 | my @values = $result->getValues(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2909 | 32 | ▶ | @values = $result->getList() unless ($#values > -1); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2910 | 32 | ▶ | return @values if wantarray; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2911 | 2 | return $values[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2912 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2913 | 71 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2914 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2915 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2916 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2917 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2918 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2919 | =pod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2920 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2921 | =head2 XPathCheck | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2922 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2923 | Run an xpath query on a node and return 1 or 0 if the path is | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2924 | valid. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2925 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2926 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2927 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2928 | sub XPathCheck | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2929 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2930 | 0 | ▶ | my $tree = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
XPathCheck: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2931 | 0 | my $path = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2932 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2933 | 0 | my $query = XML::Stream::XPath::Query->new($path); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2934 | 0 | my $result = $query->execute($tree); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2935 | 0 | return $result->check(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2936 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2937 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2938 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2939 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2940 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2941 | =pod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2942 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2943 | =head2 XML2Config | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2944 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2945 | Takes an XML data tree and turns it into a hash of hashes. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2946 | This only works for certain kinds of XML trees like this: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2947 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2948 | <foo> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2949 | <bar>1</bar> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2950 | <x> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2951 | <y>foo</y> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2952 | </x> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2953 | <z>5</z> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2954 | <z>6</z> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2955 | </foo> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2956 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2957 | The resulting hash would be: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2958 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2959 | $hash{bar} = 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2960 | $hash{x}->{y} = "foo"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2961 | $hash{z}->[0] = 5; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2962 | $hash{z}->[1] = 6; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2963 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2964 | Good for config files. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2965 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2966 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2967 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2968 | sub XML2Config | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2969 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2970 | 118 | ▶ | return &XML::Stream::Node::XML2Config(@_) if (ref($_[0]) eq "XML::Stream::Node"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
XML2Config: called CC=3 SCAR=11.1
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2971 | 59 | ▶ | return &XML::Stream::Tree::XML2Config(@_) if (ref($_[0]) eq "ARRAY"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2972 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2973 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2974 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2975 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2976 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2977 | =pod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2978 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2979 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2980 | =head2 Config2XML | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2981 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2982 | Takes a hash and produces an XML string from it. If the hash looks like this: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2983 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2984 | $hash{bar} = 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2985 | $hash{x}->{y} = "foo"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2986 | $hash{z}->[0] = 5; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2987 | $hash{z}->[1] = 6; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2988 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2989 | The resulting xml would be: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2990 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2991 | <foo> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2992 | <bar>1</bar> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2993 | <x> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2994 | <y>foo</y> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2995 | </x> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2996 | <z>5</z> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2997 | <z>6</z> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2998 | </foo> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2999 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3000 | Good for config files. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3001 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3002 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3003 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3004 | sub Config2XML | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3005 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3006 | 0 | ▶ | my ($tag,$hash,$indent) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Config2XML: not called CC=9 SCAR=45.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3007 | 0 | ▶ | $indent = "" unless defined($indent); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3008 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3009 | 0 | my $xml; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3010 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3011 | 0 | ▶ | if (ref($hash) eq "ARRAY") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3012 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3013 | 0 | foreach my $item (@{$hash}) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3014 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3015 | 0 | $xml .= &XML::Stream::Config2XML($tag,$item,$indent); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3016 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3017 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3018 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3019 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3020 | 0 | ▶ | if ((ref($hash) eq "HASH") && ((scalar keys(%{$hash})) == 0)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ref $hash eq "HASH" and scalar keys %{$hash;} == 0
MC/DC0%0/2
ref $hash eq "HASH" and scalar keys %{$hash;} == 0
ref $hash eq "HASH"
scalar keys %{$hash;} == 0
Truth table0%0/3
A and B
A= ref $hash eq "HASH"B= scalar keys %{$hash;} == 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3021 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3022 | 0 | $xml .= "$indent<$tag/>\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3023 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3024 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3025 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3026 | 0 | ▶ | if (ref($hash) eq "") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3027 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3028 | 0 | ▶ | if ($hash eq "") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3029 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3030 | 0 | return "$indent<$tag/>\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3031 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3032 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3033 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3034 | 0 | return "$indent<$tag>$hash</$tag>\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3035 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3036 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3037 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3038 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3039 | 0 | $xml .= "$indent<$tag>\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3040 | 0 | foreach my $item (sort {$a cmp $b} keys(%{$hash})) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3041 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3042 | 0 | $xml .= &XML::Stream::Config2XML($item,$hash->{$item}," $indent"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3043 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3044 | 0 | $xml .= "$indent</$tag>\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3045 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3046 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3047 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3048 | 0 | return $xml; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3049 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3050 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3051 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3052 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3053 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3054 | =pod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3055 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3056 | =head2 EscapeXML | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3057 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3058 | Simple function to make sure that no bad characters make it into | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3059 | in the XML string that might cause the string to be | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3060 | misinterpreted. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3061 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3062 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3063 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3064 | sub EscapeXML | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3065 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3066 | 269 | ▶ | my $data = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
EscapeXML: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3067 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3068 | 269 | ▶ | if (defined($data)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3069 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3070 | 269 | $data =~ s/&/&/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3071 | 269 | $data =~ s/</</g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3072 | 269 | $data =~ s/>/>/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3073 | 269 | $data =~ s/\"/"/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3074 | 269 | $data =~ s/\'/'/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3075 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3076 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3077 | 269 | return $data; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3078 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3079 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3080 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3081 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3082 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3083 | =pod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3084 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3085 | =head2 UnescapeXML | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3086 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3087 | Simple function to take an escaped string and return it to normal. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3088 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3089 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3090 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3091 | sub UnescapeXML | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3092 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3093 | 0 | ▶ | my $data = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
UnescapeXML: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3094 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3095 | 0 | ▶ | if (defined($data)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3096 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3097 | 0 | $data =~ s/&/&/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3098 | 0 | $data =~ s/</</g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3099 | 0 | $data =~ s/>/>/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3100 | 0 | $data =~ s/"/\"/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3101 | 0 | $data =~ s/'/\'/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3102 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3103 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3104 | 0 | return $data; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3105 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3106 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3107 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3108 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3109 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3110 | =pod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3111 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3112 | =head2 BuildXML | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3113 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3114 | Takes one of the data formats that XML::Stream supports and call | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3115 | the proper BuildXML_xxx function on it. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3116 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3117 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3118 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3119 | sub BuildXML | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3120 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3121 | 51 | ▶ | return &XML::Stream::Node::BuildXML(@_) if (ref($_[0]) eq "XML::Stream::Node"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BuildXML: called CC=4 SCAR=16.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3122 | 17 | ▶ | return &XML::Stream::Tree::BuildXML(@_) if (ref($_[0]) eq "ARRAY"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3123 | 0 | ▶ | return &XML::Stream::Tree::BuildXML(@_) if (ref($_[1]) eq "ARRAY"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3124 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3125 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3126 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3127 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3128 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3129 | #+---------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3130 | #| | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3131 | #| Namespace/Prefix Functions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3132 | #| | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3133 | #+---------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3134 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3135 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3136 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3137 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3138 | =pod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3139 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3140 | =head2 ConstXMLNS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3141 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3142 | Return the namespace from the constant string. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3143 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3144 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3145 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3146 | sub ConstXMLNS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3147 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3148 | 220 | ▶ | my $const = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ConstXMLNS: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3149 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3150 | 220 | return $XMLNS{$const}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3151 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3152 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3153 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3154 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3155 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3156 | # StreamPrefix - Return the prefix of the <stream:stream/> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3157 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3158 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3159 | sub StreamPrefix | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3160 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3161 | 75 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
StreamPrefix: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3162 | 75 | my $sid = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3163 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3164 | 75 | return $self->ns2prefix($sid,&ConstXMLNS("stream")); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3165 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3166 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3167 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3168 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3169 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3170 | # RegisterPrefix - setup the map for namespace to prefix | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3171 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3172 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3173 | sub RegisterPrefix | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3174 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3175 | 5 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
RegisterPrefix: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3176 | 5 | my $sid = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3177 | 5 | my $ns = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3178 | 5 | my $prefix = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3179 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3180 | 5 | $self->{SIDS}->{$sid}->{ns2prefix}->{$ns} = $prefix; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3181 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3182 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3183 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3184 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3185 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3186 | # ns2prefix - for a stream, return the prefix for the given namespace | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3187 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3188 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3189 | sub ns2prefix | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3190 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3191 | 75 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ns2prefix: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3192 | 75 | my $sid = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3193 | 75 | my $ns = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3194 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3195 | 75 | return $self->{SIDS}->{$sid}->{ns2prefix}->{$ns}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3196 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3197 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3198 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3199 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3200 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3201 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3202 | #+---------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3203 | #| | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3204 | #| Helper Functions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3205 | #| | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3206 | #+---------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3207 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3208 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3209 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3210 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3211 | =pod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3212 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3213 | =head2 GetRoot | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3214 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3215 | Returns the hash of attributes for the root <stream:stream/> tag | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3216 | so that any attributes returned can be accessed. from and any | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3217 | xmlns:foobar might be important. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3218 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3219 | GetRoot(sid) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3220 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3221 | Returns the attributes that the stream:stream tag sent | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3222 | by the other end listed in a hash for the specified session. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3223 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3224 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3225 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3226 | sub GetRoot | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3227 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3228 | 4 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
GetRoot: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3229 | 4 | my $sid = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3230 | 4 | ▶ | return unless exists($self->{SIDS}->{$sid}->{root}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3231 | 4 | return $self->{SIDS}->{$sid}->{root}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3232 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3233 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3234 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3235 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3236 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3237 | =pod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3238 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3239 | =head2 GetSock | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3240 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3241 | returns the Socket so that an outside function can access it if desired. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3242 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3243 | GetSock(sid) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3244 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3245 | Returns a pointer to the IO::Socket object for the specified session. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3246 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3247 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3248 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3249 | sub GetSock | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3250 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3251 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
GetSock: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3252 | 0 | my $sid = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3253 | 0 | return $self->{SIDS}->{$sid}->{sock}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3254 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3255 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3256 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3257 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3258 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3259 | # LoadSSL - simple call to set everything up for SSL one time. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3260 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3261 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3262 | sub LoadSSL | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3263 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3264 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
LoadSSL: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3265 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3266 | 0 | $self->debug(1,"LoadSSL: Load the IO::Socket::SSL module"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3267 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3268 | 0 | ▶ | if (defined($SSL) && ($SSL == 1)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $XML::Stream::SSL and $XML::Stream::SSL == 1
MC/DC0%0/2
defined $XML::Stream::SSL and $XML::Stream::SSL == 1
defined $XML::Stream::SSL
$XML::Stream::SSL == 1
Truth table0%0/3
A and B
A= defined $XML::Stream::SSLB= $XML::Stream::SSL == 1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3269 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3270 | 0 | $self->debug(1,"LoadSSL: Success"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3271 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3272 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3273 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3274 | 0 | ▶ | if (defined($SSL) && ($SSL == 0)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $XML::Stream::SSL and $XML::Stream::SSL == 0
MC/DC0%0/2
defined $XML::Stream::SSL and $XML::Stream::SSL == 0
defined $XML::Stream::SSL
$XML::Stream::SSL == 0
Truth table0%0/3
A and B
A= defined $XML::Stream::SSLB= $XML::Stream::SSL == 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3275 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3276 | 0 | $self->debug(1,"LoadSSL: Failure"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3277 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3278 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3279 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3280 | 0 | my $SSL_Version = "0.81"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3281 | 0 | eval "use IO::Socket::SSL $SSL_Version"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3282 | 0 | ▶ | if ($@) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3283 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3284 | 0 | croak("IO::Socket::SSL v$SSL_Version or greater is required."); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3285 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3286 | 0 | $SSL = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3287 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3288 | 0 | $self->debug(1,"LoadSSL: Success"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3289 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3290 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3291 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3292 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3293 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3294 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3295 | # Host2SID - For a server this allows you to lookup the SID of a stream server | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3296 | # based on the hostname that is is listening on. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3297 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3298 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3299 | sub Host2SID | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3300 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3301 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Host2SID: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3302 | 0 | my $hostname = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3303 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3304 | 0 | foreach my $sid (keys(%{$self->{SIDS}})) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3305 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3306 | 0 | ▶ | next if ($sid eq "default"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3307 | 0 | ▶ | next if ($sid =~ /^server/); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3308 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3309 | 0 | ▶ | return $sid if ($self->{SIDS}->{$sid}->{hostname} eq $hostname); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3310 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3311 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3312 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3313 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3314 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3315 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3316 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3317 | =pod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3318 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3319 | =head2 NewSID | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3320 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3321 | Returns a session ID to send to an incoming stream in the return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3322 | header. By default it just increments a counter and returns that, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3323 | or you can define a function and set it using the SetCallBacks | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3324 | function. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3325 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3326 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3327 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3328 | sub NewSID | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3329 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3330 | 4 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
NewSID: called CC=3 SCAR=13.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3331 | 0 | return &{$self->{CB}->{sid}}() if (exists($self->{CB}->{sid}) && | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3332 | 4 | ▶ | defined($self->{CB}->{sid})); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
exists $self->{"CB"}{"sid"} and defined $self->{"CB"}{"sid"}
MC/DC0%0/2
exists $self->{"CB"}{"sid"} and defined $self->{"CB"}{"sid"}
exists $self->{"CB"}{"sid"}
defined $self->{"CB"}{"sid"}
Truth table33%1/3
A and B
A= exists $self->{"CB"}{"sid"}B= defined $self->{"CB"}{"sid"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3333 | 4 | return $$.time.$self->{IDCOUNT}++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3334 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3335 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3336 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3337 | ########################################################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3338 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3339 | =pod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3340 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3341 | =head2 SetCallBacks | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3342 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3343 | Takes a hash with top level tags to look for as the keys | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3344 | and pointers to functions as the values. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3345 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3346 | SetCallBacks(node=>function, update=>function); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3347 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3348 | Sets the callback that should be called in various situations. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3349 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3350 | C<node> is used to handle the data structures that are built for each top level tag. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3351 | C<update> is used for when Process is blocking waiting for data, but you | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3352 | want your original code to be updated. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3353 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3354 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3355 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3356 | sub SetCallBacks | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3357 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3358 | 12 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
SetCallBacks: called CC=4 SCAR=14.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3359 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3360 | 12 | my $weak = $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3361 | 12 | weaken $weak; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3362 | 12 | ▶ | while($#_ >= 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3363 | 12 | my $func = pop(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3364 | 12 | my $tag = pop(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3365 | 12 | ▶ | if (($tag eq "node") && !defined($func)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$tag eq "node" and not defined $func
MC/DC0%0/2
$tag eq "node" and not defined $func
$tag eq "node"
not defined $func
Truth table33%1/3
A and not(B)
A= $tag eq "node"B= not defined $func
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3366 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3367 | 0 | ▶ | $self->SetCallBacks(node=>sub { $weak->_node(@_) }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3368 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3369 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3370 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3371 | 12 | $self->debug(1,"SetCallBacks: tag($tag) func($func)"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3372 | 12 | $self->{CB}->{$tag} = $func; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3373 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3374 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3375 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3376 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3377 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3378 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3379 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3380 | # StreamHeader - Given the arguments, return the opening stream header. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3381 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3382 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3383 | sub StreamHeader | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3384 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3385 | 1 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
StreamHeader: called CC=5 SCAR=16.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3386 | 1 | my (%args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3387 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3388 | 1 | my $stream; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3389 | 1 | $stream .= "<?xml version='1.0'?>"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3390 | 1 | $stream .= "<stream:stream "; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3391 | 1 | $stream .= "version='1.0' "; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3392 | 1 | $stream .= "xmlns:stream='".&ConstXMLNS("stream")."' "; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3393 | 1 | $stream .= "xmlns='$args{xmlns}' "; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3394 | 1 | ▶ | $stream .= "to='$args{to}' " if exists($args{to}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3395 | 1 | ▶ | $stream .= "from='$args{from}' " if exists($args{from}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3396 | 1 | ▶ | $stream .= "xml:lang='$args{xmllang}' " if exists($args{xmllang}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3397 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3398 | 1 | foreach my $ns (@{$args{namespaces}}) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3399 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3400 | 0 | $stream .= " ".$ns->GetStream(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3401 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3402 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3403 | 1 | $stream .= ">"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3404 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3405 | 1 | return $stream; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3406 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3407 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3408 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3409 | ########################################################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3410 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3411 | # debug - prints the arguments to the debug log if debug is turned on. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3412 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3413 | ########################################################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3414 | sub debug | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3415 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3416 | 2045 | ▶ | return if ($_[1] > $_[0]->{DEBUGLEVEL}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
debug: called CC=4 SCAR=26.7
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3417 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3418 | 0 | my ($limit,@args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3419 | 0 | ▶ | return if ($self->{DEBUGFILE} eq ""); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3420 | 0 | my $fh = $self->{DEBUGFILE}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3421 | 0 | ▶ | if ($self->{DEBUGTIME} == 1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3422 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3423 | 0 | my ($sec,$min,$hour) = localtime(time); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3424 | 0 | print $fh sprintf("[%02d:%02d:%02d] ",$hour,$min,$sec); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3425 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3426 | 0 | print $fh "XML::Stream: @args\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3427 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3428 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3429 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3430 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3431 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3432 | # nonblock - set the socket to be non-blocking. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3433 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3434 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3435 | sub nonblock | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3436 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3437 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
nonblock: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3438 | 0 | my $socket = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3439 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3440 | #-------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3441 | # Code copied from POE::Wheel::SocketFactory... | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3442 | # Win32 does things one way... | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3443 | #-------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3444 | 0 | ▶ | if ($^O eq "MSWin32") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3445 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3446 | 0 | ▶ | ioctl( $socket, 0x80000000 | (4 << 16) | (ord('f') << 8) | 126, 1) || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3447 | croak("Can't make socket nonblocking (win32): $!"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3448 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3449 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3450 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3451 | #-------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3452 | # And UNIX does them another | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3453 | #-------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3454 | 0 | ▶ | my $flags = fcntl($socket, F_GETFL, 0) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3455 | or die "Can't get flags for socket: $!\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3456 | 0 | ▶ | fcntl($socket, F_SETFL, $flags | O_NONBLOCK) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3457 | or die "Can't make socket nonblocking: $!\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3458 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3459 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3460 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3461 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3462 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3463 | # printData - debugging function to print out any data structure in an | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3464 | # organized manner. Very useful for debugging XML::Parser::Tree | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3465 | # objects. This is a private function that will only exist in | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3466 | # in the development version. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3467 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3468 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3469 | sub printData | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3470 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3471 | 0 | ▶ | print &sprintData(@_); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
printData: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3472 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3473 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3474 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3475 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3476 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3477 | # sprintData - debugging function to build a string out of any data structure | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3478 | # in an organized manner. Very useful for debugging | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3479 | # XML::Parser::Tree objects and perl hashes of hashes. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3480 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3481 | # This is a private function. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3482 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3483 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3484 | sub sprintData | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3485 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3486 | 0 | ▶ | my ($preString,$data) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sprintData: not called CC=12 SCAR=50.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3487 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3488 | 0 | my $outString = ""; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3489 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3490 | 0 | ▶ | if (ref($data) eq "HASH") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3491 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3492 | 0 | my $key; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3493 | 0 | foreach $key (sort { $a cmp $b } keys(%{$data})) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3494 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3495 | 0 | ▶ | if (ref($$data{$key}) eq "") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3496 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3497 | 0 | ▶ | my $value = defined($$data{$key}) ? $$data{$key} : ""; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3498 | 0 | $outString .= $preString."{'$key'} = \"".$value."\";\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3499 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3500 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3501 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3502 | 0 | ▶ | if (ref($$data{$key}) =~ /Net::Jabber/) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3503 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3504 | 0 | $outString .= $preString."{'$key'} = ".ref($$data{$key}).";\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3505 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3506 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3507 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3508 | 0 | $outString .= $preString."{'$key'};\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3509 | 0 | $outString .= &sprintData($preString."{'$key'}->",$$data{$key}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3510 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3511 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3512 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3513 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3514 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3515 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3516 | 0 | ▶ | if (ref($data) eq "ARRAY") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3517 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3518 | 0 | my $index; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3519 | 0 | foreach $index (0..$#{$data}) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3520 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3521 | 0 | ▶ | if (ref($$data[$index]) eq "") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3522 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3523 | 0 | $outString .= $preString."[$index] = \"$$data[$index]\";\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3524 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3525 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3526 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3527 | 0 | ▶ | if (ref($$data[$index]) =~ /Net::Jabber/) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3528 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3529 | 0 | $outString .= $preString."[$index] = ".ref($$data[$index]).";\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3530 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3531 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3532 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3533 | 0 | $outString .= $preString."[$index];\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3534 | 0 | $outString .= &sprintData($preString."[$index]->",$$data[$index]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3535 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3536 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3537 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3538 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3539 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3540 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3541 | 0 | ▶ | if (ref($data) eq "REF") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3542 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3543 | 0 | $outString .= &sprintData($preString."->",$$data); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3544 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3545 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3546 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3547 | 0 | ▶ | if (ref($data) eq "") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3548 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3549 | 0 | $outString .= $preString." = \"$data\";\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3550 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3551 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3552 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3553 | 0 | $outString .= $preString." = ".ref($data).";\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3554 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3555 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3556 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3557 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3558 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3559 | 0 | return $outString; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3560 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3561 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3562 | =pod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3563 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3564 | =head1 VARIABLES | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3565 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3566 | $NONBLOCKING | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3567 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3568 | Tells the Parser to enter into a nonblocking state. This | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3569 | might cause some funky behavior since you can get nested | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3570 | callbacks while things are waiting. 1=on, 0=off(default). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3571 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3572 | =head1 EXAMPLES | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3573 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3574 | simple example | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3575 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3576 | use XML::Stream qw( Tree ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3577 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3578 | $stream = XML::Stream->new; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3579 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3580 | my $status = $stream->Connect(hostname => "jabber.org", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3581 | port => 5222, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3582 | namespace => "jabber:client"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3583 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3584 | if (!defined($status)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3585 | print "ERROR: Could not connect to server\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3586 | print " (",$stream->GetErrorCode(),")\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3587 | exit(0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3588 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3589 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3590 | while($node = $stream->Process()) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3591 | # do something with $node | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3592 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3593 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3594 | $stream->Disconnect(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3595 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3596 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3597 | Example using a handler | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3598 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3599 | use XML::Stream qw( Tree ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3600 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3601 | $stream = XML::Stream->new; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3602 | $stream->SetCallBacks(node=>\&noder); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3603 | $stream->Connect(hostname => "jabber.org", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3604 | port => 5222, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3605 | namespace => "jabber:client", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3606 | timeout => undef) || die $!; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3607 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3608 | # Blocks here forever, noder is called for incoming | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3609 | # packets when they arrive. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3610 | while(defined($stream->Process())) { } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3611 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3612 | print "ERROR: Stream died (",$stream->GetErrorCode(),")\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3613 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3614 | sub noder | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3615 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3616 | my $sid = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3617 | my $node = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3618 | # do something with $node | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3619 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3620 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3621 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3622 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3623 | Tweaked, tuned, and brightness changes by Ryan Eatmon, reatmon@ti.com | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3624 | in May of 2000. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3625 | Colorized, and Dolby Surround sound added by Thomas Charron, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3626 | tcharron@jabber.org | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3627 | By Jeremie in October of 1999 for http://etherx.jabber.org/streams/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3628 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3629 | Currently maintained by Darian Anthony Patrick. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3630 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3631 | =head1 COPYRIGHT | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3632 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3633 | Copyright (C) 1998-2004 Jabber Software Foundation http://jabber.org/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3634 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3635 | This module licensed under the LGPL, version 2.1. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3636 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3637 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3638 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3639 | 12 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||