generated from ztimson/template
Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b1e88159b0 | ||
|
|
8261c671af |
+2
-25
@@ -67,36 +67,13 @@ wss.on('connection', ws => {
|
||||
|
||||
const socket = net.createConnection(VNC_PORT, VNC_HOST);
|
||||
|
||||
socket.on('connect', () => {
|
||||
console.log(`Connected to VNC ${VNC_HOST}:${VNC_PORT}`);
|
||||
});
|
||||
|
||||
socket.on('data', data => {
|
||||
console.log(`VNC -> browser: ${data.length} bytes`);
|
||||
|
||||
if (data.length <= 64) {
|
||||
console.log(` hex: ${data.toString('hex')}`);
|
||||
console.log(` text: ${JSON.stringify(data.toString())}`);
|
||||
}
|
||||
|
||||
if (ws.readyState === ws.OPEN) {
|
||||
ws.send(data, {binary: true});
|
||||
}
|
||||
if (ws.readyState === ws.OPEN) ws.send(data, {binary: true});
|
||||
});
|
||||
|
||||
ws.on('message', (data, isBinary) => {
|
||||
const buffer = Buffer.isBuffer(data) ? data : Buffer.from(data);
|
||||
|
||||
console.log(`Browser -> VNC: ${buffer.length} bytes (${isBinary ? 'binary' : 'text'})`);
|
||||
|
||||
if (buffer.length <= 64) {
|
||||
console.log(` hex: ${buffer.toString('hex')}`);
|
||||
console.log(` text: ${JSON.stringify(buffer.toString())}`);
|
||||
}
|
||||
|
||||
if (socket.writable) {
|
||||
socket.write(buffer);
|
||||
}
|
||||
if (socket.writable) socket.write(buffer);
|
||||
});
|
||||
|
||||
ws.on('error', error => {
|
||||
|
||||
Reference in New Issue
Block a user