summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
ce2a43e)
- Correct OpenSSL verification
- Pass data after initial handshake (Oops!)
- Find a free port to listen on, if one is not specified
- Warn users when the authentication token expires
svn path=/trunk/scripts/vnc-client/; revision=1972
-from twisted.internet import reactor, ssl, protocol
+from twisted.internet import reactor, ssl, protocol, error
from OpenSSL import SSL
import base64, pickle
from OpenSSL import SSL
import base64, pickle
+import getopt, sys, os, time
class ClientContextFactory(ssl.ClientContextFactory):
def _verify(self, connection, x509, errnum, errdepth, ok):
class ClientContextFactory(ssl.ClientContextFactory):
def _verify(self, connection, x509, errnum, errdepth, ok):
- print '_verify (ok=%d):' % ok
- print ' subject:', x509.get_subject()
- print ' issuer:', x509.get_issuer()
- print ' errnum %s, errdepth %d' % (errnum, errdepth)
+ if verbose:
+ print '_verify (ok=%d):' % ok
+ print ' subject:', x509.get_subject()
+ print ' issuer:', x509.get_issuer()
+ print ' errnum %s, errdepth %d' % (errnum, errdepth)
+ if errnum == 10:
+ print 'The VNC server certificate has expired. Please contact xvm@mit.edu.'
return ok
def getContext(self):
return ok
def getContext(self):
self.transport.write(data)
if verbose: print "ProxyClient: connection made"
def dataReceived(self, data):
self.transport.write(data)
if verbose: print "ProxyClient: connection made"
def dataReceived(self, data):
if verbose: print 'ProxyClient: received data "%s"' % data
if data.startswith("VNCProxy/1.0 200 "):
if verbose: print 'ProxyClient: received data "%s"' % data
if data.startswith("VNCProxy/1.0 200 "):
- self.peer.transport.write(data[data.find("\n")+1:])
+ self.peer.transport.write(data[data.find("\n")+3:])
self.peer.transport.resumeProducing() # Allow reading
else:
print "Failed to connect: %s" % data
self.transport.loseConnection()
self.peer.transport.resumeProducing() # Allow reading
else:
print "Failed to connect: %s" % data
self.transport.loseConnection()
+ else:
+ self.peer.transport.write(data)
class ProxyClientFactory(protocol.ClientFactory):
protocol = ProxyClient
class ProxyClientFactory(protocol.ClientFactory):
protocol = ProxyClient
sys.exit(1)
if verbose: print "Will connect to %s:%s" % (connect_host, connect_port)
sys.exit(1)
if verbose: print "Will connect to %s:%s" % (connect_host, connect_port)
+ if listen[1] is None:
+ listen[1] = 5900
+ ready = False
+ while not ready:
+ try:
+ reactor.listenTCP(listen[1], ProxyFactory(connect_host, connect_port, authtoken, machine))
+ ready = True
+ except error.CannotListenError:
+ listen[1] += 1
+ else:
+ reactor.listenTCP(listen[1], ProxyFactory(connect_host, connect_port, authtoken, machine))
- listen[1] = 10003
- reactor.listenTCP(listen[1], ProxyFactory(connect_host, connect_port, authtoken, machine))
-
- print "Ready to connect. Connect to %s:%s now with your VNC client. The password is 'moocow'." % (listen[0], listen[1])
+ 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)
+ print "You must connect before your authentication token expires at %s." % \
+ (time.ctime(token_expires))