Documentation ¶
Overview ¶
Copyright 2015 Gravitational, Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2015 Gravitational, Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2015 Gravitational, Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2015 Gravitational, Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
- Constants
- Variables
- func Consolef(w io.Writer, msg string, params ...interface{})
- func CreateTLSConfiguration(certFile, keyFile string) (*tls.Config, error)
- func CryptoRandomHex(len int) (string, error)
- func FatalError(err error)
- func InitCLIParser(appName, appHelp string) (app *kingpin.Application)
- func InitLoggerCLI()
- func InitLoggerDebug()
- func InitLoggerForTests()
- func IsHandshakeFailedError(err error) bool
- func IsLocalhost(host string) bool
- func IsLoopback(host string) bool
- func IsShellFailedError(err error) bool
- func ListenAndServeTLS(address string, handler http.Handler, certFile, keyFile string) error
- func MultiCloser(closers ...io.Closer) *multiCloser
- func NewChConn(conn ssh.Conn, ch ssh.Channel) *chConn
- func ObjectToStruct(in interface{}, out interface{}) error
- func PrintVersion()
- func RandomDuration(max time.Duration) time.Duration
- func ReadHostUUID(dataDir string) (string, error)
- func ReadOrMakeHostUUID(dataDir string) (string, error)
- func ReadPath(path string) ([]byte, error)
- func ReplaceLocalhost(addr, replaceWith string) string
- func SplitReaders(r1 io.Reader, r2 io.Reader) io.Reader
- func StartHTTPServer(addr NetAddr, h http.Handler) error
- func UserMessageFromError(err error) string
- func WriteHostUUID(dataDir string, id string) error
- type AddrStorage
- type Clock
- type CloseBroadcaster
- type FileAddrStorage
- type FileNode
- type HostKeyCallback
- type NetAddr
- func (a *NetAddr) FullAddress() string
- func (a *NetAddr) IsEmpty() bool
- func (a *NetAddr) IsLocal() bool
- func (a *NetAddr) IsLoopback() bool
- func (a *NetAddr) Network() string
- func (a *NetAddr) Set(s string) error
- func (a *NetAddr) String() string
- func (a *NetAddr) UnmarshalYAML(unmarshal func(interface{}) error) error
- type NetAddrList
- type NetAddrVal
- type PipeNetConn
- func (nc *PipeNetConn) Close() error
- func (nc *PipeNetConn) LocalAddr() net.Addr
- func (nc *PipeNetConn) Read(buf []byte) (n int, e error)
- func (nc *PipeNetConn) RemoteAddr() net.Addr
- func (nc *PipeNetConn) SetDeadline(t time.Time) error
- func (nc *PipeNetConn) SetReadDeadline(t time.Time) error
- func (nc *PipeNetConn) SetWriteDeadline(t time.Time) error
- func (nc *PipeNetConn) Write(buf []byte) (n int, e error)
- type PortList
- type TLSCredentials
- type TestClock
- type WallClock
Constants ¶
const ( // DefaultLRUCapacity is a capacity for LRU session cache DefaultLRUCapacity = 1024 // DefaultCertTTL sets the TTL of the self-signed certificate (1 year) DefaultCertTTL = (24 * time.Hour) * 365 )
const ( // CertTeleportUser specifies teleport user CertTeleportUser = "x-teleport-user" // CertExtensionRole specifies teleport role CertExtensionRole = "x-teleport-role" // CertExtensionAuthority specifies teleport authority's name // that signed this domain CertExtensionAuthority = "x-teleport-authority" // HostUUIDFile is the file name where the host UUID file is stored HostUUIDFile = "host_uuid" )
Variables ¶
var RealTime = &WallClock{}
Functions ¶
func Consolef ¶ added in v1.0.0
Consolef prints the same message to a 'ui console' (if defined) and also to the logger with INFO priority
func CreateTLSConfiguration ¶
CreateTLSConfiguration sets up default TLS configuration
func CryptoRandomHex ¶ added in v1.0.0
CryptoRandomHex returns hex encoded random string generated with crypto-strong pseudo random generator of the given bytes
func FatalError ¶ added in v1.0.0
func FatalError(err error)
FatalError is for CLI front-ends: it detects gravitational.Trace debugging information, sends it to the logger, strips it off and prints a clean message to stderr
func InitCLIParser ¶ added in v1.0.0
func InitCLIParser(appName, appHelp string) (app *kingpin.Application)
InitCLIParser configures kingpin command line args parser with some defaults common for all Teleport CLI tools
func InitLoggerCLI ¶ added in v1.0.0
func InitLoggerCLI()
InitLoggerCLI tools by default log into syslog, not stderr
func InitLoggerDebug ¶ added in v1.0.0
func InitLoggerDebug()
InitLoggerDebug configures the logger to dump everything to stderr
func InitLoggerForTests ¶ added in v1.0.0
func InitLoggerForTests()
InitLoggerForTests inits logger to discard ouput in tests unless TELEPORT_DEBUG is set to "true"
func IsHandshakeFailedError ¶ added in v1.0.0
IsHandshakeFailedError specifies whether this error indicates failed handshake
func IsLocalhost ¶ added in v1.0.0
IsLocalhost returns true if this is a local hostname or ip
func IsLoopback ¶ added in v1.0.0
IsLoopback returns 'true' if a given hostname resolves to local host's loopback interface
func IsShellFailedError ¶ added in v1.0.0
IsShellFailedError specifies whether this error indicates failed attempt to start shell
func ListenAndServeTLS ¶
ListenAndServeTLS sets up TLS listener for the http handler and blocks in listening and serving requests
func MultiCloser ¶
MultiCloser implements io.Close, it sequentially calls Close() on each object
func ObjectToStruct ¶
func ObjectToStruct(in interface{}, out interface{}) error
func RandomDuration ¶ added in v1.0.0
RandomDuration returns a duration in a range [0, max)
func ReadHostUUID ¶ added in v1.0.0
ReadHostUUID reads host UUID from the file in the data dir
func ReadOrMakeHostUUID ¶ added in v1.0.0
ReadOrMakeHostUUID looks for a hostid file in the data dir. If present, returns the UUID from it, otherwise generates one
func ReplaceLocalhost ¶ added in v1.0.0
ReplaceLocalhost checks if a given address is link-local (like 0.0.0.0 or 127.0.0.1) and replaces it with the IP taken from replaceWith, preserving the original port
Both addresses are in "host:port" format The function returns the original value if it encounters any problems with parsing
func UserMessageFromError ¶ added in v1.0.0
UserMessageFromError returns user friendly error message from error
func WriteHostUUID ¶ added in v1.0.0
WriteHostUUID writes host UUID into a file
Types ¶
type AddrStorage ¶ added in v1.0.0
type AddrStorage interface { // SetAddresses saves addresses SetAddresses([]NetAddr) error // GetAddresses GetAddresses() ([]NetAddr, error) }
AddrStorage is used to store information locally for every client that connects in the cluster, so it can always have up-to-date info about auth servers
type CloseBroadcaster ¶ added in v1.0.0
CloseBroadcaster is a helper struct that implements io.Closer and uses channel to broadcast it's closed state once called
func NewCloseBroadcaster ¶ added in v1.0.0
func NewCloseBroadcaster() *CloseBroadcaster
NewCloseBroadcaster returns new instance of close broadcaster
func (*CloseBroadcaster) Close ¶ added in v1.0.0
func (b *CloseBroadcaster) Close() error
Close closes channel (once) to start broadcasting it's closed state
type FileAddrStorage ¶ added in v1.0.0
type FileAddrStorage struct {
// contains filtered or unexported fields
}
FileAddrStorage is a file based address storage
func NewFileAddrStorage ¶ added in v1.0.0
func NewFileAddrStorage(filePath string) *FileAddrStorage
NewFileAddrStorage returns new instance of file-based address storage
func (*FileAddrStorage) GetAddresses ¶ added in v1.0.0
func (fs *FileAddrStorage) GetAddresses() ([]NetAddr, error)
GetAddresses returns saved address list
func (*FileAddrStorage) SetAddresses ¶ added in v1.0.0
func (fs *FileAddrStorage) SetAddresses(addrs []NetAddr) error
SetAddresses updates storage with new address list
type HostKeyCallback ¶ added in v1.0.0
type NetAddr ¶
type NetAddr struct { // Addr is the host:port address, like "localhost:22" Addr string `json:"addr"` // AddrNetwork is the type of a network socket, like "tcp" or "unix" AddrNetwork string `json:"network,omitempty"` // Path is a socket file path, like '/var/path/to/socket' in "unix:///var/path/to/socket" Path string `json:"path,omitempty"` }
NetAddr is network address that includes network, optional path and host port
func ParseAddr ¶
ParseAddr takes strings like "tcp://host:port/path" and returns *NetAddr or an error
func ParseHostPortAddr ¶ added in v1.0.0
ParseHostPortAddr takes strings like "host:port" and returns *NetAddr or an error
If defaultPort == -1 it expects 'hostport' string to have it
func (*NetAddr) FullAddress ¶
FullAddress returns full address including network and address (tcp://0.0.0.0:1243)
func (*NetAddr) IsLoopback ¶ added in v1.0.0
IsLoopback returns true if this is a loopback address
func (*NetAddr) UnmarshalYAML ¶
type NetAddrList ¶
type NetAddrList []NetAddr
NetAddrList is a list of NetAddrs that supports helper methods for parsing from CLI tools
func (*NetAddrList) Addresses ¶ added in v1.0.0
func (nl *NetAddrList) Addresses() []string
Addresses returns a slice of strings converted from the addresses
func (*NetAddrList) String ¶
func (nl *NetAddrList) String() string
String returns debug-friendly representation of the tool
type NetAddrVal ¶
type NetAddrVal NetAddr
NetAddrVal can be used with flag package
func NewNetAddrVal ¶
func NewNetAddrVal(defaultVal NetAddr, val *NetAddr) *NetAddrVal
func (*NetAddrVal) Get ¶
func (a *NetAddrVal) Get() interface{}
func (*NetAddrVal) Set ¶
func (a *NetAddrVal) Set(s string) error
func (*NetAddrVal) String ¶
func (a *NetAddrVal) String() string
type PipeNetConn ¶
type PipeNetConn struct {
// contains filtered or unexported fields
}
PipeNetConn implemetns net.Conn from io.Reader,io.Writer and io.Closer
func NewPipeNetConn ¶
func (*PipeNetConn) Close ¶
func (nc *PipeNetConn) Close() error
func (*PipeNetConn) LocalAddr ¶
func (nc *PipeNetConn) LocalAddr() net.Addr
func (*PipeNetConn) RemoteAddr ¶
func (nc *PipeNetConn) RemoteAddr() net.Addr
func (*PipeNetConn) SetDeadline ¶
func (nc *PipeNetConn) SetDeadline(t time.Time) error
func (*PipeNetConn) SetReadDeadline ¶
func (nc *PipeNetConn) SetReadDeadline(t time.Time) error
func (*PipeNetConn) SetWriteDeadline ¶
func (nc *PipeNetConn) SetWriteDeadline(t time.Time) error
type PortList ¶ added in v1.0.0
type PortList []string
PortList is a list of TCP port
func GetFreeTCPPorts ¶ added in v1.0.0
GetFreeTCPPorts returns a lit of available ports on localhost used for testing
type TLSCredentials ¶ added in v1.0.0
type TLSCredentials struct { // PublicKey in PEM format PublicKey []byte // PrivateKey in PEM format PrivateKey []byte Cert []byte }
TLSCredentials keeps the typical 3 components of a proper HTTPS configuration
func GenerateSelfSignedCert ¶ added in v1.0.0
func GenerateSelfSignedCert(hostNames []string) (*TLSCredentials, error)
GenerateSelfSignedCert generates a self signed certificate that is valid for given domain names and ips, returns PEM-encoded bytes with key and cert