grdp

package module
v0.4.9 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2026 License: GPL-3.0 Imports: 20 Imported by: 1

README

Golang Remote Desktop Protocol

grdp is a pure Golang implementation of the Microsoft RDP (Remote Desktop Protocol) protocol client

Forked from tomatome/grdp

How to execute example

Prepare environment variables (In your environment. You may also need to set GRDP_DOMAIN)

export GRDP_USER=user
export GRDP_PASSWORD=password
export GRDP_PORT=3389
export GRDP_HOST=host
export GRDP_WINDOW_SIZE=1280x800
Environment Variables
Variable Description Default
GRDP_HOST Hostname or IP address of the RDP server (required)
GRDP_PORT Port number (required)
GRDP_USER Username (empty)
GRDP_PASSWORD Password (empty)
GRDP_DOMAIN Domain (empty)
GRDP_WINDOW_SIZE Window size in WxH format 1280x800
GRDP_KEYBOARD_TYPE Keyboard type (see values below) IBM_101_102_KEYS
GRDP_KEYBOARD_LAYOUT Keyboard layout (see values below) US
GRDP_KEYBOARD_TYPE values
Value Description
IBM_PC_XT_83_KEY IBM PC/XT 83-key keyboard
OLIVETTI Olivetti keyboard
IBM_PC_AT_84_KEY IBM PC/AT 84-key keyboard
IBM_101_102_KEYS IBM 101/102-key keyboard (most common)
NOKIA_1050 Nokia 1050 keyboard
NOKIA_9140 Nokia 9140 keyboard
JAPANESE Japanese keyboard
GRDP_KEYBOARD_LAYOUT values
Value Language / Region
ARABIC Arabic
BULGARIAN Bulgarian
CHINESE_US_KEYBOARD Chinese (US keyboard)
CZECH Czech
DANISH Danish
GERMAN German
GREEK Greek
US English (United States)
SPANISH Spanish
FINNISH Finnish
FRENCH French
HEBREW Hebrew
HUNGARIAN Hungarian
ICELANDIC Icelandic
ITALIAN Italian
JAPANESE Japanese
KOREAN Korean
DUTCH Dutch
NORWEGIAN Norwegian

Clone and execute example

git clone https://github.com/nakagami/grdp
cd grdp
go run example/gxui.go
AVC/H.264 Hardware Accelerated Codec (Optional)

By default, grdp is pure Go and AVC (H.264) codecs are disabled. To enable hardware-accelerated H.264 decoding, build with the h264 tag and FFmpeg (≥ 3.4) development libraries:

# macOS
brew install ffmpeg

# Debian/Ubuntu
sudo apt install libavcodec-dev libavutil-dev libswscale-dev pkg-config

# Build with AVC support
go run -tags h264 example/gxui.go

When built with -tags h264, the client advertises RDPGFX v10/v8.1 capabilities and supports AVC420/AVC444 codecs. Hardware acceleration (VideoToolbox on macOS, VAAPI on Linux) is automatically used when available, with a software fallback.

This example uses gxui. Since gxui is no longer being updated, I hope to have some kind of cross-platform GUI example.

See also https://github.com/nakagami/grdpsdl2

Take ideas from

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bitmap

type Bitmap struct {
	DestLeft     int
	DestTop      int
	DestRight    int
	DestBottom   int
	Width        int
	Height       int
	BitsPerPixel int
	Data         []byte
}

func (*Bitmap) RGBA added in v0.2.3

func (bm *Bitmap) RGBA() *image.RGBA

type RdpClient

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

func NewRdpClient

func NewRdpClient(host string, width, height int) *RdpClient

func (*RdpClient) Close

func (g *RdpClient) Close()

func (*RdpClient) Height added in v0.2.2

func (g *RdpClient) Height() int

func (*RdpClient) KeyDown

func (g *RdpClient) KeyDown(sc int)

func (*RdpClient) KeyUp

func (g *RdpClient) KeyUp(sc int)

func (*RdpClient) Login

func (g *RdpClient) Login(domain string, user string, password string) error

func (*RdpClient) MouseDown

func (g *RdpClient) MouseDown(button int, x, y int)

func (*RdpClient) MouseMove

