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
list
docstring
stringlengths
6
2.61k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
85
252
partition
stringclasses
1 value
gravitational/teleport
lib/services/local/users.go
GetSAMLConnector
func (s *IdentityService) GetSAMLConnector(name string, withSecrets bool) (services.SAMLConnector, error) { if name == "" { return nil, trace.BadParameter("missing parameter name") } item, err := s.Get(context.TODO(), backend.Key(webPrefix, connectorsPrefix, samlPrefix, connectorsPrefix, name)) if err != nil { ...
go
func (s *IdentityService) GetSAMLConnector(name string, withSecrets bool) (services.SAMLConnector, error) { if name == "" { return nil, trace.BadParameter("missing parameter name") } item, err := s.Get(context.TODO(), backend.Key(webPrefix, connectorsPrefix, samlPrefix, connectorsPrefix, name)) if err != nil { ...
[ "func", "(", "s", "*", "IdentityService", ")", "GetSAMLConnector", "(", "name", "string", ",", "withSecrets", "bool", ")", "(", "services", ".", "SAMLConnector", ",", "error", ")", "{", "if", "name", "==", "\"", "\"", "{", "return", "nil", ",", "trace", ...
// GetSAMLConnector returns SAML connector data, // withSecrets includes or excludes secrets from return results
[ "GetSAMLConnector", "returns", "SAML", "connector", "data", "withSecrets", "includes", "or", "excludes", "secrets", "from", "return", "results" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/local/users.go#L912-L936
train
gravitational/teleport
lib/services/local/users.go
GetSAMLConnectors
func (s *IdentityService) GetSAMLConnectors(withSecrets bool) ([]services.SAMLConnector, error) { startKey := backend.Key(webPrefix, connectorsPrefix, samlPrefix, connectorsPrefix) result, err := s.GetRange(context.TODO(), startKey, backend.RangeEnd(startKey), backend.NoLimit) if err != nil { return nil, trace.Wra...
go
func (s *IdentityService) GetSAMLConnectors(withSecrets bool) ([]services.SAMLConnector, error) { startKey := backend.Key(webPrefix, connectorsPrefix, samlPrefix, connectorsPrefix) result, err := s.GetRange(context.TODO(), startKey, backend.RangeEnd(startKey), backend.NoLimit) if err != nil { return nil, trace.Wra...
[ "func", "(", "s", "*", "IdentityService", ")", "GetSAMLConnectors", "(", "withSecrets", "bool", ")", "(", "[", "]", "services", ".", "SAMLConnector", ",", "error", ")", "{", "startKey", ":=", "backend", ".", "Key", "(", "webPrefix", ",", "connectorsPrefix", ...
// GetSAMLConnectors returns registered connectors // withSecrets includes or excludes private key values from return results
[ "GetSAMLConnectors", "returns", "registered", "connectors", "withSecrets", "includes", "or", "excludes", "private", "key", "values", "from", "return", "results" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/local/users.go#L940-L963
train
gravitational/teleport
lib/services/local/users.go
CreateSAMLAuthRequest
func (s *IdentityService) CreateSAMLAuthRequest(req services.SAMLAuthRequest, ttl time.Duration) error { if err := req.Check(); err != nil { return trace.Wrap(err) } value, err := json.Marshal(req) if err != nil { return trace.Wrap(err) } item := backend.Item{ Key: backend.Key(webPrefix, connectorsPrefi...
go
func (s *IdentityService) CreateSAMLAuthRequest(req services.SAMLAuthRequest, ttl time.Duration) error { if err := req.Check(); err != nil { return trace.Wrap(err) } value, err := json.Marshal(req) if err != nil { return trace.Wrap(err) } item := backend.Item{ Key: backend.Key(webPrefix, connectorsPrefi...
[ "func", "(", "s", "*", "IdentityService", ")", "CreateSAMLAuthRequest", "(", "req", "services", ".", "SAMLAuthRequest", ",", "ttl", "time", ".", "Duration", ")", "error", "{", "if", "err", ":=", "req", ".", "Check", "(", ")", ";", "err", "!=", "nil", "...
// CreateSAMLAuthRequest creates new auth request
[ "CreateSAMLAuthRequest", "creates", "new", "auth", "request" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/local/users.go#L966-L984
train
gravitational/teleport
lib/services/local/users.go
GetSAMLAuthRequest
func (s *IdentityService) GetSAMLAuthRequest(id string) (*services.SAMLAuthRequest, error) { if id == "" { return nil, trace.BadParameter("missing parameter id") } item, err := s.Get(context.TODO(), backend.Key(webPrefix, connectorsPrefix, samlPrefix, requestsPrefix, id)) if err != nil { return nil, trace.Wrap(...
go
func (s *IdentityService) GetSAMLAuthRequest(id string) (*services.SAMLAuthRequest, error) { if id == "" { return nil, trace.BadParameter("missing parameter id") } item, err := s.Get(context.TODO(), backend.Key(webPrefix, connectorsPrefix, samlPrefix, requestsPrefix, id)) if err != nil { return nil, trace.Wrap(...
[ "func", "(", "s", "*", "IdentityService", ")", "GetSAMLAuthRequest", "(", "id", "string", ")", "(", "*", "services", ".", "SAMLAuthRequest", ",", "error", ")", "{", "if", "id", "==", "\"", "\"", "{", "return", "nil", ",", "trace", ".", "BadParameter", ...
// GetSAMLAuthRequest returns SAML auth request if found
[ "GetSAMLAuthRequest", "returns", "SAML", "auth", "request", "if", "found" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/local/users.go#L987-L1000
train
gravitational/teleport
lib/services/local/users.go
GetGithubConnector
func (s *IdentityService) GetGithubConnector(name string, withSecrets bool) (services.GithubConnector, error) { if name == "" { return nil, trace.BadParameter("missing parameter name") } item, err := s.Get(context.TODO(), backend.Key(webPrefix, connectorsPrefix, githubPrefix, connectorsPrefix, name)) if err != ni...
go
func (s *IdentityService) GetGithubConnector(name string, withSecrets bool) (services.GithubConnector, error) { if name == "" { return nil, trace.BadParameter("missing parameter name") } item, err := s.Get(context.TODO(), backend.Key(webPrefix, connectorsPrefix, githubPrefix, connectorsPrefix, name)) if err != ni...
[ "func", "(", "s", "*", "IdentityService", ")", "GetGithubConnector", "(", "name", "string", ",", "withSecrets", "bool", ")", "(", "services", ".", "GithubConnector", ",", "error", ")", "{", "if", "name", "==", "\"", "\"", "{", "return", "nil", ",", "trac...
// GetGithubConnectot returns a particular Github connector
[ "GetGithubConnectot", "returns", "a", "particular", "Github", "connector" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/local/users.go#L1067-L1086
train
gravitational/teleport
lib/services/local/users.go
DeleteGithubConnector
func (s *IdentityService) DeleteGithubConnector(name string) error { if name == "" { return trace.BadParameter("missing parameter name") } return trace.Wrap(s.Delete(context.TODO(), backend.Key(webPrefix, connectorsPrefix, githubPrefix, connectorsPrefix, name))) }
go
func (s *IdentityService) DeleteGithubConnector(name string) error { if name == "" { return trace.BadParameter("missing parameter name") } return trace.Wrap(s.Delete(context.TODO(), backend.Key(webPrefix, connectorsPrefix, githubPrefix, connectorsPrefix, name))) }
[ "func", "(", "s", "*", "IdentityService", ")", "DeleteGithubConnector", "(", "name", "string", ")", "error", "{", "if", "name", "==", "\"", "\"", "{", "return", "trace", ".", "BadParameter", "(", "\"", "\"", ")", "\n", "}", "\n", "return", "trace", "."...
// DeleteGithubConnector deletes the specified connector
[ "DeleteGithubConnector", "deletes", "the", "specified", "connector" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/local/users.go#L1089-L1094
train
gravitational/teleport
lib/services/local/users.go
CreateGithubAuthRequest
func (s *IdentityService) CreateGithubAuthRequest(req services.GithubAuthRequest) error { err := req.Check() if err != nil { return trace.Wrap(err) } value, err := json.Marshal(req) if err != nil { return trace.Wrap(err) } item := backend.Item{ Key: backend.Key(webPrefix, connectorsPrefix, githubPrefix...
go
func (s *IdentityService) CreateGithubAuthRequest(req services.GithubAuthRequest) error { err := req.Check() if err != nil { return trace.Wrap(err) } value, err := json.Marshal(req) if err != nil { return trace.Wrap(err) } item := backend.Item{ Key: backend.Key(webPrefix, connectorsPrefix, githubPrefix...
[ "func", "(", "s", "*", "IdentityService", ")", "CreateGithubAuthRequest", "(", "req", "services", ".", "GithubAuthRequest", ")", "error", "{", "err", ":=", "req", ".", "Check", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "trace", ".", "Wrap"...
// CreateGithubAuthRequest creates a new auth request for Github OAuth2 flow
[ "CreateGithubAuthRequest", "creates", "a", "new", "auth", "request", "for", "Github", "OAuth2", "flow" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/local/users.go#L1097-L1116
train
gravitational/teleport
lib/services/local/users.go
GetGithubAuthRequest
func (s *IdentityService) GetGithubAuthRequest(stateToken string) (*services.GithubAuthRequest, error) { if stateToken == "" { return nil, trace.BadParameter("missing parameter stateToken") } item, err := s.Get(context.TODO(), backend.Key(webPrefix, connectorsPrefix, githubPrefix, requestsPrefix, stateToken)) if ...
go
func (s *IdentityService) GetGithubAuthRequest(stateToken string) (*services.GithubAuthRequest, error) { if stateToken == "" { return nil, trace.BadParameter("missing parameter stateToken") } item, err := s.Get(context.TODO(), backend.Key(webPrefix, connectorsPrefix, githubPrefix, requestsPrefix, stateToken)) if ...
[ "func", "(", "s", "*", "IdentityService", ")", "GetGithubAuthRequest", "(", "stateToken", "string", ")", "(", "*", "services", ".", "GithubAuthRequest", ",", "error", ")", "{", "if", "stateToken", "==", "\"", "\"", "{", "return", "nil", ",", "trace", ".", ...
// GetGithubAuthRequest retrieves Github auth request by the token
[ "GetGithubAuthRequest", "retrieves", "Github", "auth", "request", "by", "the", "token" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/local/users.go#L1119-L1133
train
gravitational/teleport
lib/services/server.go
ServersToV1
func ServersToV1(in []Server) []ServerV1 { out := make([]ServerV1, len(in)) for i := range in { out[i] = *(in[i].V1()) } return out }
go
func ServersToV1(in []Server) []ServerV1 { out := make([]ServerV1, len(in)) for i := range in { out[i] = *(in[i].V1()) } return out }
[ "func", "ServersToV1", "(", "in", "[", "]", "Server", ")", "[", "]", "ServerV1", "{", "out", ":=", "make", "(", "[", "]", "ServerV1", ",", "len", "(", "in", ")", ")", "\n", "for", "i", ":=", "range", "in", "{", "out", "[", "i", "]", "=", "*",...
// ServersToV1 converts list of servers to slice of V1 style ones
[ "ServersToV1", "converts", "list", "of", "servers", "to", "slice", "of", "V1", "style", "ones" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/server.go#L81-L87
train
gravitational/teleport
lib/services/server.go
GetCmdLabels
func (s *ServerV2) GetCmdLabels() map[string]CommandLabel { if s.Spec.CmdLabels == nil { return nil } out := make(map[string]CommandLabel, len(s.Spec.CmdLabels)) for key := range s.Spec.CmdLabels { val := s.Spec.CmdLabels[key] out[key] = &val } return out }
go
func (s *ServerV2) GetCmdLabels() map[string]CommandLabel { if s.Spec.CmdLabels == nil { return nil } out := make(map[string]CommandLabel, len(s.Spec.CmdLabels)) for key := range s.Spec.CmdLabels { val := s.Spec.CmdLabels[key] out[key] = &val } return out }
[ "func", "(", "s", "*", "ServerV2", ")", "GetCmdLabels", "(", ")", "map", "[", "string", "]", "CommandLabel", "{", "if", "s", ".", "Spec", ".", "CmdLabels", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "out", ":=", "make", "(", "map", "[", ...
// GetCmdLabels returns command labels
[ "GetCmdLabels", "returns", "command", "labels" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/server.go#L232-L242
train
gravitational/teleport
lib/services/server.go
MatchAgainst
func (s *ServerV2) MatchAgainst(labels map[string]string) bool { if labels != nil { myLabels := s.GetAllLabels() for key, value := range labels { if myLabels[key] != value { return false } } } return true }
go
func (s *ServerV2) MatchAgainst(labels map[string]string) bool { if labels != nil { myLabels := s.GetAllLabels() for key, value := range labels { if myLabels[key] != value { return false } } } return true }
[ "func", "(", "s", "*", "ServerV2", ")", "MatchAgainst", "(", "labels", "map", "[", "string", "]", "string", ")", "bool", "{", "if", "labels", "!=", "nil", "{", "myLabels", ":=", "s", ".", "GetAllLabels", "(", ")", "\n", "for", "key", ",", "value", ...
// MatchAgainst takes a map of labels and returns True if this server // has ALL of them // // Any server matches against an empty label set
[ "MatchAgainst", "takes", "a", "map", "of", "labels", "and", "returns", "True", "if", "this", "server", "has", "ALL", "of", "them", "Any", "server", "matches", "against", "an", "empty", "label", "set" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/server.go#L270-L280
train
gravitational/teleport
lib/services/server.go
LabelsString
func (s *ServerV2) LabelsString() string { labels := []string{} for key, val := range s.Metadata.Labels { labels = append(labels, fmt.Sprintf("%s=%s", key, val)) } for key, val := range s.Spec.CmdLabels { labels = append(labels, fmt.Sprintf("%s=%s", key, val.Result)) } sort.Strings(labels) return strings.Joi...
go
func (s *ServerV2) LabelsString() string { labels := []string{} for key, val := range s.Metadata.Labels { labels = append(labels, fmt.Sprintf("%s=%s", key, val)) } for key, val := range s.Spec.CmdLabels { labels = append(labels, fmt.Sprintf("%s=%s", key, val.Result)) } sort.Strings(labels) return strings.Joi...
[ "func", "(", "s", "*", "ServerV2", ")", "LabelsString", "(", ")", "string", "{", "labels", ":=", "[", "]", "string", "{", "}", "\n", "for", "key", ",", "val", ":=", "range", "s", ".", "Metadata", ".", "Labels", "{", "labels", "=", "append", "(", ...
// LabelsString returns a comma separated string with all node's labels
[ "LabelsString", "returns", "a", "comma", "separated", "string", "with", "all", "node", "s", "labels" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/server.go#L283-L293
train
gravitational/teleport
lib/services/server.go
CmdLabelMapsEqual
func CmdLabelMapsEqual(a, b map[string]CommandLabel) bool { if len(a) != len(b) { return false } for key, val := range a { val2, ok := b[key] if !ok { return false } if !val.Equals(val2) { return false } } return true }
go
func CmdLabelMapsEqual(a, b map[string]CommandLabel) bool { if len(a) != len(b) { return false } for key, val := range a { val2, ok := b[key] if !ok { return false } if !val.Equals(val2) { return false } } return true }
[ "func", "CmdLabelMapsEqual", "(", "a", ",", "b", "map", "[", "string", "]", "CommandLabel", ")", "bool", "{", "if", "len", "(", "a", ")", "!=", "len", "(", "b", ")", "{", "return", "false", "\n", "}", "\n", "for", "key", ",", "val", ":=", "range"...
// CmdLabelMapsEqual compares two maps with command labels, // returns true if label sets are equal
[ "CmdLabelMapsEqual", "compares", "two", "maps", "with", "command", "labels", "returns", "true", "if", "label", "sets", "are", "equal" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/server.go#L353-L367
train
gravitational/teleport
lib/services/server.go
LabelsToV2
func LabelsToV2(labels map[string]CommandLabel) map[string]CommandLabelV2 { out := make(map[string]CommandLabelV2, len(labels)) for key, val := range labels { out[key] = CommandLabelV2{ Period: NewDuration(val.GetPeriod()), Result: val.GetResult(), Command: val.GetCommand(), } } return out }
go
func LabelsToV2(labels map[string]CommandLabel) map[string]CommandLabelV2 { out := make(map[string]CommandLabelV2, len(labels)) for key, val := range labels { out[key] = CommandLabelV2{ Period: NewDuration(val.GetPeriod()), Result: val.GetResult(), Command: val.GetCommand(), } } return out }
[ "func", "LabelsToV2", "(", "labels", "map", "[", "string", "]", "CommandLabel", ")", "map", "[", "string", "]", "CommandLabelV2", "{", "out", ":=", "make", "(", "map", "[", "string", "]", "CommandLabelV2", ",", "len", "(", "labels", ")", ")", "\n", "fo...
// LabelsToV2 converts labels from interface to V2 spec
[ "LabelsToV2", "converts", "labels", "from", "interface", "to", "V2", "spec" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/server.go#L449-L459
train
gravitational/teleport
lib/services/server.go
Equals
func (c *CommandLabelV2) Equals(other CommandLabel) bool { if c.GetPeriod() != other.GetPeriod() { return false } if c.GetResult() != other.GetResult() { return false } if !utils.StringSlicesEqual(c.GetCommand(), other.GetCommand()) { return false } return true }
go
func (c *CommandLabelV2) Equals(other CommandLabel) bool { if c.GetPeriod() != other.GetPeriod() { return false } if c.GetResult() != other.GetResult() { return false } if !utils.StringSlicesEqual(c.GetCommand(), other.GetCommand()) { return false } return true }
[ "func", "(", "c", "*", "CommandLabelV2", ")", "Equals", "(", "other", "CommandLabel", ")", "bool", "{", "if", "c", ".", "GetPeriod", "(", ")", "!=", "other", ".", "GetPeriod", "(", ")", "{", "return", "false", "\n", "}", "\n", "if", "c", ".", "GetR...
// Equals returns true if labels are equal, false otherwise
[ "Equals", "returns", "true", "if", "labels", "are", "equal", "false", "otherwise" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/server.go#L482-L493
train
gravitational/teleport
lib/services/server.go
Clone
func (c *CommandLabelV2) Clone() CommandLabel { command := make([]string, len(c.Command)) copy(command, c.Command) return &CommandLabelV2{ Command: command, Period: c.Period, Result: c.Result, } }
go
func (c *CommandLabelV2) Clone() CommandLabel { command := make([]string, len(c.Command)) copy(command, c.Command) return &CommandLabelV2{ Command: command, Period: c.Period, Result: c.Result, } }
[ "func", "(", "c", "*", "CommandLabelV2", ")", "Clone", "(", ")", "CommandLabel", "{", "command", ":=", "make", "(", "[", "]", "string", ",", "len", "(", "c", ".", "Command", ")", ")", "\n", "copy", "(", "command", ",", "c", ".", "Command", ")", "...
// Clone returns non-shallow copy of the label
[ "Clone", "returns", "non", "-", "shallow", "copy", "of", "the", "label" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/server.go#L496-L504
train
gravitational/teleport
lib/services/server.go
SetPeriod
func (c *CommandLabelV2) SetPeriod(p time.Duration) { c.Period = Duration(p) }
go
func (c *CommandLabelV2) SetPeriod(p time.Duration) { c.Period = Duration(p) }
[ "func", "(", "c", "*", "CommandLabelV2", ")", "SetPeriod", "(", "p", "time", ".", "Duration", ")", "{", "c", ".", "Period", "=", "Duration", "(", "p", ")", "\n", "}" ]
// SetPeriod sets label period
[ "SetPeriod", "sets", "label", "period" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/server.go#L512-L514
train
gravitational/teleport
lib/services/server.go
Clone
func (c *CommandLabels) Clone() CommandLabels { out := make(CommandLabels, len(*c)) for name, label := range *c { out[name] = label.Clone() } return out }
go
func (c *CommandLabels) Clone() CommandLabels { out := make(CommandLabels, len(*c)) for name, label := range *c { out[name] = label.Clone() } return out }
[ "func", "(", "c", "*", "CommandLabels", ")", "Clone", "(", ")", "CommandLabels", "{", "out", ":=", "make", "(", "CommandLabels", ",", "len", "(", "*", "c", ")", ")", "\n", "for", "name", ",", "label", ":=", "range", "*", "c", "{", "out", "[", "na...
// Clone returns copy of the set
[ "Clone", "returns", "copy", "of", "the", "set" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/server.go#L546-L552
train
gravitational/teleport
lib/services/server.go
SetEnv
func (c *CommandLabels) SetEnv(v string) error { if err := json.Unmarshal([]byte(v), c); err != nil { return trace.Wrap(err, "can not parse Command Labels") } return nil }
go
func (c *CommandLabels) SetEnv(v string) error { if err := json.Unmarshal([]byte(v), c); err != nil { return trace.Wrap(err, "can not parse Command Labels") } return nil }
[ "func", "(", "c", "*", "CommandLabels", ")", "SetEnv", "(", "v", "string", ")", "error", "{", "if", "err", ":=", "json", ".", "Unmarshal", "(", "[", "]", "byte", "(", "v", ")", ",", "c", ")", ";", "err", "!=", "nil", "{", "return", "trace", "."...
// SetEnv sets the value of the label from environment variable
[ "SetEnv", "sets", "the", "value", "of", "the", "label", "from", "environment", "variable" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/server.go#L555-L560
train
gravitational/teleport
lib/services/server.go
GetServerSchema
func GetServerSchema() string { return fmt.Sprintf(V2SchemaTemplate, MetadataSchema, fmt.Sprintf(ServerSpecV2Schema, RotationSchema), DefaultDefinitions) }
go
func GetServerSchema() string { return fmt.Sprintf(V2SchemaTemplate, MetadataSchema, fmt.Sprintf(ServerSpecV2Schema, RotationSchema), DefaultDefinitions) }
[ "func", "GetServerSchema", "(", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "V2SchemaTemplate", ",", "MetadataSchema", ",", "fmt", ".", "Sprintf", "(", "ServerSpecV2Schema", ",", "RotationSchema", ")", ",", "DefaultDefinitions", ")", "\n", "}" ]
// GetServerSchema returns role schema with optionally injected // schema for extensions
[ "GetServerSchema", "returns", "role", "schema", "with", "optionally", "injected", "schema", "for", "extensions" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/server.go#L564-L566
train
gravitational/teleport
lib/services/server.go
UnmarshalServerResource
func UnmarshalServerResource(data []byte, kind string, cfg *MarshalConfig) (Server, error) { if len(data) == 0 { return nil, trace.BadParameter("missing server data") } var h ResourceHeader err := utils.FastUnmarshal(data, &h) if err != nil { return nil, trace.Wrap(err) } switch h.Version { case "": var...
go
func UnmarshalServerResource(data []byte, kind string, cfg *MarshalConfig) (Server, error) { if len(data) == 0 { return nil, trace.BadParameter("missing server data") } var h ResourceHeader err := utils.FastUnmarshal(data, &h) if err != nil { return nil, trace.Wrap(err) } switch h.Version { case "": var...
[ "func", "UnmarshalServerResource", "(", "data", "[", "]", "byte", ",", "kind", "string", ",", "cfg", "*", "MarshalConfig", ")", "(", "Server", ",", "error", ")", "{", "if", "len", "(", "data", ")", "==", "0", "{", "return", "nil", ",", "trace", ".", ...
// UnmarshalServerResource unmarshals role from JSON or YAML, // sets defaults and checks the schema
[ "UnmarshalServerResource", "unmarshals", "role", "from", "JSON", "or", "YAML", "sets", "defaults", "and", "checks", "the", "schema" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/server.go#L570-L622
train
gravitational/teleport
lib/services/server.go
UnmarshalServer
func (*TeleportServerMarshaler) UnmarshalServer(bytes []byte, kind string, opts ...MarshalOption) (Server, error) { cfg, err := collectOptions(opts) if err != nil { return nil, trace.Wrap(err) } return UnmarshalServerResource(bytes, kind, cfg) }
go
func (*TeleportServerMarshaler) UnmarshalServer(bytes []byte, kind string, opts ...MarshalOption) (Server, error) { cfg, err := collectOptions(opts) if err != nil { return nil, trace.Wrap(err) } return UnmarshalServerResource(bytes, kind, cfg) }
[ "func", "(", "*", "TeleportServerMarshaler", ")", "UnmarshalServer", "(", "bytes", "[", "]", "byte", ",", "kind", "string", ",", "opts", "...", "MarshalOption", ")", "(", "Server", ",", "error", ")", "{", "cfg", ",", "err", ":=", "collectOptions", "(", "...
// UnmarshalServer unmarshals server from JSON
[ "UnmarshalServer", "unmarshals", "server", "from", "JSON" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/server.go#L659-L666
train
gravitational/teleport
lib/services/server.go
MarshalServer
func (*TeleportServerMarshaler) MarshalServer(s Server, opts ...MarshalOption) ([]byte, error) { cfg, err := collectOptions(opts) if err != nil { return nil, trace.Wrap(err) } type serverv1 interface { V1() *ServerV1 } type serverv2 interface { V2() *ServerV2 } version := cfg.GetVersion() switch version ...
go
func (*TeleportServerMarshaler) MarshalServer(s Server, opts ...MarshalOption) ([]byte, error) { cfg, err := collectOptions(opts) if err != nil { return nil, trace.Wrap(err) } type serverv1 interface { V1() *ServerV1 } type serverv2 interface { V2() *ServerV2 } version := cfg.GetVersion() switch version ...
[ "func", "(", "*", "TeleportServerMarshaler", ")", "MarshalServer", "(", "s", "Server", ",", "opts", "...", "MarshalOption", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "cfg", ",", "err", ":=", "collectOptions", "(", "opts", ")", "\n", "if", "er...
// MarshalServer marshals server into JSON.
[ "MarshalServer", "marshals", "server", "into", "JSON", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/server.go#L669-L705
train
gravitational/teleport
lib/services/server.go
UnmarshalServers
func (*TeleportServerMarshaler) UnmarshalServers(bytes []byte) ([]Server, error) { var servers []ServerV2 err := utils.FastUnmarshal(bytes, &servers) if err != nil { return nil, trace.Wrap(err) } out := make([]Server, len(servers)) for i, v := range servers { out[i] = Server(&v) } return out, nil }
go
func (*TeleportServerMarshaler) UnmarshalServers(bytes []byte) ([]Server, error) { var servers []ServerV2 err := utils.FastUnmarshal(bytes, &servers) if err != nil { return nil, trace.Wrap(err) } out := make([]Server, len(servers)) for i, v := range servers { out[i] = Server(&v) } return out, nil }
[ "func", "(", "*", "TeleportServerMarshaler", ")", "UnmarshalServers", "(", "bytes", "[", "]", "byte", ")", "(", "[", "]", "Server", ",", "error", ")", "{", "var", "servers", "[", "]", "ServerV2", "\n\n", "err", ":=", "utils", ".", "FastUnmarshal", "(", ...
// UnmarshalServers is used to unmarshal multiple servers from their // binary representation.
[ "UnmarshalServers", "is", "used", "to", "unmarshal", "multiple", "servers", "from", "their", "binary", "representation", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/server.go#L709-L722
train
gravitational/teleport
lib/services/server.go
MarshalServers
func (*TeleportServerMarshaler) MarshalServers(s []Server) ([]byte, error) { bytes, err := utils.FastMarshal(s) if err != nil { return nil, trace.Wrap(err) } return bytes, nil }
go
func (*TeleportServerMarshaler) MarshalServers(s []Server) ([]byte, error) { bytes, err := utils.FastMarshal(s) if err != nil { return nil, trace.Wrap(err) } return bytes, nil }
[ "func", "(", "*", "TeleportServerMarshaler", ")", "MarshalServers", "(", "s", "[", "]", "Server", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "bytes", ",", "err", ":=", "utils", ".", "FastMarshal", "(", "s", ")", "\n", "if", "err", "!=", "n...
// MarshalServers is used to marshal multiple servers to their binary // representation.
[ "MarshalServers", "is", "used", "to", "marshal", "multiple", "servers", "to", "their", "binary", "representation", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/server.go#L726-L733
train
gravitational/teleport
lib/web/ui/cluster.go
NewAvailableClusters
func NewAvailableClusters(currentClusterName string, remoteClusters []reversetunnel.RemoteSite) *AvailableClusters { out := AvailableClusters{} for _, item := range remoteClusters { cluster := Cluster{ Name: item.GetName(), LastConnected: item.GetLastConnected(), Status: item.GetStatus(), ...
go
func NewAvailableClusters(currentClusterName string, remoteClusters []reversetunnel.RemoteSite) *AvailableClusters { out := AvailableClusters{} for _, item := range remoteClusters { cluster := Cluster{ Name: item.GetName(), LastConnected: item.GetLastConnected(), Status: item.GetStatus(), ...
[ "func", "NewAvailableClusters", "(", "currentClusterName", "string", ",", "remoteClusters", "[", "]", "reversetunnel", ".", "RemoteSite", ")", "*", "AvailableClusters", "{", "out", ":=", "AvailableClusters", "{", "}", "\n", "for", "_", ",", "item", ":=", "range"...
// NewAvailableClusters returns all available clusters
[ "NewAvailableClusters", "returns", "all", "available", "clusters" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/web/ui/cluster.go#L45-L66
train
gravitational/teleport
lib/backend/legacy/import.go
Import
func Import(ctx context.Context, importer Importer, newExporter NewExporterFunc) error { log := logrus.WithFields(logrus.Fields{ trace.Component: teleport.Component(teleport.ComponentMigrate), }) err := func() error { imported, err := importer.Imported(ctx) if err != nil { return trace.Wrap(err) } if im...
go
func Import(ctx context.Context, importer Importer, newExporter NewExporterFunc) error { log := logrus.WithFields(logrus.Fields{ trace.Component: teleport.Component(teleport.ComponentMigrate), }) err := func() error { imported, err := importer.Imported(ctx) if err != nil { return trace.Wrap(err) } if im...
[ "func", "Import", "(", "ctx", "context", ".", "Context", ",", "importer", "Importer", ",", "newExporter", "NewExporterFunc", ")", "error", "{", "log", ":=", "logrus", ".", "WithFields", "(", "logrus", ".", "Fields", "{", "trace", ".", "Component", ":", "te...
// Import imports backend data into importer unless importer has already // imported data. If Importer has no imported data yet, exporter will // not be initialized. This function can be called many times on the // same importer. Importer will be closed if import has failed.
[ "Import", "imports", "backend", "data", "into", "importer", "unless", "importer", "has", "already", "imported", "data", ".", "If", "Importer", "has", "no", "imported", "data", "yet", "exporter", "will", "not", "be", "initialized", ".", "This", "function", "can...
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/backend/legacy/import.go#L39-L74
train
gravitational/teleport
lib/service/info.go
writeDebugInfo
func writeDebugInfo(w io.Writer) { fmt.Fprintf(w, "Runtime stats\n") runtimeStats(w) fmt.Fprintf(w, "Memory stats\n") memStats(w) fmt.Fprintf(w, "Goroutines\n") goroutineDump(w) }
go
func writeDebugInfo(w io.Writer) { fmt.Fprintf(w, "Runtime stats\n") runtimeStats(w) fmt.Fprintf(w, "Memory stats\n") memStats(w) fmt.Fprintf(w, "Goroutines\n") goroutineDump(w) }
[ "func", "writeDebugInfo", "(", "w", "io", ".", "Writer", ")", "{", "fmt", ".", "Fprintf", "(", "w", ",", "\"", "\\n", "\"", ")", "\n", "runtimeStats", "(", "w", ")", "\n\n", "fmt", ".", "Fprintf", "(", "w", ",", "\"", "\\n", "\"", ")", "\n", "m...
// writeDebugInfo writes debugging information // about this process
[ "writeDebugInfo", "writes", "debugging", "information", "about", "this", "process" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/service/info.go#L33-L42
train
gravitational/teleport
lib/multiplexer/wrappers.go
Read
func (c *Conn) Read(p []byte) (int, error) { return c.reader.Read(p) }
go
func (c *Conn) Read(p []byte) (int, error) { return c.reader.Read(p) }
[ "func", "(", "c", "*", "Conn", ")", "Read", "(", "p", "[", "]", "byte", ")", "(", "int", ",", "error", ")", "{", "return", "c", ".", "reader", ".", "Read", "(", "p", ")", "\n", "}" ]
// Read reads from connection
[ "Read", "reads", "from", "connection" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/multiplexer/wrappers.go#L39-L41
train
gravitational/teleport
lib/multiplexer/wrappers.go
LocalAddr
func (c *Conn) LocalAddr() net.Addr { if c.proxyLine != nil { return &c.proxyLine.Destination } return c.Conn.LocalAddr() }
go
func (c *Conn) LocalAddr() net.Addr { if c.proxyLine != nil { return &c.proxyLine.Destination } return c.Conn.LocalAddr() }
[ "func", "(", "c", "*", "Conn", ")", "LocalAddr", "(", ")", "net", ".", "Addr", "{", "if", "c", ".", "proxyLine", "!=", "nil", "{", "return", "&", "c", ".", "proxyLine", ".", "Destination", "\n", "}", "\n", "return", "c", ".", "Conn", ".", "LocalA...
// LocalAddr returns local address of the connection
[ "LocalAddr", "returns", "local", "address", "of", "the", "connection" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/multiplexer/wrappers.go#L44-L49
train
gravitational/teleport
lib/multiplexer/wrappers.go
RemoteAddr
func (c *Conn) RemoteAddr() net.Addr { if c.proxyLine != nil { return &c.proxyLine.Source } return c.Conn.RemoteAddr() }
go
func (c *Conn) RemoteAddr() net.Addr { if c.proxyLine != nil { return &c.proxyLine.Source } return c.Conn.RemoteAddr() }
[ "func", "(", "c", "*", "Conn", ")", "RemoteAddr", "(", ")", "net", ".", "Addr", "{", "if", "c", ".", "proxyLine", "!=", "nil", "{", "return", "&", "c", ".", "proxyLine", ".", "Source", "\n", "}", "\n", "return", "c", ".", "Conn", ".", "RemoteAddr...
// RemoteAddr returns remote address of the connection
[ "RemoteAddr", "returns", "remote", "address", "of", "the", "connection" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/multiplexer/wrappers.go#L52-L57
train
gravitational/teleport
lib/multiplexer/wrappers.go
Accept
func (l *Listener) Accept() (net.Conn, error) { select { case <-l.context.Done(): return nil, trace.ConnectionProblem(nil, "listener is closed") case conn := <-l.connC: if conn == nil { return nil, trace.ConnectionProblem(nil, "listener is closed") } return conn, nil } }
go
func (l *Listener) Accept() (net.Conn, error) { select { case <-l.context.Done(): return nil, trace.ConnectionProblem(nil, "listener is closed") case conn := <-l.connC: if conn == nil { return nil, trace.ConnectionProblem(nil, "listener is closed") } return conn, nil } }
[ "func", "(", "l", "*", "Listener", ")", "Accept", "(", ")", "(", "net", ".", "Conn", ",", "error", ")", "{", "select", "{", "case", "<-", "l", ".", "context", ".", "Done", "(", ")", ":", "return", "nil", ",", "trace", ".", "ConnectionProblem", "(...
// Accept accepts connections from parent multiplexer listener
[ "Accept", "accepts", "connections", "from", "parent", "multiplexer", "listener" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/multiplexer/wrappers.go#L84-L94
train
gravitational/teleport
lib/services/identity.go
Equals
func (i *ExternalIdentity) Equals(other *ExternalIdentity) bool { return i.ConnectorID == other.ConnectorID && i.Username == other.Username }
go
func (i *ExternalIdentity) Equals(other *ExternalIdentity) bool { return i.ConnectorID == other.ConnectorID && i.Username == other.Username }
[ "func", "(", "i", "*", "ExternalIdentity", ")", "Equals", "(", "other", "*", "ExternalIdentity", ")", "bool", "{", "return", "i", ".", "ConnectorID", "==", "other", ".", "ConnectorID", "&&", "i", ".", "Username", "==", "other", ".", "Username", "\n", "}"...
// Equals returns true if this identity equals to passed one
[ "Equals", "returns", "true", "if", "this", "identity", "equals", "to", "passed", "one" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/identity.go#L257-L259
train
gravitational/teleport
lib/services/identity.go
Check
func (r *GithubAuthRequest) Check() error { if r.ConnectorID == "" { return trace.BadParameter("missing ConnectorID") } if r.StateToken == "" { return trace.BadParameter("missing StateToken") } if len(r.PublicKey) != 0 { _, _, _, _, err := ssh.ParseAuthorizedKey(r.PublicKey) if err != nil { return trace...
go
func (r *GithubAuthRequest) Check() error { if r.ConnectorID == "" { return trace.BadParameter("missing ConnectorID") } if r.StateToken == "" { return trace.BadParameter("missing StateToken") } if len(r.PublicKey) != 0 { _, _, _, _, err := ssh.ParseAuthorizedKey(r.PublicKey) if err != nil { return trace...
[ "func", "(", "r", "*", "GithubAuthRequest", ")", "Check", "(", ")", "error", "{", "if", "r", ".", "ConnectorID", "==", "\"", "\"", "{", "return", "trace", ".", "BadParameter", "(", "\"", "\"", ")", "\n", "}", "\n", "if", "r", ".", "StateToken", "==...
// Check makes sure the request is valid
[ "Check", "makes", "sure", "the", "request", "is", "valid" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/identity.go#L320-L337
train
gravitational/teleport
lib/services/identity.go
Swap
func (s SortedLoginAttempts) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
go
func (s SortedLoginAttempts) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
[ "func", "(", "s", "SortedLoginAttempts", ")", "Swap", "(", "i", ",", "j", "int", ")", "{", "s", "[", "i", "]", ",", "s", "[", "j", "]", "=", "s", "[", "j", "]", ",", "s", "[", "i", "]", "\n", "}" ]
// Swap swaps two attempts
[ "Swap", "swaps", "two", "attempts" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/identity.go#L491-L493
train
gravitational/teleport
lib/services/identity.go
LastFailed
func LastFailed(x int, attempts []LoginAttempt) bool { var failed int for i := len(attempts) - 1; i >= 0; i-- { if !attempts[i].Success { failed++ } else { return false } if failed >= x { return true } } return false }
go
func LastFailed(x int, attempts []LoginAttempt) bool { var failed int for i := len(attempts) - 1; i >= 0; i-- { if !attempts[i].Success { failed++ } else { return false } if failed >= x { return true } } return false }
[ "func", "LastFailed", "(", "x", "int", ",", "attempts", "[", "]", "LoginAttempt", ")", "bool", "{", "var", "failed", "int", "\n", "for", "i", ":=", "len", "(", "attempts", ")", "-", "1", ";", "i", ">=", "0", ";", "i", "--", "{", "if", "!", "att...
// LastFailed calculates last x successive attempts are failed
[ "LastFailed", "calculates", "last", "x", "successive", "attempts", "are", "failed" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/identity.go#L496-L509
train
gravitational/teleport
lib/web/terminal.go
NewTerminal
func NewTerminal(req TerminalRequest, authProvider AuthProvider, ctx *SessionContext) (*TerminalHandler, error) { // Make sure whatever session is requested is a valid session. _, err := session.ParseID(string(req.SessionID)) if err != nil { return nil, trace.BadParameter("sid: invalid session id") } if req.Lo...
go
func NewTerminal(req TerminalRequest, authProvider AuthProvider, ctx *SessionContext) (*TerminalHandler, error) { // Make sure whatever session is requested is a valid session. _, err := session.ParseID(string(req.SessionID)) if err != nil { return nil, trace.BadParameter("sid: invalid session id") } if req.Lo...
[ "func", "NewTerminal", "(", "req", "TerminalRequest", ",", "authProvider", "AuthProvider", ",", "ctx", "*", "SessionContext", ")", "(", "*", "TerminalHandler", ",", "error", ")", "{", "// Make sure whatever session is requested is a valid session.", "_", ",", "err", "...
// NewTerminal creates a web-based terminal based on WebSockets and returns a // new TerminalHandler.
[ "NewTerminal", "creates", "a", "web", "-", "based", "terminal", "based", "on", "WebSockets", "and", "returns", "a", "new", "TerminalHandler", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/web/terminal.go#L84-L121
train
gravitational/teleport
lib/web/terminal.go
Close
func (t *TerminalHandler) Close() error { // Close the websocket connection to the client web browser. if t.ws != nil { t.ws.Close() } // Close the SSH connection to the remote node. if t.sshSession != nil { t.sshSession.Close() } // If the terminal handler was closed (most likely due to the *SessionContex...
go
func (t *TerminalHandler) Close() error { // Close the websocket connection to the client web browser. if t.ws != nil { t.ws.Close() } // Close the SSH connection to the remote node. if t.sshSession != nil { t.sshSession.Close() } // If the terminal handler was closed (most likely due to the *SessionContex...
[ "func", "(", "t", "*", "TerminalHandler", ")", "Close", "(", ")", "error", "{", "// Close the websocket connection to the client web browser.", "if", "t", ".", "ws", "!=", "nil", "{", "t", ".", "ws", ".", "Close", "(", ")", "\n", "}", "\n\n", "// Close the S...
// Close the websocket stream.
[ "Close", "the", "websocket", "stream", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/web/terminal.go#L191-L207
train
gravitational/teleport
lib/web/terminal.go
handler
func (t *TerminalHandler) handler(ws *websocket.Conn) { // Create a Teleport client, if not able to, show the reason to the user in // the terminal. tc, err := t.makeClient(ws) if err != nil { er := t.writeError(err, ws) if er != nil { t.log.Warnf("Unable to send error to terminal: %v: %v.", err, er) } r...
go
func (t *TerminalHandler) handler(ws *websocket.Conn) { // Create a Teleport client, if not able to, show the reason to the user in // the terminal. tc, err := t.makeClient(ws) if err != nil { er := t.writeError(err, ws) if er != nil { t.log.Warnf("Unable to send error to terminal: %v: %v.", err, er) } r...
[ "func", "(", "t", "*", "TerminalHandler", ")", "handler", "(", "ws", "*", "websocket", ".", "Conn", ")", "{", "// Create a Teleport client, if not able to, show the reason to the user in", "// the terminal.", "tc", ",", "err", ":=", "t", ".", "makeClient", "(", "ws"...
// handler is the main websocket loop. It creates a Teleport client and then // pumps raw events and audit events back to the client until the SSH session // is complete.
[ "handler", "is", "the", "main", "websocket", "loop", ".", "It", "creates", "a", "Teleport", "client", "and", "then", "pumps", "raw", "events", "and", "audit", "events", "back", "to", "the", "client", "until", "the", "SSH", "session", "is", "complete", "." ...
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/web/terminal.go#L212-L236
train
gravitational/teleport
lib/web/terminal.go
streamTerminal
func (t *TerminalHandler) streamTerminal(ws *websocket.Conn, tc *client.TeleportClient) { defer t.terminalCancel() // Establish SSH connection to the server. This function will block until // either an error occurs or it completes successfully. err := tc.SSH(t.terminalContext, t.params.InteractiveCommand, false) ...
go
func (t *TerminalHandler) streamTerminal(ws *websocket.Conn, tc *client.TeleportClient) { defer t.terminalCancel() // Establish SSH connection to the server. This function will block until // either an error occurs or it completes successfully. err := tc.SSH(t.terminalContext, t.params.InteractiveCommand, false) ...
[ "func", "(", "t", "*", "TerminalHandler", ")", "streamTerminal", "(", "ws", "*", "websocket", ".", "Conn", ",", "tc", "*", "client", ".", "TeleportClient", ")", "{", "defer", "t", ".", "terminalCancel", "(", ")", "\n\n", "// Establish SSH connection to the ser...
// streamTerminal opens a SSH connection to the remote host and streams // events back to the web client.
[ "streamTerminal", "opens", "a", "SSH", "connection", "to", "the", "remote", "host", "and", "streams", "events", "back", "to", "the", "web", "client", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/web/terminal.go#L288-L320
train
gravitational/teleport
lib/web/terminal.go
streamEvents
func (t *TerminalHandler) streamEvents(ws *websocket.Conn, tc *client.TeleportClient) { for { select { // Send push events that come over the events channel to the web client. case event := <-tc.EventsChannel(): data, err := json.Marshal(event) if err != nil { t.log.Errorf("Unable to marshal audit even...
go
func (t *TerminalHandler) streamEvents(ws *websocket.Conn, tc *client.TeleportClient) { for { select { // Send push events that come over the events channel to the web client. case event := <-tc.EventsChannel(): data, err := json.Marshal(event) if err != nil { t.log.Errorf("Unable to marshal audit even...
[ "func", "(", "t", "*", "TerminalHandler", ")", "streamEvents", "(", "ws", "*", "websocket", ".", "Conn", ",", "tc", "*", "client", ".", "TeleportClient", ")", "{", "for", "{", "select", "{", "// Send push events that come over the events channel to the web client.",...
// streamEvents receives events over the SSH connection and forwards them to // the web client.
[ "streamEvents", "receives", "events", "over", "the", "SSH", "connection", "and", "forwards", "them", "to", "the", "web", "client", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/web/terminal.go#L324-L366
train
gravitational/teleport
lib/web/terminal.go
windowChange
func (t *TerminalHandler) windowChange(params *session.TerminalParams) error { if t.sshSession == nil { return nil } _, err := t.sshSession.SendRequest( sshutils.WindowChangeRequest, false, ssh.Marshal(sshutils.WinChangeReqParams{ W: uint32(params.W), H: uint32(params.H), })) if err != nil { t.lo...
go
func (t *TerminalHandler) windowChange(params *session.TerminalParams) error { if t.sshSession == nil { return nil } _, err := t.sshSession.SendRequest( sshutils.WindowChangeRequest, false, ssh.Marshal(sshutils.WinChangeReqParams{ W: uint32(params.W), H: uint32(params.H), })) if err != nil { t.lo...
[ "func", "(", "t", "*", "TerminalHandler", ")", "windowChange", "(", "params", "*", "session", ".", "TerminalParams", ")", "error", "{", "if", "t", ".", "sshSession", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "_", ",", "err", ":=", "t", "....
// windowChange is called when the browser window is resized. It sends a // "window-change" channel request to the server.
[ "windowChange", "is", "called", "when", "the", "browser", "window", "is", "resized", ".", "It", "sends", "a", "window", "-", "change", "channel", "request", "to", "the", "server", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/web/terminal.go#L370-L387
train
gravitational/teleport
lib/web/terminal.go
writeError
func (t *TerminalHandler) writeError(err error, ws *websocket.Conn) error { // Replace \n with \r\n so the message correctly aligned. r := strings.NewReplacer("\r\n", "\r\n", "\n", "\r\n") errMessage := r.Replace(err.Error()) _, err = t.write([]byte(errMessage), ws) if err != nil { return trace.Wrap(err) } re...
go
func (t *TerminalHandler) writeError(err error, ws *websocket.Conn) error { // Replace \n with \r\n so the message correctly aligned. r := strings.NewReplacer("\r\n", "\r\n", "\n", "\r\n") errMessage := r.Replace(err.Error()) _, err = t.write([]byte(errMessage), ws) if err != nil { return trace.Wrap(err) } re...
[ "func", "(", "t", "*", "TerminalHandler", ")", "writeError", "(", "err", "error", ",", "ws", "*", "websocket", ".", "Conn", ")", "error", "{", "// Replace \\n with \\r\\n so the message correctly aligned.", "r", ":=", "strings", ".", "NewReplacer", "(", "\"", "\...
// writeError displays an error in the terminal window.
[ "writeError", "displays", "an", "error", "in", "the", "terminal", "window", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/web/terminal.go#L390-L400
train
gravitational/teleport
lib/web/terminal.go
resolveServerHostPort
func resolveServerHostPort(servername string, existingServers []services.Server) (string, int, error) { // If port is 0, client wants us to figure out which port to use. var defaultPort = 0 if servername == "" { return "", defaultPort, trace.BadParameter("empty server name") } // Check if servername is UUID. ...
go
func resolveServerHostPort(servername string, existingServers []services.Server) (string, int, error) { // If port is 0, client wants us to figure out which port to use. var defaultPort = 0 if servername == "" { return "", defaultPort, trace.BadParameter("empty server name") } // Check if servername is UUID. ...
[ "func", "resolveServerHostPort", "(", "servername", "string", ",", "existingServers", "[", "]", "services", ".", "Server", ")", "(", "string", ",", "int", ",", "error", ")", "{", "// If port is 0, client wants us to figure out which port to use.", "var", "defaultPort", ...
// resolveServerHostPort parses server name and attempts to resolve hostname // and port.
[ "resolveServerHostPort", "parses", "server", "name", "and", "attempts", "to", "resolve", "hostname", "and", "port", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/web/terminal.go#L404-L436
train
gravitational/teleport
lib/web/terminal.go
Write
func (w *terminalStream) Write(data []byte) (n int, err error) { return w.terminal.write(data, w.ws) }
go
func (w *terminalStream) Write(data []byte) (n int, err error) { return w.terminal.write(data, w.ws) }
[ "func", "(", "w", "*", "terminalStream", ")", "Write", "(", "data", "[", "]", "byte", ")", "(", "n", "int", ",", "err", "error", ")", "{", "return", "w", ".", "terminal", ".", "write", "(", "data", ",", "w", ".", "ws", ")", "\n", "}" ]
// Write wraps the data bytes in a raw envelope and sends.
[ "Write", "wraps", "the", "data", "bytes", "in", "a", "raw", "envelope", "and", "sends", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/web/terminal.go#L544-L546
train
gravitational/teleport
lib/web/terminal.go
SetReadDeadline
func (w *terminalStream) SetReadDeadline(t time.Time) error { return w.ws.SetReadDeadline(t) }
go
func (w *terminalStream) SetReadDeadline(t time.Time) error { return w.ws.SetReadDeadline(t) }
[ "func", "(", "w", "*", "terminalStream", ")", "SetReadDeadline", "(", "t", "time", ".", "Time", ")", "error", "{", "return", "w", ".", "ws", ".", "SetReadDeadline", "(", "t", ")", "\n", "}" ]
// SetReadDeadline sets the network read deadline on the underlying websocket.
[ "SetReadDeadline", "sets", "the", "network", "read", "deadline", "on", "the", "underlying", "websocket", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/web/terminal.go#L555-L557
train
gravitational/teleport
lib/kube/proxy/forwarder.go
NewForwarder
func NewForwarder(cfg ForwarderConfig) (*Forwarder, error) { if err := cfg.CheckAndSetDefaults(); err != nil { return nil, trace.Wrap(err) } creds, err := getKubeCreds(cfg.KubeconfigPath) if err != nil { return nil, trace.Wrap(err) } clusterSessions, err := ttlmap.New(defaults.ClientCacheSize) if err != ni...
go
func NewForwarder(cfg ForwarderConfig) (*Forwarder, error) { if err := cfg.CheckAndSetDefaults(); err != nil { return nil, trace.Wrap(err) } creds, err := getKubeCreds(cfg.KubeconfigPath) if err != nil { return nil, trace.Wrap(err) } clusterSessions, err := ttlmap.New(defaults.ClientCacheSize) if err != ni...
[ "func", "NewForwarder", "(", "cfg", "ForwarderConfig", ")", "(", "*", "Forwarder", ",", "error", ")", "{", "if", "err", ":=", "cfg", ".", "CheckAndSetDefaults", "(", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "trace", ".", "Wrap", "(", ...
// NewForwarder returns new instance of Kubernetes request // forwarding proxy.
[ "NewForwarder", "returns", "new", "instance", "of", "Kubernetes", "request", "forwarding", "proxy", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/kube/proxy/forwarder.go#L144-L187
train
gravitational/teleport
lib/kube/proxy/forwarder.go
authenticate
func (f *Forwarder) authenticate(req *http.Request) (*authContext, error) { const accessDeniedMsg = "[00] access denied" var isRemoteUser bool userTypeI := req.Context().Value(auth.ContextUser) switch userTypeI.(type) { case auth.LocalUser: case auth.RemoteUser: isRemoteUser = true default: f.Warningf("Den...
go
func (f *Forwarder) authenticate(req *http.Request) (*authContext, error) { const accessDeniedMsg = "[00] access denied" var isRemoteUser bool userTypeI := req.Context().Value(auth.ContextUser) switch userTypeI.(type) { case auth.LocalUser: case auth.RemoteUser: isRemoteUser = true default: f.Warningf("Den...
[ "func", "(", "f", "*", "Forwarder", ")", "authenticate", "(", "req", "*", "http", ".", "Request", ")", "(", "*", "authContext", ",", "error", ")", "{", "const", "accessDeniedMsg", "=", "\"", "\"", "\n\n", "var", "isRemoteUser", "bool", "\n", "userTypeI",...
// authenticate function authenticates request
[ "authenticate", "function", "authenticates", "request" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/kube/proxy/forwarder.go#L274-L321
train
gravitational/teleport
lib/kube/proxy/forwarder.go
portForward
func (f *Forwarder) portForward(ctx *authContext, w http.ResponseWriter, req *http.Request, p httprouter.Params) (interface{}, error) { f.Debugf("Port forward: %v. req headers: %v", req.URL.String(), req.Header) sess, err := f.getOrCreateClusterSession(*ctx) if err != nil { return nil, trace.Wrap(err) } if err ...
go
func (f *Forwarder) portForward(ctx *authContext, w http.ResponseWriter, req *http.Request, p httprouter.Params) (interface{}, error) { f.Debugf("Port forward: %v. req headers: %v", req.URL.String(), req.Header) sess, err := f.getOrCreateClusterSession(*ctx) if err != nil { return nil, trace.Wrap(err) } if err ...
[ "func", "(", "f", "*", "Forwarder", ")", "portForward", "(", "ctx", "*", "authContext", ",", "w", "http", ".", "ResponseWriter", ",", "req", "*", "http", ".", "Request", ",", "p", "httprouter", ".", "Params", ")", "(", "interface", "{", "}", ",", "er...
// portForward starts port forwarding to the remote cluster
[ "portForward", "starts", "port", "forwarding", "to", "the", "remote", "cluster" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/kube/proxy/forwarder.go#L568-L619
train
gravitational/teleport
lib/kube/proxy/forwarder.go
catchAll
func (f *Forwarder) catchAll(ctx *authContext, w http.ResponseWriter, req *http.Request) (interface{}, error) { sess, err := f.getOrCreateClusterSession(*ctx) if err != nil { return nil, trace.Wrap(err) } if err := f.setupForwardingHeaders(ctx, sess, req); err != nil { return nil, trace.Wrap(err) } sess.forwa...
go
func (f *Forwarder) catchAll(ctx *authContext, w http.ResponseWriter, req *http.Request) (interface{}, error) { sess, err := f.getOrCreateClusterSession(*ctx) if err != nil { return nil, trace.Wrap(err) } if err := f.setupForwardingHeaders(ctx, sess, req); err != nil { return nil, trace.Wrap(err) } sess.forwa...
[ "func", "(", "f", "*", "Forwarder", ")", "catchAll", "(", "ctx", "*", "authContext", ",", "w", "http", ".", "ResponseWriter", ",", "req", "*", "http", ".", "Request", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "sess", ",", "err", ":="...
// catchAll forwards all HTTP requests to the target k8s API server
[ "catchAll", "forwards", "all", "HTTP", "requests", "to", "the", "target", "k8s", "API", "server" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/kube/proxy/forwarder.go#L655-L665
train
gravitational/teleport
lib/kube/proxy/forwarder.go
UpdateClientActivity
func (t *trackingConn) UpdateClientActivity() { t.Lock() defer t.Unlock() t.lastActive = t.clock.Now().UTC() }
go
func (t *trackingConn) UpdateClientActivity() { t.Lock() defer t.Unlock() t.lastActive = t.clock.Now().UTC() }
[ "func", "(", "t", "*", "trackingConn", ")", "UpdateClientActivity", "(", ")", "{", "t", ".", "Lock", "(", ")", "\n", "defer", "t", ".", "Unlock", "(", ")", "\n", "t", ".", "lastActive", "=", "t", ".", "clock", ".", "Now", "(", ")", ".", "UTC", ...
// UpdateClientActivity sets last recorded client activity
[ "UpdateClientActivity", "sets", "last", "recorded", "client", "activity" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/kube/proxy/forwarder.go#L778-L782
train
gravitational/teleport
lib/kube/proxy/forwarder.go
getOrCreateRequestContext
func (f *Forwarder) getOrCreateRequestContext(key string) (context.Context, context.CancelFunc) { f.Lock() defer f.Unlock() ctx, ok := f.activeRequests[key] if ok { return ctx, nil } ctx, cancel := context.WithCancel(context.TODO()) f.activeRequests[key] = ctx return ctx, func() { cancel() f.Lock() defe...
go
func (f *Forwarder) getOrCreateRequestContext(key string) (context.Context, context.CancelFunc) { f.Lock() defer f.Unlock() ctx, ok := f.activeRequests[key] if ok { return ctx, nil } ctx, cancel := context.WithCancel(context.TODO()) f.activeRequests[key] = ctx return ctx, func() { cancel() f.Lock() defe...
[ "func", "(", "f", "*", "Forwarder", ")", "getOrCreateRequestContext", "(", "key", "string", ")", "(", "context", ".", "Context", ",", "context", ".", "CancelFunc", ")", "{", "f", ".", "Lock", "(", ")", "\n", "defer", "f", ".", "Unlock", "(", ")", "\n...
// getOrCreateRequestContext creates a new certificate request for a given context, // if there is no active CSR request in progress, or returns an existing one. // if the new context has been created, cancel function is returned as a // second argument. Caller should call this function to signal that CSR has been // c...
[ "getOrCreateRequestContext", "creates", "a", "new", "certificate", "request", "for", "a", "given", "context", "if", "there", "is", "no", "active", "CSR", "request", "in", "progress", "or", "returns", "an", "existing", "one", ".", "if", "the", "new", "context",...
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/kube/proxy/forwarder.go#L936-L951
train
gravitational/teleport
lib/multiplexer/proxyline.go
String
func (p *ProxyLine) String() string { return fmt.Sprintf("PROXY %s %s %s %d %d\r\n", p.Protocol, p.Source.IP.String(), p.Destination.IP.String(), p.Source.Port, p.Destination.Port) }
go
func (p *ProxyLine) String() string { return fmt.Sprintf("PROXY %s %s %s %d %d\r\n", p.Protocol, p.Source.IP.String(), p.Destination.IP.String(), p.Source.Port, p.Destination.Port) }
[ "func", "(", "p", "*", "ProxyLine", ")", "String", "(", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\\r", "\\n", "\"", ",", "p", ".", "Protocol", ",", "p", ".", "Source", ".", "IP", ".", "String", "(", ")", ",", "p", ".", ...
// String returns on-the wire string representation of the proxy line
[ "String", "returns", "on", "-", "the", "wire", "string", "representation", "of", "the", "proxy", "line" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/multiplexer/proxyline.go#L55-L57
train
gravitational/teleport
lib/multiplexer/proxyline.go
ReadProxyLine
func ReadProxyLine(reader *bufio.Reader) (*ProxyLine, error) { line, err := reader.ReadString('\n') if err != nil { return nil, trace.Wrap(err) } if !strings.HasSuffix(line, proxyCRLF) { return nil, trace.BadParameter("expected CRLF in proxy protocol, got something else") } tokens := strings.Split(line[:len(l...
go
func ReadProxyLine(reader *bufio.Reader) (*ProxyLine, error) { line, err := reader.ReadString('\n') if err != nil { return nil, trace.Wrap(err) } if !strings.HasSuffix(line, proxyCRLF) { return nil, trace.BadParameter("expected CRLF in proxy protocol, got something else") } tokens := strings.Split(line[:len(l...
[ "func", "ReadProxyLine", "(", "reader", "*", "bufio", ".", "Reader", ")", "(", "*", "ProxyLine", ",", "error", ")", "{", "line", ",", "err", ":=", "reader", ".", "ReadString", "(", "'\\n'", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ...
// ReadProxyLine reads proxy line protocol from the reader
[ "ReadProxyLine", "reads", "proxy", "line", "protocol", "from", "the", "reader" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/multiplexer/proxyline.go#L60-L100
train
gravitational/teleport
lib/service/state.go
newProcessState
func newProcessState(process *TeleportProcess) *processState { return &processState{ process: process, recoveryTime: process.Clock.Now(), currentState: stateOK, } }
go
func newProcessState(process *TeleportProcess) *processState { return &processState{ process: process, recoveryTime: process.Clock.Now(), currentState: stateOK, } }
[ "func", "newProcessState", "(", "process", "*", "TeleportProcess", ")", "*", "processState", "{", "return", "&", "processState", "{", "process", ":", "process", ",", "recoveryTime", ":", "process", ".", "Clock", ".", "Now", "(", ")", ",", "currentState", ":"...
// newProcessState returns a new FSM that tracks the state of the Teleport process.
[ "newProcessState", "returns", "a", "new", "FSM", "that", "tracks", "the", "state", "of", "the", "Teleport", "process", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/service/state.go#L46-L52
train
gravitational/teleport
lib/service/state.go
Process
func (f *processState) Process(event Event) { switch event.Name { // Ready event means Teleport has started successfully. case TeleportReadyEvent: atomic.StoreInt64(&f.currentState, stateOK) f.process.Infof("Detected that service started and joined the cluster successfully.") // If a degraded event was received...
go
func (f *processState) Process(event Event) { switch event.Name { // Ready event means Teleport has started successfully. case TeleportReadyEvent: atomic.StoreInt64(&f.currentState, stateOK) f.process.Infof("Detected that service started and joined the cluster successfully.") // If a degraded event was received...
[ "func", "(", "f", "*", "processState", ")", "Process", "(", "event", "Event", ")", "{", "switch", "event", ".", "Name", "{", "// Ready event means Teleport has started successfully.", "case", "TeleportReadyEvent", ":", "atomic", ".", "StoreInt64", "(", "&", "f", ...
// Process updates the state of Teleport.
[ "Process", "updates", "the", "state", "of", "Teleport", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/service/state.go#L55-L83
train
gravitational/teleport
lib/utils/addr.go
Host
func (a *NetAddr) Host() string { host, _, err := net.SplitHostPort(a.Addr) if err != nil { return a.Addr } return host }
go
func (a *NetAddr) Host() string { host, _, err := net.SplitHostPort(a.Addr) if err != nil { return a.Addr } return host }
[ "func", "(", "a", "*", "NetAddr", ")", "Host", "(", ")", "string", "{", "host", ",", "_", ",", "err", ":=", "net", ".", "SplitHostPort", "(", "a", ".", "Addr", ")", "\n", "if", "err", "!=", "nil", "{", "return", "a", ".", "Addr", "\n", "}", "...
// Host returns host part of address without port
[ "Host", "returns", "host", "part", "of", "address", "without", "port" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/addr.go#L42-L48
train
gravitational/teleport
lib/utils/addr.go
Port
func (a *NetAddr) Port(defaultPort int) int { _, port, err := net.SplitHostPort(a.Addr) if err != nil { return defaultPort } porti, err := strconv.Atoi(port) if err != nil { return defaultPort } return porti }
go
func (a *NetAddr) Port(defaultPort int) int { _, port, err := net.SplitHostPort(a.Addr) if err != nil { return defaultPort } porti, err := strconv.Atoi(port) if err != nil { return defaultPort } return porti }
[ "func", "(", "a", "*", "NetAddr", ")", "Port", "(", "defaultPort", "int", ")", "int", "{", "_", ",", "port", ",", "err", ":=", "net", ".", "SplitHostPort", "(", "a", ".", "Addr", ")", "\n", "if", "err", "!=", "nil", "{", "return", "defaultPort", ...
// Port returns defaultPort if no port is set or is invalid, // the real port otherwise
[ "Port", "returns", "defaultPort", "if", "no", "port", "is", "set", "or", "is", "invalid", "the", "real", "port", "otherwise" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/addr.go#L52-L62
train
gravitational/teleport
lib/utils/addr.go
Equals
func (a *NetAddr) Equals(other NetAddr) bool { return a.Addr == other.Addr && a.AddrNetwork == other.AddrNetwork && a.Path == other.Path }
go
func (a *NetAddr) Equals(other NetAddr) bool { return a.Addr == other.Addr && a.AddrNetwork == other.AddrNetwork && a.Path == other.Path }
[ "func", "(", "a", "*", "NetAddr", ")", "Equals", "(", "other", "NetAddr", ")", "bool", "{", "return", "a", ".", "Addr", "==", "other", ".", "Addr", "&&", "a", ".", "AddrNetwork", "==", "other", ".", "AddrNetwork", "&&", "a", ".", "Path", "==", "oth...
// Equals returns true if address is equal to other
[ "Equals", "returns", "true", "if", "address", "is", "equal", "to", "other" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/addr.go#L65-L67
train
gravitational/teleport
lib/utils/addr.go
IsLocal
func (a *NetAddr) IsLocal() bool { host, _, err := net.SplitHostPort(a.Addr) if err != nil { return false } return IsLocalhost(host) }
go
func (a *NetAddr) IsLocal() bool { host, _, err := net.SplitHostPort(a.Addr) if err != nil { return false } return IsLocalhost(host) }
[ "func", "(", "a", "*", "NetAddr", ")", "IsLocal", "(", ")", "bool", "{", "host", ",", "_", ",", "err", ":=", "net", ".", "SplitHostPort", "(", "a", ".", "Addr", ")", "\n", "if", "err", "!=", "nil", "{", "return", "false", "\n", "}", "\n", "retu...
// IsLocal returns true if this is a local address
[ "IsLocal", "returns", "true", "if", "this", "is", "a", "local", "address" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/addr.go#L70-L76
train
gravitational/teleport
lib/utils/addr.go
IsEmpty
func (a *NetAddr) IsEmpty() bool { return a.Addr == "" && a.AddrNetwork == "" && a.Path == "" }
go
func (a *NetAddr) IsEmpty() bool { return a.Addr == "" && a.AddrNetwork == "" && a.Path == "" }
[ "func", "(", "a", "*", "NetAddr", ")", "IsEmpty", "(", ")", "bool", "{", "return", "a", ".", "Addr", "==", "\"", "\"", "&&", "a", ".", "AddrNetwork", "==", "\"", "\"", "&&", "a", ".", "Path", "==", "\"", "\"", "\n", "}" ]
// IsEmpty returns true if address is empty
[ "IsEmpty", "returns", "true", "if", "address", "is", "empty" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/addr.go#L84-L86
train
gravitational/teleport
lib/utils/addr.go
MarshalYAML
func (a *NetAddr) MarshalYAML() (interface{}, error) { url := url.URL{Scheme: a.AddrNetwork, Host: a.Addr, Path: a.Path} return strings.TrimLeft(url.String(), "/"), nil }
go
func (a *NetAddr) MarshalYAML() (interface{}, error) { url := url.URL{Scheme: a.AddrNetwork, Host: a.Addr, Path: a.Path} return strings.TrimLeft(url.String(), "/"), nil }
[ "func", "(", "a", "*", "NetAddr", ")", "MarshalYAML", "(", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "url", ":=", "url", ".", "URL", "{", "Scheme", ":", "a", ".", "AddrNetwork", ",", "Host", ":", "a", ".", "Addr", ",", "Path", ":...
// MarshalYAML defines how a network address should be marshalled to a string
[ "MarshalYAML", "defines", "how", "a", "network", "address", "should", "be", "marshalled", "to", "a", "string" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/addr.go#L104-L107
train
gravitational/teleport
lib/utils/addr.go
UnmarshalYAML
func (a *NetAddr) UnmarshalYAML(unmarshal func(interface{}) error) error { var addr string err := unmarshal(&addr) if err != nil { return err } parsedAddr, err := ParseAddr(addr) if err != nil { return err } *a = *parsedAddr return nil }
go
func (a *NetAddr) UnmarshalYAML(unmarshal func(interface{}) error) error { var addr string err := unmarshal(&addr) if err != nil { return err } parsedAddr, err := ParseAddr(addr) if err != nil { return err } *a = *parsedAddr return nil }
[ "func", "(", "a", "*", "NetAddr", ")", "UnmarshalYAML", "(", "unmarshal", "func", "(", "interface", "{", "}", ")", "error", ")", "error", "{", "var", "addr", "string", "\n", "err", ":=", "unmarshal", "(", "&", "addr", ")", "\n", "if", "err", "!=", ...
// UnmarshalYAML defines how a string can be unmarshalled into a network address
[ "UnmarshalYAML", "defines", "how", "a", "string", "can", "be", "unmarshalled", "into", "a", "network", "address" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/addr.go#L110-L124
train
gravitational/teleport
lib/utils/addr.go
MustParseAddr
func MustParseAddr(a string) *NetAddr { addr, err := ParseAddr(a) if err != nil { panic(fmt.Sprintf("failed to parse %v: %v", a, err)) } return addr }
go
func MustParseAddr(a string) *NetAddr { addr, err := ParseAddr(a) if err != nil { panic(fmt.Sprintf("failed to parse %v: %v", a, err)) } return addr }
[ "func", "MustParseAddr", "(", "a", "string", ")", "*", "NetAddr", "{", "addr", ",", "err", ":=", "ParseAddr", "(", "a", ")", "\n", "if", "err", "!=", "nil", "{", "panic", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "a", ",", "err", ")", "...
// MustParseAddr parses the provided string into NetAddr or panics on an error
[ "MustParseAddr", "parses", "the", "provided", "string", "into", "NetAddr", "or", "panics", "on", "an", "error" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/addr.go#L162-L168
train
gravitational/teleport
lib/utils/addr.go
FromAddr
func FromAddr(a net.Addr) NetAddr { return NetAddr{AddrNetwork: a.Network(), Addr: a.String()} }
go
func FromAddr(a net.Addr) NetAddr { return NetAddr{AddrNetwork: a.Network(), Addr: a.String()} }
[ "func", "FromAddr", "(", "a", "net", ".", "Addr", ")", "NetAddr", "{", "return", "NetAddr", "{", "AddrNetwork", ":", "a", ".", "Network", "(", ")", ",", "Addr", ":", "a", ".", "String", "(", ")", "}", "\n", "}" ]
// FromAddr returns NetAddr from golang standard net.Addr
[ "FromAddr", "returns", "NetAddr", "from", "golang", "standard", "net", ".", "Addr" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/addr.go#L171-L173
train
gravitational/teleport
lib/utils/addr.go
JoinAddrSlices
func JoinAddrSlices(a []NetAddr, b []NetAddr) []NetAddr { if len(a)+len(b) == 0 { return nil } out := make([]NetAddr, 0, len(a)+len(b)) out = append(out, a...) out = append(out, b...) return out }
go
func JoinAddrSlices(a []NetAddr, b []NetAddr) []NetAddr { if len(a)+len(b) == 0 { return nil } out := make([]NetAddr, 0, len(a)+len(b)) out = append(out, a...) out = append(out, b...) return out }
[ "func", "JoinAddrSlices", "(", "a", "[", "]", "NetAddr", ",", "b", "[", "]", "NetAddr", ")", "[", "]", "NetAddr", "{", "if", "len", "(", "a", ")", "+", "len", "(", "b", ")", "==", "0", "{", "return", "nil", "\n", "}", "\n", "out", ":=", "make...
// JoinAddrSlices joins two addr slices and returns a resulting slice
[ "JoinAddrSlices", "joins", "two", "addr", "slices", "and", "returns", "a", "resulting", "slice" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/addr.go#L176-L184
train
gravitational/teleport
lib/utils/addr.go
DialAddrFromListenAddr
func DialAddrFromListenAddr(listenAddr NetAddr) NetAddr { if listenAddr.IsEmpty() { return listenAddr } return NetAddr{Addr: ReplaceLocalhost(listenAddr.Addr, "127.0.0.1")} }
go
func DialAddrFromListenAddr(listenAddr NetAddr) NetAddr { if listenAddr.IsEmpty() { return listenAddr } return NetAddr{Addr: ReplaceLocalhost(listenAddr.Addr, "127.0.0.1")} }
[ "func", "DialAddrFromListenAddr", "(", "listenAddr", "NetAddr", ")", "NetAddr", "{", "if", "listenAddr", ".", "IsEmpty", "(", ")", "{", "return", "listenAddr", "\n", "}", "\n", "return", "NetAddr", "{", "Addr", ":", "ReplaceLocalhost", "(", "listenAddr", ".", ...
// DialAddrFromListenAddr returns dial address from listen address
[ "DialAddrFromListenAddr", "returns", "dial", "address", "from", "listen", "address" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/addr.go#L204-L209
train
gravitational/teleport
lib/utils/addr.go
Addresses
func (nl *NetAddrList) Addresses() []string { var ns []string for _, n := range *nl { ns = append(ns, n.FullAddress()) } return ns }
go
func (nl *NetAddrList) Addresses() []string { var ns []string for _, n := range *nl { ns = append(ns, n.FullAddress()) } return ns }
[ "func", "(", "nl", "*", "NetAddrList", ")", "Addresses", "(", ")", "[", "]", "string", "{", "var", "ns", "[", "]", "string", "\n", "for", "_", ",", "n", ":=", "range", "*", "nl", "{", "ns", "=", "append", "(", "ns", ",", "n", ".", "FullAddress"...
// Addresses returns a slice of strings converted from the addresses
[ "Addresses", "returns", "a", "slice", "of", "strings", "converted", "from", "the", "addresses" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/addr.go#L242-L248
train
gravitational/teleport
lib/utils/addr.go
Set
func (nl *NetAddrList) Set(s string) error { v, err := ParseAddr(s) if err != nil { return err } *nl = append(*nl, *v) return nil }
go
func (nl *NetAddrList) Set(s string) error { v, err := ParseAddr(s) if err != nil { return err } *nl = append(*nl, *v) return nil }
[ "func", "(", "nl", "*", "NetAddrList", ")", "Set", "(", "s", "string", ")", "error", "{", "v", ",", "err", ":=", "ParseAddr", "(", "s", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "*", "nl", "=", "append", "(",...
// Set is called by CLI tools
[ "Set", "is", "called", "by", "CLI", "tools" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/addr.go#L251-L259
train
gravitational/teleport
lib/utils/addr.go
String
func (nl *NetAddrList) String() string { var ns []string for _, n := range *nl { ns = append(ns, n.FullAddress()) } return strings.Join(ns, " ") }
go
func (nl *NetAddrList) String() string { var ns []string for _, n := range *nl { ns = append(ns, n.FullAddress()) } return strings.Join(ns, " ") }
[ "func", "(", "nl", "*", "NetAddrList", ")", "String", "(", ")", "string", "{", "var", "ns", "[", "]", "string", "\n", "for", "_", ",", "n", ":=", "range", "*", "nl", "{", "ns", "=", "append", "(", "ns", ",", "n", ".", "FullAddress", "(", ")", ...
// String returns debug-friendly representation of the tool
[ "String", "returns", "debug", "-", "friendly", "representation", "of", "the", "tool" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/addr.go#L262-L268
train
gravitational/teleport
lib/utils/addr.go
IsLocalhost
func IsLocalhost(host string) bool { if host == "localhost" { return true } ip := net.ParseIP(host) return ip.IsLoopback() || ip.IsUnspecified() }
go
func IsLocalhost(host string) bool { if host == "localhost" { return true } ip := net.ParseIP(host) return ip.IsLoopback() || ip.IsUnspecified() }
[ "func", "IsLocalhost", "(", "host", "string", ")", "bool", "{", "if", "host", "==", "\"", "\"", "{", "return", "true", "\n", "}", "\n", "ip", ":=", "net", ".", "ParseIP", "(", "host", ")", "\n", "return", "ip", ".", "IsLoopback", "(", ")", "||", ...
// IsLocalhost returns true if this is a local hostname or ip
[ "IsLocalhost", "returns", "true", "if", "this", "is", "a", "local", "hostname", "or", "ip" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/addr.go#L291-L297
train
gravitational/teleport
lib/utils/addr.go
IsLoopback
func IsLoopback(host string) bool { if strings.Contains(host, ":") { var err error host, _, err = net.SplitHostPort(host) if err != nil { return false } } ips, err := net.LookupIP(host) if err != nil { return false } for _, ip := range ips { if ip.IsLoopback() { return true } } return false ...
go
func IsLoopback(host string) bool { if strings.Contains(host, ":") { var err error host, _, err = net.SplitHostPort(host) if err != nil { return false } } ips, err := net.LookupIP(host) if err != nil { return false } for _, ip := range ips { if ip.IsLoopback() { return true } } return false ...
[ "func", "IsLoopback", "(", "host", "string", ")", "bool", "{", "if", "strings", ".", "Contains", "(", "host", ",", "\"", "\"", ")", "{", "var", "err", "error", "\n", "host", ",", "_", ",", "err", "=", "net", ".", "SplitHostPort", "(", "host", ")", ...
// IsLoopback returns 'true' if a given hostname resolves to local // host's loopback interface
[ "IsLoopback", "returns", "true", "if", "a", "given", "hostname", "resolves", "to", "local", "host", "s", "loopback", "interface" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/addr.go#L301-L319
train
gravitational/teleport
lib/utils/addr.go
GuessHostIP
func GuessHostIP() (ip net.IP, err error) { ifaces, err := net.Interfaces() if err != nil { return nil, trace.Wrap(err) } adrs := make([]net.Addr, 0) for _, iface := range ifaces { ifadrs, err := iface.Addrs() if err != nil { log.Warn(err) } else { adrs = append(adrs, ifadrs...) } } return guessH...
go
func GuessHostIP() (ip net.IP, err error) { ifaces, err := net.Interfaces() if err != nil { return nil, trace.Wrap(err) } adrs := make([]net.Addr, 0) for _, iface := range ifaces { ifadrs, err := iface.Addrs() if err != nil { log.Warn(err) } else { adrs = append(adrs, ifadrs...) } } return guessH...
[ "func", "GuessHostIP", "(", ")", "(", "ip", "net", ".", "IP", ",", "err", "error", ")", "{", "ifaces", ",", "err", ":=", "net", ".", "Interfaces", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "trace", ".", "Wrap", "(", "...
// GuessIP tries to guess an IP address this machine is reachable at on the // internal network, always picking IPv4 from the internal address space // // If no internal IPs are found, it returns 127.0.0.1 but it never returns // an address from the public IP space
[ "GuessIP", "tries", "to", "guess", "an", "IP", "address", "this", "machine", "is", "reachable", "at", "on", "the", "internal", "network", "always", "picking", "IPv4", "from", "the", "internal", "address", "space", "If", "no", "internal", "IPs", "are", "found...
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/addr.go#L326-L341
train
gravitational/teleport
lib/auth/mocku2f/mocku2f.go
decodeBase64
func decodeBase64(s string) ([]byte, error) { for i := 0; i < len(s)%4; i++ { s += "=" } return base64.URLEncoding.DecodeString(s) }
go
func decodeBase64(s string) ([]byte, error) { for i := 0; i < len(s)%4; i++ { s += "=" } return base64.URLEncoding.DecodeString(s) }
[ "func", "decodeBase64", "(", "s", "string", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "for", "i", ":=", "0", ";", "i", "<", "len", "(", "s", ")", "%", "4", ";", "i", "++", "{", "s", "+=", "\"", "\"", "\n", "}", "\n", "return", "...
// The "websafe-base64 encoding" in the U2F specifications removes the padding
[ "The", "websafe", "-", "base64", "encoding", "in", "the", "U2F", "specifications", "removes", "the", "padding" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/mocku2f/mocku2f.go#L52-L57
train
gravitational/teleport
lib/reversetunnel/peer.go
newClusterPeer
func newClusterPeer(srv *server, connInfo services.TunnelConnection) (*clusterPeer, error) { clusterPeer := &clusterPeer{ srv: srv, connInfo: connInfo, log: log.WithFields(log.Fields{ trace.Component: teleport.ComponentReverseTunnelServer, trace.ComponentFields: map[string]string{ "cluster": connI...
go
func newClusterPeer(srv *server, connInfo services.TunnelConnection) (*clusterPeer, error) { clusterPeer := &clusterPeer{ srv: srv, connInfo: connInfo, log: log.WithFields(log.Fields{ trace.Component: teleport.ComponentReverseTunnelServer, trace.ComponentFields: map[string]string{ "cluster": connI...
[ "func", "newClusterPeer", "(", "srv", "*", "server", ",", "connInfo", "services", ".", "TunnelConnection", ")", "(", "*", "clusterPeer", ",", "error", ")", "{", "clusterPeer", ":=", "&", "clusterPeer", "{", "srv", ":", "srv", ",", "connInfo", ":", "connInf...
// newClusterPeer returns new cluster peer
[ "newClusterPeer", "returns", "new", "cluster", "peer" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/reversetunnel/peer.go#L136-L149
train
gravitational/teleport
lib/utils/otp.go
GenerateQRCode
func GenerateQRCode(u string) ([]byte, error) { otpKey, err := otp.NewKeyFromURL(u) if err != nil { return nil, trace.Wrap(err) } otpImage, err := otpKey.Image(450, 450) if err != nil { return nil, trace.Wrap(err) } var otpQR bytes.Buffer err = png.Encode(&otpQR, otpImage) if err != nil { return nil, t...
go
func GenerateQRCode(u string) ([]byte, error) { otpKey, err := otp.NewKeyFromURL(u) if err != nil { return nil, trace.Wrap(err) } otpImage, err := otpKey.Image(450, 450) if err != nil { return nil, trace.Wrap(err) } var otpQR bytes.Buffer err = png.Encode(&otpQR, otpImage) if err != nil { return nil, t...
[ "func", "GenerateQRCode", "(", "u", "string", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "otpKey", ",", "err", ":=", "otp", ".", "NewKeyFromURL", "(", "u", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "trace", ".", "Wr...
// GenerateQRCode takes in a OTP Key URL and returns a PNG-encoded QR code.
[ "GenerateQRCode", "takes", "in", "a", "OTP", "Key", "URL", "and", "returns", "a", "PNG", "-", "encoded", "QR", "code", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/otp.go#L15-L33
train
gravitational/teleport
lib/web/password.go
changePassword
func (h *Handler) changePassword(w http.ResponseWriter, r *http.Request, p httprouter.Params, ctx *SessionContext) (interface{}, error) { var req *changePasswordReq if err := httplib.ReadJSON(r, &req); err != nil { return nil, trace.Wrap(err) } clt, err := ctx.GetClient() if err != nil { return nil, trace.Wra...
go
func (h *Handler) changePassword(w http.ResponseWriter, r *http.Request, p httprouter.Params, ctx *SessionContext) (interface{}, error) { var req *changePasswordReq if err := httplib.ReadJSON(r, &req); err != nil { return nil, trace.Wrap(err) } clt, err := ctx.GetClient() if err != nil { return nil, trace.Wra...
[ "func", "(", "h", "*", "Handler", ")", "changePassword", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ",", "p", "httprouter", ".", "Params", ",", "ctx", "*", "SessionContext", ")", "(", "interface", "{", "}", ",", "...
// changePassword updates users password based on the old password
[ "changePassword", "updates", "users", "password", "based", "on", "the", "old", "password" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/web/password.go#L45-L70
train
gravitational/teleport
lib/web/password.go
u2fChangePasswordRequest
func (h *Handler) u2fChangePasswordRequest(w http.ResponseWriter, r *http.Request, _ httprouter.Params, ctx *SessionContext) (interface{}, error) { var req *client.U2fSignRequestReq if err := httplib.ReadJSON(r, &req); err != nil { return nil, trace.Wrap(err) } clt, err := ctx.GetClient() if err != nil { retu...
go
func (h *Handler) u2fChangePasswordRequest(w http.ResponseWriter, r *http.Request, _ httprouter.Params, ctx *SessionContext) (interface{}, error) { var req *client.U2fSignRequestReq if err := httplib.ReadJSON(r, &req); err != nil { return nil, trace.Wrap(err) } clt, err := ctx.GetClient() if err != nil { retu...
[ "func", "(", "h", "*", "Handler", ")", "u2fChangePasswordRequest", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ",", "_", "httprouter", ".", "Params", ",", "ctx", "*", "SessionContext", ")", "(", "interface", "{", "}", ...
// u2fChangePasswordRequest is called to get U2F challedge for changing a user password
[ "u2fChangePasswordRequest", "is", "called", "to", "get", "U2F", "challedge", "for", "changing", "a", "user", "password" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/web/password.go#L73-L98
train
gravitational/teleport
lib/web/static.go
NewStaticFileSystem
func NewStaticFileSystem(debugMode bool) (http.FileSystem, error) { if debugMode { assetsToCheck := []string{"index.html", "/app"} if debugAssetsPath == "" { exePath, err := osext.ExecutableFolder() if err != nil { return nil, trace.Wrap(err) } debugAssetsPath = path.Join(exePath, "../web/dist") ...
go
func NewStaticFileSystem(debugMode bool) (http.FileSystem, error) { if debugMode { assetsToCheck := []string{"index.html", "/app"} if debugAssetsPath == "" { exePath, err := osext.ExecutableFolder() if err != nil { return nil, trace.Wrap(err) } debugAssetsPath = path.Join(exePath, "../web/dist") ...
[ "func", "NewStaticFileSystem", "(", "debugMode", "bool", ")", "(", "http", ".", "FileSystem", ",", "error", ")", "{", "if", "debugMode", "{", "assetsToCheck", ":=", "[", "]", "string", "{", "\"", "\"", ",", "\"", "\"", "}", "\n\n", "if", "debugAssetsPath...
// NewStaticFileSystem returns the initialized implementation of http.FileSystem // interface which can be used to serve Teleport Proxy Web UI // // If 'debugMode' is true, it will load the web assets from the same git repo // directory where the executable is, otherwise it will load them from the embedded // zip archi...
[ "NewStaticFileSystem", "returns", "the", "initialized", "implementation", "of", "http", ".", "FileSystem", "interface", "which", "can", "be", "used", "to", "serve", "Teleport", "Proxy", "Web", "UI", "If", "debugMode", "is", "true", "it", "will", "load", "the", ...
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/web/static.go#L53-L77
train
gravitational/teleport
lib/web/static.go
isDebugMode
func isDebugMode() bool { v, _ := strconv.ParseBool(os.Getenv(teleport.DebugEnvVar)) return v }
go
func isDebugMode() bool { v, _ := strconv.ParseBool(os.Getenv(teleport.DebugEnvVar)) return v }
[ "func", "isDebugMode", "(", ")", "bool", "{", "v", ",", "_", ":=", "strconv", ".", "ParseBool", "(", "os", ".", "Getenv", "(", "teleport", ".", "DebugEnvVar", ")", ")", "\n", "return", "v", "\n", "}" ]
// isDebugMode determines if teleport is running in a "debug" mode. // It looks at DEBUG environment variable
[ "isDebugMode", "determines", "if", "teleport", "is", "running", "in", "a", "debug", "mode", ".", "It", "looks", "at", "DEBUG", "environment", "variable" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/web/static.go#L81-L84
train
gravitational/teleport
lib/web/static.go
loadZippedExeAssets
func loadZippedExeAssets() (ResourceMap, error) { // open ourselves (teleport binary) for reading: // NOTE: the file stays open to serve future Read() requests myExe, err := osext.Executable() if err != nil { return nil, trace.Wrap(err) } return readZipArchive(myExe) }
go
func loadZippedExeAssets() (ResourceMap, error) { // open ourselves (teleport binary) for reading: // NOTE: the file stays open to serve future Read() requests myExe, err := osext.Executable() if err != nil { return nil, trace.Wrap(err) } return readZipArchive(myExe) }
[ "func", "loadZippedExeAssets", "(", ")", "(", "ResourceMap", ",", "error", ")", "{", "// open ourselves (teleport binary) for reading:", "// NOTE: the file stays open to serve future Read() requests", "myExe", ",", "err", ":=", "osext", ".", "Executable", "(", ")", "\n", ...
// LoadWebResources returns a filesystem implementation compatible // with http.Serve. // // The "filesystem" is served from a zip file attached at the end of // the executable //
[ "LoadWebResources", "returns", "a", "filesystem", "implementation", "compatible", "with", "http", ".", "Serve", ".", "The", "filesystem", "is", "served", "from", "a", "zip", "file", "attached", "at", "the", "end", "of", "the", "executable" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/web/static.go#L92-L100
train
gravitational/teleport
lib/auth/register.go
LocalRegister
func LocalRegister(id IdentityID, authServer *AuthServer, additionalPrincipals, dnsNames []string, remoteAddr string) (*Identity, error) { // If local registration is happening and no remote address was passed in // (which means no advertise IP was set), use localhost. if remoteAddr == "" { remoteAddr = defaults.L...
go
func LocalRegister(id IdentityID, authServer *AuthServer, additionalPrincipals, dnsNames []string, remoteAddr string) (*Identity, error) { // If local registration is happening and no remote address was passed in // (which means no advertise IP was set), use localhost. if remoteAddr == "" { remoteAddr = defaults.L...
[ "func", "LocalRegister", "(", "id", "IdentityID", ",", "authServer", "*", "AuthServer", ",", "additionalPrincipals", ",", "dnsNames", "[", "]", "string", ",", "remoteAddr", "string", ")", "(", "*", "Identity", ",", "error", ")", "{", "// If local registration is...
// LocalRegister is used to generate host keys when a node or proxy is running // within the same process as the Auth Server and as such, does not need to // use provisioning tokens.
[ "LocalRegister", "is", "used", "to", "generate", "host", "keys", "when", "a", "node", "or", "proxy", "is", "running", "within", "the", "same", "process", "as", "the", "Auth", "Server", "and", "as", "such", "does", "not", "need", "to", "use", "provisioning"...
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/register.go#L37-L62
train
gravitational/teleport
lib/auth/register.go
Register
func Register(params RegisterParams) (*Identity, error) { // Read in the token. The token can either be passed in or come from a file // on disk. token, err := readToken(params.Token) if err != nil { return nil, trace.Wrap(err) } // Attempt to register through the auth server, if it fails, try and // register...
go
func Register(params RegisterParams) (*Identity, error) { // Read in the token. The token can either be passed in or come from a file // on disk. token, err := readToken(params.Token) if err != nil { return nil, trace.Wrap(err) } // Attempt to register through the auth server, if it fails, try and // register...
[ "func", "Register", "(", "params", "RegisterParams", ")", "(", "*", "Identity", ",", "error", ")", "{", "// Read in the token. The token can either be passed in or come from a file", "// on disk.", "token", ",", "err", ":=", "readToken", "(", "params", ".", "Token", "...
// Register is used to generate host keys when a node or proxy are running on // different hosts than the auth server. This method requires provisioning // tokens to prove a valid auth server was used to issue the joining request // as well as a method for the node to validate the auth server.
[ "Register", "is", "used", "to", "generate", "host", "keys", "when", "a", "node", "or", "proxy", "are", "running", "on", "different", "hosts", "than", "the", "auth", "server", ".", "This", "method", "requires", "provisioning", "tokens", "to", "prove", "a", ...
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/register.go#L108-L137
train
gravitational/teleport
lib/auth/register.go
registerThroughProxy
func registerThroughProxy(token string, params RegisterParams) (*Identity, error) { log.Debugf("Attempting to register through proxy server.") keys, err := params.CredsClient.HostCredentials(context.Background(), RegisterUsingTokenRequest{ Token: token, HostID: params.ID.HostUUID...
go
func registerThroughProxy(token string, params RegisterParams) (*Identity, error) { log.Debugf("Attempting to register through proxy server.") keys, err := params.CredsClient.HostCredentials(context.Background(), RegisterUsingTokenRequest{ Token: token, HostID: params.ID.HostUUID...
[ "func", "registerThroughProxy", "(", "token", "string", ",", "params", "RegisterParams", ")", "(", "*", "Identity", ",", "error", ")", "{", "log", ".", "Debugf", "(", "\"", "\"", ")", "\n\n", "keys", ",", "err", ":=", "params", ".", "CredsClient", ".", ...
// registerThroughProxy is used to register through the proxy server.
[ "registerThroughProxy", "is", "used", "to", "register", "through", "the", "proxy", "server", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/register.go#L140-L160
train
gravitational/teleport
lib/auth/register.go
registerThroughAuth
func registerThroughAuth(token string, params RegisterParams) (*Identity, error) { log.Debugf("Attempting to register through auth server.") var client *Client var err error // Build a client to the Auth Server. If a CA pin is specified require the // Auth Server is validated. Otherwise attempt to use the CA fil...
go
func registerThroughAuth(token string, params RegisterParams) (*Identity, error) { log.Debugf("Attempting to register through auth server.") var client *Client var err error // Build a client to the Auth Server. If a CA pin is specified require the // Auth Server is validated. Otherwise attempt to use the CA fil...
[ "func", "registerThroughAuth", "(", "token", "string", ",", "params", "RegisterParams", ")", "(", "*", "Identity", ",", "error", ")", "{", "log", ".", "Debugf", "(", "\"", "\"", ")", "\n\n", "var", "client", "*", "Client", "\n", "var", "err", "error", ...
// registerThroughAuth is used to register through the auth server.
[ "registerThroughAuth", "is", "used", "to", "register", "through", "the", "auth", "server", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/register.go#L163-L200
train
gravitational/teleport
lib/auth/register.go
insecureRegisterClient
func insecureRegisterClient(params RegisterParams) (*Client, error) { tlsConfig := utils.TLSConfig(params.CipherSuites) cert, err := readCA(params) if err != nil && !trace.IsNotFound(err) { return nil, trace.Wrap(err) } // If no CA was found, then create a insecure connection to the Auth Server, // otherwise ...
go
func insecureRegisterClient(params RegisterParams) (*Client, error) { tlsConfig := utils.TLSConfig(params.CipherSuites) cert, err := readCA(params) if err != nil && !trace.IsNotFound(err) { return nil, trace.Wrap(err) } // If no CA was found, then create a insecure connection to the Auth Server, // otherwise ...
[ "func", "insecureRegisterClient", "(", "params", "RegisterParams", ")", "(", "*", "Client", ",", "error", ")", "{", "tlsConfig", ":=", "utils", ".", "TLSConfig", "(", "params", ".", "CipherSuites", ")", "\n\n", "cert", ",", "err", ":=", "readCA", "(", "par...
// insecureRegisterClient attempts to connects to the Auth Server using the // CA on disk. If no CA is found on disk, Teleport will not verify the Auth // Server it is connecting to.
[ "insecureRegisterClient", "attempts", "to", "connects", "to", "the", "Auth", "Server", "using", "the", "CA", "on", "disk", ".", "If", "no", "CA", "is", "found", "on", "disk", "Teleport", "will", "not", "verify", "the", "Auth", "Server", "it", "is", "connec...
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/register.go#L205-L237
train
gravitational/teleport
lib/auth/register.go
readCA
func readCA(params RegisterParams) (*x509.Certificate, error) { certBytes, err := utils.ReadPath(params.CAPath) if err != nil { return nil, trace.Wrap(err) } cert, err := tlsca.ParseCertificatePEM(certBytes) if err != nil { return nil, trace.Wrap(err, "failed to parse certificate at %v", params.CAPath) } ret...
go
func readCA(params RegisterParams) (*x509.Certificate, error) { certBytes, err := utils.ReadPath(params.CAPath) if err != nil { return nil, trace.Wrap(err) } cert, err := tlsca.ParseCertificatePEM(certBytes) if err != nil { return nil, trace.Wrap(err, "failed to parse certificate at %v", params.CAPath) } ret...
[ "func", "readCA", "(", "params", "RegisterParams", ")", "(", "*", "x509", ".", "Certificate", ",", "error", ")", "{", "certBytes", ",", "err", ":=", "utils", ".", "ReadPath", "(", "params", ".", "CAPath", ")", "\n", "if", "err", "!=", "nil", "{", "re...
// readCA will read in CA that will be used to validate the certificate that // the Auth Server presents.
[ "readCA", "will", "read", "in", "CA", "that", "will", "be", "used", "to", "validate", "the", "certificate", "that", "the", "Auth", "Server", "presents", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/register.go#L241-L251
train
gravitational/teleport
lib/auth/register.go
pinRegisterClient
func pinRegisterClient(params RegisterParams) (*Client, error) { // Build a insecure client to the Auth Server. This is safe because even if // an attacker were to MITM this connection the CA pin will not match below. tlsConfig := utils.TLSConfig(params.CipherSuites) tlsConfig.InsecureSkipVerify = true client, err...
go
func pinRegisterClient(params RegisterParams) (*Client, error) { // Build a insecure client to the Auth Server. This is safe because even if // an attacker were to MITM this connection the CA pin will not match below. tlsConfig := utils.TLSConfig(params.CipherSuites) tlsConfig.InsecureSkipVerify = true client, err...
[ "func", "pinRegisterClient", "(", "params", "RegisterParams", ")", "(", "*", "Client", ",", "error", ")", "{", "// Build a insecure client to the Auth Server. This is safe because even if", "// an attacker were to MITM this connection the CA pin will not match below.", "tlsConfig", "...
// pinRegisterClient first connects to the Auth Server using a insecure // connection to fetch the root CA. If the root CA matches the provided CA // pin, a connection will be re-established and the root CA will be used to // validate the certificate presented. If both conditions hold true, then we // know we are conne...
[ "pinRegisterClient", "first", "connects", "to", "the", "Auth", "Server", "using", "a", "insecure", "connection", "to", "fetch", "the", "root", "CA", ".", "If", "the", "root", "CA", "matches", "the", "provided", "CA", "pin", "a", "connection", "will", "be", ...
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/register.go#L258-L303
train
gravitational/teleport
lib/auth/register.go
ReRegister
func ReRegister(params ReRegisterParams) (*Identity, error) { hostID, err := params.ID.HostID() if err != nil { return nil, trace.Wrap(err) } keys, err := params.Client.GenerateServerKeys(GenerateServerKeysRequest{ HostID: hostID, NodeName: params.ID.NodeName, Roles: ...
go
func ReRegister(params ReRegisterParams) (*Identity, error) { hostID, err := params.ID.HostID() if err != nil { return nil, trace.Wrap(err) } keys, err := params.Client.GenerateServerKeys(GenerateServerKeysRequest{ HostID: hostID, NodeName: params.ID.NodeName, Roles: ...
[ "func", "ReRegister", "(", "params", "ReRegisterParams", ")", "(", "*", "Identity", ",", "error", ")", "{", "hostID", ",", "err", ":=", "params", ".", "ID", ".", "HostID", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "trace", ...
// ReRegister renews the certificates and private keys based on the client's existing identity.
[ "ReRegister", "renews", "the", "certificates", "and", "private", "keys", "based", "on", "the", "client", "s", "existing", "identity", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/register.go#L327-L348
train
gravitational/teleport
lib/config/fileconf.go
ReadFromFile
func ReadFromFile(filePath string) (*FileConfig, error) { f, err := os.Open(filePath) if err != nil { return nil, trace.Wrap(err, fmt.Sprintf("failed to open file: %v", filePath)) } defer f.Close() return ReadConfig(f) }
go
func ReadFromFile(filePath string) (*FileConfig, error) { f, err := os.Open(filePath) if err != nil { return nil, trace.Wrap(err, fmt.Sprintf("failed to open file: %v", filePath)) } defer f.Close() return ReadConfig(f) }
[ "func", "ReadFromFile", "(", "filePath", "string", ")", "(", "*", "FileConfig", ",", "error", ")", "{", "f", ",", "err", ":=", "os", ".", "Open", "(", "filePath", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "trace", ".", "Wrap",...
// ReadFromFile reads Teleport configuration from a file. Currently only YAML // format is supported
[ "ReadFromFile", "reads", "Teleport", "configuration", "from", "a", "file", ".", "Currently", "only", "YAML", "format", "is", "supported" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/config/fileconf.go#L170-L177
train
gravitational/teleport
lib/config/fileconf.go
ReadFromString
func ReadFromString(configString string) (*FileConfig, error) { data, err := base64.StdEncoding.DecodeString(configString) if err != nil { return nil, trace.BadParameter( "confiugraion should be base64 encoded: %v", err) } return ReadConfig(bytes.NewBuffer(data)) }
go
func ReadFromString(configString string) (*FileConfig, error) { data, err := base64.StdEncoding.DecodeString(configString) if err != nil { return nil, trace.BadParameter( "confiugraion should be base64 encoded: %v", err) } return ReadConfig(bytes.NewBuffer(data)) }
[ "func", "ReadFromString", "(", "configString", "string", ")", "(", "*", "FileConfig", ",", "error", ")", "{", "data", ",", "err", ":=", "base64", ".", "StdEncoding", ".", "DecodeString", "(", "configString", ")", "\n", "if", "err", "!=", "nil", "{", "ret...
// ReadFromString reads values from base64 encoded byte string
[ "ReadFromString", "reads", "values", "from", "base64", "encoded", "byte", "string" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/config/fileconf.go#L180-L187
train
gravitational/teleport
lib/config/fileconf.go
ReadConfig
func ReadConfig(reader io.Reader) (*FileConfig, error) { // read & parse YAML config: bytes, err := ioutil.ReadAll(reader) if err != nil { return nil, trace.Wrap(err, "failed reading Teleport configuration") } var fc FileConfig if err = yaml.Unmarshal(bytes, &fc); err != nil { return nil, trace.BadParameter("...
go
func ReadConfig(reader io.Reader) (*FileConfig, error) { // read & parse YAML config: bytes, err := ioutil.ReadAll(reader) if err != nil { return nil, trace.Wrap(err, "failed reading Teleport configuration") } var fc FileConfig if err = yaml.Unmarshal(bytes, &fc); err != nil { return nil, trace.BadParameter("...
[ "func", "ReadConfig", "(", "reader", "io", ".", "Reader", ")", "(", "*", "FileConfig", ",", "error", ")", "{", "// read & parse YAML config:", "bytes", ",", "err", ":=", "ioutil", ".", "ReadAll", "(", "reader", ")", "\n", "if", "err", "!=", "nil", "{", ...
// ReadConfig reads Teleport configuration from reader in YAML format
[ "ReadConfig", "reads", "Teleport", "configuration", "from", "reader", "in", "YAML", "format" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/config/fileconf.go#L190-L235
train
gravitational/teleport
lib/config/fileconf.go
MakeSampleFileConfig
func MakeSampleFileConfig() (fc *FileConfig) { conf := service.MakeDefaultConfig() // sample global config: var g Global g.NodeName = conf.Hostname g.AuthToken = "cluster-join-token" g.Logger.Output = "stderr" g.Logger.Severity = "INFO" g.AuthServers = []string{defaults.AuthListenAddr().Addr} g.Limits.MaxConn...
go
func MakeSampleFileConfig() (fc *FileConfig) { conf := service.MakeDefaultConfig() // sample global config: var g Global g.NodeName = conf.Hostname g.AuthToken = "cluster-join-token" g.Logger.Output = "stderr" g.Logger.Severity = "INFO" g.AuthServers = []string{defaults.AuthListenAddr().Addr} g.Limits.MaxConn...
[ "func", "MakeSampleFileConfig", "(", ")", "(", "fc", "*", "FileConfig", ")", "{", "conf", ":=", "service", ".", "MakeDefaultConfig", "(", ")", "\n\n", "// sample global config:", "var", "g", "Global", "\n", "g", ".", "NodeName", "=", "conf", ".", "Hostname",...
// MakeSampleFileConfig returns a sample config structure populated by defaults, // useful to generate sample configuration files
[ "MakeSampleFileConfig", "returns", "a", "sample", "config", "structure", "populated", "by", "defaults", "useful", "to", "generate", "sample", "configuration", "files" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/config/fileconf.go#L239-L297
train
gravitational/teleport
lib/config/fileconf.go
DebugDumpToYAML
func (conf *FileConfig) DebugDumpToYAML() string { bytes, err := yaml.Marshal(&conf) if err != nil { panic(err) } return string(bytes) }
go
func (conf *FileConfig) DebugDumpToYAML() string { bytes, err := yaml.Marshal(&conf) if err != nil { panic(err) } return string(bytes) }
[ "func", "(", "conf", "*", "FileConfig", ")", "DebugDumpToYAML", "(", ")", "string", "{", "bytes", ",", "err", ":=", "yaml", ".", "Marshal", "(", "&", "conf", ")", "\n", "if", "err", "!=", "nil", "{", "panic", "(", "err", ")", "\n", "}", "\n", "re...
// DebugDumpToYAML allows for quick YAML dumping of the config
[ "DebugDumpToYAML", "allows", "for", "quick", "YAML", "dumping", "of", "the", "config" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/config/fileconf.go#L300-L306
train
gravitational/teleport
lib/config/fileconf.go
Parse
func (c *CachePolicy) Parse() (*service.CachePolicy, error) { out := service.CachePolicy{ Enabled: c.Enabled(), NeverExpires: c.NeverExpires(), } if out.NeverExpires { return &out, nil } var err error if c.TTL != "" { out.TTL, err = time.ParseDuration(c.TTL) if err != nil { return nil, trace.Bad...
go
func (c *CachePolicy) Parse() (*service.CachePolicy, error) { out := service.CachePolicy{ Enabled: c.Enabled(), NeverExpires: c.NeverExpires(), } if out.NeverExpires { return &out, nil } var err error if c.TTL != "" { out.TTL, err = time.ParseDuration(c.TTL) if err != nil { return nil, trace.Bad...
[ "func", "(", "c", "*", "CachePolicy", ")", "Parse", "(", ")", "(", "*", "service", ".", "CachePolicy", ",", "error", ")", "{", "out", ":=", "service", ".", "CachePolicy", "{", "Enabled", ":", "c", ".", "Enabled", "(", ")", ",", "NeverExpires", ":", ...
// Parse parses cache policy from Teleport config
[ "Parse", "parses", "cache", "policy", "from", "Teleport", "config" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/config/fileconf.go#L425-L441
train
gravitational/teleport
lib/config/fileconf.go
Parse
func (p *PAM) Parse() *pam.Config { serviceName := p.ServiceName if serviceName == "" { serviceName = defaults.ServiceName } enabled, _ := utils.ParseBool(p.Enabled) return &pam.Config{ Enabled: enabled, ServiceName: serviceName, } }
go
func (p *PAM) Parse() *pam.Config { serviceName := p.ServiceName if serviceName == "" { serviceName = defaults.ServiceName } enabled, _ := utils.ParseBool(p.Enabled) return &pam.Config{ Enabled: enabled, ServiceName: serviceName, } }
[ "func", "(", "p", "*", "PAM", ")", "Parse", "(", ")", "*", "pam", ".", "Config", "{", "serviceName", ":=", "p", ".", "ServiceName", "\n", "if", "serviceName", "==", "\"", "\"", "{", "serviceName", "=", "defaults", ".", "ServiceName", "\n", "}", "\n",...
// Parse returns a parsed pam.Config.
[ "Parse", "returns", "a", "parsed", "pam", ".", "Config", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/config/fileconf.go#L710-L720
train
gravitational/teleport
lib/config/fileconf.go
ConvertAndValidate
func (t *ReverseTunnel) ConvertAndValidate() (services.ReverseTunnel, error) { for i := range t.Addresses { addr, err := utils.ParseHostPortAddr(t.Addresses[i], defaults.SSHProxyTunnelListenPort) if err != nil { return nil, trace.Wrap(err, "Invalid address for tunnel %v", t.DomainName) } t.Addresses[i] = ad...
go
func (t *ReverseTunnel) ConvertAndValidate() (services.ReverseTunnel, error) { for i := range t.Addresses { addr, err := utils.ParseHostPortAddr(t.Addresses[i], defaults.SSHProxyTunnelListenPort) if err != nil { return nil, trace.Wrap(err, "Invalid address for tunnel %v", t.DomainName) } t.Addresses[i] = ad...
[ "func", "(", "t", "*", "ReverseTunnel", ")", "ConvertAndValidate", "(", ")", "(", "services", ".", "ReverseTunnel", ",", "error", ")", "{", "for", "i", ":=", "range", "t", ".", "Addresses", "{", "addr", ",", "err", ":=", "utils", ".", "ParseHostPortAddr"...
// ConvertAndValidate returns validated services.ReverseTunnel or nil and error otherwize
[ "ConvertAndValidate", "returns", "validated", "services", ".", "ReverseTunnel", "or", "nil", "and", "error", "otherwize" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/config/fileconf.go#L778-L792
train
gravitational/teleport
lib/config/fileconf.go
Parse
func (a *Authority) Parse() (services.CertAuthority, services.Role, error) { ca := &services.CertAuthorityV1{ AllowedLogins: a.AllowedLogins, DomainName: a.DomainName, Type: a.Type, } for _, path := range a.CheckingKeyFiles { keyBytes, err := utils.ReadPath(path) if err != nil { return nil,...
go
func (a *Authority) Parse() (services.CertAuthority, services.Role, error) { ca := &services.CertAuthorityV1{ AllowedLogins: a.AllowedLogins, DomainName: a.DomainName, Type: a.Type, } for _, path := range a.CheckingKeyFiles { keyBytes, err := utils.ReadPath(path) if err != nil { return nil,...
[ "func", "(", "a", "*", "Authority", ")", "Parse", "(", ")", "(", "services", ".", "CertAuthority", ",", "services", ".", "Role", ",", "error", ")", "{", "ca", ":=", "&", "services", ".", "CertAuthorityV1", "{", "AllowedLogins", ":", "a", ".", "AllowedL...
// Parse reads values and returns parsed CertAuthority
[ "Parse", "reads", "values", "and", "returns", "parsed", "CertAuthority" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/config/fileconf.go#L818-L851
train
gravitational/teleport
lib/config/fileconf.go
Parse
func (o *OIDCConnector) Parse() (services.OIDCConnector, error) { if o.Display == "" { o.Display = o.ID } var mappings []services.ClaimMapping for _, c := range o.ClaimsToRoles { var roles []string if len(c.Roles) > 0 { roles = append(roles, c.Roles...) } mappings = append(mappings, services.ClaimMap...
go
func (o *OIDCConnector) Parse() (services.OIDCConnector, error) { if o.Display == "" { o.Display = o.ID } var mappings []services.ClaimMapping for _, c := range o.ClaimsToRoles { var roles []string if len(c.Roles) > 0 { roles = append(roles, c.Roles...) } mappings = append(mappings, services.ClaimMap...
[ "func", "(", "o", "*", "OIDCConnector", ")", "Parse", "(", ")", "(", "services", ".", "OIDCConnector", ",", "error", ")", "{", "if", "o", ".", "Display", "==", "\"", "\"", "{", "o", ".", "Display", "=", "o", ".", "ID", "\n", "}", "\n\n", "var", ...
// Parse parses config struct into services connector and checks if it's valid
[ "Parse", "parses", "config", "struct", "into", "services", "connector", "and", "checks", "if", "it", "s", "valid" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/config/fileconf.go#L898-L935
train
gravitational/teleport
lib/config/fileconf.go
Parse
func (u *U2F) Parse() (*services.U2F, error) { // If no appID specified, default to hostname appID := u.AppID if appID == "" { hostname, err := os.Hostname() if err != nil { return nil, trace.Wrap(err, "failed to automatically determine U2F AppID from hostname") } appID = fmt.Sprintf("https://%s:%d", stri...
go
func (u *U2F) Parse() (*services.U2F, error) { // If no appID specified, default to hostname appID := u.AppID if appID == "" { hostname, err := os.Hostname() if err != nil { return nil, trace.Wrap(err, "failed to automatically determine U2F AppID from hostname") } appID = fmt.Sprintf("https://%s:%d", stri...
[ "func", "(", "u", "*", "U2F", ")", "Parse", "(", ")", "(", "*", "services", ".", "U2F", ",", "error", ")", "{", "// If no appID specified, default to hostname", "appID", ":=", "u", ".", "AppID", "\n", "if", "appID", "==", "\"", "\"", "{", "hostname", "...
// Parse parses values in the U2F configuration section and validates its content.
[ "Parse", "parses", "values", "in", "the", "U2F", "configuration", "section", "and", "validates", "its", "content", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/config/fileconf.go#L943-L964
train