Fix tcp proxy crash bug
diff --git a/wsproxy/wsproxy-tcp.js b/wsproxy/wsproxy-tcp.js
old mode 100755
new mode 100644
index 0e700c6..7bdb1c9
--- a/wsproxy/wsproxy-tcp.js
+++ b/wsproxy/wsproxy-tcp.js
@@ -1,5 +1,3 @@
-#!/usr/bin/env node
-
/*
* @author: Wentao Shang
* See COPYING for copyright and distribution information.
@@ -49,6 +47,7 @@
}
var sock_ready = false;
+ var ws_ready = true;
var send_queue = [];
var sock = net.connect({port: 9695, host: ccndhost});
@@ -76,6 +75,7 @@
ws.on('close', function() {
if (LOG > 0) console.log('WebSocket connection closed.');
+ ws_ready = false;
sock.end();
});
@@ -100,7 +100,9 @@
console.log(logMsg);
}
- ws.send(bytesView.buffer, {binary: true, mask: false});
+ if (ws_ready == true) {
+ ws.send(bytesView.buffer, {binary: true, mask: false});
+ }
}
});