- TOKEN_KEY = "0M6W0U1IXexThi5idy8mnkqPKEq1LtEnlK/pZSn0cDrN"
-
- data = {}
- data["user"] = username
- data["machine"] = machine.name
- data["expires"] = time.time()+(5*60)
- pickled_data = cPickle.dumps(data)
- m = hmac.new(TOKEN_KEY, digestmod=sha)
- m.update(pickled_data)
- token = {'data': pickled_data, 'digest': m.digest()}
- token = cPickle.dumps(token)
- token = base64.urlsafe_b64encode(token)
- if controls.listHost(machine) == 'sx-blade-2.mit.edu':
- port = 10004
+ token = controls.vnctoken(machine)
+ host = controls.listHost(machine)
+ if host:
+ port = 10003 + [h.hostname for h in config.hosts].index(host)