Fixed tunnel ping/pong that would corrupt traffic.
Ylian Saint-Hilaire committed
Jul 19, 2020 at 14:45 UTC
eacc7c91b207764c0dce7ac6acce694b3c14c740
5 files changed
+13
-2
agents/MeshCentralRouter.exe
Binary files a/agents/MeshCentralRouter.exe and b/agents/MeshCentralRouter.exe differ
agents/MeshCmd-signed.exe
Binary files a/agents/MeshCmd-signed.exe and b/agents/MeshCmd-signed.exe differ
agents/MeshCmd64-signed.exe
Binary files a/agents/MeshCmd64-signed.exe and b/agents/MeshCmd64-signed.exe differ
agents/meshcmd.js
+2
-1
@@ -2227,7 +2227,8 @@ function OnWebSocket(msg, s, head) {
2227
if (this.parent.tunneling == false) {
2228
msg = msg.toString();
2229
if ((msg == 'c') || (msg == 'cr')) {
2230
- this.parent.tunneling = true; this.pipe(this.parent.tcp); this.parent.tcp.pipe(this); debug(1, "Tunnel active");
2230
+ // Pipe the connection, but don't pipe text websocket frames into the TCP socket.
2231
+ this.parent.tunneling = true; this.pipe(this.parent.tcp, { dataTypeSkip: 1 }); this.parent.tcp.pipe(this); debug(1, "Tunnel active");
2232
} else if ((msg.length > 6) && (msg.substring(0, 6) == 'error:')) {
2233
console.log(msg.substring(6));
2234
disconnectTunnel(this.tcp, this, msg.substring(6));
agents/meshcore.js
+11
-1
@@ -1179,7 +1179,10 @@ function createMeshCore(agent) {
1179
1180
// Called when we get data from the server for a TCP relay (We have to skip the first received 'c' and pipe the rest)
1181
function onTcpRelayServerTunnelData(data) {
1182
- if (this.first == true) { this.first = false; this.pipe(this.tcprelay); } // Pipe Server --> Target
1182
+ if (this.first == true) {
1183
+ this.first = false;
1184
+ this.pipe(this.tcprelay, { dataTypeSkip: 1 }); // Pipe Server --> Target (don't pipe text type websocket frames)
1185
+ }
1186
}
1187
1188
function onTunnelClosed() {
@@ -2279,6 +2282,13 @@ function createMeshCore(agent) {
2282
if (sdp != null) { ws.write({ type: 'answer', ctrlChannel: '102938', sdp: sdp }); }
2283
break;
2284
}
2285
+ case 'ping': {
2286
+ ws.write("{\"ctrlChannel\":\"102938\",\"type\":\"pong\"}"); // Send pong response
2287
+ break;
2288
+ }
2289
+ case 'pong': { // NOP
2290
+ break;
2291
+ }
2292
case 'rtt': {
2293
ws.write({ type: 'rtt', ctrlChannel: '102938', time: obj.time });
2294
break;