Documentation
¶
Index ¶
- Constants
- Variables
- func BuildVNCNoisePrologue(mode byte, username string) []byte
- type ActiveSessionInfo
- type ApprovalDecision
- type ApprovalInfo
- type Approver
- type Config
- type FBCapturer
- type FBPoller
- type InputInjector
- type ScreenCapturer
- type Server
- func (s *Server) ActiveSessions() []ActiveSessionInfo
- func (s *Server) AddListener(_ context.Context, addr netip.AddrPort, network netip.Prefix) error
- func (s *Server) Start(ctx context.Context, addr netip.AddrPort, network netip.Prefix) error
- func (s *Server) Stop() error
- func (s *Server) UpdateVNCAuth(config *sshauth.Config)
- func (s *Server) VNCAuth() *sshauth.Config
- type SessionTick
- type ShutdownState
- type StubCapturer
- type StubInputInjector
- func (s *StubInputInjector) GetClipboard() string
- func (s *StubInputInjector) InjectKey(_ uint32, _ bool)
- func (s *StubInputInjector) InjectKeyScancode(_ uint32, _ uint32, _ bool)
- func (s *StubInputInjector) InjectPointer(_ uint16, _, _, _, _ int)
- func (s *StubInputInjector) SetClipboard(_ string)
- func (s *StubInputInjector) TypeText(_ string)
- type UInputInjector
- func (u *UInputInjector) Close()
- func (u *UInputInjector) GetClipboard() string
- func (u *UInputInjector) InjectKey(keysym uint32, down bool)
- func (u *UInputInjector) InjectKeyScancode(scancode, keysym uint32, down bool)
- func (u *UInputInjector) InjectPointer(buttonMask uint16, x, y, serverW, serverH int)
- func (u *UInputInjector) SetClipboard(_ string)
- func (u *UInputInjector) TypeText(text string)
- type VirtualSession
- type X11Capturer
- func (c *X11Capturer) Capture() (*image.RGBA, error)
- func (c *X11Capturer) CaptureInto(dst *image.RGBA) error
- func (c *X11Capturer) Close()
- func (x *X11Capturer) Cursor() (*image.RGBA, int, int, uint64, error)
- func (x *X11Capturer) CursorPos() (int, int, error)
- func (c *X11Capturer) Height() int
- func (c *X11Capturer) Width() int
- type X11InputInjector
- func (x *X11InputInjector) Close()
- func (x *X11InputInjector) GetClipboard() string
- func (x *X11InputInjector) InjectKey(keysym uint32, down bool)
- func (x *X11InputInjector) InjectKeyScancode(scancode, keysym uint32, down bool)
- func (x *X11InputInjector) InjectPointer(buttonMask uint16, px, py, serverW, serverH int)
- func (x *X11InputInjector) SetClipboard(text string)
- func (x *X11InputInjector) TypeText(text string)
- type X11Poller
- func (p *X11Poller) Capture() (*image.RGBA, error)
- func (p *X11Poller) CaptureInto(dst *image.RGBA) error
- func (p *X11Poller) ClientConnect()
- func (p *X11Poller) ClientDisconnect()
- func (p *X11Poller) Close()
- func (p *X11Poller) Cursor() (*image.RGBA, int, int, uint64, error)
- func (p *X11Poller) CursorPos() (int, int, error)
- func (p *X11Poller) Height() int
- func (p *X11Poller) Width() int
Constants ¶
const ( ModeAttach byte = 0 // Capture current display ModeSession byte = 1 // Virtual session as specified user )
Connection modes sent by the client in the session header.
const ( RejectCodeAuthForbidden = "AUTH_FORBIDDEN" RejectCodeSessionError = "SESSION_ERROR" RejectCodeCapturerError = "CAPTURER_ERROR" RejectCodeUnsupportedOS = "UNSUPPORTED" RejectCodeBadRequest = "BAD_REQUEST" RejectCodeNoConsoleUser = "NO_CONSOLE_USER" RejectCodeApprovalDenied = "APPROVAL_DENIED" RejectCodeApprovalTimeout = "APPROVAL_TIMEOUT" RejectCodeNoApprover = "NO_APPROVER" )
RFB security-failure reason codes sent to the client. These prefixes are stable so clients can branch on them without parsing free text. Format: "CODE: human message".
const EnvVNCDisableDownscale = "NB_VNC_DISABLE_DOWNSCALE"
EnvVNCDisableDownscale disables any platform-specific framebuffer downscaling (e.g. Retina 2:1). Set to 1/true to send the native resolution.
const ViewOnlyDesktopNamePrefix = "\x00NB-VIEW-ONLY\x00"
ViewOnlyDesktopNamePrefix tags the RFB desktop name when the host approved the connection in view-only mode, so a NetBird-aware client can switch its UI into read-only state. NUL framing guarantees no collision with a user-set name.
Variables ¶
var ( // ErrApprovalDenied means the user answered and said no. ErrApprovalDenied = errors.New("approval denied") // ErrApprovalTimeout means the prompt was raised and nobody answered // it in time. Distinct from a denial because the two call for // different things from whoever is dialling: try again later, versus // stop asking. ErrApprovalTimeout = errors.New("approval timed out") // there was no answer to wait for. A device with no way to display // one lands here, as does a daemon with no UI attached. ErrApprovalUnavailable = errors.New("no approval prompt reached the user") )
Causes an Approver can report so the rejection names why the connection was refused rather than blaming the user for every outcome. An error matching none of these still rejects, reported as a denial.
Functions ¶
func BuildVNCNoisePrologue ¶
BuildVNCNoisePrologue returns the deterministic byte sequence both sides feed to noise.Config.Prologue for a VNC handshake. Exported so the WASM proxy client computes the exact same bytes; any divergence makes the handshake fail.
Types ¶
type ActiveSessionInfo ¶
type ActiveSessionInfo struct {
RemoteAddress string
Mode string
Username string
// UserID is the authenticated session identity (hashed user ID from
// the Noise_IK static-key registration), empty when auth is disabled.
UserID string
// Initiator is the dashboard-supplied display name of the user who
// minted the SessionPubKey, when known. Empty when auth is disabled
// or the authorizer has no display-name mapping.
Initiator string
}
ActiveSessionInfo describes a currently connected VNC client.
type ApprovalDecision ¶
type ApprovalDecision struct {
ViewOnly bool
}
ApprovalDecision carries the parts of the user's response the VNC server acts on. Accept is implicit (errors signal deny). ViewOnly puts the session into read-only mode: the server drops input events.
type ApprovalInfo ¶
type ApprovalInfo struct {
PeerName string
PeerPubKey string
SourceIP string
Mode string
Username string
// Initiator is the display name of the user who initiated the
// connection (typically the dashboard user). Resolved from the
// Noise-verified client static pubkey.
Initiator string
}
ApprovalInfo describes the pending connection passed to the approver. Fields are best-effort; any may be empty.
type Approver ¶
type Approver interface {
Request(ctx context.Context, info ApprovalInfo) (ApprovalDecision, error)
}
Approver decouples the VNC server from the approval broker. A non-nil error means "do not proceed".
type Config ¶
type Config struct {
Capturer ScreenCapturer
Injector InputInjector
IdentityKey []byte
ServiceMode bool
SessionRecorder func(SessionTick)
DisableAuth bool
AgentTokenHex string
NetstackNet *wgbackend.NetstackNet
// Auth is the fine-grained authorization to open with, applied before the
// server accepts anything: a server that starts listening with an empty
// authorizer refuses the connections that arrive in the meantime. Nil
// leaves it as management has not sent one yet.
Auth *sshauth.Config
// Listener, when set, is used instead of Start opening a TCP listener;
// addr/network args to Start are then ignored. The agent uses this to
// listen on a Unix socket.
Listener net.Listener
// OnSessionsChanged, when set, is called after a session is added or
// removed. The daemon uses it to wake its status subscribers: session
// lifecycle is invisible to the peer status recorder, so without it the
// UI keeps showing the previous session list until some unrelated peer
// change happens to push a snapshot.
OnSessionsChanged func()
// RequireApproval gates each accepted connection on a user-side accept
// prompt before the proxy/session starts. Requires Approver to be set;
// otherwise the gate fails closed.
RequireApproval bool
// Approver brokers the per-connection prompt to the local user via the
// daemon→UI event channel. Nil disables the gate.
Approver Approver
// OnVirtualProcesses, when set, is called with the current virtual-session
// process records whenever one starts or stops. The daemon persists them
// through the state manager so a crash does not leave an orphaned X server
// and desktop running for the life of the host.
OnVirtualProcesses func(*ShutdownState)
}
Config bundles the values the VNC server needs at construction time; fields are read once by New. AgentTokenHex is decoded internally; an invalid value is logged and treated as empty.
type FBCapturer ¶
type FBCapturer struct {
// contains filtered or unexported fields
}
FBCapturer reads pixels straight from the Linux framebuffer device. Used as a fallback when X11 isn't available, e.g. on a headless box at the kernel console or the display manager's pre-login screen on machines without an Xorg server. The framebuffer must be mmap()-able under our process privileges (typically the netbird service runs as root).
func NewFBCapturer ¶
func NewFBCapturer(path string) (*FBCapturer, error)
NewFBCapturer opens the given framebuffer device (/dev/fbN) and queries its current geometry + pixel format.
func (*FBCapturer) Capture ¶
func (c *FBCapturer) Capture() (*image.RGBA, error)
Capture allocates a fresh image and fills it with the current framebuffer contents.
func (*FBCapturer) CaptureInto ¶
func (c *FBCapturer) CaptureInto(dst *image.RGBA) error
CaptureInto reads the framebuffer directly into dst.Pix.
func (*FBCapturer) Close ¶
func (c *FBCapturer) Close()
Close releases the framebuffer mmap and file descriptor. Serialized with CaptureInto via c.mu so an in-flight capture can't read freed memory.
func (*FBCapturer) Height ¶
func (c *FBCapturer) Height() int
Height returns the framebuffer height in pixels.
func (*FBCapturer) Width ¶
func (c *FBCapturer) Width() int
Width returns the framebuffer width in pixels.
type FBPoller ¶
type FBPoller struct {
// contains filtered or unexported fields
}
FBPoller wraps FBCapturer with the same lifecycle (ClientConnect / ClientDisconnect, lazy init) as X11Poller, so it slots into the same session plumbing without code changes upstream. The concrete FBCapturer is platform-specific (capture_fb_linux.go / _freebsd.go); this file owns the cross-platform glue.
func NewFBPoller ¶
NewFBPoller returns a poller that opens path on first use. Empty path defaults to /dev/fb0 on Linux and /dev/ttyv0 on FreeBSD.
func (*FBPoller) CaptureInto ¶
CaptureInto fills dst directly.
func (*FBPoller) ClientConnect ¶
func (p *FBPoller) ClientConnect()
ClientConnect eagerly initialises the capturer on first connect.
func (*FBPoller) ClientDisconnect ¶
func (p *FBPoller) ClientDisconnect()
ClientDisconnect closes the capturer when the last client leaves.
func (*FBPoller) Close ¶
func (p *FBPoller) Close()
Close releases all framebuffer resources. The poller stays closed: a later Capture or Width must not lazily reopen the device, the way X11Poller's done channel stops its own retry loop.
func (*FBPoller) Height ¶
Height returns the framebuffer height, doing lazy init if needed. Zero when the device cannot be opened, for the reason given on Width.
type InputInjector ¶
type InputInjector interface {
// InjectKey simulates a key press or release. keysym is an X11 KeySym.
InjectKey(keysym uint32, down bool)
// InjectKeyScancode simulates a key press or release using the QEMU
// scancode (PC AT set 1, high byte 0xE0 for extended keys). Layout-
// independent: the server's local keyboard layout decides what
// character the key produces. Implementations should fall back to
// InjectKey(keysym, down) when they don't have a scancode mapping
// for the given code; that's strictly no worse than the legacy path.
InjectKeyScancode(scancode uint32, keysym uint32, down bool)
// InjectPointer simulates mouse movement and button state.
// buttonMask is the RFB ExtendedMouseButtons mask: bits 0-6 follow
// the standard PointerEvent layout (left/middle/right/wheel),
// bit 7 is mouse-back (X1), bit 8 is mouse-forward (X2).
InjectPointer(buttonMask uint16, x, y, serverW, serverH int)
// SetClipboard sets the system clipboard to the given text.
SetClipboard(text string)
// GetClipboard returns the current system clipboard text.
GetClipboard() string
// TypeText synthesizes the given text as keystrokes on the active
// desktop. Used to push host clipboard content into a secure desktop
// (Winlogon/UAC) where the clipboard is isolated. On platforms or
// sessions without keystroke synthesis it may be a no-op.
TypeText(text string)
}
InputInjector delivers keyboard and mouse events to the OS.
type ScreenCapturer ¶
type ScreenCapturer interface {
// Width returns the current screen width in pixels.
Width() int
// Height returns the current screen height in pixels.
Height() int
// Capture returns the current desktop as an RGBA image.
Capture() (*image.RGBA, error)
}
ScreenCapturer grabs desktop frames for the VNC server.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is the embedded VNC server that listens on the WireGuard interface. It supports two operating modes:
- Direct mode: captures the screen and handles VNC sessions in-process. Used when running in a user session with desktop access.
- Service mode: proxies VNC connections to an agent process spawned in the active console session. Used when running as a Windows service in Session 0.
Within direct mode, each connection can request one of two session modes via the connection header:
- Attach: capture the current physical display.
- Session: start a virtual Xvfb display as the requested user.
func New ¶
New creates a VNC server from the provided Config. IdentityKey is the 32-byte X25519 private key used in the Noise_IK handshake; nil disables auth. The protocol-level VNC password scheme is not supported.
func (*Server) ActiveSessions ¶
func (s *Server) ActiveSessions() []ActiveSessionInfo
ActiveSessions returns a snapshot of currently connected VNC clients.
func (*Server) AddListener ¶
AddListener opens an additional overlay listener (e.g. the v6 overlay address) and serves it with the same accept path as the primary listener. The server must already be running. Mirrors the primary listener's mode so service-mode connections still route through the per-session agent proxy.
func (*Server) Start ¶
Start begins listening for VNC connections on the given address. network is the NetBird overlay prefix used to validate connection sources. When Config.Listener was supplied, addr and network are ignored and the pre-built listener is used (the per-session agent path). A Server cannot be started again after Stop; build a new one instead.
func (*Server) UpdateVNCAuth ¶
UpdateVNCAuth updates the fine-grained authorization configuration and closes any live session whose identity no longer authenticates under the new policy. Revocation is event-driven: there is no periodic re-check, so a session stays open until either the next UpdateVNCAuth call or normal disconnect.
type SessionTick ¶
type SessionTick struct {
Period time.Duration
BytesOut uint64
Writes uint64
FBUs uint64
MaxFBUBytes uint64
MaxFBURects uint64
MaxWriteBytes uint64
WriteNanos uint64
// FBUsTracked is false when the connection carried framebuffer updates it
// could not see the boundaries of, which is the case for a service-mode
// proxy relaying bytes to a per-session agent. FBUs, MaxFBUBytes and
// MaxFBURects then mean "unknown", not "none".
FBUsTracked bool
}
SessionTick is one sampling slice of a VNC session's wire activity. BytesOut / Writes / FBUs are deltas observed during this tick; Max* fields are the high-water marks observed during this tick (reset at the start of the next). Period is the wall-clock duration covered (typically sessionTickInterval, shorter for the final flush).
type ShutdownState ¶
type ShutdownState struct {
// Processes maps a description to the process it names (e.g. "xvfb:50").
Processes map[string]sessionProcess `json:"processes,omitempty"`
}
ShutdownState tracks VNC virtual session processes for crash recovery. Persisted by the state manager; on restart, residual processes are killed.
func (*ShutdownState) Cleanup ¶
func (s *ShutdownState) Cleanup() error
Cleanup kills any residual VNC session processes left from a crash.
func (*ShutdownState) Name ¶
func (s *ShutdownState) Name() string
Name returns the state name for the state manager.
type StubCapturer ¶
type StubCapturer struct{}
StubCapturer is a placeholder for platforms without screen capture support.
func (*StubCapturer) Capture ¶
func (c *StubCapturer) Capture() (*image.RGBA, error)
Capture returns an error on unsupported platforms.
func (*StubCapturer) Height ¶
func (c *StubCapturer) Height() int
Height returns 0 on unsupported platforms.
func (*StubCapturer) Width ¶
func (c *StubCapturer) Width() int
Width returns 0 on unsupported platforms.
type StubInputInjector ¶
type StubInputInjector struct{}
StubInputInjector is a placeholder for platforms without input injection support.
func (*StubInputInjector) GetClipboard ¶
func (s *StubInputInjector) GetClipboard() string
GetClipboard returns empty on unsupported platforms.
func (*StubInputInjector) InjectKey ¶
func (s *StubInputInjector) InjectKey(_ uint32, _ bool)
InjectKey is a no-op on unsupported platforms.
func (*StubInputInjector) InjectKeyScancode ¶
func (s *StubInputInjector) InjectKeyScancode(_ uint32, _ uint32, _ bool)
InjectKeyScancode is a no-op on unsupported platforms.
func (*StubInputInjector) InjectPointer ¶
func (s *StubInputInjector) InjectPointer(_ uint16, _, _, _, _ int)
InjectPointer is a no-op on unsupported platforms.
func (*StubInputInjector) SetClipboard ¶
func (s *StubInputInjector) SetClipboard(_ string)
SetClipboard is a no-op on unsupported platforms.
func (*StubInputInjector) TypeText ¶
func (s *StubInputInjector) TypeText(_ string)
TypeText is a no-op on unsupported platforms.
type UInputInjector ¶
type UInputInjector struct {
// contains filtered or unexported fields
}
UInputInjector synthesizes keyboard and mouse events via /dev/uinput. Used as a fallback when X11 isn't running, e.g. at the kernel console or pre-login screen on a server without X. Requires root or CAP_SYS_ADMIN, which the netbird service has.
func NewUInputInjector ¶
func NewUInputInjector(w, h int) (*UInputInjector, error)
NewUInputInjector opens /dev/uinput and registers a virtual keyboard + absolute pointer device sized to (w, h). The dimensions are needed because uinput's ABS axes don't autoscale; we always send absolute coordinates and let the kernel route them to the right monitor.
func (*UInputInjector) Close ¶
func (u *UInputInjector) Close()
Close destroys the virtual uinput device and closes the file descriptor.
func (*UInputInjector) GetClipboard ¶
func (u *UInputInjector) GetClipboard() string
GetClipboard returns empty: no clipboard outside X11/Wayland.
func (*UInputInjector) InjectKey ¶
func (u *UInputInjector) InjectKey(keysym uint32, down bool)
InjectKey synthesizes a press or release for the given X11 keysym.
func (*UInputInjector) InjectKeyScancode ¶
func (u *UInputInjector) InjectKeyScancode(scancode, keysym uint32, down bool)
InjectKeyScancode injects a press or release using the QEMU scancode. uinput speaks Linux KEY_* codes natively, so we map QEMU scancode → KEY_* via qemuToLinuxKey. On miss (scancode we don't have a mapping for) we fall back to the keysym path, which is exactly the legacy behaviour.
func (*UInputInjector) InjectPointer ¶
func (u *UInputInjector) InjectPointer(buttonMask uint16, x, y, serverW, serverH int)
InjectPointer moves the absolute pointer and presses/releases buttons based on the RFB button mask delta against the previous mask.
func (*UInputInjector) SetClipboard ¶
func (u *UInputInjector) SetClipboard(_ string)
SetClipboard is a no-op on the framebuffer console: there is no system clipboard daemon. Use TypeText (Paste button) to deliver host text.
func (*UInputInjector) TypeText ¶
func (u *UInputInjector) TypeText(text string)
TypeText synthesizes the given UTF-8 text as keystrokes. Only ASCII printable characters and newline are typed; other runes are skipped. This drives the "paste" button: with no console clipboard available, keystroke-by-keystroke entry is the only way to deliver a password to a TTY login prompt.
type VirtualSession ¶
type VirtualSession struct {
// contains filtered or unexported fields
}
func StartVirtualSession ¶
func StartVirtualSession(username string, width, height uint16, logger *log.Entry) (*VirtualSession, error)
StartVirtualSession creates and starts a virtual X11 session for the given user. Requires root privileges to create sessions as other users. width and height request the virtual display geometry; 0 values fall back to the defaults.
func (*VirtualSession) Capturer ¶
func (vs *VirtualSession) Capturer() ScreenCapturer
Capturer returns the screen capturer for this virtual session, or nil once Stop has torn it down. Read under vs.mu, which is what Stop writes it under.
func (*VirtualSession) ClientConnect ¶
func (vs *VirtualSession) ClientConnect()
ClientConnect increments the client count and cancels any idle timer.
func (*VirtualSession) ClientDisconnect ¶
func (vs *VirtualSession) ClientDisconnect()
ClientDisconnect decrements the client count. When the last client disconnects, starts an idle timer that destroys the session.
func (*VirtualSession) Display ¶
func (vs *VirtualSession) Display() string
Display returns the X11 display string (e.g., ":99").
func (*VirtualSession) Injector ¶
func (vs *VirtualSession) Injector() InputInjector
Injector returns the input injector for this virtual session.
func (*VirtualSession) Stop ¶
func (vs *VirtualSession) Stop()
Stop terminates the virtual session, killing the desktop and Xvfb.
type X11Capturer ¶
type X11Capturer struct {
// contains filtered or unexported fields
}
X11Capturer captures the screen from an X11 display using the MIT-SHM extension.
func NewX11Capturer ¶
func NewX11Capturer(display, cookieHex string) (*X11Capturer, error)
NewX11Capturer connects to the X11 display and sets up shared memory capture. Empty cookieHex falls back to XAUTHORITY env lookup.
func (*X11Capturer) Capture ¶
func (c *X11Capturer) Capture() (*image.RGBA, error)
Capture returns the current screen as an RGBA image.
func (*X11Capturer) CaptureInto ¶
func (c *X11Capturer) CaptureInto(dst *image.RGBA) error
CaptureInto fills the caller's destination buffer in one pass. The source path (SHM or fallback GetImage) writes directly into dst.Pix instead of going through the X11Capturer's internal double-buffer, saving one full-frame memcpy per capture.
func (*X11Capturer) Cursor ¶
Cursor on X11Capturer satisfies cursorSource. The XFixes binding is created lazily on the same X connection used for screen capture; the first init failure is latched so we stop asking on every frame.
type X11InputInjector ¶
type X11InputInjector struct {
// contains filtered or unexported fields
}
X11InputInjector injects keyboard and mouse events via the XTest extension.
func NewX11InputInjector ¶
func NewX11InputInjector(display, cookieHex, authFile string) (*X11InputInjector, error)
NewX11InputInjector connects to the X11 display and initializes XTest. Empty cookieHex/authFile fall back to XAUTHORITY env lookup.
func (*X11InputInjector) GetClipboard ¶
func (x *X11InputInjector) GetClipboard() string
GetClipboard reads the X11 clipboard using xclip or xsel.
func (*X11InputInjector) InjectKey ¶
func (x *X11InputInjector) InjectKey(keysym uint32, down bool)
InjectKey simulates a key press or release. keysym is an X11 KeySym.
func (*X11InputInjector) InjectKeyScancode ¶
func (x *X11InputInjector) InjectKeyScancode(scancode, keysym uint32, down bool)
InjectKeyScancode injects using the QEMU scancode by translating to a Linux KEY_ code and then to an X11 keycode (KEY_* + xkbKeycodeOffset). On a server running a standard XKB keymap this is layout-independent: the scancode names the physical key, the server's layout determines the resulting character. Falls back to the keysym path when the scancode has no Linux mapping.
func (*X11InputInjector) InjectPointer ¶
func (x *X11InputInjector) InjectPointer(buttonMask uint16, px, py, serverW, serverH int)
InjectPointer simulates mouse movement and button events.
func (*X11InputInjector) SetClipboard ¶
func (x *X11InputInjector) SetClipboard(text string)
SetClipboard sets the X11 clipboard using xclip or xsel.
func (*X11InputInjector) TypeText ¶
func (x *X11InputInjector) TypeText(text string)
TypeText synthesizes the given text as keystrokes via XTest. Used in places where the focused application isn't clipboard-aware (e.g. a TTY login in an X11 session, an SDDM/GDM password field that ignores XSelection, or a kiosk app), so stuffing the X clipboard and relying on Ctrl+V would not reach the input.
Limitation: only ASCII printable characters are typed. Non-ASCII runes are skipped: a paste workflow for them needs Wayland-aware text input or layout introspection that this path does not implement.
type X11Poller ¶
type X11Poller struct {
// contains filtered or unexported fields
}
X11Poller wraps X11Capturer with a staleness-cached on-demand Capture: sessions drive captures themselves through the encoder goroutine, so we don't need a background ticker. The last result is cached for a short window so concurrent sessions coalesce into one capture.
The capturer is allocated lazily on first use and released when all clients disconnect, so an idle peer holds no X connection or SHM segment.
func NewX11Poller ¶
NewX11Poller creates a lazy on-demand capturer for the given X display. Empty cookieHex falls back to XAUTHORITY env lookup.
func (*X11Poller) Capture ¶
Capture returns a fresh frame, serving from the short-lived cache if a previous caller captured within freshWindow.
func (*X11Poller) CaptureInto ¶
CaptureInto fills dst directly via the underlying capturer, bypassing the freshness cache. The session's prevFrame/curFrame swap means each session needs its own buffer anyway, so caching wouldn't help.
func (*X11Poller) ClientConnect ¶
func (p *X11Poller) ClientConnect()
ClientConnect increments the active client count. The first client triggers eager capturer initialisation so that the first FBUpdateRequest doesn't pay the X11 connect + SHM attach latency.
func (*X11Poller) ClientDisconnect ¶
func (p *X11Poller) ClientDisconnect()
ClientDisconnect decrements the active client count. On the last disconnect we close the underlying capturer so idle peers cost nothing.
func (*X11Poller) Close ¶
func (p *X11Poller) Close()
Close releases all resources. Subsequent Capture calls will fail.
func (*X11Poller) Cursor ¶
Cursor satisfies cursorSource by forwarding to the lazily-initialised X11Capturer. Asking for the cursor on an idle poller triggers the same lazy X11 connection setup as a capture would.
func (*X11Poller) CursorPos ¶
CursorPos satisfies cursorPositionSource by forwarding to the X11Capturer.
Source Files
¶
- agent_handshake.go
- agent_handshake_other.go
- capture_fb_linux.go
- capture_fb_unix.go
- capture_x11.go
- capture_x11_shm_linux.go
- console_user_other.go
- copyrect.go
- cursor_x11.go
- extclipboard.go
- handshake.go
- input_uinput_keymap_linux.go
- input_uinput_linux.go
- input_x11.go
- keysym_typetext.go
- metrics_conn.go
- rfb.go
- scancodes.go
- server.go
- server_x11.go
- service_agent.go
- session.go
- session_clipboard.go
- session_cursor.go
- session_encode.go
- session_remote_cursor.go
- shutdown_state.go
- stubs.go
- swizzle.go
- virtual_x11.go
- xauth_x11.go