Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 40 additions & 41 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,61 +1,60 @@
# Gothwad Remote Desktop (`remotedesktop.gothwadtech.com`)

**100% Zero-Database, Zero-Worker Cloudflare Pages Portal — Main Windows 11 OS Control + Headless Isolated Hyper-V Background VM, Secured by Gothwad Accounts (`@gothwadtech.com`) & WebRTC P2P!**
**Simple, fast browser-based Remote Desktop for phone and desktop — powered by Gothwad Accounts (`@gothwadtech.com`), Zero-D1 Cloudflare Pages, and WebRTC P2P.**

Yeh repository (`GothwadTech/remotedesktop`) bilkul **`GothwadTech/meet`** ki tarah **Zero-D1 / Zero-Backend** architecture par bani hai — Cloudflare par **koi D1 database nahi banana, koi Worker deploy nahi karna, koi secret set nahi karna!** Bas repo ko Cloudflare Pages se connect karo aur `remotedesktop.gothwadtech.com` live!
Modeled on Google Chrome Remote Desktop (`remotedesktop.google.com`), `GothwadTech/remotedesk` lets you connect to your **Windows 11 Main Desktop** in one tap from any mobile phone or desktop browser, with an optional secondary **Isolated Hyper-V Background VM** mode when you want a separate workspace without disturbing the physical screen.

---

## ⚠️ Important Consent & Transparency Rules

1. **Explicit Owner Permission Mandatory:** Kisi bhi Windows PC par one-time setup sirf unki **clear permission aur जानकारी** se karein (Agent pairing bina explicit consent confirm kiye reject ho jaati hai).
2. **Dual-Mode Transparency:**
- **🖥️ Mode 1 (Main Windows 11 Host OS):** Jab aap main OS connect karte ho, toh bilkul *Chrome Remote Desktop* ki tarah host screen par `"Your desktop is shared with username@gothwadtech.com [Stop Sharing]"` banner dikhta hai.
- **📦 Mode 2 (Background Hyper-V VM):** Jab dost apna kaam kar raha ho, toh aap isolated Hyper-V VM me connect hote ho — dost ki screen, mouse, ya personal files bilkul disturb nahi hoti!
3. **Laptop Battery Safety:** Kabhi bhi **"On Battery"** sleep disable mat karna taaki bag me band laptop overheat na ho.
## Key Features

- **Simple Chrome Remote Desktop UI (Phone & Desktop):**
- Clean three-section layout: **Remote Access**, **Remote Support**, and **Set up via PowerShell** (desktop left navigation rail + mobile bottom navigation bar).
- Exact ecosystem theme palette: **`#212121`** in Dark mode and **`#ffffff`** in Light mode with instant theme switching.
- **Universal Gothwad Account Menu** (`https://accounts.gothwadtech.com/widget/account-menu.js`) with multi-account (`u/0..5`) switching and `+n` avatar badge.
- **Mobile-Ready Full-Screen Viewer:**
- Collapsible floating top toolbar handle so 100% of your phone screen stays unobstructed.
- Dedicated mobile **Keyboard** button (triggers Android/iOS virtual keyboard) and **Direct Touch / Trackpad** cursor toggle.
- **Main Desktop First, Background VM Optional:**
- Primary click connects straight to your Windows 11 Main Desktop (with a visible Chrome Remote Desktop-style `"Your desktop is shared [Stop Sharing]"` banner on the host).
- Optional secondary **Hyper-V Background VM** (`Max 4 GB RAM`, `60% CPU`, Wi-Fi `Default Switch` NAT) accessible from the device overflow menu or viewer toggle.
- **100% Zero-D1 / Zero-Backend Cloudflare Pages:**
- Uses `.gothwadtech.com` SSO cookies via `https://api.gothwadtech.com/api/auth/me` directly from the browser.
- Deterministic WebRTC P2P discovery (`grd-<username>-slot-1..6`) via `PeerJS` + STUN/TURN.
- Constant-time `HMAC-SHA256(pin, nonce:viewer:mode)` challenge-response PIN verification on the Windows host (raw PIN never crosses the network).

---

## 🧠 Bina Cloudflare D1 Database ke Kaise Kaam Karta Hai? (Zero-D1 Magic!)
## Safety & Owner Consent

