From ab0237e5e6a150bebfb2d83baf81ce0d2fa65d8a Mon Sep 17 00:00:00 2001
From: Xabier de Zuazo <xabier@onddo.com>
Date: Sun, 7 Apr 2013 12:04:29 +0200
Subject: [PATCH] "hash" varible moved inside joinServerRequest function

---
 index.js | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/index.js b/index.js
index 1420f4c..248794d 100644
--- a/index.js
+++ b/index.js
@@ -261,9 +261,6 @@ function createClient(options) {
         return
       }
 
-      var hash = crypto.createHash('sha1');
-      hash.update(packet.serverId);
-
       if (haveCredentials) {
         joinServerRequest(onJoinServerResponse);
       } else {
@@ -283,6 +280,8 @@ function createClient(options) {
       }
 
       function joinServerRequest(cb) {
+        var hash = crypto.createHash('sha1');
+        hash.update(packet.serverId);
         hash.update(sharedSecret);
         hash.update(packet.publicKey);