func (g *RdpClient) MouseMove(x, y int)

func (*RdpClient) MouseUp

func (g *RdpClient) MouseUp(button int, x, y int)

func (*RdpClient) MouseWheel

func (g *RdpClient) MouseWheel(scroll int)

func (*RdpClient) NotifyClipboardChanged added in v0.4.8

func (g *RdpClient) NotifyClipboardChanged()

NotifyClipboardChanged tells the server that the local clipboard has changed. The UI should call this when it detects a system clipboard change (e.g. via polling or a platform clipboard-change signal).

func (*RdpClient) OnAudio added in v0.4.7

func (g *RdpClient) OnAudio(f func(rdpsnd.AudioFormat, []byte)) *RdpClient

OnAudio registers a callback for server audio data. The callback receives the AudioFormat describing the PCM data and the raw audio bytes. Must be called before Login.

func (*RdpClient) OnBitmap

func (g *RdpClient) OnBitmap(paint func([]Bitmap)) *RdpClient

OnBitmap registers a callback for bitmap update events. For compressed bitmaps, Bitmap.Data is borrowed from an internal pool and is valid only for the duration of the paint call. If you need to retain the raw pixel data beyond paint, copy it or call bm.RGBA() inside paint.

func (*RdpClient) OnClipboard added in v0.4.8

func (g *RdpClient) OnClipboard(onRemote func(text string), getLocal func() string) *RdpClient

OnClipboard registers callbacks for bidirectional clipboard sharing.

  • onRemote is called with the text when the RDP server's clipboard content is received (server → client).
  • getLocal is called to retrieve the current local clipboard text when the server requests it (client → server).

Must be called before Login.

func (*RdpClient) OnClose

func (g *RdpClient) OnClose(f func()) *RdpClient

func (*RdpClient) OnError

func (g *RdpClient) OnError(f func(e error)) *RdpClient

func (*RdpClient) OnPointerCached added in v0.3.3

func (g *RdpClient) OnPointerCached(f func(uint16)) *RdpClient

func (*RdpClient) OnPointerHide added in v0.3.3

func (g *RdpClient) OnPointerHide(f func()) *RdpClient

func (*RdpClient) OnPointerUpdate added in v0.3.3

func (g *RdpClient) OnPointerUpdate(f func(uint16, uint16, uint16, uint16, uint16, uint16, []byte, []byte)) *RdpClient

func (*RdpClient) OnReady

func (g *RdpClient) OnReady(f func()) *RdpClient

func (*RdpClient) OnSucces

func (g *RdpClient) OnSucces(f func()) *RdpClient

func (*RdpClient) Reconnect added in v0.4.3

func (g *RdpClient) Reconnect(width, height int) error

func (*RdpClient) SetKeyboardLayout added in v0.4.1

func (g *RdpClient) SetKeyboardLayout(layout string)

SetKeyboardLayout sets the keyboard layout by name (e.g. "US", "FRENCH"). Must be called before Login.

func (*RdpClient) SetKeyboardType added in v0.4.1

func (g *RdpClient) SetKeyboardType(keyboardType string)

SetKeyboardType sets the keyboard type by name (e.g. "IBM_101_102_KEYS"). Must be called before Login.

func (*RdpClient) Width added in v0.2.2

func (g *RdpClient) Width() int

Directories

Path Synopsis
cliprdr
Package cliprdr handler.go implements a cross-platform CLIPRDR (Clipboard Virtual Channel Extension, MS-RDPECLIP) handler for bidirectional text clipboard sharing between RDP client and server.
Package cliprdr handler.go implements a cross-platform CLIPRDR (Clipboard Virtual Channel Extension, MS-RDPECLIP) handler for bidirectional text clipboard sharing between RDP client and server.
rail
rail.go
rail.go
rdpsnd
Package rdpsnd implements the RDPSND (Audio Output Virtual Channel Extension) protocol (MS-RDPEA) for server-to-client audio redirection.
Package rdpsnd implements the RDPSND (Audio Output Virtual Channel Extension) protocol (MS-RDPEA) for server-to-client audio redirection.
protocol
lic
nla
pdu
sec

Jump to

Keyboard shortcuts

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