kvm

package module
v0.0.0-...-1717549 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 12, 2025 License: GPL-2.0 Imports: 71 Imported by: 0

README

JetKVM is a high-performance, open-source KVM over IP (Keyboard, Video, Mouse) solution designed for efficient remote management of computers, servers, and workstations. Whether you're dealing with boot failures, installing a new operating system, adjusting BIOS settings, or simply taking control of a machine from afar, JetKVM provides the tools to get it done effectively.

Features

  • Ultra-low Latency - 1080p@60FPS video with 30-60ms latency using H.264 encoding. Smooth mouse and keyboard interaction for responsive remote control.
  • Free & Optional Remote Access - Remote management via JetKVM Cloud using WebRTC.
  • Open-source software - Written in Golang on Linux. Easily customizable through SSH access to the JetKVM device.

Contributing

We welcome contributions from the community! Whether it's improving the firmware, adding new features, or enhancing documentation, your input is valuable. We also have some rules and taboos here, so please read this page and our Code of Conduct carefully.

I need help

The best place to search for answers is our Documentation. If you can't find the answer there, check our Discord Server.

I want to report an issue

If you've found an issue and want to report it, please check our Issues page. Make sure the description contains information about the firmware version you're using, your platform, and a clear explanation of the steps to reproduce the issue.

Development

JetKVM is written in Go & TypeScript. with some bits and pieces written in C. An intermediate level of Go & TypeScript knowledge is recommended for comfortable programming.

The project contains two main parts, the backend software that runs on the KVM device and the frontend software that is served by the KVM device, and also the cloud.

For comprehensive development information, including setup, testing, debugging, and contribution guidelines, see DEVELOPMENT.md.

For quick device development, use the ./dev_deploy.sh script. It will build the frontend and backend and deploy them to the local KVM device. Run ./dev_deploy.sh --help for more information.

Backend

The backend is written in Go and is responsible for the KVM device management, the cloud API and the cloud web.

Frontend

The frontend is written in React and TypeScript and is served by the KVM device. It has three build targets: device, development and production. Development is used for development of the cloud version on your local machine, device is used for building the frontend for the KVM device and production is used for building the frontend for the cloud.

Documentation

Index

Constants

View Source
const (
	// CloudWebSocketConnectTimeout is the timeout for the websocket connection to the cloud
	CloudWebSocketConnectTimeout = 1 * time.Minute
	// CloudAPIRequestTimeout is the timeout for cloud API requests
	CloudAPIRequestTimeout = 10 * time.Second
	// CloudOidcRequestTimeout is the timeout for OIDC token verification requests
	// should be lower than the websocket response timeout set in cloud-api
	CloudOidcRequestTimeout = 10 * time.Second
	// WebsocketPingInterval is the interval at which the websocket client sends ping messages to the cloud
	WebsocketPingInterval = 15 * time.Second
)
View Source
const (
	MaxMacrosPerDevice = 25
	MaxStepsPerMacro   = 10
	MaxKeysPerStep     = 10
	MinStepDelay       = 50
	MaxStepDelay       = 2000
)

Constants for keyboard macro limits

View Source
const (
	NetIfName = "eth0"
)
View Source
const UpdateMetadataUrl = "https://api.jetkvm.com/releases"

Variables

This section is empty.

Functions

func ErrorfL

func ErrorfL(l *zerolog.Logger, format string, err error, args ...any) error

func ExtractAndRunNativeBin

func ExtractAndRunNativeBin() error

func GetBuiltAppVersion

func GetBuiltAppVersion() string

func GetDefaultHostname

func GetDefaultHostname() string

func GetDeviceID

func GetDeviceID() string

func GetLocalVersion

func GetLocalVersion() (systemVersion *semver.Version, appVersion *semver.Version, err error)

func GetNativeVersion

func GetNativeVersion() (string, error)

func GetVersionData

func GetVersionData(isJson bool) ([]byte, error)

func HandleVideoStateMessage

func HandleVideoStateMessage(event CtrlResponse)

func IsUpdatePending

func IsUpdatePending() bool

func LoadConfig

func LoadConfig()

func Main

func Main()

func RunWebSecureServer

func RunWebSecureServer()

func RunWebServer

func RunWebServer()

func RunWebsocketClient

func RunWebsocketClient()

func SaveConfig

func SaveConfig() error

func StartNativeCtrlSocketServer

func StartNativeCtrlSocketServer()

func StartNativeSocketServer

func StartNativeSocketServer(socketPath string, handleClient func(net.Conn), isCtrl bool) net.Listener

func StartNativeVideoSocketServer

func StartNativeVideoSocketServer()

func TryUpdate

func TryUpdate(ctx context.Context, deviceId string, includePreRelease bool) error

