generated from ztimson/template
Compare commits
13
Commits
240119ee5f
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
279b3ff684 | ||
|
|
b1e88159b0 | ||
|
|
8261c671af | ||
|
|
22985b6230 | ||
|
|
9b5bf5d2fb | ||
|
|
daaa53790a | ||
|
|
a2afcfa7bd | ||
|
|
b9ebb149ef | ||
|
|
cfcbccf152 | ||
|
|
9c8c108da0 | ||
|
|
d54d318166 | ||
|
|
4e70c78a7a | ||
|
|
fd6e2b07dc |
@@ -53,7 +53,7 @@ Homecast is a homebrew, Chromecast-style streaming appliance built around a Rasp
|
|||||||
The goal is to provide a simple, self-hosted casting and media experience while retaining complete control over the underlying hardware and software.
|
The goal is to provide a simple, self-hosted casting and media experience while retaining complete control over the underlying hardware and software.
|
||||||
|
|
||||||
Features include:
|
Features include:
|
||||||
- Installs ontop of any Rasbian + Wayland OS
|
- Installs on-top of any Raspberry Pi OS + Wayland
|
||||||
- Allows you to fully customize and use as your own media center
|
- Allows you to fully customize and use as your own media center
|
||||||
- Remote desktop into the pi via the browser on any device
|
- Remote desktop into the pi via the browser on any device
|
||||||
- Mirrors to the TV
|
- Mirrors to the TV
|
||||||
@@ -70,8 +70,6 @@ Features include:
|
|||||||
[](https://www.w3.org/Style/CSS/Overview.en.html)
|
[](https://www.w3.org/Style/CSS/Overview.en.html)
|
||||||
[](https://www.raspberrypi.com/)
|
[](https://www.raspberrypi.com/)
|
||||||
[](https://wayland.freedesktop.org/)
|
[](https://wayland.freedesktop.org/)
|
||||||
[](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket)
|
|
||||||
[](https://novnc.com/)
|
|
||||||
|
|
||||||
## Setup
|
## Setup
|
||||||
|
|
||||||
|
|||||||
+35
@@ -0,0 +1,35 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# Fallback AP
|
||||||
|
curl -sL https://git.zakscode.com/ztimson/fallback-ap/raw/branch/master/install.sh | sudo bash
|
||||||
|
|
||||||
|
# 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
|
||||||
|
source ~/.bashrc
|
||||||
|
nvm install stable && nvm use stable
|
||||||
|
|
||||||
|
# Install Homecast
|
||||||
|
mkdir /app && cd /app
|
||||||
|
git clone https://git.zakscode.com/ztimson/homecast.git .
|
||||||
|
npm i
|
||||||
|
mkdir -p certs
|
||||||
|
openssl req -x509 -newkey rsa:2048 \
|
||||||
|
-keyout certs/key.pem \
|
||||||
|
-out certs/cert.pem \
|
||||||
|
-days 3650 \
|
||||||
|
-nodes \
|
||||||
|
-subj "/CN=homecast"
|
||||||
|
|
||||||
|
# TODO: Create service
|
||||||
+1
-1
@@ -4,7 +4,7 @@
|
|||||||
"description": "The Homebrew Chromecast",
|
"description": "The Homebrew Chromecast",
|
||||||
"main": "src/server.mjs",
|
"main": "src/server.mjs",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "node server.mjs"
|
"start": "node src/server.mjs"
|
||||||
},
|
},
|
||||||
"keywords": [],
|
"keywords": [],
|
||||||
"author": "",
|
"author": "",
|
||||||
|
|||||||
+3
-26
@@ -8,7 +8,7 @@ import {fileURLToPath} from 'node:url';
|
|||||||
import {WebSocketServer} from 'ws';
|
import {WebSocketServer} from 'ws';
|
||||||
|
|
||||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
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 PORT = process.env['PORT'] || 3000;
|
||||||
const VNC_HOST = '127.0.0.1';
|
const VNC_HOST = '127.0.0.1';
|
||||||
const VNC_PORT = 5900;
|
const VNC_PORT = 5900;
|
||||||
@@ -67,36 +67,13 @@ wss.on('connection', ws => {
|
|||||||
|
|
||||||
const socket = net.createConnection(VNC_PORT, VNC_HOST);
|
const socket = net.createConnection(VNC_PORT, VNC_HOST);
|
||||||
|
|
||||||
socket.on('connect', () => {
|
|
||||||
console.log(`Connected to VNC ${VNC_HOST}:${VNC_PORT}`);
|
|
||||||
});
|
|
||||||
|
|
||||||
socket.on('data', data => {
|
socket.on('data', data => {
|
||||||
console.log(`VNC -> browser: ${data.length} bytes`);
|
if (ws.readyState === ws.OPEN) ws.send(data, {binary: true});
|
||||||
|
|
||||||
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});
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
ws.on('message', (data, isBinary) => {
|
ws.on('message', (data, isBinary) => {
|
||||||
const buffer = Buffer.isBuffer(data) ? data : Buffer.from(data);
|
const buffer = Buffer.isBuffer(data) ? data : Buffer.from(data);
|
||||||
|
if (socket.writable) socket.write(buffer);
|
||||||
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);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
ws.on('error', error => {
|
ws.on('error', error => {
|
||||||
|
|||||||
Reference in New Issue
Block a user