gottyclient

package module
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2018 License: MIT Imports: 20 Imported by: 0

README ΒΆ

gotty-client

πŸ”§ Terminal client for GoTTY.

Build Status GoDoc FOSSA Status

                                                             β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                                                     β”Œβ”€β”€β”€β”€β”€β”€β–Άβ”‚    /bin/bash    β”‚
                                                     β”‚       β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”               β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                β”‚              β”‚               β”‚  Gotty   β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”   β”Œβ”€β”€β–Άβ”‚   Browser    │───────┐       β”‚          β”‚
β”‚       β”‚   β”‚   β”‚              β”‚       β”‚       β”‚          β”‚
β”‚       β”‚   β”‚   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜       β”‚       β”‚          β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Bob  │────                      websockets─▢│          │─▢│ emacs /var/www  β”‚
β”‚       β”‚   β”‚   ╔═ ══ ══ ══ ══ β•—       β”‚       β”‚          β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
β”‚       β”‚   β”‚   β•‘              β•‘       β”‚       β”‚          β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”˜   └──▢║ gotty-client  β”€β”€β”€β”€β”€β”€β”€β”˜       β”‚          β”‚
                               β•‘               β”‚          β”‚
                β•šβ• ══ ══ ══ ══ ╝               β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                                     β”‚       β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                                                     └──────▢│   tmux attach   β”‚
                                                             β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Example

Server side (GoTTY)

$ gotty -p 9191 sh -c 'while true; do date; sleep 1; done'
2015/08/24 18:54:31 Server is starting with command: sh -c while true; do date; sleep 1; done
2015/08/24 18:54:31 URL: http://[::1]:9191/
2015/08/24 18:54:34 GET /ws
2015/08/24 18:54:34 New client connected: 127.0.0.1:61811
2015/08/24 18:54:34 Command is running for client 127.0.0.1:61811 with PID 64834
2015/08/24 18:54:39 Command exited for: 127.0.0.1:61811
2015/08/24 18:54:39 Connection closed: 127.0.0.1:61811
...

Client side

$ gotty-client http://localhost:9191/
INFO[0000] New title: GoTTY - sh -c while true; do date; sleep 1; done (jean-michel-van-damme.local)
WARN[0000] Unhandled protocol message: json pref: 2{}
Mon Aug 24 18:54:34 CEST 2015
Mon Aug 24 18:54:35 CEST 2015
Mon Aug 24 18:54:36 CEST 2015
Mon Aug 24 18:54:37 CEST 2015
Mon Aug 24 18:54:38 CEST 2015
^C

Usage

$ gotty-client -h
NAME:
   gotty-client - GoTTY client for your terminal

USAGE:
   gotty-client [global options] command [command options] GOTTY_URL

AUTHOR:
   Manfred Touron <https://github.com/moul/gotty-client>

COMMANDS:
     help, h  Shows a list of commands or help for one command

GLOBAL OPTIONS:
   --debug, -D                  Enable debug mode [$GOTTY_CLIENT_DEBUG]
   --skip-tls-verify            Skip TLS verify [$SKIP_TLS_VERIFY]
   --use-proxy-from-env         Use Proxy from environment [$USE_PROXY_FROM_ENV]
   --detach-keys value          Key sequence for detaching gotty-client (default: "ctrl-p,ctrl-q")
   --v2                         For Gotty 2.0 [$GOTTY_CLIENT_GOTTY2]
   --ws-origin value, -w value  WebSocket Origin URL [$GOTTY_CLIENT_WS_ORIGIN]
   --help, -h                   show help
   --version, -v                print the version

Install

Install latest version using Golang (recommended)

$ go get github.com/moul/gotty-client/cmd/gotty-client

Install latest version using Homebrew (Mac OS X)

$ brew install https://raw.githubusercontent.com/moul/gotty-client/master/contrib/homebrew/gotty-client.rb --HEAD

or the latest released version

$ brew install https://raw.githubusercontent.com/moul/gotty-client/master/contrib/homebrew/gotty-client.rb

Changelog

v1.7.0 (2018-04-11)

full commits list

v1.6.1 (2017-01-19)

full commits list

