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/utils/copy.go
CopyByteSlice
func CopyByteSlice(in []byte) []byte { if in == nil { return nil } out := make([]byte, len(in)) copy(out, in) return out }
go
func CopyByteSlice(in []byte) []byte { if in == nil { return nil } out := make([]byte, len(in)) copy(out, in) return out }
[ "func", "CopyByteSlice", "(", "in", "[", "]", "byte", ")", "[", "]", "byte", "{", "if", "in", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "out", ":=", "make", "(", "[", "]", "byte", ",", "len", "(", "in", ")", ")", "\n", "copy", "(", ...
// CopyByteSlice returns a copy of the byte slice.
[ "CopyByteSlice", "returns", "a", "copy", "of", "the", "byte", "slice", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/copy.go#L20-L27
train
gravitational/teleport
lib/utils/copy.go
CopyByteSlices
func CopyByteSlices(in [][]byte) [][]byte { if in == nil { return nil } out := make([][]byte, len(in)) for i := range in { out[i] = CopyByteSlice(in[i]) } return out }
go
func CopyByteSlices(in [][]byte) [][]byte { if in == nil { return nil } out := make([][]byte, len(in)) for i := range in { out[i] = CopyByteSlice(in[i]) } return out }
[ "func", "CopyByteSlices", "(", "in", "[", "]", "[", "]", "byte", ")", "[", "]", "[", "]", "byte", "{", "if", "in", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "out", ":=", "make", "(", "[", "]", "[", "]", "byte", ",", "len", "(", "i...
// CopyByteSlices returns a copy of the byte slices.
[ "CopyByteSlices", "returns", "a", "copy", "of", "the", "byte", "slices", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/copy.go#L30-L39
train
gravitational/teleport
lib/utils/copy.go
JoinStringSlices
func JoinStringSlices(a []string, b []string) []string { if len(a)+len(b) == 0 { return nil } out := make([]string, 0, len(a)+len(b)) out = append(out, a...) out = append(out, b...) return out }
go
func JoinStringSlices(a []string, b []string) []string { if len(a)+len(b) == 0 { return nil } out := make([]string, 0, len(a)+len(b)) out = append(out, a...) out = append(out, b...) return out }
[ "func", "JoinStringSlices", "(", "a", "[", "]", "string", ",", "b", "[", "]", "string", ")", "[", "]", "string", "{", "if", "len", "(", "a", ")", "+", "len", "(", "b", ")", "==", "0", "{", "return", "nil", "\n", "}", "\n", "out", ":=", "make"...
// JoinStringSlices joins two string slices and returns a resulting slice
[ "JoinStringSlices", "joins", "two", "string", "slices", "and", "returns", "a", "resulting", "slice" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/copy.go#L42-L50
train
gravitational/teleport
lib/utils/copy.go
CopyStrings
func CopyStrings(in []string) []string { if in == nil { return nil } out := make([]string, len(in)) copy(out, in) return out }
go
func CopyStrings(in []string) []string { if in == nil { return nil } out := make([]string, len(in)) copy(out, in) return out }
[ "func", "CopyStrings", "(", "in", "[", "]", "string", ")", "[", "]", "string", "{", "if", "in", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "out", ":=", "make", "(", "[", "]", "string", ",", "len", "(", "in", ")", ")", "\n", "copy", ...
// CopyStrings makes a deep copy of the passed in string slice and returns // the copy.
[ "CopyStrings", "makes", "a", "deep", "copy", "of", "the", "passed", "in", "string", "slice", "and", "returns", "the", "copy", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/copy.go#L54-L63
train
gravitational/teleport
lib/utils/copy.go
ReplaceInSlice
func ReplaceInSlice(s []string, old string, new string) []string { out := make([]string, 0, len(s)) for _, x := range s { if x == old { out = append(out, new) } else { out = append(out, x) } } return out }
go
func ReplaceInSlice(s []string, old string, new string) []string { out := make([]string, 0, len(s)) for _, x := range s { if x == old { out = append(out, new) } else { out = append(out, x) } } return out }
[ "func", "ReplaceInSlice", "(", "s", "[", "]", "string", ",", "old", "string", ",", "new", "string", ")", "[", "]", "string", "{", "out", ":=", "make", "(", "[", "]", "string", ",", "0", ",", "len", "(", "s", ")", ")", "\n\n", "for", "_", ",", ...
// ReplaceInSlice replaces element old with new and returns a new slice.
[ "ReplaceInSlice", "replaces", "element", "old", "with", "new", "and", "returns", "a", "new", "slice", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/copy.go#L112-L124
train
gravitational/teleport
lib/service/connect.go
reconnectToAuthService
func (process *TeleportProcess) reconnectToAuthService(role teleport.Role) (*Connector, error) { retryTime := defaults.HighResPollingPeriod for { connector, err := process.connectToAuthService(role) if err == nil { // if connected and client is present, make sure the connector's // client works, by using ca...
go
func (process *TeleportProcess) reconnectToAuthService(role teleport.Role) (*Connector, error) { retryTime := defaults.HighResPollingPeriod for { connector, err := process.connectToAuthService(role) if err == nil { // if connected and client is present, make sure the connector's // client works, by using ca...
[ "func", "(", "process", "*", "TeleportProcess", ")", "reconnectToAuthService", "(", "role", "teleport", ".", "Role", ")", "(", "*", "Connector", ",", "error", ")", "{", "retryTime", ":=", "defaults", ".", "HighResPollingPeriod", "\n", "for", "{", "connector", ...
// reconnectToAuthService continuously attempts to reconnect to the auth // service until succeeds or process gets shut down
[ "reconnectToAuthService", "continuously", "attempts", "to", "reconnect", "to", "the", "auth", "service", "until", "succeeds", "or", "process", "gets", "shut", "down" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/service/connect.go#L41-L68
train
gravitational/teleport
lib/service/connect.go
connectToAuthService
func (process *TeleportProcess) connectToAuthService(role teleport.Role) (*Connector, error) { connector, err := process.connect(role) if err != nil { return nil, trace.Wrap(err) } process.Debugf("Connected client: %v", connector.ClientIdentity) process.Debugf("Connected server: %v", connector.ServerIdentity) p...
go
func (process *TeleportProcess) connectToAuthService(role teleport.Role) (*Connector, error) { connector, err := process.connect(role) if err != nil { return nil, trace.Wrap(err) } process.Debugf("Connected client: %v", connector.ClientIdentity) process.Debugf("Connected server: %v", connector.ServerIdentity) p...
[ "func", "(", "process", "*", "TeleportProcess", ")", "connectToAuthService", "(", "role", "teleport", ".", "Role", ")", "(", "*", "Connector", ",", "error", ")", "{", "connector", ",", "err", ":=", "process", ".", "connect", "(", "role", ")", "\n", "if",...
// connectToAuthService attempts to login into the auth servers specified in the // configuration and receive credentials.
[ "connectToAuthService", "attempts", "to", "login", "into", "the", "auth", "servers", "specified", "in", "the", "configuration", "and", "receive", "credentials", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/service/connect.go#L72-L82
train
gravitational/teleport
lib/service/connect.go
newWatcher
func (process *TeleportProcess) newWatcher(conn *Connector, watch services.Watch) (services.Watcher, error) { if conn.ClientIdentity.ID.Role == teleport.RoleAdmin || conn.ClientIdentity.ID.Role == teleport.RoleAuth { return process.localAuth.NewWatcher(process.ExitContext(), watch) } return conn.Client.NewWatcher(...
go
func (process *TeleportProcess) newWatcher(conn *Connector, watch services.Watch) (services.Watcher, error) { if conn.ClientIdentity.ID.Role == teleport.RoleAdmin || conn.ClientIdentity.ID.Role == teleport.RoleAuth { return process.localAuth.NewWatcher(process.ExitContext(), watch) } return conn.Client.NewWatcher(...
[ "func", "(", "process", "*", "TeleportProcess", ")", "newWatcher", "(", "conn", "*", "Connector", ",", "watch", "services", ".", "Watch", ")", "(", "services", ".", "Watcher", ",", "error", ")", "{", "if", "conn", ".", "ClientIdentity", ".", "ID", ".", ...
// newWatcher returns a new watcher, // either using local auth server connection or remote client
[ "newWatcher", "returns", "a", "new", "watcher", "either", "using", "local", "auth", "server", "connection", "or", "remote", "client" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/service/connect.go#L279-L284
train
gravitational/teleport
lib/service/connect.go
getCertAuthority
func (process *TeleportProcess) getCertAuthority(conn *Connector, id services.CertAuthID, loadPrivateKeys bool) (services.CertAuthority, error) { if conn.ClientIdentity.ID.Role == teleport.RoleAdmin || conn.ClientIdentity.ID.Role == teleport.RoleAuth { return process.localAuth.GetCertAuthority(id, loadPrivateKeys) ...
go
func (process *TeleportProcess) getCertAuthority(conn *Connector, id services.CertAuthID, loadPrivateKeys bool) (services.CertAuthority, error) { if conn.ClientIdentity.ID.Role == teleport.RoleAdmin || conn.ClientIdentity.ID.Role == teleport.RoleAuth { return process.localAuth.GetCertAuthority(id, loadPrivateKeys) ...
[ "func", "(", "process", "*", "TeleportProcess", ")", "getCertAuthority", "(", "conn", "*", "Connector", ",", "id", "services", ".", "CertAuthID", ",", "loadPrivateKeys", "bool", ")", "(", "services", ".", "CertAuthority", ",", "error", ")", "{", "if", "conn"...
// getCertAuthority returns cert authority by ID. // In case if auth servers, the role is 'TeleportAdmin' and instead of using // TLS client this method uses the local auth server.
[ "getCertAuthority", "returns", "cert", "authority", "by", "ID", ".", "In", "case", "if", "auth", "servers", "the", "role", "is", "TeleportAdmin", "and", "instead", "of", "using", "TLS", "client", "this", "method", "uses", "the", "local", "auth", "server", "....
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/service/connect.go#L289-L294
train
gravitational/teleport
lib/service/connect.go
reRegister
func (process *TeleportProcess) reRegister(conn *Connector, additionalPrincipals []string, dnsNames []string, rotation services.Rotation) (*auth.Identity, error) { if conn.ClientIdentity.ID.Role == teleport.RoleAdmin || conn.ClientIdentity.ID.Role == teleport.RoleAuth { return auth.GenerateIdentity(process.localAuth...
go
func (process *TeleportProcess) reRegister(conn *Connector, additionalPrincipals []string, dnsNames []string, rotation services.Rotation) (*auth.Identity, error) { if conn.ClientIdentity.ID.Role == teleport.RoleAdmin || conn.ClientIdentity.ID.Role == teleport.RoleAuth { return auth.GenerateIdentity(process.localAuth...
[ "func", "(", "process", "*", "TeleportProcess", ")", "reRegister", "(", "conn", "*", "Connector", ",", "additionalPrincipals", "[", "]", "string", ",", "dnsNames", "[", "]", "string", ",", "rotation", "services", ".", "Rotation", ")", "(", "*", "auth", "."...
// reRegister receives new identity credentials for proxy, node and auth. // In case if auth servers, the role is 'TeleportAdmin' and instead of using // TLS client this method uses the local auth server.
[ "reRegister", "receives", "new", "identity", "credentials", "for", "proxy", "node", "and", "auth", ".", "In", "case", "if", "auth", "servers", "the", "role", "is", "TeleportAdmin", "and", "instead", "of", "using", "TLS", "client", "this", "method", "uses", "...
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/service/connect.go#L299-L323
train
gravitational/teleport
lib/service/connect.go
periodicSyncRotationState
func (process *TeleportProcess) periodicSyncRotationState() error { // start rotation only after teleport process has started eventC := make(chan Event, 1) process.WaitForEvent(process.ExitContext(), TeleportReadyEvent, eventC) select { case <-eventC: process.Infof("The new service has started successfully. Star...
go
func (process *TeleportProcess) periodicSyncRotationState() error { // start rotation only after teleport process has started eventC := make(chan Event, 1) process.WaitForEvent(process.ExitContext(), TeleportReadyEvent, eventC) select { case <-eventC: process.Infof("The new service has started successfully. Star...
[ "func", "(", "process", "*", "TeleportProcess", ")", "periodicSyncRotationState", "(", ")", "error", "{", "// start rotation only after teleport process has started", "eventC", ":=", "make", "(", "chan", "Event", ",", "1", ")", "\n", "process", ".", "WaitForEvent", ...
// periodicSyncRotationState checks rotation state periodically and // takes action if necessary
[ "periodicSyncRotationState", "checks", "rotation", "state", "periodically", "and", "takes", "action", "if", "necessary" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/service/connect.go#L441-L466
train
gravitational/teleport
lib/service/connect.go
syncRotationStateAndBroadcast
func (process *TeleportProcess) syncRotationStateAndBroadcast(conn *Connector) (*rotationStatus, error) { status, err := process.syncRotationState(conn) if err != nil { process.BroadcastEvent(Event{Name: TeleportDegradedEvent, Payload: nil}) if trace.IsConnectionProblem(err) { process.Warningf("Connection prob...
go
func (process *TeleportProcess) syncRotationStateAndBroadcast(conn *Connector) (*rotationStatus, error) { status, err := process.syncRotationState(conn) if err != nil { process.BroadcastEvent(Event{Name: TeleportDegradedEvent, Payload: nil}) if trace.IsConnectionProblem(err) { process.Warningf("Connection prob...
[ "func", "(", "process", "*", "TeleportProcess", ")", "syncRotationStateAndBroadcast", "(", "conn", "*", "Connector", ")", "(", "*", "rotationStatus", ",", "error", ")", "{", "status", ",", "err", ":=", "process", ".", "syncRotationState", "(", "conn", ")", "...
// syncRotationStateAndBroadcast syncs rotation state and broadcasts events // when phase has been changed or reload happened
[ "syncRotationStateAndBroadcast", "syncs", "rotation", "state", "and", "broadcasts", "events", "when", "phase", "has", "been", "changed", "or", "reload", "happened" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/service/connect.go#L546-L570
train
gravitational/teleport
lib/service/connect.go
syncRotationState
func (process *TeleportProcess) syncRotationState(conn *Connector) (*rotationStatus, error) { connectors := process.getConnectors() ca, err := process.getCertAuthority(conn, services.CertAuthID{ DomainName: conn.ClientIdentity.ClusterName, Type: services.HostCA, }, false) if err != nil { return nil, tra...
go
func (process *TeleportProcess) syncRotationState(conn *Connector) (*rotationStatus, error) { connectors := process.getConnectors() ca, err := process.getCertAuthority(conn, services.CertAuthID{ DomainName: conn.ClientIdentity.ClusterName, Type: services.HostCA, }, false) if err != nil { return nil, tra...
[ "func", "(", "process", "*", "TeleportProcess", ")", "syncRotationState", "(", "conn", "*", "Connector", ")", "(", "*", "rotationStatus", ",", "error", ")", "{", "connectors", ":=", "process", ".", "getConnectors", "(", ")", "\n", "ca", ",", "err", ":=", ...
// syncRotationState compares cluster rotation state with the state of // internal services and performs the rotation if necessary.
[ "syncRotationState", "compares", "cluster", "rotation", "state", "with", "the", "state", "of", "internal", "services", "and", "performs", "the", "rotation", "if", "necessary", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/service/connect.go#L574-L598
train
gravitational/teleport
lib/service/connect.go
newClient
func (process *TeleportProcess) newClient(authServers []utils.NetAddr, identity *auth.Identity) (*auth.Client, bool, error) { directClient, err := process.newClientDirect(authServers, identity) if err != nil { return nil, false, trace.Wrap(err) } // Try and connect to the Auth Server. If the request fails, try a...
go
func (process *TeleportProcess) newClient(authServers []utils.NetAddr, identity *auth.Identity) (*auth.Client, bool, error) { directClient, err := process.newClientDirect(authServers, identity) if err != nil { return nil, false, trace.Wrap(err) } // Try and connect to the Auth Server. If the request fails, try a...
[ "func", "(", "process", "*", "TeleportProcess", ")", "newClient", "(", "authServers", "[", "]", "utils", ".", "NetAddr", ",", "identity", "*", "auth", ".", "Identity", ")", "(", "*", "auth", ".", "Client", ",", "bool", ",", "error", ")", "{", "directCl...
// newClient attempts to connect directly to the Auth Server. If it fails, it // falls back to trying to connect to the Auth Server through the proxy.
[ "newClient", "attempts", "to", "connect", "directly", "to", "the", "Auth", "Server", ".", "If", "it", "fails", "it", "falls", "back", "to", "trying", "to", "connect", "to", "the", "Auth", "Server", "through", "the", "proxy", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/service/connect.go#L778-L806
train
gravitational/teleport
lib/service/connect.go
findReverseTunnel
func (process *TeleportProcess) findReverseTunnel(addrs []utils.NetAddr) (string, error) { var errs []error for _, addr := range addrs { // In insecure mode, any certificate is accepted. In secure mode the hosts // CAs are used to validate the certificate on the proxy. clt, err := client.NewCredentialsClient( ...
go
func (process *TeleportProcess) findReverseTunnel(addrs []utils.NetAddr) (string, error) { var errs []error for _, addr := range addrs { // In insecure mode, any certificate is accepted. In secure mode the hosts // CAs are used to validate the certificate on the proxy. clt, err := client.NewCredentialsClient( ...
[ "func", "(", "process", "*", "TeleportProcess", ")", "findReverseTunnel", "(", "addrs", "[", "]", "utils", ".", "NetAddr", ")", "(", "string", ",", "error", ")", "{", "var", "errs", "[", "]", "error", "\n", "for", "_", ",", "addr", ":=", "range", "ad...
// findReverseTunnel uses the web proxy to discover where the SSH reverse tunnel // server is running.
[ "findReverseTunnel", "uses", "the", "web", "proxy", "to", "discover", "where", "the", "SSH", "reverse", "tunnel", "server", "is", "running", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/service/connect.go#L810-L835
train
gravitational/teleport
lib/utils/spki.go
CalculateSPKI
func CalculateSPKI(cert *x509.Certificate) string { sum := sha256.Sum256(cert.RawSubjectPublicKeyInfo) return "sha256:" + hex.EncodeToString(sum[:]) }
go
func CalculateSPKI(cert *x509.Certificate) string { sum := sha256.Sum256(cert.RawSubjectPublicKeyInfo) return "sha256:" + hex.EncodeToString(sum[:]) }
[ "func", "CalculateSPKI", "(", "cert", "*", "x509", ".", "Certificate", ")", "string", "{", "sum", ":=", "sha256", ".", "Sum256", "(", "cert", ".", "RawSubjectPublicKeyInfo", ")", "\n", "return", "\"", "\"", "+", "hex", ".", "EncodeToString", "(", "sum", ...
// CalculateSPKI the hash value of the SPKI header in a certificate.
[ "CalculateSPKI", "the", "hash", "value", "of", "the", "SPKI", "header", "in", "a", "certificate", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/spki.go#L30-L33
train
gravitational/teleport
lib/utils/spki.go
CheckSPKI
func CheckSPKI(pin string, cert *x509.Certificate) error { // Check that the format of the pin is valid. parts := strings.Split(pin, ":") if len(parts) != 2 { return trace.BadParameter("invalid format for certificate pin, expected algorithm:pin") } if parts[0] != "sha256" { return trace.BadParameter("sha256 on...
go
func CheckSPKI(pin string, cert *x509.Certificate) error { // Check that the format of the pin is valid. parts := strings.Split(pin, ":") if len(parts) != 2 { return trace.BadParameter("invalid format for certificate pin, expected algorithm:pin") } if parts[0] != "sha256" { return trace.BadParameter("sha256 on...
[ "func", "CheckSPKI", "(", "pin", "string", ",", "cert", "*", "x509", ".", "Certificate", ")", "error", "{", "// Check that the format of the pin is valid.", "parts", ":=", "strings", ".", "Split", "(", "pin", ",", "\"", "\"", ")", "\n", "if", "len", "(", "...
// CheckSPKI the passed in pin against the calculated value from a certificate.
[ "CheckSPKI", "the", "passed", "in", "pin", "against", "the", "calculated", "value", "from", "a", "certificate", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/spki.go#L36-L53
train
gravitational/teleport
lib/httplib/httplib.go
MakeHandler
func MakeHandler(fn HandlerFunc) httprouter.Handle { return func(w http.ResponseWriter, r *http.Request, p httprouter.Params) { // ensure that neither proxies nor browsers cache http traffic SetNoCacheHeaders(w.Header()) out, err := fn(w, r, p) if err != nil { trace.WriteError(w, err) return } if ou...
go
func MakeHandler(fn HandlerFunc) httprouter.Handle { return func(w http.ResponseWriter, r *http.Request, p httprouter.Params) { // ensure that neither proxies nor browsers cache http traffic SetNoCacheHeaders(w.Header()) out, err := fn(w, r, p) if err != nil { trace.WriteError(w, err) return } if ou...
[ "func", "MakeHandler", "(", "fn", "HandlerFunc", ")", "httprouter", ".", "Handle", "{", "return", "func", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ",", "p", "httprouter", ".", "Params", ")", "{", "// ensure that neith...
// MakeHandler returns a new httprouter.Handle func from a handler func
[ "MakeHandler", "returns", "a", "new", "httprouter", ".", "Handle", "func", "from", "a", "handler", "func" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/httplib/httplib.go#L45-L59
train
gravitational/teleport
lib/httplib/httplib.go
MakeStdHandler
func MakeStdHandler(fn StdHandlerFunc) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { // ensure that neither proxies nor browsers cache http traffic SetNoCacheHeaders(w.Header()) out, err := fn(w, r) if err != nil { trace.WriteError(w, err) return } if out != nil { round...
go
func MakeStdHandler(fn StdHandlerFunc) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { // ensure that neither proxies nor browsers cache http traffic SetNoCacheHeaders(w.Header()) out, err := fn(w, r) if err != nil { trace.WriteError(w, err) return } if out != nil { round...
[ "func", "MakeStdHandler", "(", "fn", "StdHandlerFunc", ")", "http", ".", "HandlerFunc", "{", "return", "func", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ")", "{", "// ensure that neither proxies nor browsers cache http traffic",...
// MakeStdHandler returns a new http.Handle func from http.HandlerFunc
[ "MakeStdHandler", "returns", "a", "new", "http", ".", "Handle", "func", "from", "http", ".", "HandlerFunc" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/httplib/httplib.go#L62-L76
train
gravitational/teleport
lib/httplib/httplib.go
WithCSRFProtection
func WithCSRFProtection(fn HandlerFunc) httprouter.Handle { hanlderFn := MakeHandler(fn) return func(w http.ResponseWriter, r *http.Request, p httprouter.Params) { err := csrf.VerifyHTTPHeader(r) if err != nil { log.Warningf("unable to validate CSRF token %v", err) trace.WriteError(w, trace.AccessDenied("ac...
go
func WithCSRFProtection(fn HandlerFunc) httprouter.Handle { hanlderFn := MakeHandler(fn) return func(w http.ResponseWriter, r *http.Request, p httprouter.Params) { err := csrf.VerifyHTTPHeader(r) if err != nil { log.Warningf("unable to validate CSRF token %v", err) trace.WriteError(w, trace.AccessDenied("ac...
[ "func", "WithCSRFProtection", "(", "fn", "HandlerFunc", ")", "httprouter", ".", "Handle", "{", "hanlderFn", ":=", "MakeHandler", "(", "fn", ")", "\n", "return", "func", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ",", ...
// WithCSRFProtection ensures that request to unauthenticated API is checked against CSRF attacks
[ "WithCSRFProtection", "ensures", "that", "request", "to", "unauthenticated", "API", "is", "checked", "against", "CSRF", "attacks" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/httplib/httplib.go#L79-L90
train
gravitational/teleport
lib/httplib/httplib.go
ConvertResponse
func ConvertResponse(re *roundtrip.Response, err error) (*roundtrip.Response, error) { if err != nil { if uerr, ok := err.(*url.Error); ok && uerr != nil && uerr.Err != nil { return nil, trace.ConnectionProblem(uerr.Err, uerr.Error()) } return nil, trace.ConvertSystemError(err) } return re, trace.ReadError(...
go
func ConvertResponse(re *roundtrip.Response, err error) (*roundtrip.Response, error) { if err != nil { if uerr, ok := err.(*url.Error); ok && uerr != nil && uerr.Err != nil { return nil, trace.ConnectionProblem(uerr.Err, uerr.Error()) } return nil, trace.ConvertSystemError(err) } return re, trace.ReadError(...
[ "func", "ConvertResponse", "(", "re", "*", "roundtrip", ".", "Response", ",", "err", "error", ")", "(", "*", "roundtrip", ".", "Response", ",", "error", ")", "{", "if", "err", "!=", "nil", "{", "if", "uerr", ",", "ok", ":=", "err", ".", "(", "*", ...
// ConvertResponse converts http error to internal error type // based on HTTP response code and HTTP body contents
[ "ConvertResponse", "converts", "http", "error", "to", "internal", "error", "type", "based", "on", "HTTP", "response", "code", "and", "HTTP", "body", "contents" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/httplib/httplib.go#L107-L115
train
gravitational/teleport
lib/httplib/httplib.go
ParseBool
func ParseBool(q url.Values, name string) (bool, bool, error) { stringVal := q.Get(name) if stringVal == "" { return false, false, nil } val, err := strconv.ParseBool(stringVal) if err != nil { return false, false, trace.BadParameter( "'%v': expected 'true' or 'false', got %v", name, stringVal) } return ...
go
func ParseBool(q url.Values, name string) (bool, bool, error) { stringVal := q.Get(name) if stringVal == "" { return false, false, nil } val, err := strconv.ParseBool(stringVal) if err != nil { return false, false, trace.BadParameter( "'%v': expected 'true' or 'false', got %v", name, stringVal) } return ...
[ "func", "ParseBool", "(", "q", "url", ".", "Values", ",", "name", "string", ")", "(", "bool", ",", "bool", ",", "error", ")", "{", "stringVal", ":=", "q", ".", "Get", "(", "name", ")", "\n", "if", "stringVal", "==", "\"", "\"", "{", "return", "fa...
// ParseBool will parse boolean variable from url query // returns value, ok, error
[ "ParseBool", "will", "parse", "boolean", "variable", "from", "url", "query", "returns", "value", "ok", "error" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/httplib/httplib.go#L119-L131
train
gravitational/teleport
lib/httplib/httplib.go
Rewrite
func Rewrite(in, out string) RewritePair { return RewritePair{ Expr: regexp.MustCompile(in), Replacement: out, } }
go
func Rewrite(in, out string) RewritePair { return RewritePair{ Expr: regexp.MustCompile(in), Replacement: out, } }
[ "func", "Rewrite", "(", "in", ",", "out", "string", ")", "RewritePair", "{", "return", "RewritePair", "{", "Expr", ":", "regexp", ".", "MustCompile", "(", "in", ")", ",", "Replacement", ":", "out", ",", "}", "\n", "}" ]
// Rewrite creates a rewrite pair, panics if in epxression // is not a valid regular expressoin
[ "Rewrite", "creates", "a", "rewrite", "pair", "panics", "if", "in", "epxression", "is", "not", "a", "valid", "regular", "expressoin" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/httplib/httplib.go#L143-L148
train
gravitational/teleport
lib/httplib/httplib.go
RewritePaths
func RewritePaths(next http.Handler, rewrites ...RewritePair) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { for _, rewrite := range rewrites { req.URL.Path = rewrite.Expr.ReplaceAllString(req.URL.Path, rewrite.Replacement) } next.ServeHTTP(w, req) }) }
go
func RewritePaths(next http.Handler, rewrites ...RewritePair) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { for _, rewrite := range rewrites { req.URL.Path = rewrite.Expr.ReplaceAllString(req.URL.Path, rewrite.Replacement) } next.ServeHTTP(w, req) }) }
[ "func", "RewritePaths", "(", "next", "http", ".", "Handler", ",", "rewrites", "...", "RewritePair", ")", "http", ".", "Handler", "{", "return", "http", ".", "HandlerFunc", "(", "func", "(", "w", "http", ".", "ResponseWriter", ",", "req", "*", "http", "."...
// RewritePaths creates a middleware that rewrites paths in incoming request
[ "RewritePaths", "creates", "a", "middleware", "that", "rewrites", "paths", "in", "incoming", "request" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/httplib/httplib.go#L151-L158
train
gravitational/teleport
lib/httplib/httplib.go
SafeRedirect
func SafeRedirect(w http.ResponseWriter, r *http.Request, redirectURL string) error { parsedURL, err := url.Parse(redirectURL) if err != nil { return trace.Wrap(err) } http.Redirect(w, r, parsedURL.RequestURI(), http.StatusFound) return nil }
go
func SafeRedirect(w http.ResponseWriter, r *http.Request, redirectURL string) error { parsedURL, err := url.Parse(redirectURL) if err != nil { return trace.Wrap(err) } http.Redirect(w, r, parsedURL.RequestURI(), http.StatusFound) return nil }
[ "func", "SafeRedirect", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ",", "redirectURL", "string", ")", "error", "{", "parsedURL", ",", "err", ":=", "url", ".", "Parse", "(", "redirectURL", ")", "\n", "if", "err", "!=...
// SafeRedirect performs a relative redirect to the URI part of the provided redirect URL
[ "SafeRedirect", "performs", "a", "relative", "redirect", "to", "the", "URI", "part", "of", "the", "provided", "redirect", "URL" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/httplib/httplib.go#L161-L168
train
gravitational/teleport
lib/srv/ctx.go
CreateOrJoinSession
func (c *ServerContext) CreateOrJoinSession(reg *SessionRegistry) error { // As SSH conversation progresses, at some point a session will be created and // its ID will be added to the environment ssid, found := c.GetEnv(sshutils.SessionEnvVar) if !found { return nil } // make sure whatever session is requested ...
go
func (c *ServerContext) CreateOrJoinSession(reg *SessionRegistry) error { // As SSH conversation progresses, at some point a session will be created and // its ID will be added to the environment ssid, found := c.GetEnv(sshutils.SessionEnvVar) if !found { return nil } // make sure whatever session is requested ...
[ "func", "(", "c", "*", "ServerContext", ")", "CreateOrJoinSession", "(", "reg", "*", "SessionRegistry", ")", "error", "{", "// As SSH conversation progresses, at some point a session will be created and", "// its ID will be added to the environment", "ssid", ",", "found", ":=",...
// CreateOrJoinSession will look in the SessionRegistry for the session ID. If // no session is found, a new one is created. If one is found, it is returned.
[ "CreateOrJoinSession", "will", "look", "in", "the", "SessionRegistry", "for", "the", "session", "ID", ".", "If", "no", "session", "is", "found", "a", "new", "one", "is", "created", ".", "If", "one", "is", "found", "it", "is", "returned", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/srv/ctx.go#L332-L360
train
gravitational/teleport
lib/srv/ctx.go
UpdateClientActivity
func (c *ServerContext) UpdateClientActivity() { c.Lock() defer c.Unlock() c.clientLastActive = c.srv.GetClock().Now().UTC() }
go
func (c *ServerContext) UpdateClientActivity() { c.Lock() defer c.Unlock() c.clientLastActive = c.srv.GetClock().Now().UTC() }
[ "func", "(", "c", "*", "ServerContext", ")", "UpdateClientActivity", "(", ")", "{", "c", ".", "Lock", "(", ")", "\n", "defer", "c", ".", "Unlock", "(", ")", "\n", "c", ".", "clientLastActive", "=", "c", ".", "srv", ".", "GetClock", "(", ")", ".", ...
// UpdateClientActivity sets last recorded client activity associated with this context // either channel or session
[ "UpdateClientActivity", "sets", "last", "recorded", "client", "activity", "associated", "with", "this", "context", "either", "channel", "or", "session" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/srv/ctx.go#L371-L375
train
gravitational/teleport
lib/srv/ctx.go
GetAgent
func (c *ServerContext) GetAgent() agent.Agent { c.RLock() defer c.RUnlock() return c.agent }
go
func (c *ServerContext) GetAgent() agent.Agent { c.RLock() defer c.RUnlock() return c.agent }
[ "func", "(", "c", "*", "ServerContext", ")", "GetAgent", "(", ")", "agent", ".", "Agent", "{", "c", ".", "RLock", "(", ")", "\n", "defer", "c", ".", "RUnlock", "(", ")", "\n", "return", "c", ".", "agent", "\n", "}" ]
// GetAgent returns a agent.Agent which represents the capabilities of an SSH agent.
[ "GetAgent", "returns", "a", "agent", ".", "Agent", "which", "represents", "the", "capabilities", "of", "an", "SSH", "agent", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/srv/ctx.go#L386-L390
train
gravitational/teleport
lib/srv/ctx.go
GetAgentChannel
func (c *ServerContext) GetAgentChannel() ssh.Channel { c.RLock() defer c.RUnlock() return c.agentChannel }
go
func (c *ServerContext) GetAgentChannel() ssh.Channel { c.RLock() defer c.RUnlock() return c.agentChannel }
[ "func", "(", "c", "*", "ServerContext", ")", "GetAgentChannel", "(", ")", "ssh", ".", "Channel", "{", "c", ".", "RLock", "(", ")", "\n", "defer", "c", ".", "RUnlock", "(", ")", "\n", "return", "c", ".", "agentChannel", "\n", "}" ]
// GetAgentChannel returns the channel over which communication with the agent occurs.
[ "GetAgentChannel", "returns", "the", "channel", "over", "which", "communication", "with", "the", "agent", "occurs", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/srv/ctx.go#L393-L397
train
gravitational/teleport
lib/srv/ctx.go
SetAgent
func (c *ServerContext) SetAgent(a agent.Agent, channel ssh.Channel) { c.Lock() defer c.Unlock() if c.agentChannel != nil { c.Infof("closing previous agent channel") c.agentChannel.Close() } c.agentChannel = channel c.agent = a }
go
func (c *ServerContext) SetAgent(a agent.Agent, channel ssh.Channel) { c.Lock() defer c.Unlock() if c.agentChannel != nil { c.Infof("closing previous agent channel") c.agentChannel.Close() } c.agentChannel = channel c.agent = a }
[ "func", "(", "c", "*", "ServerContext", ")", "SetAgent", "(", "a", "agent", ".", "Agent", ",", "channel", "ssh", ".", "Channel", ")", "{", "c", ".", "Lock", "(", ")", "\n", "defer", "c", ".", "Unlock", "(", ")", "\n", "if", "c", ".", "agentChanne...
// SetAgent sets the agent and channel over which communication with the agent occurs.
[ "SetAgent", "sets", "the", "agent", "and", "channel", "over", "which", "communication", "with", "the", "agent", "occurs", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/srv/ctx.go#L400-L409
train
gravitational/teleport
lib/srv/ctx.go
GetTerm
func (c *ServerContext) GetTerm() Terminal { c.RLock() defer c.RUnlock() return c.term }
go
func (c *ServerContext) GetTerm() Terminal { c.RLock() defer c.RUnlock() return c.term }
[ "func", "(", "c", "*", "ServerContext", ")", "GetTerm", "(", ")", "Terminal", "{", "c", ".", "RLock", "(", ")", "\n", "defer", "c", ".", "RUnlock", "(", ")", "\n\n", "return", "c", ".", "term", "\n", "}" ]
// GetTerm returns a Terminal.
[ "GetTerm", "returns", "a", "Terminal", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/srv/ctx.go#L412-L417
train
gravitational/teleport
lib/srv/ctx.go
SetTerm
func (c *ServerContext) SetTerm(t Terminal) { c.Lock() defer c.Unlock() c.term = t }
go
func (c *ServerContext) SetTerm(t Terminal) { c.Lock() defer c.Unlock() c.term = t }
[ "func", "(", "c", "*", "ServerContext", ")", "SetTerm", "(", "t", "Terminal", ")", "{", "c", ".", "Lock", "(", ")", "\n", "defer", "c", ".", "Unlock", "(", ")", "\n\n", "c", ".", "term", "=", "t", "\n", "}" ]
// SetTerm set a Terminal.
[ "SetTerm", "set", "a", "Terminal", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/srv/ctx.go#L420-L425
train
gravitational/teleport
lib/srv/ctx.go
SetEnv
func (c *ServerContext) SetEnv(key, val string) { c.env[key] = val }
go
func (c *ServerContext) SetEnv(key, val string) { c.env[key] = val }
[ "func", "(", "c", "*", "ServerContext", ")", "SetEnv", "(", "key", ",", "val", "string", ")", "{", "c", ".", "env", "[", "key", "]", "=", "val", "\n", "}" ]
// SetEnv sets a environment variable within this context.
[ "SetEnv", "sets", "a", "environment", "variable", "within", "this", "context", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/srv/ctx.go#L428-L430
train
gravitational/teleport
lib/srv/ctx.go
GetEnv
func (c *ServerContext) GetEnv(key string) (string, bool) { val, ok := c.env[key] return val, ok }
go
func (c *ServerContext) GetEnv(key string) (string, bool) { val, ok := c.env[key] return val, ok }
[ "func", "(", "c", "*", "ServerContext", ")", "GetEnv", "(", "key", "string", ")", "(", "string", ",", "bool", ")", "{", "val", ",", "ok", ":=", "c", ".", "env", "[", "key", "]", "\n", "return", "val", ",", "ok", "\n", "}" ]
// GetEnv returns a environment variable within this context.
[ "GetEnv", "returns", "a", "environment", "variable", "within", "this", "context", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/srv/ctx.go#L433-L436
train
gravitational/teleport
lib/srv/ctx.go
SendExecResult
func (c *ServerContext) SendExecResult(r ExecResult) { select { case c.ExecResultCh <- r: default: log.Infof("blocked on sending exec result %v", r) } }
go
func (c *ServerContext) SendExecResult(r ExecResult) { select { case c.ExecResultCh <- r: default: log.Infof("blocked on sending exec result %v", r) } }
[ "func", "(", "c", "*", "ServerContext", ")", "SendExecResult", "(", "r", "ExecResult", ")", "{", "select", "{", "case", "c", ".", "ExecResultCh", "<-", "r", ":", "default", ":", "log", ".", "Infof", "(", "\"", "\"", ",", "r", ")", "\n", "}", "\n", ...
// SendExecResult sends the result of execution of the "exec" command over the // ExecResultCh.
[ "SendExecResult", "sends", "the", "result", "of", "execution", "of", "the", "exec", "command", "over", "the", "ExecResultCh", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/srv/ctx.go#L520-L526
train
gravitational/teleport
lib/srv/ctx.go
SendSubsystemResult
func (c *ServerContext) SendSubsystemResult(r SubsystemResult) { select { case c.SubsystemResultCh <- r: default: c.Infof("blocked on sending subsystem result") } }
go
func (c *ServerContext) SendSubsystemResult(r SubsystemResult) { select { case c.SubsystemResultCh <- r: default: c.Infof("blocked on sending subsystem result") } }
[ "func", "(", "c", "*", "ServerContext", ")", "SendSubsystemResult", "(", "r", "SubsystemResult", ")", "{", "select", "{", "case", "c", ".", "SubsystemResultCh", "<-", "r", ":", "default", ":", "c", ".", "Infof", "(", "\"", "\"", ")", "\n", "}", "\n", ...
// SendSubsystemResult sends the result of running the subsystem over the // SubsystemResultCh.
[ "SendSubsystemResult", "sends", "the", "result", "of", "running", "the", "subsystem", "over", "the", "SubsystemResultCh", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/srv/ctx.go#L530-L536
train
gravitational/teleport
lib/srv/ctx.go
ProxyPublicAddress
func (c *ServerContext) ProxyPublicAddress() string { proxyHost := "<proxyhost>:3080" if c.srv == nil { return proxyHost } proxies, err := c.srv.GetAccessPoint().GetProxies() if err != nil { c.Errorf("Unable to retrieve proxy list: %v", err) } if len(proxies) > 0 { proxyHost = proxies[0].GetPublicAddr()...
go
func (c *ServerContext) ProxyPublicAddress() string { proxyHost := "<proxyhost>:3080" if c.srv == nil { return proxyHost } proxies, err := c.srv.GetAccessPoint().GetProxies() if err != nil { c.Errorf("Unable to retrieve proxy list: %v", err) } if len(proxies) > 0 { proxyHost = proxies[0].GetPublicAddr()...
[ "func", "(", "c", "*", "ServerContext", ")", "ProxyPublicAddress", "(", ")", "string", "{", "proxyHost", ":=", "\"", "\"", "\n\n", "if", "c", ".", "srv", "==", "nil", "{", "return", "proxyHost", "\n", "}", "\n\n", "proxies", ",", "err", ":=", "c", "....
// ProxyPublicAddress tries to get the public address from the first // available proxy. if public_address is not set, fall back to the hostname // of the first proxy we get back.
[ "ProxyPublicAddress", "tries", "to", "get", "the", "public", "address", "from", "the", "first", "available", "proxy", ".", "if", "public_address", "is", "not", "set", "fall", "back", "to", "the", "hostname", "of", "the", "first", "proxy", "we", "get", "back"...
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/srv/ctx.go#L541-L562
train
gravitational/teleport
lib/srv/ctx.go
NewTrackingReader
func NewTrackingReader(ctx *ServerContext, r io.Reader) *TrackingReader { return &TrackingReader{ctx: ctx, r: r} }
go
func NewTrackingReader(ctx *ServerContext, r io.Reader) *TrackingReader { return &TrackingReader{ctx: ctx, r: r} }
[ "func", "NewTrackingReader", "(", "ctx", "*", "ServerContext", ",", "r", "io", ".", "Reader", ")", "*", "TrackingReader", "{", "return", "&", "TrackingReader", "{", "ctx", ":", "ctx", ",", "r", ":", "r", "}", "\n", "}" ]
// NewTrackingReader returns a new instance of // activity tracking reader.
[ "NewTrackingReader", "returns", "a", "new", "instance", "of", "activity", "tracking", "reader", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/srv/ctx.go#L595-L597
train
gravitational/teleport
lib/srv/ctx.go
Read
func (a *TrackingReader) Read(b []byte) (int, error) { a.ctx.UpdateClientActivity() return a.r.Read(b) }
go
func (a *TrackingReader) Read(b []byte) (int, error) { a.ctx.UpdateClientActivity() return a.r.Read(b) }
[ "func", "(", "a", "*", "TrackingReader", ")", "Read", "(", "b", "[", "]", "byte", ")", "(", "int", ",", "error", ")", "{", "a", ".", "ctx", ".", "UpdateClientActivity", "(", ")", "\n", "return", "a", ".", "r", ".", "Read", "(", "b", ")", "\n", ...
// Read passes the read through to internal // reader, and updates activity of the server context
[ "Read", "passes", "the", "read", "through", "to", "internal", "reader", "and", "updates", "activity", "of", "the", "server", "context" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/srv/ctx.go#L609-L612
train
gravitational/teleport
lib/pam/config.go
CheckDefaults
func (c *Config) CheckDefaults() error { if c.ServiceName == "" { return trace.BadParameter("required parameter ServiceName missing") } if c.Username == "" { return trace.BadParameter("required parameter Username missing") } if c.Stdin == nil { return trace.BadParameter("required parameter Stdin missing") }...
go
func (c *Config) CheckDefaults() error { if c.ServiceName == "" { return trace.BadParameter("required parameter ServiceName missing") } if c.Username == "" { return trace.BadParameter("required parameter Username missing") } if c.Stdin == nil { return trace.BadParameter("required parameter Stdin missing") }...
[ "func", "(", "c", "*", "Config", ")", "CheckDefaults", "(", ")", "error", "{", "if", "c", ".", "ServiceName", "==", "\"", "\"", "{", "return", "trace", ".", "BadParameter", "(", "\"", "\"", ")", "\n", "}", "\n", "if", "c", ".", "Username", "==", ...
// CheckDefaults makes sure the Config structure has minimum required values.
[ "CheckDefaults", "makes", "sure", "the", "Config", "structure", "has", "minimum", "required", "values", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/pam/config.go#L53-L71
train
gravitational/teleport
lib/auth/permissions.go
NewAdminContext
func NewAdminContext() (*AuthContext, error) { authContext, err := contextForBuiltinRole("", nil, teleport.RoleAdmin, fmt.Sprintf("%v", teleport.RoleAdmin)) if err != nil { return nil, trace.Wrap(err) } return authContext, nil }
go
func NewAdminContext() (*AuthContext, error) { authContext, err := contextForBuiltinRole("", nil, teleport.RoleAdmin, fmt.Sprintf("%v", teleport.RoleAdmin)) if err != nil { return nil, trace.Wrap(err) } return authContext, nil }
[ "func", "NewAdminContext", "(", ")", "(", "*", "AuthContext", ",", "error", ")", "{", "authContext", ",", "err", ":=", "contextForBuiltinRole", "(", "\"", "\"", ",", "nil", ",", "teleport", ".", "RoleAdmin", ",", "fmt", ".", "Sprintf", "(", "\"", "\"", ...
// NewAdminContext returns new admin auth context
[ "NewAdminContext", "returns", "new", "admin", "auth", "context" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/permissions.go#L31-L37
train
gravitational/teleport
lib/auth/permissions.go
NewRoleAuthorizer
func NewRoleAuthorizer(clusterName string, clusterConfig services.ClusterConfig, r teleport.Role) (Authorizer, error) { authContext, err := contextForBuiltinRole(clusterName, clusterConfig, r, fmt.Sprintf("%v", r)) if err != nil { return nil, trace.Wrap(err) } return &contextAuthorizer{authContext: *authContext},...
go
func NewRoleAuthorizer(clusterName string, clusterConfig services.ClusterConfig, r teleport.Role) (Authorizer, error) { authContext, err := contextForBuiltinRole(clusterName, clusterConfig, r, fmt.Sprintf("%v", r)) if err != nil { return nil, trace.Wrap(err) } return &contextAuthorizer{authContext: *authContext},...
[ "func", "NewRoleAuthorizer", "(", "clusterName", "string", ",", "clusterConfig", "services", ".", "ClusterConfig", ",", "r", "teleport", ".", "Role", ")", "(", "Authorizer", ",", "error", ")", "{", "authContext", ",", "err", ":=", "contextForBuiltinRole", "(", ...
// NewRoleAuthorizer authorizes everyone as predefined role, used in tests
[ "NewRoleAuthorizer", "authorizes", "everyone", "as", "predefined", "role", "used", "in", "tests" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/permissions.go#L40-L46
train
gravitational/teleport
lib/auth/permissions.go
NewUserAuthorizer
func NewUserAuthorizer(username string, identity services.UserGetter, access services.Access) (Authorizer, error) { authContext, err := contextForLocalUser(username, identity, access) if err != nil { return nil, trace.Wrap(err) } return &contextAuthorizer{authContext: *authContext}, nil }
go
func NewUserAuthorizer(username string, identity services.UserGetter, access services.Access) (Authorizer, error) { authContext, err := contextForLocalUser(username, identity, access) if err != nil { return nil, trace.Wrap(err) } return &contextAuthorizer{authContext: *authContext}, nil }
[ "func", "NewUserAuthorizer", "(", "username", "string", ",", "identity", "services", ".", "UserGetter", ",", "access", "services", ".", "Access", ")", "(", "Authorizer", ",", "error", ")", "{", "authContext", ",", "err", ":=", "contextForLocalUser", "(", "user...
// NewUserAuthorizer authorizes everyone as predefined local user
[ "NewUserAuthorizer", "authorizes", "everyone", "as", "predefined", "local", "user" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/permissions.go#L60-L66
train
gravitational/teleport
lib/auth/permissions.go
NewAuthorizer
func NewAuthorizer(access services.Access, identity services.UserGetter, trust services.Trust) (Authorizer, error) { if access == nil { return nil, trace.BadParameter("missing parameter access") } if identity == nil { return nil, trace.BadParameter("missing parameter identity") } if trust == nil { return nil...
go
func NewAuthorizer(access services.Access, identity services.UserGetter, trust services.Trust) (Authorizer, error) { if access == nil { return nil, trace.BadParameter("missing parameter access") } if identity == nil { return nil, trace.BadParameter("missing parameter identity") } if trust == nil { return nil...
[ "func", "NewAuthorizer", "(", "access", "services", ".", "Access", ",", "identity", "services", ".", "UserGetter", ",", "trust", "services", ".", "Trust", ")", "(", "Authorizer", ",", "error", ")", "{", "if", "access", "==", "nil", "{", "return", "nil", ...
// NewAuthorizer returns new authorizer using backends
[ "NewAuthorizer", "returns", "new", "authorizer", "using", "backends" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/permissions.go#L69-L80
train
gravitational/teleport
lib/auth/permissions.go
authorizeLocalUser
func (a *authorizer) authorizeLocalUser(u LocalUser) (*AuthContext, error) { return contextForLocalUser(u.Username, a.identity, a.access) }
go
func (a *authorizer) authorizeLocalUser(u LocalUser) (*AuthContext, error) { return contextForLocalUser(u.Username, a.identity, a.access) }
[ "func", "(", "a", "*", "authorizer", ")", "authorizeLocalUser", "(", "u", "LocalUser", ")", "(", "*", "AuthContext", ",", "error", ")", "{", "return", "contextForLocalUser", "(", "u", ".", "Username", ",", "a", ".", "identity", ",", "a", ".", "access", ...
// authorizeLocalUser returns authz context based on the username
[ "authorizeLocalUser", "returns", "authz", "context", "based", "on", "the", "username" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/permissions.go#L124-L126
train
gravitational/teleport
lib/auth/permissions.go
authorizeRemoteUser
func (a *authorizer) authorizeRemoteUser(u RemoteUser) (*AuthContext, error) { ca, err := a.trust.GetCertAuthority(services.CertAuthID{Type: services.UserCA, DomainName: u.ClusterName}, false) if err != nil { return nil, trace.Wrap(err) } roleNames, err := ca.CombinedMapping().Map(u.RemoteRoles) if err != nil { ...
go
func (a *authorizer) authorizeRemoteUser(u RemoteUser) (*AuthContext, error) { ca, err := a.trust.GetCertAuthority(services.CertAuthID{Type: services.UserCA, DomainName: u.ClusterName}, false) if err != nil { return nil, trace.Wrap(err) } roleNames, err := ca.CombinedMapping().Map(u.RemoteRoles) if err != nil { ...
[ "func", "(", "a", "*", "authorizer", ")", "authorizeRemoteUser", "(", "u", "RemoteUser", ")", "(", "*", "AuthContext", ",", "error", ")", "{", "ca", ",", "err", ":=", "a", ".", "trust", ".", "GetCertAuthority", "(", "services", ".", "CertAuthID", "{", ...
// authorizeRemoteUser returns checker based on cert authority roles
[ "authorizeRemoteUser", "returns", "checker", "based", "on", "cert", "authority", "roles" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/permissions.go#L129-L170
train
gravitational/teleport
lib/auth/permissions.go
authorizeBuiltinRole
func (a *authorizer) authorizeBuiltinRole(r BuiltinRole) (*AuthContext, error) { config, err := r.GetClusterConfig() if err != nil { return nil, trace.Wrap(err) } return contextForBuiltinRole(r.ClusterName, config, r.Role, r.Username) }
go
func (a *authorizer) authorizeBuiltinRole(r BuiltinRole) (*AuthContext, error) { config, err := r.GetClusterConfig() if err != nil { return nil, trace.Wrap(err) } return contextForBuiltinRole(r.ClusterName, config, r.Role, r.Username) }
[ "func", "(", "a", "*", "authorizer", ")", "authorizeBuiltinRole", "(", "r", "BuiltinRole", ")", "(", "*", "AuthContext", ",", "error", ")", "{", "config", ",", "err", ":=", "r", ".", "GetClusterConfig", "(", ")", "\n", "if", "err", "!=", "nil", "{", ...
// authorizeBuiltinRole authorizes builtin role
[ "authorizeBuiltinRole", "authorizes", "builtin", "role" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/permissions.go#L173-L179
train
gravitational/teleport
tool/tctl/common/user_command.go
Initialize
func (u *UserCommand) Initialize(app *kingpin.Application, config *service.Config) { u.config = config users := app.Command("users", "Manage user accounts") u.userAdd = users.Command("add", "Generate a user invitation token") u.userAdd.Arg("account", "Teleport user account name").Required().StringVar(&u.login) u....
go
func (u *UserCommand) Initialize(app *kingpin.Application, config *service.Config) { u.config = config users := app.Command("users", "Manage user accounts") u.userAdd = users.Command("add", "Generate a user invitation token") u.userAdd.Arg("account", "Teleport user account name").Required().StringVar(&u.login) u....
[ "func", "(", "u", "*", "UserCommand", ")", "Initialize", "(", "app", "*", "kingpin", ".", "Application", ",", "config", "*", "service", ".", "Config", ")", "{", "u", ".", "config", "=", "config", "\n", "users", ":=", "app", ".", "Command", "(", "\"",...
// Initialize allows UserCommand to plug itself into the CLI parser
[ "Initialize", "allows", "UserCommand", "to", "plug", "itself", "into", "the", "CLI", "parser" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/tool/tctl/common/user_command.go#L57-L84
train
gravitational/teleport
tool/tctl/common/user_command.go
Add
func (u *UserCommand) Add(client auth.ClientI) error { // if no local logins were specified, default to 'login' if u.allowedLogins == "" { u.allowedLogins = u.login } var kubeGroups []string if u.kubeGroups != "" { kubeGroups = strings.Split(u.kubeGroups, ",") } user := services.UserV1{ Name: u.lo...
go
func (u *UserCommand) Add(client auth.ClientI) error { // if no local logins were specified, default to 'login' if u.allowedLogins == "" { u.allowedLogins = u.login } var kubeGroups []string if u.kubeGroups != "" { kubeGroups = strings.Split(u.kubeGroups, ",") } user := services.UserV1{ Name: u.lo...
[ "func", "(", "u", "*", "UserCommand", ")", "Add", "(", "client", "auth", ".", "ClientI", ")", "error", "{", "// if no local logins were specified, default to 'login'", "if", "u", ".", "allowedLogins", "==", "\"", "\"", "{", "u", ".", "allowedLogins", "=", "u",...
// Add creates a new sign-up token and prints a token URL to stdout. // A user is not created until he visits the sign-up URL and completes the process
[ "Add", "creates", "a", "new", "sign", "-", "up", "token", "and", "prints", "a", "token", "URL", "to", "stdout", ".", "A", "user", "is", "not", "created", "until", "he", "visits", "the", "sign", "-", "up", "URL", "and", "completes", "the", "process" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/tool/tctl/common/user_command.go#L105-L126
train
gravitational/teleport
tool/tctl/common/user_command.go
PrintSignupURL
func (u *UserCommand) PrintSignupURL(client auth.ClientI, token string, ttl time.Duration, format string) error { signupURL, proxyHost := web.CreateSignupLink(client, token) if format == teleport.Text { fmt.Printf("Signup token has been created and is valid for %v hours. Share this URL with the user:\n%v\n\n", ...
go
func (u *UserCommand) PrintSignupURL(client auth.ClientI, token string, ttl time.Duration, format string) error { signupURL, proxyHost := web.CreateSignupLink(client, token) if format == teleport.Text { fmt.Printf("Signup token has been created and is valid for %v hours. Share this URL with the user:\n%v\n\n", ...
[ "func", "(", "u", "*", "UserCommand", ")", "PrintSignupURL", "(", "client", "auth", ".", "ClientI", ",", "token", "string", ",", "ttl", "time", ".", "Duration", ",", "format", "string", ")", "error", "{", "signupURL", ",", "proxyHost", ":=", "web", ".", ...
// PrintSignupURL prints signup URL
[ "PrintSignupURL", "prints", "signup", "URL" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/tool/tctl/common/user_command.go#L129-L144
train
gravitational/teleport
tool/tctl/common/user_command.go
Update
func (u *UserCommand) Update(client auth.ClientI) error { user, err := client.GetUser(u.login) if err != nil { return trace.Wrap(err) } roles := strings.Split(u.roles, ",") for _, role := range roles { if _, err := client.GetRole(role); err != nil { return trace.Wrap(err) } } user.SetRoles(roles) if er...
go
func (u *UserCommand) Update(client auth.ClientI) error { user, err := client.GetUser(u.login) if err != nil { return trace.Wrap(err) } roles := strings.Split(u.roles, ",") for _, role := range roles { if _, err := client.GetRole(role); err != nil { return trace.Wrap(err) } } user.SetRoles(roles) if er...
[ "func", "(", "u", "*", "UserCommand", ")", "Update", "(", "client", "auth", ".", "ClientI", ")", "error", "{", "user", ",", "err", ":=", "client", ".", "GetUser", "(", "u", ".", "login", ")", "\n", "if", "err", "!=", "nil", "{", "return", "trace", ...
// Update updates existing user
[ "Update", "updates", "existing", "user" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/tool/tctl/common/user_command.go#L147-L164
train
gravitational/teleport
tool/tctl/common/user_command.go
List
func (u *UserCommand) List(client auth.ClientI) error { users, err := client.GetUsers() if err != nil { return trace.Wrap(err) } if u.format == teleport.Text { if len(users) == 0 { fmt.Println("No users found") return nil } t := asciitable.MakeTable([]string{"User", "Allowed logins"}) for _, u := ra...
go
func (u *UserCommand) List(client auth.ClientI) error { users, err := client.GetUsers() if err != nil { return trace.Wrap(err) } if u.format == teleport.Text { if len(users) == 0 { fmt.Println("No users found") return nil } t := asciitable.MakeTable([]string{"User", "Allowed logins"}) for _, u := ra...
[ "func", "(", "u", "*", "UserCommand", ")", "List", "(", "client", "auth", ".", "ClientI", ")", "error", "{", "users", ",", "err", ":=", "client", ".", "GetUsers", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "trace", ".", "Wrap", "(", ...
// List prints all existing user accounts
[ "List", "prints", "all", "existing", "user", "accounts" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/tool/tctl/common/user_command.go#L167-L191
train
gravitational/teleport
lib/teleagent/agent.go
ListenUnixSocket
func (a *AgentServer) ListenUnixSocket(path string, uid, gid int, mode os.FileMode) error { l, err := net.Listen("unix", path) if err != nil { return trace.Wrap(err) } if err := os.Chown(path, uid, gid); err != nil { l.Close() return trace.ConvertSystemError(err) } if err := os.Chmod(path, mode); err != nil...
go
func (a *AgentServer) ListenUnixSocket(path string, uid, gid int, mode os.FileMode) error { l, err := net.Listen("unix", path) if err != nil { return trace.Wrap(err) } if err := os.Chown(path, uid, gid); err != nil { l.Close() return trace.ConvertSystemError(err) } if err := os.Chmod(path, mode); err != nil...
[ "func", "(", "a", "*", "AgentServer", ")", "ListenUnixSocket", "(", "path", "string", ",", "uid", ",", "gid", "int", ",", "mode", "os", ".", "FileMode", ")", "error", "{", "l", ",", "err", ":=", "net", ".", "Listen", "(", "\"", "\"", ",", "path", ...
// ListenUnixSocket starts listening and serving agent assuming that
[ "ListenUnixSocket", "starts", "listening", "and", "serving", "agent", "assuming", "that" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/teleagent/agent.go#L30-L46
train
gravitational/teleport
lib/teleagent/agent.go
Serve
func (a *AgentServer) Serve() error { if a.listener == nil { return trace.BadParameter("Serve needs a Listen call first") } var tempDelay time.Duration // how long to sleep on accept failure for { conn, err := a.listener.Accept() if err != nil { neterr, ok := err.(net.Error) if !ok { return trace.Wr...
go
func (a *AgentServer) Serve() error { if a.listener == nil { return trace.BadParameter("Serve needs a Listen call first") } var tempDelay time.Duration // how long to sleep on accept failure for { conn, err := a.listener.Accept() if err != nil { neterr, ok := err.(net.Error) if !ok { return trace.Wr...
[ "func", "(", "a", "*", "AgentServer", ")", "Serve", "(", ")", "error", "{", "if", "a", ".", "listener", "==", "nil", "{", "return", "trace", ".", "BadParameter", "(", "\"", "\"", ")", "\n", "}", "\n", "var", "tempDelay", "time", ".", "Duration", "/...
// Serve starts serving on the listener, assumes that Listen was called before
[ "Serve", "starts", "serving", "on", "the", "listener", "assumes", "that", "Listen", "was", "called", "before" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/teleagent/agent.go#L49-L88
train
gravitational/teleport
lib/teleagent/agent.go
ListenAndServe
func (a *AgentServer) ListenAndServe(addr utils.NetAddr) error { l, err := net.Listen(addr.AddrNetwork, addr.Addr) if err != nil { return trace.Wrap(err) } a.listener = l return a.Serve() }
go
func (a *AgentServer) ListenAndServe(addr utils.NetAddr) error { l, err := net.Listen(addr.AddrNetwork, addr.Addr) if err != nil { return trace.Wrap(err) } a.listener = l return a.Serve() }
[ "func", "(", "a", "*", "AgentServer", ")", "ListenAndServe", "(", "addr", "utils", ".", "NetAddr", ")", "error", "{", "l", ",", "err", ":=", "net", ".", "Listen", "(", "addr", ".", "AddrNetwork", ",", "addr", ".", "Addr", ")", "\n", "if", "err", "!...
// ListenAndServe is similar http.ListenAndServe
[ "ListenAndServe", "is", "similar", "http", ".", "ListenAndServe" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/teleagent/agent.go#L91-L98
train
gravitational/teleport
lib/teleagent/agent.go
Close
func (a *AgentServer) Close() error { var errors []error if a.listener != nil { log.Debugf("AgentServer(%v) is closing", a.listener.Addr()) if err := a.listener.Close(); err != nil { errors = append(errors, trace.ConvertSystemError(err)) } } if a.path != "" { if err := os.Remove(a.path); err != nil { ...
go
func (a *AgentServer) Close() error { var errors []error if a.listener != nil { log.Debugf("AgentServer(%v) is closing", a.listener.Addr()) if err := a.listener.Close(); err != nil { errors = append(errors, trace.ConvertSystemError(err)) } } if a.path != "" { if err := os.Remove(a.path); err != nil { ...
[ "func", "(", "a", "*", "AgentServer", ")", "Close", "(", ")", "error", "{", "var", "errors", "[", "]", "error", "\n", "if", "a", ".", "listener", "!=", "nil", "{", "log", ".", "Debugf", "(", "\"", "\"", ",", "a", ".", "listener", ".", "Addr", "...
// Close closes listener and stops serving agent
[ "Close", "closes", "listener", "and", "stops", "serving", "agent" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/teleagent/agent.go#L101-L115
train
gravitational/teleport
lib/httplib/csrf/csrf.go
VerifyHTTPHeader
func VerifyHTTPHeader(r *http.Request) error { token := r.Header.Get(HeaderName) if len(token) == 0 { return trace.BadParameter("cannot retrieve CSRF token from HTTP header %q", HeaderName) } err := VerifyToken(token, r) if err != nil { return trace.Wrap(err) } return nil }
go
func VerifyHTTPHeader(r *http.Request) error { token := r.Header.Get(HeaderName) if len(token) == 0 { return trace.BadParameter("cannot retrieve CSRF token from HTTP header %q", HeaderName) } err := VerifyToken(token, r) if err != nil { return trace.Wrap(err) } return nil }
[ "func", "VerifyHTTPHeader", "(", "r", "*", "http", ".", "Request", ")", "error", "{", "token", ":=", "r", ".", "Header", ".", "Get", "(", "HeaderName", ")", "\n", "if", "len", "(", "token", ")", "==", "0", "{", "return", "trace", ".", "BadParameter",...
// VerifyHTTPHeader checks if HTTP header value matches the cookie.
[ "VerifyHTTPHeader", "checks", "if", "HTTP", "header", "value", "matches", "the", "cookie", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/httplib/csrf/csrf.go#L56-L68
train
gravitational/teleport
lib/httplib/csrf/csrf.go
VerifyToken
func VerifyToken(token string, r *http.Request) error { realToken, err := ExtractTokenFromCookie(r) if err != nil { return trace.Wrap(err, "unable to extract CSRF token from cookie") } decodedTokenA, err := decode(token) if err != nil { return trace.Wrap(err, "unable to decode CSRF token") } decodedTokenB,...
go
func VerifyToken(token string, r *http.Request) error { realToken, err := ExtractTokenFromCookie(r) if err != nil { return trace.Wrap(err, "unable to extract CSRF token from cookie") } decodedTokenA, err := decode(token) if err != nil { return trace.Wrap(err, "unable to decode CSRF token") } decodedTokenB,...
[ "func", "VerifyToken", "(", "token", "string", ",", "r", "*", "http", ".", "Request", ")", "error", "{", "realToken", ",", "err", ":=", "ExtractTokenFromCookie", "(", "r", ")", "\n", "if", "err", "!=", "nil", "{", "return", "trace", ".", "Wrap", "(", ...
// VerifyToken validates given token based on HTTP request cookie
[ "VerifyToken", "validates", "given", "token", "based", "on", "HTTP", "request", "cookie" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/httplib/csrf/csrf.go#L71-L92
train
gravitational/teleport
lib/httplib/csrf/csrf.go
ExtractTokenFromCookie
func ExtractTokenFromCookie(r *http.Request) (string, error) { cookie, err := r.Cookie(CookieName) if err != nil { return "", trace.Wrap(err) } return cookie.Value, nil }
go
func ExtractTokenFromCookie(r *http.Request) (string, error) { cookie, err := r.Cookie(CookieName) if err != nil { return "", trace.Wrap(err) } return cookie.Value, nil }
[ "func", "ExtractTokenFromCookie", "(", "r", "*", "http", ".", "Request", ")", "(", "string", ",", "error", ")", "{", "cookie", ",", "err", ":=", "r", ".", "Cookie", "(", "CookieName", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ...
// ExtractTokenFromCookie retrieves a CSRF token from the session cookie.
[ "ExtractTokenFromCookie", "retrieves", "a", "CSRF", "token", "from", "the", "session", "cookie", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/httplib/csrf/csrf.go#L95-L102
train
gravitational/teleport
lib/httplib/csrf/csrf.go
save
func save(encodedToken string, w http.ResponseWriter) string { cookie := &http.Cookie{ Name: CookieName, Value: encodedToken, MaxAge: defaultMaxAge, HttpOnly: true, Secure: true, Path: "/", } // write the authenticated cookie to the response. http.SetCookie(w, cookie) w.Header().Add("Va...
go
func save(encodedToken string, w http.ResponseWriter) string { cookie := &http.Cookie{ Name: CookieName, Value: encodedToken, MaxAge: defaultMaxAge, HttpOnly: true, Secure: true, Path: "/", } // write the authenticated cookie to the response. http.SetCookie(w, cookie) w.Header().Add("Va...
[ "func", "save", "(", "encodedToken", "string", ",", "w", "http", ".", "ResponseWriter", ")", "string", "{", "cookie", ":=", "&", "http", ".", "Cookie", "{", "Name", ":", "CookieName", ",", "Value", ":", "encodedToken", ",", "MaxAge", ":", "defaultMaxAge", ...
// save stores encoded CSRF token in the session cookie.
[ "save", "stores", "encoded", "CSRF", "token", "in", "the", "session", "cookie", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/httplib/csrf/csrf.go#L124-L138
train
gravitational/teleport
lib/auth/oidc.go
ValidateOIDCAuthCallback
func (a *AuthServer) ValidateOIDCAuthCallback(q url.Values) (*OIDCAuthResponse, error) { re, err := a.validateOIDCAuthCallback(q) if err != nil { a.EmitAuditEvent(events.UserSSOLoginFailure, events.EventFields{ events.LoginMethod: events.LoginMethodOIDC, events.AuthAttemptSuccess: false, // log the ...
go
func (a *AuthServer) ValidateOIDCAuthCallback(q url.Values) (*OIDCAuthResponse, error) { re, err := a.validateOIDCAuthCallback(q) if err != nil { a.EmitAuditEvent(events.UserSSOLoginFailure, events.EventFields{ events.LoginMethod: events.LoginMethodOIDC, events.AuthAttemptSuccess: false, // log the ...
[ "func", "(", "a", "*", "AuthServer", ")", "ValidateOIDCAuthCallback", "(", "q", "url", ".", "Values", ")", "(", "*", "OIDCAuthResponse", ",", "error", ")", "{", "re", ",", "err", ":=", "a", ".", "validateOIDCAuthCallback", "(", "q", ")", "\n", "if", "e...
// ValidateOIDCAuthCallback is called by the proxy to check OIDC query parameters // returned by OIDC Provider, if everything checks out, auth server // will respond with OIDCAuthResponse, otherwise it will return error
[ "ValidateOIDCAuthCallback", "is", "called", "by", "the", "proxy", "to", "check", "OIDC", "query", "parameters", "returned", "by", "OIDC", "Provider", "if", "everything", "checks", "out", "auth", "server", "will", "respond", "with", "OIDCAuthResponse", "otherwise", ...
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/oidc.go#L128-L145
train
gravitational/teleport
lib/auth/oidc.go
buildOIDCRoles
func (a *AuthServer) buildOIDCRoles(connector services.OIDCConnector, claims jose.Claims) ([]string, error) { roles := connector.MapClaims(claims) if len(roles) == 0 { return nil, trace.AccessDenied("unable to map claims to role for connector: %v", connector.GetName()) } return roles, nil }
go
func (a *AuthServer) buildOIDCRoles(connector services.OIDCConnector, claims jose.Claims) ([]string, error) { roles := connector.MapClaims(claims) if len(roles) == 0 { return nil, trace.AccessDenied("unable to map claims to role for connector: %v", connector.GetName()) } return roles, nil }
[ "func", "(", "a", "*", "AuthServer", ")", "buildOIDCRoles", "(", "connector", "services", ".", "OIDCConnector", ",", "claims", "jose", ".", "Claims", ")", "(", "[", "]", "string", ",", "error", ")", "{", "roles", ":=", "connector", ".", "MapClaims", "(",...
// buildOIDCRoles takes a connector and claims and returns a slice of roles.
[ "buildOIDCRoles", "takes", "a", "connector", "and", "claims", "and", "returns", "a", "slice", "of", "roles", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/oidc.go#L301-L308
train
gravitational/teleport
lib/auth/oidc.go
claimsToTraitMap
func claimsToTraitMap(claims jose.Claims) map[string][]string { traits := make(map[string][]string) for claimName := range claims { claimValue, ok, _ := claims.StringClaim(claimName) if ok { traits[claimName] = []string{claimValue} } claimValues, ok, _ := claims.StringsClaim(claimName) if ok { traits...
go
func claimsToTraitMap(claims jose.Claims) map[string][]string { traits := make(map[string][]string) for claimName := range claims { claimValue, ok, _ := claims.StringClaim(claimName) if ok { traits[claimName] = []string{claimValue} } claimValues, ok, _ := claims.StringsClaim(claimName) if ok { traits...
[ "func", "claimsToTraitMap", "(", "claims", "jose", ".", "Claims", ")", "map", "[", "string", "]", "[", "]", "string", "{", "traits", ":=", "make", "(", "map", "[", "string", "]", "[", "]", "string", ")", "\n\n", "for", "claimName", ":=", "range", "cl...
// claimsToTraitMap extracts all string claims and creates a map of traits // that can be used to populate role variables.
[ "claimsToTraitMap", "extracts", "all", "string", "claims", "and", "creates", "a", "map", "of", "traits", "that", "can", "be", "used", "to", "populate", "role", "variables", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/oidc.go#L312-L327
train
gravitational/teleport
lib/auth/oidc.go
claimsFromIDToken
func claimsFromIDToken(oidcClient *oidc.Client, idToken string) (jose.Claims, error) { jwt, err := jose.ParseJWT(idToken) if err != nil { return nil, trace.Wrap(err) } err = oidcClient.VerifyJWT(jwt) if err != nil { return nil, trace.Wrap(err) } log.Debugf("Extracting OIDC claims from ID token.") claims,...
go
func claimsFromIDToken(oidcClient *oidc.Client, idToken string) (jose.Claims, error) { jwt, err := jose.ParseJWT(idToken) if err != nil { return nil, trace.Wrap(err) } err = oidcClient.VerifyJWT(jwt) if err != nil { return nil, trace.Wrap(err) } log.Debugf("Extracting OIDC claims from ID token.") claims,...
[ "func", "claimsFromIDToken", "(", "oidcClient", "*", "oidc", ".", "Client", ",", "idToken", "string", ")", "(", "jose", ".", "Claims", ",", "error", ")", "{", "jwt", ",", "err", ":=", "jose", ".", "ParseJWT", "(", "idToken", ")", "\n", "if", "err", "...
// claimsFromIDToken extracts claims from the ID token.
[ "claimsFromIDToken", "extracts", "claims", "from", "the", "ID", "token", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/oidc.go#L422-L441
train
gravitational/teleport
lib/auth/oidc.go
fetchGroups
func (g *gsuiteClient) fetchGroups() (jose.Claims, error) { count := 0 var groups []string var nextPageToken string collect: for { if count > MaxPages { warningMessage := "Truncating list of teams used to populate claims: " + "hit maximum number pages that can be fetched from GSuite." // Print warning ...
go
func (g *gsuiteClient) fetchGroups() (jose.Claims, error) { count := 0 var groups []string var nextPageToken string collect: for { if count > MaxPages { warningMessage := "Truncating list of teams used to populate claims: " + "hit maximum number pages that can be fetched from GSuite." // Print warning ...
[ "func", "(", "g", "*", "gsuiteClient", ")", "fetchGroups", "(", ")", "(", "jose", ".", "Claims", ",", "error", ")", "{", "count", ":=", "0", "\n", "var", "groups", "[", "]", "string", "\n", "var", "nextPageToken", "string", "\n", "collect", ":", "for...
// fetchGroups fetches GSuite groups a user belongs to and returns // "groups" claim with
[ "fetchGroups", "fetches", "GSuite", "groups", "a", "user", "belongs", "to", "and", "returns", "groups", "claim", "with" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/oidc.go#L545-L575
train
gravitational/teleport
lib/auth/oidc.go
mergeClaims
func mergeClaims(a jose.Claims, b jose.Claims) (jose.Claims, error) { for k, v := range b { _, ok := a[k] if !ok { a[k] = v } } return a, nil }
go
func mergeClaims(a jose.Claims, b jose.Claims) (jose.Claims, error) { for k, v := range b { _, ok := a[k] if !ok { a[k] = v } } return a, nil }
[ "func", "mergeClaims", "(", "a", "jose", ".", "Claims", ",", "b", "jose", ".", "Claims", ")", "(", "jose", ".", "Claims", ",", "error", ")", "{", "for", "k", ",", "v", ":=", "range", "b", "{", "_", ",", "ok", ":=", "a", "[", "k", "]", "\n", ...
// mergeClaims merges b into a.
[ "mergeClaims", "merges", "b", "into", "a", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/oidc.go#L635-L644
train
gravitational/teleport
lib/auth/oidc.go
validateACRValues
func (a *AuthServer) validateACRValues(acrValue string, identityProvider string, claims jose.Claims) error { switch identityProvider { case teleport.NetIQ: log.Debugf("Validating OIDC ACR values with '%v' rules.", identityProvider) tokenAcr, ok := claims["acr"] if !ok { return trace.BadParameter("acr not fo...
go
func (a *AuthServer) validateACRValues(acrValue string, identityProvider string, claims jose.Claims) error { switch identityProvider { case teleport.NetIQ: log.Debugf("Validating OIDC ACR values with '%v' rules.", identityProvider) tokenAcr, ok := claims["acr"] if !ok { return trace.BadParameter("acr not fo...
[ "func", "(", "a", "*", "AuthServer", ")", "validateACRValues", "(", "acrValue", "string", ",", "identityProvider", "string", ",", "claims", "jose", ".", "Claims", ")", "error", "{", "switch", "identityProvider", "{", "case", "teleport", ".", "NetIQ", ":", "l...
// validateACRValues validates that we get an appropriate response for acr values. By default // we expect the same value we send, but this function also handles Identity Provider specific // forms of validation.
[ "validateACRValues", "validates", "that", "we", "get", "an", "appropriate", "response", "for", "acr", "values", ".", "By", "default", "we", "expect", "the", "same", "value", "we", "send", "but", "this", "function", "also", "handles", "Identity", "Provider", "s...
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/oidc.go#L733-L787
train
gravitational/teleport
lib/client/bench.go
Benchmark
func (tc *TeleportClient) Benchmark(ctx context.Context, bench Benchmark) (*BenchmarkResult, error) { tc.Stdout = ioutil.Discard tc.Stderr = ioutil.Discard tc.Stdin = &bytes.Buffer{} ctx, cancel := context.WithTimeout(ctx, bench.Duration) defer cancel() requestC := make(chan *benchMeasure) responseC := make(ch...
go
func (tc *TeleportClient) Benchmark(ctx context.Context, bench Benchmark) (*BenchmarkResult, error) { tc.Stdout = ioutil.Discard tc.Stderr = ioutil.Discard tc.Stdin = &bytes.Buffer{} ctx, cancel := context.WithTimeout(ctx, bench.Duration) defer cancel() requestC := make(chan *benchMeasure) responseC := make(ch...
[ "func", "(", "tc", "*", "TeleportClient", ")", "Benchmark", "(", "ctx", "context", ".", "Context", ",", "bench", "Benchmark", ")", "(", "*", "BenchmarkResult", ",", "error", ")", "{", "tc", ".", "Stdout", "=", "ioutil", ".", "Discard", "\n", "tc", ".",...
// Benchmark connects to remote server and executes requests in parallel according // to benchmark spec. It returns benchmark result when completed. // This is a blocking function that can be cancelled via context argument.
[ "Benchmark", "connects", "to", "remote", "server", "and", "executes", "requests", "in", "parallel", "according", "to", "benchmark", "spec", ".", "It", "returns", "benchmark", "result", "when", "completed", ".", "This", "is", "a", "blocking", "function", "that", ...
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/bench.go#L60-L147
train
gravitational/teleport
lib/utils/conn.go
NewCloserConn
func NewCloserConn(conn net.Conn, closers ...io.Closer) *CloserConn { return &CloserConn{ Conn: conn, closers: closers, } }
go
func NewCloserConn(conn net.Conn, closers ...io.Closer) *CloserConn { return &CloserConn{ Conn: conn, closers: closers, } }
[ "func", "NewCloserConn", "(", "conn", "net", ".", "Conn", ",", "closers", "...", "io", ".", "Closer", ")", "*", "CloserConn", "{", "return", "&", "CloserConn", "{", "Conn", ":", "conn", ",", "closers", ":", "closers", ",", "}", "\n", "}" ]
// NewCloserConn returns new connection wrapper that // when closed will also close passed closers
[ "NewCloserConn", "returns", "new", "connection", "wrapper", "that", "when", "closed", "will", "also", "close", "passed", "closers" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/conn.go#L33-L38
train
gravitational/teleport
lib/client/interfaces.go
ClientTLSConfig
func (k *Key) ClientTLSConfig() (*tls.Config, error) { // Because Teleport clients can't be configured (yet), they take the default // list of cipher suites from Go. tlsConfig := utils.TLSConfig(nil) pool := x509.NewCertPool() for _, ca := range k.TrustedCA { for _, certPEM := range ca.TLSCertificates { if !...
go
func (k *Key) ClientTLSConfig() (*tls.Config, error) { // Because Teleport clients can't be configured (yet), they take the default // list of cipher suites from Go. tlsConfig := utils.TLSConfig(nil) pool := x509.NewCertPool() for _, ca := range k.TrustedCA { for _, certPEM := range ca.TLSCertificates { if !...
[ "func", "(", "k", "*", "Key", ")", "ClientTLSConfig", "(", ")", "(", "*", "tls", ".", "Config", ",", "error", ")", "{", "// Because Teleport clients can't be configured (yet), they take the default", "// list of cipher suites from Go.", "tlsConfig", ":=", "utils", ".", ...
// TLSConfig returns client TLS configuration used // to authenticate against API servers
[ "TLSConfig", "returns", "client", "TLS", "configuration", "used", "to", "authenticate", "against", "API", "servers" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/interfaces.go#L62-L82
train
gravitational/teleport
lib/client/interfaces.go
CertUsername
func (k *Key) CertUsername() (string, error) { pubKey, _, _, _, err := ssh.ParseAuthorizedKey(k.Cert) if err != nil { return "", trace.Wrap(err) } cert, ok := pubKey.(*ssh.Certificate) if !ok { return "", trace.BadParameter("expected SSH certificate, got public key") } return cert.KeyId, nil }
go
func (k *Key) CertUsername() (string, error) { pubKey, _, _, _, err := ssh.ParseAuthorizedKey(k.Cert) if err != nil { return "", trace.Wrap(err) } cert, ok := pubKey.(*ssh.Certificate) if !ok { return "", trace.BadParameter("expected SSH certificate, got public key") } return cert.KeyId, nil }
[ "func", "(", "k", "*", "Key", ")", "CertUsername", "(", ")", "(", "string", ",", "error", ")", "{", "pubKey", ",", "_", ",", "_", ",", "_", ",", "err", ":=", "ssh", ".", "ParseAuthorizedKey", "(", "k", ".", "Cert", ")", "\n", "if", "err", "!=",...
// CertUsername returns the name of the Teleport user encoded in the SSH certificate.
[ "CertUsername", "returns", "the", "name", "of", "the", "Teleport", "user", "encoded", "in", "the", "SSH", "certificate", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/interfaces.go#L85-L95
train
gravitational/teleport
lib/client/interfaces.go
CertPrincipals
func (k *Key) CertPrincipals() ([]string, error) { publicKey, _, _, _, err := ssh.ParseAuthorizedKey(k.Cert) if err != nil { return nil, trace.Wrap(err) } cert, ok := publicKey.(*ssh.Certificate) if !ok { return nil, trace.BadParameter("no certificate found") } return cert.ValidPrincipals, nil }
go
func (k *Key) CertPrincipals() ([]string, error) { publicKey, _, _, _, err := ssh.ParseAuthorizedKey(k.Cert) if err != nil { return nil, trace.Wrap(err) } cert, ok := publicKey.(*ssh.Certificate) if !ok { return nil, trace.BadParameter("no certificate found") } return cert.ValidPrincipals, nil }
[ "func", "(", "k", "*", "Key", ")", "CertPrincipals", "(", ")", "(", "[", "]", "string", ",", "error", ")", "{", "publicKey", ",", "_", ",", "_", ",", "_", ",", "err", ":=", "ssh", ".", "ParseAuthorizedKey", "(", "k", ".", "Cert", ")", "\n", "if...
// CertPrincipals returns the principals listed on the SSH certificate.
[ "CertPrincipals", "returns", "the", "principals", "listed", "on", "the", "SSH", "certificate", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/interfaces.go#L98-L108
train
gravitational/teleport
lib/client/interfaces.go
EqualsTo
func (k *Key) EqualsTo(other *Key) bool { if k == other { return true } return bytes.Equal(k.Cert, other.Cert) && bytes.Equal(k.Priv, other.Priv) && bytes.Equal(k.Pub, other.Pub) && bytes.Equal(k.TLSCert, other.TLSCert) }
go
func (k *Key) EqualsTo(other *Key) bool { if k == other { return true } return bytes.Equal(k.Cert, other.Cert) && bytes.Equal(k.Priv, other.Priv) && bytes.Equal(k.Pub, other.Pub) && bytes.Equal(k.TLSCert, other.TLSCert) }
[ "func", "(", "k", "*", "Key", ")", "EqualsTo", "(", "other", "*", "Key", ")", "bool", "{", "if", "k", "==", "other", "{", "return", "true", "\n", "}", "\n", "return", "bytes", ".", "Equal", "(", "k", ".", "Cert", ",", "other", ".", "Cert", ")",...
// EqualsTo returns true if this key is the same as the other. // Primarily used in tests
[ "EqualsTo", "returns", "true", "if", "this", "key", "is", "the", "same", "as", "the", "other", ".", "Primarily", "used", "in", "tests" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/interfaces.go#L173-L181
train
gravitational/teleport
lib/client/interfaces.go
TLSCertValidBefore
func (k *Key) TLSCertValidBefore() (t time.Time, err error) { cert, err := tlsca.ParseCertificatePEM(k.TLSCert) if err != nil { return t, trace.Wrap(err) } return cert.NotAfter, nil }
go
func (k *Key) TLSCertValidBefore() (t time.Time, err error) { cert, err := tlsca.ParseCertificatePEM(k.TLSCert) if err != nil { return t, trace.Wrap(err) } return cert.NotAfter, nil }
[ "func", "(", "k", "*", "Key", ")", "TLSCertValidBefore", "(", ")", "(", "t", "time", ".", "Time", ",", "err", "error", ")", "{", "cert", ",", "err", ":=", "tlsca", ".", "ParseCertificatePEM", "(", "k", ".", "TLSCert", ")", "\n", "if", "err", "!=", ...
// TLSCertValidBefore returns the time of the TLS cert expiration
[ "TLSCertValidBefore", "returns", "the", "time", "of", "the", "TLS", "cert", "expiration" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/interfaces.go#L184-L190
train
gravitational/teleport
lib/client/interfaces.go
CertValidBefore
func (k *Key) CertValidBefore() (t time.Time, err error) { pcert, _, _, _, err := ssh.ParseAuthorizedKey(k.Cert) if err != nil { return t, trace.Wrap(err) } cert, ok := pcert.(*ssh.Certificate) if !ok { return t, trace.Errorf("not supported certificate type") } return time.Unix(int64(cert.ValidBefore), 0), n...
go
func (k *Key) CertValidBefore() (t time.Time, err error) { pcert, _, _, _, err := ssh.ParseAuthorizedKey(k.Cert) if err != nil { return t, trace.Wrap(err) } cert, ok := pcert.(*ssh.Certificate) if !ok { return t, trace.Errorf("not supported certificate type") } return time.Unix(int64(cert.ValidBefore), 0), n...
[ "func", "(", "k", "*", "Key", ")", "CertValidBefore", "(", ")", "(", "t", "time", ".", "Time", ",", "err", "error", ")", "{", "pcert", ",", "_", ",", "_", ",", "_", ",", "err", ":=", "ssh", ".", "ParseAuthorizedKey", "(", "k", ".", "Cert", ")",...
// CertValidBefore returns the time of the cert expiration
[ "CertValidBefore", "returns", "the", "time", "of", "the", "cert", "expiration" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/interfaces.go#L193-L203
train
gravitational/teleport
lib/client/interfaces.go
AsAuthMethod
func (k *Key) AsAuthMethod() (ssh.AuthMethod, error) { keys, err := k.AsAgentKeys() if err != nil { return nil, trace.Wrap(err) } signer, err := ssh.NewSignerFromKey(keys[0].PrivateKey) if err != nil { return nil, trace.Wrap(err) } if signer, err = ssh.NewCertSigner(keys[0].Certificate, signer); err != nil {...
go
func (k *Key) AsAuthMethod() (ssh.AuthMethod, error) { keys, err := k.AsAgentKeys() if err != nil { return nil, trace.Wrap(err) } signer, err := ssh.NewSignerFromKey(keys[0].PrivateKey) if err != nil { return nil, trace.Wrap(err) } if signer, err = ssh.NewCertSigner(keys[0].Certificate, signer); err != nil {...
[ "func", "(", "k", "*", "Key", ")", "AsAuthMethod", "(", ")", "(", "ssh", ".", "AuthMethod", ",", "error", ")", "{", "keys", ",", "err", ":=", "k", ".", "AsAgentKeys", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "trace", ...
// AsAuthMethod returns an "auth method" interface, a common abstraction // used by Golang SSH library. This is how you actually use a Key to feed // it into the SSH lib.
[ "AsAuthMethod", "returns", "an", "auth", "method", "interface", "a", "common", "abstraction", "used", "by", "Golang", "SSH", "library", ".", "This", "is", "how", "you", "actually", "use", "a", "Key", "to", "feed", "it", "into", "the", "SSH", "lib", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/interfaces.go#L208-L221
train
gravitational/teleport
lib/client/interfaces.go
CheckCert
func (k *Key) CheckCert() error { key, _, _, _, err := ssh.ParseAuthorizedKey(k.Cert) if err != nil { return trace.Wrap(err) } cert, ok := key.(*ssh.Certificate) if !ok { return trace.BadParameter("found key, not certificate") } if len(cert.ValidPrincipals) == 0 { return trace.BadParameter("principals are...
go
func (k *Key) CheckCert() error { key, _, _, _, err := ssh.ParseAuthorizedKey(k.Cert) if err != nil { return trace.Wrap(err) } cert, ok := key.(*ssh.Certificate) if !ok { return trace.BadParameter("found key, not certificate") } if len(cert.ValidPrincipals) == 0 { return trace.BadParameter("principals are...
[ "func", "(", "k", "*", "Key", ")", "CheckCert", "(", ")", "error", "{", "key", ",", "_", ",", "_", ",", "_", ",", "err", ":=", "ssh", ".", "ParseAuthorizedKey", "(", "k", ".", "Cert", ")", "\n", "if", "err", "!=", "nil", "{", "return", "trace",...
// CheckCert makes sure the SSH certificate is valid.
[ "CheckCert", "makes", "sure", "the", "SSH", "certificate", "is", "valid", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/interfaces.go#L224-L247
train
gravitational/teleport
lib/backend/dynamo/shards.go
collectActiveShards
func (b *DynamoDBBackend) collectActiveShards(ctx context.Context, streamArn *string) ([]*dynamodbstreams.Shard, error) { var out []*dynamodbstreams.Shard input := &dynamodbstreams.DescribeStreamInput{ StreamArn: streamArn, } for { streamInfo, err := b.streams.DescribeStreamWithContext(ctx, input) if err != ...
go
func (b *DynamoDBBackend) collectActiveShards(ctx context.Context, streamArn *string) ([]*dynamodbstreams.Shard, error) { var out []*dynamodbstreams.Shard input := &dynamodbstreams.DescribeStreamInput{ StreamArn: streamArn, } for { streamInfo, err := b.streams.DescribeStreamWithContext(ctx, input) if err != ...
[ "func", "(", "b", "*", "DynamoDBBackend", ")", "collectActiveShards", "(", "ctx", "context", ".", "Context", ",", "streamArn", "*", "string", ")", "(", "[", "]", "*", "dynamodbstreams", ".", "Shard", ",", "error", ")", "{", "var", "out", "[", "]", "*",...
// collectActiveShards collects shards
[ "collectActiveShards", "collects", "shards" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/backend/dynamo/shards.go#L202-L219
train
gravitational/teleport
lib/backend/dynamo/dynamodbbk.go
GetRange
func (b *DynamoDBBackend) GetRange(ctx context.Context, startKey []byte, endKey []byte, limit int) (*backend.GetResult, error) { if len(startKey) == 0 { return nil, trace.BadParameter("missing parameter startKey") } if len(endKey) == 0 { return nil, trace.BadParameter("missing parameter endKey") } result, err ...
go
func (b *DynamoDBBackend) GetRange(ctx context.Context, startKey []byte, endKey []byte, limit int) (*backend.GetResult, error) { if len(startKey) == 0 { return nil, trace.BadParameter("missing parameter startKey") } if len(endKey) == 0 { return nil, trace.BadParameter("missing parameter endKey") } result, err ...
[ "func", "(", "b", "*", "DynamoDBBackend", ")", "GetRange", "(", "ctx", "context", ".", "Context", ",", "startKey", "[", "]", "byte", ",", "endKey", "[", "]", "byte", ",", "limit", "int", ")", "(", "*", "backend", ".", "GetResult", ",", "error", ")", ...
// GetRange returns range of elements
[ "GetRange", "returns", "range", "of", "elements" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/backend/dynamo/dynamodbbk.go#L302-L325
train
gravitational/teleport
lib/backend/dynamo/dynamodbbk.go
CompareAndSwap
func (b *DynamoDBBackend) CompareAndSwap(ctx context.Context, expected backend.Item, replaceWith backend.Item) (*backend.Lease, error) { if len(expected.Key) == 0 { return nil, trace.BadParameter("missing parameter Key") } if len(replaceWith.Key) == 0 { return nil, trace.BadParameter("missing parameter Key") } ...
go
func (b *DynamoDBBackend) CompareAndSwap(ctx context.Context, expected backend.Item, replaceWith backend.Item) (*backend.Lease, error) { if len(expected.Key) == 0 { return nil, trace.BadParameter("missing parameter Key") } if len(replaceWith.Key) == 0 { return nil, trace.BadParameter("missing parameter Key") } ...
[ "func", "(", "b", "*", "DynamoDBBackend", ")", "CompareAndSwap", "(", "ctx", "context", ".", "Context", ",", "expected", "backend", ".", "Item", ",", "replaceWith", "backend", ".", "Item", ")", "(", "*", "backend", ".", "Lease", ",", "error", ")", "{", ...
// CompareAndSwap compares and swap values in atomic operation // CompareAndSwap compares item with existing item // and replaces is with replaceWith item
[ "CompareAndSwap", "compares", "and", "swap", "values", "in", "atomic", "operation", "CompareAndSwap", "compares", "item", "with", "existing", "item", "and", "replaces", "is", "with", "replaceWith", "item" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/backend/dynamo/dynamodbbk.go#L413-L460
train
gravitational/teleport
lib/backend/dynamo/dynamodbbk.go
Close
func (b *DynamoDBBackend) Close() error { b.setClosed() b.cancel() return b.buf.Close() }
go
func (b *DynamoDBBackend) Close() error { b.setClosed() b.cancel() return b.buf.Close() }
[ "func", "(", "b", "*", "DynamoDBBackend", ")", "Close", "(", ")", "error", "{", "b", ".", "setClosed", "(", ")", "\n", "b", ".", "cancel", "(", ")", "\n", "return", "b", ".", "buf", ".", "Close", "(", ")", "\n", "}" ]
// Close closes the DynamoDB driver // and releases associated resources
[ "Close", "closes", "the", "DynamoDB", "driver", "and", "releases", "associated", "resources" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/backend/dynamo/dynamodbbk.go#L530-L534
train
gravitational/teleport
lib/backend/dynamo/dynamodbbk.go
deleteTable
func (b *DynamoDBBackend) deleteTable(ctx context.Context, tableName string, wait bool) error { tn := aws.String(tableName) _, err := b.svc.DeleteTable(&dynamodb.DeleteTableInput{TableName: tn}) if err != nil { return trace.Wrap(err) } if wait { return trace.Wrap( b.svc.WaitUntilTableNotExists(&dynamodb.Des...
go
func (b *DynamoDBBackend) deleteTable(ctx context.Context, tableName string, wait bool) error { tn := aws.String(tableName) _, err := b.svc.DeleteTable(&dynamodb.DeleteTableInput{TableName: tn}) if err != nil { return trace.Wrap(err) } if wait { return trace.Wrap( b.svc.WaitUntilTableNotExists(&dynamodb.Des...
[ "func", "(", "b", "*", "DynamoDBBackend", ")", "deleteTable", "(", "ctx", "context", ".", "Context", ",", "tableName", "string", ",", "wait", "bool", ")", "error", "{", "tn", ":=", "aws", ".", "String", "(", "tableName", ")", "\n", "_", ",", "err", "...
// deleteTable deletes DynamoDB table with a given name
[ "deleteTable", "deletes", "DynamoDB", "table", "with", "a", "given", "name" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/backend/dynamo/dynamodbbk.go#L637-L648
train
gravitational/teleport
lib/backend/dynamo/dynamodbbk.go
getRecords
func (b *DynamoDBBackend) getRecords(ctx context.Context, startKey, endKey string, limit int, lastEvaluatedKey map[string]*dynamodb.AttributeValue) (*getResult, error) { query := "HashKey = :hashKey AND FullPath BETWEEN :fullPath AND :rangeEnd" attrV := map[string]interface{}{ ":fullPath": startKey, ":hashKey": ...
go
func (b *DynamoDBBackend) getRecords(ctx context.Context, startKey, endKey string, limit int, lastEvaluatedKey map[string]*dynamodb.AttributeValue) (*getResult, error) { query := "HashKey = :hashKey AND FullPath BETWEEN :fullPath AND :rangeEnd" attrV := map[string]interface{}{ ":fullPath": startKey, ":hashKey": ...
[ "func", "(", "b", "*", "DynamoDBBackend", ")", "getRecords", "(", "ctx", "context", ".", "Context", ",", "startKey", ",", "endKey", "string", ",", "limit", "int", ",", "lastEvaluatedKey", "map", "[", "string", "]", "*", "dynamodb", ".", "AttributeValue", "...
// getRecords retrieves all keys by path
[ "getRecords", "retrieves", "all", "keys", "by", "path" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/backend/dynamo/dynamodbbk.go#L659-L700
train
gravitational/teleport
lib/backend/buffer.go
NewCircularBuffer
func NewCircularBuffer(ctx context.Context, size int) (*CircularBuffer, error) { if size <= 0 { return nil, trace.BadParameter("circular buffer size should be > 0") } ctx, cancel := context.WithCancel(ctx) buf := &CircularBuffer{ Entry: log.WithFields(log.Fields{ trace.Component: teleport.ComponentBuffer, ...
go
func NewCircularBuffer(ctx context.Context, size int) (*CircularBuffer, error) { if size <= 0 { return nil, trace.BadParameter("circular buffer size should be > 0") } ctx, cancel := context.WithCancel(ctx) buf := &CircularBuffer{ Entry: log.WithFields(log.Fields{ trace.Component: teleport.ComponentBuffer, ...
[ "func", "NewCircularBuffer", "(", "ctx", "context", ".", "Context", ",", "size", "int", ")", "(", "*", "CircularBuffer", ",", "error", ")", "{", "if", "size", "<=", "0", "{", "return", "nil", ",", "trace", ".", "BadParameter", "(", "\"", "\"", ")", "...
// NewCircularBuffer returns a new instance of circular buffer
[ "NewCircularBuffer", "returns", "a", "new", "instance", "of", "circular", "buffer" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/backend/buffer.go#L48-L66
train
gravitational/teleport
lib/backend/buffer.go
Reset
func (c *CircularBuffer) Reset() { c.Lock() defer c.Unlock() // could close mulitple times c.watchers.walk(func(w *BufferWatcher) { w.Close() }) c.watchers = newWatcherTree() c.start = -1 c.end = -1 c.size = 0 for i := 0; i < len(c.events); i++ { c.events[i] = Event{} } }
go
func (c *CircularBuffer) Reset() { c.Lock() defer c.Unlock() // could close mulitple times c.watchers.walk(func(w *BufferWatcher) { w.Close() }) c.watchers = newWatcherTree() c.start = -1 c.end = -1 c.size = 0 for i := 0; i < len(c.events); i++ { c.events[i] = Event{} } }
[ "func", "(", "c", "*", "CircularBuffer", ")", "Reset", "(", ")", "{", "c", ".", "Lock", "(", ")", "\n", "defer", "c", ".", "Unlock", "(", ")", "\n", "// could close mulitple times", "c", ".", "watchers", ".", "walk", "(", "func", "(", "w", "*", "Bu...
// Reset resets all events from the queue // and closes all active watchers
[ "Reset", "resets", "all", "events", "from", "the", "queue", "and", "closes", "all", "active", "watchers" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/backend/buffer.go#L70-L84
train
gravitational/teleport
lib/backend/buffer.go
Events
func (c *CircularBuffer) Events() []Event { c.Lock() defer c.Unlock() return c.eventsCopy() }
go
func (c *CircularBuffer) Events() []Event { c.Lock() defer c.Unlock() return c.eventsCopy() }
[ "func", "(", "c", "*", "CircularBuffer", ")", "Events", "(", ")", "[", "]", "Event", "{", "c", ".", "Lock", "(", ")", "\n", "defer", "c", ".", "Unlock", "(", ")", "\n", "return", "c", ".", "eventsCopy", "(", ")", "\n", "}" ]
// Events returns a copy of records as arranged from start to end
[ "Events", "returns", "a", "copy", "of", "records", "as", "arranged", "from", "start", "to", "end" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/backend/buffer.go#L99-L103
train
gravitational/teleport
lib/backend/buffer.go
eventsCopy
func (c *CircularBuffer) eventsCopy() []Event { if c.size == 0 { return nil } var out []Event for i := 0; i < c.size; i++ { index := (c.start + i) % len(c.events) if out == nil { out = make([]Event, 0, c.size) } out = append(out, c.events[index]) } return out }
go
func (c *CircularBuffer) eventsCopy() []Event { if c.size == 0 { return nil } var out []Event for i := 0; i < c.size; i++ { index := (c.start + i) % len(c.events) if out == nil { out = make([]Event, 0, c.size) } out = append(out, c.events[index]) } return out }
[ "func", "(", "c", "*", "CircularBuffer", ")", "eventsCopy", "(", ")", "[", "]", "Event", "{", "if", "c", ".", "size", "==", "0", "{", "return", "nil", "\n", "}", "\n", "var", "out", "[", "]", "Event", "\n", "for", "i", ":=", "0", ";", "i", "<...
// eventsCopy returns a copy of events as arranged from start to end
[ "eventsCopy", "returns", "a", "copy", "of", "events", "as", "arranged", "from", "start", "to", "end" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/backend/buffer.go#L106-L119
train
gravitational/teleport
lib/backend/buffer.go
PushBatch
func (c *CircularBuffer) PushBatch(events []Event) { c.Lock() defer c.Unlock() for i := range events { c.push(events[i]) } }
go
func (c *CircularBuffer) PushBatch(events []Event) { c.Lock() defer c.Unlock() for i := range events { c.push(events[i]) } }
[ "func", "(", "c", "*", "CircularBuffer", ")", "PushBatch", "(", "events", "[", "]", "Event", ")", "{", "c", ".", "Lock", "(", ")", "\n", "defer", "c", ".", "Unlock", "(", ")", "\n\n", "for", "i", ":=", "range", "events", "{", "c", ".", "push", ...
// PushBatch pushes elements to the queue as a batch
[ "PushBatch", "pushes", "elements", "to", "the", "queue", "as", "a", "batch" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/backend/buffer.go#L122-L129
train
gravitational/teleport
lib/backend/buffer.go
Push
func (c *CircularBuffer) Push(r Event) { c.Lock() defer c.Unlock() c.push(r) }
go
func (c *CircularBuffer) Push(r Event) { c.Lock() defer c.Unlock() c.push(r) }
[ "func", "(", "c", "*", "CircularBuffer", ")", "Push", "(", "r", "Event", ")", "{", "c", ".", "Lock", "(", ")", "\n", "defer", "c", ".", "Unlock", "(", ")", "\n", "c", ".", "push", "(", "r", ")", "\n", "}" ]
// Push pushes elements to the queue
[ "Push", "pushes", "elements", "to", "the", "queue" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/backend/buffer.go#L132-L136
train
gravitational/teleport
lib/backend/buffer.go
NewWatcher
func (c *CircularBuffer) NewWatcher(ctx context.Context, watch Watch) (Watcher, error) { c.Lock() defer c.Unlock() select { case <-c.ctx.Done(): return nil, trace.BadParameter("buffer is closed") default: } if watch.QueueSize == 0 { watch.QueueSize = len(c.events) } if len(watch.Prefixes) == 0 { // if...
go
func (c *CircularBuffer) NewWatcher(ctx context.Context, watch Watch) (Watcher, error) { c.Lock() defer c.Unlock() select { case <-c.ctx.Done(): return nil, trace.BadParameter("buffer is closed") default: } if watch.QueueSize == 0 { watch.QueueSize = len(c.events) } if len(watch.Prefixes) == 0 { // if...
[ "func", "(", "c", "*", "CircularBuffer", ")", "NewWatcher", "(", "ctx", "context", ".", "Context", ",", "watch", "Watch", ")", "(", "Watcher", ",", "error", ")", "{", "c", ".", "Lock", "(", ")", "\n", "defer", "c", ".", "Unlock", "(", ")", "\n\n", ...
// NewWatcher adds a new watcher to the events buffer
[ "NewWatcher", "adds", "a", "new", "watcher", "to", "the", "events", "buffer" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/backend/buffer.go#L203-L247
train
gravitational/teleport
lib/backend/buffer.go
String
func (w *BufferWatcher) String() string { return fmt.Sprintf("Watcher(name=%v, prefixes=%v, capacity=%v, size=%v)", w.Name, string(bytes.Join(w.Prefixes, []byte(", "))), w.capacity, len(w.eventsC)) }
go
func (w *BufferWatcher) String() string { return fmt.Sprintf("Watcher(name=%v, prefixes=%v, capacity=%v, size=%v)", w.Name, string(bytes.Join(w.Prefixes, []byte(", "))), w.capacity, len(w.eventsC)) }
[ "func", "(", "w", "*", "BufferWatcher", ")", "String", "(", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "w", ".", "Name", ",", "string", "(", "bytes", ".", "Join", "(", "w", ".", "Prefixes", ",", "[", "]", "byte", ...
// String returns user-friendly representation // of the buffer watcher
[ "String", "returns", "user", "-", "friendly", "representation", "of", "the", "buffer", "watcher" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/backend/buffer.go#L268-L270
train
gravitational/teleport
lib/backend/buffer.go
add
func (t *watcherTree) add(w *BufferWatcher) { for _, p := range w.Prefixes { prefix := string(p) val, ok := t.Tree.Get(prefix) var watchers []*BufferWatcher if ok { watchers = val.([]*BufferWatcher) } watchers = append(watchers, w) t.Tree.Insert(prefix, watchers) } }
go
func (t *watcherTree) add(w *BufferWatcher) { for _, p := range w.Prefixes { prefix := string(p) val, ok := t.Tree.Get(prefix) var watchers []*BufferWatcher if ok { watchers = val.([]*BufferWatcher) } watchers = append(watchers, w) t.Tree.Insert(prefix, watchers) } }
[ "func", "(", "t", "*", "watcherTree", ")", "add", "(", "w", "*", "BufferWatcher", ")", "{", "for", "_", ",", "p", ":=", "range", "w", ".", "Prefixes", "{", "prefix", ":=", "string", "(", "p", ")", "\n", "val", ",", "ok", ":=", "t", ".", "Tree",...
// add adds buffer watcher to the tree
[ "add", "adds", "buffer", "watcher", "to", "the", "tree" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/backend/buffer.go#L300-L311
train
gravitational/teleport
lib/backend/buffer.go
rm
func (t *watcherTree) rm(w *BufferWatcher) bool { if w == nil { return false } var found bool for _, p := range w.Prefixes { prefix := string(p) val, ok := t.Tree.Get(prefix) if !ok { continue } buffers := val.([]*BufferWatcher) prevLen := len(buffers) for i := range buffers { if buffers[i] ==...
go
func (t *watcherTree) rm(w *BufferWatcher) bool { if w == nil { return false } var found bool for _, p := range w.Prefixes { prefix := string(p) val, ok := t.Tree.Get(prefix) if !ok { continue } buffers := val.([]*BufferWatcher) prevLen := len(buffers) for i := range buffers { if buffers[i] ==...
[ "func", "(", "t", "*", "watcherTree", ")", "rm", "(", "w", "*", "BufferWatcher", ")", "bool", "{", "if", "w", "==", "nil", "{", "return", "false", "\n", "}", "\n", "var", "found", "bool", "\n", "for", "_", ",", "p", ":=", "range", "w", ".", "Pr...
// rm removes the buffer watcher from the prefix tree
[ "rm", "removes", "the", "buffer", "watcher", "from", "the", "prefix", "tree" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/backend/buffer.go#L314-L341
train
gravitational/teleport
lib/backend/buffer.go
walkPath
func (t *watcherTree) walkPath(key string, fn walkFn) { t.Tree.WalkPath(key, func(prefix string, val interface{}) bool { watchers := val.([]*BufferWatcher) for _, w := range watchers { fn(w) } return false }) }
go
func (t *watcherTree) walkPath(key string, fn walkFn) { t.Tree.WalkPath(key, func(prefix string, val interface{}) bool { watchers := val.([]*BufferWatcher) for _, w := range watchers { fn(w) } return false }) }
[ "func", "(", "t", "*", "watcherTree", ")", "walkPath", "(", "key", "string", ",", "fn", "walkFn", ")", "{", "t", ".", "Tree", ".", "WalkPath", "(", "key", ",", "func", "(", "prefix", "string", ",", "val", "interface", "{", "}", ")", "bool", "{", ...
// walkPath walks the tree above the longest matching prefix // and calls fn callback for every buffer watcher
[ "walkPath", "walks", "the", "tree", "above", "the", "longest", "matching", "prefix", "and", "calls", "fn", "callback", "for", "every", "buffer", "watcher" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/backend/buffer.go#L348-L356
train
gravitational/teleport
lib/backend/buffer.go
walk
func (t *watcherTree) walk(fn walkFn) { t.Tree.Walk(func(prefix string, val interface{}) bool { watchers := val.([]*BufferWatcher) for _, w := range watchers { fn(w) } return false }) }
go
func (t *watcherTree) walk(fn walkFn) { t.Tree.Walk(func(prefix string, val interface{}) bool { watchers := val.([]*BufferWatcher) for _, w := range watchers { fn(w) } return false }) }
[ "func", "(", "t", "*", "watcherTree", ")", "walk", "(", "fn", "walkFn", ")", "{", "t", ".", "Tree", ".", "Walk", "(", "func", "(", "prefix", "string", ",", "val", "interface", "{", "}", ")", "bool", "{", "watchers", ":=", "val", ".", "(", "[", ...
// walk calls fn for every matching leaf of the tree
[ "walk", "calls", "fn", "for", "every", "matching", "leaf", "of", "the", "tree" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/backend/buffer.go#L359-L367
train
gravitational/teleport
lib/kube/client/kubeclient.go
UpdateKubeconfig
func UpdateKubeconfig(tc *client.TeleportClient) error { config, err := LoadKubeConfig() if err != nil { return trace.Wrap(err) } clusterName, proxyPort := tc.KubeProxyHostPort() var clusterAddr string if tc.SiteName != "" { // In case of a remote cluster, use SNI subdomain to "point" to a remote cluster nam...
go
func UpdateKubeconfig(tc *client.TeleportClient) error { config, err := LoadKubeConfig() if err != nil { return trace.Wrap(err) } clusterName, proxyPort := tc.KubeProxyHostPort() var clusterAddr string if tc.SiteName != "" { // In case of a remote cluster, use SNI subdomain to "point" to a remote cluster nam...
[ "func", "UpdateKubeconfig", "(", "tc", "*", "client", ".", "TeleportClient", ")", "error", "{", "config", ",", "err", ":=", "LoadKubeConfig", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "trace", ".", "Wrap", "(", "err", ")", "\n", "}", "...
// UpdateKubeconfig adds Teleport configuration to kubeconfig.
[ "UpdateKubeconfig", "adds", "Teleport", "configuration", "to", "kubeconfig", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/kube/client/kubeclient.go#L26-L73
train
gravitational/teleport
lib/kube/client/kubeclient.go
RemoveKubeconifg
func RemoveKubeconifg(tc *client.TeleportClient, clusterName string) error { // Load existing kubeconfig from disk. config, err := LoadKubeConfig() if err != nil { return trace.Wrap(err) } // Remove Teleport related AuthInfos, Clusters, and Contexts from kubeconfig. delete(config.AuthInfos, clusterName) delet...
go
func RemoveKubeconifg(tc *client.TeleportClient, clusterName string) error { // Load existing kubeconfig from disk. config, err := LoadKubeConfig() if err != nil { return trace.Wrap(err) } // Remove Teleport related AuthInfos, Clusters, and Contexts from kubeconfig. delete(config.AuthInfos, clusterName) delet...
[ "func", "RemoveKubeconifg", "(", "tc", "*", "client", ".", "TeleportClient", ",", "clusterName", "string", ")", "error", "{", "// Load existing kubeconfig from disk.", "config", ",", "err", ":=", "LoadKubeConfig", "(", ")", "\n", "if", "err", "!=", "nil", "{", ...
// RemoveKubeconifg removes Teleport configuration from kubeconfig.
[ "RemoveKubeconifg", "removes", "Teleport", "configuration", "from", "kubeconfig", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/kube/client/kubeclient.go#L76-L100
train
gravitational/teleport
lib/kube/client/kubeclient.go
LoadKubeConfig
func LoadKubeConfig() (*clientcmdapi.Config, error) { filename, err := utils.EnsureLocalPath( kubeconfigFromEnv(), teleport.KubeConfigDir, teleport.KubeConfigFile) if err != nil { return nil, trace.Wrap(err) } config, err := clientcmd.LoadFromFile(filename) if err != nil && !os.IsNotExist(err) { return n...
go
func LoadKubeConfig() (*clientcmdapi.Config, error) { filename, err := utils.EnsureLocalPath( kubeconfigFromEnv(), teleport.KubeConfigDir, teleport.KubeConfigFile) if err != nil { return nil, trace.Wrap(err) } config, err := clientcmd.LoadFromFile(filename) if err != nil && !os.IsNotExist(err) { return n...
[ "func", "LoadKubeConfig", "(", ")", "(", "*", "clientcmdapi", ".", "Config", ",", "error", ")", "{", "filename", ",", "err", ":=", "utils", ".", "EnsureLocalPath", "(", "kubeconfigFromEnv", "(", ")", ",", "teleport", ".", "KubeConfigDir", ",", "teleport", ...
// LoadKubeconfig tries to read a kubeconfig file and if it can't, returns an error. // One exception, missing files result in empty configs, not an error.
[ "LoadKubeconfig", "tries", "to", "read", "a", "kubeconfig", "file", "and", "if", "it", "can", "t", "returns", "an", "error", ".", "One", "exception", "missing", "files", "result", "in", "empty", "configs", "not", "an", "error", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/kube/client/kubeclient.go#L104-L121
train
gravitational/teleport
lib/kube/client/kubeclient.go
SaveKubeConfig
func SaveKubeConfig(config clientcmdapi.Config) error { filename, err := utils.EnsureLocalPath( kubeconfigFromEnv(), teleport.KubeConfigDir, teleport.KubeConfigFile) if err != nil { return trace.Wrap(err) } err = clientcmd.WriteToFile(config, filename) if err != nil { return trace.ConvertSystemError(err...
go
func SaveKubeConfig(config clientcmdapi.Config) error { filename, err := utils.EnsureLocalPath( kubeconfigFromEnv(), teleport.KubeConfigDir, teleport.KubeConfigFile) if err != nil { return trace.Wrap(err) } err = clientcmd.WriteToFile(config, filename) if err != nil { return trace.ConvertSystemError(err...
[ "func", "SaveKubeConfig", "(", "config", "clientcmdapi", ".", "Config", ")", "error", "{", "filename", ",", "err", ":=", "utils", ".", "EnsureLocalPath", "(", "kubeconfigFromEnv", "(", ")", ",", "teleport", ".", "KubeConfigDir", ",", "teleport", ".", "KubeConf...
// SaveKubeConfig saves updated config to location specified by environment variable or // default location
[ "SaveKubeConfig", "saves", "updated", "config", "to", "location", "specified", "by", "environment", "variable", "or", "default", "location" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/kube/client/kubeclient.go#L125-L139
train
gravitational/teleport
lib/kube/client/kubeclient.go
kubeconfigFromEnv
func kubeconfigFromEnv() string { kubeconfig := os.Getenv(teleport.EnvKubeConfig) // The KUBECONFIG environment variable is a list. On Windows it's // semicolon-delimited. On Linux and macOS it's colon-delimited. var parts []string switch runtime.GOOS { case teleport.WindowsOS: parts = strings.Split(kubeconfig...
go
func kubeconfigFromEnv() string { kubeconfig := os.Getenv(teleport.EnvKubeConfig) // The KUBECONFIG environment variable is a list. On Windows it's // semicolon-delimited. On Linux and macOS it's colon-delimited. var parts []string switch runtime.GOOS { case teleport.WindowsOS: parts = strings.Split(kubeconfig...
[ "func", "kubeconfigFromEnv", "(", ")", "string", "{", "kubeconfig", ":=", "os", ".", "Getenv", "(", "teleport", ".", "EnvKubeConfig", ")", "\n\n", "// The KUBECONFIG environment variable is a list. On Windows it's", "// semicolon-delimited. On Linux and macOS it's colon-delimited...
// kubeconfigFromEnv extracts location of kubeconfig from the environment.
[ "kubeconfigFromEnv", "extracts", "location", "of", "kubeconfig", "from", "the", "environment", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/kube/client/kubeclient.go#L142-L163
train