1. **Direct Gothwad Accounts SSO (`api.gothwadtech.com`):**
- `GothwadTech/accounts` pehle se har `*.gothwadtech.com` subdomain ke liye CORS + `.gothwadtech.com` `HttpOnly` multi-account cookies (`u/0..5`) allow karta hai!
- Isliye `remotedesktop.gothwadtech.com` seedha browser se `https://api.gothwadtech.com/api/auth/me` call karke aapka `@gothwadtech.com` user verify kar leta hai — kisi alag Worker ya D1 ki zaroorat hi nahi!
2. **Deterministic WebRTC P2P Slots (`PeerJS` + STUN/TURN, `GothwadTech/meet` Stack):**
- Jab aapka Windows PC start hota hai, `GothwadRemoteAgent.exe` aapke Gothwad username ke deterministic P2P slot (`grd-<username>-slot-1`..`6`) par online aa jaata hai.
- Jab aap duniya me kahin se bhi `remotedesktop.gothwadtech.com` kholte ho, browser aapke slots ko P2P probe karke turant **Online**, **RAM/CPU**, aur **Hyper-V VM State** dikha deta hai!
3. **Zero-Knowledge HMAC-SHA256 PIN + Host-Local ACL (`agent-config.json`):**
- Aapka **6-digit PIN** aur allowed `@gothwadtech.com` users (`vm_only` vs `host_and_vm`) seedha Windows Host ke `C:\ProgramData\GothwadRemote\agent-config.json` me rehte hain.
- Connect karte waqt raw PIN kabhi network par nahi jaata — fresh `nonce` ke saath `HMAC-SHA256(pin, nonce + ":" + viewer + ":" + mode)` verify hota hai (5 galat tries par 5-min lockout!).
1. **Explicit Owner Consent Required:** One-time setup on any Windows PC must only be run with the explicit permission of the computer's owner (`--confirm-owner-consent`).
2. **Visible Screen-Sharing Notice:** Connecting to the Main Windows Desktop displays an always-on-top `"Your desktop is shared ... [Stop Sharing]"` banner on the host monitor.
3. **Battery Protection:** Never disable **"On Battery"** sleep so a laptop closed inside a backpack cannot overheat.

---

## ✨ Website ke Andar Built-in Windows Setup Wizard (`/setup`)
## Documentation Index

Bilkul `remotedesktop.google.com/headless` ki tarah `https://remotedesktop.gothwadtech.com` par top bar me **`Windows Setup & Commands`** tab hai jahan user ko saare steps aur copy-paste PowerShell commands website ke andar hi mil jaate hain:
- **Mode Picker:** `Main OS + Background VM`, `Main OS Only` (2-min setup), ya `Background VM Only`.
- **Interactive Hyper-V VM Builder:** RAM, Disk, Linux/Windows ISO badalte hi live PowerShell command banti hai.
- **1-Line Gothwad P2P Installer Command** + Direct `.EXE` / `.ZIP` GitHub Release download buttons.
- **Safe Charger Power Command** (`standby-timeout-ac 0`, battery sleep protected).
- [`docs/01-architecture.md`](docs/01-architecture.md) — Zero-D1 WebRTC P2P & Wi-Fi NAT architecture
- [`docs/02-host-setup-windows11.md`](docs/02-host-setup-windows11.md) — Windows 11 host setup & safe power rules
- [`docs/03-option-a-crd-vm.md`](docs/03-option-a-crd-vm.md) — Optional Background VM with Chrome Remote Desktop
- [`docs/04-option-b-kasm-cloudflare.md`](docs/04-option-b-kasm-cloudflare.md) — Optional Background VM with KasmVNC & Cloudflare Tunnel
- [`docs/05-option-c-guacamole-rdp.md`](docs/05-option-c-guacamole-rdp.md) — Optional Background VM with Tailscale & RDP
- [`docs/06-troubleshooting-faq.md`](docs/06-troubleshooting-faq.md) — Wi-Fi reconnects, PIN lockouts, and troubleshooting
- [`docs/07-gothwad-ecosystem-setup.md`](docs/07-gothwad-ecosystem-setup.md) — 60-second Cloudflare Pages deployment guide

---

## 🚀 60-Second Cloudflare Pages Deployment (Zero D1, Zero Secrets!)

1. **Cloudflare Dashboard -> Workers & Pages -> Create -> Pages -> Connect to Git (`GothwadTech/remotedesktop`)**
2. **Build command:** `npm run build`
3. **Build output directory:** `dist`
4. **Custom domain:** `remotedesktop.gothwadtech.com`
5. **Done!** 🎉
## Local Development

---
```bash
npm install
npm test
npm run dev
```

## 📚 Documentation Index (`docs/`)
Build static bundle for Cloudflare Pages (`dist/`):