func WriteCtrlMessage

func WriteCtrlMessage(message []byte) error

Types

type ATXState

type ATXState struct {
	Power bool `json:"power"`
	HDD   bool `json:"hdd"`
}

type BacklightSettings

type BacklightSettings struct {
	MaxBrightness int `json:"max_brightness"`
	DimAfter      int `json:"dim_after"`
	OffAfter      int `json:"off_after"`
}

type ChangePasswordRequest

type ChangePasswordRequest struct {
	OldPassword string `json:"oldPassword"`
	NewPassword string `json:"newPassword"`
}

type CloudConnectionState

type CloudConnectionState uint8
const (
	CloudConnectionStateNotConfigured CloudConnectionState = iota
	CloudConnectionStateDisconnected
	CloudConnectionStateConnecting
	CloudConnectionStateConnected
)

type CloudRegisterRequest

type CloudRegisterRequest struct {
	Token      string `json:"token"`
	CloudAPI   string `json:"cloudApi"`
	OidcGoogle string `json:"oidcGoogle"`
	ClientId   string `json:"clientId"`
}

type CloudState

type CloudState struct {
	Connected bool   `json:"connected"`
	URL       string `json:"url,omitempty"`
	AppURL    string `json:"appUrl,omitempty"`
}

type Config

type Config struct {
	CloudURL             string                 `json:"cloud_url"`
	CloudAppURL          string                 `json:"cloud_app_url"`
	CloudToken           string                 `json:"cloud_token"`
	GoogleIdentity       string                 `json:"google_identity"`
	JigglerEnabled       bool                   `json:"jiggler_enabled"`
	JigglerConfig        *JigglerConfig         `json:"jiggler_config"`
	AutoUpdateEnabled    bool                   `json:"auto_update_enabled"`
	IncludePreRelease    bool                   `json:"include_pre_release"`
	HashedPassword       string                 `json:"hashed_password"`
	LocalAuthToken       string                 `json:"local_auth_token"`
	LocalAuthMode        string                 `json:"localAuthMode"` //TODO: fix it with migration
	LocalLoopbackOnly    bool                   `json:"local_loopback_only"`
	WakeOnLanDevices     []WakeOnLanDevice      `json:"wake_on_lan_devices"`
	KeyboardMacros       []KeyboardMacro        `json:"keyboard_macros"`
	KeyboardLayout       string                 `json:"keyboard_layout"`
	EdidString           string                 `json:"hdmi_edid_string"`
	ActiveExtension      string                 `json:"active_extension"`
	DisplayRotation      string                 `json:"display_rotation"`
	DisplayMaxBrightness int                    `json:"display_max_brightness"`
	DisplayDimAfterSec   int                    `json:"display_dim_after_sec"`
	DisplayOffAfterSec   int                    `json:"display_off_after_sec"`
	TLSMode              string                 `json:"tls_mode"` // options: "self-signed", "user-defined", ""
	UsbConfig            *usbgadget.Config      `json:"usb_config"`
	UsbDevices           *usbgadget.Devices     `json:"usb_devices"`
	NetworkConfig        *network.NetworkConfig `json:"network_config"`
	DefaultLogLevel      string                 `json:"default_log_level"`
}

type CtrlAction

type CtrlAction struct {
	Action string         `json:"action"`
	Seq    int32          `json:"seq,omitempty"`
	Params map[string]any `json:"params,omitempty"`
}

type CtrlResponse

type CtrlResponse struct {
	Seq    int32           `json:"seq,omitempty"`
	Error  string          `json:"error,omitempty"`
	Errno  int32           `json:"errno,omitempty"`
	Result map[string]any  `json:"result,omitempty"`
	Event  string          `json:"event,omitempty"`
	Data   json.RawMessage `json:"data,omitempty"`
}

func CallCtrlAction

func CallCtrlAction(action string, params map[string]any) (*CtrlResponse, error)

type DCPowerState

type DCPowerState struct {
	IsOn         bool    `json:"isOn"`
	Voltage      float64 `json:"voltage"`
	Current      float64 `json:"current"`
	Power        float64 `json:"power"`
	RestoreState int     `json:"restoreState"`
}

type DevModeState

type DevModeState struct {
	Enabled bool `json:"enabled"`
}

type DeviceStatus

type DeviceStatus struct {
	IsSetup bool `json:"isSetup"`
}

type DisplayRotationSettings

type DisplayRotationSettings struct {
	Rotation string `json:"rotation"`
}

type EventHandler

type EventHandler func(event CtrlResponse)

type JSONRPCEvent

type JSONRPCEvent struct {
	JSONRPC string `json:"jsonrpc"`
	Method  string `json:"method"`
	Params  any    `json:"params,omitempty"`
}

type JSONRPCRequest

