mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2024-12-28 08:05:53 -05:00
Fixed tunnel ping/pong that would corrupt traffic.
This commit is contained in:
parent
e1a7c94b22
commit
58adf804da
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -2227,7 +2227,8 @@ function OnWebSocket(msg, s, head) {
|
|||||||
if (this.parent.tunneling == false) {
|
if (this.parent.tunneling == false) {
|
||||||
msg = msg.toString();
|
msg = msg.toString();
|
||||||
if ((msg == 'c') || (msg == 'cr')) {
|
if ((msg == 'c') || (msg == 'cr')) {
|
||||||
this.parent.tunneling = true; this.pipe(this.parent.tcp); this.parent.tcp.pipe(this); debug(1, "Tunnel active");
|
// Pipe the connection, but don't pipe text websocket frames into the TCP socket.
|
||||||
|
this.parent.tunneling = true; this.pipe(this.parent.tcp, { dataTypeSkip: 1 }); this.parent.tcp.pipe(this); debug(1, "Tunnel active");
|
||||||
} else if ((msg.length > 6) && (msg.substring(0, 6) == 'error:')) {
|
} else if ((msg.length > 6) && (msg.substring(0, 6) == 'error:')) {
|
||||||
console.log(msg.substring(6));
|
console.log(msg.substring(6));
|
||||||
disconnectTunnel(this.tcp, this, msg.substring(6));
|
disconnectTunnel(this.tcp, this, msg.substring(6));
|
||||||
|
@ -1179,7 +1179,10 @@ function createMeshCore(agent) {
|
|||||||
|
|
||||||
// Called when we get data from the server for a TCP relay (We have to skip the first received 'c' and pipe the rest)
|
// Called when we get data from the server for a TCP relay (We have to skip the first received 'c' and pipe the rest)
|
||||||
function onTcpRelayServerTunnelData(data) {
|
function onTcpRelayServerTunnelData(data) {
|
||||||
if (this.first == true) { this.first = false; this.pipe(this.tcprelay); } // Pipe Server --> Target
|
if (this.first == true) {
|
||||||
|
this.first = false;
|
||||||
|
this.pipe(this.tcprelay, { dataTypeSkip: 1 }); // Pipe Server --> Target (don't pipe text type websocket frames)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function onTunnelClosed() {
|
function onTunnelClosed() {
|
||||||
@ -2279,6 +2282,13 @@ function createMeshCore(agent) {
|
|||||||
if (sdp != null) { ws.write({ type: 'answer', ctrlChannel: '102938', sdp: sdp }); }
|
if (sdp != null) { ws.write({ type: 'answer', ctrlChannel: '102938', sdp: sdp }); }
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case 'ping': {
|
||||||
|
ws.write("{\"ctrlChannel\":\"102938\",\"type\":\"pong\"}"); // Send pong response
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'pong': { // NOP
|
||||||
|
break;
|
||||||
|
}
|
||||||
case 'rtt': {
|
case 'rtt': {
|
||||||
ws.write({ type: 'rtt', ctrlChannel: '102938', time: obj.time });
|
ws.write({ type: 'rtt', ctrlChannel: '102938', time: obj.time });
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user