Documentation
¶
Overview ¶
client.go
Package client implements the RDP client, and carries the RFB (VNC) client this fork inherited from upstream alongside it.
The VNC client (VncClient) builds and is kept, but it has never been run against a VNC server in this project, so it is not a supported path; its clipboard methods are stubs that do nothing. The RFB parse steps it uses are unit tested in protocol/rfb.
Index ¶
- Constants
- func Bpp(bp uint16) int
- type Bitmap
- type Client
- func (c *Client) Close()
- func (c *Client) KeyDown(sc int, name string)
- func (c *Client) KeyUp(sc int, name string)
- func (c *Client) Login() error
- func (c *Client) LoginContext(ctx context.Context) error
- func (c *Client) MouseDown(button, x, y int)
- func (c *Client) MouseMove(x, y int)
- func (c *Client) MouseUp(button, x, y int)
- func (c *Client) MouseWheel(scroll, x, y int)
- func (c *Client) OnBitmap(f func([]Bitmap))
- func (c *Client) OnClipboardText(f func(text string))
- func (c *Client) OnClose(f func())
- func (c *Client) OnError(f func(e error))
- func (c *Client) OnOrdersFrame(f func(dirty image.Rectangle))
- func (c *Client) OnPointer(f func(p *pdu.PointerDataPDU))
- func (c *Client) OnPointerPosition(f func(x, y int))
- func (c *Client) OnReady(f func())
- func (c *Client) OnSuccess(f func())
- func (c *Client) OnSurfaceFrame(f func(frameID uint32, surfaces []*rdpgfx.Surface))
- func (c *Client) OnSurfaceReset(f func(width, height int))
- func (c *Client) RequestClipboardText() error
- func (c *Client) Screen() *orders.Screen
- func (c *Client) SetClipboardText(text string) error
- type Control
- type RdpClient
- func (c *RdpClient) Close()
- func (c *RdpClient) KeyDown(sc int, name string)
- func (c *RdpClient) KeyUp(sc int, name string)
- func (c *RdpClient) Login(host, user, pwd string, width, height int) error
- func (c *RdpClient) MouseDown(button int, x, y int)
- func (c *RdpClient) MouseMove(x, y int)
- func (c *RdpClient) MouseUp(button int, x, y int)
- func (c *RdpClient) MouseWheel(scroll, x, y int)
- func (c *RdpClient) On(event string, f interface{})
- func (c *RdpClient) RequestClipboardText() error
- func (c *RdpClient) SetClipboardText(text string) error
- type Setting
- type VncClient
- func (c *VncClient) Close()
- func (c *VncClient) KeyDown(sc int, name string)
- func (c *VncClient) KeyUp(sc int, name string)
- func (c *VncClient) Login(host, user, pwd string, width, height int) error
- func (c *VncClient) MouseDown(button int, x, y int)
- func (c *VncClient) MouseMove(x, y int)
- func (c *VncClient) MouseUp(button int, x, y int)
- func (c *VncClient) MouseWheel(scroll, x, y int)
- func (c *VncClient) On(event string, f interface{})
- func (c *VncClient) RequestClipboardText() error
- func (c *VncClient) SetClipboardText(string) error
Constants ¶
const ( CLIP_OFF = 0 CLIP_IN = 0x1 CLIP_OUT = 0x2 )
const ( TC_RDP = 0 TC_VNC = 1 )
const DefaultLoginTimeout = 30 * time.Second
DefaultLoginTimeout bounds how long Login waits for the RDP session to become ready after the transport handshake succeeds.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Bitmap ¶
type Bitmap struct {
DestLeft int `json:"destLeft"`
DestTop int `json:"destTop"`
DestRight int `json:"destRight"`
DestBottom int `json:"destBottom"`
Width int `json:"width"`
Height int `json:"height"`
BitsPerPixel int `json:"bitsPerPixel"`
IsCompress bool `json:"isCompress"`
Data []byte `json:"data"`
}
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) LoginContext ¶
LoginContext is Login with an explicit context. It returns only once the server has completed the connection sequence and the session is ready, or when the handshake fails, the connection is closed, or ctx expires.
func (*Client) MouseWheel ¶
func (*Client) OnClipboardText ¶
OnClipboardText reports text the server has put on the clipboard. It only fires when the clipboard channel is enabled.
func (*Client) OnOrdersFrame ¶ added in v0.3.0
OnOrdersFrame reports that a batch of drawing orders changed the screen, giving the area that changed. The pixels are in Client.Screen.
func (*Client) OnPointer ¶
func (c *Client) OnPointer(f func(p *pdu.PointerDataPDU))
OnPointer reports slow-path pointer updates (PDUTYPE2_POINTER), which carry either a new position or a pointer shape.
func (*Client) OnPointerPosition ¶
OnPointerPosition reports the server-side pointer position (fast-path FASTPATH_UPDATETYPE_PTR_POSITION). It is useful to confirm that mouse input reached the remote session.
func (*Client) OnSurfaceFrame ¶
OnSurfaceFrame reports each completed EGFX frame and the surfaces it touched. The pixel data lives on the surfaces, so callers that need it should copy what they need before returning.
func (*Client) OnSurfaceReset ¶
OnSurfaceReset reports the desktop size an EGFX server will composite into, which also means any previously known surfaces are gone.
func (*Client) RequestClipboardText ¶
RequestClipboardText asks the server for the clipboard text it last announced. OnClipboardText normally triggers this by itself, but a server can announce a format before it is able to serve it, in which case an explicit request made later is what gets the data.
func (*Client) Screen ¶ added in v0.3.0
Screen returns the framebuffer that drawing orders are rendered into, or nil when Setting.EnableOrders was not set. It holds BGRA pixels, top down, and is safe to read while the connection is running.
func (*Client) SetClipboardText ¶
SetClipboardText publishes text on the shared clipboard, so a paste on the server pastes it. It only does anything when the clipboard channel is enabled.
type Control ¶
type Control interface {
Login(host, user, passwd string, width, height int) error
KeyUp(sc int, name string)
KeyDown(sc int, name string)
MouseMove(x, y int)
MouseWheel(scroll, x, y int)
MouseUp(button int, x, y int)
MouseDown(button int, x, y int)
On(event string, msg interface{})
SetClipboardText(text string) error
RequestClipboardText() error
Close()
}
type RdpClient ¶
type RdpClient struct {
// contains filtered or unexported fields
}
func (*RdpClient) MouseWheel ¶
func (*RdpClient) RequestClipboardText ¶
RequestClipboardText asks the server for its clipboard text.
func (*RdpClient) SetClipboardText ¶
SetClipboardText publishes text on the shared clipboard.
type Setting ¶
type Setting struct {
Width int
Height int
Protocol string
Timeout time.Duration
LogLevel glog.LEVEL
// NoFastPathInput forces keyboard/mouse input over the slow path even
// when the server advertised fast-path input. Useful for debugging.
NoFastPathInput bool
// EnableEGFX opens the dynamic virtual channel needed for the RDP
// Graphics Pipeline Extension, so the server can composite surfaces and
// send them as compressed bitmaps instead of bitmap updates.
//
// This is off by default: it has not been exercised against a server that
// speaks EGFX, and enabling it changes how the server draws the session.
EnableEGFX bool
// EnableClipboard opens the clipboard channel so text can be exchanged
// with the server. Use Client.OnClipboardText and Client.SetClipboardText
// to bridge it to the local clipboard.
EnableClipboard bool
// EnableOrders advertises support for the MEMBLT drawing order and renders
// the drawing orders that follow, into a framebuffer reachable through
// Client.Screen.
//
// It is off by default because it changes how the server draws the session
// and it cannot mix: once MEMBLT is advertised the server stops sending
// bitmap updates and puts everything through the bitmap cache instead. With
// it off the session is drawn from bitmap updates, which is correct, just
// larger on the wire.
EnableOrders bool
}
func NewSetting ¶
func NewSetting() *Setting
func (*Setting) SetClipboard ¶
func (*Setting) SetLogLevel ¶
func (s *Setting) SetLogLevel()
func (*Setting) SetRequestedProtocol ¶
type VncClient ¶
type VncClient struct {
// contains filtered or unexported fields
}
func (*VncClient) Login ¶
Login dials the server and returns only once the RFB handshake has completed, the handshake has failed, or the timeout expires. The handshake is event driven, so it is driven to a result the caller can see instead of returning while it is still running. There is no VNC server in this project to exercise it against.
func (*VncClient) MouseWheel ¶
func (*VncClient) On ¶
On registers a listener. It is a no-op before Login succeeds, so a caller that lost the connection cannot panic here.
func (*VncClient) RequestClipboardText ¶
RequestClipboardText is not implemented for RFB.
func (*VncClient) SetClipboardText ¶
SetClipboardText is not implemented for RFB.