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/auth/helpers.go | CertPool | func (t *TestTLSServer) CertPool() (*x509.CertPool, error) {
tlsConfig, err := t.Identity.TLSConfig(t.AuthServer.CipherSuites)
if err != nil {
return nil, trace.Wrap(err)
}
return tlsConfig.RootCAs, nil
} | go | func (t *TestTLSServer) CertPool() (*x509.CertPool, error) {
tlsConfig, err := t.Identity.TLSConfig(t.AuthServer.CipherSuites)
if err != nil {
return nil, trace.Wrap(err)
}
return tlsConfig.RootCAs, nil
} | [
"func",
"(",
"t",
"*",
"TestTLSServer",
")",
"CertPool",
"(",
")",
"(",
"*",
"x509",
".",
"CertPool",
",",
"error",
")",
"{",
"tlsConfig",
",",
"err",
":=",
"t",
".",
"Identity",
".",
"TLSConfig",
"(",
"t",
".",
"AuthServer",
".",
"CipherSuites",
")"... | // CertPool returns cert pool that auth server represents | [
"CertPool",
"returns",
"cert",
"pool",
"that",
"auth",
"server",
"represents"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/helpers.go#L528-L534 | train |
gravitational/teleport | lib/auth/helpers.go | ClientTLSConfig | func (t *TestTLSServer) ClientTLSConfig(identity TestIdentity) (*tls.Config, error) {
tlsConfig, err := t.Identity.TLSConfig(t.AuthServer.CipherSuites)
if err != nil {
return nil, trace.Wrap(err)
}
if identity.I != nil {
cert, err := t.AuthServer.NewCertificate(identity)
if err != nil {
return nil, trace.W... | go | func (t *TestTLSServer) ClientTLSConfig(identity TestIdentity) (*tls.Config, error) {
tlsConfig, err := t.Identity.TLSConfig(t.AuthServer.CipherSuites)
if err != nil {
return nil, trace.Wrap(err)
}
if identity.I != nil {
cert, err := t.AuthServer.NewCertificate(identity)
if err != nil {
return nil, trace.W... | [
"func",
"(",
"t",
"*",
"TestTLSServer",
")",
"ClientTLSConfig",
"(",
"identity",
"TestIdentity",
")",
"(",
"*",
"tls",
".",
"Config",
",",
"error",
")",
"{",
"tlsConfig",
",",
"err",
":=",
"t",
".",
"Identity",
".",
"TLSConfig",
"(",
"t",
".",
"AuthSer... | // ClientTLSConfig returns client TLS config based on the identity | [
"ClientTLSConfig",
"returns",
"client",
"TLS",
"config",
"based",
"on",
"the",
"identity"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/helpers.go#L537-L554 | train |
gravitational/teleport | lib/auth/helpers.go | CloneClient | func (t *TestTLSServer) CloneClient(clt *Client) *Client {
addr := []utils.NetAddr{{Addr: t.Addr().String(), AddrNetwork: t.Addr().Network()}}
newClient, err := NewTLSClient(ClientConfig{Addrs: addr, TLS: clt.TLSConfig()})
if err != nil {
panic(err)
}
return newClient
} | go | func (t *TestTLSServer) CloneClient(clt *Client) *Client {
addr := []utils.NetAddr{{Addr: t.Addr().String(), AddrNetwork: t.Addr().Network()}}
newClient, err := NewTLSClient(ClientConfig{Addrs: addr, TLS: clt.TLSConfig()})
if err != nil {
panic(err)
}
return newClient
} | [
"func",
"(",
"t",
"*",
"TestTLSServer",
")",
"CloneClient",
"(",
"clt",
"*",
"Client",
")",
"*",
"Client",
"{",
"addr",
":=",
"[",
"]",
"utils",
".",
"NetAddr",
"{",
"{",
"Addr",
":",
"t",
".",
"Addr",
"(",
")",
".",
"String",
"(",
")",
",",
"A... | // CloneClient uses the same credentials as the passed client
// but forces the client to be recreated | [
"CloneClient",
"uses",
"the",
"same",
"credentials",
"as",
"the",
"passed",
"client",
"but",
"forces",
"the",
"client",
"to",
"be",
"recreated"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/helpers.go#L558-L565 | train |
gravitational/teleport | lib/auth/helpers.go | NewClient | func (t *TestTLSServer) NewClient(identity TestIdentity) (*Client, error) {
tlsConfig, err := t.ClientTLSConfig(identity)
if err != nil {
return nil, trace.Wrap(err)
}
addrs := []utils.NetAddr{utils.FromAddr(t.Listener.Addr())}
return NewTLSClient(ClientConfig{Addrs: addrs, TLS: tlsConfig})
} | go | func (t *TestTLSServer) NewClient(identity TestIdentity) (*Client, error) {
tlsConfig, err := t.ClientTLSConfig(identity)
if err != nil {
return nil, trace.Wrap(err)
}
addrs := []utils.NetAddr{utils.FromAddr(t.Listener.Addr())}
return NewTLSClient(ClientConfig{Addrs: addrs, TLS: tlsConfig})
} | [
"func",
"(",
"t",
"*",
"TestTLSServer",
")",
"NewClient",
"(",
"identity",
"TestIdentity",
")",
"(",
"*",
"Client",
",",
"error",
")",
"{",
"tlsConfig",
",",
"err",
":=",
"t",
".",
"ClientTLSConfig",
"(",
"identity",
")",
"\n",
"if",
"err",
"!=",
"nil"... | // NewClient returns new client to test server authenticated with identity | [
"NewClient",
"returns",
"new",
"client",
"to",
"test",
"server",
"authenticated",
"with",
"identity"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/helpers.go#L568-L575 | train |
gravitational/teleport | lib/auth/helpers.go | Start | func (t *TestTLSServer) Start() error {
var err error
if t.Listener == nil {
t.Listener, err = net.Listen("tcp", "127.0.0.1:0")
if err != nil {
return trace.Wrap(err)
}
}
go t.TLSServer.Serve(t.Listener)
return nil
} | go | func (t *TestTLSServer) Start() error {
var err error
if t.Listener == nil {
t.Listener, err = net.Listen("tcp", "127.0.0.1:0")
if err != nil {
return trace.Wrap(err)
}
}
go t.TLSServer.Serve(t.Listener)
return nil
} | [
"func",
"(",
"t",
"*",
"TestTLSServer",
")",
"Start",
"(",
")",
"error",
"{",
"var",
"err",
"error",
"\n",
"if",
"t",
".",
"Listener",
"==",
"nil",
"{",
"t",
".",
"Listener",
",",
"err",
"=",
"net",
".",
"Listen",
"(",
"\"",
"\"",
",",
"\"",
"\... | // Start starts TLS server on loopback address on the first lisenting socket | [
"Start",
"starts",
"TLS",
"server",
"on",
"loopback",
"address",
"on",
"the",
"first",
"lisenting",
"socket"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/helpers.go#L583-L593 | train |
gravitational/teleport | lib/auth/helpers.go | Close | func (t *TestTLSServer) Close() error {
err := t.TLSServer.Close()
if t.Listener != nil {
t.Listener.Close()
}
if t.AuthServer.Backend != nil {
t.AuthServer.Backend.Close()
}
return err
} | go | func (t *TestTLSServer) Close() error {
err := t.TLSServer.Close()
if t.Listener != nil {
t.Listener.Close()
}
if t.AuthServer.Backend != nil {
t.AuthServer.Backend.Close()
}
return err
} | [
"func",
"(",
"t",
"*",
"TestTLSServer",
")",
"Close",
"(",
")",
"error",
"{",
"err",
":=",
"t",
".",
"TLSServer",
".",
"Close",
"(",
")",
"\n",
"if",
"t",
".",
"Listener",
"!=",
"nil",
"{",
"t",
".",
"Listener",
".",
"Close",
"(",
")",
"\n",
"}... | // Close closes the listener and HTTP server | [
"Close",
"closes",
"the",
"listener",
"and",
"HTTP",
"server"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/helpers.go#L596-L605 | train |
gravitational/teleport | lib/auth/helpers.go | Stop | func (t *TestTLSServer) Stop() error {
err := t.TLSServer.Close()
if t.Listener != nil {
t.Listener.Close()
}
return err
} | go | func (t *TestTLSServer) Stop() error {
err := t.TLSServer.Close()
if t.Listener != nil {
t.Listener.Close()
}
return err
} | [
"func",
"(",
"t",
"*",
"TestTLSServer",
")",
"Stop",
"(",
")",
"error",
"{",
"err",
":=",
"t",
".",
"TLSServer",
".",
"Close",
"(",
")",
"\n",
"if",
"t",
".",
"Listener",
"!=",
"nil",
"{",
"t",
".",
"Listener",
".",
"Close",
"(",
")",
"\n",
"}"... | // Stop stops listening server, but does not close the auth backend | [
"Stop",
"stops",
"listening",
"server",
"but",
"does",
"not",
"close",
"the",
"auth",
"backend"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/helpers.go#L608-L614 | train |
gravitational/teleport | lib/auth/helpers.go | NewServerIdentity | func NewServerIdentity(clt *AuthServer, hostID string, role teleport.Role) (*Identity, error) {
keys, err := clt.GenerateServerKeys(GenerateServerKeysRequest{
HostID: hostID,
NodeName: hostID,
Roles: teleport.Roles{teleport.RoleAuth},
})
if err != nil {
return nil, trace.Wrap(err)
}
return ReadIdentit... | go | func NewServerIdentity(clt *AuthServer, hostID string, role teleport.Role) (*Identity, error) {
keys, err := clt.GenerateServerKeys(GenerateServerKeysRequest{
HostID: hostID,
NodeName: hostID,
Roles: teleport.Roles{teleport.RoleAuth},
})
if err != nil {
return nil, trace.Wrap(err)
}
return ReadIdentit... | [
"func",
"NewServerIdentity",
"(",
"clt",
"*",
"AuthServer",
",",
"hostID",
"string",
",",
"role",
"teleport",
".",
"Role",
")",
"(",
"*",
"Identity",
",",
"error",
")",
"{",
"keys",
",",
"err",
":=",
"clt",
".",
"GenerateServerKeys",
"(",
"GenerateServerKe... | // NewServerIdentity generates new server identity, used in tests | [
"NewServerIdentity",
"generates",
"new",
"server",
"identity",
"used",
"in",
"tests"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/helpers.go#L617-L627 | train |
gravitational/teleport | lib/auth/helpers.go | CreateUserAndRole | func CreateUserAndRole(clt clt, username string, allowedLogins []string) (services.User, services.Role, error) {
user, err := services.NewUser(username)
if err != nil {
return nil, nil, trace.Wrap(err)
}
role := services.RoleForUser(user)
role.SetLogins(services.Allow, []string{user.GetName()})
err = clt.Upsert... | go | func CreateUserAndRole(clt clt, username string, allowedLogins []string) (services.User, services.Role, error) {
user, err := services.NewUser(username)
if err != nil {
return nil, nil, trace.Wrap(err)
}
role := services.RoleForUser(user)
role.SetLogins(services.Allow, []string{user.GetName()})
err = clt.Upsert... | [
"func",
"CreateUserAndRole",
"(",
"clt",
"clt",
",",
"username",
"string",
",",
"allowedLogins",
"[",
"]",
"string",
")",
"(",
"services",
".",
"User",
",",
"services",
".",
"Role",
",",
"error",
")",
"{",
"user",
",",
"err",
":=",
"services",
".",
"Ne... | // CreateUserAndRole creates user and role and assignes role to a user, used in tests | [
"CreateUserAndRole",
"creates",
"user",
"and",
"role",
"and",
"assignes",
"role",
"to",
"a",
"user",
"used",
"in",
"tests"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/helpers.go#L637-L654 | train |
gravitational/teleport | lib/auth/helpers.go | CreateUserAndRoleWithoutRoles | func CreateUserAndRoleWithoutRoles(clt clt, username string, allowedLogins []string) (services.User, services.Role, error) {
user, err := services.NewUser(username)
if err != nil {
return nil, nil, trace.Wrap(err)
}
role := services.RoleForUser(user)
set := services.MakeRuleSet(role.GetRules(services.Allow))
d... | go | func CreateUserAndRoleWithoutRoles(clt clt, username string, allowedLogins []string) (services.User, services.Role, error) {
user, err := services.NewUser(username)
if err != nil {
return nil, nil, trace.Wrap(err)
}
role := services.RoleForUser(user)
set := services.MakeRuleSet(role.GetRules(services.Allow))
d... | [
"func",
"CreateUserAndRoleWithoutRoles",
"(",
"clt",
"clt",
",",
"username",
"string",
",",
"allowedLogins",
"[",
"]",
"string",
")",
"(",
"services",
".",
"User",
",",
"services",
".",
"Role",
",",
"error",
")",
"{",
"user",
",",
"err",
":=",
"services",
... | // CreateUserAndRoleWithoutRoles creates user and role, but does not assign user to a role, used in tests | [
"CreateUserAndRoleWithoutRoles",
"creates",
"user",
"and",
"role",
"but",
"does",
"not",
"assign",
"user",
"to",
"a",
"role",
"used",
"in",
"tests"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/helpers.go#L657-L680 | train |
gravitational/teleport | lib/events/uploader.go | CheckAndSetDefaults | func (cfg *UploaderConfig) CheckAndSetDefaults() error {
if cfg.ServerID == "" {
return trace.BadParameter("missing parameter ServerID")
}
if cfg.AuditLog == nil {
return trace.BadParameter("missing parameter AuditLog")
}
if cfg.DataDir == "" {
return trace.BadParameter("missing parameter DataDir")
}
if cf... | go | func (cfg *UploaderConfig) CheckAndSetDefaults() error {
if cfg.ServerID == "" {
return trace.BadParameter("missing parameter ServerID")
}
if cfg.AuditLog == nil {
return trace.BadParameter("missing parameter AuditLog")
}
if cfg.DataDir == "" {
return trace.BadParameter("missing parameter DataDir")
}
if cf... | [
"func",
"(",
"cfg",
"*",
"UploaderConfig",
")",
"CheckAndSetDefaults",
"(",
")",
"error",
"{",
"if",
"cfg",
".",
"ServerID",
"==",
"\"",
"\"",
"{",
"return",
"trace",
".",
"BadParameter",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"if",
"cfg",
".",
"Audi... | // CheckAndSetDefaults checks and sets default values of UploaderConfig | [
"CheckAndSetDefaults",
"checks",
"and",
"sets",
"default",
"values",
"of",
"UploaderConfig"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/events/uploader.go#L80-L106 | train |
gravitational/teleport | lib/events/uploader.go | NewUploader | func NewUploader(cfg UploaderConfig) (*Uploader, error) {
if err := cfg.CheckAndSetDefaults(); err != nil {
return nil, trace.Wrap(err)
}
ctx, cancel := context.WithCancel(cfg.Context)
uploader := &Uploader{
UploaderConfig: cfg,
Entry: log.WithFields(log.Fields{
trace.Component: teleport.ComponentAuditLog... | go | func NewUploader(cfg UploaderConfig) (*Uploader, error) {
if err := cfg.CheckAndSetDefaults(); err != nil {
return nil, trace.Wrap(err)
}
ctx, cancel := context.WithCancel(cfg.Context)
uploader := &Uploader{
UploaderConfig: cfg,
Entry: log.WithFields(log.Fields{
trace.Component: teleport.ComponentAuditLog... | [
"func",
"NewUploader",
"(",
"cfg",
"UploaderConfig",
")",
"(",
"*",
"Uploader",
",",
"error",
")",
"{",
"if",
"err",
":=",
"cfg",
".",
"CheckAndSetDefaults",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"trace",
".",
"Wrap",
"(",
"er... | // NewUploader creates new disk based session logger | [
"NewUploader",
"creates",
"new",
"disk",
"based",
"session",
"logger"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/events/uploader.go#L109-L126 | train |
gravitational/teleport | lib/events/uploader.go | Scan | func (u *Uploader) Scan() error {
df, err := os.Open(u.scanDir)
err = trace.ConvertSystemError(err)
if err != nil {
return trace.Wrap(err)
}
defer df.Close()
entries, err := df.Readdir(-1)
if err != nil {
return trace.ConvertSystemError(err)
}
var count int
for i := range entries {
fi := entries[i]
if... | go | func (u *Uploader) Scan() error {
df, err := os.Open(u.scanDir)
err = trace.ConvertSystemError(err)
if err != nil {
return trace.Wrap(err)
}
defer df.Close()
entries, err := df.Readdir(-1)
if err != nil {
return trace.ConvertSystemError(err)
}
var count int
for i := range entries {
fi := entries[i]
if... | [
"func",
"(",
"u",
"*",
"Uploader",
")",
"Scan",
"(",
")",
"error",
"{",
"df",
",",
"err",
":=",
"os",
".",
"Open",
"(",
"u",
".",
"scanDir",
")",
"\n",
"err",
"=",
"trace",
".",
"ConvertSystemError",
"(",
"err",
")",
"\n",
"if",
"err",
"!=",
"n... | // Scan scans the directory and uploads recordings | [
"Scan",
"scans",
"the",
"directory",
"and",
"uploads",
"recordings"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/events/uploader.go#L272-L309 | train |
gravitational/teleport | lib/client/api.go | MakeDefaultConfig | func MakeDefaultConfig() *Config {
return &Config{
Stdout: os.Stdout,
Stderr: os.Stderr,
Stdin: os.Stdin,
}
} | go | func MakeDefaultConfig() *Config {
return &Config{
Stdout: os.Stdout,
Stderr: os.Stderr,
Stdin: os.Stdin,
}
} | [
"func",
"MakeDefaultConfig",
"(",
")",
"*",
"Config",
"{",
"return",
"&",
"Config",
"{",
"Stdout",
":",
"os",
".",
"Stdout",
",",
"Stderr",
":",
"os",
".",
"Stderr",
",",
"Stdin",
":",
"os",
".",
"Stdin",
",",
"}",
"\n",
"}"
] | // MakeDefaultConfig returns default client config | [
"MakeDefaultConfig",
"returns",
"default",
"client",
"config"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/api.go#L255-L261 | train |
gravitational/teleport | lib/client/api.go | IsExpired | func (p *ProfileStatus) IsExpired(clock clockwork.Clock) bool {
return p.ValidUntil.Sub(clock.Now()) <= 0
} | go | func (p *ProfileStatus) IsExpired(clock clockwork.Clock) bool {
return p.ValidUntil.Sub(clock.Now()) <= 0
} | [
"func",
"(",
"p",
"*",
"ProfileStatus",
")",
"IsExpired",
"(",
"clock",
"clockwork",
".",
"Clock",
")",
"bool",
"{",
"return",
"p",
".",
"ValidUntil",
".",
"Sub",
"(",
"clock",
".",
"Now",
"(",
")",
")",
"<=",
"0",
"\n",
"}"
] | // IsExpired returns true if profile is not expired yet | [
"IsExpired",
"returns",
"true",
"if",
"profile",
"is",
"not",
"expired",
"yet"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/api.go#L289-L291 | train |
gravitational/teleport | lib/client/api.go | RetryWithRelogin | func RetryWithRelogin(ctx context.Context, tc *TeleportClient, fn func() error) error {
err := fn()
if err == nil {
return nil
}
// Assume that failed handshake is a result of expired credentials,
// retry the login procedure
if !utils.IsHandshakeFailedError(err) && !utils.IsCertExpiredError(err) && !trace.IsBa... | go | func RetryWithRelogin(ctx context.Context, tc *TeleportClient, fn func() error) error {
err := fn()
if err == nil {
return nil
}
// Assume that failed handshake is a result of expired credentials,
// retry the login procedure
if !utils.IsHandshakeFailedError(err) && !utils.IsCertExpiredError(err) && !trace.IsBa... | [
"func",
"RetryWithRelogin",
"(",
"ctx",
"context",
".",
"Context",
",",
"tc",
"*",
"TeleportClient",
",",
"fn",
"func",
"(",
")",
"error",
")",
"error",
"{",
"err",
":=",
"fn",
"(",
")",
"\n",
"if",
"err",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"... | // RetryWithRelogin is a helper error handling method,
// attempts to relogin and retry the function once | [
"RetryWithRelogin",
"is",
"a",
"helper",
"error",
"handling",
"method",
"attempts",
"to",
"relogin",
"and",
"retry",
"the",
"function",
"once"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/api.go#L295-L327 | train |
gravitational/teleport | lib/client/api.go | fullProfileName | func fullProfileName(profileDir string, proxyHost string) (string, error) {
var err error
var profileName string
// If no profile name was passed in, try and extract the active profile from
// the ~/.tsh/profile symlink. If one was passed in, append .yaml to name.
if proxyHost == "" {
profileName, err = os.Read... | go | func fullProfileName(profileDir string, proxyHost string) (string, error) {
var err error
var profileName string
// If no profile name was passed in, try and extract the active profile from
// the ~/.tsh/profile symlink. If one was passed in, append .yaml to name.
if proxyHost == "" {
profileName, err = os.Read... | [
"func",
"fullProfileName",
"(",
"profileDir",
"string",
",",
"proxyHost",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"var",
"err",
"error",
"\n",
"var",
"profileName",
"string",
"\n\n",
"// If no profile name was passed in, try and extract the active profile ... | // fullProfileName takes a profile directory and the host the user is trying
// to connect to and returns the name of the profile file. | [
"fullProfileName",
"takes",
"a",
"profile",
"directory",
"and",
"the",
"host",
"the",
"user",
"is",
"trying",
"to",
"connect",
"to",
"and",
"returns",
"the",
"name",
"of",
"the",
"profile",
"file",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/api.go#L401-L423 | train |
gravitational/teleport | lib/client/api.go | Status | func Status(profileDir string, proxyHost string) (*ProfileStatus, []*ProfileStatus, error) {
var err error
var profile *ProfileStatus
var others []*ProfileStatus
// remove ports from proxy host, because profile name is stored
// by host name
if proxyHost != "" {
proxyHost, err = utils.Host(proxyHost)
if err ... | go | func Status(profileDir string, proxyHost string) (*ProfileStatus, []*ProfileStatus, error) {
var err error
var profile *ProfileStatus
var others []*ProfileStatus
// remove ports from proxy host, because profile name is stored
// by host name
if proxyHost != "" {
proxyHost, err = utils.Host(proxyHost)
if err ... | [
"func",
"Status",
"(",
"profileDir",
"string",
",",
"proxyHost",
"string",
")",
"(",
"*",
"ProfileStatus",
",",
"[",
"]",
"*",
"ProfileStatus",
",",
"error",
")",
"{",
"var",
"err",
"error",
"\n",
"var",
"profile",
"*",
"ProfileStatus",
"\n",
"var",
"oth... | // Status returns the active profile as well as a list of available profiles. | [
"Status",
"returns",
"the",
"active",
"profile",
"as",
"well",
"as",
"a",
"list",
"of",
"available",
"profiles",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/api.go#L426-L506 | train |
gravitational/teleport | lib/client/api.go | KubeProxyHostPort | func (c *Config) KubeProxyHostPort() (string, int) {
if c.KubeProxyAddr != "" {
addr, err := utils.ParseAddr(c.KubeProxyAddr)
if err == nil {
return addr.Host(), addr.Port(defaults.KubeProxyListenPort)
}
}
webProxyHost, _ := c.WebProxyHostPort()
return webProxyHost, defaults.KubeProxyListenPort
} | go | func (c *Config) KubeProxyHostPort() (string, int) {
if c.KubeProxyAddr != "" {
addr, err := utils.ParseAddr(c.KubeProxyAddr)
if err == nil {
return addr.Host(), addr.Port(defaults.KubeProxyListenPort)
}
}
webProxyHost, _ := c.WebProxyHostPort()
return webProxyHost, defaults.KubeProxyListenPort
} | [
"func",
"(",
"c",
"*",
"Config",
")",
"KubeProxyHostPort",
"(",
")",
"(",
"string",
",",
"int",
")",
"{",
"if",
"c",
".",
"KubeProxyAddr",
"!=",
"\"",
"\"",
"{",
"addr",
",",
"err",
":=",
"utils",
".",
"ParseAddr",
"(",
"c",
".",
"KubeProxyAddr",
"... | // KubeProxyHostPort returns the host and port of the Kubernetes proxy. | [
"KubeProxyHostPort",
"returns",
"the",
"host",
"and",
"port",
"of",
"the",
"Kubernetes",
"proxy",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/api.go#L656-L666 | train |
gravitational/teleport | lib/client/api.go | WebProxyHostPort | func (c *Config) WebProxyHostPort() (string, int) {
if c.WebProxyAddr != "" {
addr, err := utils.ParseAddr(c.WebProxyAddr)
if err == nil {
return addr.Host(), addr.Port(defaults.HTTPListenPort)
}
}
webProxyHost, _ := c.WebProxyHostPort()
return webProxyHost, defaults.HTTPListenPort
} | go | func (c *Config) WebProxyHostPort() (string, int) {
if c.WebProxyAddr != "" {
addr, err := utils.ParseAddr(c.WebProxyAddr)
if err == nil {
return addr.Host(), addr.Port(defaults.HTTPListenPort)
}
}
webProxyHost, _ := c.WebProxyHostPort()
return webProxyHost, defaults.HTTPListenPort
} | [
"func",
"(",
"c",
"*",
"Config",
")",
"WebProxyHostPort",
"(",
")",
"(",
"string",
",",
"int",
")",
"{",
"if",
"c",
".",
"WebProxyAddr",
"!=",
"\"",
"\"",
"{",
"addr",
",",
"err",
":=",
"utils",
".",
"ParseAddr",
"(",
"c",
".",
"WebProxyAddr",
")",... | // WebProxyHostPort returns the host and port of the web proxy. | [
"WebProxyHostPort",
"returns",
"the",
"host",
"and",
"port",
"of",
"the",
"web",
"proxy",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/api.go#L669-L679 | train |
gravitational/teleport | lib/client/api.go | SSHProxyHostPort | func (c *Config) SSHProxyHostPort() (string, int) {
if c.SSHProxyAddr != "" {
addr, err := utils.ParseAddr(c.SSHProxyAddr)
if err == nil {
return addr.Host(), addr.Port(defaults.SSHProxyListenPort)
}
}
webProxyHost, _ := c.WebProxyHostPort()
return webProxyHost, defaults.SSHProxyListenPort
} | go | func (c *Config) SSHProxyHostPort() (string, int) {
if c.SSHProxyAddr != "" {
addr, err := utils.ParseAddr(c.SSHProxyAddr)
if err == nil {
return addr.Host(), addr.Port(defaults.SSHProxyListenPort)
}
}
webProxyHost, _ := c.WebProxyHostPort()
return webProxyHost, defaults.SSHProxyListenPort
} | [
"func",
"(",
"c",
"*",
"Config",
")",
"SSHProxyHostPort",
"(",
")",
"(",
"string",
",",
"int",
")",
"{",
"if",
"c",
".",
"SSHProxyAddr",
"!=",
"\"",
"\"",
"{",
"addr",
",",
"err",
":=",
"utils",
".",
"ParseAddr",
"(",
"c",
".",
"SSHProxyAddr",
")",... | // SSHProxyHostPort returns the host and port of the SSH proxy. | [
"SSHProxyHostPort",
"returns",
"the",
"host",
"and",
"port",
"of",
"the",
"SSH",
"proxy",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/api.go#L682-L692 | train |
gravitational/teleport | lib/client/api.go | NewClient | func NewClient(c *Config) (tc *TeleportClient, err error) {
// validate configuration
if c.Username == "" {
c.Username, err = Username()
if err != nil {
return nil, trace.Wrap(err)
}
log.Infof("No teleport login given. defaulting to %s", c.Username)
}
if c.WebProxyAddr == "" {
return nil, trace.BadPara... | go | func NewClient(c *Config) (tc *TeleportClient, err error) {
// validate configuration
if c.Username == "" {
c.Username, err = Username()
if err != nil {
return nil, trace.Wrap(err)
}
log.Infof("No teleport login given. defaulting to %s", c.Username)
}
if c.WebProxyAddr == "" {
return nil, trace.BadPara... | [
"func",
"NewClient",
"(",
"c",
"*",
"Config",
")",
"(",
"tc",
"*",
"TeleportClient",
",",
"err",
"error",
")",
"{",
"// validate configuration",
"if",
"c",
".",
"Username",
"==",
"\"",
"\"",
"{",
"c",
".",
"Username",
",",
"err",
"=",
"Username",
"(",
... | // NewClient creates a TeleportClient object and fully configures it | [
"NewClient",
"creates",
"a",
"TeleportClient",
"object",
"and",
"fully",
"configures",
"it"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/api.go#L735-L810 | train |
gravitational/teleport | lib/client/api.go | accessPoint | func (tc *TeleportClient) accessPoint(clt auth.AccessPoint, proxyHostPort string, clusterName string) (auth.AccessPoint, error) {
// If no caching policy was set or on Windows (where Teleport does not
// support file locking at the moment), return direct access to the access
// point.
if tc.CachePolicy == nil || ru... | go | func (tc *TeleportClient) accessPoint(clt auth.AccessPoint, proxyHostPort string, clusterName string) (auth.AccessPoint, error) {
// If no caching policy was set or on Windows (where Teleport does not
// support file locking at the moment), return direct access to the access
// point.
if tc.CachePolicy == nil || ru... | [
"func",
"(",
"tc",
"*",
"TeleportClient",
")",
"accessPoint",
"(",
"clt",
"auth",
".",
"AccessPoint",
",",
"proxyHostPort",
"string",
",",
"clusterName",
"string",
")",
"(",
"auth",
".",
"AccessPoint",
",",
"error",
")",
"{",
"// If no caching policy was set or ... | // accessPoint returns access point based on the cache policy | [
"accessPoint",
"returns",
"access",
"point",
"based",
"on",
"the",
"cache",
"policy"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/api.go#L813-L822 | train |
gravitational/teleport | lib/client/api.go | getTargetNodes | func (tc *TeleportClient) getTargetNodes(ctx context.Context, proxy *ProxyClient) ([]string, error) {
var (
err error
nodes []services.Server
retval = make([]string, 0)
)
if tc.Labels != nil && len(tc.Labels) > 0 {
nodes, err = proxy.FindServersByLabels(ctx, tc.Namespace, tc.Labels)
if err != nil {
... | go | func (tc *TeleportClient) getTargetNodes(ctx context.Context, proxy *ProxyClient) ([]string, error) {
var (
err error
nodes []services.Server
retval = make([]string, 0)
)
if tc.Labels != nil && len(tc.Labels) > 0 {
nodes, err = proxy.FindServersByLabels(ctx, tc.Namespace, tc.Labels)
if err != nil {
... | [
"func",
"(",
"tc",
"*",
"TeleportClient",
")",
"getTargetNodes",
"(",
"ctx",
"context",
".",
"Context",
",",
"proxy",
"*",
"ProxyClient",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"var",
"(",
"err",
"error",
"\n",
"nodes",
"[",
"]",
"serv... | // getTargetNodes returns a list of node addresses this SSH command needs to
// operate on. | [
"getTargetNodes",
"returns",
"a",
"list",
"of",
"node",
"addresses",
"this",
"SSH",
"command",
"needs",
"to",
"operate",
"on",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/api.go#L830-L849 | train |
gravitational/teleport | lib/client/api.go | Play | func (tc *TeleportClient) Play(ctx context.Context, namespace, sessionId string) (err error) {
if namespace == "" {
return trace.BadParameter(auth.MissingNamespaceError)
}
sid, err := session.ParseID(sessionId)
if err != nil {
return fmt.Errorf("'%v' is not a valid session ID (must be GUID)", sid)
}
// connec... | go | func (tc *TeleportClient) Play(ctx context.Context, namespace, sessionId string) (err error) {
if namespace == "" {
return trace.BadParameter(auth.MissingNamespaceError)
}
sid, err := session.ParseID(sessionId)
if err != nil {
return fmt.Errorf("'%v' is not a valid session ID (must be GUID)", sid)
}
// connec... | [
"func",
"(",
"tc",
"*",
"TeleportClient",
")",
"Play",
"(",
"ctx",
"context",
".",
"Context",
",",
"namespace",
",",
"sessionId",
"string",
")",
"(",
"err",
"error",
")",
"{",
"if",
"namespace",
"==",
"\"",
"\"",
"{",
"return",
"trace",
".",
"BadParame... | // Play replays the recorded session | [
"Play",
"replays",
"the",
"recorded",
"session"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/api.go#L1019-L1108 | train |
gravitational/teleport | lib/client/api.go | ExecuteSCP | func (tc *TeleportClient) ExecuteSCP(ctx context.Context, cmd scp.Command) (err error) {
// connect to proxy first:
if !tc.Config.ProxySpecified() {
return trace.BadParameter("proxy server is not specified")
}
proxyClient, err := tc.ConnectToProxy(ctx)
if err != nil {
return trace.Wrap(err)
}
defer proxyCli... | go | func (tc *TeleportClient) ExecuteSCP(ctx context.Context, cmd scp.Command) (err error) {
// connect to proxy first:
if !tc.Config.ProxySpecified() {
return trace.BadParameter("proxy server is not specified")
}
proxyClient, err := tc.ConnectToProxy(ctx)
if err != nil {
return trace.Wrap(err)
}
defer proxyCli... | [
"func",
"(",
"tc",
"*",
"TeleportClient",
")",
"ExecuteSCP",
"(",
"ctx",
"context",
".",
"Context",
",",
"cmd",
"scp",
".",
"Command",
")",
"(",
"err",
"error",
")",
"{",
"// connect to proxy first:",
"if",
"!",
"tc",
".",
"Config",
".",
"ProxySpecified",
... | // ExecuteSCP executes SCP command. It executes scp.Command using
// lower-level API integrations that mimic SCP CLI command behavior | [
"ExecuteSCP",
"executes",
"SCP",
"command",
".",
"It",
"executes",
"scp",
".",
"Command",
"using",
"lower",
"-",
"level",
"API",
"integrations",
"that",
"mimic",
"SCP",
"CLI",
"command",
"behavior"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/api.go#L1112-L1160 | train |
gravitational/teleport | lib/client/api.go | ListNodes | func (tc *TeleportClient) ListNodes(ctx context.Context) ([]services.Server, error) {
var err error
// userhost is specified? that must be labels
if tc.Host != "" {
tc.Labels, err = ParseLabelSpec(tc.Host)
if err != nil {
return nil, trace.Wrap(err)
}
}
// connect to the proxy and ask it to return a full... | go | func (tc *TeleportClient) ListNodes(ctx context.Context) ([]services.Server, error) {
var err error
// userhost is specified? that must be labels
if tc.Host != "" {
tc.Labels, err = ParseLabelSpec(tc.Host)
if err != nil {
return nil, trace.Wrap(err)
}
}
// connect to the proxy and ask it to return a full... | [
"func",
"(",
"tc",
"*",
"TeleportClient",
")",
"ListNodes",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"[",
"]",
"services",
".",
"Server",
",",
"error",
")",
"{",
"var",
"err",
"error",
"\n",
"// userhost is specified? that must be labels",
"if",
"tc"... | // ListNodes returns a list of nodes connected to a proxy | [
"ListNodes",
"returns",
"a",
"list",
"of",
"nodes",
"connected",
"to",
"a",
"proxy"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/api.go#L1295-L1313 | train |
gravitational/teleport | lib/client/api.go | runCommand | func (tc *TeleportClient) runCommand(
ctx context.Context, siteName string, nodeAddresses []string, proxyClient *ProxyClient, command []string) error {
resultsC := make(chan error, len(nodeAddresses))
for _, address := range nodeAddresses {
go func(address string) {
var (
err error
nodeSession ... | go | func (tc *TeleportClient) runCommand(
ctx context.Context, siteName string, nodeAddresses []string, proxyClient *ProxyClient, command []string) error {
resultsC := make(chan error, len(nodeAddresses))
for _, address := range nodeAddresses {
go func(address string) {
var (
err error
nodeSession ... | [
"func",
"(",
"tc",
"*",
"TeleportClient",
")",
"runCommand",
"(",
"ctx",
"context",
".",
"Context",
",",
"siteName",
"string",
",",
"nodeAddresses",
"[",
"]",
"string",
",",
"proxyClient",
"*",
"ProxyClient",
",",
"command",
"[",
"]",
"string",
")",
"error... | // runCommand executes a given bash command on a bunch of remote nodes | [
"runCommand",
"executes",
"a",
"given",
"bash",
"command",
"on",
"a",
"bunch",
"of",
"remote",
"nodes"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/api.go#L1316-L1370 | train |
gravitational/teleport | lib/client/api.go | getProxySSHPrincipal | func (tc *TeleportClient) getProxySSHPrincipal() string {
proxyPrincipal := tc.Config.HostLogin
if tc.DefaultPrincipal != "" {
proxyPrincipal = tc.DefaultPrincipal
}
// see if we already have a signed key in the cache, we'll use that instead
if !tc.Config.SkipLocalAuth && tc.LocalAgent() != nil {
signers, err ... | go | func (tc *TeleportClient) getProxySSHPrincipal() string {
proxyPrincipal := tc.Config.HostLogin
if tc.DefaultPrincipal != "" {
proxyPrincipal = tc.DefaultPrincipal
}
// see if we already have a signed key in the cache, we'll use that instead
if !tc.Config.SkipLocalAuth && tc.LocalAgent() != nil {
signers, err ... | [
"func",
"(",
"tc",
"*",
"TeleportClient",
")",
"getProxySSHPrincipal",
"(",
")",
"string",
"{",
"proxyPrincipal",
":=",
"tc",
".",
"Config",
".",
"HostLogin",
"\n",
"if",
"tc",
".",
"DefaultPrincipal",
"!=",
"\"",
"\"",
"{",
"proxyPrincipal",
"=",
"tc",
".... | // getProxyLogin determines which SSH principal to use when connecting to proxy. | [
"getProxyLogin",
"determines",
"which",
"SSH",
"principal",
"to",
"use",
"when",
"connecting",
"to",
"proxy",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/api.go#L1391-L1408 | train |
gravitational/teleport | lib/client/api.go | ConnectToProxy | func (tc *TeleportClient) ConnectToProxy(ctx context.Context) (*ProxyClient, error) {
var err error
var proxyClient *ProxyClient
// Use connectContext and the cancel function to signal when a response is
// returned from connectToProxy.
connectContext, cancel := context.WithCancel(context.Background())
go func()... | go | func (tc *TeleportClient) ConnectToProxy(ctx context.Context) (*ProxyClient, error) {
var err error
var proxyClient *ProxyClient
// Use connectContext and the cancel function to signal when a response is
// returned from connectToProxy.
connectContext, cancel := context.WithCancel(context.Background())
go func()... | [
"func",
"(",
"tc",
"*",
"TeleportClient",
")",
"ConnectToProxy",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"*",
"ProxyClient",
",",
"error",
")",
"{",
"var",
"err",
"error",
"\n",
"var",
"proxyClient",
"*",
"ProxyClient",
"\n\n",
"// Use connectContex... | // ConnectToProxy will dial to the proxy server and return a ProxyClient when
// successful. If the passed in context is canceled, this function will return
// a trace.ConnectionProblem right away. | [
"ConnectToProxy",
"will",
"dial",
"to",
"the",
"proxy",
"server",
"and",
"return",
"a",
"ProxyClient",
"when",
"successful",
".",
"If",
"the",
"passed",
"in",
"context",
"is",
"canceled",
"this",
"function",
"will",
"return",
"a",
"trace",
".",
"ConnectionProb... | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/api.go#L1423-L1444 | train |
gravitational/teleport | lib/client/api.go | connectToProxy | func (tc *TeleportClient) connectToProxy(ctx context.Context) (*ProxyClient, error) {
var err error
proxyPrincipal := tc.getProxySSHPrincipal()
sshConfig := &ssh.ClientConfig{
User: proxyPrincipal,
HostKeyCallback: tc.HostKeyCallback,
}
// helper to create a ProxyClient struct
makeProxyClient := ... | go | func (tc *TeleportClient) connectToProxy(ctx context.Context) (*ProxyClient, error) {
var err error
proxyPrincipal := tc.getProxySSHPrincipal()
sshConfig := &ssh.ClientConfig{
User: proxyPrincipal,
HostKeyCallback: tc.HostKeyCallback,
}
// helper to create a ProxyClient struct
makeProxyClient := ... | [
"func",
"(",
"tc",
"*",
"TeleportClient",
")",
"connectToProxy",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"*",
"ProxyClient",
",",
"error",
")",
"{",
"var",
"err",
"error",
"\n\n",
"proxyPrincipal",
":=",
"tc",
".",
"getProxySSHPrincipal",
"(",
")"... | // connectToProxy will dial to the proxy server and return a ProxyClient when
// successful. | [
"connectToProxy",
"will",
"dial",
"to",
"the",
"proxy",
"server",
"and",
"return",
"a",
"ProxyClient",
"when",
"successful",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/api.go#L1448-L1491 | train |
gravitational/teleport | lib/client/api.go | Logout | func (tc *TeleportClient) Logout() error {
err := tc.localAgent.DeleteKey()
if err != nil {
return trace.Wrap(err)
}
return nil
} | go | func (tc *TeleportClient) Logout() error {
err := tc.localAgent.DeleteKey()
if err != nil {
return trace.Wrap(err)
}
return nil
} | [
"func",
"(",
"tc",
"*",
"TeleportClient",
")",
"Logout",
"(",
")",
"error",
"{",
"err",
":=",
"tc",
".",
"localAgent",
".",
"DeleteKey",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"trace",
".",
"Wrap",
"(",
"err",
")",
"\n",
"}",
"\... | // Logout removes certificate and key for the currently logged in user from
// the filesystem and agent. | [
"Logout",
"removes",
"certificate",
"and",
"key",
"for",
"the",
"currently",
"logged",
"in",
"user",
"from",
"the",
"filesystem",
"and",
"agent",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/api.go#L1495-L1502 | train |
gravitational/teleport | lib/client/api.go | LogoutAll | func (tc *TeleportClient) LogoutAll() error {
err := tc.localAgent.DeleteKeys()
if err != nil {
return trace.Wrap(err)
}
return nil
} | go | func (tc *TeleportClient) LogoutAll() error {
err := tc.localAgent.DeleteKeys()
if err != nil {
return trace.Wrap(err)
}
return nil
} | [
"func",
"(",
"tc",
"*",
"TeleportClient",
")",
"LogoutAll",
"(",
")",
"error",
"{",
"err",
":=",
"tc",
".",
"localAgent",
".",
"DeleteKeys",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"trace",
".",
"Wrap",
"(",
"err",
")",
"\n",
"}",
... | // LogoutAll removes all certificates for all users from the filesystem
// and agent. | [
"LogoutAll",
"removes",
"all",
"certificates",
"for",
"all",
"users",
"from",
"the",
"filesystem",
"and",
"agent",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/api.go#L1506-L1512 | train |
gravitational/teleport | lib/client/api.go | GetTrustedCA | func (tc *TeleportClient) GetTrustedCA(ctx context.Context, clusterName string) ([]services.CertAuthority, error) {
// Connect to the proxy.
if !tc.Config.ProxySpecified() {
return nil, trace.BadParameter("proxy server is not specified")
}
proxyClient, err := tc.ConnectToProxy(ctx)
if err != nil {
return nil, ... | go | func (tc *TeleportClient) GetTrustedCA(ctx context.Context, clusterName string) ([]services.CertAuthority, error) {
// Connect to the proxy.
if !tc.Config.ProxySpecified() {
return nil, trace.BadParameter("proxy server is not specified")
}
proxyClient, err := tc.ConnectToProxy(ctx)
if err != nil {
return nil, ... | [
"func",
"(",
"tc",
"*",
"TeleportClient",
")",
"GetTrustedCA",
"(",
"ctx",
"context",
".",
"Context",
",",
"clusterName",
"string",
")",
"(",
"[",
"]",
"services",
".",
"CertAuthority",
",",
"error",
")",
"{",
"// Connect to the proxy.",
"if",
"!",
"tc",
"... | // GetTrustedCA returns a list of host certificate authorities
// trusted by the cluster client is authenticated with. | [
"GetTrustedCA",
"returns",
"a",
"list",
"of",
"host",
"certificate",
"authorities",
"trusted",
"by",
"the",
"cluster",
"client",
"is",
"authenticated",
"with",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/api.go#L1631-L1650 | train |
gravitational/teleport | lib/client/api.go | applyProxySettings | func (tc *TeleportClient) applyProxySettings(proxySettings ProxySettings) error {
// Kubernetes proxy settings.
if proxySettings.Kube.Enabled && proxySettings.Kube.PublicAddr != "" && tc.KubeProxyAddr == "" {
_, err := utils.ParseAddr(proxySettings.Kube.PublicAddr)
if err != nil {
return trace.BadParameter(
... | go | func (tc *TeleportClient) applyProxySettings(proxySettings ProxySettings) error {
// Kubernetes proxy settings.
if proxySettings.Kube.Enabled && proxySettings.Kube.PublicAddr != "" && tc.KubeProxyAddr == "" {
_, err := utils.ParseAddr(proxySettings.Kube.PublicAddr)
if err != nil {
return trace.BadParameter(
... | [
"func",
"(",
"tc",
"*",
"TeleportClient",
")",
"applyProxySettings",
"(",
"proxySettings",
"ProxySettings",
")",
"error",
"{",
"// Kubernetes proxy settings.",
"if",
"proxySettings",
".",
"Kube",
".",
"Enabled",
"&&",
"proxySettings",
".",
"Kube",
".",
"PublicAddr",... | // applyProxySettings updates configuration changes based on the advertised
// proxy settings, user supplied values take precedence - will be preserved
// if set | [
"applyProxySettings",
"updates",
"configuration",
"changes",
"based",
"on",
"the",
"advertised",
"proxy",
"settings",
"user",
"supplied",
"values",
"take",
"precedence",
"-",
"will",
"be",
"preserved",
"if",
"set"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/api.go#L1681-L1738 | train |
gravitational/teleport | lib/client/api.go | AddTrustedCA | func (tc *TeleportClient) AddTrustedCA(ca services.CertAuthority) error {
err := tc.LocalAgent().AddHostSignersToCache(auth.AuthoritiesToTrustedCerts([]services.CertAuthority{ca}))
if err != nil {
return trace.Wrap(err)
}
// only host CA has TLS certificates, user CA will overwrite trusted certs
// to empty fil... | go | func (tc *TeleportClient) AddTrustedCA(ca services.CertAuthority) error {
err := tc.LocalAgent().AddHostSignersToCache(auth.AuthoritiesToTrustedCerts([]services.CertAuthority{ca}))
if err != nil {
return trace.Wrap(err)
}
// only host CA has TLS certificates, user CA will overwrite trusted certs
// to empty fil... | [
"func",
"(",
"tc",
"*",
"TeleportClient",
")",
"AddTrustedCA",
"(",
"ca",
"services",
".",
"CertAuthority",
")",
"error",
"{",
"err",
":=",
"tc",
".",
"LocalAgent",
"(",
")",
".",
"AddHostSignersToCache",
"(",
"auth",
".",
"AuthoritiesToTrustedCerts",
"(",
"... | // Adds a new CA as trusted CA for this client, used in tests | [
"Adds",
"a",
"new",
"CA",
"as",
"trusted",
"CA",
"for",
"this",
"client",
"used",
"in",
"tests"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/api.go#L1763-L1779 | train |
gravitational/teleport | lib/client/api.go | directLogin | func (tc *TeleportClient) directLogin(ctx context.Context, secondFactorType string, pub []byte) (*auth.SSHLoginResponse, error) {
var err error
var password string
var otpToken string
password, err = tc.AskPassword()
if err != nil {
return nil, trace.Wrap(err)
}
// only ask for a second factor if it's enabl... | go | func (tc *TeleportClient) directLogin(ctx context.Context, secondFactorType string, pub []byte) (*auth.SSHLoginResponse, error) {
var err error
var password string
var otpToken string
password, err = tc.AskPassword()
if err != nil {
return nil, trace.Wrap(err)
}
// only ask for a second factor if it's enabl... | [
"func",
"(",
"tc",
"*",
"TeleportClient",
")",
"directLogin",
"(",
"ctx",
"context",
".",
"Context",
",",
"secondFactorType",
"string",
",",
"pub",
"[",
"]",
"byte",
")",
"(",
"*",
"auth",
".",
"SSHLoginResponse",
",",
"error",
")",
"{",
"var",
"err",
... | // directLogin asks for a password + HOTP token, makes a request to CA via proxy | [
"directLogin",
"asks",
"for",
"a",
"password",
"+",
"HOTP",
"token",
"makes",
"a",
"request",
"to",
"CA",
"via",
"proxy"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/api.go#L1786-L1816 | train |
gravitational/teleport | lib/client/api.go | ssoLogin | func (tc *TeleportClient) ssoLogin(ctx context.Context, connectorID string, pub []byte, protocol string) (*auth.SSHLoginResponse, error) {
log.Debugf("samlLogin start")
// ask the CA (via proxy) to sign our public key:
response, err := tc.credClient.SSHAgentSSOLogin(SSHLogin{
Context: ctx,
ConnectorID: c... | go | func (tc *TeleportClient) ssoLogin(ctx context.Context, connectorID string, pub []byte, protocol string) (*auth.SSHLoginResponse, error) {
log.Debugf("samlLogin start")
// ask the CA (via proxy) to sign our public key:
response, err := tc.credClient.SSHAgentSSOLogin(SSHLogin{
Context: ctx,
ConnectorID: c... | [
"func",
"(",
"tc",
"*",
"TeleportClient",
")",
"ssoLogin",
"(",
"ctx",
"context",
".",
"Context",
",",
"connectorID",
"string",
",",
"pub",
"[",
"]",
"byte",
",",
"protocol",
"string",
")",
"(",
"*",
"auth",
".",
"SSHLoginResponse",
",",
"error",
")",
... | // samlLogin opens browser window and uses OIDC or SAML redirect cycle with browser | [
"samlLogin",
"opens",
"browser",
"window",
"and",
"uses",
"OIDC",
"or",
"SAML",
"redirect",
"cycle",
"with",
"browser"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/api.go#L1819-L1832 | train |
gravitational/teleport | lib/client/api.go | u2fLogin | func (tc *TeleportClient) u2fLogin(ctx context.Context, pub []byte) (*auth.SSHLoginResponse, error) {
// U2F login requires the official u2f-host executable
_, err := exec.LookPath("u2f-host")
if err != nil {
return nil, trace.Wrap(err)
}
password, err := tc.AskPassword()
if err != nil {
return nil, trace.Wr... | go | func (tc *TeleportClient) u2fLogin(ctx context.Context, pub []byte) (*auth.SSHLoginResponse, error) {
// U2F login requires the official u2f-host executable
_, err := exec.LookPath("u2f-host")
if err != nil {
return nil, trace.Wrap(err)
}
password, err := tc.AskPassword()
if err != nil {
return nil, trace.Wr... | [
"func",
"(",
"tc",
"*",
"TeleportClient",
")",
"u2fLogin",
"(",
"ctx",
"context",
".",
"Context",
",",
"pub",
"[",
"]",
"byte",
")",
"(",
"*",
"auth",
".",
"SSHLoginResponse",
",",
"error",
")",
"{",
"// U2F login requires the official u2f-host executable",
"_... | // directLogin asks for a password and performs the challenge-response authentication | [
"directLogin",
"asks",
"for",
"a",
"password",
"and",
"performs",
"the",
"challenge",
"-",
"response",
"authentication"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/api.go#L1835-L1856 | train |
gravitational/teleport | lib/client/api.go | SendEvent | func (tc *TeleportClient) SendEvent(ctx context.Context, e events.EventFields) error {
// Try and send the event to the eventsCh. If blocking, keep blocking until
// the passed in context in canceled.
select {
case tc.eventsCh <- e:
return nil
case <-ctx.Done():
return trace.Wrap(ctx.Err())
}
} | go | func (tc *TeleportClient) SendEvent(ctx context.Context, e events.EventFields) error {
// Try and send the event to the eventsCh. If blocking, keep blocking until
// the passed in context in canceled.
select {
case tc.eventsCh <- e:
return nil
case <-ctx.Done():
return trace.Wrap(ctx.Err())
}
} | [
"func",
"(",
"tc",
"*",
"TeleportClient",
")",
"SendEvent",
"(",
"ctx",
"context",
".",
"Context",
",",
"e",
"events",
".",
"EventFields",
")",
"error",
"{",
"// Try and send the event to the eventsCh. If blocking, keep blocking until",
"// the passed in context in canceled... | // SendEvent adds a events.EventFields to the channel. | [
"SendEvent",
"adds",
"a",
"events",
".",
"EventFields",
"to",
"the",
"channel",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/api.go#L1859-L1868 | train |
gravitational/teleport | lib/client/api.go | loopbackPool | func loopbackPool(proxyAddr string) *x509.CertPool {
if !utils.IsLoopback(proxyAddr) {
log.Debugf("not using loopback pool for remote proxy addr: %v", proxyAddr)
return nil
}
log.Debugf("attempting to use loopback pool for local proxy addr: %v", proxyAddr)
certPool := x509.NewCertPool()
certPath := filepath.J... | go | func loopbackPool(proxyAddr string) *x509.CertPool {
if !utils.IsLoopback(proxyAddr) {
log.Debugf("not using loopback pool for remote proxy addr: %v", proxyAddr)
return nil
}
log.Debugf("attempting to use loopback pool for local proxy addr: %v", proxyAddr)
certPool := x509.NewCertPool()
certPath := filepath.J... | [
"func",
"loopbackPool",
"(",
"proxyAddr",
"string",
")",
"*",
"x509",
".",
"CertPool",
"{",
"if",
"!",
"utils",
".",
"IsLoopback",
"(",
"proxyAddr",
")",
"{",
"log",
".",
"Debugf",
"(",
"\"",
"\"",
",",
"proxyAddr",
")",
"\n",
"return",
"nil",
"\n",
... | // loopbackPool reads trusted CAs if it finds it in a predefined location
// and will work only if target proxy address is loopback | [
"loopbackPool",
"reads",
"trusted",
"CAs",
"if",
"it",
"finds",
"it",
"in",
"a",
"predefined",
"location",
"and",
"will",
"work",
"only",
"if",
"target",
"proxy",
"address",
"is",
"loopback"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/api.go#L1878-L1908 | train |
gravitational/teleport | lib/client/api.go | connectToSSHAgent | func connectToSSHAgent() agent.Agent {
socketPath := os.Getenv(teleport.SSHAuthSock)
conn, err := agentconn.Dial(socketPath)
if err != nil {
log.Errorf("[KEY AGENT] Unable to connect to SSH agent on socket: %q.", socketPath)
return nil
}
log.Infof("[KEY AGENT] Connected to the system agent: %q", socketPath)
... | go | func connectToSSHAgent() agent.Agent {
socketPath := os.Getenv(teleport.SSHAuthSock)
conn, err := agentconn.Dial(socketPath)
if err != nil {
log.Errorf("[KEY AGENT] Unable to connect to SSH agent on socket: %q.", socketPath)
return nil
}
log.Infof("[KEY AGENT] Connected to the system agent: %q", socketPath)
... | [
"func",
"connectToSSHAgent",
"(",
")",
"agent",
".",
"Agent",
"{",
"socketPath",
":=",
"os",
".",
"Getenv",
"(",
"teleport",
".",
"SSHAuthSock",
")",
"\n",
"conn",
",",
"err",
":=",
"agentconn",
".",
"Dial",
"(",
"socketPath",
")",
"\n",
"if",
"err",
"... | // connectToSSHAgent connects to the local SSH agent and returns a agent.Agent. | [
"connectToSSHAgent",
"connects",
"to",
"the",
"local",
"SSH",
"agent",
"and",
"returns",
"a",
"agent",
".",
"Agent",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/api.go#L1911-L1921 | train |
gravitational/teleport | lib/client/api.go | Username | func Username() (string, error) {
u, err := user.Current()
if err != nil {
return "", trace.Wrap(err)
}
return u.Username, nil
} | go | func Username() (string, error) {
u, err := user.Current()
if err != nil {
return "", trace.Wrap(err)
}
return u.Username, nil
} | [
"func",
"Username",
"(",
")",
"(",
"string",
",",
"error",
")",
"{",
"u",
",",
"err",
":=",
"user",
".",
"Current",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"trace",
".",
"Wrap",
"(",
"err",
")",
"\n",
"}",
"\... | // Username returns the current user's username | [
"Username",
"returns",
"the",
"current",
"user",
"s",
"username"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/api.go#L1924-L1930 | train |
gravitational/teleport | lib/client/api.go | AskOTP | func (tc *TeleportClient) AskOTP() (token string, err error) {
fmt.Printf("Enter your OTP token:\n")
token, err = lineFromConsole()
if err != nil {
fmt.Fprintln(tc.Stderr, err)
return "", trace.Wrap(err)
}
return token, nil
} | go | func (tc *TeleportClient) AskOTP() (token string, err error) {
fmt.Printf("Enter your OTP token:\n")
token, err = lineFromConsole()
if err != nil {
fmt.Fprintln(tc.Stderr, err)
return "", trace.Wrap(err)
}
return token, nil
} | [
"func",
"(",
"tc",
"*",
"TeleportClient",
")",
"AskOTP",
"(",
")",
"(",
"token",
"string",
",",
"err",
"error",
")",
"{",
"fmt",
".",
"Printf",
"(",
"\"",
"\\n",
"\"",
")",
"\n",
"token",
",",
"err",
"=",
"lineFromConsole",
"(",
")",
"\n",
"if",
... | // AskOTP prompts the user to enter the OTP token. | [
"AskOTP",
"prompts",
"the",
"user",
"to",
"enter",
"the",
"OTP",
"token",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/api.go#L1933-L1941 | train |
gravitational/teleport | lib/client/api.go | AskPassword | func (tc *TeleportClient) AskPassword() (pwd string, err error) {
fmt.Printf("Enter password for Teleport user %v:\n", tc.Config.Username)
pwd, err = passwordFromConsole()
if err != nil {
fmt.Fprintln(tc.Stderr, err)
return "", trace.Wrap(err)
}
return pwd, nil
} | go | func (tc *TeleportClient) AskPassword() (pwd string, err error) {
fmt.Printf("Enter password for Teleport user %v:\n", tc.Config.Username)
pwd, err = passwordFromConsole()
if err != nil {
fmt.Fprintln(tc.Stderr, err)
return "", trace.Wrap(err)
}
return pwd, nil
} | [
"func",
"(",
"tc",
"*",
"TeleportClient",
")",
"AskPassword",
"(",
")",
"(",
"pwd",
"string",
",",
"err",
"error",
")",
"{",
"fmt",
".",
"Printf",
"(",
"\"",
"\\n",
"\"",
",",
"tc",
".",
"Config",
".",
"Username",
")",
"\n",
"pwd",
",",
"err",
"=... | // AskPassword prompts the user to enter the password | [
"AskPassword",
"prompts",
"the",
"user",
"to",
"enter",
"the",
"password"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/api.go#L1944-L1953 | train |
gravitational/teleport | lib/client/api.go | passwordFromConsole | func passwordFromConsole() (string, error) {
fd := syscall.Stdin
state, err := terminal.GetState(int(fd))
// intercept Ctr+C and restore terminal
sigCh := make(chan os.Signal, 1)
closeCh := make(chan int)
if err != nil {
log.Warnf("failed reading terminal state: %v", err)
} else {
signal.Notify(sigCh, sysca... | go | func passwordFromConsole() (string, error) {
fd := syscall.Stdin
state, err := terminal.GetState(int(fd))
// intercept Ctr+C and restore terminal
sigCh := make(chan os.Signal, 1)
closeCh := make(chan int)
if err != nil {
log.Warnf("failed reading terminal state: %v", err)
} else {
signal.Notify(sigCh, sysca... | [
"func",
"passwordFromConsole",
"(",
")",
"(",
"string",
",",
"error",
")",
"{",
"fd",
":=",
"syscall",
".",
"Stdin",
"\n",
"state",
",",
"err",
":=",
"terminal",
".",
"GetState",
"(",
"int",
"(",
"fd",
")",
")",
"\n\n",
"// intercept Ctr+C and restore term... | // passwordFromConsole reads from stdin without echoing typed characters to stdout | [
"passwordFromConsole",
"reads",
"from",
"stdin",
"without",
"echoing",
"typed",
"characters",
"to",
"stdout"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/api.go#L1956-L1982 | train |
gravitational/teleport | lib/client/api.go | lineFromConsole | func lineFromConsole() (string, error) {
bytes, _, err := bufio.NewReader(os.Stdin).ReadLine()
return string(bytes), err
} | go | func lineFromConsole() (string, error) {
bytes, _, err := bufio.NewReader(os.Stdin).ReadLine()
return string(bytes), err
} | [
"func",
"lineFromConsole",
"(",
")",
"(",
"string",
",",
"error",
")",
"{",
"bytes",
",",
"_",
",",
"err",
":=",
"bufio",
".",
"NewReader",
"(",
"os",
".",
"Stdin",
")",
".",
"ReadLine",
"(",
")",
"\n",
"return",
"string",
"(",
"bytes",
")",
",",
... | // lineFromConsole reads a line from stdin | [
"lineFromConsole",
"reads",
"a",
"line",
"from",
"stdin"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/api.go#L1985-L1988 | train |
gravitational/teleport | lib/client/api.go | String | func (fp DynamicForwardedPorts) String() (retval []string) {
for _, p := range fp {
retval = append(retval, p.ToString())
}
return retval
} | go | func (fp DynamicForwardedPorts) String() (retval []string) {
for _, p := range fp {
retval = append(retval, p.ToString())
}
return retval
} | [
"func",
"(",
"fp",
"DynamicForwardedPorts",
")",
"String",
"(",
")",
"(",
"retval",
"[",
"]",
"string",
")",
"{",
"for",
"_",
",",
"p",
":=",
"range",
"fp",
"{",
"retval",
"=",
"append",
"(",
"retval",
",",
"p",
".",
"ToString",
"(",
")",
")",
"\... | // String returns the same string spec which can be parsed by
// ParseDynamicPortForwardSpec. | [
"String",
"returns",
"the",
"same",
"string",
"spec",
"which",
"can",
"be",
"parsed",
"by",
"ParseDynamicPortForwardSpec",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/api.go#L2097-L2102 | train |
gravitational/teleport | lib/client/api.go | InsecureSkipHostKeyChecking | func InsecureSkipHostKeyChecking(host string, remote net.Addr, key ssh.PublicKey) error {
return nil
} | go | func InsecureSkipHostKeyChecking(host string, remote net.Addr, key ssh.PublicKey) error {
return nil
} | [
"func",
"InsecureSkipHostKeyChecking",
"(",
"host",
"string",
",",
"remote",
"net",
".",
"Addr",
",",
"key",
"ssh",
".",
"PublicKey",
")",
"error",
"{",
"return",
"nil",
"\n",
"}"
] | // InsecureSkipHostKeyChecking is used when the user passes in
// "StrictHostKeyChecking yes". | [
"InsecureSkipHostKeyChecking",
"is",
"used",
"when",
"the",
"user",
"passes",
"in",
"StrictHostKeyChecking",
"yes",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/api.go#L2137-L2139 | train |
gravitational/teleport | lib/reversetunnel/conn.go | OpenChannel | func (c *remoteConn) OpenChannel(name string, data []byte) (ssh.Channel, error) {
channel, _, err := c.sconn.OpenChannel(name, data)
if err != nil {
return nil, trace.Wrap(err)
}
return channel, nil
} | go | func (c *remoteConn) OpenChannel(name string, data []byte) (ssh.Channel, error) {
channel, _, err := c.sconn.OpenChannel(name, data)
if err != nil {
return nil, trace.Wrap(err)
}
return channel, nil
} | [
"func",
"(",
"c",
"*",
"remoteConn",
")",
"OpenChannel",
"(",
"name",
"string",
",",
"data",
"[",
"]",
"byte",
")",
"(",
"ssh",
".",
"Channel",
",",
"error",
")",
"{",
"channel",
",",
"_",
",",
"err",
":=",
"c",
".",
"sconn",
".",
"OpenChannel",
... | // OpenChannel will open a SSH channel to the remote side. | [
"OpenChannel",
"will",
"open",
"a",
"SSH",
"channel",
"to",
"the",
"remote",
"side",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/reversetunnel/conn.go#L149-L156 | train |
gravitational/teleport | lib/reversetunnel/conn.go | ChannelConn | func (c *remoteConn) ChannelConn(channel ssh.Channel) net.Conn {
return utils.NewChConn(c.sconn, channel)
} | go | func (c *remoteConn) ChannelConn(channel ssh.Channel) net.Conn {
return utils.NewChConn(c.sconn, channel)
} | [
"func",
"(",
"c",
"*",
"remoteConn",
")",
"ChannelConn",
"(",
"channel",
"ssh",
".",
"Channel",
")",
"net",
".",
"Conn",
"{",
"return",
"utils",
".",
"NewChConn",
"(",
"c",
".",
"sconn",
",",
"channel",
")",
"\n",
"}"
] | // ChannelConn creates a net.Conn over a SSH channel. | [
"ChannelConn",
"creates",
"a",
"net",
".",
"Conn",
"over",
"a",
"SSH",
"channel",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/reversetunnel/conn.go#L159-L161 | train |
gravitational/teleport | lib/reversetunnel/conn.go | findAndSend | func (c *remoteConn) findAndSend() error {
// Find all proxies that don't have a connection to a remote agent. If all
// proxies have connections, return right away.
disconnectedProxies, err := c.findDisconnectedProxies()
if err != nil {
return trace.Wrap(err)
}
if len(disconnectedProxies) == 0 {
return nil
... | go | func (c *remoteConn) findAndSend() error {
// Find all proxies that don't have a connection to a remote agent. If all
// proxies have connections, return right away.
disconnectedProxies, err := c.findDisconnectedProxies()
if err != nil {
return trace.Wrap(err)
}
if len(disconnectedProxies) == 0 {
return nil
... | [
"func",
"(",
"c",
"*",
"remoteConn",
")",
"findAndSend",
"(",
")",
"error",
"{",
"// Find all proxies that don't have a connection to a remote agent. If all",
"// proxies have connections, return right away.",
"disconnectedProxies",
",",
"err",
":=",
"c",
".",
"findDisconnected... | // sendDiscovery requests sends special "Discovery Requests" back to the
// connected agent. Discovery request consists of the proxies that are part
// of the cluster, but did not receive the connection from the agent. Agent
// will act on a discovery request attempting to establish connection to the
// proxies that we... | [
"sendDiscovery",
"requests",
"sends",
"special",
"Discovery",
"Requests",
"back",
"to",
"the",
"connected",
"agent",
".",
"Discovery",
"request",
"consists",
"of",
"the",
"proxies",
"that",
"are",
"part",
"of",
"the",
"cluster",
"but",
"did",
"not",
"receive",
... | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/reversetunnel/conn.go#L232-L258 | train |
gravitational/teleport | lib/reversetunnel/conn.go | findDisconnectedProxies | func (c *remoteConn) findDisconnectedProxies() ([]services.Server, error) {
// Find all proxies that have connection from the remote domain.
conns, err := c.accessPoint.GetTunnelConnections(c.clusterName, services.SkipValidation())
if err != nil {
return nil, trace.Wrap(err)
}
connected := make(map[string]bool)
... | go | func (c *remoteConn) findDisconnectedProxies() ([]services.Server, error) {
// Find all proxies that have connection from the remote domain.
conns, err := c.accessPoint.GetTunnelConnections(c.clusterName, services.SkipValidation())
if err != nil {
return nil, trace.Wrap(err)
}
connected := make(map[string]bool)
... | [
"func",
"(",
"c",
"*",
"remoteConn",
")",
"findDisconnectedProxies",
"(",
")",
"(",
"[",
"]",
"services",
".",
"Server",
",",
"error",
")",
"{",
"// Find all proxies that have connection from the remote domain.",
"conns",
",",
"err",
":=",
"c",
".",
"accessPoint",... | // findDisconnectedProxies finds proxies that do not have inbound reverse tunnel
// connections. | [
"findDisconnectedProxies",
"finds",
"proxies",
"that",
"do",
"not",
"have",
"inbound",
"reverse",
"tunnel",
"connections",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/reversetunnel/conn.go#L262-L295 | train |
gravitational/teleport | lib/reversetunnel/conn.go | sendDiscoveryRequests | func (c *remoteConn) sendDiscoveryRequests(req discoveryRequest) error {
discoveryCh, err := c.openDiscoveryChannel()
if err != nil {
return trace.Wrap(err)
}
// Marshal and send the request. If the connection failed, mark the
// connection as invalid so it will be removed later.
payload, err := marshalDiscove... | go | func (c *remoteConn) sendDiscoveryRequests(req discoveryRequest) error {
discoveryCh, err := c.openDiscoveryChannel()
if err != nil {
return trace.Wrap(err)
}
// Marshal and send the request. If the connection failed, mark the
// connection as invalid so it will be removed later.
payload, err := marshalDiscove... | [
"func",
"(",
"c",
"*",
"remoteConn",
")",
"sendDiscoveryRequests",
"(",
"req",
"discoveryRequest",
")",
"error",
"{",
"discoveryCh",
",",
"err",
":=",
"c",
".",
"openDiscoveryChannel",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"trace",
".",
... | // sendDiscoveryRequests sends a discovery request with missing proxies. | [
"sendDiscoveryRequests",
"sends",
"a",
"discovery",
"request",
"with",
"missing",
"proxies",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/reversetunnel/conn.go#L298-L317 | train |
gravitational/teleport | lib/reversetunnel/conn.go | TunnelAuthDialer | func TunnelAuthDialer(proxyAddr string, sshConfig *ssh.ClientConfig) auth.DialContext {
return func(ctx context.Context, network string, addr string) (net.Conn, error) {
// Connect to the reverse tunnel server.
dialer := proxy.DialerFromEnvironment(proxyAddr)
sconn, err := dialer.Dial("tcp", proxyAddr, sshConfig... | go | func TunnelAuthDialer(proxyAddr string, sshConfig *ssh.ClientConfig) auth.DialContext {
return func(ctx context.Context, network string, addr string) (net.Conn, error) {
// Connect to the reverse tunnel server.
dialer := proxy.DialerFromEnvironment(proxyAddr)
sconn, err := dialer.Dial("tcp", proxyAddr, sshConfig... | [
"func",
"TunnelAuthDialer",
"(",
"proxyAddr",
"string",
",",
"sshConfig",
"*",
"ssh",
".",
"ClientConfig",
")",
"auth",
".",
"DialContext",
"{",
"return",
"func",
"(",
"ctx",
"context",
".",
"Context",
",",
"network",
"string",
",",
"addr",
"string",
")",
... | // TunnelAuthDialer connects to the Auth Server through the reverse tunnel. | [
"TunnelAuthDialer",
"connects",
"to",
"the",
"Auth",
"Server",
"through",
"the",
"reverse",
"tunnel",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/reversetunnel/conn.go#L341-L356 | train |
gravitational/teleport | lib/reversetunnel/conn.go | connectProxyTransport | func connectProxyTransport(sconn ssh.Conn, addr string) (net.Conn, error) {
channel, _, err := sconn.OpenChannel(chanTransport, nil)
if err != nil {
return nil, trace.Wrap(err)
}
// Send a special SSH out-of-band request called "teleport-transport"
// the agent on the other side will create a new TCP/IP connect... | go | func connectProxyTransport(sconn ssh.Conn, addr string) (net.Conn, error) {
channel, _, err := sconn.OpenChannel(chanTransport, nil)
if err != nil {
return nil, trace.Wrap(err)
}
// Send a special SSH out-of-band request called "teleport-transport"
// the agent on the other side will create a new TCP/IP connect... | [
"func",
"connectProxyTransport",
"(",
"sconn",
"ssh",
".",
"Conn",
",",
"addr",
"string",
")",
"(",
"net",
".",
"Conn",
",",
"error",
")",
"{",
"channel",
",",
"_",
",",
"err",
":=",
"sconn",
".",
"OpenChannel",
"(",
"chanTransport",
",",
"nil",
")",
... | // connectProxyTransport opens a channel over the remote tunnel and connects
// to the requested host. | [
"connectProxyTransport",
"opens",
"a",
"channel",
"over",
"the",
"remote",
"tunnel",
"and",
"connects",
"to",
"the",
"requested",
"host",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/reversetunnel/conn.go#L360-L387 | train |
gravitational/teleport | lib/service/service.go | Close | func (c *Connector) Close() error {
if c.Client != nil {
return c.Close()
}
return nil
} | go | func (c *Connector) Close() error {
if c.Client != nil {
return c.Close()
}
return nil
} | [
"func",
"(",
"c",
"*",
"Connector",
")",
"Close",
"(",
")",
"error",
"{",
"if",
"c",
".",
"Client",
"!=",
"nil",
"{",
"return",
"c",
".",
"Close",
"(",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] | // Close closes resources associated with connector | [
"Close",
"closes",
"resources",
"associated",
"with",
"connector"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/service/service.go#L179-L184 | train |
gravitational/teleport | lib/service/service.go | getConnectors | func (process *TeleportProcess) getConnectors() []*Connector {
process.Lock()
defer process.Unlock()
out := make([]*Connector, 0, len(process.connectors))
for role := range process.connectors {
out = append(out, process.connectors[role])
}
return out
} | go | func (process *TeleportProcess) getConnectors() []*Connector {
process.Lock()
defer process.Unlock()
out := make([]*Connector, 0, len(process.connectors))
for role := range process.connectors {
out = append(out, process.connectors[role])
}
return out
} | [
"func",
"(",
"process",
"*",
"TeleportProcess",
")",
"getConnectors",
"(",
")",
"[",
"]",
"*",
"Connector",
"{",
"process",
".",
"Lock",
"(",
")",
"\n",
"defer",
"process",
".",
"Unlock",
"(",
")",
"\n\n",
"out",
":=",
"make",
"(",
"[",
"]",
"*",
"... | // getConnectors returns a copy of the identities registered for auth server | [
"getConnectors",
"returns",
"a",
"copy",
"of",
"the",
"identities",
"registered",
"for",
"auth",
"server"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/service/service.go#L279-L288 | train |
gravitational/teleport | lib/service/service.go | addConnector | func (process *TeleportProcess) addConnector(connector *Connector) {
process.Lock()
defer process.Unlock()
process.connectors[connector.ClientIdentity.ID.Role] = connector
} | go | func (process *TeleportProcess) addConnector(connector *Connector) {
process.Lock()
defer process.Unlock()
process.connectors[connector.ClientIdentity.ID.Role] = connector
} | [
"func",
"(",
"process",
"*",
"TeleportProcess",
")",
"addConnector",
"(",
"connector",
"*",
"Connector",
")",
"{",
"process",
".",
"Lock",
"(",
")",
"\n",
"defer",
"process",
".",
"Unlock",
"(",
")",
"\n\n",
"process",
".",
"connectors",
"[",
"connector",
... | // addConnector adds connector to registered connectors list,
// it will overwrite the connector for the same role | [
"addConnector",
"adds",
"connector",
"to",
"registered",
"connectors",
"list",
"it",
"will",
"overwrite",
"the",
"connector",
"for",
"the",
"same",
"role"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/service/service.go#L292-L297 | train |
gravitational/teleport | lib/service/service.go | Run | func Run(ctx context.Context, cfg Config, newTeleport NewProcess) error {
if newTeleport == nil {
newTeleport = newTeleportProcess
}
copyCfg := cfg
srv, err := newTeleport(©Cfg)
if err != nil {
return trace.Wrap(err, "initialization failed")
}
if srv == nil {
return trace.BadParameter("process has retu... | go | func Run(ctx context.Context, cfg Config, newTeleport NewProcess) error {
if newTeleport == nil {
newTeleport = newTeleportProcess
}
copyCfg := cfg
srv, err := newTeleport(©Cfg)
if err != nil {
return trace.Wrap(err, "initialization failed")
}
if srv == nil {
return trace.BadParameter("process has retu... | [
"func",
"Run",
"(",
"ctx",
"context",
".",
"Context",
",",
"cfg",
"Config",
",",
"newTeleport",
"NewProcess",
")",
"error",
"{",
"if",
"newTeleport",
"==",
"nil",
"{",
"newTeleport",
"=",
"newTeleportProcess",
"\n",
"}",
"\n",
"copyCfg",
":=",
"cfg",
"\n",... | // Run starts teleport processes, waits for signals
// and handles internal process reloads. | [
"Run",
"starts",
"teleport",
"processes",
"waits",
"for",
"signals",
"and",
"handles",
"internal",
"process",
"reloads",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/service/service.go#L379-L406 | train |
gravitational/teleport | lib/service/service.go | notifyParent | func (process *TeleportProcess) notifyParent() {
signalPipe, err := process.importSignalPipe()
if err != nil {
if !trace.IsNotFound(err) {
process.Warningf("Failed to import signal pipe")
}
process.Debugf("No signal pipe to import, must be first Teleport process.")
return
}
defer signalPipe.Close()
ctx... | go | func (process *TeleportProcess) notifyParent() {
signalPipe, err := process.importSignalPipe()
if err != nil {
if !trace.IsNotFound(err) {
process.Warningf("Failed to import signal pipe")
}
process.Debugf("No signal pipe to import, must be first Teleport process.")
return
}
defer signalPipe.Close()
ctx... | [
"func",
"(",
"process",
"*",
"TeleportProcess",
")",
"notifyParent",
"(",
")",
"{",
"signalPipe",
",",
"err",
":=",
"process",
".",
"importSignalPipe",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"if",
"!",
"trace",
".",
"IsNotFound",
"(",
"err",
")... | // notifyParent notifies parent process that this process has started
// by writing to in-memory pipe used by communication channel. | [
"notifyParent",
"notifies",
"parent",
"process",
"that",
"this",
"process",
"has",
"started",
"by",
"writing",
"to",
"in",
"-",
"memory",
"pipe",
"used",
"by",
"communication",
"channel",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/service/service.go#L666-L699 | train |
gravitational/teleport | lib/service/service.go | adminCreds | func adminCreds() (*int, *int, error) {
if runtime.GOOS != teleport.LinuxOS {
return nil, nil, nil
}
// if the user member of adm linux group,
// make audit log folder readable by admins
isAdmin, err := utils.IsGroupMember(teleport.LinuxAdminGID)
if err != nil {
return nil, nil, trace.Wrap(err)
}
if !isAdmi... | go | func adminCreds() (*int, *int, error) {
if runtime.GOOS != teleport.LinuxOS {
return nil, nil, nil
}
// if the user member of adm linux group,
// make audit log folder readable by admins
isAdmin, err := utils.IsGroupMember(teleport.LinuxAdminGID)
if err != nil {
return nil, nil, trace.Wrap(err)
}
if !isAdmi... | [
"func",
"adminCreds",
"(",
")",
"(",
"*",
"int",
",",
"*",
"int",
",",
"error",
")",
"{",
"if",
"runtime",
".",
"GOOS",
"!=",
"teleport",
".",
"LinuxOS",
"{",
"return",
"nil",
",",
"nil",
",",
"nil",
"\n",
"}",
"\n",
"// if the user member of adm linux... | // adminCreds returns admin UID and GID settings based on the OS | [
"adminCreds",
"returns",
"admin",
"UID",
"and",
"GID",
"settings",
"based",
"on",
"the",
"OS"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/service/service.go#L714-L730 | train |
gravitational/teleport | lib/service/service.go | initUploadHandler | func initUploadHandler(auditConfig services.AuditConfig) (events.UploadHandler, error) {
if auditConfig.AuditSessionsURI == "" {
return nil, trace.NotFound("no upload handler is setup")
}
uri, err := utils.ParseSessionsURI(auditConfig.AuditSessionsURI)
if err != nil {
return nil, trace.Wrap(err)
}
switch uri... | go | func initUploadHandler(auditConfig services.AuditConfig) (events.UploadHandler, error) {
if auditConfig.AuditSessionsURI == "" {
return nil, trace.NotFound("no upload handler is setup")
}
uri, err := utils.ParseSessionsURI(auditConfig.AuditSessionsURI)
if err != nil {
return nil, trace.Wrap(err)
}
switch uri... | [
"func",
"initUploadHandler",
"(",
"auditConfig",
"services",
".",
"AuditConfig",
")",
"(",
"events",
".",
"UploadHandler",
",",
"error",
")",
"{",
"if",
"auditConfig",
".",
"AuditSessionsURI",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"trace",
".",
"NotFo... | // initUploadHandler initializes upload handler based on the config settings,
// currently the only upload handler supported is S3
// the call can return trace.NotFOund if no upload handler is setup | [
"initUploadHandler",
"initializes",
"upload",
"handler",
"based",
"on",
"the",
"config",
"settings",
"currently",
"the",
"only",
"upload",
"handler",
"supported",
"is",
"S3",
"the",
"call",
"can",
"return",
"trace",
".",
"NotFOund",
"if",
"no",
"upload",
"handle... | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/service/service.go#L735-L775 | train |
gravitational/teleport | lib/service/service.go | initExternalLog | func initExternalLog(auditConfig services.AuditConfig) (events.IAuditLog, error) {
if auditConfig.AuditTableName != "" {
log.Warningf("Please note that 'audit_table_name' is deprecated and will be removed in several releases. Use audit_events_uri: '%v://%v' instead.", dynamo.GetName(), auditConfig.AuditTableName)
... | go | func initExternalLog(auditConfig services.AuditConfig) (events.IAuditLog, error) {
if auditConfig.AuditTableName != "" {
log.Warningf("Please note that 'audit_table_name' is deprecated and will be removed in several releases. Use audit_events_uri: '%v://%v' instead.", dynamo.GetName(), auditConfig.AuditTableName)
... | [
"func",
"initExternalLog",
"(",
"auditConfig",
"services",
".",
"AuditConfig",
")",
"(",
"events",
".",
"IAuditLog",
",",
"error",
")",
"{",
"if",
"auditConfig",
".",
"AuditTableName",
"!=",
"\"",
"\"",
"{",
"log",
".",
"Warningf",
"(",
"\"",
"\"",
",",
... | // initExternalLog initializes external storage, if the storage is not
// setup, returns nil | [
"initExternalLog",
"initializes",
"external",
"storage",
"if",
"the",
"storage",
"is",
"not",
"setup",
"returns",
"nil"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/service/service.go#L779-L843 | train |
gravitational/teleport | lib/service/service.go | onExit | func (process *TeleportProcess) onExit(serviceName string, callback func(interface{})) {
process.RegisterFunc(serviceName, func() error {
eventC := make(chan Event)
process.WaitForEvent(context.TODO(), TeleportExitEvent, eventC)
select {
case event := <-eventC:
callback(event.Payload)
}
return nil
})
} | go | func (process *TeleportProcess) onExit(serviceName string, callback func(interface{})) {
process.RegisterFunc(serviceName, func() error {
eventC := make(chan Event)
process.WaitForEvent(context.TODO(), TeleportExitEvent, eventC)
select {
case event := <-eventC:
callback(event.Payload)
}
return nil
})
} | [
"func",
"(",
"process",
"*",
"TeleportProcess",
")",
"onExit",
"(",
"serviceName",
"string",
",",
"callback",
"func",
"(",
"interface",
"{",
"}",
")",
")",
"{",
"process",
".",
"RegisterFunc",
"(",
"serviceName",
",",
"func",
"(",
")",
"error",
"{",
"eve... | // onExit allows individual services to register a callback function which will be
// called when Teleport Process is asked to exit. Usually services terminate themselves
// when the callback is called | [
"onExit",
"allows",
"individual",
"services",
"to",
"register",
"a",
"callback",
"function",
"which",
"will",
"be",
"called",
"when",
"Teleport",
"Process",
"is",
"asked",
"to",
"exit",
".",
"Usually",
"services",
"terminate",
"themselves",
"when",
"the",
"callb... | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/service/service.go#L1160-L1170 | train |
gravitational/teleport | lib/service/service.go | newAccessCache | func (process *TeleportProcess) newAccessCache(cfg accessCacheConfig) (*cache.Cache, error) {
if err := cfg.CheckAndSetDefaults(); err != nil {
return nil, trace.Wrap(err)
}
var cacheBackend backend.Backend
if cfg.inMemory {
mem, err := memory.New(memory.Config{
Context: process.ExitContext(),
EventsOff... | go | func (process *TeleportProcess) newAccessCache(cfg accessCacheConfig) (*cache.Cache, error) {
if err := cfg.CheckAndSetDefaults(); err != nil {
return nil, trace.Wrap(err)
}
var cacheBackend backend.Backend
if cfg.inMemory {
mem, err := memory.New(memory.Config{
Context: process.ExitContext(),
EventsOff... | [
"func",
"(",
"process",
"*",
"TeleportProcess",
")",
"newAccessCache",
"(",
"cfg",
"accessCacheConfig",
")",
"(",
"*",
"cache",
".",
"Cache",
",",
"error",
")",
"{",
"if",
"err",
":=",
"cfg",
".",
"CheckAndSetDefaults",
"(",
")",
";",
"err",
"!=",
"nil",... | // newAccessCache returns new local cache access point | [
"newAccessCache",
"returns",
"new",
"local",
"cache",
"access",
"point"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/service/service.go#L1209-L1264 | train |
gravitational/teleport | lib/service/service.go | setupCachePolicy | func (process *TeleportProcess) setupCachePolicy(in cache.SetupConfigFn) cache.SetupConfigFn {
return func(c cache.Config) cache.Config {
config := in(c)
config.PreferRecent = cache.PreferRecent{
Enabled: process.Config.CachePolicy.Enabled,
NeverExpires: process.Config.CachePolicy.NeverExpires,
MaxTT... | go | func (process *TeleportProcess) setupCachePolicy(in cache.SetupConfigFn) cache.SetupConfigFn {
return func(c cache.Config) cache.Config {
config := in(c)
config.PreferRecent = cache.PreferRecent{
Enabled: process.Config.CachePolicy.Enabled,
NeverExpires: process.Config.CachePolicy.NeverExpires,
MaxTT... | [
"func",
"(",
"process",
"*",
"TeleportProcess",
")",
"setupCachePolicy",
"(",
"in",
"cache",
".",
"SetupConfigFn",
")",
"cache",
".",
"SetupConfigFn",
"{",
"return",
"func",
"(",
"c",
"cache",
".",
"Config",
")",
"cache",
".",
"Config",
"{",
"config",
":="... | // setupCachePolicy sets up cache policy based on teleport configuration,
// it is a wrapper function, that sets up configuration | [
"setupCachePolicy",
"sets",
"up",
"cache",
"policy",
"based",
"on",
"teleport",
"configuration",
"it",
"is",
"a",
"wrapper",
"function",
"that",
"sets",
"up",
"configuration"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/service/service.go#L1268-L1278 | train |
gravitational/teleport | lib/service/service.go | newLocalCacheForProxy | func (process *TeleportProcess) newLocalCacheForProxy(clt auth.ClientI, cacheName []string) (auth.AccessPoint, error) {
return process.newLocalCache(clt, cache.ForProxy, cacheName)
} | go | func (process *TeleportProcess) newLocalCacheForProxy(clt auth.ClientI, cacheName []string) (auth.AccessPoint, error) {
return process.newLocalCache(clt, cache.ForProxy, cacheName)
} | [
"func",
"(",
"process",
"*",
"TeleportProcess",
")",
"newLocalCacheForProxy",
"(",
"clt",
"auth",
".",
"ClientI",
",",
"cacheName",
"[",
"]",
"string",
")",
"(",
"auth",
".",
"AccessPoint",
",",
"error",
")",
"{",
"return",
"process",
".",
"newLocalCache",
... | // newAccessPointCache returns new instance of access point configured for proxy | [
"newAccessPointCache",
"returns",
"new",
"instance",
"of",
"access",
"point",
"configured",
"for",
"proxy"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/service/service.go#L1281-L1283 | train |
gravitational/teleport | lib/service/service.go | newLocalCache | func (process *TeleportProcess) newLocalCache(clt auth.ClientI, setupConfig cache.SetupConfigFn, cacheName []string) (auth.AccessPoint, error) {
// if caching is disabled, return access point
if !process.Config.CachePolicy.Enabled {
return clt, nil
}
cache, err := process.newAccessCache(accessCacheConfig{
servi... | go | func (process *TeleportProcess) newLocalCache(clt auth.ClientI, setupConfig cache.SetupConfigFn, cacheName []string) (auth.AccessPoint, error) {
// if caching is disabled, return access point
if !process.Config.CachePolicy.Enabled {
return clt, nil
}
cache, err := process.newAccessCache(accessCacheConfig{
servi... | [
"func",
"(",
"process",
"*",
"TeleportProcess",
")",
"newLocalCache",
"(",
"clt",
"auth",
".",
"ClientI",
",",
"setupConfig",
"cache",
".",
"SetupConfigFn",
",",
"cacheName",
"[",
"]",
"string",
")",
"(",
"auth",
".",
"AccessPoint",
",",
"error",
")",
"{",... | // newAccessPointCache returns new instance of access point | [
"newAccessPointCache",
"returns",
"new",
"instance",
"of",
"access",
"point"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/service/service.go#L1286-L1300 | train |
gravitational/teleport | lib/service/service.go | registerWithAuthServer | func (process *TeleportProcess) registerWithAuthServer(role teleport.Role, eventName string) {
serviceName := strings.ToLower(role.String())
process.RegisterCriticalFunc(fmt.Sprintf("register.%v", serviceName), func() error {
connector, err := process.reconnectToAuthService(role)
if err != nil {
return trace.W... | go | func (process *TeleportProcess) registerWithAuthServer(role teleport.Role, eventName string) {
serviceName := strings.ToLower(role.String())
process.RegisterCriticalFunc(fmt.Sprintf("register.%v", serviceName), func() error {
connector, err := process.reconnectToAuthService(role)
if err != nil {
return trace.W... | [
"func",
"(",
"process",
"*",
"TeleportProcess",
")",
"registerWithAuthServer",
"(",
"role",
"teleport",
".",
"Role",
",",
"eventName",
"string",
")",
"{",
"serviceName",
":=",
"strings",
".",
"ToLower",
"(",
"role",
".",
"String",
"(",
")",
")",
"\n",
"pro... | // registerWithAuthServer uses one time provisioning token obtained earlier
// from the server to get a pair of SSH keys signed by Auth server host
// certificate authority | [
"registerWithAuthServer",
"uses",
"one",
"time",
"provisioning",
"token",
"obtained",
"earlier",
"from",
"the",
"server",
"to",
"get",
"a",
"pair",
"of",
"SSH",
"keys",
"signed",
"by",
"Auth",
"server",
"host",
"certificate",
"authority"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/service/service.go#L1521-L1538 | train |
gravitational/teleport | lib/service/service.go | getAdditionalPrincipals | func (process *TeleportProcess) getAdditionalPrincipals(role teleport.Role) ([]string, []string, error) {
var principals []string
var dnsNames []string
if process.Config.Hostname != "" {
principals = append(principals, process.Config.Hostname)
}
var addrs []utils.NetAddr
switch role {
case teleport.RoleProxy:
... | go | func (process *TeleportProcess) getAdditionalPrincipals(role teleport.Role) ([]string, []string, error) {
var principals []string
var dnsNames []string
if process.Config.Hostname != "" {
principals = append(principals, process.Config.Hostname)
}
var addrs []utils.NetAddr
switch role {
case teleport.RoleProxy:
... | [
"func",
"(",
"process",
"*",
"TeleportProcess",
")",
"getAdditionalPrincipals",
"(",
"role",
"teleport",
".",
"Role",
")",
"(",
"[",
"]",
"string",
",",
"[",
"]",
"string",
",",
"error",
")",
"{",
"var",
"principals",
"[",
"]",
"string",
"\n",
"var",
"... | // getAdditionalPrincipals returns a list of additional principals to add
// to role's service certificates. | [
"getAdditionalPrincipals",
"returns",
"a",
"list",
"of",
"additional",
"principals",
"to",
"add",
"to",
"role",
"s",
"service",
"certificates",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/service/service.go#L1698-L1748 | train |
gravitational/teleport | lib/service/service.go | initAuthStorage | func (process *TeleportProcess) initAuthStorage() (bk backend.Backend, err error) {
bc := &process.Config.Auth.StorageConfig
process.Debugf("Using %v backend.", bc.Type)
switch bc.Type {
case lite.GetName():
bk, err = lite.New(context.TODO(), bc.Params)
// legacy bolt backend, import all data into SQLite and re... | go | func (process *TeleportProcess) initAuthStorage() (bk backend.Backend, err error) {
bc := &process.Config.Auth.StorageConfig
process.Debugf("Using %v backend.", bc.Type)
switch bc.Type {
case lite.GetName():
bk, err = lite.New(context.TODO(), bc.Params)
// legacy bolt backend, import all data into SQLite and re... | [
"func",
"(",
"process",
"*",
"TeleportProcess",
")",
"initAuthStorage",
"(",
")",
"(",
"bk",
"backend",
".",
"Backend",
",",
"err",
"error",
")",
"{",
"bc",
":=",
"&",
"process",
".",
"Config",
".",
"Auth",
".",
"StorageConfig",
"\n",
"process",
".",
"... | // initAuthStorage initializes the storage backend for the auth service. | [
"initAuthStorage",
"initializes",
"the",
"storage",
"backend",
"for",
"the",
"auth",
"service",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/service/service.go#L2225-L2281 | train |
gravitational/teleport | lib/service/service.go | WaitWithContext | func (process *TeleportProcess) WaitWithContext(ctx context.Context) {
local, cancel := context.WithCancel(ctx)
go func() {
defer cancel()
process.Supervisor.Wait()
}()
select {
case <-local.Done():
return
}
} | go | func (process *TeleportProcess) WaitWithContext(ctx context.Context) {
local, cancel := context.WithCancel(ctx)
go func() {
defer cancel()
process.Supervisor.Wait()
}()
select {
case <-local.Done():
return
}
} | [
"func",
"(",
"process",
"*",
"TeleportProcess",
")",
"WaitWithContext",
"(",
"ctx",
"context",
".",
"Context",
")",
"{",
"local",
",",
"cancel",
":=",
"context",
".",
"WithCancel",
"(",
"ctx",
")",
"\n",
"go",
"func",
"(",
")",
"{",
"defer",
"cancel",
... | // WaitWithContext waits until all internal services stop. | [
"WaitWithContext",
"waits",
"until",
"all",
"internal",
"services",
"stop",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/service/service.go#L2296-L2306 | train |
gravitational/teleport | lib/service/service.go | StartShutdown | func (process *TeleportProcess) StartShutdown(ctx context.Context) context.Context {
process.BroadcastEvent(Event{Name: TeleportExitEvent, Payload: ctx})
localCtx, cancel := context.WithCancel(ctx)
go func() {
defer cancel()
process.Supervisor.Wait()
process.Debugf("All supervisor functions are completed.")
... | go | func (process *TeleportProcess) StartShutdown(ctx context.Context) context.Context {
process.BroadcastEvent(Event{Name: TeleportExitEvent, Payload: ctx})
localCtx, cancel := context.WithCancel(ctx)
go func() {
defer cancel()
process.Supervisor.Wait()
process.Debugf("All supervisor functions are completed.")
... | [
"func",
"(",
"process",
"*",
"TeleportProcess",
")",
"StartShutdown",
"(",
"ctx",
"context",
".",
"Context",
")",
"context",
".",
"Context",
"{",
"process",
".",
"BroadcastEvent",
"(",
"Event",
"{",
"Name",
":",
"TeleportExitEvent",
",",
"Payload",
":",
"ctx... | // StartShutdown launches non-blocking graceful shutdown process that signals
// completion, returns context that will be closed once the shutdown is done | [
"StartShutdown",
"launches",
"non",
"-",
"blocking",
"graceful",
"shutdown",
"process",
"that",
"signals",
"completion",
"returns",
"context",
"that",
"will",
"be",
"closed",
"once",
"the",
"shutdown",
"is",
"done"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/service/service.go#L2310-L2326 | train |
gravitational/teleport | lib/service/service.go | Shutdown | func (process *TeleportProcess) Shutdown(ctx context.Context) {
localCtx := process.StartShutdown(ctx)
// wait until parent context closes
select {
case <-localCtx.Done():
process.Debugf("Process completed.")
}
} | go | func (process *TeleportProcess) Shutdown(ctx context.Context) {
localCtx := process.StartShutdown(ctx)
// wait until parent context closes
select {
case <-localCtx.Done():
process.Debugf("Process completed.")
}
} | [
"func",
"(",
"process",
"*",
"TeleportProcess",
")",
"Shutdown",
"(",
"ctx",
"context",
".",
"Context",
")",
"{",
"localCtx",
":=",
"process",
".",
"StartShutdown",
"(",
"ctx",
")",
"\n",
"// wait until parent context closes",
"select",
"{",
"case",
"<-",
"loc... | // Shutdown launches graceful shutdown process and waits
// for it to complete | [
"Shutdown",
"launches",
"graceful",
"shutdown",
"process",
"and",
"waits",
"for",
"it",
"to",
"complete"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/service/service.go#L2330-L2337 | train |
gravitational/teleport | lib/service/service.go | Close | func (process *TeleportProcess) Close() error {
process.BroadcastEvent(Event{Name: TeleportExitEvent})
process.Config.Keygen.Close()
var errors []error
localAuth := process.getLocalAuth()
if localAuth != nil {
errors = append(errors, process.localAuth.Close())
}
if process.storage != nil {
errors = append... | go | func (process *TeleportProcess) Close() error {
process.BroadcastEvent(Event{Name: TeleportExitEvent})
process.Config.Keygen.Close()
var errors []error
localAuth := process.getLocalAuth()
if localAuth != nil {
errors = append(errors, process.localAuth.Close())
}
if process.storage != nil {
errors = append... | [
"func",
"(",
"process",
"*",
"TeleportProcess",
")",
"Close",
"(",
")",
"error",
"{",
"process",
".",
"BroadcastEvent",
"(",
"Event",
"{",
"Name",
":",
"TeleportExitEvent",
"}",
")",
"\n\n",
"process",
".",
"Config",
".",
"Keygen",
".",
"Close",
"(",
")"... | // Close broadcasts close signals and exits immediately | [
"Close",
"broadcasts",
"close",
"signals",
"and",
"exits",
"immediately"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/service/service.go#L2340-L2356 | train |
gravitational/teleport | lib/service/service.go | initSelfSignedHTTPSCert | func initSelfSignedHTTPSCert(cfg *Config) (err error) {
log.Warningf("No TLS Keys provided, using self signed certificate.")
keyPath := filepath.Join(cfg.DataDir, defaults.SelfSignedKeyPath)
certPath := filepath.Join(cfg.DataDir, defaults.SelfSignedCertPath)
cfg.Proxy.TLSKey = keyPath
cfg.Proxy.TLSCert = certPat... | go | func initSelfSignedHTTPSCert(cfg *Config) (err error) {
log.Warningf("No TLS Keys provided, using self signed certificate.")
keyPath := filepath.Join(cfg.DataDir, defaults.SelfSignedKeyPath)
certPath := filepath.Join(cfg.DataDir, defaults.SelfSignedCertPath)
cfg.Proxy.TLSKey = keyPath
cfg.Proxy.TLSCert = certPat... | [
"func",
"initSelfSignedHTTPSCert",
"(",
"cfg",
"*",
"Config",
")",
"(",
"err",
"error",
")",
"{",
"log",
".",
"Warningf",
"(",
"\"",
"\"",
")",
"\n\n",
"keyPath",
":=",
"filepath",
".",
"Join",
"(",
"cfg",
".",
"DataDir",
",",
"defaults",
".",
"SelfSig... | // initSelfSignedHTTPSCert generates and self-signs a TLS key+cert pair for https connection
// to the proxy server. | [
"initSelfSignedHTTPSCert",
"generates",
"and",
"self",
"-",
"signs",
"a",
"TLS",
"key",
"+",
"cert",
"pair",
"for",
"https",
"connection",
"to",
"the",
"proxy",
"server",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/service/service.go#L2401-L2432 | train |
gravitational/teleport | lib/kube/utils/utils.go | GetKubeClient | func GetKubeClient(configPath string) (client *kubernetes.Clientset, config *rest.Config, err error) {
// if path to kubeconfig was provided, init config from it
if configPath != "" {
config, err = clientcmd.BuildConfigFromFlags("", configPath)
if err != nil {
return nil, nil, trace.Wrap(err)
}
} else {
/... | go | func GetKubeClient(configPath string) (client *kubernetes.Clientset, config *rest.Config, err error) {
// if path to kubeconfig was provided, init config from it
if configPath != "" {
config, err = clientcmd.BuildConfigFromFlags("", configPath)
if err != nil {
return nil, nil, trace.Wrap(err)
}
} else {
/... | [
"func",
"GetKubeClient",
"(",
"configPath",
"string",
")",
"(",
"client",
"*",
"kubernetes",
".",
"Clientset",
",",
"config",
"*",
"rest",
".",
"Config",
",",
"err",
"error",
")",
"{",
"// if path to kubeconfig was provided, init config from it",
"if",
"configPath",... | // GetKubeClient returns instance of client to the kubernetes cluster
// using in-cluster configuration if available and falling back to
// configuration file under configPath otherwise | [
"GetKubeClient",
"returns",
"instance",
"of",
"client",
"to",
"the",
"kubernetes",
"cluster",
"using",
"in",
"-",
"cluster",
"configuration",
"if",
"available",
"and",
"falling",
"back",
"to",
"configuration",
"file",
"under",
"configPath",
"otherwise"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/kube/utils/utils.go#L16-L36 | train |
gravitational/teleport | lib/kube/utils/utils.go | GetKubeConfig | func GetKubeConfig(configPath string) (*rest.Config, error) {
// if path to kubeconfig was provided, init config from it
if configPath != "" {
return clientcmd.BuildConfigFromFlags("", configPath)
}
return rest.InClusterConfig()
} | go | func GetKubeConfig(configPath string) (*rest.Config, error) {
// if path to kubeconfig was provided, init config from it
if configPath != "" {
return clientcmd.BuildConfigFromFlags("", configPath)
}
return rest.InClusterConfig()
} | [
"func",
"GetKubeConfig",
"(",
"configPath",
"string",
")",
"(",
"*",
"rest",
".",
"Config",
",",
"error",
")",
"{",
"// if path to kubeconfig was provided, init config from it",
"if",
"configPath",
"!=",
"\"",
"\"",
"{",
"return",
"clientcmd",
".",
"BuildConfigFromF... | // GetKubeConfig returns kubernetes configuration
// from configPath file or, by default reads in-cluster configuration | [
"GetKubeConfig",
"returns",
"kubernetes",
"configuration",
"from",
"configPath",
"file",
"or",
"by",
"default",
"reads",
"in",
"-",
"cluster",
"configuration"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/kube/utils/utils.go#L40-L46 | train |
gravitational/teleport | lib/services/provisioning.go | MustCreateProvisionToken | func MustCreateProvisionToken(token string, roles teleport.Roles, expires time.Time) ProvisionToken {
t, err := NewProvisionToken(token, roles, expires)
if err != nil {
panic(err)
}
return t
} | go | func MustCreateProvisionToken(token string, roles teleport.Roles, expires time.Time) ProvisionToken {
t, err := NewProvisionToken(token, roles, expires)
if err != nil {
panic(err)
}
return t
} | [
"func",
"MustCreateProvisionToken",
"(",
"token",
"string",
",",
"roles",
"teleport",
".",
"Roles",
",",
"expires",
"time",
".",
"Time",
")",
"ProvisionToken",
"{",
"t",
",",
"err",
":=",
"NewProvisionToken",
"(",
"token",
",",
"roles",
",",
"expires",
")",
... | // MustCreateProvisionToken returns a new valid provision token
// or panics, used in testes | [
"MustCreateProvisionToken",
"returns",
"a",
"new",
"valid",
"provision",
"token",
"or",
"panics",
"used",
"in",
"testes"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/provisioning.go#L33-L39 | train |
gravitational/teleport | lib/services/provisioning.go | NewProvisionToken | func NewProvisionToken(token string, roles teleport.Roles, expires time.Time) (ProvisionToken, error) {
t := &ProvisionTokenV2{
Kind: KindToken,
Version: V2,
Metadata: Metadata{
Name: token,
Expires: &expires,
Namespace: defaults.Namespace,
},
Spec: ProvisionTokenSpecV2{
Roles: roles,
... | go | func NewProvisionToken(token string, roles teleport.Roles, expires time.Time) (ProvisionToken, error) {
t := &ProvisionTokenV2{
Kind: KindToken,
Version: V2,
Metadata: Metadata{
Name: token,
Expires: &expires,
Namespace: defaults.Namespace,
},
Spec: ProvisionTokenSpecV2{
Roles: roles,
... | [
"func",
"NewProvisionToken",
"(",
"token",
"string",
",",
"roles",
"teleport",
".",
"Roles",
",",
"expires",
"time",
".",
"Time",
")",
"(",
"ProvisionToken",
",",
"error",
")",
"{",
"t",
":=",
"&",
"ProvisionTokenV2",
"{",
"Kind",
":",
"KindToken",
",",
... | // NewProvisionToken returns a new instance of provision token resource | [
"NewProvisionToken",
"returns",
"a",
"new",
"instance",
"of",
"provision",
"token",
"resource"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/provisioning.go#L42-L59 | train |
gravitational/teleport | lib/services/provisioning.go | ProvisionTokensToV1 | func ProvisionTokensToV1(in []ProvisionToken) []ProvisionTokenV1 {
if in == nil {
return nil
}
out := make([]ProvisionTokenV1, len(in))
for i := range in {
out[i] = *in[i].V1()
}
return out
} | go | func ProvisionTokensToV1(in []ProvisionToken) []ProvisionTokenV1 {
if in == nil {
return nil
}
out := make([]ProvisionTokenV1, len(in))
for i := range in {
out[i] = *in[i].V1()
}
return out
} | [
"func",
"ProvisionTokensToV1",
"(",
"in",
"[",
"]",
"ProvisionToken",
")",
"[",
"]",
"ProvisionTokenV1",
"{",
"if",
"in",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"out",
":=",
"make",
"(",
"[",
"]",
"ProvisionTokenV1",
",",
"len",
"(",
"in",... | // ProvisionTokensToV1 converts provision tokens to V1 list | [
"ProvisionTokensToV1",
"converts",
"provision",
"tokens",
"to",
"V1",
"list"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/provisioning.go#L97-L106 | train |
gravitational/teleport | lib/services/provisioning.go | ProvisionTokensFromV1 | func ProvisionTokensFromV1(in []ProvisionTokenV1) []ProvisionToken {
if in == nil {
return nil
}
out := make([]ProvisionToken, len(in))
for i := range in {
out[i] = in[i].V2()
}
return out
} | go | func ProvisionTokensFromV1(in []ProvisionTokenV1) []ProvisionToken {
if in == nil {
return nil
}
out := make([]ProvisionToken, len(in))
for i := range in {
out[i] = in[i].V2()
}
return out
} | [
"func",
"ProvisionTokensFromV1",
"(",
"in",
"[",
"]",
"ProvisionTokenV1",
")",
"[",
"]",
"ProvisionToken",
"{",
"if",
"in",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"out",
":=",
"make",
"(",
"[",
"]",
"ProvisionToken",
",",
"len",
"(",
"in",... | // ProvisionTokensFromV1 converts V1 provision tokens to resource list | [
"ProvisionTokensFromV1",
"converts",
"V1",
"provision",
"tokens",
"to",
"resource",
"list"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/provisioning.go#L109-L118 | train |
gravitational/teleport | lib/services/provisioning.go | SetRoles | func (p *ProvisionTokenV2) SetRoles(r teleport.Roles) {
p.Spec.Roles = r
} | go | func (p *ProvisionTokenV2) SetRoles(r teleport.Roles) {
p.Spec.Roles = r
} | [
"func",
"(",
"p",
"*",
"ProvisionTokenV2",
")",
"SetRoles",
"(",
"r",
"teleport",
".",
"Roles",
")",
"{",
"p",
".",
"Spec",
".",
"Roles",
"=",
"r",
"\n",
"}"
] | // SetRoles sets teleport roles | [
"SetRoles",
"sets",
"teleport",
"roles"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/provisioning.go#L149-L151 | train |
gravitational/teleport | lib/services/provisioning.go | UnmarshalProvisionToken | func UnmarshalProvisionToken(data []byte, opts ...MarshalOption) (ProvisionToken, error) {
if len(data) == 0 {
return nil, trace.BadParameter("missing provision token data")
}
cfg, err := collectOptions(opts)
if err != nil {
return nil, trace.Wrap(err)
}
var h ResourceHeader
err = utils.FastUnmarshal(data,... | go | func UnmarshalProvisionToken(data []byte, opts ...MarshalOption) (ProvisionToken, error) {
if len(data) == 0 {
return nil, trace.BadParameter("missing provision token data")
}
cfg, err := collectOptions(opts)
if err != nil {
return nil, trace.Wrap(err)
}
var h ResourceHeader
err = utils.FastUnmarshal(data,... | [
"func",
"UnmarshalProvisionToken",
"(",
"data",
"[",
"]",
"byte",
",",
"opts",
"...",
"MarshalOption",
")",
"(",
"ProvisionToken",
",",
"error",
")",
"{",
"if",
"len",
"(",
"data",
")",
"==",
"0",
"{",
"return",
"nil",
",",
"trace",
".",
"BadParameter",
... | // UnmarshalProvisionToken unmarshals provision token from JSON or YAML,
// sets defaults and checks the schema | [
"UnmarshalProvisionToken",
"unmarshals",
"provision",
"token",
"from",
"JSON",
"or",
"YAML",
"sets",
"defaults",
"and",
"checks",
"the",
"schema"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/provisioning.go#L281-L329 | train |
gravitational/teleport | lib/services/provisioning.go | MarshalProvisionToken | func MarshalProvisionToken(t ProvisionToken, opts ...MarshalOption) ([]byte, error) {
cfg, err := collectOptions(opts)
if err != nil {
return nil, trace.Wrap(err)
}
type token1 interface {
V1() *ProvisionTokenV1
}
type token2 interface {
V2() *ProvisionTokenV2
}
version := cfg.GetVersion()
switch version... | go | func MarshalProvisionToken(t ProvisionToken, opts ...MarshalOption) ([]byte, error) {
cfg, err := collectOptions(opts)
if err != nil {
return nil, trace.Wrap(err)
}
type token1 interface {
V1() *ProvisionTokenV1
}
type token2 interface {
V2() *ProvisionTokenV2
}
version := cfg.GetVersion()
switch version... | [
"func",
"MarshalProvisionToken",
"(",
"t",
"ProvisionToken",
",",
"opts",
"...",
"MarshalOption",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"cfg",
",",
"err",
":=",
"collectOptions",
"(",
"opts",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"ret... | // MarshalProvisionToken marshals provisioning token into JSON. | [
"MarshalProvisionToken",
"marshals",
"provisioning",
"token",
"into",
"JSON",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/provisioning.go#L332-L360 | train |
gravitational/teleport | lib/utils/proxy/proxy.go | NewClientConnWithDeadline | func NewClientConnWithDeadline(conn net.Conn, addr string, config *ssh.ClientConfig) (*ssh.Client, error) {
if config.Timeout > 0 {
conn.SetReadDeadline(time.Now().Add(config.Timeout))
}
c, chans, reqs, err := ssh.NewClientConn(conn, addr, config)
if err != nil {
return nil, err
}
if config.Timeout > 0 {
co... | go | func NewClientConnWithDeadline(conn net.Conn, addr string, config *ssh.ClientConfig) (*ssh.Client, error) {
if config.Timeout > 0 {
conn.SetReadDeadline(time.Now().Add(config.Timeout))
}
c, chans, reqs, err := ssh.NewClientConn(conn, addr, config)
if err != nil {
return nil, err
}
if config.Timeout > 0 {
co... | [
"func",
"NewClientConnWithDeadline",
"(",
"conn",
"net",
".",
"Conn",
",",
"addr",
"string",
",",
"config",
"*",
"ssh",
".",
"ClientConfig",
")",
"(",
"*",
"ssh",
".",
"Client",
",",
"error",
")",
"{",
"if",
"config",
".",
"Timeout",
">",
"0",
"{",
"... | // NewClientConnWithDeadline establishes new client connection with specified deadline | [
"NewClientConnWithDeadline",
"establishes",
"new",
"client",
"connection",
"with",
"specified",
"deadline"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/proxy/proxy.go#L41-L53 | train |
gravitational/teleport | lib/utils/proxy/proxy.go | DialWithDeadline | func DialWithDeadline(network string, addr string, config *ssh.ClientConfig) (*ssh.Client, error) {
conn, err := net.DialTimeout(network, addr, config.Timeout)
if err != nil {
return nil, err
}
return NewClientConnWithDeadline(conn, addr, config)
} | go | func DialWithDeadline(network string, addr string, config *ssh.ClientConfig) (*ssh.Client, error) {
conn, err := net.DialTimeout(network, addr, config.Timeout)
if err != nil {
return nil, err
}
return NewClientConnWithDeadline(conn, addr, config)
} | [
"func",
"DialWithDeadline",
"(",
"network",
"string",
",",
"addr",
"string",
",",
"config",
"*",
"ssh",
".",
"ClientConfig",
")",
"(",
"*",
"ssh",
".",
"Client",
",",
"error",
")",
"{",
"conn",
",",
"err",
":=",
"net",
".",
"DialTimeout",
"(",
"network... | // DialWithDeadline works around the case when net.DialWithTimeout
// succeeds, but key exchange hangs. Setting deadline on connection
// prevents this case from happening | [
"DialWithDeadline",
"works",
"around",
"the",
"case",
"when",
"net",
".",
"DialWithTimeout",
"succeeds",
"but",
"key",
"exchange",
"hangs",
".",
"Setting",
"deadline",
"on",
"connection",
"prevents",
"this",
"case",
"from",
"happening"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/proxy/proxy.go#L58-L64 | train |
gravitational/teleport | lib/utils/proxy/proxy.go | Dial | func (d directDial) Dial(network string, addr string, config *ssh.ClientConfig) (*ssh.Client, error) {
return DialWithDeadline(network, addr, config)
} | go | func (d directDial) Dial(network string, addr string, config *ssh.ClientConfig) (*ssh.Client, error) {
return DialWithDeadline(network, addr, config)
} | [
"func",
"(",
"d",
"directDial",
")",
"Dial",
"(",
"network",
"string",
",",
"addr",
"string",
",",
"config",
"*",
"ssh",
".",
"ClientConfig",
")",
"(",
"*",
"ssh",
".",
"Client",
",",
"error",
")",
"{",
"return",
"DialWithDeadline",
"(",
"network",
","... | // Dial calls ssh.Dial directly. | [
"Dial",
"calls",
"ssh",
".",
"Dial",
"directly",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/proxy/proxy.go#L78-L80 | train |
gravitational/teleport | lib/utils/proxy/proxy.go | Dial | func (d proxyDial) Dial(network string, addr string, config *ssh.ClientConfig) (*ssh.Client, error) {
// Build a proxy connection first.
pconn, err := dialProxy(context.Background(), d.proxyHost, addr)
if err != nil {
return nil, trace.Wrap(err)
}
if config.Timeout > 0 {
pconn.SetReadDeadline(time.Now().Add(co... | go | func (d proxyDial) Dial(network string, addr string, config *ssh.ClientConfig) (*ssh.Client, error) {
// Build a proxy connection first.
pconn, err := dialProxy(context.Background(), d.proxyHost, addr)
if err != nil {
return nil, trace.Wrap(err)
}
if config.Timeout > 0 {
pconn.SetReadDeadline(time.Now().Add(co... | [
"func",
"(",
"d",
"proxyDial",
")",
"Dial",
"(",
"network",
"string",
",",
"addr",
"string",
",",
"config",
"*",
"ssh",
".",
"ClientConfig",
")",
"(",
"*",
"ssh",
".",
"Client",
",",
"error",
")",
"{",
"// Build a proxy connection first.",
"pconn",
",",
... | // Dial first connects to a proxy, then uses the connection to establish a new
// SSH connection. | [
"Dial",
"first",
"connects",
"to",
"a",
"proxy",
"then",
"uses",
"the",
"connection",
"to",
"establish",
"a",
"new",
"SSH",
"connection",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/proxy/proxy.go#L105-L123 | train |
gravitational/teleport | lib/utils/proxy/proxy.go | DialerFromEnvironment | func DialerFromEnvironment(addr string) Dialer {
// Try and get proxy addr from the environment.
proxyAddr := getProxyAddress(addr)
// If no proxy settings are in environment return regular ssh dialer,
// otherwise return a proxy dialer.
if proxyAddr == "" {
log.Debugf("No proxy set in environment, returning di... | go | func DialerFromEnvironment(addr string) Dialer {
// Try and get proxy addr from the environment.
proxyAddr := getProxyAddress(addr)
// If no proxy settings are in environment return regular ssh dialer,
// otherwise return a proxy dialer.
if proxyAddr == "" {
log.Debugf("No proxy set in environment, returning di... | [
"func",
"DialerFromEnvironment",
"(",
"addr",
"string",
")",
"Dialer",
"{",
"// Try and get proxy addr from the environment.",
"proxyAddr",
":=",
"getProxyAddress",
"(",
"addr",
")",
"\n\n",
"// If no proxy settings are in environment return regular ssh dialer,",
"// otherwise retu... | // DialerFromEnvironment returns a Dial function. If the https_proxy or http_proxy
// environment variable are set, it returns a function that will dial through
// said proxy server. If neither variable is set, it will connect to the SSH
// server directly. | [
"DialerFromEnvironment",
"returns",
"a",
"Dial",
"function",
".",
"If",
"the",
"https_proxy",
"or",
"http_proxy",
"environment",
"variable",
"are",
"set",
"it",
"returns",
"a",
"function",
"that",
"will",
"dial",
"through",
"said",
"proxy",
"server",
".",
"If",
... | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/proxy/proxy.go#L129-L141 | train |
gravitational/teleport | lib/backend/etcdbk/etcd.go | New | func New(ctx context.Context, params backend.Params) (*EtcdBackend, error) {
var err error
if params == nil {
return nil, trace.BadParameter("missing etcd configuration")
}
// convert generic backend parameters structure to etcd config:
var cfg *Config
if err = utils.ObjectToStruct(params, &cfg); err != nil {
... | go | func New(ctx context.Context, params backend.Params) (*EtcdBackend, error) {
var err error
if params == nil {
return nil, trace.BadParameter("missing etcd configuration")
}
// convert generic backend parameters structure to etcd config:
var cfg *Config
if err = utils.ObjectToStruct(params, &cfg); err != nil {
... | [
"func",
"New",
"(",
"ctx",
"context",
".",
"Context",
",",
"params",
"backend",
".",
"Params",
")",
"(",
"*",
"EtcdBackend",
",",
"error",
")",
"{",
"var",
"err",
"error",
"\n",
"if",
"params",
"==",
"nil",
"{",
"return",
"nil",
",",
"trace",
".",
... | // New returns new instance of Etcd-powered backend | [
"New",
"returns",
"new",
"instance",
"of",
"Etcd",
"-",
"powered",
"backend"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/backend/etcdbk/etcd.go#L168-L207 | train |
gravitational/teleport | lib/backend/etcdbk/etcd.go | KeepAlive | func (b *EtcdBackend) KeepAlive(ctx context.Context, lease backend.Lease, expires time.Time) error {
if lease.ID == 0 {
return trace.BadParameter("lease is not specified")
}
re, err := b.client.Get(ctx, prependPrefix(lease.Key), clientv3.WithSerializable(), clientv3.WithKeysOnly())
if err != nil {
return conver... | go | func (b *EtcdBackend) KeepAlive(ctx context.Context, lease backend.Lease, expires time.Time) error {
if lease.ID == 0 {
return trace.BadParameter("lease is not specified")
}
re, err := b.client.Get(ctx, prependPrefix(lease.Key), clientv3.WithSerializable(), clientv3.WithKeysOnly())
if err != nil {
return conver... | [
"func",
"(",
"b",
"*",
"EtcdBackend",
")",
"KeepAlive",
"(",
"ctx",
"context",
".",
"Context",
",",
"lease",
"backend",
".",
"Lease",
",",
"expires",
"time",
".",
"Time",
")",
"error",
"{",
"if",
"lease",
".",
"ID",
"==",
"0",
"{",
"return",
"trace",... | // KeepAlive updates TTL on the lease ID | [
"KeepAlive",
"updates",
"TTL",
"on",
"the",
"lease",
"ID"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/backend/etcdbk/etcd.go#L487-L510 | train |
gravitational/teleport | lib/backend/etcdbk/etcd.go | seconds | func seconds(ttl time.Duration) int64 {
i := int64(ttl / time.Second)
if i <= 0 {
i = 1
}
return i
} | go | func seconds(ttl time.Duration) int64 {
i := int64(ttl / time.Second)
if i <= 0 {
i = 1
}
return i
} | [
"func",
"seconds",
"(",
"ttl",
"time",
".",
"Duration",
")",
"int64",
"{",
"i",
":=",
"int64",
"(",
"ttl",
"/",
"time",
".",
"Second",
")",
"\n",
"if",
"i",
"<=",
"0",
"{",
"i",
"=",
"1",
"\n",
"}",
"\n",
"return",
"i",
"\n",
"}"
] | // seconds converts duration to seconds, rounds up to 1 second | [
"seconds",
"converts",
"duration",
"to",
"seconds",
"rounds",
"up",
"to",
"1",
"second"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/backend/etcdbk/etcd.go#L606-L612 | train |
gravitational/teleport | tool/tctl/common/auth_command.go | GenerateKeys | func (a *AuthCommand) GenerateKeys() error {
keygen, err := native.New(context.TODO(), native.PrecomputeKeys(0))
if err != nil {
return trace.Wrap(err)
}
defer keygen.Close()
privBytes, pubBytes, err := keygen.GenerateKeyPair("")
if err != nil {
return trace.Wrap(err)
}
err = ioutil.WriteFile(a.genPubPath, ... | go | func (a *AuthCommand) GenerateKeys() error {
keygen, err := native.New(context.TODO(), native.PrecomputeKeys(0))
if err != nil {
return trace.Wrap(err)
}
defer keygen.Close()
privBytes, pubBytes, err := keygen.GenerateKeyPair("")
if err != nil {
return trace.Wrap(err)
}
err = ioutil.WriteFile(a.genPubPath, ... | [
"func",
"(",
"a",
"*",
"AuthCommand",
")",
"GenerateKeys",
"(",
")",
"error",
"{",
"keygen",
",",
"err",
":=",
"native",
".",
"New",
"(",
"context",
".",
"TODO",
"(",
")",
",",
"native",
".",
"PrecomputeKeys",
"(",
"0",
")",
")",
"\n",
"if",
"err",... | // GenerateKeys generates a new keypair | [
"GenerateKeys",
"generates",
"a",
"new",
"keypair"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/tool/tctl/common/auth_command.go#L219-L241 | train |
gravitational/teleport | tool/tctl/common/auth_command.go | GenerateAndSignKeys | func (a *AuthCommand) GenerateAndSignKeys(clusterApi auth.ClientI) error {
switch {
case a.genUser != "" && a.genHost == "":
return a.generateUserKeys(clusterApi)
case a.genUser == "" && a.genHost != "":
return a.generateHostKeys(clusterApi)
default:
return trace.BadParameter("--user or --host must be specifi... | go | func (a *AuthCommand) GenerateAndSignKeys(clusterApi auth.ClientI) error {
switch {
case a.genUser != "" && a.genHost == "":
return a.generateUserKeys(clusterApi)
case a.genUser == "" && a.genHost != "":
return a.generateHostKeys(clusterApi)
default:
return trace.BadParameter("--user or --host must be specifi... | [
"func",
"(",
"a",
"*",
"AuthCommand",
")",
"GenerateAndSignKeys",
"(",
"clusterApi",
"auth",
".",
"ClientI",
")",
"error",
"{",
"switch",
"{",
"case",
"a",
".",
"genUser",
"!=",
"\"",
"\"",
"&&",
"a",
".",
"genHost",
"==",
"\"",
"\"",
":",
"return",
... | // GenerateAndSignKeys generates a new keypair and signs it for role | [
"GenerateAndSignKeys",
"generates",
"a",
"new",
"keypair",
"and",
"signs",
"it",
"for",
"role"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/tool/tctl/common/auth_command.go#L244-L253 | train |
gravitational/teleport | tool/tctl/common/auth_command.go | RotateCertAuthority | func (a *AuthCommand) RotateCertAuthority(client auth.ClientI) error {
req := auth.RotateRequest{
Type: services.CertAuthType(a.rotateType),
GracePeriod: &a.rotateGracePeriod,
TargetPhase: a.rotateTargetPhase,
}
if a.rotateManualMode {
req.Mode = services.RotationModeManual
} else {
req.Mode = serv... | go | func (a *AuthCommand) RotateCertAuthority(client auth.ClientI) error {
req := auth.RotateRequest{
Type: services.CertAuthType(a.rotateType),
GracePeriod: &a.rotateGracePeriod,
TargetPhase: a.rotateTargetPhase,
}
if a.rotateManualMode {
req.Mode = services.RotationModeManual
} else {
req.Mode = serv... | [
"func",
"(",
"a",
"*",
"AuthCommand",
")",
"RotateCertAuthority",
"(",
"client",
"auth",
".",
"ClientI",
")",
"error",
"{",
"req",
":=",
"auth",
".",
"RotateRequest",
"{",
"Type",
":",
"services",
".",
"CertAuthType",
"(",
"a",
".",
"rotateType",
")",
",... | // RotateCertAuthority starts or restarts certificate authority rotation process | [
"RotateCertAuthority",
"starts",
"or",
"restarts",
"certificate",
"authority",
"rotation",
"process"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/tool/tctl/common/auth_command.go#L256-L277 | train |
gravitational/teleport | lib/backend/legacy/legacy.go | CollectOptions | func CollectOptions(opts []OpOption) (*OpConfig, error) {
cfg := OpConfig{}
for _, o := range opts {
if err := o(&cfg); err != nil {
return nil, trace.Wrap(err)
}
}
return &cfg, nil
} | go | func CollectOptions(opts []OpOption) (*OpConfig, error) {
cfg := OpConfig{}
for _, o := range opts {
if err := o(&cfg); err != nil {
return nil, trace.Wrap(err)
}
}
return &cfg, nil
} | [
"func",
"CollectOptions",
"(",
"opts",
"[",
"]",
"OpOption",
")",
"(",
"*",
"OpConfig",
",",
"error",
")",
"{",
"cfg",
":=",
"OpConfig",
"{",
"}",
"\n",
"for",
"_",
",",
"o",
":=",
"range",
"opts",
"{",
"if",
"err",
":=",
"o",
"(",
"&",
"cfg",
... | // CollectOptions collects all options from functional
// arg and returns config | [
"CollectOptions",
"collects",
"all",
"options",
"from",
"functional",
"arg",
"and",
"returns",
"config"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/backend/legacy/legacy.go#L96-L104 | train |
gravitational/teleport | lib/backend/legacy/legacy.go | ValidateLockTTL | func ValidateLockTTL(ttl time.Duration) error {
if ttl == Forever || ttl > MaxLockDuration {
return trace.BadParameter("locks cannot exceed %v", MaxLockDuration)
}
return nil
} | go | func ValidateLockTTL(ttl time.Duration) error {
if ttl == Forever || ttl > MaxLockDuration {
return trace.BadParameter("locks cannot exceed %v", MaxLockDuration)
}
return nil
} | [
"func",
"ValidateLockTTL",
"(",
"ttl",
"time",
".",
"Duration",
")",
"error",
"{",
"if",
"ttl",
"==",
"Forever",
"||",
"ttl",
">",
"MaxLockDuration",
"{",
"return",
"trace",
".",
"BadParameter",
"(",
"\"",
"\"",
",",
"MaxLockDuration",
")",
"\n",
"}",
"\... | // ValidateLockTTL helper allows all backends to validate lock TTL parameter | [
"ValidateLockTTL",
"helper",
"allows",
"all",
"backends",
"to",
"validate",
"lock",
"TTL",
"parameter"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/backend/legacy/legacy.go#L160-L165 | train |
gravitational/teleport | lib/backend/legacy/legacy.go | TTL | func TTL(clock clockwork.Clock, t time.Time) time.Duration {
if t.IsZero() {
return Forever
}
diff := t.UTC().Sub(clock.Now().UTC())
if diff < 0 {
return Forever
}
return diff
} | go | func TTL(clock clockwork.Clock, t time.Time) time.Duration {
if t.IsZero() {
return Forever
}
diff := t.UTC().Sub(clock.Now().UTC())
if diff < 0 {
return Forever
}
return diff
} | [
"func",
"TTL",
"(",
"clock",
"clockwork",
".",
"Clock",
",",
"t",
"time",
".",
"Time",
")",
"time",
".",
"Duration",
"{",
"if",
"t",
".",
"IsZero",
"(",
")",
"{",
"return",
"Forever",
"\n",
"}",
"\n",
"diff",
":=",
"t",
".",
"UTC",
"(",
")",
".... | // TTL converts time to TTL from current time supplied
// by provider, if t is zero, returns forever | [
"TTL",
"converts",
"time",
"to",
"TTL",
"from",
"current",
"time",
"supplied",
"by",
"provider",
"if",
"t",
"is",
"zero",
"returns",
"forever"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/backend/legacy/legacy.go#L180-L189 | train |
Subsets and Splits
SQL Console for semeru/code-text-go
Retrieves a limited set of code samples with their languages, with a specific case adjustment for 'Go' language.