Changeset 7869e48 for perl/modules/Jabber/lib/XML/Stream.pm
- Timestamp:
- Jan 12, 2013, 1:43:13 PM (11 years ago)
- Children:
- e3a0d71, 4485285
- Parents:
- 4626016
- git-author:
- Jason Gross <jgross@mit.edu> (01/12/13 13:13:18)
- git-committer:
- Jason Gross <jgross@mit.edu> (01/12/13 13:43:13)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
perl/modules/Jabber/lib/XML/Stream.pm
ra8d5a39 r7869e48 317 317 318 318 my $lc = lc($module); 319 319 320 320 eval("\$HANDLERS{\$lc}->{startElement} = \\&XML::Stream::${module}::_handle_element;"); 321 321 eval("\$HANDLERS{\$lc}->{endElement} = \\&XML::Stream::${module}::_handle_close;"); … … 600 600 601 601 my $root = $self->GetRoot($sid); 602 602 603 603 if ($root->{xmlns} ne $self->{SIDS}->{$serverid}->{namespace}) 604 604 { … … 668 668 } 669 669 while($#_ >= 0) { $self->{SIDS}->{newconnection}->{ lc pop(@_) } = pop(@_); } 670 670 671 671 my $timeout = exists($self->{SIDS}->{newconnection}->{timeout}) ? 672 672 delete($self->{SIDS}->{newconnection}->{timeout}) : … … 674 674 675 675 $self->debug(4,"Connect: timeout($timeout)"); 676 676 677 677 678 678 if (exists($self->{SIDS}->{newconnection}->{srv})) … … 683 683 my $res = Net::DNS::Resolver->new(); 684 684 my $query = $res->query($self->{SIDS}->{newconnection}->{srv}.".".$self->{SIDS}->{newconnection}->{hostname},"SRV"); 685 685 686 686 if ($query) 687 { 687 { 688 688 $self->{SIDS}->{newconnection}->{hostname} = ($query->answer)[0]->target(); 689 689 $self->{SIDS}->{newconnection}->{port} = ($query->answer)[0]->port(); … … 771 771 $self->{SIDS}->{newconnection}->{sock} = 772 772 new FileHandle(">&STDOUT"); 773 } 773 } 774 774 775 775 #--------------------------------------------------------------------------- … … 1030 1030 #--------------------------------------------------------------------------- 1031 1031 my %stream_args; 1032 1032 1033 1033 if (($self->{SIDS}->{$currsid}->{connectiontype} eq "tcpip") || 1034 1034 ($self->{SIDS}->{$currsid}->{connectiontype} eq "http")) … … 1036 1036 $stream_args{to}= $self->{SIDS}->{$currsid}->{hostname} 1037 1037 unless exists($self->{SIDS}->{$currsid}->{to}); 1038 1038 1039 1039 $stream_args{to} = $self->{SIDS}->{$currsid}->{to} 1040 1040 if exists($self->{SIDS}->{$currsid}->{to}); … … 1044 1044 ($self->{SIDS}->{$currsid}->{myhostname} ne "") 1045 1045 ); 1046 1046 1047 1047 $stream_args{from} = $self->{SIDS}->{$currsid}->{from} 1048 1048 if exists($self->{SIDS}->{$currsid}->{from}); 1049 1049 1050 1050 $stream_args{id} = $self->{SIDS}->{$currsid}->{id} 1051 1051 if (exists($self->{SIDS}->{$currsid}->{id}) && … … 1055 1055 $stream_args{namespaces} = $self->{SIDS}->{$currsid}->{namespaces}; 1056 1056 } 1057 1057 1058 1058 my $stream = 1059 1059 $self->StreamHeader( … … 1172 1172 } 1173 1173 } 1174 1174 1175 1175 return $self->GetRoot($sid); 1176 1176 } … … 1333 1333 #--------------------------------------------------------------------------- 1334 1334 $self->{SIDS}->{$sid}->{streamfeatures}->{received} = 0; 1335 1335 1336 1336 #--------------------------------------------------------------------------- 1337 1337 # First acitivty is the connection... duh. =) … … 1522 1522 $self->debug(4,"Process: sid($sid) time(",time,") timeout(undef)"); 1523 1523 } 1524 1524 1525 1525 $self->Respond($sid) 1526 1526 if (exists($self->{SIDS}->{$sid}->{activitytimeout}) && … … 1637 1637 $self->debug(3,"Send: sid($sid)"); 1638 1638 $self->debug(3,"Send: status($self->{SIDS}->{$sid}->{status})"); 1639 1639 1640 1640 $self->{SIDS}->{$sid}->{keepalive} = time; 1641 1641 … … 1677 1677 return; 1678 1678 } 1679 1679 1680 1680 $self->debug(4,"Send: SENDWRITTEN($self->{SENDWRITTEN})"); 1681 1681 … … 1736 1736 } 1737 1737 } 1738 1738 1739 1739 #------------------------------------------------------------------------- 1740 1740 # XMPP-TLS - 1.0 … … 1753 1753 } 1754 1754 } 1755 1755 1756 1756 #------------------------------------------------------------------------- 1757 1757 # XMPP-Bind - 1.0 … … 1762 1762 $self->{SIDS}->{$sid}->{streamfeatures}->{'xmpp-bind'} = 1; 1763 1763 } 1764 1764 1765 1765 #------------------------------------------------------------------------- 1766 1766 # XMPP-Session - 1.0 … … 1771 1771 $self->{SIDS}->{$sid}->{streamfeatures}->{'xmpp-session'} = 1; 1772 1772 } 1773 1773 1774 1774 } 1775 1775 … … 1833 1833 $self->TLSClientFailure($sid,$node); 1834 1834 } 1835 1835 1836 1836 if ($tag eq "proceed") 1837 1837 { … … 1853 1853 $timeout = 120 unless defined($timeout); 1854 1854 $timeout = 120 if ($timeout eq ""); 1855 1855 1856 1856 $self->TLSStartTLS($sid); 1857 1857 … … 1904 1904 return; 1905 1905 } 1906 1906 1907 1907 IO::Socket::SSL->start_SSL($self->{SIDS}->{$sid}->{sock},{SSL_verify_mode=>0x00}); 1908 1908 … … 1910 1910 $self->debug(1,"TLSClientProceed: SSL: We are secure") 1911 1911 if ($self->{SIDS}->{$sid}->{sock}); 1912 1912 1913 1913 $self->{SIDS}->{$sid}->{tls}->{done} = 1; 1914 1914 $self->{SIDS}->{$sid}->{tls}->{secure} = 1; … … 1925 1925 my $self = shift; 1926 1926 my $sid = shift; 1927 1927 1928 1928 return $self->{SIDS}->{$sid}->{tls}->{secure}; 1929 1929 } … … 1939 1939 my $self = shift; 1940 1940 my $sid = shift; 1941 1941 1942 1942 return $self->{SIDS}->{$sid}->{tls}->{done}; 1943 1943 } … … 1953 1953 my $self = shift; 1954 1954 my $sid = shift; 1955 1955 1956 1956 return $self->{SIDS}->{$sid}->{tls}->{error}; 1957 1957 } … … 1968 1968 my $sid = shift; 1969 1969 my $node = shift; 1970 1970 1971 1971 my $type = &XPath($node,"*/name()"); 1972 1972 … … 1986 1986 my $sid = shift; 1987 1987 my $type = shift; 1988 1988 1989 1989 $self->Send($sid,"<failure xmlns='".&ConstXMLNS('xmpp-tls')."'><${type}/></failure>"); 1990 1990 } … … 2018 2018 $self->SASLAnswerChallenge($sid,$node); 2019 2019 } 2020 2020 2021 2021 if ($tag eq "failure") 2022 2022 { 2023 2023 $self->SASLClientFailure($sid,$node); 2024 2024 } 2025 2025 2026 2026 if ($tag eq "success") 2027 2027 { … … 2045 2045 my $challenge64 = &XPath($node,"text()"); 2046 2046 my $challenge = MIME::Base64::decode_base64($challenge64); 2047 2047 2048 2048 #------------------------------------------------------------------------- 2049 2049 # As far as I can tell, if the challenge contains rspauth, then we authed. … … 2112 2112 2113 2113 return unless defined($mechanisms); 2114 2114 2115 2115 my $sasl = new Authen::SASL(mechanism=>join(" ",@{$mechanisms}), 2116 2116 callback=>{ … … 2140 2140 my $self = shift; 2141 2141 my $sid = shift; 2142 2142 2143 2143 return $self->{SIDS}->{$sid}->{sasl}->{authed}; 2144 2144 } … … 2154 2154 my $self = shift; 2155 2155 my $sid = shift; 2156 2156 2157 2157 return $self->{SIDS}->{$sid}->{sasl}->{done}; 2158 2158 } … … 2168 2168 my $self = shift; 2169 2169 my $sid = shift; 2170 2170 2171 2171 return $self->{SIDS}->{$sid}->{sasl}->{error}; 2172 2172 } … … 2183 2183 my $sid = shift; 2184 2184 my $node = shift; 2185 2185 2186 2186 my $type = &XPath($node,"*/name()"); 2187 2187 … … 2201 2201 my $sid = shift; 2202 2202 my $node = shift; 2203 2203 2204 2204 $self->{SIDS}->{$sid}->{sasl}->{authed} = 1; 2205 2205 $self->{SIDS}->{$sid}->{sasl}->{done} = 1; … … 2217 2217 my $sid = shift; 2218 2218 my $type = shift; 2219 2219 2220 2220 $self->Send($sid,"<failure xmlns='".&ConstXMLNS('xmpp-sasl')."'><${type}/></failure>"); 2221 2221 } … … 2292 2292 # Make sure we are receiving a valid stream on the same namespace. 2293 2293 #--------------------------------------------------------------------- 2294 2294 2295 2295 $self->debug(3,"_handle_root: ($self->{SIDS}->{$self->{SIDS}->{$sid}->{serverid}}->{namespace})"); 2296 2296 $self->{SIDS}->{$sid}->{status} = … … 2328 2328 } 2329 2329 } 2330 2330 2331 2331 #------------------------------------------------------------------------- 2332 2332 # Sometimes we will get an error, so let's parse the tag assuming that we … … 2335 2335 my $stream_prefix = $self->StreamPrefix($sid); 2336 2336 $self->debug(5,"_handle_root: stream_prefix($stream_prefix)"); 2337 2337 2338 2338 if ($tag eq $stream_prefix.":error") 2339 2339 { … … 2441 2441 $self->{SIDS}->{$sid}->{streamerror}->{type} = "unknown"; 2442 2442 $self->{SIDS}->{$sid}->{streamerror}->{node} = $node; 2443 2443 2444 2444 #------------------------------------------------------------------------- 2445 2445 # Check for older 0.9 streams and handle the errors for them. … … 2676 2676 my $tree = shift; 2677 2677 my $path = shift; 2678 2678 2679 2679 my $query = new XML::Stream::XPath::Query($path); 2680 2680 my $result = $query->execute($tree); … … 2683 2683 my %attribs = $result->getAttribs(); 2684 2684 return %attribs if (scalar(keys(%attribs)) > 0); 2685 2685 2686 2686 my @values = $result->getValues(); 2687 2687 @values = $result->getList() unless ($#values > -1); … … 2703 2703 my $tree = shift; 2704 2704 my $path = shift; 2705 2705 2706 2706 my $query = new XML::Stream::XPath::Query($path); 2707 2707 my $result = $query->execute($tree); … … 2891 2891 { 2892 2892 my $const = shift; 2893 2893 2894 2894 return $XMLNS{$const}; 2895 2895 } … … 2905 2905 my $self = shift; 2906 2906 my $sid = shift; 2907 2907 2908 2908 return $self->ns2prefix($sid,&ConstXMLNS("stream")); 2909 2909 } … … 2991 2991 2992 2992 $self->debug(1,"LoadSSL: Load the IO::Socket::SSL module"); 2993 2993 2994 2994 if (defined($SSL) && ($SSL == 1)) 2995 2995 { … … 2997 2997 return 1; 2998 2998 } 2999 2999 3000 3000 if (defined($SSL) && ($SSL == 0)) 3001 3001 { … … 3106 3106 $stream .= " ".$ns->GetStream(); 3107 3107 } 3108 3108 3109 3109 $stream .= ">"; 3110 3110
Note: See TracChangeset
for help on using the changeset viewer.