v1.6.0 (2016-05-23)
  • Support of --use-proxy-from-env (Add Proxy support) (#36) (@byung2)
  • Add debug mode (#18)
  • Fix argument passing (#16)
  • Remove warnings + golang fixes and refactoring (@QuentinPerez)

full commits list

v1.5.0 (2016-02-18)
  • Add autocomplete support (#19)
  • Switch from Party to Godep
  • Fix terminal data being interpreted as format string (#34) (@mickael9)

full commits list

v1.4.0 (2015-12-09)
  • Remove solaris,plan9,nacl for .goxc.json
  • Add an error if the go version is lower than 1.5
  • Flexible parsing of the input URL
  • Add tests
  • Support of --skip-tls-verify

full commits list

v1.3.0 (2015-10-27)
  • Fix connected state when using Connect() + Loop() methods
  • Add ExitLoop which allow to exit from Loop function

full commits list

v1.2.0 (2015-10-23)
  • Removed an annoying warning when exiting connection (#22) (@QuentinPerez)
  • Add the ability to configure alternative stdout (#21) (@QuentinPerez)
  • Refactored the goroutine system with select, improve speed and stability (@QuentinPerez)
  • Add debug mode (--debug/-D) (#18)
  • Improve error message when connecting by checking HTTP status code
  • Fix arguments passing (#16)
  • Dropped support for golang<1.5
  • Small fixes

full commits list

v1.1.0 (2015-10-10)
  • Handling arguments + using mutexes (thanks to @QuentinPerez)
  • Add logo (#9)
  • Using codegansta/cli for CLI parsing (#3)
  • Fix panic when running on older GoTTY server (#13)
  • Add 'homebrew support' (#1)
  • Add Changelog (#5)
  • Add GOXC configuration to build binaries for multiple architectures (#2)

full commits list

v1.0.1 (2015-09-27)
  • Using party to manage dependencies

full commits list

v1.0.0 (2015-09-27)

Compatible with GoTTY version: v0.0.10

Features
  • Support basic-auth
  • Support terminal-(re)size
  • Support write
  • Support title
  • Support custom URI

full commits list

License

MIT

FOSSA Status

Documentation ΒΆ

Index ΒΆ

Constants ΒΆ

View Source
const (
	OutputV1         = '0'
	PongV1           = '1'
	SetWindowTitleV1 = '2'
	SetPreferencesV1 = '3'
	SetReconnectV1   = '4'

	InputV1          = '0'
	PingV1           = '1'
	ResizeTerminalV1 = '2'
)

message types for gotty

View Source
const (
	// Unknown message type, maybe set by a bug
	UnknownOutput = '0'
	// Normal output to the terminal
	Output = '1'
	// Pong to the browser
	Pong = '2'
	// Set window title of the terminal
	SetWindowTitle = '3'
	// Set terminal preference
	SetPreferences = '4'
	// Make terminal to reconnect
	SetReconnect = '5'

	// Unknown message type, maybe sent by a bug
	UnknownInput = '0'
	// User input typically from a keyboard
	Input = '1'
	// Ping to the server
	Ping = '2'
	// Notify that the browser size has been changed
	ResizeTerminal = '3'
)

message types for gotty v2.0

Variables ΒΆ

This section is empty.

Functions ΒΆ

func GetAuthTokenURL ΒΆ

func GetAuthTokenURL(httpURL string) (*url.URL, *http.Header, error)

GetAuthTokenURL transforms a GoTTY http URL to its AuthToken file URL

func GetURLQuery ΒΆ added in v1.1.0

func GetURLQuery(rawurl string) (url.Values, error)

GetURLQuery returns url.query

func GetWebsocketURL ΒΆ

func GetWebsocketURL(httpURL string) (*url.URL, *http.Header, error)

GetWebsocketURL transforms a GoTTY http URL to its WebSocket URL

func NewEscapeProxy ΒΆ added in v1.7.0

func NewEscapeProxy(r io.Reader, escapeKeys []byte) io.Reader

NewEscapeProxy returns a new TTY proxy reader which wraps the given reader and detects when the specified escape keys are read, in which case the Read method will return an error of type EscapeError.

func ParseURL ΒΆ added in v1.4.0

func ParseURL(input string) (string, error)

ParseURL parses an URL which may be incomplete and tries to standardize it

Types ΒΆ

type Client ΒΆ

type Client struct {
	Dialer     *websocket.Dialer
	Conn       *websocket.Conn
	URL        string
	WriteMutex *sync.Mutex
	Output     io.Writer

	SkipTLSVerify   bool
	UseProxyFromEnv bool
	Connected       bool
	EscapeKeys      []byte
	V2              bool

	WSOrigin string
	// contains filtered or unexported fields
}

func NewClient ΒΆ

func NewClient(inputURL string) (*Client, error)

NewClient returns a GoTTY client object

func (*Client) Close ΒΆ

func (c *Client) Close()

Close will nicely close the dialer

func (*Client) Connect ΒΆ

func (c *Client) Connect() error

Connect tries to dial a websocket server

func (*Client) ExitLoop ΒΆ added in v1.3.0

func (c *Client) ExitLoop()

ExitLoop will kill all goroutines launched by c.Loop() ExitLoop() -> wait Loop() -> Close()

func (*Client) GetAuthToken ΒΆ

func (c *Client) GetAuthToken() (string, error)

GetAuthToken retrieves an Auth Token from dynamic auth_token.js file

func (*Client) Loop ΒΆ

func (c *Client) Loop() error

Loop will look indefinitely for new messages

func (*Client) SetOutput ΒΆ added in v1.2.0

func (c *Client) SetOutput(w io.Writer)

SetOutput changes the output stream

type EscapeError ΒΆ added in v1.7.0

type EscapeError struct{}

EscapeError is special error which returned by a TTY proxy reader's Read() method in case its detach escape sequence is read.

func (EscapeError) Error ΒΆ added in v1.7.0

func (EscapeError) Error() string

Directories ΒΆ

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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