generated from ztimson/template
Compare commits
6
Commits
a2afcfa7bd
..
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
279b3ff684 | ||
|
|
b1e88159b0 | ||
|
|
8261c671af | ||
|
|
22985b6230 | ||
|
|
9b5bf5d2fb | ||
|
|
daaa53790a |
@@ -7,6 +7,13 @@ curl -sL https://git.zakscode.com/ztimson/fallback-ap/raw/branch/master/install.
|
||||
|
||||
# VNC
|
||||
sudo raspi-config nonint do_vnc 0
|
||||
cat <<EOF | sudo tee /etc/wayvnc/config
|
||||
use_relative_paths=true
|
||||
address=127.0.0.1
|
||||
enable_auth=false
|
||||
enable_pam=false
|
||||
relax_encryption=true
|
||||
EOF
|
||||
|
||||
# Node
|
||||
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.7/install.sh | bash
|
||||
|
||||
+3
-26
@@ -8,7 +8,7 @@ import {fileURLToPath} from 'node:url';
|
||||
import {WebSocketServer} from 'ws';
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
const NOVNC = path.join(__dirname, 'node_modules/@novnc/novnc');
|
||||
const NOVNC = path.join(__dirname, '../node_modules/@novnc/novnc');
|
||||
const PORT = process.env['PORT'] || 3000;
|
||||
const VNC_HOST = '127.0.0.1';
|
||||
const VNC_PORT = 5900;
|
||||
@@ -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