type JSONRPCRequest struct {
	JSONRPC string         `json:"jsonrpc"`
	Method  string         `json:"method"`
	Params  map[string]any `json:"params,omitempty"`
	ID      any            `json:"id,omitempty"`
}

type JSONRPCResponse

type JSONRPCResponse struct {
	JSONRPC string `json:"jsonrpc"`
	Result  any    `json:"result,omitempty"`
	Error   any    `json:"error,omitempty"`
	ID      any    `json:"id"`
}

type JigglerConfig

type JigglerConfig struct {
	InactivityLimitSeconds int    `json:"inactivity_limit_seconds"`
	JitterPercentage       int    `json:"jitter_percentage"`
	ScheduleCronTab        string `json:"schedule_cron_tab"`
	Timezone               string `json:"timezone,omitempty"`
}

type KeyboardMacro

type KeyboardMacro struct {
	ID        string              `json:"id"`
	Name      string              `json:"name"`
	Steps     []KeyboardMacroStep `json:"steps"`
	SortOrder int                 `json:"sortOrder,omitempty"`
}

func (*KeyboardMacro) Validate

func (m *KeyboardMacro) Validate() error

type KeyboardMacroStep

type KeyboardMacroStep struct {
	Keys      []string `json:"keys"`
	Modifiers []string `json:"modifiers"`
	Delay     int      `json:"delay"`
}

func (*KeyboardMacroStep) Validate

func (s *KeyboardMacroStep) Validate() error

type KeyboardMacrosParams

type KeyboardMacrosParams struct {
	Macros []any `json:"macros"`
}

type LocalDevice

type LocalDevice struct {
	AuthMode     *string `json:"authMode"`
	DeviceID     string  `json:"deviceId"`
	LoopbackOnly bool    `json:"loopbackOnly"`
}

type LocalMetadata

type LocalMetadata struct {
	AppVersion    string `json:"appVersion"`
	SystemVersion string `json:"systemVersion"`
}

type LoginRequest

type LoginRequest struct {
	Password string `json:"password"`
}

type NBDDevice

type NBDDevice struct {
	// contains filtered or unexported fields
}

func NewNBDDevice

func NewNBDDevice() *NBDDevice

func (*NBDDevice) Close

func (d *NBDDevice) Close()

func (*NBDDevice) Start

func (d *NBDDevice) Start() error

type OTAState

type OTAState struct {
	Updating                   bool       `json:"updating"`
	Error                      string     `json:"error,omitempty"`
	MetadataFetchedAt          *time.Time `json:"metadataFetchedAt,omitempty"`
	AppUpdatePending           bool       `json:"appUpdatePending"`
	SystemUpdatePending        bool       `json:"systemUpdatePending"`
	AppDownloadProgress        float32    `json:"appDownloadProgress,omitempty"` //TODO: implement for progress bar
	AppDownloadFinishedAt      *time.Time `json:"appDownloadFinishedAt,omitempty"`
	SystemDownloadProgress     float32    `json:"systemDownloadProgress,omitempty"` //TODO: implement for progress bar
	SystemDownloadFinishedAt   *time.Time `json:"systemDownloadFinishedAt,omitempty"`
	AppVerificationProgress    float32    `json:"appVerificationProgress,omitempty"`
	AppVerifiedAt              *time.Time `json:"appVerifiedAt,omitempty"`
	SystemVerificationProgress float32    `json:"systemVerificationProgress,omitempty"`
	SystemVerifiedAt           *time.Time `json:"systemVerifiedAt,omitempty"`
	AppUpdateProgress          float32    `json:"appUpdateProgress,omitempty"` //TODO: implement for progress bar
	AppUpdatedAt               *time.Time `json:"appUpdatedAt,omitempty"`
	SystemUpdateProgress       float32    `json:"systemUpdateProgress,omitempty"` //TODO: port rk_ota, then implement
	SystemUpdatedAt            *time.Time `json:"systemUpdatedAt,omitempty"`
}

type RPCHandler

type RPCHandler struct {
	Func   any
	Params []string
}

type SSHKeyState

type SSHKeyState struct {
	SSHKey string `json:"sshKey"`
}

type SerialSettings

type SerialSettings struct {
	BaudRate string `json:"baudRate"`
	DataBits string `json:"dataBits"`
	StopBits string `json:"stopBits"`
	Parity   string `json:"parity"`
}

type Session

type Session struct {
	VideoTrack     *webrtc.TrackLocalStaticSample
	ControlChannel *webrtc.DataChannel
	RPCChannel     *webrtc.DataChannel
	HidChannel     *webrtc.DataChannel
	// contains filtered or unexported fields
}

func (*Session) ExchangeOffer

func (s *Session) ExchangeOffer(offerStr string) (string, error)

