lib

package
v0.0.0-...-be7c396 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2021 License: Apache-2.0 Imports: 25 Imported by: 2

Documentation

Index

Constants

View Source
const (
	TrimChars   = "\"'"
	CommentChar = ";"
)
View Source
const (
	ClientVersionHeader = "X-Client-Version"
)

Variables

This section is empty.

Functions

func GetFreePorts

func GetFreePorts(n int) (ports []int, err error)

findFreePortRange returns a slice of n available IP ports

func ParseForwardAddr

func ParseForwardAddr(spec string) (p *client.ForwardedPort, err error)

ParseForwardAddr takes a host:port spec and returns a pre-configured "ForwardedPort" structure. It understands the following spec:

"5000" -> localhost:5000 "host:port" -> host:port "http://host" -> host:80

func ReplaceHost

func ReplaceHost(hostPort, newHost string) string

replaceHost takes a host:port string (with optional port), replaces host with 'newHost' and returns the result

Types

type GithubError

type GithubError struct {
	Message string `json:"message"`
}

func (GithubError) Error

func (this GithubError) Error() string

type GithubKey

type GithubKey struct {
	ID    int    `json:"id"`
	Value string `json:"key"`
}

type Identity

type Identity struct {
	Anonymous bool `json:"anonymous"`
	// username here indicates the local OS user name
	Username string `json:"username"`
	// an identity may have multiple SSH keys, for example Github allows
	// you to have several. also, a user can specify multiple SSH identities
	// for a single session, they all go here:
	Logins []sshLogin `json:"logins"`
}

Identity defines a user/account of Teleconsole. There are two types of identities:

  1. Anonymous identity maps to a local OS user and uses one-time auto-generated SSH pair of keys (priv/pub). By default an anonymous identity is submitted to the proxy server along with a single-use session.

    A joining party receives pub/priv keypair of the anonymous identity and logs in using it.

  1. A named identity uses a user-supplied SSH key, either via github handle or as a file (like ~/.ssh/id_rsa). Named identities private key never leaves the machine, but the joining party is supposed to have a private key on their machine to be able to join.

func MakeIdentity

func MakeIdentity(idPath string) (*Identity, error)

MakeIdentity creates a new identity from an identity source. If the source is an empty string, an anonymous identity is created.

Otherwise a regular (named) identity is created. A source can be a comma-separated list of values, where each value can be either a file, or a github handle

Examples:

MakeIdentity("filename")
MakeIdentity('"/home/my name/.ssh/id_rsa",githubuser')

func MakeIdentityFromFile

func MakeIdentityFromFile(idFile string) (*Identity, error)

func (*Identity) AnnounceUsers

func (this *Identity) AnnounceUsers() UserMap

AnnounceUsers returns a list of Teleport users to be sent along with a new Teleconsole session. Anonymous identities send private keys too, while regular identities do not send their private keys.

func (*Identity) LoginUsers

func (this *Identity) LoginUsers() UserMap

LoginUsers returns Teleport users suitable for logging into a locally running Teleport instance. Public and private keys are returned.

func (*Identity) PrivateKeyFor

func (this *Identity) PrivateKeyFor(publicKey []byte) []byte

func (*Identity) ToJSON

func (this *Identity) ToJSON() string

type IniConfig

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

IniConfig type stores all values found in a ini-file

func ParseIniFile

func ParseIniFile(fileName string) (conf IniConfig, err error)

ParseIniFile reads the supplied ini-file and returns a IniConf structure Later you can use IniConf.Get("section", "name") to get config values

func (*IniConfig) Get

func (conf *IniConfig) Get(section string, name string) string

func (*IniConfig) GetOrDefault

func (conf *IniConfig) GetOrDefault(section, name, defaultValue string) string

func (*IniConfig) GetSection

func (conf *IniConfig) GetSection(section string) map[string]string

func (*IniConfig) GetSectionNames

func (conf *IniConfig) GetSectionNames() (names sort.StringSlice)

type Party

type Party struct {
	// FullName is not supported for now...
	FullName   string    `json"full_name"`
	RemoteAddr string    `json:"remote_addr"`
	LastActive time.Time `json:"last_active"`
}

type ServerVersion

type ServerVersion struct {
	// server's version & build data
	ServerVersion string `json:"server_ver"`

	// clients must show this warning message to users if it's not empty
	WarningMsg string `json:"warn_msg"`
}

ServerVersion is a JSON response returned by the server at the behinning of API conversation

type Session

type Session struct {
	// web session ID (not the same as teleport session ID)
	ID string `json:"id"`

	// teleport session ID
	TSID string `json:"teleport_session_id"`

	// Secretes and Login are needed to join this session
	Secrets integration.InstanceSecrets `json:"secrets"`
	Login   string                      `json:"login"`

	// ProxyHostPort is the host:port of the SSH proxy dynamically
	// created for this session
	ProxyHostPort string `json:"proxy_addr"`

	// NodeHostPort is the host:port of the client machine which
	// initiated the Teleconsole
	NodeHostPort string `json:"node_addr"`

	// Forwarded ports: these are set via -f flag on the client
	// when it creates a new session
	ForwardedPort *client.ForwardedPort `json:"forwarded_port"`
}

Session travels in JSON format between teleconsole client/server

func (*Session) GetNodeHostPort

func (s *Session) GetNodeHostPort() (host string, port int, err error)

func (*Session) ToJSON

func (s *Session) ToJSON() string

ToJSON returns a nicely formatted JSON representation of the session (use it only for odebugging since there's no error handling)

type SessionStats

type SessionStats struct {
	// Parties lists all people who've joined this session
	Parties []Party `json:"connected_parties"`

	// Terminal size
	TermWidth  int `json:"term_width"`
	TermHeight int `json:"term_height"`
}

type UserMap

type UserMap map[string]*integration.User

Jump to

Keyboard shortcuts

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