Esempio n. 1
0
 def _handle_new_client(self, conn):
   log.debug('Accepted client at %s' % conn.transport.getPeer().host)
   self.srclients.append(conn)
   # send auth message to drive the sr-client state machine
   salt = os.urandom(20)
   conn.send(VNSAuthRequest(salt))
   return
Esempio n. 2
0
 def msg_received(self, conn, msg):
     """Handles messages received from the TI server.  Starts the
     TopologyInteractor command-line interface once authentication is complete."""
     if msg is not None:
         if msg.get_type() == VNSAuthRequest.get_type():
             print 'Authenticating as %s' % self.username
             sha1_of_salted_pw = hashlib.sha1(msg.salt +
                                              self.auth_key).digest()
             conn.send(VNSAuthReply(self.username, sha1_of_salted_pw))
         elif msg.get_type() == VNSAuthStatus.get_type():
             if msg.auth_ok:
                 print 'Authentication successful.'
                 conn.send(TIOpen(self.tid))
                 reactor.callInThread(TopologyInteractor(self).cmdloop)
             else:
                 print 'Authentication failed.'
         elif msg.get_type() == TIBadNodeOrPort.get_type():
             txt = str(msg)
             if self.prev_bn_msg == txt:
                 self.prev_bn_msg = None  # only stop it once
             else:
                 if self.prev_bn_msg != None:
                     print '***%s!=%s' % (self.prev_bn_msg, txt)
                 self.prev_bn_msg = txt
                 print '\n', txt
         elif msg.get_type() == TIBanner.get_type():
             print '\n', msg.msg
         elif msg.get_type() == TIPacket.get_type():
             self.got_tapped_packet(msg)
         else:
             print 'unexpected TI message received: %s' % msg
Esempio n. 3
0
 def msg_received(self, conn, msg):
     """Handles messages received from the TI server.  Starts the
     TopologyInteractor command-line interface once authentication is complete."""
     if msg is not None:
         if msg.get_type() == VNSAuthRequest.get_type():
             print 'Authenticating as %s' % self.username
             sha1_of_salted_pw = hashlib.sha1(msg.salt + self.auth_key).digest()
             conn.send(VNSAuthReply(self.username, sha1_of_salted_pw))
         elif msg.get_type() == VNSAuthStatus.get_type():
             if msg.auth_ok:
                 print 'Authentication successful.'
                 conn.send(TIOpen(self.tid))
                 reactor.callInThread(TopologyInteractor(self).cmdloop)
             else:
                 print 'Authentication failed.'
         elif msg.get_type() ==  TIBadNodeOrPort.get_type():
             txt = str(msg)
             if self.prev_bn_msg == txt:
                 self.prev_bn_msg = None # only stop it once
             else:
                 if self.prev_bn_msg != None:
                     print '***%s!=%s'%(self.prev_bn_msg,txt)
                 self.prev_bn_msg = txt
                 print '\n', txt
         elif msg.get_type() ==  TIBanner.get_type():
             print '\n', msg.msg
         elif msg.get_type() ==  TIPacket.get_type():
             self.got_tapped_packet(msg)
         else:
             print 'unexpected TI message received: %s' % msg
Esempio n. 4
0
 def handle_new_client(self, conn):
     """Sends an authentication request to the new user."""
     logging.debug("client %s connected: sending auth request" % conn)
     conn.vns_auth_salt = os.urandom(20)
     conn.vns_authorized = False
     conn.vns_user_profile = None
     conn.send(VNSAuthRequest(conn.vns_auth_salt))