type SessionConfig

type SessionConfig struct {
	ICEServers []string
	LocalIP    string
	IsCloud    bool

	Logger *zerolog.Logger
	// contains filtered or unexported fields
}

type SetPasswordRequest

type SetPasswordRequest struct {
	Password string `json:"password"`
}

type SetWakeOnLanDevicesParams

type SetWakeOnLanDevicesParams struct {
	Devices []WakeOnLanDevice `json:"devices"`
}

type SetupRequest

type SetupRequest struct {
	LocalAuthMode string `json:"localAuthMode"`
	Password      string `json:"password,omitempty"`
}

type StorageFile

type StorageFile struct {
	Filename  string    `json:"filename"`
	Size      int64     `json:"size"`
	CreatedAt time.Time `json:"createdAt"`
}

type StorageFileUpload

type StorageFileUpload struct {
	AlreadyUploadedBytes int64  `json:"alreadyUploadedBytes"`
	DataChannel          string `json:"dataChannel"`
}

type StorageFiles

type StorageFiles struct {
	Files []StorageFile `json:"files"`
}

type StorageSpace

type StorageSpace struct {
	BytesUsed int64 `json:"bytesUsed"`
	BytesFree int64 `json:"bytesFree"`
}

type TLSState

type TLSState struct {
	Mode        string `json:"mode"`
	Certificate string `json:"certificate"`
	PrivateKey  string `json:"privateKey"`
}

type TerminalSize

type TerminalSize struct {
	Rows int `json:"rows"`
	Cols int `json:"cols"`
}

type UpdateMetadata

type UpdateMetadata struct {
	AppVersion    string `json:"appVersion"`
	AppUrl        string `json:"appUrl"`
	AppHash       string `json:"appHash"`
	SystemVersion string `json:"systemVersion"`
	SystemUrl     string `json:"systemUrl"`
	SystemHash    string `json:"systemHash"`
}

type UpdateStatus

type UpdateStatus struct {
	Local                 *LocalMetadata  `json:"local"`
	Remote                *UpdateMetadata `json:"remote"`
	SystemUpdateAvailable bool            `json:"systemUpdateAvailable"`
	AppUpdateAvailable    bool            `json:"appUpdateAvailable"`

	// for backwards compatibility
	Error string `json:"error,omitempty"`
}

UpdateStatus represents the current update status

func GetUpdateStatus

func GetUpdateStatus(ctx context.Context, deviceId string, includePreRelease bool) (*UpdateStatus, error)

type UploadProgress

type UploadProgress struct {
	Size                 int64
	AlreadyUploadedBytes int64
}

type VideoInputState

type VideoInputState struct {
	Ready          bool    `json:"ready"`
	Error          string  `json:"error,omitempty"` //no_signal, no_lock, out_of_range
	Width          int     `json:"width"`
	Height         int     `json:"height"`
	FramePerSecond float64 `json:"fps"`
}

type VirtualMediaMode

type VirtualMediaMode string
const (
	CDROM VirtualMediaMode = "CDROM"
	Disk  VirtualMediaMode = "Disk"
)

type VirtualMediaSource

type VirtualMediaSource string
const (
	HTTP    VirtualMediaSource = "HTTP"
	Storage VirtualMediaSource = "Storage"
)

type VirtualMediaState

type VirtualMediaState struct {
	Source   VirtualMediaSource `json:"source"`
	Mode     VirtualMediaMode   `json:"mode"`
	Filename string             `json:"filename,omitempty"`
	URL      string             `json:"url,omitempty"`
	Size     int64              `json:"size"`
}

type VirtualMediaUrlInfo

type VirtualMediaUrlInfo struct {
	Usable bool
	Reason string //only populated if Usable is false
	Size   int64
}

type WakeOnLanDevice

type WakeOnLanDevice struct {
	Name       string `json:"name"`
	MacAddress string `json:"macAddress"`
}

type WebRTCSessionRequest

type WebRTCSessionRequest struct {
	Sd         string   `json:"sd"`
	OidcGoogle string   `json:"OidcGoogle,omitempty"`
	IP         string   `json:"ip,omitempty"`
	ICEServers []string `json:"iceServers,omitempty"`
}

Directories

Path Synopsis
internal
tzdata
Code generated by "go run gen.go".
Code generated by "go run gen.go".
usbgadget
Package usbgadget provides a high-level interface to manage USB gadgets THIS PACKAGE IS FOR INTERNAL USE ONLY AND ITS API MAY CHANGE WITHOUT NOTICE
Package usbgadget provides a high-level interface to manage USB gadgets THIS PACKAGE IS FOR INTERNAL USE ONLY AND ITS API MAY CHANGE WITHOUT NOTICE

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL