mirror of
https://github.com/netbirdio/netbird.git
synced 2026-07-19 04:59:56 +00:00
- **Wails v3 application** (`client/ui`) with a React + TypeScript + Tailwind frontend replacing the Fyne UI: main connection view, exit-node switcher, networks/peers browser with detail panels, profile management, settings (general, network, SSH, security, troubleshooting, appearance), debug-bundle creation, and a first-run welcome flow. - **Internationalization**: go-i18n bundle with 9 locales (en, de, es, fr, hu, it, pt, ru, zh-CN) shared between the tray and the frontend. - **New system tray** implementation with per-platform theme-aware icons, including a native XEmbed host for Linux (`xembed_tray_linux.c`) and a Linux theme watcher. - **Session handling**: auth session watcher (`client/internal/auth/sessionwatch`), pending login flow, session-expiration dialog and tray notifications, and `netbird login` improvements. - **Daemon API extensions** (`daemon.proto`): status stream subscription, event stream, networks/exit-node selection endpoints, and richer full status — with probe throttling on the daemon side to protect against UI-driven request storms. - **UI preferences store** persisted per profile, autostart management via the daemon (single source of truth in HKCU on Windows). - **Build system**: Taskfile-based builds per platform (macOS, Linux, Windows), Docker cross-compilation images, MSIX/NSIS/nfpm/AppImage packaging, and a new `frontend-ui` CI workflow. Co-authored-by: Zoltan Papp <zoltan.pmail@gmail.com> Co-authored-by: Eduard Gert <kontakt@eduardgert.de> Co-authored-by: braginini <bangvalo@gmail.com> Co-authored-by: Pascal Fischer <32096965+pascal-fischer@users.noreply.github.com> Co-authored-by: riccardom <riccardomanfrin@gmail.com>
79 lines
2.0 KiB
Go
79 lines
2.0 KiB
Go
//go:build windows
|
|
|
|
package main
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"time"
|
|
|
|
log "github.com/sirupsen/logrus"
|
|
"golang.org/x/sys/windows"
|
|
)
|
|
|
|
const (
|
|
quickActionsTriggerEventName = `Global\NetBirdQuickActionsTriggerEvent`
|
|
waitTimeout = 5 * time.Second
|
|
desiredAccesses = windows.SYNCHRONIZE | windows.EVENT_MODIFY_STATE
|
|
|
|
// WAIT_TIMEOUT return code; not exposed by golang.org/x/sys/windows.
|
|
waitTimeoutCode uint32 = 0x00000102
|
|
)
|
|
|
|
// listenForShowSignal shows the main window when an external process pulses the named event.
|
|
func listenForShowSignal(ctx context.Context, tray *Tray) {
|
|
namePtr, err := windows.UTF16PtrFromString(quickActionsTriggerEventName)
|
|
if err != nil {
|
|
log.Errorf("trigger event name: %v", err)
|
|
return
|
|
}
|
|
|
|
handle, err := windows.CreateEvent(nil, 1, 0, namePtr)
|
|
if err != nil {
|
|
if !errors.Is(err, windows.ERROR_ALREADY_EXISTS) {
|
|
log.Errorf("create trigger event %q: %v", quickActionsTriggerEventName, err)
|
|
return
|
|
}
|
|
handle, err = windows.OpenEvent(desiredAccesses, false, namePtr)
|
|
if err != nil {
|
|
log.Errorf("open trigger event %q: %v", quickActionsTriggerEventName, err)
|
|
return
|
|
}
|
|
}
|
|
|
|
if handle == windows.InvalidHandle {
|
|
log.Errorf("invalid handle for trigger event %q", quickActionsTriggerEventName)
|
|
return
|
|
}
|
|
|
|
go waitForTrigger(ctx, handle, tray)
|
|
}
|
|
|
|
func waitForTrigger(ctx context.Context, handle windows.Handle, tray *Tray) {
|
|
defer func() {
|
|
if err := windows.CloseHandle(handle); err != nil {
|
|
log.Errorf("close trigger event handle: %v", err)
|
|
}
|
|
}()
|
|
|
|
timeoutMs := uint32(waitTimeout / time.Millisecond)
|
|
for {
|
|
if ctx.Err() != nil {
|
|
return
|
|
}
|
|
ev, err := windows.WaitForSingleObject(handle, timeoutMs)
|
|
switch {
|
|
case err != nil:
|
|
log.Errorf("wait trigger event: %v", err)
|
|
return
|
|
case ev == waitTimeoutCode:
|
|
continue
|
|
case ev == windows.WAIT_OBJECT_0:
|
|
if err := windows.ResetEvent(handle); err != nil {
|
|
log.Errorf("reset trigger event: %v", err)
|
|
}
|
|
tray.ShowWindow()
|
|
}
|
|
}
|
|
}
|