1. **[`docs/07-gothwad-ecosystem-setup.md`](docs/07-gothwad-ecosystem-setup.md)** — ⭐ **START HERE:** Zero-D1 Architecture, Cloudflare Pages 1-Step Deploy & GitHub Actions EXE Release Guide.
2. **[`docs/01-architecture.md`](docs/01-architecture.md)** — Hyper-V Type-1 Service, `Default Switch` Wi-Fi NAT & CGNAT Bypass Deep Dive.
3. **[`docs/02-host-setup-windows11.md`](docs/02-host-setup-windows11.md)** — Windows 11 Pro (16GB/512GB) Safe RAM/CPU Limits & Auto-Boot VM Guide.
4. **[`docs/03-option-a-crd-vm.md`](docs/03-option-a-crd-vm.md)** — Alternative A: Chrome Remote Desktop Inside Guest VM.
5. **[`docs/04-option-b-kasm-cloudflare.md`](docs/04-option-b-kasm-cloudflare.md)** — Alternative B: KasmVNC (`Webtop`) + Cloudflare Tunnel.
6. **[`docs/05-option-c-guacamole-rdp.md`](docs/05-option-c-guacamole-rdp.md)** — Alternative C: DWService / Apache Guacamole HTML5 Windows RDP.
7. **[`docs/06-troubleshooting-faq.md`](docs/06-troubleshooting-faq.md)** — 1080p Resolution Fix, Wi-Fi Drop Watchdog, Gaming Pause/Resume Shortcut & SSD Compacting.
```bash
npm run build
```
70 changes: 22 additions & 48 deletions docs/01-architecture.md
Original file line number Diff line number Diff line change
@@ -1,65 +1,39 @@
# 01 — System Architecture & How It Works
# 01 — Architecture: Zero-D1 WebRTC P2P & Optional Hyper-V VM

Yeh document explain karta hai ki **1 km (ya kisi bhi distance) door rakhe Wi-Fi laptop** par bina router chhede aur bina host desktop disturb kiye browser-based VM kaise kaam karta hai.
This document explains how **Gothwad Remote Desktop (`remotedesktop.gothwadtech.com`)** connects to a remote Windows 11 laptop over Wi-Fi or mobile hotspot without router port forwarding, without a Cloudflare D1 database, and with optional background VM isolation.

---

## 1. Windows 11 Pro ka Sabse Bada Plus Point: Native Hyper-V
## 1. Primary Mode vs Secondary Background VM Mode

Aapke dost ke laptop me **Windows 11 Pro** hai — yeh sabse bada advantage hai kyunki isme **Microsoft Hyper-V** pehle se built-in aata hai (free, official Microsoft feature).

### VirtualBox / VMware Workstation vs Hyper-V:
| Feature | VirtualBox / VMware Player | **Microsoft Hyper-V (Win 11 Pro)** |
| :--- | :--- | :--- |
| **Type** | Type-2 (App ki tarah chalta hai) | **Type-1 Bare-Metal Hypervisor** |
| **Auto-Start on Boot** | Mushkil (User login aur taskbar window chahiye) | **Native Windows Service (`vmms`) — Boot hote hi start!** |
| **Headless Mode** | Aksar taskbar me icon/window aati hai | **100% Headless Service (Zero UI windows on desktop)** |
| **Dynamic Memory** | Fixed RAM block kar leta hai | **Dynamic RAM (Jitni zaroorat utni hi RAM use karega)** |
| **Auto Save on Shutdown**| VM crash ho sakta hai agar PC band ho | **Graceful State Save — Wahin se resume hoga!** |
1. **Primary Mode — Main Windows 11 Desktop (`host_os`):**
- Works just like Google Chrome Remote Desktop.
- Streams the Windows 11 desktop over WebRTC DataChannels and forwards mouse, trackpad, keyboard, and clipboard input.
- Displays a visible `"Your desktop is shared with <user>@gothwadtech.com [Stop Sharing]"` banner on the host monitor whenever a session is active.
2. **Secondary Optional Mode — Isolated Hyper-V Background VM (`hyperv_vm`):**
- Windows 11 Pro includes Microsoft's Type-1 **Hyper-V** hypervisor (`vmms` service).
- If enabled, an isolated Linux or Windows guest VM runs headlessly in the background (capped at **4 GB dynamic RAM** and **60% CPU**) so remote work never disturbs the person using the physical laptop.

---

## 2. Wi-Fi + CGNAT Problem aur Uska Solution
## 2. Solving Wi-Fi & CGNAT Without Router Access

