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/reversetunnel/agent.go
connectedTo
func (a *Agent) connectedTo(proxy services.Server) bool { principals := a.getPrincipals() proxyID := fmt.Sprintf("%v.%v", proxy.GetName(), a.ClusterName) if _, ok := principals[proxyID]; ok { return true } return false }
go
func (a *Agent) connectedTo(proxy services.Server) bool { principals := a.getPrincipals() proxyID := fmt.Sprintf("%v.%v", proxy.GetName(), a.ClusterName) if _, ok := principals[proxyID]; ok { return true } return false }
[ "func", "(", "a", "*", "Agent", ")", "connectedTo", "(", "proxy", "services", ".", "Server", ")", "bool", "{", "principals", ":=", "a", ".", "getPrincipals", "(", ")", "\n", "proxyID", ":=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "proxy", ".", ...
// connectedTo returns true if connected services.Server passed in.
[ "connectedTo", "returns", "true", "if", "connected", "services", ".", "Server", "passed", "in", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/reversetunnel/agent.go#L230-L237
train
gravitational/teleport
lib/reversetunnel/agent.go
connectedToRightProxy
func (a *Agent) connectedToRightProxy() bool { for _, proxy := range a.DiscoverProxies { if a.connectedTo(proxy) { return true } } return false }
go
func (a *Agent) connectedToRightProxy() bool { for _, proxy := range a.DiscoverProxies { if a.connectedTo(proxy) { return true } } return false }
[ "func", "(", "a", "*", "Agent", ")", "connectedToRightProxy", "(", ")", "bool", "{", "for", "_", ",", "proxy", ":=", "range", "a", ".", "DiscoverProxies", "{", "if", "a", ".", "connectedTo", "(", "proxy", ")", "{", "return", "true", "\n", "}", "\n", ...
// connectedToRightProxy returns true if it connected to a proxy in the // discover list.
[ "connectedToRightProxy", "returns", "true", "if", "it", "connected", "to", "a", "proxy", "in", "the", "discover", "list", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/reversetunnel/agent.go#L241-L248
train
gravitational/teleport
lib/reversetunnel/agent.go
run
func (a *Agent) run() { defer a.setState(agentStateDisconnected) if len(a.DiscoverProxies) != 0 { a.setStateAndPrincipals(agentStateDiscovering, nil) } else { a.setStateAndPrincipals(agentStateConnecting, nil) } // Try and connect to remote cluster. conn, err := a.connect() if err != nil || conn == nil { ...
go
func (a *Agent) run() { defer a.setState(agentStateDisconnected) if len(a.DiscoverProxies) != 0 { a.setStateAndPrincipals(agentStateDiscovering, nil) } else { a.setStateAndPrincipals(agentStateConnecting, nil) } // Try and connect to remote cluster. conn, err := a.connect() if err != nil || conn == nil { ...
[ "func", "(", "a", "*", "Agent", ")", "run", "(", ")", "{", "defer", "a", ".", "setState", "(", "agentStateDisconnected", ")", "\n\n", "if", "len", "(", "a", ".", "DiscoverProxies", ")", "!=", "0", "{", "a", ".", "setStateAndPrincipals", "(", "agentStat...
// run is the main agent loop. It tries to establish a connection to the // remote proxy and then process requests that come over the tunnel. // // Once run connects to a proxy it starts processing requests from the proxy // via SSH channels opened by the remote Proxy. // // Agent sends periodic heartbeats back to the ...
[ "run", "is", "the", "main", "agent", "loop", ".", "It", "tries", "to", "establish", "a", "connection", "to", "the", "remote", "proxy", "and", "then", "process", "requests", "that", "come", "over", "the", "tunnel", ".", "Once", "run", "connects", "to", "a...
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/reversetunnel/agent.go#L324-L376
train
gravitational/teleport
lib/reversetunnel/agent.go
processRequests
func (a *Agent) processRequests(conn *ssh.Client) error { defer conn.Close() ticker := time.NewTicker(defaults.ReverseTunnelAgentHeartbeatPeriod) defer ticker.Stop() hb, reqC, err := conn.OpenChannel(chanHeartbeat, nil) if err != nil { return trace.Wrap(err) } newTransportC := conn.HandleChannelOpen(chanTrans...
go
func (a *Agent) processRequests(conn *ssh.Client) error { defer conn.Close() ticker := time.NewTicker(defaults.ReverseTunnelAgentHeartbeatPeriod) defer ticker.Stop() hb, reqC, err := conn.OpenChannel(chanHeartbeat, nil) if err != nil { return trace.Wrap(err) } newTransportC := conn.HandleChannelOpen(chanTrans...
[ "func", "(", "a", "*", "Agent", ")", "processRequests", "(", "conn", "*", "ssh", ".", "Client", ")", "error", "{", "defer", "conn", ".", "Close", "(", ")", "\n", "ticker", ":=", "time", ".", "NewTicker", "(", "defaults", ".", "ReverseTunnelAgentHeartbeat...
// processRequests is a blocking function which runs in a loop sending heartbeats // to the given SSH connection and processes inbound requests from the // remote proxy
[ "processRequests", "is", "a", "blocking", "function", "which", "runs", "in", "a", "loop", "sending", "heartbeats", "to", "the", "given", "SSH", "connection", "and", "processes", "inbound", "requests", "from", "the", "remote", "proxy" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/reversetunnel/agent.go#L384-L454
train
gravitational/teleport
lib/utils/retry.go
NewLinear
func NewLinear(cfg LinearConfig) (*Linear, error) { if err := cfg.CheckAndSetDefaults(); err != nil { return nil, trace.Wrap(err) } closedChan := make(chan time.Time) close(closedChan) return &Linear{LinearConfig: cfg, closedChan: closedChan}, nil }
go
func NewLinear(cfg LinearConfig) (*Linear, error) { if err := cfg.CheckAndSetDefaults(); err != nil { return nil, trace.Wrap(err) } closedChan := make(chan time.Time) close(closedChan) return &Linear{LinearConfig: cfg, closedChan: closedChan}, nil }
[ "func", "NewLinear", "(", "cfg", "LinearConfig", ")", "(", "*", "Linear", ",", "error", ")", "{", "if", "err", ":=", "cfg", ".", "CheckAndSetDefaults", "(", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "trace", ".", "Wrap", "(", "err", ...
// NewLinear returns a new instance of linear retry
[ "NewLinear", "returns", "a", "new", "instance", "of", "linear", "retry" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/retry.go#L66-L73
train
gravitational/teleport
lib/utils/retry.go
Duration
func (r *Linear) Duration() time.Duration { a := r.First + time.Duration(r.attempt)*r.Step if a < 0 { return 0 } if a <= r.Max { return a } return r.Max }
go
func (r *Linear) Duration() time.Duration { a := r.First + time.Duration(r.attempt)*r.Step if a < 0 { return 0 } if a <= r.Max { return a } return r.Max }
[ "func", "(", "r", "*", "Linear", ")", "Duration", "(", ")", "time", ".", "Duration", "{", "a", ":=", "r", ".", "First", "+", "time", ".", "Duration", "(", "r", ".", "attempt", ")", "*", "r", ".", "Step", "\n", "if", "a", "<", "0", "{", "retur...
// Duration returns retry duration based on state
[ "Duration", "returns", "retry", "duration", "based", "on", "state" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/retry.go#L98-L107
train
gravitational/teleport
lib/utils/retry.go
After
func (r *Linear) After() <-chan time.Time { if r.Duration() == 0 { return r.closedChan } return time.After(r.Duration()) }
go
func (r *Linear) After() <-chan time.Time { if r.Duration() == 0 { return r.closedChan } return time.After(r.Duration()) }
[ "func", "(", "r", "*", "Linear", ")", "After", "(", ")", "<-", "chan", "time", ".", "Time", "{", "if", "r", ".", "Duration", "(", ")", "==", "0", "{", "return", "r", ".", "closedChan", "\n", "}", "\n", "return", "time", ".", "After", "(", "r", ...
// After returns channel that fires with timeout // defined in Duration method, as a special case // if Duration is 0 returns a closed channel
[ "After", "returns", "channel", "that", "fires", "with", "timeout", "defined", "in", "Duration", "method", "as", "a", "special", "case", "if", "Duration", "is", "0", "returns", "a", "closed", "channel" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/retry.go#L112-L117
train
gravitational/teleport
lib/utils/retry.go
String
func (r *Linear) String() string { return fmt.Sprintf("Linear(attempt=%v, duration=%v)", r.attempt, r.Duration()) }
go
func (r *Linear) String() string { return fmt.Sprintf("Linear(attempt=%v, duration=%v)", r.attempt, r.Duration()) }
[ "func", "(", "r", "*", "Linear", ")", "String", "(", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "r", ".", "attempt", ",", "r", ".", "Duration", "(", ")", ")", "\n", "}" ]
// String returns user-friendly representation of the LinearPeriod
[ "String", "returns", "user", "-", "friendly", "representation", "of", "the", "LinearPeriod" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/retry.go#L120-L122
train
gravitational/teleport
lib/shell/shell_unix.go
getLoginShell
func getLoginShell(username string) (string, error) { // See if the username is valid. _, err := user.Lookup(username) if err != nil { return "", trace.Wrap(err) } // Based on stdlib user/lookup_unix.go packages which does not return // user shell: https://golang.org/src/os/user/lookup_unix.go var pwd C.struc...
go
func getLoginShell(username string) (string, error) { // See if the username is valid. _, err := user.Lookup(username) if err != nil { return "", trace.Wrap(err) } // Based on stdlib user/lookup_unix.go packages which does not return // user shell: https://golang.org/src/os/user/lookup_unix.go var pwd C.struc...
[ "func", "getLoginShell", "(", "username", "string", ")", "(", "string", ",", "error", ")", "{", "// See if the username is valid.", "_", ",", "err", ":=", "user", ".", "Lookup", "(", "username", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "...
// getLoginShell determines the login shell for a given username
[ "getLoginShell", "determines", "the", "login", "shell", "for", "a", "given", "username" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/shell/shell_unix.go#L46-L88
train
gravitational/teleport
lib/sshutils/fingerprint.go
AuthorizedKeyFingerprint
func AuthorizedKeyFingerprint(publicKey []byte) (string, error) { key, _, _, _, err := ssh.ParseAuthorizedKey(publicKey) if err != nil { return "", trace.Wrap(err) } return Fingerprint(key), nil }
go
func AuthorizedKeyFingerprint(publicKey []byte) (string, error) { key, _, _, _, err := ssh.ParseAuthorizedKey(publicKey) if err != nil { return "", trace.Wrap(err) } return Fingerprint(key), nil }
[ "func", "AuthorizedKeyFingerprint", "(", "publicKey", "[", "]", "byte", ")", "(", "string", ",", "error", ")", "{", "key", ",", "_", ",", "_", ",", "_", ",", "err", ":=", "ssh", ".", "ParseAuthorizedKey", "(", "publicKey", ")", "\n", "if", "err", "!=...
// AuthorizedKeyFingerprint returns fingerprint from public key // in authorized key format
[ "AuthorizedKeyFingerprint", "returns", "fingerprint", "from", "public", "key", "in", "authorized", "key", "format" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/sshutils/fingerprint.go#L15-L21
train
gravitational/teleport
lib/sshutils/fingerprint.go
PrivateKeyFingerprint
func PrivateKeyFingerprint(keyBytes []byte) (string, error) { signer, err := ssh.ParsePrivateKey(keyBytes) if err != nil { return "", trace.Wrap(err) } return Fingerprint(signer.PublicKey()), nil }
go
func PrivateKeyFingerprint(keyBytes []byte) (string, error) { signer, err := ssh.ParsePrivateKey(keyBytes) if err != nil { return "", trace.Wrap(err) } return Fingerprint(signer.PublicKey()), nil }
[ "func", "PrivateKeyFingerprint", "(", "keyBytes", "[", "]", "byte", ")", "(", "string", ",", "error", ")", "{", "signer", ",", "err", ":=", "ssh", ".", "ParsePrivateKey", "(", "keyBytes", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ...
// PrivateKeyFingerprint returns fingerprint of the public key // extracted from the PEM encoded private key
[ "PrivateKeyFingerprint", "returns", "fingerprint", "of", "the", "public", "key", "extracted", "from", "the", "PEM", "encoded", "private", "key" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/sshutils/fingerprint.go#L25-L31
train
gravitational/teleport
lib/utils/anonymizer.go
NewHMACAnonymizer
func NewHMACAnonymizer(key string) (*hmacAnonymizer, error) { if strings.TrimSpace(key) == "" { return nil, trace.BadParameter("HMAC key must not be empty") } return &hmacAnonymizer{ key: key, }, nil }
go
func NewHMACAnonymizer(key string) (*hmacAnonymizer, error) { if strings.TrimSpace(key) == "" { return nil, trace.BadParameter("HMAC key must not be empty") } return &hmacAnonymizer{ key: key, }, nil }
[ "func", "NewHMACAnonymizer", "(", "key", "string", ")", "(", "*", "hmacAnonymizer", ",", "error", ")", "{", "if", "strings", ".", "TrimSpace", "(", "key", ")", "==", "\"", "\"", "{", "return", "nil", ",", "trace", ".", "BadParameter", "(", "\"", "\"", ...
// NewHMACAnonymizer returns a new HMAC-based anonymizer
[ "NewHMACAnonymizer", "returns", "a", "new", "HMAC", "-", "based", "anonymizer" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/anonymizer.go#L41-L48
train
gravitational/teleport
lib/utils/anonymizer.go
Anonymize
func (a *hmacAnonymizer) Anonymize(data []byte) string { h := hmac.New(sha256.New, []byte(a.key)) h.Write(data) return base64.StdEncoding.EncodeToString(h.Sum(nil)) }
go
func (a *hmacAnonymizer) Anonymize(data []byte) string { h := hmac.New(sha256.New, []byte(a.key)) h.Write(data) return base64.StdEncoding.EncodeToString(h.Sum(nil)) }
[ "func", "(", "a", "*", "hmacAnonymizer", ")", "Anonymize", "(", "data", "[", "]", "byte", ")", "string", "{", "h", ":=", "hmac", ".", "New", "(", "sha256", ".", "New", ",", "[", "]", "byte", "(", "a", ".", "key", ")", ")", "\n", "h", ".", "Wr...
// Anonymize anonymizes the provided data using HMAC
[ "Anonymize", "anonymizes", "the", "provided", "data", "using", "HMAC" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/anonymizer.go#L51-L55
train
gravitational/teleport
lib/utils/schema.go
UnmarshalWithSchema
func UnmarshalWithSchema(schemaDefinition string, object interface{}, data []byte) error { schema, err := jsonschema.New([]byte(schemaDefinition)) if err != nil { return trace.Wrap(err) } jsonData, err := ToJSON(data) if err != nil { return trace.Wrap(err) } raw := map[string]interface{}{} if err := json.U...
go
func UnmarshalWithSchema(schemaDefinition string, object interface{}, data []byte) error { schema, err := jsonschema.New([]byte(schemaDefinition)) if err != nil { return trace.Wrap(err) } jsonData, err := ToJSON(data) if err != nil { return trace.Wrap(err) } raw := map[string]interface{}{} if err := json.U...
[ "func", "UnmarshalWithSchema", "(", "schemaDefinition", "string", ",", "object", "interface", "{", "}", ",", "data", "[", "]", "byte", ")", "error", "{", "schema", ",", "err", ":=", "jsonschema", ".", "New", "(", "[", "]", "byte", "(", "schemaDefinition", ...
// UnmarshalWithSchema processes YAML or JSON encoded object with JSON schema, sets defaults // and unmarshals resulting object into given struct
[ "UnmarshalWithSchema", "processes", "YAML", "or", "JSON", "encoded", "object", "with", "JSON", "schema", "sets", "defaults", "and", "unmarshals", "resulting", "object", "into", "given", "struct" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/schema.go#L28-L57
train
gravitational/teleport
lib/events/archive.go
NewSessionArchive
func NewSessionArchive(dataDir, serverID, namespace string, sessionID session.ID) (io.ReadCloser, error) { index, err := readSessionIndex( dataDir, []string{serverID}, namespace, sessionID) if err != nil { return nil, trace.Wrap(err) } // io.Pipe allows to generate the archive part by part // without writing ...
go
func NewSessionArchive(dataDir, serverID, namespace string, sessionID session.ID) (io.ReadCloser, error) { index, err := readSessionIndex( dataDir, []string{serverID}, namespace, sessionID) if err != nil { return nil, trace.Wrap(err) } // io.Pipe allows to generate the archive part by part // without writing ...
[ "func", "NewSessionArchive", "(", "dataDir", ",", "serverID", ",", "namespace", "string", ",", "sessionID", "session", ".", "ID", ")", "(", "io", ".", "ReadCloser", ",", "error", ")", "{", "index", ",", "err", ":=", "readSessionIndex", "(", "dataDir", ",",...
// NewSessionArchive returns generated tar archive with all components
[ "NewSessionArchive", "returns", "generated", "tar", "archive", "with", "all", "components" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/events/archive.go#L30-L49
train
gravitational/teleport
lib/utils/certs.go
ParseSigningKeyStorePEM
func ParseSigningKeyStorePEM(keyPEM, certPEM string) (*SigningKeyStore, error) { _, err := ParseCertificatePEM([]byte(certPEM)) if err != nil { return nil, trace.Wrap(err) } key, err := ParsePrivateKeyPEM([]byte(keyPEM)) if err != nil { return nil, trace.Wrap(err) } rsaKey, ok := key.(*rsa.PrivateKey) if !o...
go
func ParseSigningKeyStorePEM(keyPEM, certPEM string) (*SigningKeyStore, error) { _, err := ParseCertificatePEM([]byte(certPEM)) if err != nil { return nil, trace.Wrap(err) } key, err := ParsePrivateKeyPEM([]byte(keyPEM)) if err != nil { return nil, trace.Wrap(err) } rsaKey, ok := key.(*rsa.PrivateKey) if !o...
[ "func", "ParseSigningKeyStorePEM", "(", "keyPEM", ",", "certPEM", "string", ")", "(", "*", "SigningKeyStore", ",", "error", ")", "{", "_", ",", "err", ":=", "ParseCertificatePEM", "(", "[", "]", "byte", "(", "certPEM", ")", ")", "\n", "if", "err", "!=", ...
// ParseSigningKeyStore parses signing key store from PEM encoded key pair
[ "ParseSigningKeyStore", "parses", "signing", "key", "store", "from", "PEM", "encoded", "key", "pair" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/certs.go#L36-L54
train
gravitational/teleport
lib/utils/certs.go
ParseCertificateRequestPEM
func ParseCertificateRequestPEM(bytes []byte) (*x509.CertificateRequest, error) { block, _ := pem.Decode(bytes) if block == nil { return nil, trace.BadParameter("expected PEM-encoded block") } csr, err := x509.ParseCertificateRequest(block.Bytes) if err != nil { return nil, trace.BadParameter(err.Error()) } ...
go
func ParseCertificateRequestPEM(bytes []byte) (*x509.CertificateRequest, error) { block, _ := pem.Decode(bytes) if block == nil { return nil, trace.BadParameter("expected PEM-encoded block") } csr, err := x509.ParseCertificateRequest(block.Bytes) if err != nil { return nil, trace.BadParameter(err.Error()) } ...
[ "func", "ParseCertificateRequestPEM", "(", "bytes", "[", "]", "byte", ")", "(", "*", "x509", ".", "CertificateRequest", ",", "error", ")", "{", "block", ",", "_", ":=", "pem", ".", "Decode", "(", "bytes", ")", "\n", "if", "block", "==", "nil", "{", "...
// ParseCertificateRequestPEM parses PEM-encoded certificate signing request
[ "ParseCertificateRequestPEM", "parses", "PEM", "-", "encoded", "certificate", "signing", "request" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/certs.go#L105-L115
train
gravitational/teleport
lib/utils/certs.go
ParseCertificatePEM
func ParseCertificatePEM(bytes []byte) (*x509.Certificate, error) { block, _ := pem.Decode(bytes) if block == nil { return nil, trace.BadParameter("expected PEM-encoded block") } cert, err := x509.ParseCertificate(block.Bytes) if err != nil { return nil, trace.BadParameter(err.Error()) } return cert, nil }
go
func ParseCertificatePEM(bytes []byte) (*x509.Certificate, error) { block, _ := pem.Decode(bytes) if block == nil { return nil, trace.BadParameter("expected PEM-encoded block") } cert, err := x509.ParseCertificate(block.Bytes) if err != nil { return nil, trace.BadParameter(err.Error()) } return cert, nil }
[ "func", "ParseCertificatePEM", "(", "bytes", "[", "]", "byte", ")", "(", "*", "x509", ".", "Certificate", ",", "error", ")", "{", "block", ",", "_", ":=", "pem", ".", "Decode", "(", "bytes", ")", "\n", "if", "block", "==", "nil", "{", "return", "ni...
// ParseCertificatePEM parses PEM-encoded certificate
[ "ParseCertificatePEM", "parses", "PEM", "-", "encoded", "certificate" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/certs.go#L118-L128
train
gravitational/teleport
lib/utils/certs.go
ParsePrivateKeyPEM
func ParsePrivateKeyPEM(bytes []byte) (crypto.Signer, error) { block, _ := pem.Decode(bytes) if block == nil { return nil, trace.BadParameter("expected PEM-encoded block") } return ParsePrivateKeyDER(block.Bytes) }
go
func ParsePrivateKeyPEM(bytes []byte) (crypto.Signer, error) { block, _ := pem.Decode(bytes) if block == nil { return nil, trace.BadParameter("expected PEM-encoded block") } return ParsePrivateKeyDER(block.Bytes) }
[ "func", "ParsePrivateKeyPEM", "(", "bytes", "[", "]", "byte", ")", "(", "crypto", ".", "Signer", ",", "error", ")", "{", "block", ",", "_", ":=", "pem", ".", "Decode", "(", "bytes", ")", "\n", "if", "block", "==", "nil", "{", "return", "nil", ",", ...
// ParsePrivateKeyPEM parses PEM-encoded private key
[ "ParsePrivateKeyPEM", "parses", "PEM", "-", "encoded", "private", "key" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/certs.go#L131-L137
train
gravitational/teleport
lib/utils/certs.go
ParsePrivateKeyDER
func ParsePrivateKeyDER(der []byte) (crypto.Signer, error) { generalKey, err := x509.ParsePKCS8PrivateKey(der) if err != nil { generalKey, err = x509.ParsePKCS1PrivateKey(der) if err != nil { generalKey, err = x509.ParseECPrivateKey(der) if err != nil { logrus.Errorf("Failed to parse key: %v.", err) ...
go
func ParsePrivateKeyDER(der []byte) (crypto.Signer, error) { generalKey, err := x509.ParsePKCS8PrivateKey(der) if err != nil { generalKey, err = x509.ParsePKCS1PrivateKey(der) if err != nil { generalKey, err = x509.ParseECPrivateKey(der) if err != nil { logrus.Errorf("Failed to parse key: %v.", err) ...
[ "func", "ParsePrivateKeyDER", "(", "der", "[", "]", "byte", ")", "(", "crypto", ".", "Signer", ",", "error", ")", "{", "generalKey", ",", "err", ":=", "x509", ".", "ParsePKCS8PrivateKey", "(", "der", ")", "\n", "if", "err", "!=", "nil", "{", "generalKe...
// ParsePrivateKeyDER parses unencrypted DER-encoded private key
[ "ParsePrivateKeyDER", "parses", "unencrypted", "DER", "-", "encoded", "private", "key" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/certs.go#L140-L161
train
gravitational/teleport
lib/utils/certs.go
ReadCertificateChain
func ReadCertificateChain(certificateChainBytes []byte) ([]*x509.Certificate, error) { // build the certificate chain next var certificateBlock *pem.Block var remainingBytes []byte = bytes.TrimSpace(certificateChainBytes) var certificateChain [][]byte for { certificateBlock, remainingBytes = pem.Decode(remainin...
go
func ReadCertificateChain(certificateChainBytes []byte) ([]*x509.Certificate, error) { // build the certificate chain next var certificateBlock *pem.Block var remainingBytes []byte = bytes.TrimSpace(certificateChainBytes) var certificateChain [][]byte for { certificateBlock, remainingBytes = pem.Decode(remainin...
[ "func", "ReadCertificateChain", "(", "certificateChainBytes", "[", "]", "byte", ")", "(", "[", "]", "*", "x509", ".", "Certificate", ",", "error", ")", "{", "// build the certificate chain next", "var", "certificateBlock", "*", "pem", ".", "Block", "\n", "var", ...
// ReadCertificateChain parses PEM encoded bytes that can contain one or // multiple certificates and returns a slice of x509.Certificate.
[ "ReadCertificateChain", "parses", "PEM", "encoded", "bytes", "that", "can", "contain", "one", "or", "multiple", "certificates", "and", "returns", "a", "slice", "of", "x509", ".", "Certificate", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/certs.go#L226-L260
train
gravitational/teleport
lib/utils/loadbalancer.go
NewLoadBalancer
func NewLoadBalancer(ctx context.Context, frontend NetAddr, backends ...NetAddr) (*LoadBalancer, error) { if ctx == nil { return nil, trace.BadParameter("missing parameter context") } waitCtx, waitCancel := context.WithCancel(ctx) return &LoadBalancer{ frontend: frontend, ctx: ctx, backends: ...
go
func NewLoadBalancer(ctx context.Context, frontend NetAddr, backends ...NetAddr) (*LoadBalancer, error) { if ctx == nil { return nil, trace.BadParameter("missing parameter context") } waitCtx, waitCancel := context.WithCancel(ctx) return &LoadBalancer{ frontend: frontend, ctx: ctx, backends: ...
[ "func", "NewLoadBalancer", "(", "ctx", "context", ".", "Context", ",", "frontend", "NetAddr", ",", "backends", "...", "NetAddr", ")", "(", "*", "LoadBalancer", ",", "error", ")", "{", "if", "ctx", "==", "nil", "{", "return", "nil", ",", "trace", ".", "...
// NewLoadBalancer returns new load balancer listening on frontend // and redirecting requests to backends using round robin algo
[ "NewLoadBalancer", "returns", "new", "load", "balancer", "listening", "on", "frontend", "and", "redirecting", "requests", "to", "backends", "using", "round", "robin", "algo" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/loadbalancer.go#L32-L52
train
gravitational/teleport
lib/utils/loadbalancer.go
trackConnection
func (l *LoadBalancer) trackConnection(backend NetAddr, conn net.Conn) int64 { l.Lock() defer l.Unlock() l.connID += 1 tracker, ok := l.connections[backend] if !ok { tracker = make(map[int64]net.Conn) l.connections[backend] = tracker } tracker[l.connID] = conn return l.connID }
go
func (l *LoadBalancer) trackConnection(backend NetAddr, conn net.Conn) int64 { l.Lock() defer l.Unlock() l.connID += 1 tracker, ok := l.connections[backend] if !ok { tracker = make(map[int64]net.Conn) l.connections[backend] = tracker } tracker[l.connID] = conn return l.connID }
[ "func", "(", "l", "*", "LoadBalancer", ")", "trackConnection", "(", "backend", "NetAddr", ",", "conn", "net", ".", "Conn", ")", "int64", "{", "l", ".", "Lock", "(", ")", "\n", "defer", "l", ".", "Unlock", "(", ")", "\n", "l", ".", "connID", "+=", ...
// trackeConnection adds connection to the connection tracker
[ "trackeConnection", "adds", "connection", "to", "the", "connection", "tracker" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/loadbalancer.go#L72-L83
train
gravitational/teleport
lib/utils/loadbalancer.go
untrackConnection
func (l *LoadBalancer) untrackConnection(backend NetAddr, id int64) { l.Lock() defer l.Unlock() tracker, ok := l.connections[backend] if !ok { return } delete(tracker, id) }
go
func (l *LoadBalancer) untrackConnection(backend NetAddr, id int64) { l.Lock() defer l.Unlock() tracker, ok := l.connections[backend] if !ok { return } delete(tracker, id) }
[ "func", "(", "l", "*", "LoadBalancer", ")", "untrackConnection", "(", "backend", "NetAddr", ",", "id", "int64", ")", "{", "l", ".", "Lock", "(", ")", "\n", "defer", "l", ".", "Unlock", "(", ")", "\n", "tracker", ",", "ok", ":=", "l", ".", "connecti...
// untrackConnection removes connection from connection tracker
[ "untrackConnection", "removes", "connection", "from", "connection", "tracker" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/loadbalancer.go#L86-L94
train
gravitational/teleport
lib/utils/loadbalancer.go
dropConnections
func (l *LoadBalancer) dropConnections(backend NetAddr) { tracker := l.connections[backend] for _, conn := range tracker { conn.Close() } delete(l.connections, backend) }
go
func (l *LoadBalancer) dropConnections(backend NetAddr) { tracker := l.connections[backend] for _, conn := range tracker { conn.Close() } delete(l.connections, backend) }
[ "func", "(", "l", "*", "LoadBalancer", ")", "dropConnections", "(", "backend", "NetAddr", ")", "{", "tracker", ":=", "l", ".", "connections", "[", "backend", "]", "\n", "for", "_", ",", "conn", ":=", "range", "tracker", "{", "conn", ".", "Close", "(", ...
// dropConnections drops connections associated with backend
[ "dropConnections", "drops", "connections", "associated", "with", "backend" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/loadbalancer.go#L97-L103
train
gravitational/teleport
lib/utils/loadbalancer.go
AddBackend
func (l *LoadBalancer) AddBackend(b NetAddr) { l.Lock() defer l.Unlock() l.backends = append(l.backends, b) l.Debugf("backends %v", l.backends) }
go
func (l *LoadBalancer) AddBackend(b NetAddr) { l.Lock() defer l.Unlock() l.backends = append(l.backends, b) l.Debugf("backends %v", l.backends) }
[ "func", "(", "l", "*", "LoadBalancer", ")", "AddBackend", "(", "b", "NetAddr", ")", "{", "l", ".", "Lock", "(", ")", "\n", "defer", "l", ".", "Unlock", "(", ")", "\n", "l", ".", "backends", "=", "append", "(", "l", ".", "backends", ",", "b", ")...
// AddBackend adds backend
[ "AddBackend", "adds", "backend" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/loadbalancer.go#L106-L111
train
gravitational/teleport
lib/utils/loadbalancer.go
RemoveBackend
func (l *LoadBalancer) RemoveBackend(b NetAddr) { l.Lock() defer l.Unlock() l.currentIndex = -1 for i := range l.backends { if l.backends[i].Equals(b) { l.backends = append(l.backends[:i], l.backends[i+1:]...) l.dropConnections(b) return } } }
go
func (l *LoadBalancer) RemoveBackend(b NetAddr) { l.Lock() defer l.Unlock() l.currentIndex = -1 for i := range l.backends { if l.backends[i].Equals(b) { l.backends = append(l.backends[:i], l.backends[i+1:]...) l.dropConnections(b) return } } }
[ "func", "(", "l", "*", "LoadBalancer", ")", "RemoveBackend", "(", "b", "NetAddr", ")", "{", "l", ".", "Lock", "(", ")", "\n", "defer", "l", ".", "Unlock", "(", ")", "\n", "l", ".", "currentIndex", "=", "-", "1", "\n", "for", "i", ":=", "range", ...
// RemoveBackend removes backend
[ "RemoveBackend", "removes", "backend" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/loadbalancer.go#L114-L125
train
gravitational/teleport
lib/utils/loadbalancer.go
ListenAndServe
func (l *LoadBalancer) ListenAndServe() error { if err := l.Listen(); err != nil { return trace.Wrap(err) } return l.Serve() }
go
func (l *LoadBalancer) ListenAndServe() error { if err := l.Listen(); err != nil { return trace.Wrap(err) } return l.Serve() }
[ "func", "(", "l", "*", "LoadBalancer", ")", "ListenAndServe", "(", ")", "error", "{", "if", "err", ":=", "l", ".", "Listen", "(", ")", ";", "err", "!=", "nil", "{", "return", "trace", ".", "Wrap", "(", "err", ")", "\n", "}", "\n", "return", "l", ...
// ListenAndServe starts listening socket and serves connections on it
[ "ListenAndServe", "starts", "listening", "socket", "and", "serves", "connections", "on", "it" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/loadbalancer.go#L162-L167
train
gravitational/teleport
lib/utils/loadbalancer.go
Listen
func (l *LoadBalancer) Listen() error { var err error l.listener, err = net.Listen(l.frontend.AddrNetwork, l.frontend.Addr) if err != nil { return trace.ConvertSystemError(err) } l.Debugf("created listening socket") return nil }
go
func (l *LoadBalancer) Listen() error { var err error l.listener, err = net.Listen(l.frontend.AddrNetwork, l.frontend.Addr) if err != nil { return trace.ConvertSystemError(err) } l.Debugf("created listening socket") return nil }
[ "func", "(", "l", "*", "LoadBalancer", ")", "Listen", "(", ")", "error", "{", "var", "err", "error", "\n", "l", ".", "listener", ",", "err", "=", "net", ".", "Listen", "(", "l", ".", "frontend", ".", "AddrNetwork", ",", "l", ".", "frontend", ".", ...
// Listen creates a listener on the frontend addr
[ "Listen", "creates", "a", "listener", "on", "the", "frontend", "addr" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/loadbalancer.go#L170-L178
train
gravitational/teleport
lib/utils/loadbalancer.go
Serve
func (l *LoadBalancer) Serve() error { defer l.waitCancel() backoffTimer := time.NewTicker(5 * time.Second) defer backoffTimer.Stop() for { conn, err := l.listener.Accept() if err != nil { if l.isClosed() { return trace.ConnectionProblem(nil, "listener is closed") } select { case <-backoffTimer....
go
func (l *LoadBalancer) Serve() error { defer l.waitCancel() backoffTimer := time.NewTicker(5 * time.Second) defer backoffTimer.Stop() for { conn, err := l.listener.Accept() if err != nil { if l.isClosed() { return trace.ConnectionProblem(nil, "listener is closed") } select { case <-backoffTimer....
[ "func", "(", "l", "*", "LoadBalancer", ")", "Serve", "(", ")", "error", "{", "defer", "l", ".", "waitCancel", "(", ")", "\n", "backoffTimer", ":=", "time", ".", "NewTicker", "(", "5", "*", "time", ".", "Second", ")", "\n", "defer", "backoffTimer", "....
// Serve starts accepting connections
[ "Serve", "starts", "accepting", "connections" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/loadbalancer.go#L181-L200
train
gravitational/teleport
lib/events/sessionlog.go
NewDiskSessionLogger
func NewDiskSessionLogger(cfg DiskSessionLoggerConfig) (*DiskSessionLogger, error) { if err := cfg.CheckAndSetDefaults(); err != nil { return nil, trace.Wrap(err) } var err error sessionDir := filepath.Join(cfg.DataDir, cfg.ServerID, SessionLogsDir, cfg.Namespace) indexFile, err := os.OpenFile( filepath.Join(...
go
func NewDiskSessionLogger(cfg DiskSessionLoggerConfig) (*DiskSessionLogger, error) { if err := cfg.CheckAndSetDefaults(); err != nil { return nil, trace.Wrap(err) } var err error sessionDir := filepath.Join(cfg.DataDir, cfg.ServerID, SessionLogsDir, cfg.Namespace) indexFile, err := os.OpenFile( filepath.Join(...
[ "func", "NewDiskSessionLogger", "(", "cfg", "DiskSessionLoggerConfig", ")", "(", "*", "DiskSessionLogger", ",", "error", ")", "{", "if", "err", ":=", "cfg", ".", "CheckAndSetDefaults", "(", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "trace", ...
// NewDiskSessionLogger creates new disk based session logger
[ "NewDiskSessionLogger", "creates", "new", "disk", "based", "session", "logger" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/events/sessionlog.go#L80-L107
train
gravitational/teleport
lib/events/sessionlog.go
Finalize
func (sl *DiskSessionLogger) Finalize() error { sl.Lock() defer sl.Unlock() return sl.finalize() }
go
func (sl *DiskSessionLogger) Finalize() error { sl.Lock() defer sl.Unlock() return sl.finalize() }
[ "func", "(", "sl", "*", "DiskSessionLogger", ")", "Finalize", "(", ")", "error", "{", "sl", ".", "Lock", "(", ")", "\n", "defer", "sl", ".", "Unlock", "(", ")", "\n\n", "return", "sl", ".", "finalize", "(", ")", "\n", "}" ]
// Finalize is called by the session when it's closing. This is where we're // releasing audit resources associated with the session
[ "Finalize", "is", "called", "by", "the", "session", "when", "it", "s", "closing", ".", "This", "is", "where", "we", "re", "releasing", "audit", "resources", "associated", "with", "the", "session" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/events/sessionlog.go#L163-L168
train
gravitational/teleport
lib/events/sessionlog.go
flush
func (sl *DiskSessionLogger) flush() error { var err, err2 error if sl.RecordSessions && sl.chunksFile != nil { err = sl.chunksFile.Flush() } if sl.eventsFile != nil { err2 = sl.eventsFile.Flush() } return trace.NewAggregate(err, err2) }
go
func (sl *DiskSessionLogger) flush() error { var err, err2 error if sl.RecordSessions && sl.chunksFile != nil { err = sl.chunksFile.Flush() } if sl.eventsFile != nil { err2 = sl.eventsFile.Flush() } return trace.NewAggregate(err, err2) }
[ "func", "(", "sl", "*", "DiskSessionLogger", ")", "flush", "(", ")", "error", "{", "var", "err", ",", "err2", "error", "\n\n", "if", "sl", ".", "RecordSessions", "&&", "sl", ".", "chunksFile", "!=", "nil", "{", "err", "=", "sl", ".", "chunksFile", "....
// flush is used to flush gzip frames to file, otherwise // some attempts to read the file could fail
[ "flush", "is", "used", "to", "flush", "gzip", "frames", "to", "file", "otherwise", "some", "attempts", "to", "read", "the", "file", "could", "fail" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/events/sessionlog.go#L172-L182
train
gravitational/teleport
lib/events/sessionlog.go
eventsFileName
func eventsFileName(dataDir string, sessionID session.ID, eventIndex int64) string { return filepath.Join(dataDir, fmt.Sprintf("%v-%v.events.gz", sessionID.String(), eventIndex)) }
go
func eventsFileName(dataDir string, sessionID session.ID, eventIndex int64) string { return filepath.Join(dataDir, fmt.Sprintf("%v-%v.events.gz", sessionID.String(), eventIndex)) }
[ "func", "eventsFileName", "(", "dataDir", "string", ",", "sessionID", "session", ".", "ID", ",", "eventIndex", "int64", ")", "string", "{", "return", "filepath", ".", "Join", "(", "dataDir", ",", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "sessionID", ...
// eventsFileName consists of session id and the first global event index recorded there
[ "eventsFileName", "consists", "of", "session", "id", "and", "the", "first", "global", "event", "index", "recorded", "there" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/events/sessionlog.go#L215-L217
train
gravitational/teleport
lib/events/sessionlog.go
chunksFileName
func chunksFileName(dataDir string, sessionID session.ID, offset int64) string { return filepath.Join(dataDir, fmt.Sprintf("%v-%v.chunks.gz", sessionID.String(), offset)) }
go
func chunksFileName(dataDir string, sessionID session.ID, offset int64) string { return filepath.Join(dataDir, fmt.Sprintf("%v-%v.chunks.gz", sessionID.String(), offset)) }
[ "func", "chunksFileName", "(", "dataDir", "string", ",", "sessionID", "session", ".", "ID", ",", "offset", "int64", ")", "string", "{", "return", "filepath", ".", "Join", "(", "dataDir", ",", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "sessionID", ".",...
// chunksFileName consists of session id and the first global offset recorded
[ "chunksFileName", "consists", "of", "session", "id", "and", "the", "first", "global", "offset", "recorded" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/events/sessionlog.go#L220-L222
train
gravitational/teleport
lib/events/sessionlog.go
PostSessionSlice
func (sl *DiskSessionLogger) PostSessionSlice(slice SessionSlice) error { sl.Lock() defer sl.Unlock() for i := range slice.Chunks { _, err := sl.writeChunk(slice.SessionID, slice.Chunks[i]) if err != nil { return trace.Wrap(err) } } return sl.flush() }
go
func (sl *DiskSessionLogger) PostSessionSlice(slice SessionSlice) error { sl.Lock() defer sl.Unlock() for i := range slice.Chunks { _, err := sl.writeChunk(slice.SessionID, slice.Chunks[i]) if err != nil { return trace.Wrap(err) } } return sl.flush() }
[ "func", "(", "sl", "*", "DiskSessionLogger", ")", "PostSessionSlice", "(", "slice", "SessionSlice", ")", "error", "{", "sl", ".", "Lock", "(", ")", "\n", "defer", "sl", ".", "Unlock", "(", ")", "\n\n", "for", "i", ":=", "range", "slice", ".", "Chunks",...
// PostSessionSlice takes series of events associated with the session // and writes them to events files and data file for future replays
[ "PostSessionSlice", "takes", "series", "of", "events", "associated", "with", "the", "session", "and", "writes", "them", "to", "events", "files", "and", "data", "file", "for", "future", "replays" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/events/sessionlog.go#L292-L303
train
gravitational/teleport
lib/events/sessionlog.go
EventFromChunk
func EventFromChunk(sessionID string, chunk *SessionChunk) (EventFields, error) { var fields EventFields eventStart := time.Unix(0, chunk.Time).In(time.UTC).Round(time.Millisecond) err := json.Unmarshal(chunk.Data, &fields) if err != nil { return nil, trace.Wrap(err) } fields[SessionEventID] = sessionID fields...
go
func EventFromChunk(sessionID string, chunk *SessionChunk) (EventFields, error) { var fields EventFields eventStart := time.Unix(0, chunk.Time).In(time.UTC).Round(time.Millisecond) err := json.Unmarshal(chunk.Data, &fields) if err != nil { return nil, trace.Wrap(err) } fields[SessionEventID] = sessionID fields...
[ "func", "EventFromChunk", "(", "sessionID", "string", ",", "chunk", "*", "SessionChunk", ")", "(", "EventFields", ",", "error", ")", "{", "var", "fields", "EventFields", "\n", "eventStart", ":=", "time", ".", "Unix", "(", "0", ",", "chunk", ".", "Time", ...
// EventFromChunk returns event converted from session chunk
[ "EventFromChunk", "returns", "event", "converted", "from", "session", "chunk" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/events/sessionlog.go#L306-L321
train
gravitational/teleport
lib/events/sessionlog.go
Close
func (f *gzipWriter) Close() error { var errors []error if f.Writer != nil { errors = append(errors, f.Writer.Close()) f.Writer.Reset(ioutil.Discard) writerPool.Put(f.Writer) f.Writer = nil } if f.file != nil { errors = append(errors, f.file.Close()) f.file = nil } return trace.NewAggregate(errors...)...
go
func (f *gzipWriter) Close() error { var errors []error if f.Writer != nil { errors = append(errors, f.Writer.Close()) f.Writer.Reset(ioutil.Discard) writerPool.Put(f.Writer) f.Writer = nil } if f.file != nil { errors = append(errors, f.file.Close()) f.file = nil } return trace.NewAggregate(errors...)...
[ "func", "(", "f", "*", "gzipWriter", ")", "Close", "(", ")", "error", "{", "var", "errors", "[", "]", "error", "\n", "if", "f", ".", "Writer", "!=", "nil", "{", "errors", "=", "append", "(", "errors", ",", "f", ".", "Writer", ".", "Close", "(", ...
// Close closes gzip writer and file
[ "Close", "closes", "gzip", "writer", "and", "file" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/events/sessionlog.go#L421-L434
train
gravitational/teleport
lib/events/sessionlog.go
Close
func (f *gzipReader) Close() error { var errors []error if f.ReadCloser != nil { errors = append(errors, f.ReadCloser.Close()) f.ReadCloser = nil } if f.file != nil { errors = append(errors, f.file.Close()) f.file = nil } return trace.NewAggregate(errors...) }
go
func (f *gzipReader) Close() error { var errors []error if f.ReadCloser != nil { errors = append(errors, f.ReadCloser.Close()) f.ReadCloser = nil } if f.file != nil { errors = append(errors, f.file.Close()) f.file = nil } return trace.NewAggregate(errors...) }
[ "func", "(", "f", "*", "gzipReader", ")", "Close", "(", ")", "error", "{", "var", "errors", "[", "]", "error", "\n", "if", "f", ".", "ReadCloser", "!=", "nil", "{", "errors", "=", "append", "(", "errors", ",", "f", ".", "ReadCloser", ".", "Close", ...
// Close closes file and gzip writer
[ "Close", "closes", "file", "and", "gzip", "writer" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/events/sessionlog.go#L463-L474
train
gravitational/teleport
lib/srv/heartbeat.go
String
func (h HeartbeatMode) String() string { switch h { case HeartbeatModeNode: return "Node" case HeartbeatModeProxy: return "Proxy" case HeartbeatModeAuth: return "Auth" default: return fmt.Sprintf("<unknown: %v>", int(h)) } }
go
func (h HeartbeatMode) String() string { switch h { case HeartbeatModeNode: return "Node" case HeartbeatModeProxy: return "Proxy" case HeartbeatModeAuth: return "Auth" default: return fmt.Sprintf("<unknown: %v>", int(h)) } }
[ "func", "(", "h", "HeartbeatMode", ")", "String", "(", ")", "string", "{", "switch", "h", "{", "case", "HeartbeatModeNode", ":", "return", "\"", "\"", "\n", "case", "HeartbeatModeProxy", ":", "return", "\"", "\"", "\n", "case", "HeartbeatModeAuth", ":", "r...
// String returns user-friendly representation of the mode
[ "String", "returns", "user", "-", "friendly", "representation", "of", "the", "mode" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/srv/heartbeat.go#L88-L99
train
gravitational/teleport
lib/srv/heartbeat.go
NewHeartbeat
func NewHeartbeat(cfg HeartbeatConfig) (*Heartbeat, error) { if err := cfg.CheckAndSetDefaults(); err != nil { return nil, trace.Wrap(err) } ctx, cancel := context.WithCancel(cfg.Context) h := &Heartbeat{ cancelCtx: ctx, cancel: cancel, HeartbeatConfig: cfg, Entry: log.WithFields(log.Fields...
go
func NewHeartbeat(cfg HeartbeatConfig) (*Heartbeat, error) { if err := cfg.CheckAndSetDefaults(); err != nil { return nil, trace.Wrap(err) } ctx, cancel := context.WithCancel(cfg.Context) h := &Heartbeat{ cancelCtx: ctx, cancel: cancel, HeartbeatConfig: cfg, Entry: log.WithFields(log.Fields...
[ "func", "NewHeartbeat", "(", "cfg", "HeartbeatConfig", ")", "(", "*", "Heartbeat", ",", "error", ")", "{", "if", "err", ":=", "cfg", ".", "CheckAndSetDefaults", "(", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "trace", ".", "Wrap", "(", ...
// NewHeartbeat returns a new instance of heartbeat
[ "NewHeartbeat", "returns", "a", "new", "instance", "of", "heartbeat" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/srv/heartbeat.go#L114-L132
train
gravitational/teleport
lib/srv/heartbeat.go
Run
func (h *Heartbeat) Run() error { defer func() { h.reset(HeartbeatStateInit) h.checkTicker.Stop() }() for { if err := h.fetchAndAnnounce(); err != nil { h.Warningf("Heartbeat failed %v.", err) } select { case <-h.checkTicker.C: case <-h.sendC: h.Debugf("Asked check out of cycle") case <-h.cance...
go
func (h *Heartbeat) Run() error { defer func() { h.reset(HeartbeatStateInit) h.checkTicker.Stop() }() for { if err := h.fetchAndAnnounce(); err != nil { h.Warningf("Heartbeat failed %v.", err) } select { case <-h.checkTicker.C: case <-h.sendC: h.Debugf("Asked check out of cycle") case <-h.cance...
[ "func", "(", "h", "*", "Heartbeat", ")", "Run", "(", ")", "error", "{", "defer", "func", "(", ")", "{", "h", ".", "reset", "(", "HeartbeatStateInit", ")", "\n", "h", ".", "checkTicker", ".", "Stop", "(", ")", "\n", "}", "(", ")", "\n", "for", "...
// Run periodically calls to announce presence, // should be called explicitly in a separate goroutine
[ "Run", "periodically", "calls", "to", "announce", "presence", "should", "be", "called", "explicitly", "in", "a", "separate", "goroutine" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/srv/heartbeat.go#L233-L251
train
gravitational/teleport
lib/srv/heartbeat.go
reset
func (h *Heartbeat) reset(state KeepAliveState) { h.setState(state) h.nextAnnounce = time.Time{} h.nextKeepAlive = time.Time{} h.keepAlive = nil if h.keepAliver != nil { if err := h.keepAliver.Close(); err != nil { h.Warningf("Failed to close keep aliver: %v", err) } h.keepAliver = nil } }
go
func (h *Heartbeat) reset(state KeepAliveState) { h.setState(state) h.nextAnnounce = time.Time{} h.nextKeepAlive = time.Time{} h.keepAlive = nil if h.keepAliver != nil { if err := h.keepAliver.Close(); err != nil { h.Warningf("Failed to close keep aliver: %v", err) } h.keepAliver = nil } }
[ "func", "(", "h", "*", "Heartbeat", ")", "reset", "(", "state", "KeepAliveState", ")", "{", "h", ".", "setState", "(", "state", ")", "\n", "h", ".", "nextAnnounce", "=", "time", ".", "Time", "{", "}", "\n", "h", ".", "nextKeepAlive", "=", "time", "...
// reset resets keep alive state // and sends the state back to the initial state // of sending full update
[ "reset", "resets", "keep", "alive", "state", "and", "sends", "the", "state", "back", "to", "the", "initial", "state", "of", "sending", "full", "update" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/srv/heartbeat.go#L276-L287
train
gravitational/teleport
lib/srv/heartbeat.go
fetch
func (h *Heartbeat) fetch() error { // failed to fetch server info? // reset to init state regardless of the current state server, err := h.GetServerInfo() if err != nil { h.reset(HeartbeatStateInit) return trace.Wrap(err) } switch h.state { // in case of successfull state fetch, move to announce from init ...
go
func (h *Heartbeat) fetch() error { // failed to fetch server info? // reset to init state regardless of the current state server, err := h.GetServerInfo() if err != nil { h.reset(HeartbeatStateInit) return trace.Wrap(err) } switch h.state { // in case of successfull state fetch, move to announce from init ...
[ "func", "(", "h", "*", "Heartbeat", ")", "fetch", "(", ")", "error", "{", "// failed to fetch server info?", "// reset to init state regardless of the current state", "server", ",", "err", ":=", "h", ".", "GetServerInfo", "(", ")", "\n", "if", "err", "!=", "nil", ...
// fetch, if succeeded updates or sets current server // to the last received server
[ "fetch", "if", "succeeded", "updates", "or", "sets", "current", "server", "to", "the", "last", "received", "server" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/srv/heartbeat.go#L291-L343
train
gravitational/teleport
lib/srv/heartbeat.go
fetchAndAnnounce
func (h *Heartbeat) fetchAndAnnounce() error { if err := h.fetch(); err != nil { return trace.Wrap(err) } if err := h.announce(); err != nil { return trace.Wrap(err) } return nil }
go
func (h *Heartbeat) fetchAndAnnounce() error { if err := h.fetch(); err != nil { return trace.Wrap(err) } if err := h.announce(); err != nil { return trace.Wrap(err) } return nil }
[ "func", "(", "h", "*", "Heartbeat", ")", "fetchAndAnnounce", "(", ")", "error", "{", "if", "err", ":=", "h", ".", "fetch", "(", ")", ";", "err", "!=", "nil", "{", "return", "trace", ".", "Wrap", "(", "err", ")", "\n", "}", "\n", "if", "err", ":...
// fetchAndAnnounce fetches data about server // and announces it to the server
[ "fetchAndAnnounce", "fetches", "data", "about", "server", "and", "announces", "it", "to", "the", "server" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/srv/heartbeat.go#L433-L441
train
gravitational/teleport
lib/srv/heartbeat.go
ForceSend
func (h *Heartbeat) ForceSend(timeout time.Duration) error { timeoutC := time.After(timeout) select { case h.sendC <- struct{}{}: case <-timeoutC: return trace.ConnectionProblem(nil, "timeout waiting for send") } select { case <-h.announceC: return nil case <-timeoutC: return trace.ConnectionProblem(nil, ...
go
func (h *Heartbeat) ForceSend(timeout time.Duration) error { timeoutC := time.After(timeout) select { case h.sendC <- struct{}{}: case <-timeoutC: return trace.ConnectionProblem(nil, "timeout waiting for send") } select { case <-h.announceC: return nil case <-timeoutC: return trace.ConnectionProblem(nil, ...
[ "func", "(", "h", "*", "Heartbeat", ")", "ForceSend", "(", "timeout", "time", ".", "Duration", ")", "error", "{", "timeoutC", ":=", "time", ".", "After", "(", "timeout", ")", "\n", "select", "{", "case", "h", ".", "sendC", "<-", "struct", "{", "}", ...
// ForceSend forces send cycle, used in tests, returns // nil in case of success, error otherwise
[ "ForceSend", "forces", "send", "cycle", "used", "in", "tests", "returns", "nil", "in", "case", "of", "success", "error", "otherwise" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/srv/heartbeat.go#L445-L458
train
gravitational/teleport
lib/events/dynamoevents/dynamoevents.go
deleteAllItems
func (b *Log) deleteAllItems() error { out, err := b.svc.Scan(&dynamodb.ScanInput{TableName: aws.String(b.Tablename)}) if err != nil { return trace.Wrap(err) } var requests []*dynamodb.WriteRequest for _, item := range out.Items { requests = append(requests, &dynamodb.WriteRequest{ DeleteRequest: &dynamodb....
go
func (b *Log) deleteAllItems() error { out, err := b.svc.Scan(&dynamodb.ScanInput{TableName: aws.String(b.Tablename)}) if err != nil { return trace.Wrap(err) } var requests []*dynamodb.WriteRequest for _, item := range out.Items { requests = append(requests, &dynamodb.WriteRequest{ DeleteRequest: &dynamodb....
[ "func", "(", "b", "*", "Log", ")", "deleteAllItems", "(", ")", "error", "{", "out", ",", "err", ":=", "b", ".", "svc", ".", "Scan", "(", "&", "dynamodb", ".", "ScanInput", "{", "TableName", ":", "aws", ".", "String", "(", "b", ".", "Tablename", "...
// deleteAllItems deletes all items from the database, used in tests
[ "deleteAllItems", "deletes", "all", "items", "from", "the", "database", "used", "in", "tests" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/events/dynamoevents/dynamoevents.go#L572-L602
train
gravitational/teleport
lib/services/local/events.go
NewEventsService
func NewEventsService(b backend.Backend) *EventsService { return &EventsService{ Entry: logrus.WithFields(logrus.Fields{trace.Component: "Events"}), backend: b, } }
go
func NewEventsService(b backend.Backend) *EventsService { return &EventsService{ Entry: logrus.WithFields(logrus.Fields{trace.Component: "Events"}), backend: b, } }
[ "func", "NewEventsService", "(", "b", "backend", ".", "Backend", ")", "*", "EventsService", "{", "return", "&", "EventsService", "{", "Entry", ":", "logrus", ".", "WithFields", "(", "logrus", ".", "Fields", "{", "trace", ".", "Component", ":", "\"", "\"", ...
// NewEventsService returns new events service instance
[ "NewEventsService", "returns", "new", "events", "service", "instance" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/local/events.go#L39-L44
train
gravitational/teleport
lib/services/local/events.go
base
func base(key []byte, offset int) ([]byte, error) { parts := bytes.Split(key, []byte{backend.Separator}) if len(parts) < offset+1 { return nil, trace.NotFound("failed parsing %v", string(key)) } return parts[len(parts)-offset-1], nil }
go
func base(key []byte, offset int) ([]byte, error) { parts := bytes.Split(key, []byte{backend.Separator}) if len(parts) < offset+1 { return nil, trace.NotFound("failed parsing %v", string(key)) } return parts[len(parts)-offset-1], nil }
[ "func", "base", "(", "key", "[", "]", "byte", ",", "offset", "int", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "parts", ":=", "bytes", ".", "Split", "(", "key", ",", "[", "]", "byte", "{", "backend", ".", "Separator", "}", ")", "\n", ...
// base returns last element delimited by separator, index is // is an index of the key part to get counting from the end
[ "base", "returns", "last", "element", "delimited", "by", "separator", "index", "is", "is", "an", "index", "of", "the", "key", "part", "to", "get", "counting", "from", "the", "end" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/local/events.go#L715-L721
train
gravitational/teleport
lib/services/local/events.go
baseTwoKeys
func baseTwoKeys(key []byte) (string, string, error) { parts := bytes.Split(key, []byte{backend.Separator}) if len(parts) < 2 { return "", "", trace.NotFound("failed parsing %v", string(key)) } return string(parts[len(parts)-2]), string(parts[len(parts)-1]), nil }
go
func baseTwoKeys(key []byte) (string, string, error) { parts := bytes.Split(key, []byte{backend.Separator}) if len(parts) < 2 { return "", "", trace.NotFound("failed parsing %v", string(key)) } return string(parts[len(parts)-2]), string(parts[len(parts)-1]), nil }
[ "func", "baseTwoKeys", "(", "key", "[", "]", "byte", ")", "(", "string", ",", "string", ",", "error", ")", "{", "parts", ":=", "bytes", ".", "Split", "(", "key", ",", "[", "]", "byte", "{", "backend", ".", "Separator", "}", ")", "\n", "if", "len"...
// baseTwoKeys returns two last keys
[ "baseTwoKeys", "returns", "two", "last", "keys" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/local/events.go#L724-L730
train
gravitational/teleport
lib/auth/api.go
NewWrapper
func NewWrapper(writer AccessPoint, cache ReadAccessPoint) AccessPoint { return &Wrapper{ Write: writer, ReadAccessPoint: cache, } }
go
func NewWrapper(writer AccessPoint, cache ReadAccessPoint) AccessPoint { return &Wrapper{ Write: writer, ReadAccessPoint: cache, } }
[ "func", "NewWrapper", "(", "writer", "AccessPoint", ",", "cache", "ReadAccessPoint", ")", "AccessPoint", "{", "return", "&", "Wrapper", "{", "Write", ":", "writer", ",", "ReadAccessPoint", ":", "cache", ",", "}", "\n", "}" ]
// NewWrapper returns new access point wrapper
[ "NewWrapper", "returns", "new", "access", "point", "wrapper" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/api.go#L142-L147
train
gravitational/teleport
lib/auth/api.go
UpsertNode
func (w *Wrapper) UpsertNode(s services.Server) (*services.KeepAlive, error) { return w.Write.UpsertNode(s) }
go
func (w *Wrapper) UpsertNode(s services.Server) (*services.KeepAlive, error) { return w.Write.UpsertNode(s) }
[ "func", "(", "w", "*", "Wrapper", ")", "UpsertNode", "(", "s", "services", ".", "Server", ")", "(", "*", "services", ".", "KeepAlive", ",", "error", ")", "{", "return", "w", ".", "Write", ".", "UpsertNode", "(", "s", ")", "\n", "}" ]
// UpsertNode is part of auth.AccessPoint implementation
[ "UpsertNode", "is", "part", "of", "auth", ".", "AccessPoint", "implementation" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/api.go#L158-L160
train
gravitational/teleport
lib/auth/api.go
UpsertAuthServer
func (w *Wrapper) UpsertAuthServer(s services.Server) error { return w.Write.UpsertAuthServer(s) }
go
func (w *Wrapper) UpsertAuthServer(s services.Server) error { return w.Write.UpsertAuthServer(s) }
[ "func", "(", "w", "*", "Wrapper", ")", "UpsertAuthServer", "(", "s", "services", ".", "Server", ")", "error", "{", "return", "w", ".", "Write", ".", "UpsertAuthServer", "(", "s", ")", "\n", "}" ]
// UpsertAuthServer is part of auth.AccessPoint implementation
[ "UpsertAuthServer", "is", "part", "of", "auth", ".", "AccessPoint", "implementation" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/api.go#L163-L165
train
gravitational/teleport
lib/auth/api.go
UpsertProxy
func (w *Wrapper) UpsertProxy(s services.Server) error { return w.Write.UpsertProxy(s) }
go
func (w *Wrapper) UpsertProxy(s services.Server) error { return w.Write.UpsertProxy(s) }
[ "func", "(", "w", "*", "Wrapper", ")", "UpsertProxy", "(", "s", "services", ".", "Server", ")", "error", "{", "return", "w", ".", "Write", ".", "UpsertProxy", "(", "s", ")", "\n", "}" ]
// UpsertProxy is part of auth.AccessPoint implementation
[ "UpsertProxy", "is", "part", "of", "auth", ".", "AccessPoint", "implementation" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/api.go#L173-L175
train
gravitational/teleport
lib/auth/api.go
UpsertTunnelConnection
func (w *Wrapper) UpsertTunnelConnection(conn services.TunnelConnection) error { return w.Write.UpsertTunnelConnection(conn) }
go
func (w *Wrapper) UpsertTunnelConnection(conn services.TunnelConnection) error { return w.Write.UpsertTunnelConnection(conn) }
[ "func", "(", "w", "*", "Wrapper", ")", "UpsertTunnelConnection", "(", "conn", "services", ".", "TunnelConnection", ")", "error", "{", "return", "w", ".", "Write", ".", "UpsertTunnelConnection", "(", "conn", ")", "\n", "}" ]
// UpsertTunnelConnection is a part of auth.AccessPoint implementation
[ "UpsertTunnelConnection", "is", "a", "part", "of", "auth", ".", "AccessPoint", "implementation" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/api.go#L178-L180
train
gravitational/teleport
lib/auth/api.go
DeleteTunnelConnection
func (w *Wrapper) DeleteTunnelConnection(clusterName, connName string) error { return w.Write.DeleteTunnelConnection(clusterName, connName) }
go
func (w *Wrapper) DeleteTunnelConnection(clusterName, connName string) error { return w.Write.DeleteTunnelConnection(clusterName, connName) }
[ "func", "(", "w", "*", "Wrapper", ")", "DeleteTunnelConnection", "(", "clusterName", ",", "connName", "string", ")", "error", "{", "return", "w", ".", "Write", ".", "DeleteTunnelConnection", "(", "clusterName", ",", "connName", ")", "\n", "}" ]
// DeleteTunnelConnection is a part of auth.AccessPoint implementation
[ "DeleteTunnelConnection", "is", "a", "part", "of", "auth", ".", "AccessPoint", "implementation" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/api.go#L183-L185
train
gravitational/teleport
lib/sshutils/server.go
SetShutdownPollPeriod
func SetShutdownPollPeriod(period time.Duration) ServerOption { return func(s *Server) error { s.shutdownPollPeriod = period return nil } }
go
func SetShutdownPollPeriod(period time.Duration) ServerOption { return func(s *Server) error { s.shutdownPollPeriod = period return nil } }
[ "func", "SetShutdownPollPeriod", "(", "period", "time", ".", "Duration", ")", "ServerOption", "{", "return", "func", "(", "s", "*", "Server", ")", "error", "{", "s", ".", "shutdownPollPeriod", "=", "period", "\n", "return", "nil", "\n", "}", "\n", "}" ]
// SetShutdownPollPeriod sets a polling period for graceful shutdowns of SSH servers
[ "SetShutdownPollPeriod", "sets", "a", "polling", "period", "for", "graceful", "shutdowns", "of", "SSH", "servers" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/sshutils/server.go#L113-L118
train
gravitational/teleport
lib/sshutils/server.go
Wait
func (s *Server) Wait(ctx context.Context) { select { case <-s.closeContext.Done(): case <-ctx.Done(): } }
go
func (s *Server) Wait(ctx context.Context) { select { case <-s.closeContext.Done(): case <-ctx.Done(): } }
[ "func", "(", "s", "*", "Server", ")", "Wait", "(", "ctx", "context", ".", "Context", ")", "{", "select", "{", "case", "<-", "s", ".", "closeContext", ".", "Done", "(", ")", ":", "case", "<-", "ctx", ".", "Done", "(", ")", ":", "}", "\n", "}" ]
// Wait waits until server stops serving new connections // on the listener socket
[ "Wait", "waits", "until", "server", "stops", "serving", "new", "connections", "on", "the", "listener", "socket" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/sshutils/server.go#L268-L273
train
gravitational/teleport
lib/sshutils/server.go
Shutdown
func (s *Server) Shutdown(ctx context.Context) error { // close listener to stop receiving new connections err := s.Close() s.Wait(ctx) activeConnections := s.trackConnections(0) if activeConnections == 0 { return err } s.Infof("Shutdown: waiting for %v connections to finish.", activeConnections) lastReport :...
go
func (s *Server) Shutdown(ctx context.Context) error { // close listener to stop receiving new connections err := s.Close() s.Wait(ctx) activeConnections := s.trackConnections(0) if activeConnections == 0 { return err } s.Infof("Shutdown: waiting for %v connections to finish.", activeConnections) lastReport :...
[ "func", "(", "s", "*", "Server", ")", "Shutdown", "(", "ctx", "context", ".", "Context", ")", "error", "{", "// close listener to stop receiving new connections", "err", ":=", "s", ".", "Close", "(", ")", "\n", "s", ".", "Wait", "(", "ctx", ")", "\n", "a...
// Shutdown initiates graceful shutdown - waiting until all active // connections will get closed
[ "Shutdown", "initiates", "graceful", "shutdown", "-", "waiting", "until", "all", "active", "connections", "will", "get", "closed" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/sshutils/server.go#L277-L305
train
gravitational/teleport
lib/sshutils/server.go
validateHostSigner
func validateHostSigner(signer ssh.Signer) error { cert, ok := signer.PublicKey().(*ssh.Certificate) if !ok { return trace.BadParameter("only host certificates supported") } if len(cert.ValidPrincipals) == 0 { return trace.BadParameter("at least one valid principal is required in host certificate") } certChe...
go
func validateHostSigner(signer ssh.Signer) error { cert, ok := signer.PublicKey().(*ssh.Certificate) if !ok { return trace.BadParameter("only host certificates supported") } if len(cert.ValidPrincipals) == 0 { return trace.BadParameter("at least one valid principal is required in host certificate") } certChe...
[ "func", "validateHostSigner", "(", "signer", "ssh", ".", "Signer", ")", "error", "{", "cert", ",", "ok", ":=", "signer", ".", "PublicKey", "(", ")", ".", "(", "*", "ssh", ".", "Certificate", ")", "\n", "if", "!", "ok", "{", "return", "trace", ".", ...
// validateHostSigner make sure the signer is a valid certificate.
[ "validateHostSigner", "make", "sure", "the", "signer", "is", "a", "valid", "certificate", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/sshutils/server.go#L506-L522
train
gravitational/teleport
lib/sshutils/server.go
KeysEqual
func KeysEqual(ak, bk ssh.PublicKey) bool { a := ssh.Marshal(ak) b := ssh.Marshal(bk) return (len(a) == len(b) && subtle.ConstantTimeCompare(a, b) == 1) }
go
func KeysEqual(ak, bk ssh.PublicKey) bool { a := ssh.Marshal(ak) b := ssh.Marshal(bk) return (len(a) == len(b) && subtle.ConstantTimeCompare(a, b) == 1) }
[ "func", "KeysEqual", "(", "ak", ",", "bk", "ssh", ".", "PublicKey", ")", "bool", "{", "a", ":=", "ssh", ".", "Marshal", "(", "ak", ")", "\n", "b", ":=", "ssh", ".", "Marshal", "(", "bk", ")", "\n", "return", "(", "len", "(", "a", ")", "==", "...
// KeysEqual is constant time compare of the keys to avoid timing attacks
[ "KeysEqual", "is", "constant", "time", "compare", "of", "the", "keys", "to", "avoid", "timing", "attacks" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/sshutils/server.go#L528-L532
train
gravitational/teleport
lib/backend/backend.go
String
func (w *Watch) String() string { return fmt.Sprintf("Watcher(name=%v, prefixes=%v)", w.Name, string(bytes.Join(w.Prefixes, []byte(", ")))) }
go
func (w *Watch) String() string { return fmt.Sprintf("Watcher(name=%v, prefixes=%v)", w.Name, string(bytes.Join(w.Prefixes, []byte(", ")))) }
[ "func", "(", "w", "*", "Watch", ")", "String", "(", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "w", ".", "Name", ",", "string", "(", "bytes", ".", "Join", "(", "w", ".", "Prefixes", ",", "[", "]", "byte", "(", ...
// String returns a user-friendly description // of the watcher
[ "String", "returns", "a", "user", "-", "friendly", "description", "of", "the", "watcher" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/backend/backend.go#L132-L134
train
gravitational/teleport
lib/backend/backend.go
GetString
func (p Params) GetString(key string) string { v, ok := p[key] if !ok { return "" } s, _ := v.(string) return s }
go
func (p Params) GetString(key string) string { v, ok := p[key] if !ok { return "" } s, _ := v.(string) return s }
[ "func", "(", "p", "Params", ")", "GetString", "(", "key", "string", ")", "string", "{", "v", ",", "ok", ":=", "p", "[", "key", "]", "\n", "if", "!", "ok", "{", "return", "\"", "\"", "\n", "}", "\n", "s", ",", "_", ":=", "v", ".", "(", "stri...
// GetString returns a string value stored in Params map, or an empty string // if nothing is found
[ "GetString", "returns", "a", "string", "value", "stored", "in", "Params", "map", "or", "an", "empty", "string", "if", "nothing", "is", "found" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/backend/backend.go#L229-L236
train
gravitational/teleport
lib/backend/backend.go
RangeEnd
func RangeEnd(key []byte) []byte { end := make([]byte, len(key)) copy(end, key) for i := len(end) - 1; i >= 0; i-- { if end[i] < 0xff { end[i] = end[i] + 1 end = end[:i+1] return end } } // next key does not exist (e.g., 0xffff); return noEnd }
go
func RangeEnd(key []byte) []byte { end := make([]byte, len(key)) copy(end, key) for i := len(end) - 1; i >= 0; i-- { if end[i] < 0xff { end[i] = end[i] + 1 end = end[:i+1] return end } } // next key does not exist (e.g., 0xffff); return noEnd }
[ "func", "RangeEnd", "(", "key", "[", "]", "byte", ")", "[", "]", "byte", "{", "end", ":=", "make", "(", "[", "]", "byte", ",", "len", "(", "key", ")", ")", "\n", "copy", "(", "end", ",", "key", ")", "\n", "for", "i", ":=", "len", "(", "end"...
// RangeEnd returns end of the range for given key
[ "RangeEnd", "returns", "end", "of", "the", "range", "for", "given", "key" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/backend/backend.go#L242-L254
train
gravitational/teleport
lib/backend/backend.go
TTL
func TTL(clock clockwork.Clock, expires time.Time) time.Duration { ttl := expires.Sub(clock.Now()) if ttl < time.Second { return time.Second } return ttl }
go
func TTL(clock clockwork.Clock, expires time.Time) time.Duration { ttl := expires.Sub(clock.Now()) if ttl < time.Second { return time.Second } return ttl }
[ "func", "TTL", "(", "clock", "clockwork", ".", "Clock", ",", "expires", "time", ".", "Time", ")", "time", ".", "Duration", "{", "ttl", ":=", "expires", ".", "Sub", "(", "clock", ".", "Now", "(", ")", ")", "\n", "if", "ttl", "<", "time", ".", "Sec...
// TTL returns TTL in duration units, rounds up to one second
[ "TTL", "returns", "TTL", "in", "duration", "units", "rounds", "up", "to", "one", "second" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/backend/backend.go#L279-L285
train
gravitational/teleport
lib/backend/backend.go
EarliestExpiry
func EarliestExpiry(times ...time.Time) time.Time { if len(times) == 0 { return time.Time{} } sort.Sort(earliest(times)) return times[0] }
go
func EarliestExpiry(times ...time.Time) time.Time { if len(times) == 0 { return time.Time{} } sort.Sort(earliest(times)) return times[0] }
[ "func", "EarliestExpiry", "(", "times", "...", "time", ".", "Time", ")", "time", ".", "Time", "{", "if", "len", "(", "times", ")", "==", "0", "{", "return", "time", ".", "Time", "{", "}", "\n", "}", "\n", "sort", ".", "Sort", "(", "earliest", "("...
// EarliestExpiry returns first of the // otherwise returns empty
[ "EarliestExpiry", "returns", "first", "of", "the", "otherwise", "returns", "empty" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/backend/backend.go#L289-L295
train
gravitational/teleport
lib/backend/backend.go
Expiry
func Expiry(clock clockwork.Clock, ttl time.Duration) time.Time { if ttl == 0 { return time.Time{} } return clock.Now().UTC().Add(ttl) }
go
func Expiry(clock clockwork.Clock, ttl time.Duration) time.Time { if ttl == 0 { return time.Time{} } return clock.Now().UTC().Add(ttl) }
[ "func", "Expiry", "(", "clock", "clockwork", ".", "Clock", ",", "ttl", "time", ".", "Duration", ")", "time", ".", "Time", "{", "if", "ttl", "==", "0", "{", "return", "time", ".", "Time", "{", "}", "\n", "}", "\n", "return", "clock", ".", "Now", "...
// Expiry converts ttl to expiry time, if ttl is 0 // returns empty time
[ "Expiry", "converts", "ttl", "to", "expiry", "time", "if", "ttl", "is", "0", "returns", "empty", "time" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/backend/backend.go#L299-L304
train
gravitational/teleport
lib/utils/agentconn/agent_unix.go
Dial
func Dial(socket string) (net.Conn, error) { conn, err := net.Dial("unix", socket) if err != nil { return nil, trace.Wrap(err) } return conn, nil }
go
func Dial(socket string) (net.Conn, error) { conn, err := net.Dial("unix", socket) if err != nil { return nil, trace.Wrap(err) } return conn, nil }
[ "func", "Dial", "(", "socket", "string", ")", "(", "net", ".", "Conn", ",", "error", ")", "{", "conn", ",", "err", ":=", "net", ".", "Dial", "(", "\"", "\"", ",", "socket", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "trace"...
// Dial creates net.Conn to a SSH agent listening on a Unix socket.
[ "Dial", "creates", "net", ".", "Conn", "to", "a", "SSH", "agent", "listening", "on", "a", "Unix", "socket", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/agentconn/agent_unix.go#L28-L35
train
gravitational/teleport
lib/services/authentication.go
NewAuthPreference
func NewAuthPreference(spec AuthPreferenceSpecV2) (AuthPreference, error) { return &AuthPreferenceV2{ Kind: KindClusterAuthPreference, Version: V2, Metadata: Metadata{ Name: MetaNameClusterAuthPreference, Namespace: defaults.Namespace, }, Spec: spec, }, nil }
go
func NewAuthPreference(spec AuthPreferenceSpecV2) (AuthPreference, error) { return &AuthPreferenceV2{ Kind: KindClusterAuthPreference, Version: V2, Metadata: Metadata{ Name: MetaNameClusterAuthPreference, Namespace: defaults.Namespace, }, Spec: spec, }, nil }
[ "func", "NewAuthPreference", "(", "spec", "AuthPreferenceSpecV2", ")", "(", "AuthPreference", ",", "error", ")", "{", "return", "&", "AuthPreferenceV2", "{", "Kind", ":", "KindClusterAuthPreference", ",", "Version", ":", "V2", ",", "Metadata", ":", "Metadata", "...
// NewAuthPreference is a convenience method to to create AuthPreferenceV2.
[ "NewAuthPreference", "is", "a", "convenience", "method", "to", "to", "create", "AuthPreferenceV2", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/authentication.go#L77-L87
train
gravitational/teleport
lib/services/authentication.go
GetU2F
func (c *AuthPreferenceV2) GetU2F() (*U2F, error) { if c.Spec.U2F == nil { return nil, trace.NotFound("U2F configuration not found") } return c.Spec.U2F, nil }
go
func (c *AuthPreferenceV2) GetU2F() (*U2F, error) { if c.Spec.U2F == nil { return nil, trace.NotFound("U2F configuration not found") } return c.Spec.U2F, nil }
[ "func", "(", "c", "*", "AuthPreferenceV2", ")", "GetU2F", "(", ")", "(", "*", "U2F", ",", "error", ")", "{", "if", "c", ".", "Spec", ".", "U2F", "==", "nil", "{", "return", "nil", ",", "trace", ".", "NotFound", "(", "\"", "\"", ")", "\n", "}", ...
// GetU2F gets the U2F configuration settings.
[ "GetU2F", "gets", "the", "U2F", "configuration", "settings", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/authentication.go#L175-L180
train
gravitational/teleport
lib/services/authentication.go
CheckAndSetDefaults
func (c *AuthPreferenceV2) CheckAndSetDefaults() error { // if nothing is passed in, set defaults if c.Spec.Type == "" { c.Spec.Type = teleport.Local } if c.Spec.SecondFactor == "" { c.Spec.SecondFactor = teleport.OTP } // make sure type makes sense switch c.Spec.Type { case teleport.Local, teleport.OIDC, ...
go
func (c *AuthPreferenceV2) CheckAndSetDefaults() error { // if nothing is passed in, set defaults if c.Spec.Type == "" { c.Spec.Type = teleport.Local } if c.Spec.SecondFactor == "" { c.Spec.SecondFactor = teleport.OTP } // make sure type makes sense switch c.Spec.Type { case teleport.Local, teleport.OIDC, ...
[ "func", "(", "c", "*", "AuthPreferenceV2", ")", "CheckAndSetDefaults", "(", ")", "error", "{", "// if nothing is passed in, set defaults", "if", "c", ".", "Spec", ".", "Type", "==", "\"", "\"", "{", "c", ".", "Spec", ".", "Type", "=", "teleport", ".", "Loc...
// CheckAndSetDefaults verifies the constraints for AuthPreference.
[ "CheckAndSetDefaults", "verifies", "the", "constraints", "for", "AuthPreference", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/authentication.go#L188-L212
train
gravitational/teleport
lib/services/authentication.go
String
func (c *AuthPreferenceV2) String() string { return fmt.Sprintf("AuthPreference(Type=%q,SecondFactor=%q)", c.Spec.Type, c.Spec.SecondFactor) }
go
func (c *AuthPreferenceV2) String() string { return fmt.Sprintf("AuthPreference(Type=%q,SecondFactor=%q)", c.Spec.Type, c.Spec.SecondFactor) }
[ "func", "(", "c", "*", "AuthPreferenceV2", ")", "String", "(", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "c", ".", "Spec", ".", "Type", ",", "c", ".", "Spec", ".", "SecondFactor", ")", "\n", "}" ]
// String represents a human readable version of authentication settings.
[ "String", "represents", "a", "human", "readable", "version", "of", "authentication", "settings", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/authentication.go#L215-L217
train
gravitational/teleport
lib/services/authentication.go
GetAuthPreferenceSchema
func GetAuthPreferenceSchema(extensionSchema string) string { var authPreferenceSchema string if authPreferenceSchema == "" { authPreferenceSchema = fmt.Sprintf(AuthPreferenceSpecSchemaTemplate, "") } else { authPreferenceSchema = fmt.Sprintf(AuthPreferenceSpecSchemaTemplate, ","+extensionSchema) } return fmt....
go
func GetAuthPreferenceSchema(extensionSchema string) string { var authPreferenceSchema string if authPreferenceSchema == "" { authPreferenceSchema = fmt.Sprintf(AuthPreferenceSpecSchemaTemplate, "") } else { authPreferenceSchema = fmt.Sprintf(AuthPreferenceSpecSchemaTemplate, ","+extensionSchema) } return fmt....
[ "func", "GetAuthPreferenceSchema", "(", "extensionSchema", "string", ")", "string", "{", "var", "authPreferenceSchema", "string", "\n", "if", "authPreferenceSchema", "==", "\"", "\"", "{", "authPreferenceSchema", "=", "fmt", ".", "Sprintf", "(", "AuthPreferenceSpecSch...
// GetAuthPreferenceSchema returns the schema with optionally injected // schema for extensions.
[ "GetAuthPreferenceSchema", "returns", "the", "schema", "with", "optionally", "injected", "schema", "for", "extensions", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/authentication.go#L277-L285
train
gravitational/teleport
lib/srv/regular/proxy.go
proxyToSite
func (t *proxySubsys) proxyToSite( ctx *srv.ServerContext, site reversetunnel.RemoteSite, remoteAddr net.Addr, ch ssh.Channel) error { conn, err := site.DialAuthServer() if err != nil { return trace.Wrap(err) } t.log.Infof("Connected to auth server: %v", conn.RemoteAddr()) go func() { var err error defer ...
go
func (t *proxySubsys) proxyToSite( ctx *srv.ServerContext, site reversetunnel.RemoteSite, remoteAddr net.Addr, ch ssh.Channel) error { conn, err := site.DialAuthServer() if err != nil { return trace.Wrap(err) } t.log.Infof("Connected to auth server: %v", conn.RemoteAddr()) go func() { var err error defer ...
[ "func", "(", "t", "*", "proxySubsys", ")", "proxyToSite", "(", "ctx", "*", "srv", ".", "ServerContext", ",", "site", "reversetunnel", ".", "RemoteSite", ",", "remoteAddr", "net", ".", "Addr", ",", "ch", "ssh", ".", "Channel", ")", "error", "{", "conn", ...
// proxyToSite establishes a proxy connection from the connected SSH client to the // auth server of the requested remote site
[ "proxyToSite", "establishes", "a", "proxy", "connection", "from", "the", "connected", "SSH", "client", "to", "the", "auth", "server", "of", "the", "requested", "remote", "site" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/srv/regular/proxy.go#L198-L226
train
gravitational/teleport
lib/utils/tls.go
ListenTLS
func ListenTLS(address string, certFile, keyFile string, cipherSuites []uint16) (net.Listener, error) { tlsConfig, err := CreateTLSConfiguration(certFile, keyFile, cipherSuites) if err != nil { return nil, trace.Wrap(err) } return tls.Listen("tcp", address, tlsConfig) }
go
func ListenTLS(address string, certFile, keyFile string, cipherSuites []uint16) (net.Listener, error) { tlsConfig, err := CreateTLSConfiguration(certFile, keyFile, cipherSuites) if err != nil { return nil, trace.Wrap(err) } return tls.Listen("tcp", address, tlsConfig) }
[ "func", "ListenTLS", "(", "address", "string", ",", "certFile", ",", "keyFile", "string", ",", "cipherSuites", "[", "]", "uint16", ")", "(", "net", ".", "Listener", ",", "error", ")", "{", "tlsConfig", ",", "err", ":=", "CreateTLSConfiguration", "(", "cert...
// ListenTLS sets up TLS listener for the http handler, starts listening // on a TCP socket and returns the socket which is ready to be used // for http.Serve
[ "ListenTLS", "sets", "up", "TLS", "listener", "for", "the", "http", "handler", "starts", "listening", "on", "a", "TCP", "socket", "and", "returns", "the", "socket", "which", "is", "ready", "to", "be", "used", "for", "http", ".", "Serve" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/tls.go#L41-L47
train
gravitational/teleport
lib/utils/tls.go
TLSConfig
func TLSConfig(cipherSuites []uint16) *tls.Config { config := &tls.Config{} // If ciphers suites were passed in, use them. Otherwise use the the // Go defaults. if len(cipherSuites) > 0 { config.CipherSuites = cipherSuites } // Pick the servers preferred ciphersuite, not the clients. config.PreferServerCiphe...
go
func TLSConfig(cipherSuites []uint16) *tls.Config { config := &tls.Config{} // If ciphers suites were passed in, use them. Otherwise use the the // Go defaults. if len(cipherSuites) > 0 { config.CipherSuites = cipherSuites } // Pick the servers preferred ciphersuite, not the clients. config.PreferServerCiphe...
[ "func", "TLSConfig", "(", "cipherSuites", "[", "]", "uint16", ")", "*", "tls", ".", "Config", "{", "config", ":=", "&", "tls", ".", "Config", "{", "}", "\n\n", "// If ciphers suites were passed in, use them. Otherwise use the the", "// Go defaults.", "if", "len", ...
// TLSConfig returns default TLS configuration strong defaults.
[ "TLSConfig", "returns", "default", "TLS", "configuration", "strong", "defaults", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/tls.go#L50-L67
train
gravitational/teleport
lib/utils/tls.go
CreateTLSConfiguration
func CreateTLSConfiguration(certFile, keyFile string, cipherSuites []uint16) (*tls.Config, error) { config := TLSConfig(cipherSuites) if _, err := os.Stat(certFile); err != nil { return nil, trace.BadParameter("certificate is not accessible by '%v'", certFile) } if _, err := os.Stat(keyFile); err != nil { retu...
go
func CreateTLSConfiguration(certFile, keyFile string, cipherSuites []uint16) (*tls.Config, error) { config := TLSConfig(cipherSuites) if _, err := os.Stat(certFile); err != nil { return nil, trace.BadParameter("certificate is not accessible by '%v'", certFile) } if _, err := os.Stat(keyFile); err != nil { retu...
[ "func", "CreateTLSConfiguration", "(", "certFile", ",", "keyFile", "string", ",", "cipherSuites", "[", "]", "uint16", ")", "(", "*", "tls", ".", "Config", ",", "error", ")", "{", "config", ":=", "TLSConfig", "(", "cipherSuites", ")", "\n\n", "if", "_", "...
// CreateTLSConfiguration sets up default TLS configuration
[ "CreateTLSConfiguration", "sets", "up", "default", "TLS", "configuration" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/tls.go#L70-L87
train
gravitational/teleport
lib/utils/tls.go
GenerateSelfSignedCert
func GenerateSelfSignedCert(hostNames []string) (*TLSCredentials, error) { priv, err := rsa.GenerateKey(rand.Reader, teleport.RSAKeySize) if err != nil { return nil, trace.Wrap(err) } notBefore := time.Now() notAfter := notBefore.Add(time.Hour * 24 * 365 * 10) // 10 years serialNumberLimit := new(big.Int).Lsh(...
go
func GenerateSelfSignedCert(hostNames []string) (*TLSCredentials, error) { priv, err := rsa.GenerateKey(rand.Reader, teleport.RSAKeySize) if err != nil { return nil, trace.Wrap(err) } notBefore := time.Now() notAfter := notBefore.Add(time.Hour * 24 * 365 * 10) // 10 years serialNumberLimit := new(big.Int).Lsh(...
[ "func", "GenerateSelfSignedCert", "(", "hostNames", "[", "]", "string", ")", "(", "*", "TLSCredentials", ",", "error", ")", "{", "priv", ",", "err", ":=", "rsa", ".", "GenerateKey", "(", "rand", ".", "Reader", ",", "teleport", ".", "RSAKeySize", ")", "\n...
// GenerateSelfSignedCert generates a self signed certificate that // is valid for given domain names and ips, returns PEM-encoded bytes with key and cert
[ "GenerateSelfSignedCert", "generates", "a", "self", "signed", "certificate", "that", "is", "valid", "for", "given", "domain", "names", "and", "ips", "returns", "PEM", "-", "encoded", "bytes", "with", "key", "and", "cert" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/tls.go#L100-L153
train
gravitational/teleport
lib/utils/tls.go
CipherSuiteMapping
func CipherSuiteMapping(cipherSuites []string) ([]uint16, error) { out := make([]uint16, 0, len(cipherSuites)) for _, cs := range cipherSuites { c, ok := cipherSuiteMapping[cs] if !ok { return nil, trace.BadParameter("cipher suite not supported: %v", cs) } out = append(out, c) } return out, nil }
go
func CipherSuiteMapping(cipherSuites []string) ([]uint16, error) { out := make([]uint16, 0, len(cipherSuites)) for _, cs := range cipherSuites { c, ok := cipherSuiteMapping[cs] if !ok { return nil, trace.BadParameter("cipher suite not supported: %v", cs) } out = append(out, c) } return out, nil }
[ "func", "CipherSuiteMapping", "(", "cipherSuites", "[", "]", "string", ")", "(", "[", "]", "uint16", ",", "error", ")", "{", "out", ":=", "make", "(", "[", "]", "uint16", ",", "0", ",", "len", "(", "cipherSuites", ")", ")", "\n\n", "for", "_", ",",...
// CipherSuiteMapping transforms Teleport formatted cipher suites strings // into uint16 IDs.
[ "CipherSuiteMapping", "transforms", "Teleport", "formatted", "cipher", "suites", "strings", "into", "uint16", "IDs", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/tls.go#L157-L170
train
gravitational/teleport
lib/srv/term.go
NewTerminal
func NewTerminal(ctx *ServerContext) (Terminal, error) { // It doesn't matter what mode the cluster is in, if this is a Teleport node // return a local terminal. if ctx.srv.Component() == teleport.ComponentNode { return newLocalTerminal(ctx) } // If this is not a Teleport node, find out what mode the cluster is...
go
func NewTerminal(ctx *ServerContext) (Terminal, error) { // It doesn't matter what mode the cluster is in, if this is a Teleport node // return a local terminal. if ctx.srv.Component() == teleport.ComponentNode { return newLocalTerminal(ctx) } // If this is not a Teleport node, find out what mode the cluster is...
[ "func", "NewTerminal", "(", "ctx", "*", "ServerContext", ")", "(", "Terminal", ",", "error", ")", "{", "// It doesn't matter what mode the cluster is in, if this is a Teleport node", "// return a local terminal.", "if", "ctx", ".", "srv", ".", "Component", "(", ")", "==...
// NewTerminal returns a new terminal. Terminal can be local or remote // depending on cluster configuration.
[ "NewTerminal", "returns", "a", "new", "terminal", ".", "Terminal", "can", "be", "local", "or", "remote", "depending", "on", "cluster", "configuration", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/srv/term.go#L95-L108
train
gravitational/teleport
lib/srv/term.go
newLocalTerminal
func newLocalTerminal(ctx *ServerContext) (*terminal, error) { var err error t := &terminal{ log: log.WithFields(log.Fields{ trace.Component: teleport.ComponentLocalTerm, }), ctx: ctx, } // Open PTY and corresponding TTY. t.pty, t.tty, err = pty.Open() if err != nil { log.Warnf("Could not start PTY %...
go
func newLocalTerminal(ctx *ServerContext) (*terminal, error) { var err error t := &terminal{ log: log.WithFields(log.Fields{ trace.Component: teleport.ComponentLocalTerm, }), ctx: ctx, } // Open PTY and corresponding TTY. t.pty, t.tty, err = pty.Open() if err != nil { log.Warnf("Could not start PTY %...
[ "func", "newLocalTerminal", "(", "ctx", "*", "ServerContext", ")", "(", "*", "terminal", ",", "error", ")", "{", "var", "err", "error", "\n\n", "t", ":=", "&", "terminal", "{", "log", ":", "log", ".", "WithFields", "(", "log", ".", "Fields", "{", "tr...
// NewLocalTerminal creates and returns a local PTY.
[ "NewLocalTerminal", "creates", "and", "returns", "a", "local", "PTY", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/srv/term.go#L128-L153
train
gravitational/teleport
lib/srv/term.go
Run
func (t *terminal) Run() error { defer t.closeTTY() cmd, err := prepareInteractiveCommand(t.ctx) if err != nil { return trace.Wrap(err) } t.cmd = cmd cmd.Stdout = t.tty cmd.Stdin = t.tty cmd.Stderr = t.tty cmd.SysProcAttr.Setctty = true cmd.SysProcAttr.Setsid = true err = cmd.Start() if err != nil { ...
go
func (t *terminal) Run() error { defer t.closeTTY() cmd, err := prepareInteractiveCommand(t.ctx) if err != nil { return trace.Wrap(err) } t.cmd = cmd cmd.Stdout = t.tty cmd.Stdin = t.tty cmd.Stderr = t.tty cmd.SysProcAttr.Setctty = true cmd.SysProcAttr.Setsid = true err = cmd.Start() if err != nil { ...
[ "func", "(", "t", "*", "terminal", ")", "Run", "(", ")", "error", "{", "defer", "t", ".", "closeTTY", "(", ")", "\n\n", "cmd", ",", "err", ":=", "prepareInteractiveCommand", "(", "t", ".", "ctx", ")", "\n", "if", "err", "!=", "nil", "{", "return", ...
// Run will run the terminal.
[ "Run", "will", "run", "the", "terminal", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/srv/term.go#L162-L183
train
gravitational/teleport
lib/srv/term.go
Wait
func (t *terminal) Wait() (*ExecResult, error) { err := t.cmd.Wait() if err != nil { if exitErr, ok := err.(*exec.ExitError); ok { status := exitErr.Sys().(syscall.WaitStatus) return &ExecResult{Code: status.ExitStatus(), Command: t.cmd.Path}, nil } return nil, err } status, ok := t.cmd.ProcessState.Sy...
go
func (t *terminal) Wait() (*ExecResult, error) { err := t.cmd.Wait() if err != nil { if exitErr, ok := err.(*exec.ExitError); ok { status := exitErr.Sys().(syscall.WaitStatus) return &ExecResult{Code: status.ExitStatus(), Command: t.cmd.Path}, nil } return nil, err } status, ok := t.cmd.ProcessState.Sy...
[ "func", "(", "t", "*", "terminal", ")", "Wait", "(", ")", "(", "*", "ExecResult", ",", "error", ")", "{", "err", ":=", "t", ".", "cmd", ".", "Wait", "(", ")", "\n", "if", "err", "!=", "nil", "{", "if", "exitErr", ",", "ok", ":=", "err", ".", ...
// Wait will block until the terminal is complete.
[ "Wait", "will", "block", "until", "the", "terminal", "is", "complete", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/srv/term.go#L186-L205
train
gravitational/teleport
lib/srv/term.go
Kill
func (t *terminal) Kill() error { if t.cmd.Process != nil { if err := t.cmd.Process.Kill(); err != nil { if err.Error() != "os: process already finished" { return trace.Wrap(err) } } } return nil }
go
func (t *terminal) Kill() error { if t.cmd.Process != nil { if err := t.cmd.Process.Kill(); err != nil { if err.Error() != "os: process already finished" { return trace.Wrap(err) } } } return nil }
[ "func", "(", "t", "*", "terminal", ")", "Kill", "(", ")", "error", "{", "if", "t", ".", "cmd", ".", "Process", "!=", "nil", "{", "if", "err", ":=", "t", ".", "cmd", ".", "Process", ".", "Kill", "(", ")", ";", "err", "!=", "nil", "{", "if", ...
// Kill will force kill the terminal.
[ "Kill", "will", "force", "kill", "the", "terminal", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/srv/term.go#L208-L218
train
gravitational/teleport
lib/srv/term.go
Close
func (t *terminal) Close() error { var err error // note, pty is closed in the copying goroutine, // not here to avoid data races if t.tty != nil { if e := t.tty.Close(); e != nil { err = e } } go t.closePTY() return trace.Wrap(err) }
go
func (t *terminal) Close() error { var err error // note, pty is closed in the copying goroutine, // not here to avoid data races if t.tty != nil { if e := t.tty.Close(); e != nil { err = e } } go t.closePTY() return trace.Wrap(err) }
[ "func", "(", "t", "*", "terminal", ")", "Close", "(", ")", "error", "{", "var", "err", "error", "\n", "// note, pty is closed in the copying goroutine,", "// not here to avoid data races", "if", "t", ".", "tty", "!=", "nil", "{", "if", "e", ":=", "t", ".", "...
// Close will free resources associated with the terminal.
[ "Close", "will", "free", "resources", "associated", "with", "the", "terminal", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/srv/term.go#L231-L242
train
gravitational/teleport
lib/srv/term.go
GetWinSize
func (t *terminal) GetWinSize() (*term.Winsize, error) { t.mu.Lock() defer t.mu.Unlock() if t.pty == nil { return nil, trace.NotFound("no pty") } ws, err := term.GetWinsize(t.pty.Fd()) if err != nil { return nil, trace.Wrap(err) } return ws, nil }
go
func (t *terminal) GetWinSize() (*term.Winsize, error) { t.mu.Lock() defer t.mu.Unlock() if t.pty == nil { return nil, trace.NotFound("no pty") } ws, err := term.GetWinsize(t.pty.Fd()) if err != nil { return nil, trace.Wrap(err) } return ws, nil }
[ "func", "(", "t", "*", "terminal", ")", "GetWinSize", "(", ")", "(", "*", "term", ".", "Winsize", ",", "error", ")", "{", "t", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "t", ".", "mu", ".", "Unlock", "(", ")", "\n", "if", "t", ".", "...
// GetWinSize returns the window size of the terminal.
[ "GetWinSize", "returns", "the", "window", "size", "of", "the", "terminal", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/srv/term.go#L264-L275
train
gravitational/teleport
lib/srv/term.go
SetWinSize
func (t *terminal) SetWinSize(params rsession.TerminalParams) error { t.mu.Lock() defer t.mu.Unlock() if t.pty == nil { return trace.NotFound("no pty") } if err := term.SetWinsize(t.pty.Fd(), params.Winsize()); err != nil { return trace.Wrap(err) } t.params = params return nil }
go
func (t *terminal) SetWinSize(params rsession.TerminalParams) error { t.mu.Lock() defer t.mu.Unlock() if t.pty == nil { return trace.NotFound("no pty") } if err := term.SetWinsize(t.pty.Fd(), params.Winsize()); err != nil { return trace.Wrap(err) } t.params = params return nil }
[ "func", "(", "t", "*", "terminal", ")", "SetWinSize", "(", "params", "rsession", ".", "TerminalParams", ")", "error", "{", "t", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "t", ".", "mu", ".", "Unlock", "(", ")", "\n", "if", "t", ".", "pty",...
// SetWinSize sets the window size of the terminal.
[ "SetWinSize", "sets", "the", "window", "size", "of", "the", "terminal", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/srv/term.go#L278-L289
train
gravitational/teleport
lib/srv/term.go
GetTerminalParams
func (t *terminal) GetTerminalParams() rsession.TerminalParams { t.mu.Lock() defer t.mu.Unlock() return t.params }
go
func (t *terminal) GetTerminalParams() rsession.TerminalParams { t.mu.Lock() defer t.mu.Unlock() return t.params }
[ "func", "(", "t", "*", "terminal", ")", "GetTerminalParams", "(", ")", "rsession", ".", "TerminalParams", "{", "t", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "t", ".", "mu", ".", "Unlock", "(", ")", "\n", "return", "t", ".", "params", "\n", ...
// GetTerminalParams is a fast call to get cached terminal parameters // and avoid extra system call.
[ "GetTerminalParams", "is", "a", "fast", "call", "to", "get", "cached", "terminal", "parameters", "and", "avoid", "extra", "system", "call", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/srv/term.go#L293-L297
train
gravitational/teleport
lib/srv/term.go
SetTermType
func (t *terminal) SetTermType(term string) { if term == "" { term = defaultTerm } t.termType = term }
go
func (t *terminal) SetTermType(term string) { if term == "" { term = defaultTerm } t.termType = term }
[ "func", "(", "t", "*", "terminal", ")", "SetTermType", "(", "term", "string", ")", "{", "if", "term", "==", "\"", "\"", "{", "term", "=", "defaultTerm", "\n", "}", "\n", "t", ".", "termType", "=", "term", "\n", "}" ]
// SetTermType sets the terminal type from "req-pty" request.
[ "SetTermType", "sets", "the", "terminal", "type", "from", "req", "-", "pty", "request", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/srv/term.go#L305-L310
train
gravitational/teleport
lib/srv/term.go
setOwner
func (t *terminal) setOwner() error { uid, gid, mode, err := getOwner(t.ctx.Identity.Login, user.Lookup, user.LookupGroup) if err != nil { return trace.Wrap(err) } err = os.Chown(t.tty.Name(), uid, gid) if err != nil { return trace.Wrap(err) } err = os.Chmod(t.tty.Name(), mode) if err != nil { return tra...
go
func (t *terminal) setOwner() error { uid, gid, mode, err := getOwner(t.ctx.Identity.Login, user.Lookup, user.LookupGroup) if err != nil { return trace.Wrap(err) } err = os.Chown(t.tty.Name(), uid, gid) if err != nil { return trace.Wrap(err) } err = os.Chmod(t.tty.Name(), mode) if err != nil { return tra...
[ "func", "(", "t", "*", "terminal", ")", "setOwner", "(", ")", "error", "{", "uid", ",", "gid", ",", "mode", ",", "err", ":=", "getOwner", "(", "t", ".", "ctx", ".", "Identity", ".", "Login", ",", "user", ".", "Lookup", ",", "user", ".", "LookupGr...
// setOwner changes the owner and mode of the TTY.
[ "setOwner", "changes", "the", "owner", "and", "mode", "of", "the", "TTY", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/srv/term.go#L355-L373
train
gravitational/teleport
lib/srv/term.go
prepareRemoteSession
func (t *remoteTerminal) prepareRemoteSession(session *ssh.Session, ctx *ServerContext) { envs := map[string]string{ teleport.SSHTeleportUser: ctx.Identity.TeleportUser, teleport.SSHSessionWebproxyAddr: ctx.ProxyPublicAddress(), teleport.SSHTeleportHostUUID: ctx.srv.ID(), teleport.SSHTeleportClusterN...
go
func (t *remoteTerminal) prepareRemoteSession(session *ssh.Session, ctx *ServerContext) { envs := map[string]string{ teleport.SSHTeleportUser: ctx.Identity.TeleportUser, teleport.SSHSessionWebproxyAddr: ctx.ProxyPublicAddress(), teleport.SSHTeleportHostUUID: ctx.srv.ID(), teleport.SSHTeleportClusterN...
[ "func", "(", "t", "*", "remoteTerminal", ")", "prepareRemoteSession", "(", "session", "*", "ssh", ".", "Session", ",", "ctx", "*", "ServerContext", ")", "{", "envs", ":=", "map", "[", "string", "]", "string", "{", "teleport", ".", "SSHTeleportUser", ":", ...
// prepareRemoteSession prepares the more session for execution.
[ "prepareRemoteSession", "prepares", "the", "more", "session", "for", "execution", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/srv/term.go#L586-L600
train
gravitational/teleport
lib/auth/auth.go
NewAuthServer
func NewAuthServer(cfg *InitConfig, opts ...AuthServerOption) (*AuthServer, error) { if cfg.Trust == nil { cfg.Trust = local.NewCAService(cfg.Backend) } if cfg.Presence == nil { cfg.Presence = local.NewPresenceService(cfg.Backend) } if cfg.Provisioner == nil { cfg.Provisioner = local.NewProvisioningService(c...
go
func NewAuthServer(cfg *InitConfig, opts ...AuthServerOption) (*AuthServer, error) { if cfg.Trust == nil { cfg.Trust = local.NewCAService(cfg.Backend) } if cfg.Presence == nil { cfg.Presence = local.NewPresenceService(cfg.Backend) } if cfg.Provisioner == nil { cfg.Provisioner = local.NewProvisioningService(c...
[ "func", "NewAuthServer", "(", "cfg", "*", "InitConfig", ",", "opts", "...", "AuthServerOption", ")", "(", "*", "AuthServer", ",", "error", ")", "{", "if", "cfg", ".", "Trust", "==", "nil", "{", "cfg", ".", "Trust", "=", "local", ".", "NewCAService", "(...
// NewAuthServer creates and configures a new AuthServer instance
[ "NewAuthServer", "creates", "and", "configures", "a", "new", "AuthServer", "instance" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/auth.go#L62-L125
train
gravitational/teleport
lib/auth/auth.go
SetCache
func (a *AuthServer) SetCache(clt AuthCache) { a.lock.Lock() defer a.lock.Unlock() a.cache = clt }
go
func (a *AuthServer) SetCache(clt AuthCache) { a.lock.Lock() defer a.lock.Unlock() a.cache = clt }
[ "func", "(", "a", "*", "AuthServer", ")", "SetCache", "(", "clt", "AuthCache", ")", "{", "a", ".", "lock", ".", "Lock", "(", ")", "\n", "defer", "a", ".", "lock", ".", "Unlock", "(", ")", "\n", "a", ".", "cache", "=", "clt", "\n", "}" ]
// SetCache sets cache used by auth server
[ "SetCache", "sets", "cache", "used", "by", "auth", "server" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/auth.go#L212-L216
train
gravitational/teleport
lib/auth/auth.go
GetCache
func (a *AuthServer) GetCache() AuthCache { a.lock.RLock() defer a.lock.RUnlock() if a.cache == nil { return &a.AuthServices } return a.cache }
go
func (a *AuthServer) GetCache() AuthCache { a.lock.RLock() defer a.lock.RUnlock() if a.cache == nil { return &a.AuthServices } return a.cache }
[ "func", "(", "a", "*", "AuthServer", ")", "GetCache", "(", ")", "AuthCache", "{", "a", ".", "lock", ".", "RLock", "(", ")", "\n", "defer", "a", ".", "lock", ".", "RUnlock", "(", ")", "\n", "if", "a", ".", "cache", "==", "nil", "{", "return", "&...
// GetCache returns cache used by auth server
[ "GetCache", "returns", "cache", "used", "by", "auth", "server" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/auth.go#L219-L226
train
gravitational/teleport
lib/auth/auth.go
runPeriodicOperations
func (a *AuthServer) runPeriodicOperations() { // run periodic functions with a semi-random period // to avoid contention on the database in case if there are multiple // auth servers running - so they don't compete trying // to update the same resources. r := rand.New(rand.NewSource(a.GetClock().Now().UnixNano())...
go
func (a *AuthServer) runPeriodicOperations() { // run periodic functions with a semi-random period // to avoid contention on the database in case if there are multiple // auth servers running - so they don't compete trying // to update the same resources. r := rand.New(rand.NewSource(a.GetClock().Now().UnixNano())...
[ "func", "(", "a", "*", "AuthServer", ")", "runPeriodicOperations", "(", ")", "{", "// run periodic functions with a semi-random period", "// to avoid contention on the database in case if there are multiple", "// auth servers running - so they don't compete trying", "// to update the same ...
// runPeriodicOperations runs some periodic bookkeeping operations // performed by auth server
[ "runPeriodicOperations", "runs", "some", "periodic", "bookkeeping", "operations", "performed", "by", "auth", "server" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/auth.go#L230-L255
train
gravitational/teleport
lib/auth/auth.go
SetClock
func (a *AuthServer) SetClock(clock clockwork.Clock) { a.lock.Lock() defer a.lock.Unlock() a.clock = clock }
go
func (a *AuthServer) SetClock(clock clockwork.Clock) { a.lock.Lock() defer a.lock.Unlock() a.clock = clock }
[ "func", "(", "a", "*", "AuthServer", ")", "SetClock", "(", "clock", "clockwork", ".", "Clock", ")", "{", "a", ".", "lock", ".", "Lock", "(", ")", "\n", "defer", "a", ".", "lock", ".", "Unlock", "(", ")", "\n", "a", ".", "clock", "=", "clock", "...
// SetClock sets clock, used in tests
[ "SetClock", "sets", "clock", "used", "in", "tests" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/auth.go#L272-L276
train
gravitational/teleport
lib/auth/auth.go
GetClusterConfig
func (a *AuthServer) GetClusterConfig(opts ...services.MarshalOption) (services.ClusterConfig, error) { return a.GetCache().GetClusterConfig(opts...) }
go
func (a *AuthServer) GetClusterConfig(opts ...services.MarshalOption) (services.ClusterConfig, error) { return a.GetCache().GetClusterConfig(opts...) }
[ "func", "(", "a", "*", "AuthServer", ")", "GetClusterConfig", "(", "opts", "...", "services", ".", "MarshalOption", ")", "(", "services", ".", "ClusterConfig", ",", "error", ")", "{", "return", "a", ".", "GetCache", "(", ")", ".", "GetClusterConfig", "(", ...
// GetClusterConfig gets ClusterConfig from the backend.
[ "GetClusterConfig", "gets", "ClusterConfig", "from", "the", "backend", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/auth.go#L284-L286
train
gravitational/teleport
lib/auth/auth.go
GetClusterName
func (a *AuthServer) GetClusterName(opts ...services.MarshalOption) (services.ClusterName, error) { return a.GetCache().GetClusterName(opts...) }
go
func (a *AuthServer) GetClusterName(opts ...services.MarshalOption) (services.ClusterName, error) { return a.GetCache().GetClusterName(opts...) }
[ "func", "(", "a", "*", "AuthServer", ")", "GetClusterName", "(", "opts", "...", "services", ".", "MarshalOption", ")", "(", "services", ".", "ClusterName", ",", "error", ")", "{", "return", "a", ".", "GetCache", "(", ")", ".", "GetClusterName", "(", "opt...
// GetClusterName returns the domain name that identifies this authority server. // Also known as "cluster name"
[ "GetClusterName", "returns", "the", "domain", "name", "that", "identifies", "this", "authority", "server", ".", "Also", "known", "as", "cluster", "name" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/auth.go#L290-L292
train
gravitational/teleport
lib/auth/auth.go
GetDomainName
func (a *AuthServer) GetDomainName() (string, error) { clusterName, err := a.GetClusterName() if err != nil { return "", trace.Wrap(err) } return clusterName.GetClusterName(), nil }
go
func (a *AuthServer) GetDomainName() (string, error) { clusterName, err := a.GetClusterName() if err != nil { return "", trace.Wrap(err) } return clusterName.GetClusterName(), nil }
[ "func", "(", "a", "*", "AuthServer", ")", "GetDomainName", "(", ")", "(", "string", ",", "error", ")", "{", "clusterName", ",", "err", ":=", "a", ".", "GetClusterName", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "trac...
// GetDomainName returns the domain name that identifies this authority server. // Also known as "cluster name"
[ "GetDomainName", "returns", "the", "domain", "name", "that", "identifies", "this", "authority", "server", ".", "Also", "known", "as", "cluster", "name" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/auth.go#L296-L302
train
gravitational/teleport
lib/auth/auth.go
GenerateUserCerts
func (a *AuthServer) GenerateUserCerts(key []byte, username string, ttl time.Duration, compatibility string) ([]byte, []byte, error) { user, err := a.Identity.GetUser(username) if err != nil { return nil, nil, trace.Wrap(err) } checker, err := services.FetchRoles(user.GetRoles(), a.Access, user.GetTraits()) if e...
go
func (a *AuthServer) GenerateUserCerts(key []byte, username string, ttl time.Duration, compatibility string) ([]byte, []byte, error) { user, err := a.Identity.GetUser(username) if err != nil { return nil, nil, trace.Wrap(err) } checker, err := services.FetchRoles(user.GetRoles(), a.Access, user.GetTraits()) if e...
[ "func", "(", "a", "*", "AuthServer", ")", "GenerateUserCerts", "(", "key", "[", "]", "byte", ",", "username", "string", ",", "ttl", "time", ".", "Duration", ",", "compatibility", "string", ")", "(", "[", "]", "byte", ",", "[", "]", "byte", ",", "erro...
// GenerateUserCerts is used to generate user certificate, used internally for tests
[ "GenerateUserCerts", "is", "used", "to", "generate", "user", "certificate", "used", "internally", "for", "tests" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/auth.go#L407-L427
train