Beispiel #1
0
 def decode( data ) :
     data = decode( data )
     if type(data) is not dict : raise TypeError
     publicIP = data.get( 'publicIP' )
     try :
         validateIPAddress( publicIP )
     except :
         publicIP = ''
     directLocations = []
     routedLocations = []
     for direct in data.get('direct',[]) :
         if type(direct) is not list : continue
         direct = tuple( direct )
         try :
             validateInetAddress( direct )
         except :
             continue
         directLocations.append( DirectLocation(direct) )
     for routed in data.get('routed',[]) :
         if type(routed) is not list : continue
         if len(routed) != 2 : continue
         routerAddr,routerId = routed
         if type(routerId) is not str : continue
         if type(routerAddr) is not list : continue
         routerAddr = tuple( routerAddr )
         try :
             validateInetAddress( routerAddr )
         except :
             continue
         routedLocations.append( RoutedLocation(routerAddr,routerId) )
     return UserLocation( directLocations, routedLocations, publicIP )
Beispiel #2
0
 def decode(data):
     data = decode(data)
     if type(data) is not dict: raise TypeError
     publicIP = data.get('publicIP')
     try:
         validateIPAddress(publicIP)
     except:
         publicIP = ''
     directLocations = []
     routedLocations = []
     for direct in data.get('direct', []):
         if type(direct) is not list: continue
         direct = tuple(direct)
         try:
             validateInetAddress(direct)
         except:
             continue
         directLocations.append(DirectLocation(direct))
     for routed in data.get('routed', []):
         if type(routed) is not list: continue
         if len(routed) != 2: continue
         routerAddr, routerId = routed
         if type(routerId) is not str: continue
         if type(routerAddr) is not list: continue
         routerAddr = tuple(routerAddr)
         try:
             validateInetAddress(routerAddr)
         except:
             continue
         routedLocations.append(RoutedLocation(routerAddr, routerId))
     return UserLocation(directLocations, routedLocations, publicIP)
Beispiel #3
0
 def _onInput( self, data ) :
     try :
         (msgCode,requestId,payload) = decode(data)
         if (type(msgCode) is not IntType) or (type(requestId) is not IntType) :
             raise TypeError, 'invalid msg structure'
     except DecodeError, de :
         logger.warning( 'invalid msg structure: %s', de )
         return
Beispiel #4
0
 def _onInput(self, data, fromaddr):
     try:
         (msgCode, id, payload) = decode(data)
         if (type(msgCode) is not IntType) or (type(id) is not StringType):
             raise TypeError, 'invalid msg structure'
     except DecodeError, de:
         logger.exception('decode error: %s', de)
         return
Beispiel #5
0
 def _onInput( self, data, fromaddr ) :
     try :
         (msgCode,id,payload) = decode( data )
         if (type(msgCode) is not IntType) or (type(id) is not StringType) :
             raise TypeError, 'invalid msg structure'
     except DecodeError, de :
         logger.exception( 'decode error: %s', de )
         return
Beispiel #6
0
 def _onInput(self, data):
     try:
         (msgCode, requestId, payload) = decode(data)
         if (type(msgCode) is not IntType) or (type(requestId)
                                               is not IntType):
             raise TypeError, 'invalid msg structure'
     except DecodeError, de:
         logger.warning('invalid msg structure: %s', de)
         return
Beispiel #7
0
 def onInput(data):
     try:
         serviceName = decode(data)
         assert type(serviceName) is str
         assert len(serviceName) > 0
     except:
         onError()
         return
     obj.stream.shutdown()
     obj.stream = None
     op.notify((obj.sslConn, obj.peerKey, obj.peerName, serviceName))
Beispiel #8
0
 def onInput( data ) :
     try :
         serviceName = decode( data )
         assert type(serviceName) is str
         assert len(serviceName) > 0
     except :
         onError()
         return
     obj.stream.shutdown()
     obj.stream = None
     op.notify( (obj.sslConn,obj.peerKey,obj.peerName,serviceName) )
Beispiel #9
0
 def onInput( data ) :
     try :
         result = decode( data )
         assert type(result) is int
         assert result == 0
     except :
         doCancel()
         op.notify( None )
         return
     ms.shutdown()
     op.notify( sslConn )