Changeset 1972 for trunk/scripts
- Timestamp:
- Jan 9, 2009, 11:42:17 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/scripts/vnc-client/invirt-vnc-client
r1969 r1972 1 1 #!/usr/bin/python 2 from twisted.internet import reactor, ssl, protocol 2 from twisted.internet import reactor, ssl, protocol, error 3 3 from OpenSSL import SSL 4 4 import base64, pickle 5 import getopt, sys 5 import getopt, sys, os, time 6 6 7 7 verbose = False … … 20 20 21 21 def _verify(self, connection, x509, errnum, errdepth, ok): 22 print '_verify (ok=%d):' % ok 23 print ' subject:', x509.get_subject() 24 print ' issuer:', x509.get_issuer() 25 print ' errnum %s, errdepth %d' % (errnum, errdepth) 22 if verbose: 23 print '_verify (ok=%d):' % ok 24 print ' subject:', x509.get_subject() 25 print ' issuer:', x509.get_issuer() 26 print ' errnum %s, errdepth %d' % (errnum, errdepth) 27 if errnum == 10: 28 print 'The VNC server certificate has expired. Please contact xvm@mit.edu.' 26 29 return ok 27 30 … … 60 63 if verbose: print "ProxyClient: connection made" 61 64 def dataReceived(self, data): 62 if not ready:65 if not self.ready: 63 66 if verbose: print 'ProxyClient: received data "%s"' % data 64 67 if data.startswith("VNCProxy/1.0 200 "): 65 ready = True68 self.ready = True 66 69 if "\n" in data: 67 self.peer.transport.write(data[data.find("\n")+ 1:])70 self.peer.transport.write(data[data.find("\n")+3:]) 68 71 self.peer.transport.resumeProducing() # Allow reading 69 72 else: 70 73 print "Failed to connect: %s" % data 71 74 self.transport.loseConnection() 75 else: 76 self.peer.transport.write(data) 72 77 73 78 class ProxyClientFactory(protocol.ClientFactory): … … 183 188 184 189 if verbose: print "Will connect to %s:%s" % (connect_host, connect_port) 185 186 listen[1] = 10003 187 reactor.listenTCP(listen[1], ProxyFactory(connect_host, connect_port, authtoken, machine)) 188 189 print "Ready to connect. Connect to %s:%s now with your VNC client. The password is 'moocow'." % (listen[0], listen[1]) 190 if listen[1] is None: 191 listen[1] = 5900 192 ready = False 193 while not ready: 194 try: 195 reactor.listenTCP(listen[1], ProxyFactory(connect_host, connect_port, authtoken, machine)) 196 ready = True 197 except error.CannotListenError: 198 listen[1] += 1 199 else: 200 reactor.listenTCP(listen[1], ProxyFactory(connect_host, connect_port, authtoken, machine)) 201 202 print "Ready to connect. Connect to %s:%s (display %d) now with your VNC client. The password is 'moocow'." % (listen[0], listen[1], listen[1]-5900) 203 print "You must connect before your authentication token expires at %s." % \ 204 (time.ctime(token_expires)) 190 205 191 206 reactor.run()
Note: See TracChangeset
for help on using the changeset viewer.