24 Commits

Author SHA1 Message Date
Alex Howells 5cd265ae52 feat(network): add custom NTP/HTTP time sync configuration UI (#1289)
* feat(network): add custom NTP/HTTP time sync configuration UI

Closes #516, #645, #59

The backend supports custom NTP servers, HTTP URLs, source ordering,
parallel queries, and fallback control for time synchronization, but the
frontend only exposes three presets (NTP only, NTP and HTTP, HTTP only).
Users who need to specify their own NTP server — the core ask in all
three linked issues — have no way to do so through the UI.

Add a "Custom" option to the time sync dropdown. When selected, a card
appears with input fields for NTP servers and HTTP URLs, following the
same list-with-add/remove pattern used by the static IPv4 DNS fields.

This is a simplified alternative to #1102 which exposed every backend
field (source ordering, parallel queries, disable fallback) as direct
UI controls. That PR stalled for 3 months due to complexity concerns
and UX debate. This PR ships the functionality users actually requested
— custom NTP servers — with a minimal UI surface:

  #1102: 753 additions, 15 files, new Combobox modifications
  This:  ~120 additions, 18 files (13 are localization)

The advanced fields (TimeSyncOrdering, TimeSyncParallel,
TimeSyncDisableFallback) retain their backend defaults and can be
surfaced in a follow-up if there is demand.

Backend changes:

  confparser.go — add hostname_or_ipv4_or_ipv6 validation type so NTP
  server fields accept hostnames like pool.ntp.org, not just raw IPs.

  config.go — change TimeSyncNTPServers validation from ipv4_or_ipv6
  to hostname_or_ipv4_or_ipv6.

Frontend changes:

  CustomTimeSyncCard.tsx — new component with NTP server list and HTTP
  URL list, field validation, add/remove controls.

  stores.ts — add optional time_sync_ordering, time_sync_ntp_servers,
  time_sync_http_urls, time_sync_disable_fallback, time_sync_parallel
  to NetworkSettings interface.

  network settings page — uncomment Custom option, render card when
  time_sync_mode is custom.

Translations added for all 13 supported languages.

* fix(timesync): address review feedback on custom NTP UI

1. filterNTPServers: pass hostnames through instead of dropping
   them. net.ParseIP() returns nil for hostnames like
   pool.ntp.org, causing them to be silently skipped. The NTP
   library handles DNS resolution itself, so hostnames are valid
   entries.

2. getSyncMode: when TimeSyncMode is "custom", default the
   ordering to [ntp_user_provided, http_user_provided, ntp_dhcp,
   ntp, http] so user-provided servers are actually queried. The
   previous hardcoded default never included *_user_provided
   entries, rendering custom servers unreachable.

3. Stale config pointer: add SetNetworkConfig() on TimeSync and
   call it from rpcSetNetworkSettings after config.NetworkConfig
   is replaced. Without this, TimeSync holds a stale pointer and
   ignores runtime config changes until restart.

4. DNS vacuous truth: guard .every() calls on ipv4/ipv6 DNS
   dirty arrays with .length > 0 checks. [].every() returns true
   in JS, causing empty DNS arrays to falsely appear in the
   confirmation dialog.

Signed-off-by: Alex Howells <alex@howells.me>

* fix(timesync): ensure custom mode uses user-provided servers and re-syncs on settings change

Move TimeSyncOrdering override before the mode switch so "custom" mode
always sets the correct ordering with ntp_user_provided first, preventing
stale ordering values from overriding it. Trigger an immediate time sync
when network settings are saved so users don't have to wait for the
hourly cycle or reboot.

---------

Signed-off-by: Alex Howells <alex@howells.me>
Co-authored-by: Adam Shiervani <adam@jetkvm.com>
2026-03-29 12:16:52 +02:00
Adam Shiervani d2370a155a fix: gate public IP check behind cloud adoption status (#1328)
Prevent HTTP requests to api.jetkvm.com/cdn-cgi/trace when cloud is not
enabled. Previously, visiting the network settings page would trigger
ForceUpdate() which always called checkIPs with true/true, bypassing any
cloud adoption check.

Changes:
- Gate rpcGetPublicIPAddresses refresh behind cloud token/URL check
- Gate rpcCheckPublicIPAddresses behind cloud token/URL check
- Hide PublicIPCard in UI when cloud is not adopted
- Fetch cloud state on network settings page mount to determine visibility
2026-03-25 18:45:45 +01:00
Alex Howells 1c30bac4f1 fix(display): prevent background events from resetting off timer (#1277)
The display-off timer never fires when a WebRTC session is active because
background system events (video state changes, session count updates, USB
state changes, network state changes) all call requestDisplayUpdate with
shouldWakeDisplay=true. Each wake resets both the dim and off tickers via
wakeDisplay, so the off timer restarts from zero on every event and never
reaches its threshold.

Only physical input device events (touchscreen taps, reported as
indev_event) should wake the display and reset the timers. Background
state updates still need to refresh the LCD content but should not
interfere with the backlight timeout cycle.

Change requestDisplayUpdate calls from background event handlers to pass
shouldWakeDisplay=false in native.go (video_state_changed), network.go
(network_state_changed), usb.go (usb_state_changed), and webrtc.go
(active_sessions_changed). Startup paths (init_display, native_restart)
retain shouldWakeDisplay=true.

Fixes #1133
2026-03-16 11:45:52 +01:00
Adam Shiervani 0a09d9e8bf feat: add hostname change detection and reboot requirement in network settings (#989) 2025-11-20 16:36:02 +01:00
Aveline 752fb55799 refactor: OTA (#912)
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Adam Shiervani <adam.shiervani@gmail.com>
2025-11-19 15:20:59 +01:00
Aveline cf629bed46 feat: add remote IP address to connection stats sidebar (#944) 2025-11-11 12:00:37 +01:00
Adam Shiervani ce9f95b8c8 refactor: ota redirecting (#898)
* refactor: improve URL handling in RebootingOverlay component

* refactor: enhance redirect URL handling in TryUpdate function

* refactor: disable old ota rebooting method in new version

* refactor: streamline version retrieval logic and enhance error handling in useVersion hook

* refactor: rename to RedirectTo

* fix: force page reload when redirecting from reboot actions

* refactor: consolidate sleep utility and update usages across components

* refactor: update JsonRpcCallOptions to use maxAttempts and attemptTimeoutMs, implement exponential backoff for retries

---------

Co-authored-by: Adam Shiervani <adamshiervani@fastmail.com>
2025-10-27 16:21:11 +01:00
Marc Brooks 9a4d061034 Localize the client/browser UI with inlang paraglide-js (#864) 2025-10-23 14:27:29 +02:00
Aveline c775979ccb feat: refactoring network stack (#878)
Co-authored-by: Adam Shiervani <adam.shiervani@gmail.com>
2025-10-15 18:32:58 +02:00
Aveline 657a177462 feat: jetkvm native in cGo 2025-09-29 14:09:30 +02:00
Marc Brooks cf679978be fix(timesync): ensure that auto-update waits for time sync (#609)
- Added check to not attempt auto update if time sync is needed and not yet successful (delays 30 second to recheck).
- Added resync of time when DHCP or link state changes if online
- Added conditional* fallback from configured* NTP servers to the IP-named NTP servers, and then to the DNS named ones if that fails
- Added conditional* fallback from the configured* HTTP servers to the default DNS named ones.
- Uses the configuration* option for how many queries to run in parallel
- Added known static IPs for time servers (in case DNS resolution isn't up yet)
- Added time.cloudflare.com to fall-back NTP servers
- Added fallback to NTP via hostnames
- Logs the resultant time (and mode)
2025-09-16 15:37:02 +02:00
Siyuan Miao ab3dda6dee chore(network): fix linting error errcheck 2025-07-11 11:30:02 +02:00
Marc Brooks 11a095c0f6 feat(ntp): enhances time sync with DHCP NTP and custom servers (#625)
* Ensure the mDNS mode is set every time network state changes

Eliminates (mostly) duplicate code

* Add custom NTP and HTTP time sync servers

Since the ordering may have been previously defaulted and saved as "ntp,http", but that was being ignored and fallback-defaults were being used, in Ordering, `ntp` means use the fallback NTP servers, and `http` means use the fallback HTTP URLs. Thus `ntp_user_provided` and `http_user_provided` are the user specified static lists.

* Add support for using DHCP-provided NTP server
2025-07-11 08:04:19 +02:00
Marc Brooks ccba27cedd chore(mDNS): ensure the mDNS mode is set every time network state changes (#624)
Eliminates (mostly) duplicate code
2025-06-19 09:29:21 +02:00
Aveline 189b84380b network enhanecment / refactor (#361)
* chore(network): improve connectivity check

* refactor(network): rewrite network and timesync component

* feat(display): show cloud connection status

* chore: change logging verbosity

* chore(websecure): update log message

* fix(ota): validate root certificate when downloading update

* feat(ui): add network settings tab

* fix(display): cloud connecting animation

* fix: golintci issues

* feat: add network settings tab

* feat(timesync): query servers in parallel

* refactor(network): move to internal/network package

* feat(timesync): add metrics

* refactor(log): move log to internal/logging package

* refactor(mdms): move mdns to internal/mdns package

* feat(developer): add pprof endpoint

* feat(logging): add a simple logging streaming endpoint

* fix(mdns): do not start mdns until network is up

* feat(network): allow users to update network settings from ui

* fix(network): handle errors when net.IPAddr is nil

* fix(mdns): scopedLogger SIGSEGV

* fix(dhcp): watch directory instead of file to catch fsnotify.Create event

* refactor(nbd): move platform-specific code to different files

* refactor(native): move platform-specific code to different files

* chore: fix linter issues

* chore(dev_deploy): allow to override PION_LOG_TRACE
2025-04-16 01:39:23 +02:00
Siyuan Miao 0ba7902f82 chore: update logging 2025-04-11 12:55:36 +02:00
Siyuan Miao 4c37f7e079 refactor: use structured logging 2025-04-11 00:43:46 +02:00
SuperQ 75296b4b7e Chore: Enable golangci-lint
Add a GitHub actions workflow to run golangci-lint.

Signed-off-by: SuperQ <superq@gmail.com>
2025-03-11 18:35:12 +01:00
SuperQ 34e33e45bf Cleanup logging
Make sure all logging output is called via the main logger instead of
stdlib `"log"` or `fmt.Print(f|ln)`.

Signed-off-by: SuperQ <superq@gmail.com>
2025-03-11 16:53:54 +01:00
Aveline 554121a20b chore: ensure config is loaded before init functions (#226) 2025-03-04 11:32:54 +01:00
Aveline 806792203f feat(ntp): add delay between sync attempts and support NTP servers from DHCP (#162)
* feat(ntp): use ntp server from dhcp info

* feat(ntp): use ntp server from dhcp info

* feat(ntp): add delay between time sync attempts

* chore(ntp): more logging
2025-02-17 11:02:28 +01:00
Andrew 951173ba19 Restart mDNS every time the connection information changes (#155) 2025-02-13 18:10:47 +01:00
Cameron Fleming 2a99c2db9d fix(net): stop dhcp client and release all v4 addr on linkdown (#16)
This commit fixes jetkvm/kvm#12 by disabling the udhcpc client when the
link goes down, it then removes all the active IPv4 addresses from the
deivce.

Once the link comes back up, it re-activates the udhcpc client so it can
fetch a new IPv4 address for the device.

This doesn't make any changes to the IPv6 side of things yet.
2025-02-13 15:41:10 +01:00
Adam Shiervani 20780b65db Release 202412292127 2024-12-29 21:27:42 +01:00