id
int32
0
167k
repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
listlengths
21
1.41k
docstring
stringlengths
6
2.61k
docstring_tokens
listlengths
3
215
sha
stringlengths
40
40
url
stringlengths
85
252
23,700
gravitational/teleport
lib/backend/legacy/boltbk/boltbk.go
Exists
func Exists(path string) (bool, error) { path, err := filepath.Abs(filepath.Join(path, keysBoltFile)) if err != nil { return false, trace.Wrap(err) } f, err := os.Open(path) err = trace.ConvertSystemError(err) if err != nil { if trace.IsNotFound(err) { return false, nil } return false, trace.Wrap(err) ...
go
func Exists(path string) (bool, error) { path, err := filepath.Abs(filepath.Join(path, keysBoltFile)) if err != nil { return false, trace.Wrap(err) } f, err := os.Open(path) err = trace.ConvertSystemError(err) if err != nil { if trace.IsNotFound(err) { return false, nil } return false, trace.Wrap(err) ...
[ "func", "Exists", "(", "path", "string", ")", "(", "bool", ",", "error", ")", "{", "path", ",", "err", ":=", "filepath", ".", "Abs", "(", "filepath", ".", "Join", "(", "path", ",", "keysBoltFile", ")", ")", "\n", "if", "err", "!=", "nil", "{", "r...
// Exists returns true if backend has been used before
[ "Exists", "returns", "true", "if", "backend", "has", "been", "used", "before" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/backend/legacy/boltbk/boltbk.go#L66-L81
23,701
gravitational/teleport
lib/backend/legacy/boltbk/boltbk.go
New
func New(params legacy.Params) (*BoltBackend, error) { // look at 'path' parameter, if it's missing use 'data_dir' (default): path := params.GetString("path") if len(path) == 0 { path = params.GetString(teleport.DataDirParameterName) } // still nothing? return an error: if path == "" { return nil, trace.BadPa...
go
func New(params legacy.Params) (*BoltBackend, error) { // look at 'path' parameter, if it's missing use 'data_dir' (default): path := params.GetString("path") if len(path) == 0 { path = params.GetString(teleport.DataDirParameterName) } // still nothing? return an error: if path == "" { return nil, trace.BadPa...
[ "func", "New", "(", "params", "legacy", ".", "Params", ")", "(", "*", "BoltBackend", ",", "error", ")", "{", "// look at 'path' parameter, if it's missing use 'data_dir' (default):", "path", ":=", "params", ".", "GetString", "(", "\"", "\"", ")", "\n", "if", "le...
// New initializes and returns a fully created BoltDB backend. It's // a properly implemented Backend.NewFunc, part of a backend API
[ "New", "initializes", "and", "returns", "a", "fully", "created", "BoltDB", "backend", ".", "It", "s", "a", "properly", "implemented", "Backend", ".", "NewFunc", "part", "of", "a", "backend", "API" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/backend/legacy/boltbk/boltbk.go#L85-L117
23,702
gravitational/teleport
lib/backend/legacy/boltbk/boltbk.go
GetItems
func (b *BoltBackend) GetItems(path []string, opts ...legacy.OpOption) ([]legacy.Item, error) { cfg, err := legacy.CollectOptions(opts) if err != nil { return nil, trace.Wrap(err) } if cfg.Recursive { return b.getItemsRecursive(path) } keys, err := b.GetKeys(path) if err != nil { return nil, trace.Wrap(er...
go
func (b *BoltBackend) GetItems(path []string, opts ...legacy.OpOption) ([]legacy.Item, error) { cfg, err := legacy.CollectOptions(opts) if err != nil { return nil, trace.Wrap(err) } if cfg.Recursive { return b.getItemsRecursive(path) } keys, err := b.GetKeys(path) if err != nil { return nil, trace.Wrap(er...
[ "func", "(", "b", "*", "BoltBackend", ")", "GetItems", "(", "path", "[", "]", "string", ",", "opts", "...", "legacy", ".", "OpOption", ")", "(", "[", "]", "legacy", ".", "Item", ",", "error", ")", "{", "cfg", ",", "err", ":=", "legacy", ".", "Col...
// GetItems fetches keys and values and returns them to the caller.
[ "GetItems", "fetches", "keys", "and", "values", "and", "returns", "them", "to", "the", "caller", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/backend/legacy/boltbk/boltbk.go#L278-L309
23,703
gravitational/teleport
lib/backend/legacy/boltbk/boltbk.go
CompareAndSwapVal
func (b *BoltBackend) CompareAndSwapVal(bucket []string, key string, newData []byte, prevData []byte, ttl time.Duration) error { if len(prevData) == 0 { return trace.BadParameter("missing prevData parameter, to atomically create item, use CreateVal method") } v := &kv{ Created: b.clock.Now().UTC(), Value: ne...
go
func (b *BoltBackend) CompareAndSwapVal(bucket []string, key string, newData []byte, prevData []byte, ttl time.Duration) error { if len(prevData) == 0 { return trace.BadParameter("missing prevData parameter, to atomically create item, use CreateVal method") } v := &kv{ Created: b.clock.Now().UTC(), Value: ne...
[ "func", "(", "b", "*", "BoltBackend", ")", "CompareAndSwapVal", "(", "bucket", "[", "]", "string", ",", "key", "string", ",", "newData", "[", "]", "byte", ",", "prevData", "[", "]", "byte", ",", "ttl", "time", ".", "Duration", ")", "error", "{", "if"...
// CompareAndSwapVal compares and swap values in atomic operation, // succeeds if prevData matches the value stored in the databases, // requires prevData as a non-empty value. Returns trace.CompareFailed // in case if value did not match
[ "CompareAndSwapVal", "compares", "and", "swap", "values", "in", "atomic", "operation", "succeeds", "if", "prevData", "matches", "the", "value", "stored", "in", "the", "databases", "requires", "prevData", "as", "a", "non", "-", "empty", "value", ".", "Returns", ...
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/backend/legacy/boltbk/boltbk.go#L357-L396
23,704
gravitational/teleport
lib/services/invite.go
NewInviteToken
func NewInviteToken(token, signupURL string, expires time.Time) *InviteTokenV3 { tok := InviteTokenV3{ Kind: KindInviteToken, Version: V3, Metadata: Metadata{ Name: token, }, Spec: InviteTokenSpecV3{ URL: signupURL, }, } if !expires.IsZero() { tok.Metadata.SetExpiry(expires) } return &tok }
go
func NewInviteToken(token, signupURL string, expires time.Time) *InviteTokenV3 { tok := InviteTokenV3{ Kind: KindInviteToken, Version: V3, Metadata: Metadata{ Name: token, }, Spec: InviteTokenSpecV3{ URL: signupURL, }, } if !expires.IsZero() { tok.Metadata.SetExpiry(expires) } return &tok }
[ "func", "NewInviteToken", "(", "token", ",", "signupURL", "string", ",", "expires", "time", ".", "Time", ")", "*", "InviteTokenV3", "{", "tok", ":=", "InviteTokenV3", "{", "Kind", ":", "KindInviteToken", ",", "Version", ":", "V3", ",", "Metadata", ":", "Me...
// NewInviteToken returns a new instance of the invite token
[ "NewInviteToken", "returns", "a", "new", "instance", "of", "the", "invite", "token" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/invite.go#L48-L63
23,705
gravitational/teleport
lib/sshutils/scp/http.go
CreateHTTPUpload
func CreateHTTPUpload(req HTTPTransferRequest) (Command, error) { if req.HTTPRequest == nil { return nil, trace.BadParameter("missing parameter HTTPRequest") } if req.FileName == "" { return nil, trace.BadParameter("missing file name") } if req.RemoteLocation == "" { return nil, trace.BadParameter("missing...
go
func CreateHTTPUpload(req HTTPTransferRequest) (Command, error) { if req.HTTPRequest == nil { return nil, trace.BadParameter("missing parameter HTTPRequest") } if req.FileName == "" { return nil, trace.BadParameter("missing file name") } if req.RemoteLocation == "" { return nil, trace.BadParameter("missing...
[ "func", "CreateHTTPUpload", "(", "req", "HTTPTransferRequest", ")", "(", "Command", ",", "error", ")", "{", "if", "req", ".", "HTTPRequest", "==", "nil", "{", "return", "nil", ",", "trace", ".", "BadParameter", "(", "\"", "\"", ")", "\n", "}", "\n\n", ...
// CreateHTTPUpload creates HTTP download command
[ "CreateHTTPUpload", "creates", "HTTP", "download", "command" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/sshutils/scp/http.go#L69-L114
23,706
gravitational/teleport
lib/sshutils/scp/http.go
CreateHTTPDownload
func CreateHTTPDownload(req HTTPTransferRequest) (Command, error) { _, filename, err := req.parseRemoteLocation() if err != nil { return nil, trace.Wrap(err) } flags := Flags{ Target: []string{filename}, } cfg := Config{ Flags: flags, User: req.User, ProgressWriter: req.Progress, ...
go
func CreateHTTPDownload(req HTTPTransferRequest) (Command, error) { _, filename, err := req.parseRemoteLocation() if err != nil { return nil, trace.Wrap(err) } flags := Flags{ Target: []string{filename}, } cfg := Config{ Flags: flags, User: req.User, ProgressWriter: req.Progress, ...
[ "func", "CreateHTTPDownload", "(", "req", "HTTPTransferRequest", ")", "(", "Command", ",", "error", ")", "{", "_", ",", "filename", ",", "err", ":=", "req", ".", "parseRemoteLocation", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", ...
// CreateHTTPDownload creates HTTP upload command
[ "CreateHTTPDownload", "creates", "HTTP", "upload", "command" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/sshutils/scp/http.go#L117-L143
23,707
gravitational/teleport
lib/sshutils/scp/http.go
MkDir
func (l *httpFileSystem) MkDir(path string, mode int) error { return trace.BadParameter("directories are not supported in http file transfer") }
go
func (l *httpFileSystem) MkDir(path string, mode int) error { return trace.BadParameter("directories are not supported in http file transfer") }
[ "func", "(", "l", "*", "httpFileSystem", ")", "MkDir", "(", "path", "string", ",", "mode", "int", ")", "error", "{", "return", "trace", ".", "BadParameter", "(", "\"", "\"", ")", "\n", "}" ]
// MkDir creates a directory. This method is not implemented as creating directories // is not supported during HTTP downloads.
[ "MkDir", "creates", "a", "directory", ".", "This", "method", "is", "not", "implemented", "as", "creating", "directories", "is", "not", "supported", "during", "HTTP", "downloads", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/sshutils/scp/http.go#L161-L163
23,708
gravitational/teleport
lib/sshutils/scp/http.go
OpenFile
func (l *httpFileSystem) OpenFile(filePath string) (io.ReadCloser, error) { if l.reader == nil { return nil, trace.BadParameter("missing reader") } return l.reader, nil }
go
func (l *httpFileSystem) OpenFile(filePath string) (io.ReadCloser, error) { if l.reader == nil { return nil, trace.BadParameter("missing reader") } return l.reader, nil }
[ "func", "(", "l", "*", "httpFileSystem", ")", "OpenFile", "(", "filePath", "string", ")", "(", "io", ".", "ReadCloser", ",", "error", ")", "{", "if", "l", ".", "reader", "==", "nil", "{", "return", "nil", ",", "trace", ".", "BadParameter", "(", "\"",...
// OpenFile returns file reader
[ "OpenFile", "returns", "file", "reader" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/sshutils/scp/http.go#L172-L178
23,709
gravitational/teleport
lib/sshutils/scp/http.go
CreateFile
func (l *httpFileSystem) CreateFile(filePath string, length uint64) (io.WriteCloser, error) { _, filename := filepath.Split(filePath) contentLength := strconv.FormatUint(length, 10) header := l.writer.Header() httplib.SetNoCacheHeaders(header) httplib.SetNoSniff(header) header.Set("Content-Length", contentLength...
go
func (l *httpFileSystem) CreateFile(filePath string, length uint64) (io.WriteCloser, error) { _, filename := filepath.Split(filePath) contentLength := strconv.FormatUint(length, 10) header := l.writer.Header() httplib.SetNoCacheHeaders(header) httplib.SetNoSniff(header) header.Set("Content-Length", contentLength...
[ "func", "(", "l", "*", "httpFileSystem", ")", "CreateFile", "(", "filePath", "string", ",", "length", "uint64", ")", "(", "io", ".", "WriteCloser", ",", "error", ")", "{", "_", ",", "filename", ":=", "filepath", ".", "Split", "(", "filePath", ")", "\n"...
// CreateFile sets proper HTTP headers and returns HTTP writer to stream incoming // file content
[ "CreateFile", "sets", "proper", "HTTP", "headers", "and", "returns", "HTTP", "writer", "to", "stream", "incoming", "file", "content" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/sshutils/scp/http.go#L182-L195
23,710
gravitational/teleport
lib/sshutils/scp/http.go
GetFileInfo
func (l *httpFileSystem) GetFileInfo(filePath string) (FileInfo, error) { return &httpFileInfo{ name: l.fileName, path: l.fileName, size: l.fileSize, }, nil }
go
func (l *httpFileSystem) GetFileInfo(filePath string) (FileInfo, error) { return &httpFileInfo{ name: l.fileName, path: l.fileName, size: l.fileSize, }, nil }
[ "func", "(", "l", "*", "httpFileSystem", ")", "GetFileInfo", "(", "filePath", "string", ")", "(", "FileInfo", ",", "error", ")", "{", "return", "&", "httpFileInfo", "{", "name", ":", "l", ".", "fileName", ",", "path", ":", "l", ".", "fileName", ",", ...
// GetFileInfo returns file information
[ "GetFileInfo", "returns", "file", "information" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/sshutils/scp/http.go#L198-L204
23,711
gravitational/teleport
lib/utils/writer.go
Write
func (w *BroadcastWriter) Write(p []byte) (n int, err error) { for _, writer := range w.writers { n, err = writer.Write(p) if err != nil { return } if n != len(p) { err = io.ErrShortWrite return } } return len(p), nil }
go
func (w *BroadcastWriter) Write(p []byte) (n int, err error) { for _, writer := range w.writers { n, err = writer.Write(p) if err != nil { return } if n != len(p) { err = io.ErrShortWrite return } } return len(p), nil }
[ "func", "(", "w", "*", "BroadcastWriter", ")", "Write", "(", "p", "[", "]", "byte", ")", "(", "n", "int", ",", "err", "error", ")", "{", "for", "_", ",", "writer", ":=", "range", "w", ".", "writers", "{", "n", ",", "err", "=", "writer", ".", ...
// Write multiplexes the input to multiple sub-writers. If any of the write // fails, it won't attempt to write to other writers
[ "Write", "multiplexes", "the", "input", "to", "multiple", "sub", "-", "writers", ".", "If", "any", "of", "the", "write", "fails", "it", "won", "t", "attempt", "to", "write", "to", "other", "writers" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/writer.go#L37-L49
23,712
gravitational/teleport
lib/backend/memory/memory.go
New
func New(cfg Config) (*Memory, error) { if err := cfg.CheckAndSetDefaults(); err != nil { return nil, trace.Wrap(err) } ctx, cancel := context.WithCancel(cfg.Context) buf, err := backend.NewCircularBuffer(ctx, cfg.BufferSize) if err != nil { cancel() return nil, trace.Wrap(err) } m := &Memory{ Mutex: &sy...
go
func New(cfg Config) (*Memory, error) { if err := cfg.CheckAndSetDefaults(); err != nil { return nil, trace.Wrap(err) } ctx, cancel := context.WithCancel(cfg.Context) buf, err := backend.NewCircularBuffer(ctx, cfg.BufferSize) if err != nil { cancel() return nil, trace.Wrap(err) } m := &Memory{ Mutex: &sy...
[ "func", "New", "(", "cfg", "Config", ")", "(", "*", "Memory", ",", "error", ")", "{", "if", "err", ":=", "cfg", ".", "CheckAndSetDefaults", "(", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "trace", ".", "Wrap", "(", "err", ")", "\n",...
// New creates a new memory backend
[ "New", "creates", "a", "new", "memory", "backend" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/backend/memory/memory.go#L83-L106
23,713
gravitational/teleport
lib/backend/memory/memory.go
Close
func (m *Memory) Close() error { m.cancel() m.Lock() defer m.Unlock() m.buf.Close() return nil }
go
func (m *Memory) Close() error { m.cancel() m.Lock() defer m.Unlock() m.buf.Close() return nil }
[ "func", "(", "m", "*", "Memory", ")", "Close", "(", ")", "error", "{", "m", ".", "cancel", "(", ")", "\n", "m", ".", "Lock", "(", ")", "\n", "defer", "m", ".", "Unlock", "(", ")", "\n", "m", ".", "buf", ".", "Close", "(", ")", "\n", "return...
// Close closes memory backend
[ "Close", "closes", "memory", "backend" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/backend/memory/memory.go#L128-L134
23,714
gravitational/teleport
lib/backend/memory/memory.go
Update
func (m *Memory) Update(ctx context.Context, i backend.Item) (*backend.Lease, error) { if len(i.Key) == 0 { return nil, trace.BadParameter("missing parameter key") } m.Lock() defer m.Unlock() m.removeExpired() if m.tree.Get(&btreeItem{Item: i}) == nil { return nil, trace.NotFound("key %q is not found", string...
go
func (m *Memory) Update(ctx context.Context, i backend.Item) (*backend.Lease, error) { if len(i.Key) == 0 { return nil, trace.BadParameter("missing parameter key") } m.Lock() defer m.Unlock() m.removeExpired() if m.tree.Get(&btreeItem{Item: i}) == nil { return nil, trace.NotFound("key %q is not found", string...
[ "func", "(", "m", "*", "Memory", ")", "Update", "(", "ctx", "context", ".", "Context", ",", "i", "backend", ".", "Item", ")", "(", "*", "backend", ".", "Lease", ",", "error", ")", "{", "if", "len", "(", "i", ".", "Key", ")", "==", "0", "{", "...
// Update updates item if it exists, or returns NotFound error
[ "Update", "updates", "item", "if", "it", "exists", "or", "returns", "NotFound", "error" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/backend/memory/memory.go#L182-L204
23,715
gravitational/teleport
lib/backend/memory/memory.go
CompareAndSwap
func (m *Memory) CompareAndSwap(ctx context.Context, expected backend.Item, replaceWith backend.Item) (*backend.Lease, error) { if len(expected.Key) == 0 { return nil, trace.BadParameter("missing parameter Key") } if len(replaceWith.Key) == 0 { return nil, trace.BadParameter("missing parameter Key") } if bytes...
go
func (m *Memory) CompareAndSwap(ctx context.Context, expected backend.Item, replaceWith backend.Item) (*backend.Lease, error) { if len(expected.Key) == 0 { return nil, trace.BadParameter("missing parameter Key") } if len(replaceWith.Key) == 0 { return nil, trace.BadParameter("missing parameter Key") } if bytes...
[ "func", "(", "m", "*", "Memory", ")", "CompareAndSwap", "(", "ctx", "context", ".", "Context", ",", "expected", "backend", ".", "Item", ",", "replaceWith", "backend", ".", "Item", ")", "(", "*", "backend", ".", "Lease", ",", "error", ")", "{", "if", ...
// CompareAndSwap compares item with existing item and replaces it with replaceWith item
[ "CompareAndSwap", "compares", "item", "with", "existing", "item", "and", "replaces", "it", "with", "replaceWith", "item" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/backend/memory/memory.go#L344-L374
23,716
gravitational/teleport
lib/backend/memory/memory.go
removeExpired
func (m *Memory) removeExpired() int { removed := 0 now := m.Clock().Now().UTC() for { if len(*m.heap) == 0 { break } item := m.heap.PeekEl() if now.Before(item.Expires) { break } m.heap.PopEl() m.tree.Delete(item) m.Debugf("Removed expired %v %v item.", string(item.Key), item.Expires) remove...
go
func (m *Memory) removeExpired() int { removed := 0 now := m.Clock().Now().UTC() for { if len(*m.heap) == 0 { break } item := m.heap.PeekEl() if now.Before(item.Expires) { break } m.heap.PopEl() m.tree.Delete(item) m.Debugf("Removed expired %v %v item.", string(item.Key), item.Expires) remove...
[ "func", "(", "m", "*", "Memory", ")", "removeExpired", "(", ")", "int", "{", "removed", ":=", "0", "\n", "now", ":=", "m", ".", "Clock", "(", ")", ".", "Now", "(", ")", ".", "UTC", "(", ")", "\n", "for", "{", "if", "len", "(", "*", "m", "."...
// removeExpired makes a pass through map and removes expired elements // returns the number of expired elements removed
[ "removeExpired", "makes", "a", "pass", "through", "map", "and", "removes", "expired", "elements", "returns", "the", "number", "of", "expired", "elements", "removed" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/backend/memory/memory.go#L412-L432
23,717
gravitational/teleport
lib/session/session.go
Set
func (s *ID) Set(v string) error { id, err := ParseID(v) if err != nil { return trace.Wrap(err) } *s = *id return nil }
go
func (s *ID) Set(v string) error { id, err := ParseID(v) if err != nil { return trace.Wrap(err) } *s = *id return nil }
[ "func", "(", "s", "*", "ID", ")", "Set", "(", "v", "string", ")", "error", "{", "id", ",", "err", ":=", "ParseID", "(", "v", ")", "\n", "if", "err", "!=", "nil", "{", "return", "trace", ".", "Wrap", "(", "err", ")", "\n", "}", "\n", "*", "s...
// Set makes ID cli compatible, lets to set value from string
[ "Set", "makes", "ID", "cli", "compatible", "lets", "to", "set", "value", "from", "string" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/session/session.go#L58-L65
23,718
gravitational/teleport
lib/session/session.go
Time
func (s *ID) Time() time.Time { tm, ok := s.UUID().Time() if !ok { return time.Time{} } sec, nsec := tm.UnixTime() return time.Unix(sec, nsec).UTC() }
go
func (s *ID) Time() time.Time { tm, ok := s.UUID().Time() if !ok { return time.Time{} } sec, nsec := tm.UnixTime() return time.Unix(sec, nsec).UTC() }
[ "func", "(", "s", "*", "ID", ")", "Time", "(", ")", "time", ".", "Time", "{", "tm", ",", "ok", ":=", "s", ".", "UUID", "(", ")", ".", "Time", "(", ")", "\n", "if", "!", "ok", "{", "return", "time", ".", "Time", "{", "}", "\n", "}", "\n", ...
// Time returns time portion of this ID
[ "Time", "returns", "time", "portion", "of", "this", "ID" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/session/session.go#L68-L75
23,719
gravitational/teleport
lib/session/session.go
Check
func (s *ID) Check() error { _, err := ParseID(string(*s)) return trace.Wrap(err) }
go
func (s *ID) Check() error { _, err := ParseID(string(*s)) return trace.Wrap(err) }
[ "func", "(", "s", "*", "ID", ")", "Check", "(", ")", "error", "{", "_", ",", "err", ":=", "ParseID", "(", "string", "(", "*", "s", ")", ")", "\n", "return", "trace", ".", "Wrap", "(", "err", ")", "\n", "}" ]
// Check checks if it's a valid UUID
[ "Check", "checks", "if", "it", "s", "a", "valid", "UUID" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/session/session.go#L78-L81
23,720
gravitational/teleport
lib/session/session.go
ParseID
func ParseID(id string) (*ID, error) { val := uuid.Parse(id) if val == nil { return nil, trace.BadParameter("'%v' is not a valid Time UUID v1", id) } if ver, ok := val.Version(); !ok || ver != 1 { return nil, trace.BadParameter("'%v' is not a be a valid Time UUID v1", id) } uid := ID(id) return &uid, nil }
go
func ParseID(id string) (*ID, error) { val := uuid.Parse(id) if val == nil { return nil, trace.BadParameter("'%v' is not a valid Time UUID v1", id) } if ver, ok := val.Version(); !ok || ver != 1 { return nil, trace.BadParameter("'%v' is not a be a valid Time UUID v1", id) } uid := ID(id) return &uid, nil }
[ "func", "ParseID", "(", "id", "string", ")", "(", "*", "ID", ",", "error", ")", "{", "val", ":=", "uuid", ".", "Parse", "(", "id", ")", "\n", "if", "val", "==", "nil", "{", "return", "nil", ",", "trace", ".", "BadParameter", "(", "\"", "\"", ",...
// ParseID parses ID and checks if it's correct
[ "ParseID", "parses", "ID", "and", "checks", "if", "it", "s", "correct" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/session/session.go#L84-L94
23,721
gravitational/teleport
lib/session/session.go
RemoveParty
func (s *Session) RemoveParty(pid ID) bool { for i := range s.Parties { if s.Parties[i].ID == pid { s.Parties = append(s.Parties[:i], s.Parties[i+1:]...) return true } } return false }
go
func (s *Session) RemoveParty(pid ID) bool { for i := range s.Parties { if s.Parties[i].ID == pid { s.Parties = append(s.Parties[:i], s.Parties[i+1:]...) return true } } return false }
[ "func", "(", "s", "*", "Session", ")", "RemoveParty", "(", "pid", "ID", ")", "bool", "{", "for", "i", ":=", "range", "s", ".", "Parties", "{", "if", "s", ".", "Parties", "[", "i", "]", ".", "ID", "==", "pid", "{", "s", ".", "Parties", "=", "a...
// RemoveParty helper allows to remove a party by it's ID from the // session's list. Returns 'false' if pid couldn't be found
[ "RemoveParty", "helper", "allows", "to", "remove", "a", "party", "by", "it", "s", "ID", "from", "the", "session", "s", "list", ".", "Returns", "false", "if", "pid", "couldn", "t", "be", "found" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/session/session.go#L128-L136
23,722
gravitational/teleport
lib/session/session.go
String
func (p *Party) String() string { return fmt.Sprintf( "party(id=%v, remote=%v, user=%v, server=%v, last_active=%v)", p.ID, p.RemoteAddr, p.User, p.ServerID, p.LastActive, ) }
go
func (p *Party) String() string { return fmt.Sprintf( "party(id=%v, remote=%v, user=%v, server=%v, last_active=%v)", p.ID, p.RemoteAddr, p.User, p.ServerID, p.LastActive, ) }
[ "func", "(", "p", "*", "Party", ")", "String", "(", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "p", ".", "ID", ",", "p", ".", "RemoteAddr", ",", "p", ".", "User", ",", "p", ".", "ServerID", ",", "p", ".", "Last...
// String returns debug friendly representation
[ "String", "returns", "debug", "friendly", "representation" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/session/session.go#L154-L159
23,723
gravitational/teleport
lib/session/session.go
String
func (p *TerminalParams) String() string { return fmt.Sprintf("TerminalParams(w=%v, h=%v)", p.W, p.H) }
go
func (p *TerminalParams) String() string { return fmt.Sprintf("TerminalParams(w=%v, h=%v)", p.W, p.H) }
[ "func", "(", "p", "*", "TerminalParams", ")", "String", "(", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "p", ".", "W", ",", "p", ".", "H", ")", "\n", "}" ]
// String returns debug friendly representation of terminal
[ "String", "returns", "debug", "friendly", "representation", "of", "terminal" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/session/session.go#L199-L201
23,724
gravitational/teleport
lib/session/session.go
Winsize
func (p *TerminalParams) Winsize() *term.Winsize { return &term.Winsize{ Width: uint16(p.W), Height: uint16(p.H), } }
go
func (p *TerminalParams) Winsize() *term.Winsize { return &term.Winsize{ Width: uint16(p.W), Height: uint16(p.H), } }
[ "func", "(", "p", "*", "TerminalParams", ")", "Winsize", "(", ")", "*", "term", ".", "Winsize", "{", "return", "&", "term", ".", "Winsize", "{", "Width", ":", "uint16", "(", "p", ".", "W", ")", ",", "Height", ":", "uint16", "(", "p", ".", "H", ...
// Winsize returns low-level parameters for changing PTY
[ "Winsize", "returns", "low", "-", "level", "parameters", "for", "changing", "PTY" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/session/session.go#L204-L209
23,725
gravitational/teleport
lib/session/session.go
Check
func (u *UpdateRequest) Check() error { if err := u.ID.Check(); err != nil { return trace.Wrap(err) } if u.Namespace == "" { return trace.BadParameter("missing parameter Namespace") } if u.TerminalParams != nil { _, err := NewTerminalParamsFromInt(u.TerminalParams.W, u.TerminalParams.H) if err != nil { ...
go
func (u *UpdateRequest) Check() error { if err := u.ID.Check(); err != nil { return trace.Wrap(err) } if u.Namespace == "" { return trace.BadParameter("missing parameter Namespace") } if u.TerminalParams != nil { _, err := NewTerminalParamsFromInt(u.TerminalParams.W, u.TerminalParams.H) if err != nil { ...
[ "func", "(", "u", "*", "UpdateRequest", ")", "Check", "(", ")", "error", "{", "if", "err", ":=", "u", ".", "ID", ".", "Check", "(", ")", ";", "err", "!=", "nil", "{", "return", "trace", ".", "Wrap", "(", "err", ")", "\n", "}", "\n", "if", "u"...
// Check returns nil if request is valid, error otherwize
[ "Check", "returns", "nil", "if", "request", "is", "valid", "error", "otherwize" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/session/session.go#L230-L244
23,726
gravitational/teleport
lib/session/session.go
New
func New(bk backend.Backend) (Service, error) { s := &server{ bk: bk, clock: clockwork.NewRealClock(), } if s.activeSessionTTL == 0 { s.activeSessionTTL = defaults.ActiveSessionTTL } return s, nil }
go
func New(bk backend.Backend) (Service, error) { s := &server{ bk: bk, clock: clockwork.NewRealClock(), } if s.activeSessionTTL == 0 { s.activeSessionTTL = defaults.ActiveSessionTTL } return s, nil }
[ "func", "New", "(", "bk", "backend", ".", "Backend", ")", "(", "Service", ",", "error", ")", "{", "s", ":=", "&", "server", "{", "bk", ":", "bk", ",", "clock", ":", "clockwork", ".", "NewRealClock", "(", ")", ",", "}", "\n", "if", "s", ".", "ac...
// New returns new session server that uses sqlite to manage // active sessions
[ "New", "returns", "new", "session", "server", "that", "uses", "sqlite", "to", "manage", "active", "sessions" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/session/session.go#L277-L286
23,727
gravitational/teleport
lib/session/session.go
GetSessions
func (s *server) GetSessions(namespace string) ([]Session, error) { prefix := activePrefix(namespace) result, err := s.bk.GetRange(context.TODO(), prefix, backend.RangeEnd(prefix), MaxSessionSliceLength) if err != nil { return nil, trace.Wrap(err) } out := make(Sessions, 0, len(result.Items)) for i := range r...
go
func (s *server) GetSessions(namespace string) ([]Session, error) { prefix := activePrefix(namespace) result, err := s.bk.GetRange(context.TODO(), prefix, backend.RangeEnd(prefix), MaxSessionSliceLength) if err != nil { return nil, trace.Wrap(err) } out := make(Sessions, 0, len(result.Items)) for i := range r...
[ "func", "(", "s", "*", "server", ")", "GetSessions", "(", "namespace", "string", ")", "(", "[", "]", "Session", ",", "error", ")", "{", "prefix", ":=", "activePrefix", "(", "namespace", ")", "\n\n", "result", ",", "err", ":=", "s", ".", "bk", ".", ...
// GetSessions returns a list of active sessions. Returns an empty slice // if no sessions are active
[ "GetSessions", "returns", "a", "list", "of", "active", "sessions", ".", "Returns", "an", "empty", "slice", "if", "no", "sessions", "are", "active" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/session/session.go#L298-L316
23,728
gravitational/teleport
lib/session/session.go
GetSession
func (s *server) GetSession(namespace string, id ID) (*Session, error) { item, err := s.bk.Get(context.TODO(), activeKey(namespace, string(id))) if err != nil { if trace.IsNotFound(err) { return nil, trace.NotFound("session(%v, %v) is not found", namespace, id) } return nil, trace.Wrap(err) } var sess Sess...
go
func (s *server) GetSession(namespace string, id ID) (*Session, error) { item, err := s.bk.Get(context.TODO(), activeKey(namespace, string(id))) if err != nil { if trace.IsNotFound(err) { return nil, trace.NotFound("session(%v, %v) is not found", namespace, id) } return nil, trace.Wrap(err) } var sess Sess...
[ "func", "(", "s", "*", "server", ")", "GetSession", "(", "namespace", "string", ",", "id", "ID", ")", "(", "*", "Session", ",", "error", ")", "{", "item", ",", "err", ":=", "s", ".", "bk", ".", "Get", "(", "context", ".", "TODO", "(", ")", ",",...
// GetSession returns the session by it's id. Returns NotFound if a session // is not found
[ "GetSession", "returns", "the", "session", "by", "it", "s", "id", ".", "Returns", "NotFound", "if", "a", "session", "is", "not", "found" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/session/session.go#L341-L354
23,729
gravitational/teleport
lib/session/session.go
CreateSession
func (s *server) CreateSession(sess Session) error { if err := sess.ID.Check(); err != nil { return trace.Wrap(err) } if sess.Namespace == "" { return trace.BadParameter("session namespace can not be empty") } if sess.Login == "" { return trace.BadParameter("session login can not be empty") } if sess.Creat...
go
func (s *server) CreateSession(sess Session) error { if err := sess.ID.Check(); err != nil { return trace.Wrap(err) } if sess.Namespace == "" { return trace.BadParameter("session namespace can not be empty") } if sess.Login == "" { return trace.BadParameter("session login can not be empty") } if sess.Creat...
[ "func", "(", "s", "*", "server", ")", "CreateSession", "(", "sess", "Session", ")", "error", "{", "if", "err", ":=", "sess", ".", "ID", ".", "Check", "(", ")", ";", "err", "!=", "nil", "{", "return", "trace", ".", "Wrap", "(", "err", ")", "\n", ...
// CreateSession creates a new session if it does not exist, if the session // exists the function will return AlreadyExists error // The session will be marked as active for TTL period of time
[ "CreateSession", "creates", "a", "new", "session", "if", "it", "does", "not", "exist", "if", "the", "session", "exists", "the", "function", "will", "return", "AlreadyExists", "error", "The", "session", "will", "be", "marked", "as", "active", "for", "TTL", "p...
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/session/session.go#L359-L394
23,730
gravitational/teleport
lib/session/session.go
UpdateSession
func (s *server) UpdateSession(req UpdateRequest) error { if err := req.Check(); err != nil { return trace.Wrap(err) } key := activeKey(req.Namespace, string(req.ID)) // Try several times, then give up for i := 0; i < sessionUpdateAttempts; i++ { item, err := s.bk.Get(context.TODO(), key) if err != nil { ...
go
func (s *server) UpdateSession(req UpdateRequest) error { if err := req.Check(); err != nil { return trace.Wrap(err) } key := activeKey(req.Namespace, string(req.ID)) // Try several times, then give up for i := 0; i < sessionUpdateAttempts; i++ { item, err := s.bk.Get(context.TODO(), key) if err != nil { ...
[ "func", "(", "s", "*", "server", ")", "UpdateSession", "(", "req", "UpdateRequest", ")", "error", "{", "if", "err", ":=", "req", ".", "Check", "(", ")", ";", "err", "!=", "nil", "{", "return", "trace", ".", "Wrap", "(", "err", ")", "\n", "}", "\n...
// UpdateSession updates session parameters - can mark it as inactive and update it's terminal parameters
[ "UpdateSession", "updates", "session", "parameters", "-", "can", "mark", "it", "as", "inactive", "and", "update", "it", "s", "terminal", "parameters" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/session/session.go#L402-L452
23,731
gravitational/teleport
lib/session/session.go
GetSession
func (d *discardSessionServer) GetSession(namespace string, id ID) (*Session, error) { return &Session{}, nil }
go
func (d *discardSessionServer) GetSession(namespace string, id ID) (*Session, error) { return &Session{}, nil }
[ "func", "(", "d", "*", "discardSessionServer", ")", "GetSession", "(", "namespace", "string", ",", "id", "ID", ")", "(", "*", "Session", ",", "error", ")", "{", "return", "&", "Session", "{", "}", ",", "nil", "\n", "}" ]
// GetSession always returns a zero session.
[ "GetSession", "always", "returns", "a", "zero", "session", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/session/session.go#L471-L473
23,732
gravitational/teleport
lib/session/session.go
NewTerminalParamsFromUint32
func NewTerminalParamsFromUint32(w uint32, h uint32) (*TerminalParams, error) { if w > maxSize || w < minSize { return nil, trace.BadParameter("bad width") } if h > maxSize || h < minSize { return nil, trace.BadParameter("bad height") } return &TerminalParams{W: int(w), H: int(h)}, nil }
go
func NewTerminalParamsFromUint32(w uint32, h uint32) (*TerminalParams, error) { if w > maxSize || w < minSize { return nil, trace.BadParameter("bad width") } if h > maxSize || h < minSize { return nil, trace.BadParameter("bad height") } return &TerminalParams{W: int(w), H: int(h)}, nil }
[ "func", "NewTerminalParamsFromUint32", "(", "w", "uint32", ",", "h", "uint32", ")", "(", "*", "TerminalParams", ",", "error", ")", "{", "if", "w", ">", "maxSize", "||", "w", "<", "minSize", "{", "return", "nil", ",", "trace", ".", "BadParameter", "(", ...
// NewTerminalParamsFromUint32 returns new terminal parameters from uint32 width and height
[ "NewTerminalParamsFromUint32", "returns", "new", "terminal", "parameters", "from", "uint32", "width", "and", "height" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/session/session.go#L486-L494
23,733
gravitational/teleport
lib/srv/regular/sshserver.go
isAuditedAtProxy
func (s *Server) isAuditedAtProxy() bool { // always be safe, better to double record than not record at all clusterConfig, err := s.GetAccessPoint().GetClusterConfig() if err != nil { return false } isRecordAtProxy := clusterConfig.GetSessionRecording() == services.RecordAtProxy isTeleportNode := s.Component(...
go
func (s *Server) isAuditedAtProxy() bool { // always be safe, better to double record than not record at all clusterConfig, err := s.GetAccessPoint().GetClusterConfig() if err != nil { return false } isRecordAtProxy := clusterConfig.GetSessionRecording() == services.RecordAtProxy isTeleportNode := s.Component(...
[ "func", "(", "s", "*", "Server", ")", "isAuditedAtProxy", "(", ")", "bool", "{", "// always be safe, better to double record than not record at all", "clusterConfig", ",", "err", ":=", "s", ".", "GetAccessPoint", "(", ")", ".", "GetClusterConfig", "(", ")", "\n", ...
// isAuditedAtProxy returns true if sessions are being recorded at the proxy // and this is a Teleport node.
[ "isAuditedAtProxy", "returns", "true", "if", "sessions", "are", "being", "recorded", "at", "the", "proxy", "and", "this", "is", "a", "Teleport", "node", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/srv/regular/sshserver.go#L188-L202
23,734
gravitational/teleport
lib/srv/regular/sshserver.go
Shutdown
func (s *Server) Shutdown(ctx context.Context) error { // wait until connections drain off err := s.srv.Shutdown(ctx) s.cancel() s.reg.Close() if s.heartbeat != nil { if err := s.heartbeat.Close(); err != nil { s.Warningf("Failed to close heartbeat: %v.", err) } s.heartbeat = nil } return err }
go
func (s *Server) Shutdown(ctx context.Context) error { // wait until connections drain off err := s.srv.Shutdown(ctx) s.cancel() s.reg.Close() if s.heartbeat != nil { if err := s.heartbeat.Close(); err != nil { s.Warningf("Failed to close heartbeat: %v.", err) } s.heartbeat = nil } return err }
[ "func", "(", "s", "*", "Server", ")", "Shutdown", "(", "ctx", "context", ".", "Context", ")", "error", "{", "// wait until connections drain off", "err", ":=", "s", ".", "srv", ".", "Shutdown", "(", "ctx", ")", "\n", "s", ".", "cancel", "(", ")", "\n",...
// Shutdown performs graceful shutdown
[ "Shutdown", "performs", "graceful", "shutdown" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/srv/regular/sshserver.go#L221-L233
23,735
gravitational/teleport
lib/srv/regular/sshserver.go
Start
func (s *Server) Start() error { if len(s.getCommandLabels()) > 0 { s.updateLabels() } go s.heartbeat.Run() // If the server requested connections to it arrive over a reverse tunnel, // don't call Start() which listens on a socket, return right away. if s.useTunnel { return nil } return s.srv.Start() }
go
func (s *Server) Start() error { if len(s.getCommandLabels()) > 0 { s.updateLabels() } go s.heartbeat.Run() // If the server requested connections to it arrive over a reverse tunnel, // don't call Start() which listens on a socket, return right away. if s.useTunnel { return nil } return s.srv.Start() }
[ "func", "(", "s", "*", "Server", ")", "Start", "(", ")", "error", "{", "if", "len", "(", "s", ".", "getCommandLabels", "(", ")", ")", ">", "0", "{", "s", ".", "updateLabels", "(", ")", "\n", "}", "\n", "go", "s", ".", "heartbeat", ".", "Run", ...
// Start starts server
[ "Start", "starts", "server" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/srv/regular/sshserver.go#L236-L248
23,736
gravitational/teleport
lib/srv/regular/sshserver.go
Serve
func (s *Server) Serve(l net.Listener) error { if len(s.getCommandLabels()) > 0 { s.updateLabels() } go s.heartbeat.Run() return s.srv.Serve(l) }
go
func (s *Server) Serve(l net.Listener) error { if len(s.getCommandLabels()) > 0 { s.updateLabels() } go s.heartbeat.Run() return s.srv.Serve(l) }
[ "func", "(", "s", "*", "Server", ")", "Serve", "(", "l", "net", ".", "Listener", ")", "error", "{", "if", "len", "(", "s", ".", "getCommandLabels", "(", ")", ")", ">", "0", "{", "s", ".", "updateLabels", "(", ")", "\n", "}", "\n", "go", "s", ...
// Serve servers service on started listener
[ "Serve", "servers", "service", "on", "started", "listener" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/srv/regular/sshserver.go#L251-L257
23,737
gravitational/teleport
lib/srv/regular/sshserver.go
HandleConnection
func (s *Server) HandleConnection(conn net.Conn) { s.srv.HandleConnection(conn) }
go
func (s *Server) HandleConnection(conn net.Conn) { s.srv.HandleConnection(conn) }
[ "func", "(", "s", "*", "Server", ")", "HandleConnection", "(", "conn", "net", ".", "Conn", ")", "{", "s", ".", "srv", ".", "HandleConnection", "(", "conn", ")", "\n", "}" ]
// HandleConnection is called after a connection has been accepted and starts // to perform the SSH handshake immediately.
[ "HandleConnection", "is", "called", "after", "a", "connection", "has", "been", "accepted", "and", "starts", "to", "perform", "the", "SSH", "handshake", "immediately", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/srv/regular/sshserver.go#L266-L268
23,738
gravitational/teleport
lib/srv/regular/sshserver.go
SetRotationGetter
func SetRotationGetter(getter RotationGetter) ServerOption { return func(s *Server) error { s.getRotation = getter return nil } }
go
func SetRotationGetter(getter RotationGetter) ServerOption { return func(s *Server) error { s.getRotation = getter return nil } }
[ "func", "SetRotationGetter", "(", "getter", "RotationGetter", ")", "ServerOption", "{", "return", "func", "(", "s", "*", "Server", ")", "error", "{", "s", ".", "getRotation", "=", "getter", "\n", "return", "nil", "\n", "}", "\n", "}" ]
// SetRotationGetter sets rotation state getter
[ "SetRotationGetter", "sets", "rotation", "state", "getter" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/srv/regular/sshserver.go#L274-L279
23,739
gravitational/teleport
lib/srv/regular/sshserver.go
SetShell
func SetShell(shell string) ServerOption { return func(s *Server) error { s.shell = shell return nil } }
go
func SetShell(shell string) ServerOption { return func(s *Server) error { s.shell = shell return nil } }
[ "func", "SetShell", "(", "shell", "string", ")", "ServerOption", "{", "return", "func", "(", "s", "*", "Server", ")", "error", "{", "s", ".", "shell", "=", "shell", "\n", "return", "nil", "\n", "}", "\n", "}" ]
// SetShell sets default shell that will be executed for interactive // sessions
[ "SetShell", "sets", "default", "shell", "that", "will", "be", "executed", "for", "interactive", "sessions" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/srv/regular/sshserver.go#L283-L288
23,740
gravitational/teleport
lib/srv/regular/sshserver.go
SetSessionServer
func SetSessionServer(sessionServer rsession.Service) ServerOption { return func(s *Server) error { s.sessionServer = sessionServer return nil } }
go
func SetSessionServer(sessionServer rsession.Service) ServerOption { return func(s *Server) error { s.sessionServer = sessionServer return nil } }
[ "func", "SetSessionServer", "(", "sessionServer", "rsession", ".", "Service", ")", "ServerOption", "{", "return", "func", "(", "s", "*", "Server", ")", "error", "{", "s", ".", "sessionServer", "=", "sessionServer", "\n", "return", "nil", "\n", "}", "\n", "...
// SetSessionServer represents realtime session registry server
[ "SetSessionServer", "represents", "realtime", "session", "registry", "server" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/srv/regular/sshserver.go#L291-L296
23,741
gravitational/teleport
lib/srv/regular/sshserver.go
SetProxyMode
func SetProxyMode(tsrv reversetunnel.Server) ServerOption { return func(s *Server) error { // always set proxy mode to true, // because in some tests reverse tunnel is disabled, // but proxy is still used without it. s.proxyMode = true s.proxyTun = tsrv return nil } }
go
func SetProxyMode(tsrv reversetunnel.Server) ServerOption { return func(s *Server) error { // always set proxy mode to true, // because in some tests reverse tunnel is disabled, // but proxy is still used without it. s.proxyMode = true s.proxyTun = tsrv return nil } }
[ "func", "SetProxyMode", "(", "tsrv", "reversetunnel", ".", "Server", ")", "ServerOption", "{", "return", "func", "(", "s", "*", "Server", ")", "error", "{", "// always set proxy mode to true,", "// because in some tests reverse tunnel is disabled,", "// but proxy is still u...
// SetProxyMode starts this server in SSH proxying mode
[ "SetProxyMode", "starts", "this", "server", "in", "SSH", "proxying", "mode" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/srv/regular/sshserver.go#L299-L308
23,742
gravitational/teleport
lib/srv/regular/sshserver.go
SetLabels
func SetLabels(labels map[string]string, cmdLabels services.CommandLabels) ServerOption { return func(s *Server) error { // make sure to clone labels to avoid // concurrent writes to the map during reloads cmdLabels = cmdLabels.Clone() for name, label := range cmdLabels { if label.GetPeriod() < time.Second...
go
func SetLabels(labels map[string]string, cmdLabels services.CommandLabels) ServerOption { return func(s *Server) error { // make sure to clone labels to avoid // concurrent writes to the map during reloads cmdLabels = cmdLabels.Clone() for name, label := range cmdLabels { if label.GetPeriod() < time.Second...
[ "func", "SetLabels", "(", "labels", "map", "[", "string", "]", "string", ",", "cmdLabels", "services", ".", "CommandLabels", ")", "ServerOption", "{", "return", "func", "(", "s", "*", "Server", ")", "error", "{", "// make sure to clone labels to avoid", "// conc...
// SetLabels sets dynamic and static labels that server will report to the // auth servers
[ "SetLabels", "sets", "dynamic", "and", "static", "labels", "that", "server", "will", "report", "to", "the", "auth", "servers" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/srv/regular/sshserver.go#L312-L329
23,743
gravitational/teleport
lib/srv/regular/sshserver.go
SetAuditLog
func SetAuditLog(alog events.IAuditLog) ServerOption { return func(s *Server) error { s.alog = alog return nil } }
go
func SetAuditLog(alog events.IAuditLog) ServerOption { return func(s *Server) error { s.alog = alog return nil } }
[ "func", "SetAuditLog", "(", "alog", "events", ".", "IAuditLog", ")", "ServerOption", "{", "return", "func", "(", "s", "*", "Server", ")", "error", "{", "s", ".", "alog", "=", "alog", "\n", "return", "nil", "\n", "}", "\n", "}" ]
// SetAuditLog assigns an audit log interfaces to this server
[ "SetAuditLog", "assigns", "an", "audit", "log", "interfaces", "to", "this", "server" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/srv/regular/sshserver.go#L340-L345
23,744
gravitational/teleport
lib/srv/regular/sshserver.go
SetUUID
func SetUUID(uuid string) ServerOption { return func(s *Server) error { s.uuid = uuid return nil } }
go
func SetUUID(uuid string) ServerOption { return func(s *Server) error { s.uuid = uuid return nil } }
[ "func", "SetUUID", "(", "uuid", "string", ")", "ServerOption", "{", "return", "func", "(", "s", "*", "Server", ")", "error", "{", "s", ".", "uuid", "=", "uuid", "\n", "return", "nil", "\n", "}", "\n", "}" ]
// SetUUID sets server unique ID
[ "SetUUID", "sets", "server", "unique", "ID" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/srv/regular/sshserver.go#L348-L353
23,745
gravitational/teleport
lib/srv/regular/sshserver.go
SetPermitUserEnvironment
func SetPermitUserEnvironment(permitUserEnvironment bool) ServerOption { return func(s *Server) error { s.permitUserEnvironment = permitUserEnvironment return nil } }
go
func SetPermitUserEnvironment(permitUserEnvironment bool) ServerOption { return func(s *Server) error { s.permitUserEnvironment = permitUserEnvironment return nil } }
[ "func", "SetPermitUserEnvironment", "(", "permitUserEnvironment", "bool", ")", "ServerOption", "{", "return", "func", "(", "s", "*", "Server", ")", "error", "{", "s", ".", "permitUserEnvironment", "=", "permitUserEnvironment", "\n", "return", "nil", "\n", "}", "...
// SetPermitUserEnvironment allows you to set the value of permitUserEnvironment.
[ "SetPermitUserEnvironment", "allows", "you", "to", "set", "the", "value", "of", "permitUserEnvironment", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/srv/regular/sshserver.go#L363-L368
23,746
gravitational/teleport
lib/srv/regular/sshserver.go
serveAgent
func (s *Server) serveAgent(ctx *srv.ServerContext) error { // gather information about user and process. this will be used to set the // socket path and permissions systemUser, err := user.Lookup(ctx.Identity.Login) if err != nil { return trace.ConvertSystemError(err) } uid, err := strconv.Atoi(systemUser.Uid)...
go
func (s *Server) serveAgent(ctx *srv.ServerContext) error { // gather information about user and process. this will be used to set the // socket path and permissions systemUser, err := user.Lookup(ctx.Identity.Login) if err != nil { return trace.ConvertSystemError(err) } uid, err := strconv.Atoi(systemUser.Uid)...
[ "func", "(", "s", "*", "Server", ")", "serveAgent", "(", "ctx", "*", "srv", ".", "ServerContext", ")", "error", "{", "// gather information about user and process. this will be used to set the", "// socket path and permissions", "systemUser", ",", "err", ":=", "user", "...
// serveAgent will build the a sock path for this user and serve an SSH agent on unix socket.
[ "serveAgent", "will", "build", "the", "a", "sock", "path", "for", "this", "user", "and", "serve", "an", "SSH", "agent", "on", "unix", "socket", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/srv/regular/sshserver.go#L683-L728
23,747
gravitational/teleport
lib/srv/regular/sshserver.go
EmitAuditEvent
func (s *Server) EmitAuditEvent(event events.Event, fields events.EventFields) { log.Debugf("server.EmitAuditEvent(%v)", event.Name) alog := s.alog if alog != nil { // record the event time with ms precision fields[events.EventTime] = s.clock.Now().In(time.UTC).Round(time.Millisecond) if err := alog.EmitAuditE...
go
func (s *Server) EmitAuditEvent(event events.Event, fields events.EventFields) { log.Debugf("server.EmitAuditEvent(%v)", event.Name) alog := s.alog if alog != nil { // record the event time with ms precision fields[events.EventTime] = s.clock.Now().In(time.UTC).Round(time.Millisecond) if err := alog.EmitAuditE...
[ "func", "(", "s", "*", "Server", ")", "EmitAuditEvent", "(", "event", "events", ".", "Event", ",", "fields", "events", ".", "EventFields", ")", "{", "log", ".", "Debugf", "(", "\"", "\"", ",", "event", ".", "Name", ")", "\n", "alog", ":=", "s", "."...
// EmitAuditEvent logs a given event to the audit log attached to the // server who owns these sessions
[ "EmitAuditEvent", "logs", "a", "given", "event", "to", "the", "audit", "log", "attached", "to", "the", "server", "who", "owns", "these", "sessions" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/srv/regular/sshserver.go#L732-L744
23,748
gravitational/teleport
lib/srv/regular/sshserver.go
HandleNewChan
func (s *Server) HandleNewChan(wconn net.Conn, sconn *ssh.ServerConn, nch ssh.NewChannel) { identityContext, err := s.authHandlers.CreateIdentityContext(sconn) if err != nil { nch.Reject(ssh.Prohibited, fmt.Sprintf("Unable to create identity from connection: %v", err)) return } channelType := nch.ChannelType()...
go
func (s *Server) HandleNewChan(wconn net.Conn, sconn *ssh.ServerConn, nch ssh.NewChannel) { identityContext, err := s.authHandlers.CreateIdentityContext(sconn) if err != nil { nch.Reject(ssh.Prohibited, fmt.Sprintf("Unable to create identity from connection: %v", err)) return } channelType := nch.ChannelType()...
[ "func", "(", "s", "*", "Server", ")", "HandleNewChan", "(", "wconn", "net", ".", "Conn", ",", "sconn", "*", "ssh", ".", "ServerConn", ",", "nch", "ssh", ".", "NewChannel", ")", "{", "identityContext", ",", "err", ":=", "s", ".", "authHandlers", ".", ...
// HandleNewChan is called when new channel is opened
[ "HandleNewChan", "is", "called", "when", "new", "channel", "is", "opened" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/srv/regular/sshserver.go#L768-L823
23,749
gravitational/teleport
lib/srv/regular/sshserver.go
handleAgentForwardNode
func (s *Server) handleAgentForwardNode(req *ssh.Request, ctx *srv.ServerContext) error { // check if the user's RBAC role allows agent forwarding err := s.authHandlers.CheckAgentForward(ctx) if err != nil { return trace.Wrap(err) } // open a channel to the client where the client will serve an agent authChann...
go
func (s *Server) handleAgentForwardNode(req *ssh.Request, ctx *srv.ServerContext) error { // check if the user's RBAC role allows agent forwarding err := s.authHandlers.CheckAgentForward(ctx) if err != nil { return trace.Wrap(err) } // open a channel to the client where the client will serve an agent authChann...
[ "func", "(", "s", "*", "Server", ")", "handleAgentForwardNode", "(", "req", "*", "ssh", ".", "Request", ",", "ctx", "*", "srv", ".", "ServerContext", ")", "error", "{", "// check if the user's RBAC role allows agent forwarding", "err", ":=", "s", ".", "authHandl...
// handleAgentForwardNode will create a unix socket and serve the agent running // on the client on it.
[ "handleAgentForwardNode", "will", "create", "a", "unix", "socket", "and", "serve", "the", "agent", "running", "on", "the", "client", "on", "it", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/srv/regular/sshserver.go#L1079-L1102
23,750
gravitational/teleport
lib/srv/regular/sshserver.go
handleKeepAlive
func (s *Server) handleKeepAlive(req *ssh.Request) { log.Debugf("Received %q: WantReply: %v", req.Type, req.WantReply) // only reply if the sender actually wants a response if req.WantReply { err := req.Reply(true, nil) if err != nil { log.Warnf("Unable to reply to %q request: %v", req.Type, err) return ...
go
func (s *Server) handleKeepAlive(req *ssh.Request) { log.Debugf("Received %q: WantReply: %v", req.Type, req.WantReply) // only reply if the sender actually wants a response if req.WantReply { err := req.Reply(true, nil) if err != nil { log.Warnf("Unable to reply to %q request: %v", req.Type, err) return ...
[ "func", "(", "s", "*", "Server", ")", "handleKeepAlive", "(", "req", "*", "ssh", ".", "Request", ")", "{", "log", ".", "Debugf", "(", "\"", "\"", ",", "req", ".", "Type", ",", "req", ".", "WantReply", ")", "\n\n", "// only reply if the sender actually wa...
// handleKeepAlive accepts and replies to keepalive@openssh.com requests.
[ "handleKeepAlive", "accepts", "and", "replies", "to", "keepalive" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/srv/regular/sshserver.go#L1171-L1184
23,751
gravitational/teleport
lib/srv/regular/sshserver.go
handleRecordingProxy
func (s *Server) handleRecordingProxy(req *ssh.Request) { var recordingProxy bool log.Debugf("Global request (%v, %v) received", req.Type, req.WantReply) if req.WantReply { // get the cluster config, if we can't get it, reply false clusterConfig, err := s.authService.GetClusterConfig() if err != nil { err...
go
func (s *Server) handleRecordingProxy(req *ssh.Request) { var recordingProxy bool log.Debugf("Global request (%v, %v) received", req.Type, req.WantReply) if req.WantReply { // get the cluster config, if we can't get it, reply false clusterConfig, err := s.authService.GetClusterConfig() if err != nil { err...
[ "func", "(", "s", "*", "Server", ")", "handleRecordingProxy", "(", "req", "*", "ssh", ".", "Request", ")", "{", "var", "recordingProxy", "bool", "\n\n", "log", ".", "Debugf", "(", "\"", "\"", ",", "req", ".", "Type", ",", "req", ".", "WantReply", ")"...
// handleRecordingProxy responds to global out-of-band with a bool which // indicates if it is in recording mode or not.
[ "handleRecordingProxy", "responds", "to", "global", "out", "-", "of", "-", "band", "with", "a", "bool", "which", "indicates", "if", "it", "is", "in", "recording", "mode", "or", "not", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/srv/regular/sshserver.go#L1188-L1215
23,752
gravitational/teleport
lib/services/wrappers.go
UnmarshalJSON
func (s *Strings) UnmarshalJSON(data []byte) error { if len(data) == 0 { return nil } var stringVar string if err := json.Unmarshal(data, &stringVar); err == nil { *s = []string{stringVar} return nil } var stringsVar []string if err := json.Unmarshal(data, &stringsVar); err != nil { return trace.Wrap(err...
go
func (s *Strings) UnmarshalJSON(data []byte) error { if len(data) == 0 { return nil } var stringVar string if err := json.Unmarshal(data, &stringVar); err == nil { *s = []string{stringVar} return nil } var stringsVar []string if err := json.Unmarshal(data, &stringsVar); err != nil { return trace.Wrap(err...
[ "func", "(", "s", "*", "Strings", ")", "UnmarshalJSON", "(", "data", "[", "]", "byte", ")", "error", "{", "if", "len", "(", "data", ")", "==", "0", "{", "return", "nil", "\n", "}", "\n", "var", "stringVar", "string", "\n", "if", "err", ":=", "jso...
// UnmarshalJSON unmarshals scalar string or strings slice to Strings
[ "UnmarshalJSON", "unmarshals", "scalar", "string", "or", "strings", "slice", "to", "Strings" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/wrappers.go#L99-L114
23,753
gravitational/teleport
lib/services/wrappers.go
UnmarshalYAML
func (s *Strings) UnmarshalYAML(unmarshal func(interface{}) error) error { // try unmarshal as string var val string err := unmarshal(&val) if err == nil { *s = []string{val} return nil } // try unmarshal as slice var slice []string err = unmarshal(&slice) if err == nil { *s = slice return nil } re...
go
func (s *Strings) UnmarshalYAML(unmarshal func(interface{}) error) error { // try unmarshal as string var val string err := unmarshal(&val) if err == nil { *s = []string{val} return nil } // try unmarshal as slice var slice []string err = unmarshal(&slice) if err == nil { *s = slice return nil } re...
[ "func", "(", "s", "*", "Strings", ")", "UnmarshalYAML", "(", "unmarshal", "func", "(", "interface", "{", "}", ")", "error", ")", "error", "{", "// try unmarshal as string", "var", "val", "string", "\n", "err", ":=", "unmarshal", "(", "&", "val", ")", "\n...
// UnmarshalYAML is used to allow Strings to unmarshal from // scalar string value or from the list
[ "UnmarshalYAML", "is", "used", "to", "allow", "Strings", "to", "unmarshal", "from", "scalar", "string", "value", "or", "from", "the", "list" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/wrappers.go#L118-L136
23,754
gravitational/teleport
lib/services/wrappers.go
MarshalJSON
func (s Strings) MarshalJSON() ([]byte, error) { if len(s) == 1 { return json.Marshal(s[0]) } return json.Marshal([]string(s)) }
go
func (s Strings) MarshalJSON() ([]byte, error) { if len(s) == 1 { return json.Marshal(s[0]) } return json.Marshal([]string(s)) }
[ "func", "(", "s", "Strings", ")", "MarshalJSON", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "if", "len", "(", "s", ")", "==", "1", "{", "return", "json", ".", "Marshal", "(", "s", "[", "0", "]", ")", "\n", "}", "\n", "return", ...
// MarshalJSON marshals to scalar value // if there is only one value in the list // to list otherwise
[ "MarshalJSON", "marshals", "to", "scalar", "value", "if", "there", "is", "only", "one", "value", "in", "the", "list", "to", "list", "otherwise" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/wrappers.go#L141-L146
23,755
gravitational/teleport
lib/services/wrappers.go
MarshalYAML
func (s Strings) MarshalYAML() (interface{}, error) { if len(s) == 1 { return s[0], nil } return []string(s), nil }
go
func (s Strings) MarshalYAML() (interface{}, error) { if len(s) == 1 { return s[0], nil } return []string(s), nil }
[ "func", "(", "s", "Strings", ")", "MarshalYAML", "(", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "if", "len", "(", "s", ")", "==", "1", "{", "return", "s", "[", "0", "]", ",", "nil", "\n", "}", "\n", "return", "[", "]", "string"...
// MarshalYAML marshals to scalar value // if there is only one value in the list, // marshals to list otherwise
[ "MarshalYAML", "marshals", "to", "scalar", "value", "if", "there", "is", "only", "one", "value", "in", "the", "list", "marshals", "to", "list", "otherwise" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/wrappers.go#L151-L156
23,756
gravitational/teleport
lib/utils/utils.go
NewTracer
func NewTracer(description string) *Tracer { return &Tracer{Started: time.Now().UTC(), Description: description} }
go
func NewTracer(description string) *Tracer { return &Tracer{Started: time.Now().UTC(), Description: description} }
[ "func", "NewTracer", "(", "description", "string", ")", "*", "Tracer", "{", "return", "&", "Tracer", "{", "Started", ":", "time", ".", "Now", "(", ")", ".", "UTC", "(", ")", ",", "Description", ":", "description", "}", "\n", "}" ]
// NewTracer returns a new tracer
[ "NewTracer", "returns", "a", "new", "tracer" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/utils.go#L50-L52
23,757
gravitational/teleport
lib/utils/utils.go
Stop
func (t *Tracer) Stop() *Tracer { log.Debugf("Tracer completed %v in %v.", t.Description, time.Now().Sub(t.Started)) return t }
go
func (t *Tracer) Stop() *Tracer { log.Debugf("Tracer completed %v in %v.", t.Description, time.Now().Sub(t.Started)) return t }
[ "func", "(", "t", "*", "Tracer", ")", "Stop", "(", ")", "*", "Tracer", "{", "log", ".", "Debugf", "(", "\"", "\"", ",", "t", ".", "Description", ",", "time", ".", "Now", "(", ")", ".", "Sub", "(", "t", ".", "Started", ")", ")", "\n", "return"...
// Stop logs stop of the trace
[ "Stop", "logs", "stop", "of", "the", "trace" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/utils.go#L61-L64
23,758
gravitational/teleport
lib/utils/utils.go
ThisFunction
func ThisFunction() string { var pc [32]uintptr runtime.Callers(2, pc[:]) return runtime.FuncForPC(pc[0]).Name() }
go
func ThisFunction() string { var pc [32]uintptr runtime.Callers(2, pc[:]) return runtime.FuncForPC(pc[0]).Name() }
[ "func", "ThisFunction", "(", ")", "string", "{", "var", "pc", "[", "32", "]", "uintptr", "\n", "runtime", ".", "Callers", "(", "2", ",", "pc", "[", ":", "]", ")", "\n", "return", "runtime", ".", "FuncForPC", "(", "pc", "[", "0", "]", ")", ".", ...
// ThisFunction returns calling function name
[ "ThisFunction", "returns", "calling", "function", "name" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/utils.go#L67-L71
23,759
gravitational/teleport
lib/utils/utils.go
Value
func (s *SyncString) Value() string { s.Lock() defer s.Unlock() return s.string }
go
func (s *SyncString) Value() string { s.Lock() defer s.Unlock() return s.string }
[ "func", "(", "s", "*", "SyncString", ")", "Value", "(", ")", "string", "{", "s", ".", "Lock", "(", ")", "\n", "defer", "s", ".", "Unlock", "(", ")", "\n", "return", "s", ".", "string", "\n", "}" ]
// Value returns value of the string
[ "Value", "returns", "value", "of", "the", "string" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/utils.go#L81-L85
23,760
gravitational/teleport
lib/utils/utils.go
Set
func (s *SyncString) Set(v string) { s.Lock() defer s.Unlock() s.string = v }
go
func (s *SyncString) Set(v string) { s.Lock() defer s.Unlock() s.string = v }
[ "func", "(", "s", "*", "SyncString", ")", "Set", "(", "v", "string", ")", "{", "s", ".", "Lock", "(", ")", "\n", "defer", "s", ".", "Unlock", "(", ")", "\n", "s", ".", "string", "=", "v", "\n", "}" ]
// Set sets the value of the string
[ "Set", "sets", "the", "value", "of", "the", "string" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/utils.go#L88-L92
23,761
gravitational/teleport
lib/utils/utils.go
AsBool
func AsBool(v string) bool { if v == "" { return false } out, _ := ParseBool(v) return out }
go
func AsBool(v string) bool { if v == "" { return false } out, _ := ParseBool(v) return out }
[ "func", "AsBool", "(", "v", "string", ")", "bool", "{", "if", "v", "==", "\"", "\"", "{", "return", "false", "\n", "}", "\n", "out", ",", "_", ":=", "ParseBool", "(", "v", ")", "\n", "return", "out", "\n", "}" ]
// AsBool converts string to bool, in case of the value is empty // or unknown, defaults to false
[ "AsBool", "converts", "string", "to", "bool", "in", "case", "of", "the", "value", "is", "empty", "or", "unknown", "defaults", "to", "false" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/utils.go#L118-L124
23,762
gravitational/teleport
lib/utils/utils.go
ParseBool
func ParseBool(value string) (bool, error) { switch strings.ToLower(value) { case "yes", "yeah", "y", "true", "1", "on": return true, nil case "no", "nope", "n", "false", "0", "off": return false, nil default: return false, trace.BadParameter("unsupported value: %q", value) } }
go
func ParseBool(value string) (bool, error) { switch strings.ToLower(value) { case "yes", "yeah", "y", "true", "1", "on": return true, nil case "no", "nope", "n", "false", "0", "off": return false, nil default: return false, trace.BadParameter("unsupported value: %q", value) } }
[ "func", "ParseBool", "(", "value", "string", ")", "(", "bool", ",", "error", ")", "{", "switch", "strings", ".", "ToLower", "(", "value", ")", "{", "case", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"...
// ParseBool parses string as boolean value, // returns error in case if value is not recognized
[ "ParseBool", "parses", "string", "as", "boolean", "value", "returns", "error", "in", "case", "if", "value", "is", "not", "recognized" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/utils.go#L128-L137
23,763
gravitational/teleport
lib/utils/utils.go
ParseAdvertiseAddr
func ParseAdvertiseAddr(advertiseIP string) (string, string, error) { advertiseIP = strings.TrimSpace(advertiseIP) host := advertiseIP port := "" if len(net.ParseIP(host)) == 0 && strings.Contains(advertiseIP, ":") { var err error host, port, err = net.SplitHostPort(advertiseIP) if err != nil { return "", ...
go
func ParseAdvertiseAddr(advertiseIP string) (string, string, error) { advertiseIP = strings.TrimSpace(advertiseIP) host := advertiseIP port := "" if len(net.ParseIP(host)) == 0 && strings.Contains(advertiseIP, ":") { var err error host, port, err = net.SplitHostPort(advertiseIP) if err != nil { return "", ...
[ "func", "ParseAdvertiseAddr", "(", "advertiseIP", "string", ")", "(", "string", ",", "string", ",", "error", ")", "{", "advertiseIP", "=", "strings", ".", "TrimSpace", "(", "advertiseIP", ")", "\n", "host", ":=", "advertiseIP", "\n", "port", ":=", "\"", "\...
// ParseAdvertiseAddr validates advertise address, // makes sure it's not an unreachable or multicast address // returns address split into host and port, port could be empty // if not specified
[ "ParseAdvertiseAddr", "validates", "advertise", "address", "makes", "sure", "it", "s", "not", "an", "unreachable", "or", "multicast", "address", "returns", "address", "split", "into", "host", "and", "port", "port", "could", "be", "empty", "if", "not", "specified...
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/utils.go#L143-L167
23,764
gravitational/teleport
lib/utils/utils.go
ParseOnOff
func ParseOnOff(parameterName, val string, defaultValue bool) (bool, error) { switch val { case teleport.On: return true, nil case teleport.Off: return false, nil case "": return defaultValue, nil default: return false, trace.BadParameter("bad %q parameter value: %q, supported values are on or off", parame...
go
func ParseOnOff(parameterName, val string, defaultValue bool) (bool, error) { switch val { case teleport.On: return true, nil case teleport.Off: return false, nil case "": return defaultValue, nil default: return false, trace.BadParameter("bad %q parameter value: %q, supported values are on or off", parame...
[ "func", "ParseOnOff", "(", "parameterName", ",", "val", "string", ",", "defaultValue", "bool", ")", "(", "bool", ",", "error", ")", "{", "switch", "val", "{", "case", "teleport", ".", "On", ":", "return", "true", ",", "nil", "\n", "case", "teleport", "...
// ParseOnOff parses whether value is "on" or "off", parameterName is passed for error // reporting purposes, defaultValue is returned when no value is set
[ "ParseOnOff", "parses", "whether", "value", "is", "on", "or", "off", "parameterName", "is", "passed", "for", "error", "reporting", "purposes", "defaultValue", "is", "returned", "when", "no", "value", "is", "set" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/utils.go#L184-L195
23,765
gravitational/teleport
lib/utils/utils.go
IsGroupMember
func IsGroupMember(gid int) (bool, error) { groups, err := os.Getgroups() if err != nil { return false, trace.ConvertSystemError(err) } for _, group := range groups { if group == gid { return true, nil } } return false, nil }
go
func IsGroupMember(gid int) (bool, error) { groups, err := os.Getgroups() if err != nil { return false, trace.ConvertSystemError(err) } for _, group := range groups { if group == gid { return true, nil } } return false, nil }
[ "func", "IsGroupMember", "(", "gid", "int", ")", "(", "bool", ",", "error", ")", "{", "groups", ",", "err", ":=", "os", ".", "Getgroups", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "false", ",", "trace", ".", "ConvertSystemError", "(", ...
// IsGroupMember returns whether currently logged user is a member of a group
[ "IsGroupMember", "returns", "whether", "currently", "logged", "user", "is", "a", "member", "of", "a", "group" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/utils.go#L198-L209
23,766
gravitational/teleport
lib/utils/utils.go
SplitHostPort
func SplitHostPort(hostname string) (string, string, error) { host, port, err := net.SplitHostPort(hostname) if err != nil { return "", "", trace.Wrap(err) } if host == "" { return "", "", trace.BadParameter("empty hostname") } return host, port, nil }
go
func SplitHostPort(hostname string) (string, string, error) { host, port, err := net.SplitHostPort(hostname) if err != nil { return "", "", trace.Wrap(err) } if host == "" { return "", "", trace.BadParameter("empty hostname") } return host, port, nil }
[ "func", "SplitHostPort", "(", "hostname", "string", ")", "(", "string", ",", "string", ",", "error", ")", "{", "host", ",", "port", ",", "err", ":=", "net", ".", "SplitHostPort", "(", "hostname", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\...
// SplitHostPort splits host and port and checks that host is not empty
[ "SplitHostPort", "splits", "host", "and", "port", "and", "checks", "that", "host", "is", "not", "empty" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/utils.go#L224-L233
23,767
gravitational/teleport
lib/utils/utils.go
ReadPath
func ReadPath(path string) ([]byte, error) { if path == "" { return nil, trace.NotFound("empty path") } s, err := filepath.Abs(path) if err != nil { return nil, trace.ConvertSystemError(err) } abs, err := filepath.EvalSymlinks(s) if err != nil { return nil, trace.ConvertSystemError(err) } bytes, err := i...
go
func ReadPath(path string) ([]byte, error) { if path == "" { return nil, trace.NotFound("empty path") } s, err := filepath.Abs(path) if err != nil { return nil, trace.ConvertSystemError(err) } abs, err := filepath.EvalSymlinks(s) if err != nil { return nil, trace.ConvertSystemError(err) } bytes, err := i...
[ "func", "ReadPath", "(", "path", "string", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "if", "path", "==", "\"", "\"", "{", "return", "nil", ",", "trace", ".", "NotFound", "(", "\"", "\"", ")", "\n", "}", "\n", "s", ",", "err", ":=", ...
// ReadPath reads file contents
[ "ReadPath", "reads", "file", "contents" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/utils.go#L236-L253
23,768
gravitational/teleport
lib/utils/utils.go
IsHandshakeFailedError
func IsHandshakeFailedError(err error) bool { if err == nil { return false } return strings.Contains(trace.Unwrap(err).Error(), "ssh: handshake failed") }
go
func IsHandshakeFailedError(err error) bool { if err == nil { return false } return strings.Contains(trace.Unwrap(err).Error(), "ssh: handshake failed") }
[ "func", "IsHandshakeFailedError", "(", "err", "error", ")", "bool", "{", "if", "err", "==", "nil", "{", "return", "false", "\n", "}", "\n", "return", "strings", ".", "Contains", "(", "trace", ".", "Unwrap", "(", "err", ")", ".", "Error", "(", ")", ",...
// IsHandshakeFailedError specifies whether this error indicates // failed handshake
[ "IsHandshakeFailedError", "specifies", "whether", "this", "error", "indicates", "failed", "handshake" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/utils.go#L277-L282
23,769
gravitational/teleport
lib/utils/utils.go
Pop
func (p *PortList) Pop() string { if len(*p) == 0 { panic("list is empty") } val := (*p)[len(*p)-1] *p = (*p)[:len(*p)-1] return val }
go
func (p *PortList) Pop() string { if len(*p) == 0 { panic("list is empty") } val := (*p)[len(*p)-1] *p = (*p)[:len(*p)-1] return val }
[ "func", "(", "p", "*", "PortList", ")", "Pop", "(", ")", "string", "{", "if", "len", "(", "*", "p", ")", "==", "0", "{", "panic", "(", "\"", "\"", ")", "\n", "}", "\n", "val", ":=", "(", "*", "p", ")", "[", "len", "(", "*", "p", ")", "-...
// Pop returns a value from the list, it panics if the value is not there
[ "Pop", "returns", "a", "value", "from", "the", "list", "it", "panics", "if", "the", "value", "is", "not", "there" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/utils.go#L303-L310
23,770
gravitational/teleport
lib/utils/utils.go
PopInt
func (p *PortList) PopInt() int { i, err := strconv.Atoi(p.Pop()) if err != nil { panic(err) } return i }
go
func (p *PortList) PopInt() int { i, err := strconv.Atoi(p.Pop()) if err != nil { panic(err) } return i }
[ "func", "(", "p", "*", "PortList", ")", "PopInt", "(", ")", "int", "{", "i", ",", "err", ":=", "strconv", ".", "Atoi", "(", "p", ".", "Pop", "(", ")", ")", "\n", "if", "err", "!=", "nil", "{", "panic", "(", "err", ")", "\n", "}", "\n", "ret...
// PopInt returns a value from the list, it panics if not enough values // were allocated
[ "PopInt", "returns", "a", "value", "from", "the", "list", "it", "panics", "if", "not", "enough", "values", "were", "allocated" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/utils.go#L314-L320
23,771
gravitational/teleport
lib/utils/utils.go
PopIntSlice
func (p *PortList) PopIntSlice(num int) []int { ports := make([]int, num) for i := range ports { ports[i] = p.PopInt() } return ports }
go
func (p *PortList) PopIntSlice(num int) []int { ports := make([]int, num) for i := range ports { ports[i] = p.PopInt() } return ports }
[ "func", "(", "p", "*", "PortList", ")", "PopIntSlice", "(", "num", "int", ")", "[", "]", "int", "{", "ports", ":=", "make", "(", "[", "]", "int", ",", "num", ")", "\n", "for", "i", ":=", "range", "ports", "{", "ports", "[", "i", "]", "=", "p"...
// PopIntSlice returns a slice of values from the list, it panics if not enough // ports were allocated
[ "PopIntSlice", "returns", "a", "slice", "of", "values", "from", "the", "list", "it", "panics", "if", "not", "enough", "ports", "were", "allocated" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/utils.go#L324-L330
23,772
gravitational/teleport
lib/utils/utils.go
GetFreeTCPPorts
func GetFreeTCPPorts(n int, offset ...int) (PortList, error) { list := make(PortList, 0, n) start := PortStartingNumber if len(offset) != 0 { start = offset[0] } for i := start; i < start+n; i++ { list = append(list, strconv.Itoa(i)) } return list, nil }
go
func GetFreeTCPPorts(n int, offset ...int) (PortList, error) { list := make(PortList, 0, n) start := PortStartingNumber if len(offset) != 0 { start = offset[0] } for i := start; i < start+n; i++ { list = append(list, strconv.Itoa(i)) } return list, nil }
[ "func", "GetFreeTCPPorts", "(", "n", "int", ",", "offset", "...", "int", ")", "(", "PortList", ",", "error", ")", "{", "list", ":=", "make", "(", "PortList", ",", "0", ",", "n", ")", "\n", "start", ":=", "PortStartingNumber", "\n", "if", "len", "(", ...
// GetFreeTCPPorts returns n ports starting from port 20000.
[ "GetFreeTCPPorts", "returns", "n", "ports", "starting", "from", "port", "20000", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/utils.go#L336-L346
23,773
gravitational/teleport
lib/utils/utils.go
ReadHostUUID
func ReadHostUUID(dataDir string) (string, error) { out, err := ReadPath(filepath.Join(dataDir, HostUUIDFile)) if err != nil { return "", trace.Wrap(err) } return strings.TrimSpace(string(out)), nil }
go
func ReadHostUUID(dataDir string) (string, error) { out, err := ReadPath(filepath.Join(dataDir, HostUUIDFile)) if err != nil { return "", trace.Wrap(err) } return strings.TrimSpace(string(out)), nil }
[ "func", "ReadHostUUID", "(", "dataDir", "string", ")", "(", "string", ",", "error", ")", "{", "out", ",", "err", ":=", "ReadPath", "(", "filepath", ".", "Join", "(", "dataDir", ",", "HostUUIDFile", ")", ")", "\n", "if", "err", "!=", "nil", "{", "retu...
// ReadHostUUID reads host UUID from the file in the data dir
[ "ReadHostUUID", "reads", "host", "UUID", "from", "the", "file", "in", "the", "data", "dir" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/utils.go#L349-L355
23,774
gravitational/teleport
lib/utils/utils.go
WriteHostUUID
func WriteHostUUID(dataDir string, id string) error { err := ioutil.WriteFile(filepath.Join(dataDir, HostUUIDFile), []byte(id), os.ModeExclusive|0400) if err != nil { return trace.ConvertSystemError(err) } return nil }
go
func WriteHostUUID(dataDir string, id string) error { err := ioutil.WriteFile(filepath.Join(dataDir, HostUUIDFile), []byte(id), os.ModeExclusive|0400) if err != nil { return trace.ConvertSystemError(err) } return nil }
[ "func", "WriteHostUUID", "(", "dataDir", "string", ",", "id", "string", ")", "error", "{", "err", ":=", "ioutil", ".", "WriteFile", "(", "filepath", ".", "Join", "(", "dataDir", ",", "HostUUIDFile", ")", ",", "[", "]", "byte", "(", "id", ")", ",", "o...
// WriteHostUUID writes host UUID into a file
[ "WriteHostUUID", "writes", "host", "UUID", "into", "a", "file" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/utils.go#L358-L364
23,775
gravitational/teleport
lib/utils/utils.go
ReadOrMakeHostUUID
func ReadOrMakeHostUUID(dataDir string) (string, error) { id, err := ReadHostUUID(dataDir) if err == nil { return id, nil } if !trace.IsNotFound(err) { return "", trace.Wrap(err) } id = uuid.New() if err = WriteHostUUID(dataDir, id); err != nil { return "", trace.Wrap(err) } return id, nil }
go
func ReadOrMakeHostUUID(dataDir string) (string, error) { id, err := ReadHostUUID(dataDir) if err == nil { return id, nil } if !trace.IsNotFound(err) { return "", trace.Wrap(err) } id = uuid.New() if err = WriteHostUUID(dataDir, id); err != nil { return "", trace.Wrap(err) } return id, nil }
[ "func", "ReadOrMakeHostUUID", "(", "dataDir", "string", ")", "(", "string", ",", "error", ")", "{", "id", ",", "err", ":=", "ReadHostUUID", "(", "dataDir", ")", "\n", "if", "err", "==", "nil", "{", "return", "id", ",", "nil", "\n", "}", "\n", "if", ...
// ReadOrMakeHostUUID looks for a hostid file in the data dir. If present, // returns the UUID from it, otherwise generates one
[ "ReadOrMakeHostUUID", "looks", "for", "a", "hostid", "file", "in", "the", "data", "dir", ".", "If", "present", "returns", "the", "UUID", "from", "it", "otherwise", "generates", "one" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/utils.go#L368-L381
23,776
gravitational/teleport
lib/utils/utils.go
Deduplicate
func Deduplicate(in []string) []string { if len(in) == 0 { return in } out := make([]string, 0, len(in)) seen := make(map[string]bool, len(in)) for _, val := range in { if _, ok := seen[val]; !ok { out = append(out, val) seen[val] = true } } return out }
go
func Deduplicate(in []string) []string { if len(in) == 0 { return in } out := make([]string, 0, len(in)) seen := make(map[string]bool, len(in)) for _, val := range in { if _, ok := seen[val]; !ok { out = append(out, val) seen[val] = true } } return out }
[ "func", "Deduplicate", "(", "in", "[", "]", "string", ")", "[", "]", "string", "{", "if", "len", "(", "in", ")", "==", "0", "{", "return", "in", "\n", "}", "\n", "out", ":=", "make", "(", "[", "]", "string", ",", "0", ",", "len", "(", "in", ...
// Deduplicate deduplicates list of strings
[ "Deduplicate", "deduplicates", "list", "of", "strings" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/utils.go#L394-L407
23,777
gravitational/teleport
lib/utils/utils.go
SliceContainsStr
func SliceContainsStr(slice []string, value string) bool { for i := range slice { if slice[i] == value { return true } } return false }
go
func SliceContainsStr(slice []string, value string) bool { for i := range slice { if slice[i] == value { return true } } return false }
[ "func", "SliceContainsStr", "(", "slice", "[", "]", "string", ",", "value", "string", ")", "bool", "{", "for", "i", ":=", "range", "slice", "{", "if", "slice", "[", "i", "]", "==", "value", "{", "return", "true", "\n", "}", "\n", "}", "\n", "return...
// SliceContainsStr returns 'true' if the slice contains the given value
[ "SliceContainsStr", "returns", "true", "if", "the", "slice", "contains", "the", "given", "value" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/utils.go#L410-L417
23,778
gravitational/teleport
lib/utils/utils.go
RemoveFromSlice
func RemoveFromSlice(slice []string, values ...string) []string { output := make([]string, 0, len(slice)) remove := make(map[string]bool) for _, value := range values { remove[value] = true } for _, s := range slice { _, ok := remove[s] if ok { continue } output = append(output, s) } return outpu...
go
func RemoveFromSlice(slice []string, values ...string) []string { output := make([]string, 0, len(slice)) remove := make(map[string]bool) for _, value := range values { remove[value] = true } for _, s := range slice { _, ok := remove[s] if ok { continue } output = append(output, s) } return outpu...
[ "func", "RemoveFromSlice", "(", "slice", "[", "]", "string", ",", "values", "...", "string", ")", "[", "]", "string", "{", "output", ":=", "make", "(", "[", "]", "string", ",", "0", ",", "len", "(", "slice", ")", ")", "\n\n", "remove", ":=", "make"...
// RemoveFromSlice makes a copy of the slice and removes the passed in values from the copy.
[ "RemoveFromSlice", "makes", "a", "copy", "of", "the", "slice", "and", "removes", "the", "passed", "in", "values", "from", "the", "copy", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/utils.go#L420-L437
23,779
gravitational/teleport
lib/utils/utils.go
CheckCertificateFormatFlag
func CheckCertificateFormatFlag(s string) (string, error) { switch s { case teleport.CertificateFormatStandard, teleport.CertificateFormatOldSSH, teleport.CertificateFormatUnspecified: return s, nil default: return "", trace.BadParameter("invalid certificate format parameter: %q", s) } }
go
func CheckCertificateFormatFlag(s string) (string, error) { switch s { case teleport.CertificateFormatStandard, teleport.CertificateFormatOldSSH, teleport.CertificateFormatUnspecified: return s, nil default: return "", trace.BadParameter("invalid certificate format parameter: %q", s) } }
[ "func", "CheckCertificateFormatFlag", "(", "s", "string", ")", "(", "string", ",", "error", ")", "{", "switch", "s", "{", "case", "teleport", ".", "CertificateFormatStandard", ",", "teleport", ".", "CertificateFormatOldSSH", ",", "teleport", ".", "CertificateForma...
// CheckCertificateFormatFlag checks if the certificate format is valid.
[ "CheckCertificateFormatFlag", "checks", "if", "the", "certificate", "format", "is", "valid", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/utils.go#L440-L447
23,780
gravitational/teleport
lib/utils/utils.go
Addrs
func (s Strings) Addrs(defaultPort int) ([]NetAddr, error) { addrs := make([]NetAddr, len(s)) for i, val := range s { addr, err := ParseHostPortAddr(val, defaultPort) if err != nil { return nil, trace.Wrap(err) } addrs[i] = *addr } return addrs, nil }
go
func (s Strings) Addrs(defaultPort int) ([]NetAddr, error) { addrs := make([]NetAddr, len(s)) for i, val := range s { addr, err := ParseHostPortAddr(val, defaultPort) if err != nil { return nil, trace.Wrap(err) } addrs[i] = *addr } return addrs, nil }
[ "func", "(", "s", "Strings", ")", "Addrs", "(", "defaultPort", "int", ")", "(", "[", "]", "NetAddr", ",", "error", ")", "{", "addrs", ":=", "make", "(", "[", "]", "NetAddr", ",", "len", "(", "s", ")", ")", "\n", "for", "i", ",", "val", ":=", ...
// Addrs returns strings list converted to address list
[ "Addrs", "returns", "strings", "list", "converted", "to", "address", "list" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/utils.go#L514-L524
23,781
gravitational/teleport
tool/tctl/common/tctl.go
connectToAuthService
func connectToAuthService(cfg *service.Config) (client auth.ClientI, err error) { // connect to the local auth server by default: cfg.Auth.Enabled = true if len(cfg.AuthServers) == 0 { cfg.AuthServers = []utils.NetAddr{ *defaults.AuthConnectAddr(), } } // read the host SSH keys and use them to open an SSH c...
go
func connectToAuthService(cfg *service.Config) (client auth.ClientI, err error) { // connect to the local auth server by default: cfg.Auth.Enabled = true if len(cfg.AuthServers) == 0 { cfg.AuthServers = []utils.NetAddr{ *defaults.AuthConnectAddr(), } } // read the host SSH keys and use them to open an SSH c...
[ "func", "connectToAuthService", "(", "cfg", "*", "service", ".", "Config", ")", "(", "client", "auth", ".", "ClientI", ",", "err", "error", ")", "{", "// connect to the local auth server by default:", "cfg", ".", "Auth", ".", "Enabled", "=", "true", "\n", "if"...
// connectToAuthService creates a valid client connection to the auth service
[ "connectToAuthService", "creates", "a", "valid", "client", "connection", "to", "the", "auth", "service" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/tool/tctl/common/tctl.go#L128-L163
23,782
gravitational/teleport
tool/tctl/common/tctl.go
applyConfig
func applyConfig(ccf *GlobalCLIFlags, cfg *service.Config) error { // load /etc/teleport.yaml and apply it's values: fileConf, err := config.ReadConfigFile(ccf.ConfigFile) if err != nil { return trace.Wrap(err) } // if configuration is passed as an environment variable, // try to decode it and override the conf...
go
func applyConfig(ccf *GlobalCLIFlags, cfg *service.Config) error { // load /etc/teleport.yaml and apply it's values: fileConf, err := config.ReadConfigFile(ccf.ConfigFile) if err != nil { return trace.Wrap(err) } // if configuration is passed as an environment variable, // try to decode it and override the conf...
[ "func", "applyConfig", "(", "ccf", "*", "GlobalCLIFlags", ",", "cfg", "*", "service", ".", "Config", ")", "error", "{", "// load /etc/teleport.yaml and apply it's values:", "fileConf", ",", "err", ":=", "config", ".", "ReadConfigFile", "(", "ccf", ".", "ConfigFile...
// applyConfig takes configuration values from the config file and applies // them to 'service.Config' object
[ "applyConfig", "takes", "configuration", "values", "from", "the", "config", "file", "and", "applies", "them", "to", "service", ".", "Config", "object" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/tool/tctl/common/tctl.go#L167-L197
23,783
gravitational/teleport
lib/limiter/limiter.go
SetEnv
func (l *LimiterConfig) SetEnv(v string) error { if err := json.Unmarshal([]byte(v), l); err != nil { return trace.Wrap(err, "expected JSON encoded remote certificate") } return nil }
go
func (l *LimiterConfig) SetEnv(v string) error { if err := json.Unmarshal([]byte(v), l); err != nil { return trace.Wrap(err, "expected JSON encoded remote certificate") } return nil }
[ "func", "(", "l", "*", "LimiterConfig", ")", "SetEnv", "(", "v", "string", ")", "error", "{", "if", "err", ":=", "json", ".", "Unmarshal", "(", "[", "]", "byte", "(", "v", ")", ",", "l", ")", ";", "err", "!=", "nil", "{", "return", "trace", "."...
// SetEnv reads LimiterConfig from JSON string
[ "SetEnv", "reads", "LimiterConfig", "from", "JSON", "string" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/limiter/limiter.go#L49-L54
23,784
gravitational/teleport
lib/limiter/limiter.go
NewLimiter
func NewLimiter(config LimiterConfig) (*Limiter, error) { var err error limiter := Limiter{} limiter.ConnectionsLimiter, err = NewConnectionsLimiter(config) if err != nil { return nil, trace.Wrap(err) } limiter.rateLimiter, err = NewRateLimiter(config) if err != nil { return nil, trace.Wrap(err) } retur...
go
func NewLimiter(config LimiterConfig) (*Limiter, error) { var err error limiter := Limiter{} limiter.ConnectionsLimiter, err = NewConnectionsLimiter(config) if err != nil { return nil, trace.Wrap(err) } limiter.rateLimiter, err = NewRateLimiter(config) if err != nil { return nil, trace.Wrap(err) } retur...
[ "func", "NewLimiter", "(", "config", "LimiterConfig", ")", "(", "*", "Limiter", ",", "error", ")", "{", "var", "err", "error", "\n", "limiter", ":=", "Limiter", "{", "}", "\n\n", "limiter", ".", "ConnectionsLimiter", ",", "err", "=", "NewConnectionsLimiter",...
// NewLimiter returns new rate and connection limiter
[ "NewLimiter", "returns", "new", "rate", "and", "connection", "limiter" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/limiter/limiter.go#L57-L72
23,785
gravitational/teleport
lib/limiter/limiter.go
WrapHandle
func (l *Limiter) WrapHandle(h http.Handler) { l.rateLimiter.Wrap(h) l.ConnLimiter.Wrap(l.rateLimiter) }
go
func (l *Limiter) WrapHandle(h http.Handler) { l.rateLimiter.Wrap(h) l.ConnLimiter.Wrap(l.rateLimiter) }
[ "func", "(", "l", "*", "Limiter", ")", "WrapHandle", "(", "h", "http", ".", "Handler", ")", "{", "l", ".", "rateLimiter", ".", "Wrap", "(", "h", ")", "\n", "l", ".", "ConnLimiter", ".", "Wrap", "(", "l", ".", "rateLimiter", ")", "\n", "}" ]
// Add limiter to the handle
[ "Add", "limiter", "to", "the", "handle" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/limiter/limiter.go#L79-L82
23,786
gravitational/teleport
lib/web/apiserver.go
SetSessionStreamPollPeriod
func SetSessionStreamPollPeriod(period time.Duration) HandlerOption { return func(h *Handler) error { if period < 0 { return trace.BadParameter("period should be non zero") } h.sessionStreamPollPeriod = period return nil } }
go
func SetSessionStreamPollPeriod(period time.Duration) HandlerOption { return func(h *Handler) error { if period < 0 { return trace.BadParameter("period should be non zero") } h.sessionStreamPollPeriod = period return nil } }
[ "func", "SetSessionStreamPollPeriod", "(", "period", "time", ".", "Duration", ")", "HandlerOption", "{", "return", "func", "(", "h", "*", "Handler", ")", "error", "{", "if", "period", "<", "0", "{", "return", "trace", ".", "BadParameter", "(", "\"", "\"", ...
// SetSessionStreamPollPeriod sets polling period for session streams
[ "SetSessionStreamPollPeriod", "sets", "polling", "period", "for", "session", "streams" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/web/apiserver.go#L79-L87
23,787
gravitational/teleport
lib/web/apiserver.go
getWebConfig
func (h *Handler) getWebConfig(w http.ResponseWriter, r *http.Request, p httprouter.Params) (interface{}, error) { httplib.SetWebConfigHeaders(w.Header()) authProviders := []ui.WebConfigAuthProvider{} secondFactor := teleport.OFF // get all OIDC connectors oidcConnectors, err := h.cfg.ProxyClient.GetOIDCConnecto...
go
func (h *Handler) getWebConfig(w http.ResponseWriter, r *http.Request, p httprouter.Params) (interface{}, error) { httplib.SetWebConfigHeaders(w.Header()) authProviders := []ui.WebConfigAuthProvider{} secondFactor := teleport.OFF // get all OIDC connectors oidcConnectors, err := h.cfg.ProxyClient.GetOIDCConnecto...
[ "func", "(", "h", "*", "Handler", ")", "getWebConfig", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ",", "p", "httprouter", ".", "Params", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "httplib", ".", "...
// getWebConfig returns configuration for the web application.
[ "getWebConfig", "returns", "configuration", "for", "the", "web", "application", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/web/apiserver.go#L577-L659
23,788
gravitational/teleport
lib/web/apiserver.go
ConstructSSHResponse
func ConstructSSHResponse(response AuthParams) (*url.URL, error) { u, err := url.Parse(response.ClientRedirectURL) if err != nil { return nil, trace.Wrap(err) } consoleResponse := auth.SSHLoginResponse{ Username: response.Username, Cert: response.Cert, TLSCert: response.TLSCert, HostSigners:...
go
func ConstructSSHResponse(response AuthParams) (*url.URL, error) { u, err := url.Parse(response.ClientRedirectURL) if err != nil { return nil, trace.Wrap(err) } consoleResponse := auth.SSHLoginResponse{ Username: response.Username, Cert: response.Cert, TLSCert: response.TLSCert, HostSigners:...
[ "func", "ConstructSSHResponse", "(", "response", "AuthParams", ")", "(", "*", "url", ".", "URL", ",", "error", ")", "{", "u", ",", "err", ":=", "url", ".", "Parse", "(", "response", ".", "ClientRedirectURL", ")", "\n", "if", "err", "!=", "nil", "{", ...
// ConstructSSHResponse creates a special SSH response for SSH login method // that encodes everything using the client's secret key
[ "ConstructSSHResponse", "creates", "a", "special", "SSH", "response", "for", "SSH", "login", "method", "that", "encodes", "everything", "using", "the", "client", "s", "secret", "key" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/web/apiserver.go#L901-L967
23,789
gravitational/teleport
lib/web/apiserver.go
queryTime
func queryTime(query url.Values, name string, def time.Time) (time.Time, error) { str := query.Get(name) if str == "" { return def, nil } parsed, err := time.Parse(time.RFC3339, str) if err != nil { return time.Time{}, trace.BadParameter("failed to parse %v as RFC3339 time: %v", name, str) } return parsed, n...
go
func queryTime(query url.Values, name string, def time.Time) (time.Time, error) { str := query.Get(name) if str == "" { return def, nil } parsed, err := time.Parse(time.RFC3339, str) if err != nil { return time.Time{}, trace.BadParameter("failed to parse %v as RFC3339 time: %v", name, str) } return parsed, n...
[ "func", "queryTime", "(", "query", "url", ".", "Values", ",", "name", "string", ",", "def", "time", ".", "Time", ")", "(", "time", ".", "Time", ",", "error", ")", "{", "str", ":=", "query", ".", "Get", "(", "name", ")", "\n", "if", "str", "==", ...
// queryTime parses the query string parameter with the specified name as a // RFC3339 time and returns it. // // If there's no such parameter, specified default value is returned.
[ "queryTime", "parses", "the", "query", "string", "parameter", "with", "the", "specified", "name", "as", "a", "RFC3339", "time", "and", "returns", "it", ".", "If", "there", "s", "no", "such", "parameter", "specified", "default", "value", "is", "returned", "."...
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/web/apiserver.go#L1643-L1653
23,790
gravitational/teleport
lib/web/apiserver.go
queryLimit
func queryLimit(query url.Values, name string, def int) (int, error) { str := query.Get(name) if str == "" { return def, nil } limit, err := strconv.Atoi(str) if err != nil { return 0, trace.BadParameter("failed to parse %v as limit: %v", name, str) } return limit, nil }
go
func queryLimit(query url.Values, name string, def int) (int, error) { str := query.Get(name) if str == "" { return def, nil } limit, err := strconv.Atoi(str) if err != nil { return 0, trace.BadParameter("failed to parse %v as limit: %v", name, str) } return limit, nil }
[ "func", "queryLimit", "(", "query", "url", ".", "Values", ",", "name", "string", ",", "def", "int", ")", "(", "int", ",", "error", ")", "{", "str", ":=", "query", ".", "Get", "(", "name", ")", "\n", "if", "str", "==", "\"", "\"", "{", "return", ...
// queryLimit returns the limit parameter with the specified name from the // query string. // // If there's no such parameter, specified default limit is returned.
[ "queryLimit", "returns", "the", "limit", "parameter", "with", "the", "specified", "name", "from", "the", "query", "string", ".", "If", "there", "s", "no", "such", "parameter", "specified", "default", "limit", "is", "returned", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/web/apiserver.go#L1659-L1669
23,791
gravitational/teleport
lib/web/apiserver.go
hostCredentials
func (h *Handler) hostCredentials(w http.ResponseWriter, r *http.Request, p httprouter.Params) (interface{}, error) { var req auth.RegisterUsingTokenRequest if err := httplib.ReadJSON(r, &req); err != nil { return nil, trace.Wrap(err) } authClient := h.cfg.ProxyClient packedKeys, err := authClient.RegisterUsing...
go
func (h *Handler) hostCredentials(w http.ResponseWriter, r *http.Request, p httprouter.Params) (interface{}, error) { var req auth.RegisterUsingTokenRequest if err := httplib.ReadJSON(r, &req); err != nil { return nil, trace.Wrap(err) } authClient := h.cfg.ProxyClient packedKeys, err := authClient.RegisterUsing...
[ "func", "(", "h", "*", "Handler", ")", "hostCredentials", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ",", "p", "httprouter", ".", "Params", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "var", "req", ...
// hostCredentials sends a registration token and metadata to the Auth Server // and gets back SSH and TLS certificates.
[ "hostCredentials", "sends", "a", "registration", "token", "and", "metadata", "to", "the", "Auth", "Server", "and", "gets", "back", "SSH", "and", "TLS", "certificates", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/web/apiserver.go#L1832-L1845
23,792
gravitational/teleport
lib/web/apiserver.go
WithClusterAuth
func (h *Handler) WithClusterAuth(fn ClusterHandler) httprouter.Handle { return httplib.MakeHandler(func(w http.ResponseWriter, r *http.Request, p httprouter.Params) (interface{}, error) { ctx, err := h.AuthenticateRequest(w, r, true) if err != nil { log.Info(err) // clear session just in case if the authent...
go
func (h *Handler) WithClusterAuth(fn ClusterHandler) httprouter.Handle { return httplib.MakeHandler(func(w http.ResponseWriter, r *http.Request, p httprouter.Params) (interface{}, error) { ctx, err := h.AuthenticateRequest(w, r, true) if err != nil { log.Info(err) // clear session just in case if the authent...
[ "func", "(", "h", "*", "Handler", ")", "WithClusterAuth", "(", "fn", "ClusterHandler", ")", "httprouter", ".", "Handle", "{", "return", "httplib", ".", "MakeHandler", "(", "func", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Requ...
// WithClusterAuth ensures that request is authenticated and is issued for existing cluster
[ "WithClusterAuth", "ensures", "that", "request", "is", "authenticated", "and", "is", "issued", "for", "existing", "cluster" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/web/apiserver.go#L1976-L2003
23,793
gravitational/teleport
lib/web/apiserver.go
WithAuth
func (h *Handler) WithAuth(fn ContextHandler) httprouter.Handle { return httplib.MakeHandler(func(w http.ResponseWriter, r *http.Request, p httprouter.Params) (interface{}, error) { ctx, err := h.AuthenticateRequest(w, r, true) if err != nil { return nil, trace.Wrap(err) } return fn(w, r, p, ctx) }) }
go
func (h *Handler) WithAuth(fn ContextHandler) httprouter.Handle { return httplib.MakeHandler(func(w http.ResponseWriter, r *http.Request, p httprouter.Params) (interface{}, error) { ctx, err := h.AuthenticateRequest(w, r, true) if err != nil { return nil, trace.Wrap(err) } return fn(w, r, p, ctx) }) }
[ "func", "(", "h", "*", "Handler", ")", "WithAuth", "(", "fn", "ContextHandler", ")", "httprouter", ".", "Handle", "{", "return", "httplib", ".", "MakeHandler", "(", "func", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ...
// WithAuth ensures that request is authenticated
[ "WithAuth", "ensures", "that", "request", "is", "authenticated" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/web/apiserver.go#L2006-L2014
23,794
gravitational/teleport
lib/web/apiserver.go
AuthenticateRequest
func (h *Handler) AuthenticateRequest(w http.ResponseWriter, r *http.Request, checkBearerToken bool) (*SessionContext, error) { const missingCookieMsg = "missing session cookie" logger := log.WithFields(log.Fields{ "request": fmt.Sprintf("%v %v", r.Method, r.URL.Path), }) cookie, err := r.Cookie("session") if er...
go
func (h *Handler) AuthenticateRequest(w http.ResponseWriter, r *http.Request, checkBearerToken bool) (*SessionContext, error) { const missingCookieMsg = "missing session cookie" logger := log.WithFields(log.Fields{ "request": fmt.Sprintf("%v %v", r.Method, r.URL.Path), }) cookie, err := r.Cookie("session") if er...
[ "func", "(", "h", "*", "Handler", ")", "AuthenticateRequest", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ",", "checkBearerToken", "bool", ")", "(", "*", "SessionContext", ",", "error", ")", "{", "const", "missingCookieM...
// AuthenticateRequest authenticates request using combination of a session cookie // and bearer token
[ "AuthenticateRequest", "authenticates", "request", "using", "combination", "of", "a", "session", "cookie", "and", "bearer", "token" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/web/apiserver.go#L2018-L2054
23,795
gravitational/teleport
lib/web/apiserver.go
CreateSignupLink
func CreateSignupLink(client auth.ClientI, token string) (string, string) { proxyHost := "<proxyhost>:3080" proxies, err := client.GetProxies() if err != nil { log.Errorf("Unable to retrieve proxy list: %v", err) } if len(proxies) > 0 { proxyHost = proxies[0].GetPublicAddr() if proxyHost == "" { proxyHo...
go
func CreateSignupLink(client auth.ClientI, token string) (string, string) { proxyHost := "<proxyhost>:3080" proxies, err := client.GetProxies() if err != nil { log.Errorf("Unable to retrieve proxy list: %v", err) } if len(proxies) > 0 { proxyHost = proxies[0].GetPublicAddr() if proxyHost == "" { proxyHo...
[ "func", "CreateSignupLink", "(", "client", "auth", ".", "ClientI", ",", "token", "string", ")", "(", "string", ",", "string", ")", "{", "proxyHost", ":=", "\"", "\"", "\n\n", "proxies", ",", "err", ":=", "client", ".", "GetProxies", "(", ")", "\n", "if...
// CreateSignupLink generates and returns a URL which is given to a new // user to complete registration with Teleport via Web UI
[ "CreateSignupLink", "generates", "and", "returns", "a", "URL", "which", "is", "given", "to", "a", "new", "user", "to", "complete", "registration", "with", "Teleport", "via", "Web", "UI" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/web/apiserver.go#L2080-L2102
23,796
gravitational/teleport
lib/web/apiserver.go
makeTeleportClientConfig
func makeTeleportClientConfig(ctx *SessionContext) (*client.Config, error) { agent, cert, err := ctx.GetAgent() if err != nil { return nil, trace.BadParameter("failed to get user credentials: %v", err) } signers, err := agent.Signers() if err != nil { return nil, trace.BadParameter("failed to get user credent...
go
func makeTeleportClientConfig(ctx *SessionContext) (*client.Config, error) { agent, cert, err := ctx.GetAgent() if err != nil { return nil, trace.BadParameter("failed to get user credentials: %v", err) } signers, err := agent.Signers() if err != nil { return nil, trace.BadParameter("failed to get user credent...
[ "func", "makeTeleportClientConfig", "(", "ctx", "*", "SessionContext", ")", "(", "*", "client", ".", "Config", ",", "error", ")", "{", "agent", ",", "cert", ",", "err", ":=", "ctx", ".", "GetAgent", "(", ")", "\n", "if", "err", "!=", "nil", "{", "ret...
// makeTeleportClientConfig creates default teleport client configuration // that is used to initiate an SSH terminal session or SCP file transfer
[ "makeTeleportClientConfig", "creates", "default", "teleport", "client", "configuration", "that", "is", "used", "to", "initiate", "an", "SSH", "terminal", "session", "or", "SCP", "file", "transfer" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/web/apiserver.go#L2114-L2141
23,797
gravitational/teleport
lib/client/keyagent.go
LoadKey
func (a *LocalKeyAgent) LoadKey(key Key) (*agent.AddedKey, error) { agents := []agent.Agent{a.Agent} if a.sshAgent != nil { agents = append(agents, a.sshAgent) } // convert keys into a format understood by the ssh agent agentKeys, err := key.AsAgentKeys() if err != nil { return nil, trace.Wrap(err) } // r...
go
func (a *LocalKeyAgent) LoadKey(key Key) (*agent.AddedKey, error) { agents := []agent.Agent{a.Agent} if a.sshAgent != nil { agents = append(agents, a.sshAgent) } // convert keys into a format understood by the ssh agent agentKeys, err := key.AsAgentKeys() if err != nil { return nil, trace.Wrap(err) } // r...
[ "func", "(", "a", "*", "LocalKeyAgent", ")", "LoadKey", "(", "key", "Key", ")", "(", "*", "agent", ".", "AddedKey", ",", "error", ")", "{", "agents", ":=", "[", "]", "agent", ".", "Agent", "{", "a", ".", "Agent", "}", "\n", "if", "a", ".", "ssh...
// LoadKey adds a key into the Teleport ssh agent as well as the system ssh // agent.
[ "LoadKey", "adds", "a", "key", "into", "the", "Teleport", "ssh", "agent", "as", "well", "as", "the", "system", "ssh", "agent", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/keyagent.go#L123-L154
23,798
gravitational/teleport
lib/client/keyagent.go
UnloadKey
func (a *LocalKeyAgent) UnloadKey() error { agents := []agent.Agent{a.Agent} if a.sshAgent != nil { agents = append(agents, a.sshAgent) } // iterate over all agents we have and unload keys for this user for i, _ := range agents { // get a list of all keys in the agent keyList, err := agents[i].List() if e...
go
func (a *LocalKeyAgent) UnloadKey() error { agents := []agent.Agent{a.Agent} if a.sshAgent != nil { agents = append(agents, a.sshAgent) } // iterate over all agents we have and unload keys for this user for i, _ := range agents { // get a list of all keys in the agent keyList, err := agents[i].List() if e...
[ "func", "(", "a", "*", "LocalKeyAgent", ")", "UnloadKey", "(", ")", "error", "{", "agents", ":=", "[", "]", "agent", ".", "Agent", "{", "a", ".", "Agent", "}", "\n", "if", "a", ".", "sshAgent", "!=", "nil", "{", "agents", "=", "append", "(", "age...
// UnloadKey will unload key for user from the teleport ssh agent as well as // the system agent.
[ "UnloadKey", "will", "unload", "key", "for", "user", "from", "the", "teleport", "ssh", "agent", "as", "well", "as", "the", "system", "agent", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/keyagent.go#L158-L184
23,799
gravitational/teleport
lib/client/keyagent.go
UnloadKeys
func (a *LocalKeyAgent) UnloadKeys() error { agents := []agent.Agent{a.Agent} if a.sshAgent != nil { agents = append(agents, a.sshAgent) } // iterate over all agents we have for i, _ := range agents { // get a list of all keys in the agent keyList, err := agents[i].List() if err != nil { a.log.Warnf("U...
go
func (a *LocalKeyAgent) UnloadKeys() error { agents := []agent.Agent{a.Agent} if a.sshAgent != nil { agents = append(agents, a.sshAgent) } // iterate over all agents we have for i, _ := range agents { // get a list of all keys in the agent keyList, err := agents[i].List() if err != nil { a.log.Warnf("U...
[ "func", "(", "a", "*", "LocalKeyAgent", ")", "UnloadKeys", "(", ")", "error", "{", "agents", ":=", "[", "]", "agent", ".", "Agent", "{", "a", ".", "Agent", "}", "\n", "if", "a", ".", "sshAgent", "!=", "nil", "{", "agents", "=", "append", "(", "ag...
// UnloadKeys will unload all Teleport keys from the teleport agent as well as // the system agent.
[ "UnloadKeys", "will", "unload", "all", "Teleport", "keys", "from", "the", "teleport", "agent", "as", "well", "as", "the", "system", "agent", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/keyagent.go#L188-L214