Alexey patch that allows discover that server is violating RFC by not restarting stream after TLS start.

If server did such thing xmpppy will not crash unpredictely but will issue a appropriate exception.
This commit is contained in:
Yann Leboulanger 2005-05-10 09:27:04 +00:00
parent 61558b8942
commit aa9de25923
1 changed files with 5 additions and 0 deletions

View File

@ -89,6 +89,7 @@ class Dispatcher(PlugIn):
self.Stream=simplexml.NodeBuilder()
self.Stream._dispatch_depth=2
self.Stream.dispatch=self.dispatch
self.Stream.stream_header_received=self._check_stream_start
self._owner.debug_flags.append(simplexml.DBG_NODEBUILDER)
self.Stream.DEBUG=self._owner.DEBUG
self.Stream.features=None
@ -99,6 +100,10 @@ class Dispatcher(PlugIn):
self._metastream.setAttr('to',self._owner.Server)
self._owner.send("<?xml version='1.0'?>%s>"%str(self._metastream)[:-2])
def _check_stream_start(self,ns,tag,attrs):
if ns<>NS_STREAMS or tag<>'stream':
raise ValueError('Incorrect stream start: (%s,%s). Terminating.'%(tag,ns))
def Process(self, timeout=0):
""" Check incoming stream for data waiting. If "timeout" is positive - block for as max. this time.
Returns: