rdp

package
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2026 License: AGPL-3.0 Imports: 39 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package rdp implements the client side of the Remote Desktop Protocol.

Index

Constants

View Source
const (
	// KnownCertsFile is the RDP certificate pin store in the application data folder.
	KnownCertsFile = "rdp_known_certs.json"
)

Variables

This section is empty.

Functions

func Classify

func Classify(err error) (Kind, Reason)

Classify finds a typed failure in the error chain.

func Fingerprint

func Fingerprint(cert *x509.Certificate) string

Fingerprint returns the colon-separated SHA-256 digest of the leaf's DER.

func Retryable

func Retryable(err error) bool

Retryable reports whether another attempt could repair a network failure.

Types

type Button

type Button int

Button names the mouse buttons carried in RDP input events.

const (
	ButtonLeft Button = iota
	ButtonRight
	ButtonMiddle
	ButtonX1
	ButtonX2
)

type CertError

type CertError struct {
	Addr        string
	Fingerprint string
	Known       string
	Subject     string
	NotAfter    time.Time
}

CertError identifies an unknown or changed RDP leaf certificate.

func (*CertError) Error

func (e *CertError) Error() string

type Config

type Config struct {
	Addr, Domain, User, ClientName string
	Dial                           func(context.Context, string, string) (net.Conn, error)
	Password                       func(context.Context) (string, error)
	VerifyCert                     func(addr string, chain []*x509.Certificate) error
	Security                       Security
	Width, Height, Scale           int
	Admin, Clipboard               bool
	KeyboardLayout                 uint32
	Timeout                        time.Duration
	Log                            func(string)
}

Config is a snapshot of the settings used by one connection attempt.

type Error

type Error struct {
	Kind   Kind
	Reason Reason
	Code   uint32
	Err    error
}

Error describes an RDP connection failure.

func (*Error) Error

func (e *Error) Error() string

func (*Error) Unwrap

func (e *Error) Unwrap() error

type Kind

type Kind int

Kind is the connection stage or origin of a failure.

const (
	KindOther Kind = iota
	KindNetwork
	KindAuth
	KindCert
	KindSecurity
	KindServer
	KindLicense
)

type KnownCerts

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

KnownCerts keeps explicit trust-on-first-use pins by host and port.

func OpenKnownCerts

func OpenKnownCerts(path string) (*KnownCerts, error)

OpenKnownCerts loads path. A missing file has an empty trust store.

func (*KnownCerts) Contents

func (k *KnownCerts) Contents() ([]byte, error)

Contents returns a snapshot suitable for backup.

func (*KnownCerts) Forget

func (k *KnownCerts) Forget(addr string) error

Forget removes the pin for addr.

func (*KnownCerts) Known

func (k *KnownCerts) Known(addr string) (string, bool)

Known returns the fingerprint trusted for addr, if any.

func (*KnownCerts) Merge

func (k *KnownCerts) Merge(data []byte) (int, error)

Merge adds imported pins whose addresses are absent from this store.

func (*KnownCerts) Path

func (k *KnownCerts) Path() string

Path returns the location of the file.

func (*KnownCerts) Trust

func (k *KnownCerts) Trust(addr, fingerprint string) error

Trust adds or replaces a leaf pin after explicit user approval.

func (*KnownCerts) Verify

func (k *KnownCerts) Verify(addr string, chain []*x509.Certificate) error

Verify accepts only the currently pinned leaf certificate for addr.

type Options

type Options struct {
	AutoReconnect bool
}

Options controls session behavior across individual attempts.

type Pointer

type Pointer struct {
	Image           *image.RGBA
	HotX, HotY      int
	Hidden, Default bool
	Version         uint64
}

Pointer is the current remote cursor shape. Image is immutable and may be shared with earlier snapshots. HotX and HotY are relative to Image.

type Reason

type Reason int

Reason is a failure detail that the application can present to the user.

const (
	ReasonNone Reason = iota
	ReasonLogonFailure
	ReasonAccountLocked
	ReasonAccountDisabled
	ReasonAccountRestricted
	ReasonAccountExpired
	ReasonPasswordExpired
	ReasonPasswordMustChange
	ReasonLogonTypeNotGranted
	ReasonLoggedOff
	ReasonIdleTimeout
	ReasonLogonTimeout
	ReasonReplaced
	ReasonAdminEnded
	ReasonServerDenied
	ReasonProtocol
)

type Security

type Security string

Security selects the external security protocol used by an RDP connection.

const (
	SecurityAuto Security = ""
	SecurityNLA  Security = "nla"
	SecurityTLS  Security = "tls"
)

type Session

type Session struct {
	OnChange    func()
	OnClipboard func(text string)
	// contains filtered or unexported fields
}

Session owns one remote desktop and reconnects it when configured to do so. Set the callbacks before starting the session.

func New

func New(cfg Config, opts Options) *Session

New prepares an idle session without opening a network connection.

func (*Session) Close

func (s *Session) Close()

Close cancels pending work and disconnects the desktop.

func (*Session) CopyFrame

func (s *Session) CopyFrame(dst *image.RGBA, since uint64) (*image.RGBA, uint64, image.Rectangle)

CopyFrame copies the desktop pixels changed after since. A nil or mismatched destination or a version outside the history gets a full copy.

func (*Session) CtrlAltDel

func (s *Session) CtrlAltDel()

CtrlAltDel queues a secure attention chord.

func (*Session) Key

func (s *Session) Key(scancode uint16, extended, down bool)

Key queues a positional Set 1 key transition.

func (*Session) MouseButton

func (s *Session) MouseButton(x, y int, b Button, down bool)

MouseButton queues a button press or release at a desktop position.

func (*Session) MouseMove

func (s *Session) MouseMove(x, y int)

MouseMove queues a remote desktop position, coalescing adjacent moves.

func (*Session) Pointer

func (s *Session) Pointer() Pointer

Pointer returns the latest immutable cursor shape and hot spot.

func (*Session) PointerPosition

func (s *Session) PointerPosition() (image.Point, bool)

PointerPosition returns the last explicit position set by the server.

func (*Session) Reconnect

func (s *Session) Reconnect()

Reconnect replaces any running connection with a new attempt.

func (*Session) ReleaseAll

func (s *Session) ReleaseAll()

ReleaseAll releases the keys and buttons currently pressed by this client.

func (*Session) Resize

func (s *Session) Resize(width, height, scale int)

Resize requests a display update after 300 milliseconds without new sizes.

func (*Session) SetClipboard

func (s *Session) SetClipboard(text string)

SetClipboard sends supported plain text when clipboard redirection is enabled.

func (*Session) SetConfig

func (s *Session) SetConfig(cfg Config)

SetConfig replaces settings for subsequent connection attempts.

func (*Session) SetVisible

func (s *Session) SetVisible(visible bool)

SetVisible asks an active server to suppress or resume display updates.

func (*Session) Start

func (s *Session) Start()

Start opens the connection in the background.

func (*Session) Status

func (s *Session) Status() Status

Status reports a copy of the current state and negotiated desktop size.

func (*Session) SyncLocks

func (s *Session) SyncLocks(capsLock, numLock, scrollLock, kanaLock bool)

SyncLocks sends the local toggle key state.

func (*Session) Unicode

func (s *Session) Unicode(r rune, down bool)

Unicode queues a Unicode key transition for a server that supports it.

func (*Session) Wheel

func (s *Session) Wheel(x, y, dx, dy int)

Wheel queues horizontal and vertical wheel deltas in Windows wheel units.

type State

type State int

State is the state of a desktop session.

const (
	Idle State = iota
	Connecting
	Connected
	Reconnecting
	Disconnected
	Failed
)

type Status

type Status struct {
	State             State
	Step              Step
	Err               error
	Attempt, Connects int
	Width, Height     int
	Since             time.Time
}

Status is the current state and progress of a desktop session.

type Step

type Step int

Step describes the latest connection progress.

const (
	StepDial Step = iota
	StepTLS
	StepAuth
	StepLicense
	StepCapabilities
	StepReady
)

Jump to

Keyboard shortcuts

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