Skip to content

Commit 87e1723

Browse files
author
neil
committed
fix remote-vnc
1 parent a84eb8d commit 87e1723

File tree

2 files changed

+29
-3
lines changed

2 files changed

+29
-3
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ AnyVM includes a built-in, premium VNC Web UI that allows you to access the VM's
140140
- **Fullscreen**: Toggle fullscreen mode for an immersive experience.
141141
- **Stats**: Real-time FPS and latency monitoring.
142142
- **Accessibility**: Available at `http://localhost:6080` by default. If the port is occupied, AnyVM will automatically try the next available port (e.g., 6081, 6082).
143-
- **Remote Access**: Use `--remote-vnc` to automatically create a public, secure tunnel (via Cloudflare, Localhost.run, or Pinggy) to access your VM's display from anywhere in the world.
143+
- **Remote Access**: Use `--remote-vnc` to automatically create a public, secure tunnel (via Cloudflare, Localhost.run, or Pinggy) to access your VM's display from anywhere in the world. (In Google Cloud Shell, this is enabled by default; use `--remote-vnc no` to disable).
144144

145145
## 9. CLI options (with examples)
146146

@@ -240,6 +240,7 @@ All examples below use `python3 anyvm.py ...`. You can also run `python3 anyvm.p
240240
- `--remote-vnc`: Create a public tunnel for the VNC Web UI using Cloudflare, Localhost.run, or Pinggy.
241241
- Example: `python3 anyvm.py --os freebsd --remote-vnc`
242242
- Advanced: Use `cf`, `lhr`, or `pinggy` to specify a service: `python3 anyvm.py --os freebsd --remote-vnc cf`
243+
- Disable: Use `no` to disable (e.g., in Google Cloud Shell where it's default): `python3 anyvm.py --os freebsd --remote-vnc no`
243244

244245
- `--mon <port>`: Expose the QEMU monitor via telnet on localhost.
245246
- Example: `python3 anyvm.py --os freebsd --mon 4444`

anyvm.py

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2384,6 +2384,8 @@ def print_usage():
23842384
Use "--vnc off" to disable.
23852385
--remote-vnc Create a public URL for the VNC Web UI using Cloudflare, Localhost.run, or Pinggy.
23862386
Usage: --remote-vnc (auto), --remote-vnc cf, --remote-vnc lhr, --remote-vnc pinggy.
2387+
Enabled by default if no local browser is detected (e.g., in Cloud Shell).
2388+
Use "--remote-vnc no" to disable.
23872389
--vga <type> VGA device type (e.g., virtio, std, virtio-gpu). Default: virtio (std for NetBSD).
23882390
--res, --resolution Set initial screen resolution (e.g., 1280x800). Default: 1280x800.
23892391
--mon <port> QEMU monitor telnet port (localhost).
@@ -3460,7 +3462,8 @@ def main():
34603462
'public_vnc': False,
34613463
'public_ssh': False,
34623464
'accept_vm_ssh': False,
3463-
'remote_vnc': False
3465+
'remote_vnc': None,
3466+
'remote_vnc_is_default': False
34643467
}
34653468

34663469
ssh_passthrough = []
@@ -3477,6 +3480,8 @@ def main():
34773480
working_dir = "/tmp/anyvm.org"
34783481
if not os.path.exists(working_dir):
34793482
os.makedirs(working_dir)
3483+
config['remote_vnc'] = True
3484+
config['remote_vnc_is_default'] = True
34803485

34813486
# Manual argument parsing
34823487
args = sys.argv[1:]
@@ -3575,7 +3580,11 @@ def main():
35753580
config['public_ssh'] = True
35763581
elif arg == "--remote-vnc":
35773582
if i + 1 < len(args) and not args[i+1].startswith("-"):
3578-
config['remote_vnc'] = args[i+1]
3583+
val = args[i+1]
3584+
if val.lower() in ["no", "off", "false", "0"]:
3585+
config['remote_vnc'] = False
3586+
else:
3587+
config['remote_vnc'] = val
35793588
i += 1
35803589
else:
35813590
config['remote_vnc'] = True
@@ -3608,11 +3617,21 @@ def main():
36083617
i += 1
36093618
else:
36103619
config['synctime'] = True
3620+
else:
3621+
log("Warning: Unrecognized argument: {}".format(arg))
36113622
i += 1
36123623

36133624
if config['debug']:
36143625
debuglog(True, "Debug logging enabled")
36153626

3627+
# If remote VNC not explicitly specified, enable it by default if browser is unavailable
3628+
if config['remote_vnc'] is None:
3629+
if config['vnc'].lower() != "off" and not is_browser_available():
3630+
config['remote_vnc'] = True
3631+
config['remote_vnc_is_default'] = True
3632+
else:
3633+
config['remote_vnc'] = False
3634+
36163635
is_vnc_console = (config.get('vnc') == "console")
36173636

36183637
if not config['os']:
@@ -5165,6 +5184,9 @@ def finish_wait_timer():
51655184
if supports_ansi_color():
51665185
display_url = "\x1b[32m{}\x1b[0m".format(tunnel_url)
51675186
log("WebVNC ({}): {}".format(tunnel_service, display_url))
5187+
if config.get('remote_vnc_is_default'):
5188+
log("Notice: Remote VNC tunnel is enabled by default as no local browser was detected.")
5189+
log(" Use '--remote-vnc off' to disable it.")
51685190
log("======================================")
51695191

51705192
if not config['detach']:
@@ -5194,6 +5216,9 @@ def finish_wait_timer():
51945216
if supports_ansi_color():
51955217
display_url = "\x1b[32m{}\x1b[0m".format(tunnel_url)
51965218
log("WebVNC ({}): {}".format(tunnel_service, display_url))
5219+
if config.get('remote_vnc_is_default'):
5220+
log("Notice: Remote VNC tunnel is enabled by default as no local browser was detected.")
5221+
log(" Use '--remote-vnc off' to disable it.")
51975222
log("======================================")
51985223
else:
51995224
log("VM has exited")

0 commit comments

Comments
 (0)