Jab dost ka laptop ghar ke Wi-Fi ya mobile hotspot se connect hota hai, toh 2 challenges aate hain:
1. **CGNAT / Dynamic IP:** India me JioFiber, Airtel, aur mobile networks par aapko public IP nahi milti, isliye router me **Port Forwarding kaam nahi karti**.
2. **Wi-Fi Bridging Issue:** Laptop ke Wi-Fi card par Hyper-V ka "External Switch" (Bridge) banane se dost ka Wi-Fi bar-bar disconnect ho sakta hai.
Residential fiber and mobile hotspots place laptops behind **CGNAT** (no public IPv4 address for port forwarding). In addition, bridging a laptop Wi-Fi adapter directly in Hyper-V frequently drops wireless connections.

### Solution: `Default Switch` (WinNAT) + Outbound Tunnel Inside VM
1. **Hyper-V `Default Switch`:** Windows 11 Hyper-V me ek built-in virtual switch hota hai jiska naam hai **`Default Switch`**. Dost chahe Ghar ka Wi-Fi lagaye, Hostel Wi-Fi lagaye, ya Phone Hotspot — Windows automatic apne internet ko NAT ke through VM ke andar bhej deta hai!
2. **Outbound Connection:** VM ke andar chalne wala agent (`chromoting` / `cloudflared` / `tailscaled`) andar se bahar (`Outbound Port 443 HTTPS/WebRTC`) connect karta hai. Isliye:
- Router login ki zaroorat **NAHI** hai.
- Static IP ki zaroorat **NAHI** hai.
- Host Windows Firewall me inbound ports kholne ki zaroorat **NAHI** hai.
Our architecture solves both problems cleanly:
1. **Outbound WebRTC + TURN Relay:** The Windows host agent (`gothwad_agent.py`) opens an outbound WebSocket to PeerJS signaling and establishes peer-to-peer WebRTC connections via Google STUN and OpenRelay TURN over port `443` — zero router configuration or inbound firewall rules required.
2. **Hyper-V `Default Switch` (NAT):** For the optional Background VM, Hyper-V's built-in `Default Switch` automatically NATs traffic over whichever Wi-Fi network or phone hotspot the Windows host joins.

---

## 3. Boot-to-Browser Lifecycle (Jab Dost Laptop On Karega Toh Kya Hoga?)
## 3. Boot-to-Browser Lifecycle

```text
[00:00 sec] Dost ne Laptop ka Power Button dabaya
|
[00:12 sec] Windows 11 Pro Boot hua -> Dost apna kaam shuru kar sakta hai
| (30-second Auto-Start Delay rakha hai taaki boot time pe SSD slow na ho)
|
[00:42 sec] Hyper-V Service (`vmms`) background me Guest VM ko Resume/Boot karti hai
| (Dost ke desktop par koi window nahi aati)
|
[00:55 sec] Dost ka Laptop Wi-Fi se connect hota hai -> `Default Switch` VM ko internet deta hai
|
[01:05 sec] Guest VM ke andar ka Tunnel Service (CRD / Cloudflared / Tailscale)
| auto-start hota hai aur Cloud Relay se jud jaata hai
|
[01:10 sec] AAP APNE GHAR PE BROWSER KHOLTE HO -> VM "ONLINE" DIKHTA HAI -> CLICK & USE!
[00:00s] Windows 11 laptop powers on
[00:15s] Scheduled Task starts GothwadRemoteAgent.exe in the background
[00:20s] Host connects to Wi-Fi and registers on P2P slot grd-<username>-slot-1
[00:30s] (Optional) Hyper-V service resumes RemoteWorkVM after a 30s SSD-friendly delay
[00:35s] Open remotedesktop.gothwadtech.com on phone or desktop -> Click Connect -> Enter 6-digit PIN
```

Aur jab dost apna laptop **Shut Down** karega:
- Hyper-V automatically VM ki current state (khule huye apps ke saath!) disk par **Save** kar dega (`AutomaticStopAction = Save`).
- Agli baar laptop on hone par VM wahin se wapas chalu ho jayega!

---

## 4. Security & Isolation Guarantee

- **Host -> Guest Isolation:** Aap VM ke andar kuch bhi install karo, browser chalao, code compile karo — woh sab ek single `.vhdx` virtual hard disk file ke andar band rehta hai. Dost ke `C:\Users\...` personal folders VM ko bilkul accessible nahi hote (jab tak koi manually share na kare).
- **Encrypted Traffic:** Browser se VM tak sara display/keyboard stream **TLS 1.3 / WebRTC DTLS-SRTP** encrypted hota hai.
When the Windows laptop shuts down cleanly, Hyper-V automatically saves any running VM state (`AutomaticStopAction = Save`) and resumes it on the next boot.
Loading
Loading