Documentation
¶
Overview ¶
package guacamole implements a HTTP client and a WebSocket client that connects to an Apache Guacamole server.
Index ¶
- Constants
- Variables
- type Config
- type CountedLock
- type ErrGuac
- type ErrKind
- type Instruction
- type InstructionReader
- type SimpleTunnel
- func (t *SimpleTunnel) AcquireReader() InstructionReader
- func (t *SimpleTunnel) AcquireWriter() io.Writer
- func (t *SimpleTunnel) Close() (err error)
- func (t *SimpleTunnel) ConnectionID() string
- func (t *SimpleTunnel) GetUUID() string
- func (t *SimpleTunnel) HasQueuedReaderThreads() bool
- func (t *SimpleTunnel) HasQueuedWriterThreads() bool
- func (t *SimpleTunnel) ReleaseReader()
- func (t *SimpleTunnel) ReleaseWriter()
- type Status
- type Stream
- func (s *Stream) AssertOpcode(opcode string) (instruction *Instruction, err error)
- func (s *Stream) Available() bool
- func (s *Stream) Close() error
- func (s *Stream) Flush()
- func (s *Stream) Handshake(config *Config) error
- func (s *Stream) ReadSome() (instruction []byte, err error)
- func (s *Stream) Write(data []byte) (n int, err error)
- type Tunnel
Constants ¶
const ( SocketTimeout = 15 * time.Second MaxGuacMessage = 8192 )
const InternalDataOpcode = ""
The Guacamole protocol instruction Opcode reserved for arbitrary internal use by tunnel implementations. The value of this Opcode is guaranteed to be the empty string (""). Tunnel implementations may use this Opcode for any purpose. It is currently used by the HTTP tunnel to mark the end of the HTTP response, and by the WebSocket tunnel to transmit the tunnel UUID.
const TfaOpcode = "tfa"
Variables ¶
var InternalOpcodeIns = []byte(fmt.Sprint(len(InternalDataOpcode), ".", InternalDataOpcode))
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { // ConnectionID is used to reconnect to an existing session, otherwise leave blank for a new session. ConnectionID string // Protocol is the protocol of the connection from guacd to the remote (rdp, ssh, etc). Protocol string // Parameters are used to configure protocol specific options like sla for rdp or terminal color schemes. Parameters map[string]string // OptimalScreenWidth is the desired width of the screen OptimalScreenWidth int // OptimalScreenHeight is the desired height of the screen OptimalScreenHeight int // OptimalResolution is the desired resolution of the screen OptimalResolution int // AudioMimetypes is an array of the supported audio types AudioMimetypes []string // VideoMimetypes is an array of the supported video types VideoMimetypes []string // ImageMimetypes is an array of the supported image types ImageMimetypes []string }
Config is the data sent to guacd to configure the session during the handshake.
func NewGuacamoleConfiguration ¶
func NewGuacamoleConfiguration() *Config
NewGuacamoleConfiguration returns a Config with sane defaults
type CountedLock ¶
type CountedLock struct {
// contains filtered or unexported fields
}
CountedLock counts how many goroutines are waiting on the lock
func (*CountedLock) HasQueued ¶
func (r *CountedLock) HasQueued() bool
HasQueued returns true if a goroutine is waiting on the lock
type ErrKind ¶
type ErrKind int
const ( ErrClientBadType ErrKind = iota ErrClient ErrClientOverrun ErrClientTimeout ErrClientTooMany ErrConnectionClosed ErrOther ErrResourceClosed ErrResourceConflict ErrResourceNotFound ErrSecurity ErrServerBusy ErrServer ErrSessionClosed ErrSessionConflict ErrSessionTimeout ErrUnsupported ErrUpstream ErrUpstreamNotFound ErrUpstreamTimeout )
type Instruction ¶
Instruction represents a Guacamole instruction
func NewInstruction ¶
func NewInstruction(opcode string, args ...string) *Instruction
NewInstruction creates an instruction
func Parse ¶
func Parse(data []byte) (*Instruction, error)
func ReadOne ¶
func ReadOne(stream *Stream) (instruction *Instruction, err error)
ReadOne takes an instruction from the stream and parses it into an Instruction
func (*Instruction) Byte ¶
func (i *Instruction) Byte() []byte
func (*Instruction) String ¶
func (i *Instruction) String() string
String returns the on-wire representation of the instruction
type InstructionReader ¶
type InstructionReader interface { // ReadSome returns the next complete guacd message from the stream ReadSome() ([]byte, error) // Available returns true if there are bytes buffered in the stream Available() bool // Flush resets the internal buffer for reuse Flush() }
InstructionReader provides reading functionality to a Stream
type SimpleTunnel ¶
type SimpleTunnel struct {
// contains filtered or unexported fields
}
Base Tunnel implementation which synchronizes access to the underlying reader and writer with locks
func NewSimpleTunnel ¶
func NewSimpleTunnel(stream *Stream, uuid string) *SimpleTunnel
NewSimpleTunnel creates a new tunnel
func (*SimpleTunnel) AcquireReader ¶
func (t *SimpleTunnel) AcquireReader() InstructionReader
AcquireReader acquires the reader lock
func (*SimpleTunnel) AcquireWriter ¶
func (t *SimpleTunnel) AcquireWriter() io.Writer
AcquireWriter locks the writer lock
func (*SimpleTunnel) Close ¶
func (t *SimpleTunnel) Close() (err error)
Close closes the underlying stream
func (*SimpleTunnel) ConnectionID ¶
func (t *SimpleTunnel) ConnectionID() string
ConnectionID returns the underlying Guacamole connection ID
func (*SimpleTunnel) GetUUID ¶
func (t *SimpleTunnel) GetUUID() string
GetUUID returns the tunnel's UUID
func (*SimpleTunnel) HasQueuedReaderThreads ¶
func (t *SimpleTunnel) HasQueuedReaderThreads() bool
HasQueuedReaderThreads returns true if more than one goroutine is trying to read
func (*SimpleTunnel) HasQueuedWriterThreads ¶
func (t *SimpleTunnel) HasQueuedWriterThreads() bool
HasQueuedWriterThreads returns true if more than one goroutine is trying to write
func (*SimpleTunnel) ReleaseReader ¶
func (t *SimpleTunnel) ReleaseReader()
ReleaseReader releases the reader
func (*SimpleTunnel) ReleaseWriter ¶
func (t *SimpleTunnel) ReleaseWriter()
ReleaseWriter releases the writer lock
type Status ¶
type Status int
const ( // Undefined Add to instead null Undefined Status = -1 // Success indicates the operation succeeded. Success Status = iota // Unsupported indicates the requested operation is unsupported. Unsupported // ServerError indicates the operation could not be performed due to an internal failure. ServerError // ServerBusy indicates the operation could not be performed as the server is busy. ServerBusy // UpstreamTimeout indicates the operation could not be performed because the upstream server is not responding. UpstreamTimeout // UpstreamError indicates the operation was unsuccessful due to an error or otherwise unexpected // condition of the upstream server. UpstreamError // ResourceNotFound indicates the operation could not be performed as the requested resource does not exist. ResourceNotFound // ResourceConflict indicates the operation could not be performed as the requested resource is already in use. ResourceConflict // ResourceClosed indicates the operation could not be performed as the requested resource is now closed. ResourceClosed // UpstreamNotFound indicates the operation could not be performed because the upstream server does // not appear to exist. UpstreamNotFound // available to service the request. UpstreamUnavailable // SessionConflict indicates the session within the upstream server has ended because it conflicted // with another session. SessionConflict // SessionTimeout indicates the session within the upstream server has ended because it appeared to be inactive. SessionTimeout // SessionClosed indicates the session within the upstream server has been forcibly terminated. SessionClosed // ClientBadRequest indicates the operation could not be performed because bad parameters were given. ClientBadRequest ClientUnauthorized // ClientForbidden indicates the user is not allowed to do the operation. ClientForbidden // ClientTimeout indicates the client took too long to respond. ClientTimeout // ClientOverrun indicates the client sent too much data. ClientOverrun // ClientBadType indicates the client sent data of an unsupported or unexpected type. ClientBadType // ClientTooMany indivates the operation failed because the current client is already using too many resources. ClientTooMany )
func FromGuacamoleStatusCode ¶
FromGuacamoleStatusCode returns the Status corresponding to the given Guacamole protocol Status code.
func (Status) GetGuacamoleStatusCode ¶
GetGuacamoleStatusCode returns the corresponding Guacamole protocol Status code.
func (Status) GetHTTPStatusCode ¶
GetHTTPStatusCode returns the most applicable HTTP error code.
func (Status) GetWebSocketCode ¶
GetWebSocketCode returns the most applicable HTTP error code.
type Stream ¶
type Stream struct { // ConnectionID is the ID Guacamole gives and can be used to reconnect or share sessions ConnectionID string // contains filtered or unexported fields }
Stream wraps the connection to Guacamole providing timeouts and reading a single instruction at a time (since returning partial instructions would be an error)
func (*Stream) AssertOpcode ¶
func (s *Stream) AssertOpcode(opcode string) (instruction *Instruction, err error)
AssertOpcode checks the next opcode in the stream matches what is expected. Useful during handshake.
type Tunnel ¶
type Tunnel interface { // AcquireReader returns a reader to the tunnel if it isn't locked AcquireReader() InstructionReader // ReleaseReader releases the lock on the reader ReleaseReader() // HasQueuedReaderThreads returns true if there is a reader locked HasQueuedReaderThreads() bool // AcquireWriter returns a writer to the tunnel if it isn't locked AcquireWriter() io.Writer // ReleaseWriter releases the lock on the writer ReleaseWriter() // HasQueuedWriterThreads returns true if there is a writer locked HasQueuedWriterThreads() bool // GetUUID returns the uuid of the tunnel GetUUID() string // ConnectionId returns the guacd Connection ID of the tunnel ConnectionID() string // Close closes the tunnel Close() error }
Tunnel provides a unique identifier and synchronized access to the InstructionReader and Writer associated with a Stream.