repo stringlengths 5 54 | path stringlengths 4 155 | func_name stringlengths 1 118 | original_string stringlengths 52 85.5k | language stringclasses 1
value | code stringlengths 52 85.5k | code_tokens list | docstring stringlengths 6 2.61k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 85 252 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
gravitational/teleport | lib/services/tunnelconn.go | String | func (r *TunnelConnectionV2) String() string {
return fmt.Sprintf("TunnelConnection(name=%v, type=%v, cluster=%v, proxy=%v)",
r.Metadata.Name, r.Spec.Type, r.Spec.ClusterName, r.Spec.ProxyName)
} | go | func (r *TunnelConnectionV2) String() string {
return fmt.Sprintf("TunnelConnection(name=%v, type=%v, cluster=%v, proxy=%v)",
r.Metadata.Name, r.Spec.Type, r.Spec.ClusterName, r.Spec.ProxyName)
} | [
"func",
"(",
"r",
"*",
"TunnelConnectionV2",
")",
"String",
"(",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"r",
".",
"Metadata",
".",
"Name",
",",
"r",
".",
"Spec",
".",
"Type",
",",
"r",
".",
"Spec",
".",
"Cluste... | // String returns user-friendly description of this connection | [
"String",
"returns",
"user",
"-",
"friendly",
"description",
"of",
"this",
"connection"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/tunnelconn.go#L151-L154 | train |
gravitational/teleport | lib/services/tunnelconn.go | SetLastHeartbeat | func (r *TunnelConnectionV2) SetLastHeartbeat(tm time.Time) {
r.Spec.LastHeartbeat = tm
} | go | func (r *TunnelConnectionV2) SetLastHeartbeat(tm time.Time) {
r.Spec.LastHeartbeat = tm
} | [
"func",
"(",
"r",
"*",
"TunnelConnectionV2",
")",
"SetLastHeartbeat",
"(",
"tm",
"time",
".",
"Time",
")",
"{",
"r",
".",
"Spec",
".",
"LastHeartbeat",
"=",
"tm",
"\n",
"}"
] | // SetLastHeartbeat sets last heartbeat time | [
"SetLastHeartbeat",
"sets",
"last",
"heartbeat",
"time"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/tunnelconn.go#L221-L223 | train |
gravitational/teleport | lib/services/tunnelconn.go | UnmarshalTunnelConnection | func UnmarshalTunnelConnection(data []byte, opts ...MarshalOption) (TunnelConnection, error) {
if len(data) == 0 {
return nil, trace.BadParameter("missing tunnel connection data")
}
cfg, err := collectOptions(opts)
if err != nil {
return nil, trace.Wrap(err)
}
var h ResourceHeader
err = utils.FastUnmarshal(d... | go | func UnmarshalTunnelConnection(data []byte, opts ...MarshalOption) (TunnelConnection, error) {
if len(data) == 0 {
return nil, trace.BadParameter("missing tunnel connection data")
}
cfg, err := collectOptions(opts)
if err != nil {
return nil, trace.Wrap(err)
}
var h ResourceHeader
err = utils.FastUnmarshal(d... | [
"func",
"UnmarshalTunnelConnection",
"(",
"data",
"[",
"]",
"byte",
",",
"opts",
"...",
"MarshalOption",
")",
"(",
"TunnelConnection",
",",
"error",
")",
"{",
"if",
"len",
"(",
"data",
")",
"==",
"0",
"{",
"return",
"nil",
",",
"trace",
".",
"BadParamete... | // UnmarshalTunnelConnection unmarshals reverse tunnel from JSON or YAML,
// sets defaults and checks the schema | [
"UnmarshalTunnelConnection",
"unmarshals",
"reverse",
"tunnel",
"from",
"JSON",
"or",
"YAML",
"sets",
"defaults",
"and",
"checks",
"the",
"schema"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/tunnelconn.go#L275-L314 | train |
gravitational/teleport | lib/services/tunnelconn.go | MarshalTunnelConnection | func MarshalTunnelConnection(rt TunnelConnection, opts ...MarshalOption) ([]byte, error) {
cfg, err := collectOptions(opts)
if err != nil {
return nil, trace.Wrap(err)
}
switch resource := rt.(type) {
case *TunnelConnectionV2:
if !cfg.PreserveResourceID {
// avoid modifying the original object
// to prev... | go | func MarshalTunnelConnection(rt TunnelConnection, opts ...MarshalOption) ([]byte, error) {
cfg, err := collectOptions(opts)
if err != nil {
return nil, trace.Wrap(err)
}
switch resource := rt.(type) {
case *TunnelConnectionV2:
if !cfg.PreserveResourceID {
// avoid modifying the original object
// to prev... | [
"func",
"MarshalTunnelConnection",
"(",
"rt",
"TunnelConnection",
",",
"opts",
"...",
"MarshalOption",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"cfg",
",",
"err",
":=",
"collectOptions",
"(",
"opts",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
... | // MarshalTunnelConnection marshals tunnel connection | [
"MarshalTunnelConnection",
"marshals",
"tunnel",
"connection"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/tunnelconn.go#L317-L335 | train |
gravitational/teleport | tool/tctl/common/status_command.go | Initialize | func (c *StatusCommand) Initialize(app *kingpin.Application, config *service.Config) {
c.config = config
c.status = app.Command("status", "Report cluster status")
} | go | func (c *StatusCommand) Initialize(app *kingpin.Application, config *service.Config) {
c.config = config
c.status = app.Command("status", "Report cluster status")
} | [
"func",
"(",
"c",
"*",
"StatusCommand",
")",
"Initialize",
"(",
"app",
"*",
"kingpin",
".",
"Application",
",",
"config",
"*",
"service",
".",
"Config",
")",
"{",
"c",
".",
"config",
"=",
"config",
"\n",
"c",
".",
"status",
"=",
"app",
".",
"Command"... | // Initialize allows StatusCommand to plug itself into the CLI parser. | [
"Initialize",
"allows",
"StatusCommand",
"to",
"plug",
"itself",
"into",
"the",
"CLI",
"parser",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/tool/tctl/common/status_command.go#L41-L44 | train |
gravitational/teleport | tool/tctl/common/status_command.go | Status | func (c *StatusCommand) Status(client auth.ClientI) error {
clusterNameResource, err := client.GetClusterName()
if err != nil {
return trace.Wrap(err)
}
clusterName := clusterNameResource.GetClusterName()
hostCAs, err := client.GetCertAuthorities(services.HostCA, false)
if err != nil {
return trace.Wrap(err)... | go | func (c *StatusCommand) Status(client auth.ClientI) error {
clusterNameResource, err := client.GetClusterName()
if err != nil {
return trace.Wrap(err)
}
clusterName := clusterNameResource.GetClusterName()
hostCAs, err := client.GetCertAuthorities(services.HostCA, false)
if err != nil {
return trace.Wrap(err)... | [
"func",
"(",
"c",
"*",
"StatusCommand",
")",
"Status",
"(",
"client",
"auth",
".",
"ClientI",
")",
"error",
"{",
"clusterNameResource",
",",
"err",
":=",
"client",
".",
"GetClusterName",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"trace",
... | // Status is called to execute "status" CLI command. | [
"Status",
"is",
"called",
"to",
"execute",
"status",
"CLI",
"command",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/tool/tctl/common/status_command.go#L58-L126 | train |
gravitational/teleport | lib/auth/trustedcluster.go | DeleteTrustedCluster | func (a *AuthServer) DeleteTrustedCluster(name string) error {
err := a.DeleteCertAuthority(services.CertAuthID{Type: services.HostCA, DomainName: name})
if err != nil {
if !trace.IsNotFound(err) {
return trace.Wrap(err)
}
}
err = a.DeleteCertAuthority(services.CertAuthID{Type: services.UserCA, DomainName: ... | go | func (a *AuthServer) DeleteTrustedCluster(name string) error {
err := a.DeleteCertAuthority(services.CertAuthID{Type: services.HostCA, DomainName: name})
if err != nil {
if !trace.IsNotFound(err) {
return trace.Wrap(err)
}
}
err = a.DeleteCertAuthority(services.CertAuthID{Type: services.UserCA, DomainName: ... | [
"func",
"(",
"a",
"*",
"AuthServer",
")",
"DeleteTrustedCluster",
"(",
"name",
"string",
")",
"error",
"{",
"err",
":=",
"a",
".",
"DeleteCertAuthority",
"(",
"services",
".",
"CertAuthID",
"{",
"Type",
":",
"services",
".",
"HostCA",
",",
"DomainName",
":... | // DeleteTrustedCluster removes services.CertAuthority, services.ReverseTunnel,
// and services.TrustedCluster resources. | [
"DeleteTrustedCluster",
"removes",
"services",
".",
"CertAuthority",
"services",
".",
"ReverseTunnel",
"and",
"services",
".",
"TrustedCluster",
"resources",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/trustedcluster.go#L171-L199 | train |
gravitational/teleport | lib/auth/trustedcluster.go | DeleteRemoteCluster | func (a *AuthServer) DeleteRemoteCluster(clusterName string) error {
// To make sure remote cluster exists - to protect against random
// clusterName requests (e.g. when clusterName is set to local cluster name)
_, err := a.Presence.GetRemoteCluster(clusterName)
if err != nil {
return trace.Wrap(err)
}
// delet... | go | func (a *AuthServer) DeleteRemoteCluster(clusterName string) error {
// To make sure remote cluster exists - to protect against random
// clusterName requests (e.g. when clusterName is set to local cluster name)
_, err := a.Presence.GetRemoteCluster(clusterName)
if err != nil {
return trace.Wrap(err)
}
// delet... | [
"func",
"(",
"a",
"*",
"AuthServer",
")",
"DeleteRemoteCluster",
"(",
"clusterName",
"string",
")",
"error",
"{",
"// To make sure remote cluster exists - to protect against random",
"// clusterName requests (e.g. when clusterName is set to local cluster name)",
"_",
",",
"err",
... | // DeleteRemoteCluster deletes remote cluster resource, all certificate authorities
// associated with it | [
"DeleteRemoteCluster",
"deletes",
"remote",
"cluster",
"resource",
"all",
"certificate",
"authorities",
"associated",
"with",
"it"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/trustedcluster.go#L293-L325 | train |
gravitational/teleport | lib/auth/trustedcluster.go | GetRemoteCluster | func (a *AuthServer) GetRemoteCluster(clusterName string) (services.RemoteCluster, error) {
// To make sure remote cluster exists - to protect against random
// clusterName requests (e.g. when clusterName is set to local cluster name)
remoteCluster, err := a.Presence.GetRemoteCluster(clusterName)
if err != nil {
... | go | func (a *AuthServer) GetRemoteCluster(clusterName string) (services.RemoteCluster, error) {
// To make sure remote cluster exists - to protect against random
// clusterName requests (e.g. when clusterName is set to local cluster name)
remoteCluster, err := a.Presence.GetRemoteCluster(clusterName)
if err != nil {
... | [
"func",
"(",
"a",
"*",
"AuthServer",
")",
"GetRemoteCluster",
"(",
"clusterName",
"string",
")",
"(",
"services",
".",
"RemoteCluster",
",",
"error",
")",
"{",
"// To make sure remote cluster exists - to protect against random",
"// clusterName requests (e.g. when clusterName... | // GetRemoteCluster returns remote cluster by name | [
"GetRemoteCluster",
"returns",
"remote",
"cluster",
"by",
"name"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/trustedcluster.go#L328-L339 | train |
gravitational/teleport | lib/auth/trustedcluster.go | GetRemoteClusters | func (a *AuthServer) GetRemoteClusters(opts ...services.MarshalOption) ([]services.RemoteCluster, error) {
// To make sure remote cluster exists - to protect against random
// clusterName requests (e.g. when clusterName is set to local cluster name)
remoteClusters, err := a.Presence.GetRemoteClusters(opts...)
if er... | go | func (a *AuthServer) GetRemoteClusters(opts ...services.MarshalOption) ([]services.RemoteCluster, error) {
// To make sure remote cluster exists - to protect against random
// clusterName requests (e.g. when clusterName is set to local cluster name)
remoteClusters, err := a.Presence.GetRemoteClusters(opts...)
if er... | [
"func",
"(",
"a",
"*",
"AuthServer",
")",
"GetRemoteClusters",
"(",
"opts",
"...",
"services",
".",
"MarshalOption",
")",
"(",
"[",
"]",
"services",
".",
"RemoteCluster",
",",
"error",
")",
"{",
"// To make sure remote cluster exists - to protect against random",
"/... | // GetRemoteClusters returns remote clusters with updated statuses | [
"GetRemoteClusters",
"returns",
"remote",
"clusters",
"with",
"updated",
"statuses"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/trustedcluster.go#L357-L370 | train |
gravitational/teleport | lib/auth/trustedcluster.go | activateCertAuthority | func (a *AuthServer) activateCertAuthority(t services.TrustedCluster) error {
err := a.ActivateCertAuthority(services.CertAuthID{Type: services.UserCA, DomainName: t.GetName()})
if err != nil {
return trace.Wrap(err)
}
return trace.Wrap(a.ActivateCertAuthority(services.CertAuthID{Type: services.HostCA, DomainNam... | go | func (a *AuthServer) activateCertAuthority(t services.TrustedCluster) error {
err := a.ActivateCertAuthority(services.CertAuthID{Type: services.UserCA, DomainName: t.GetName()})
if err != nil {
return trace.Wrap(err)
}
return trace.Wrap(a.ActivateCertAuthority(services.CertAuthID{Type: services.HostCA, DomainNam... | [
"func",
"(",
"a",
"*",
"AuthServer",
")",
"activateCertAuthority",
"(",
"t",
"services",
".",
"TrustedCluster",
")",
"error",
"{",
"err",
":=",
"a",
".",
"ActivateCertAuthority",
"(",
"services",
".",
"CertAuthID",
"{",
"Type",
":",
"services",
".",
"UserCA"... | // activateCertAuthority will activate both the user and host certificate
// authority given in the services.TrustedCluster resource. | [
"activateCertAuthority",
"will",
"activate",
"both",
"the",
"user",
"and",
"host",
"certificate",
"authority",
"given",
"in",
"the",
"services",
".",
"TrustedCluster",
"resource",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/trustedcluster.go#L599-L606 | train |
gravitational/teleport | lib/auth/trustedcluster.go | createReverseTunnel | func (a *AuthServer) createReverseTunnel(t services.TrustedCluster) error {
reverseTunnel := services.NewReverseTunnel(
t.GetName(),
[]string{t.GetReverseTunnelAddress()},
)
return trace.Wrap(a.UpsertReverseTunnel(reverseTunnel))
} | go | func (a *AuthServer) createReverseTunnel(t services.TrustedCluster) error {
reverseTunnel := services.NewReverseTunnel(
t.GetName(),
[]string{t.GetReverseTunnelAddress()},
)
return trace.Wrap(a.UpsertReverseTunnel(reverseTunnel))
} | [
"func",
"(",
"a",
"*",
"AuthServer",
")",
"createReverseTunnel",
"(",
"t",
"services",
".",
"TrustedCluster",
")",
"error",
"{",
"reverseTunnel",
":=",
"services",
".",
"NewReverseTunnel",
"(",
"t",
".",
"GetName",
"(",
")",
",",
"[",
"]",
"string",
"{",
... | // createReverseTunnel will create a services.ReverseTunnel givenin the
// services.TrustedCluster resource. | [
"createReverseTunnel",
"will",
"create",
"a",
"services",
".",
"ReverseTunnel",
"givenin",
"the",
"services",
".",
"TrustedCluster",
"resource",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/trustedcluster.go#L621-L627 | train |
gravitational/teleport | lib/services/local/configuration.go | DeleteClusterName | func (s *ClusterConfigurationService) DeleteClusterName() error {
err := s.Delete(context.TODO(), backend.Key(clusterConfigPrefix, namePrefix))
if err != nil {
if trace.IsNotFound(err) {
return trace.NotFound("cluster configuration not found")
}
return trace.Wrap(err)
}
return nil
} | go | func (s *ClusterConfigurationService) DeleteClusterName() error {
err := s.Delete(context.TODO(), backend.Key(clusterConfigPrefix, namePrefix))
if err != nil {
if trace.IsNotFound(err) {
return trace.NotFound("cluster configuration not found")
}
return trace.Wrap(err)
}
return nil
} | [
"func",
"(",
"s",
"*",
"ClusterConfigurationService",
")",
"DeleteClusterName",
"(",
")",
"error",
"{",
"err",
":=",
"s",
".",
"Delete",
"(",
"context",
".",
"TODO",
"(",
")",
",",
"backend",
".",
"Key",
"(",
"clusterConfigPrefix",
",",
"namePrefix",
")",
... | // DeleteClusterName deletes services.ClusterName from the backend. | [
"DeleteClusterName",
"deletes",
"services",
".",
"ClusterName",
"from",
"the",
"backend",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/local/configuration.go#L54-L63 | train |
gravitational/teleport | lib/services/local/configuration.go | SetClusterName | func (s *ClusterConfigurationService) SetClusterName(c services.ClusterName) error {
value, err := services.GetClusterNameMarshaler().Marshal(c)
if err != nil {
return trace.Wrap(err)
}
_, err = s.Create(context.TODO(), backend.Item{
Key: backend.Key(clusterConfigPrefix, namePrefix),
Value: value,
Ex... | go | func (s *ClusterConfigurationService) SetClusterName(c services.ClusterName) error {
value, err := services.GetClusterNameMarshaler().Marshal(c)
if err != nil {
return trace.Wrap(err)
}
_, err = s.Create(context.TODO(), backend.Item{
Key: backend.Key(clusterConfigPrefix, namePrefix),
Value: value,
Ex... | [
"func",
"(",
"s",
"*",
"ClusterConfigurationService",
")",
"SetClusterName",
"(",
"c",
"services",
".",
"ClusterName",
")",
"error",
"{",
"value",
",",
"err",
":=",
"services",
".",
"GetClusterNameMarshaler",
"(",
")",
".",
"Marshal",
"(",
"c",
")",
"\n",
... | // SetClusterName sets the name of the cluster in the backend. SetClusterName
// can only be called once on a cluster after which it will return trace.AlreadyExists. | [
"SetClusterName",
"sets",
"the",
"name",
"of",
"the",
"cluster",
"in",
"the",
"backend",
".",
"SetClusterName",
"can",
"only",
"be",
"called",
"once",
"on",
"a",
"cluster",
"after",
"which",
"it",
"will",
"return",
"trace",
".",
"AlreadyExists",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/local/configuration.go#L67-L83 | train |
gravitational/teleport | lib/services/local/configuration.go | GetAuthPreference | func (s *ClusterConfigurationService) GetAuthPreference() (services.AuthPreference, error) {
item, err := s.Get(context.TODO(), backend.Key(authPrefix, preferencePrefix, generalPrefix))
if err != nil {
if trace.IsNotFound(err) {
return nil, trace.NotFound("authentication preference not found")
}
return nil, ... | go | func (s *ClusterConfigurationService) GetAuthPreference() (services.AuthPreference, error) {
item, err := s.Get(context.TODO(), backend.Key(authPrefix, preferencePrefix, generalPrefix))
if err != nil {
if trace.IsNotFound(err) {
return nil, trace.NotFound("authentication preference not found")
}
return nil, ... | [
"func",
"(",
"s",
"*",
"ClusterConfigurationService",
")",
"GetAuthPreference",
"(",
")",
"(",
"services",
".",
"AuthPreference",
",",
"error",
")",
"{",
"item",
",",
"err",
":=",
"s",
".",
"Get",
"(",
"context",
".",
"TODO",
"(",
")",
",",
"backend",
... | // GetAuthPreference fetches the cluster authentication preferences
// from the backend and return them. | [
"GetAuthPreference",
"fetches",
"the",
"cluster",
"authentication",
"preferences",
"from",
"the",
"backend",
"and",
"return",
"them",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/local/configuration.go#L151-L161 | train |
gravitational/teleport | lib/services/local/configuration.go | SetAuthPreference | func (s *ClusterConfigurationService) SetAuthPreference(preferences services.AuthPreference) error {
value, err := services.GetAuthPreferenceMarshaler().Marshal(preferences)
if err != nil {
return trace.Wrap(err)
}
item := backend.Item{
Key: backend.Key(authPrefix, preferencePrefix, generalPrefix),
Value: ... | go | func (s *ClusterConfigurationService) SetAuthPreference(preferences services.AuthPreference) error {
value, err := services.GetAuthPreferenceMarshaler().Marshal(preferences)
if err != nil {
return trace.Wrap(err)
}
item := backend.Item{
Key: backend.Key(authPrefix, preferencePrefix, generalPrefix),
Value: ... | [
"func",
"(",
"s",
"*",
"ClusterConfigurationService",
")",
"SetAuthPreference",
"(",
"preferences",
"services",
".",
"AuthPreference",
")",
"error",
"{",
"value",
",",
"err",
":=",
"services",
".",
"GetAuthPreferenceMarshaler",
"(",
")",
".",
"Marshal",
"(",
"pr... | // SetAuthPreference sets the cluster authentication preferences
// on the backend. | [
"SetAuthPreference",
"sets",
"the",
"cluster",
"authentication",
"preferences",
"on",
"the",
"backend",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/local/configuration.go#L165-L183 | train |
gravitational/teleport | lib/services/local/configuration.go | DeleteClusterConfig | func (s *ClusterConfigurationService) DeleteClusterConfig() error {
err := s.Delete(context.TODO(), backend.Key(clusterConfigPrefix, generalPrefix))
if err != nil {
if trace.IsNotFound(err) {
return trace.NotFound("cluster configuration not found")
}
return trace.Wrap(err)
}
return nil
} | go | func (s *ClusterConfigurationService) DeleteClusterConfig() error {
err := s.Delete(context.TODO(), backend.Key(clusterConfigPrefix, generalPrefix))
if err != nil {
if trace.IsNotFound(err) {
return trace.NotFound("cluster configuration not found")
}
return trace.Wrap(err)
}
return nil
} | [
"func",
"(",
"s",
"*",
"ClusterConfigurationService",
")",
"DeleteClusterConfig",
"(",
")",
"error",
"{",
"err",
":=",
"s",
".",
"Delete",
"(",
"context",
".",
"TODO",
"(",
")",
",",
"backend",
".",
"Key",
"(",
"clusterConfigPrefix",
",",
"generalPrefix",
... | // DeleteClusterConfig deletes services.ClusterConfig from the backend. | [
"DeleteClusterConfig",
"deletes",
"services",
".",
"ClusterConfig",
"from",
"the",
"backend",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/local/configuration.go#L200-L209 | train |
gravitational/teleport | lib/services/local/configuration.go | SetClusterConfig | func (s *ClusterConfigurationService) SetClusterConfig(c services.ClusterConfig) error {
value, err := services.GetClusterConfigMarshaler().Marshal(c)
if err != nil {
return trace.Wrap(err)
}
item := backend.Item{
Key: backend.Key(clusterConfigPrefix, generalPrefix),
Value: value,
ID: c.GetResourceID(... | go | func (s *ClusterConfigurationService) SetClusterConfig(c services.ClusterConfig) error {
value, err := services.GetClusterConfigMarshaler().Marshal(c)
if err != nil {
return trace.Wrap(err)
}
item := backend.Item{
Key: backend.Key(clusterConfigPrefix, generalPrefix),
Value: value,
ID: c.GetResourceID(... | [
"func",
"(",
"s",
"*",
"ClusterConfigurationService",
")",
"SetClusterConfig",
"(",
"c",
"services",
".",
"ClusterConfig",
")",
"error",
"{",
"value",
",",
"err",
":=",
"services",
".",
"GetClusterConfigMarshaler",
"(",
")",
".",
"Marshal",
"(",
"c",
")",
"\... | // SetClusterConfig sets services.ClusterConfig on the backend. | [
"SetClusterConfig",
"sets",
"services",
".",
"ClusterConfig",
"on",
"the",
"backend",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/local/configuration.go#L212-L230 | train |
gravitational/teleport | lib/httplib/httpheaders.go | SetNoCacheHeaders | func SetNoCacheHeaders(h http.Header) {
h.Set("Cache-Control", "no-cache, no-store, must-revalidate")
h.Set("Pragma", "no-cache")
h.Set("Expires", "0")
} | go | func SetNoCacheHeaders(h http.Header) {
h.Set("Cache-Control", "no-cache, no-store, must-revalidate")
h.Set("Pragma", "no-cache")
h.Set("Expires", "0")
} | [
"func",
"SetNoCacheHeaders",
"(",
"h",
"http",
".",
"Header",
")",
"{",
"h",
".",
"Set",
"(",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"h",
".",
"Set",
"(",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"h",
".",
"Set",
"(",
"\"",
"\"",
",",
"\"",... | // SetNoCacheHeaders tells proxies and browsers do not cache the content | [
"SetNoCacheHeaders",
"tells",
"proxies",
"and",
"browsers",
"do",
"not",
"cache",
"the",
"content"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/httplib/httpheaders.go#L27-L31 | train |
gravitational/teleport | lib/httplib/httpheaders.go | SetIndexHTMLHeaders | func SetIndexHTMLHeaders(h http.Header) {
SetNoCacheHeaders(h)
SetSameOriginIFrame(h)
SetNoSniff(h)
// X-Frame-Options indicates that the page can only be displayed in iframe on the same origin as the page itself
h.Set("X-Frame-Options", "SAMEORIGIN")
// X-XSS-Protection is a feature of Internet Explorer, Chrom... | go | func SetIndexHTMLHeaders(h http.Header) {
SetNoCacheHeaders(h)
SetSameOriginIFrame(h)
SetNoSniff(h)
// X-Frame-Options indicates that the page can only be displayed in iframe on the same origin as the page itself
h.Set("X-Frame-Options", "SAMEORIGIN")
// X-XSS-Protection is a feature of Internet Explorer, Chrom... | [
"func",
"SetIndexHTMLHeaders",
"(",
"h",
"http",
".",
"Header",
")",
"{",
"SetNoCacheHeaders",
"(",
"h",
")",
"\n",
"SetSameOriginIFrame",
"(",
"h",
")",
"\n",
"SetNoSniff",
"(",
"h",
")",
"\n\n",
"// X-Frame-Options indicates that the page can only be displayed in if... | // SetIndexHTMLHeaders sets security header flags for main index.html page | [
"SetIndexHTMLHeaders",
"sets",
"security",
"header",
"flags",
"for",
"main",
"index",
".",
"html",
"page"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/httplib/httpheaders.go#L40-L70 | train |
gravitational/teleport | lib/kube/proxy/roundtrip.go | NewSpdyRoundTripperWithDialer | func NewSpdyRoundTripperWithDialer(cfg roundTripperConfig) *SpdyRoundTripper {
return &SpdyRoundTripper{tlsConfig: cfg.tlsConfig, followRedirects: cfg.followRedirects, dialWithContext: cfg.dial, ctx: cfg.ctx, authCtx: cfg.authCtx, bearerToken: cfg.bearerToken}
} | go | func NewSpdyRoundTripperWithDialer(cfg roundTripperConfig) *SpdyRoundTripper {
return &SpdyRoundTripper{tlsConfig: cfg.tlsConfig, followRedirects: cfg.followRedirects, dialWithContext: cfg.dial, ctx: cfg.ctx, authCtx: cfg.authCtx, bearerToken: cfg.bearerToken}
} | [
"func",
"NewSpdyRoundTripperWithDialer",
"(",
"cfg",
"roundTripperConfig",
")",
"*",
"SpdyRoundTripper",
"{",
"return",
"&",
"SpdyRoundTripper",
"{",
"tlsConfig",
":",
"cfg",
".",
"tlsConfig",
",",
"followRedirects",
":",
"cfg",
".",
"followRedirects",
",",
"dialWit... | // NewSpdyRoundTripperWithDialer creates a new SpdyRoundTripper that will use
// the specified tlsConfig. This function is mostly meant for unit tests. | [
"NewSpdyRoundTripperWithDialer",
"creates",
"a",
"new",
"SpdyRoundTripper",
"that",
"will",
"use",
"the",
"specified",
"tlsConfig",
".",
"This",
"function",
"is",
"mostly",
"meant",
"for",
"unit",
"tests",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/kube/proxy/roundtrip.go#L99-L101 | train |
gravitational/teleport | lib/kube/proxy/roundtrip.go | dial | func (s *SpdyRoundTripper) dial(req *http.Request) (net.Conn, error) {
return s.dialWithoutProxy(req.URL)
} | go | func (s *SpdyRoundTripper) dial(req *http.Request) (net.Conn, error) {
return s.dialWithoutProxy(req.URL)
} | [
"func",
"(",
"s",
"*",
"SpdyRoundTripper",
")",
"dial",
"(",
"req",
"*",
"http",
".",
"Request",
")",
"(",
"net",
".",
"Conn",
",",
"error",
")",
"{",
"return",
"s",
".",
"dialWithoutProxy",
"(",
"req",
".",
"URL",
")",
"\n",
"}"
] | // dial dials the host specified by req | [
"dial",
"dials",
"the",
"host",
"specified",
"by",
"req"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/kube/proxy/roundtrip.go#L125-L127 | train |
gravitational/teleport | lib/srv/authhandlers.go | CreateIdentityContext | func (h *AuthHandlers) CreateIdentityContext(sconn *ssh.ServerConn) (IdentityContext, error) {
identity := IdentityContext{
TeleportUser: sconn.Permissions.Extensions[utils.CertTeleportUser],
Certificate: []byte(sconn.Permissions.Extensions[utils.CertTeleportUserCertificate]),
Login: sconn.User(),
}
c... | go | func (h *AuthHandlers) CreateIdentityContext(sconn *ssh.ServerConn) (IdentityContext, error) {
identity := IdentityContext{
TeleportUser: sconn.Permissions.Extensions[utils.CertTeleportUser],
Certificate: []byte(sconn.Permissions.Extensions[utils.CertTeleportUserCertificate]),
Login: sconn.User(),
}
c... | [
"func",
"(",
"h",
"*",
"AuthHandlers",
")",
"CreateIdentityContext",
"(",
"sconn",
"*",
"ssh",
".",
"ServerConn",
")",
"(",
"IdentityContext",
",",
"error",
")",
"{",
"identity",
":=",
"IdentityContext",
"{",
"TeleportUser",
":",
"sconn",
".",
"Permissions",
... | // BuildIdentityContext returns an IdentityContext populated with information
// about the logged in user on the connection. | [
"BuildIdentityContext",
"returns",
"an",
"IdentityContext",
"populated",
"with",
"information",
"about",
"the",
"logged",
"in",
"user",
"on",
"the",
"connection",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/srv/authhandlers.go#L59-L92 | train |
gravitational/teleport | lib/srv/authhandlers.go | CheckAgentForward | func (h *AuthHandlers) CheckAgentForward(ctx *ServerContext) error {
if err := ctx.Identity.RoleSet.CheckAgentForward(ctx.Identity.Login); err != nil {
return trace.Wrap(err)
}
return nil
} | go | func (h *AuthHandlers) CheckAgentForward(ctx *ServerContext) error {
if err := ctx.Identity.RoleSet.CheckAgentForward(ctx.Identity.Login); err != nil {
return trace.Wrap(err)
}
return nil
} | [
"func",
"(",
"h",
"*",
"AuthHandlers",
")",
"CheckAgentForward",
"(",
"ctx",
"*",
"ServerContext",
")",
"error",
"{",
"if",
"err",
":=",
"ctx",
".",
"Identity",
".",
"RoleSet",
".",
"CheckAgentForward",
"(",
"ctx",
".",
"Identity",
".",
"Login",
")",
";"... | // CheckAgentForward checks if agent forwarding is allowed for the users RoleSet. | [
"CheckAgentForward",
"checks",
"if",
"agent",
"forwarding",
"is",
"allowed",
"for",
"the",
"users",
"RoleSet",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/srv/authhandlers.go#L95-L101 | train |
gravitational/teleport | lib/srv/authhandlers.go | CheckPortForward | func (h *AuthHandlers) CheckPortForward(addr string, ctx *ServerContext) error {
if ok := ctx.Identity.RoleSet.CanPortForward(); !ok {
systemErrorMessage := fmt.Sprintf("port forwarding not allowed by role set: %v", ctx.Identity.RoleSet)
userErrorMessage := "port forwarding not allowed"
// emit port forward fai... | go | func (h *AuthHandlers) CheckPortForward(addr string, ctx *ServerContext) error {
if ok := ctx.Identity.RoleSet.CanPortForward(); !ok {
systemErrorMessage := fmt.Sprintf("port forwarding not allowed by role set: %v", ctx.Identity.RoleSet)
userErrorMessage := "port forwarding not allowed"
// emit port forward fai... | [
"func",
"(",
"h",
"*",
"AuthHandlers",
")",
"CheckPortForward",
"(",
"addr",
"string",
",",
"ctx",
"*",
"ServerContext",
")",
"error",
"{",
"if",
"ok",
":=",
"ctx",
".",
"Identity",
".",
"RoleSet",
".",
"CanPortForward",
"(",
")",
";",
"!",
"ok",
"{",
... | // CheckPortForward checks if port forwarding is allowed for the users RoleSet. | [
"CheckPortForward",
"checks",
"if",
"port",
"forwarding",
"is",
"allowed",
"for",
"the",
"users",
"RoleSet",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/srv/authhandlers.go#L104-L125 | train |
gravitational/teleport | lib/srv/authhandlers.go | HostKeyAuth | func (h *AuthHandlers) HostKeyAuth(addr string, remote net.Addr, key ssh.PublicKey) error {
fingerprint := fmt.Sprintf("%v %v", key.Type(), sshutils.Fingerprint(key))
// update entry to include a fingerprint of the key so admins can track down
// the key causing problems
h.Entry = log.WithFields(log.Fields{
trac... | go | func (h *AuthHandlers) HostKeyAuth(addr string, remote net.Addr, key ssh.PublicKey) error {
fingerprint := fmt.Sprintf("%v %v", key.Type(), sshutils.Fingerprint(key))
// update entry to include a fingerprint of the key so admins can track down
// the key causing problems
h.Entry = log.WithFields(log.Fields{
trac... | [
"func",
"(",
"h",
"*",
"AuthHandlers",
")",
"HostKeyAuth",
"(",
"addr",
"string",
",",
"remote",
"net",
".",
"Addr",
",",
"key",
"ssh",
".",
"PublicKey",
")",
"error",
"{",
"fingerprint",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"key",
".",... | // HostKeyAuth implements host key verification and is called by the client
// to validate the certificate presented by the target server. If the target
// server presents a SSH certificate, we validate that it was Teleport that
// generated the certificate. If the target server presents a public key, if
// we are stri... | [
"HostKeyAuth",
"implements",
"host",
"key",
"verification",
"and",
"is",
"called",
"by",
"the",
"client",
"to",
"validate",
"the",
"certificate",
"presented",
"by",
"the",
"target",
"server",
".",
"If",
"the",
"target",
"server",
"presents",
"a",
"SSH",
"certi... | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/srv/authhandlers.go#L237-L263 | train |
gravitational/teleport | lib/srv/authhandlers.go | hostKeyCallback | func (h *AuthHandlers) hostKeyCallback(hostname string, remote net.Addr, key ssh.PublicKey) error {
// If strict host key checking is enabled, reject host key fallback.
clusterConfig, err := h.AccessPoint.GetClusterConfig()
if err != nil {
return trace.Wrap(err)
}
if clusterConfig.GetProxyChecksHostKeys() == ser... | go | func (h *AuthHandlers) hostKeyCallback(hostname string, remote net.Addr, key ssh.PublicKey) error {
// If strict host key checking is enabled, reject host key fallback.
clusterConfig, err := h.AccessPoint.GetClusterConfig()
if err != nil {
return trace.Wrap(err)
}
if clusterConfig.GetProxyChecksHostKeys() == ser... | [
"func",
"(",
"h",
"*",
"AuthHandlers",
")",
"hostKeyCallback",
"(",
"hostname",
"string",
",",
"remote",
"net",
".",
"Addr",
",",
"key",
"ssh",
".",
"PublicKey",
")",
"error",
"{",
"// If strict host key checking is enabled, reject host key fallback.",
"clusterConfig"... | // hostKeyCallback allows connections to hosts that present keys only if
// strict host key checking is disabled. | [
"hostKeyCallback",
"allows",
"connections",
"to",
"hosts",
"that",
"present",
"keys",
"only",
"if",
"strict",
"host",
"key",
"checking",
"is",
"disabled",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/srv/authhandlers.go#L267-L281 | train |
gravitational/teleport | lib/srv/authhandlers.go | IsUserAuthority | func (h *AuthHandlers) IsUserAuthority(cert ssh.PublicKey) bool {
if _, err := h.authorityForCert(services.UserCA, cert); err != nil {
return false
}
return true
} | go | func (h *AuthHandlers) IsUserAuthority(cert ssh.PublicKey) bool {
if _, err := h.authorityForCert(services.UserCA, cert); err != nil {
return false
}
return true
} | [
"func",
"(",
"h",
"*",
"AuthHandlers",
")",
"IsUserAuthority",
"(",
"cert",
"ssh",
".",
"PublicKey",
")",
"bool",
"{",
"if",
"_",
",",
"err",
":=",
"h",
".",
"authorityForCert",
"(",
"services",
".",
"UserCA",
",",
"cert",
")",
";",
"err",
"!=",
"nil... | // IsUserAuthority is called during checking the client key, to see if the
// key used to sign the certificate was a Teleport CA. | [
"IsUserAuthority",
"is",
"called",
"during",
"checking",
"the",
"client",
"key",
"to",
"see",
"if",
"the",
"key",
"used",
"to",
"sign",
"the",
"certificate",
"was",
"a",
"Teleport",
"CA",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/srv/authhandlers.go#L285-L291 | train |
gravitational/teleport | lib/srv/authhandlers.go | IsHostAuthority | func (h *AuthHandlers) IsHostAuthority(cert ssh.PublicKey, address string) bool {
if _, err := h.authorityForCert(services.HostCA, cert); err != nil {
h.Entry.Debugf("Unable to find SSH host CA: %v.", err)
return false
}
return true
} | go | func (h *AuthHandlers) IsHostAuthority(cert ssh.PublicKey, address string) bool {
if _, err := h.authorityForCert(services.HostCA, cert); err != nil {
h.Entry.Debugf("Unable to find SSH host CA: %v.", err)
return false
}
return true
} | [
"func",
"(",
"h",
"*",
"AuthHandlers",
")",
"IsHostAuthority",
"(",
"cert",
"ssh",
".",
"PublicKey",
",",
"address",
"string",
")",
"bool",
"{",
"if",
"_",
",",
"err",
":=",
"h",
".",
"authorityForCert",
"(",
"services",
".",
"HostCA",
",",
"cert",
")"... | // IsHostAuthority is called when checking the host certificate a server
// presents. It make sure that the key used to sign the host certificate was a
// Teleport CA. | [
"IsHostAuthority",
"is",
"called",
"when",
"checking",
"the",
"host",
"certificate",
"a",
"server",
"presents",
".",
"It",
"make",
"sure",
"that",
"the",
"key",
"used",
"to",
"sign",
"the",
"host",
"certificate",
"was",
"a",
"Teleport",
"CA",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/srv/authhandlers.go#L296-L302 | train |
gravitational/teleport | lib/srv/authhandlers.go | fetchRoleSet | func (h *AuthHandlers) fetchRoleSet(cert *ssh.Certificate, ca services.CertAuthority, teleportUser string, clusterName string) (services.RoleSet, error) {
// for local users, go and check their individual permissions
var roles services.RoleSet
if clusterName == ca.GetClusterName() {
u, err := h.AccessPoint.GetUser... | go | func (h *AuthHandlers) fetchRoleSet(cert *ssh.Certificate, ca services.CertAuthority, teleportUser string, clusterName string) (services.RoleSet, error) {
// for local users, go and check their individual permissions
var roles services.RoleSet
if clusterName == ca.GetClusterName() {
u, err := h.AccessPoint.GetUser... | [
"func",
"(",
"h",
"*",
"AuthHandlers",
")",
"fetchRoleSet",
"(",
"cert",
"*",
"ssh",
".",
"Certificate",
",",
"ca",
"services",
".",
"CertAuthority",
",",
"teleportUser",
"string",
",",
"clusterName",
"string",
")",
"(",
"services",
".",
"RoleSet",
",",
"e... | // fetchRoleSet fetches the services.RoleSet assigned to a Teleport user. | [
"fetchRoleSet",
"fetches",
"the",
"services",
".",
"RoleSet",
"assigned",
"to",
"a",
"Teleport",
"user",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/srv/authhandlers.go#L347-L381 | train |
gravitational/teleport | lib/srv/authhandlers.go | authorityForCert | func (h *AuthHandlers) authorityForCert(caType services.CertAuthType, key ssh.PublicKey) (services.CertAuthority, error) {
// get all certificate authorities for given type
cas, err := h.AccessPoint.GetCertAuthorities(caType, false)
if err != nil {
h.Warnf("%v", trace.DebugReport(err))
return nil, trace.Wrap(err... | go | func (h *AuthHandlers) authorityForCert(caType services.CertAuthType, key ssh.PublicKey) (services.CertAuthority, error) {
// get all certificate authorities for given type
cas, err := h.AccessPoint.GetCertAuthorities(caType, false)
if err != nil {
h.Warnf("%v", trace.DebugReport(err))
return nil, trace.Wrap(err... | [
"func",
"(",
"h",
"*",
"AuthHandlers",
")",
"authorityForCert",
"(",
"caType",
"services",
".",
"CertAuthType",
",",
"key",
"ssh",
".",
"PublicKey",
")",
"(",
"services",
".",
"CertAuthority",
",",
"error",
")",
"{",
"// get all certificate authorities for given t... | // authorityForCert checks if the certificate was signed by a Teleport
// Certificate Authority and returns it. | [
"authorityForCert",
"checks",
"if",
"the",
"certificate",
"was",
"signed",
"by",
"a",
"Teleport",
"Certificate",
"Authority",
"and",
"returns",
"it",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/srv/authhandlers.go#L385-L427 | train |
gravitational/teleport | lib/srv/authhandlers.go | isProxy | func (h *AuthHandlers) isProxy() bool {
if h.Component == teleport.ComponentProxy {
return true
}
return false
} | go | func (h *AuthHandlers) isProxy() bool {
if h.Component == teleport.ComponentProxy {
return true
}
return false
} | [
"func",
"(",
"h",
"*",
"AuthHandlers",
")",
"isProxy",
"(",
")",
"bool",
"{",
"if",
"h",
".",
"Component",
"==",
"teleport",
".",
"ComponentProxy",
"{",
"return",
"true",
"\n",
"}",
"\n",
"return",
"false",
"\n",
"}"
] | // isProxy returns true if it's a regular SSH proxy. | [
"isProxy",
"returns",
"true",
"if",
"it",
"s",
"a",
"regular",
"SSH",
"proxy",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/srv/authhandlers.go#L430-L435 | train |
gravitational/teleport | lib/srv/authhandlers.go | extractRolesFromCert | func extractRolesFromCert(cert *ssh.Certificate) ([]string, error) {
data, ok := cert.Extensions[teleport.CertExtensionTeleportRoles]
if !ok {
// it's ok to not have any roles in the metadata
return nil, nil
}
return services.UnmarshalCertRoles(data)
} | go | func extractRolesFromCert(cert *ssh.Certificate) ([]string, error) {
data, ok := cert.Extensions[teleport.CertExtensionTeleportRoles]
if !ok {
// it's ok to not have any roles in the metadata
return nil, nil
}
return services.UnmarshalCertRoles(data)
} | [
"func",
"extractRolesFromCert",
"(",
"cert",
"*",
"ssh",
".",
"Certificate",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"data",
",",
"ok",
":=",
"cert",
".",
"Extensions",
"[",
"teleport",
".",
"CertExtensionTeleportRoles",
"]",
"\n",
"if",
"!... | // extractRolesFromCert extracts roles from certificate metadata extensions. | [
"extractRolesFromCert",
"extracts",
"roles",
"from",
"certificate",
"metadata",
"extensions",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/srv/authhandlers.go#L446-L453 | train |
gravitational/teleport | lib/web/sessions.go | GetUserClient | func (c *SessionContext) GetUserClient(site reversetunnel.RemoteSite) (auth.ClientI, error) {
// get the name of the current cluster
clt, err := c.GetClient()
if err != nil {
return nil, trace.Wrap(err)
}
cn, err := clt.GetClusterName()
if err != nil {
return nil, trace.Wrap(err)
}
// if we're trying to ac... | go | func (c *SessionContext) GetUserClient(site reversetunnel.RemoteSite) (auth.ClientI, error) {
// get the name of the current cluster
clt, err := c.GetClient()
if err != nil {
return nil, trace.Wrap(err)
}
cn, err := clt.GetClusterName()
if err != nil {
return nil, trace.Wrap(err)
}
// if we're trying to ac... | [
"func",
"(",
"c",
"*",
"SessionContext",
")",
"GetUserClient",
"(",
"site",
"reversetunnel",
".",
"RemoteSite",
")",
"(",
"auth",
".",
"ClientI",
",",
"error",
")",
"{",
"// get the name of the current cluster",
"clt",
",",
"err",
":=",
"c",
".",
"GetClient",
... | // GetUserClient will return an auth.ClientI with the role of the user at
// the requested site. If the site is local a client with the users local role
// is returned. If the site is remote a client with the users remote role is
// returned. | [
"GetUserClient",
"will",
"return",
"an",
"auth",
".",
"ClientI",
"with",
"the",
"role",
"of",
"the",
"user",
"at",
"the",
"requested",
"site",
".",
"If",
"the",
"site",
"is",
"local",
"a",
"client",
"with",
"the",
"users",
"local",
"role",
"is",
"returne... | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/web/sessions.go#L116-L154 | train |
gravitational/teleport | lib/web/sessions.go | newRemoteClient | func (c *SessionContext) newRemoteClient(cluster reversetunnel.RemoteSite) (auth.ClientI, net.Conn, error) {
clt, err := c.tryRemoteTLSClient(cluster)
if err != nil {
return nil, nil, trace.Wrap(err)
}
return clt, nil, nil
} | go | func (c *SessionContext) newRemoteClient(cluster reversetunnel.RemoteSite) (auth.ClientI, net.Conn, error) {
clt, err := c.tryRemoteTLSClient(cluster)
if err != nil {
return nil, nil, trace.Wrap(err)
}
return clt, nil, nil
} | [
"func",
"(",
"c",
"*",
"SessionContext",
")",
"newRemoteClient",
"(",
"cluster",
"reversetunnel",
".",
"RemoteSite",
")",
"(",
"auth",
".",
"ClientI",
",",
"net",
".",
"Conn",
",",
"error",
")",
"{",
"clt",
",",
"err",
":=",
"c",
".",
"tryRemoteTLSClient... | // newRemoteClient returns a client to a remote cluster with the role of
// the logged in user. | [
"newRemoteClient",
"returns",
"a",
"client",
"to",
"a",
"remote",
"cluster",
"with",
"the",
"role",
"of",
"the",
"logged",
"in",
"user",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/web/sessions.go#L158-L164 | train |
gravitational/teleport | lib/web/sessions.go | clusterDialer | func clusterDialer(remoteCluster reversetunnel.RemoteSite) auth.DialContext {
return func(in context.Context, network, _ string) (net.Conn, error) {
return remoteCluster.DialAuthServer()
}
} | go | func clusterDialer(remoteCluster reversetunnel.RemoteSite) auth.DialContext {
return func(in context.Context, network, _ string) (net.Conn, error) {
return remoteCluster.DialAuthServer()
}
} | [
"func",
"clusterDialer",
"(",
"remoteCluster",
"reversetunnel",
".",
"RemoteSite",
")",
"auth",
".",
"DialContext",
"{",
"return",
"func",
"(",
"in",
"context",
".",
"Context",
",",
"network",
",",
"_",
"string",
")",
"(",
"net",
".",
"Conn",
",",
"error",... | // clusterDialer returns DialContext function using cluster's dial function | [
"clusterDialer",
"returns",
"DialContext",
"function",
"using",
"cluster",
"s",
"dial",
"function"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/web/sessions.go#L167-L171 | train |
gravitational/teleport | lib/web/sessions.go | ClientTLSConfig | func (c *SessionContext) ClientTLSConfig(clusterName ...string) (*tls.Config, error) {
var certPool *x509.CertPool
if len(clusterName) == 0 {
certAuthorities, err := c.parent.proxyClient.GetCertAuthorities(services.HostCA, false)
if err != nil {
return nil, trace.Wrap(err)
}
certPool, err = services.CertPo... | go | func (c *SessionContext) ClientTLSConfig(clusterName ...string) (*tls.Config, error) {
var certPool *x509.CertPool
if len(clusterName) == 0 {
certAuthorities, err := c.parent.proxyClient.GetCertAuthorities(services.HostCA, false)
if err != nil {
return nil, trace.Wrap(err)
}
certPool, err = services.CertPo... | [
"func",
"(",
"c",
"*",
"SessionContext",
")",
"ClientTLSConfig",
"(",
"clusterName",
"...",
"string",
")",
"(",
"*",
"tls",
".",
"Config",
",",
"error",
")",
"{",
"var",
"certPool",
"*",
"x509",
".",
"CertPool",
"\n",
"if",
"len",
"(",
"clusterName",
"... | // ClientTLSConfig returns client TLS authentication associated
// with the web session context | [
"ClientTLSConfig",
"returns",
"client",
"TLS",
"authentication",
"associated",
"with",
"the",
"web",
"session",
"context"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/web/sessions.go#L189-L223 | train |
gravitational/teleport | lib/web/sessions.go | ExtendWebSession | func (c *SessionContext) ExtendWebSession() (services.WebSession, error) {
sess, err := c.clt.ExtendWebSession(c.user, c.sess.GetName())
if err != nil {
return nil, trace.Wrap(err)
}
return sess, nil
} | go | func (c *SessionContext) ExtendWebSession() (services.WebSession, error) {
sess, err := c.clt.ExtendWebSession(c.user, c.sess.GetName())
if err != nil {
return nil, trace.Wrap(err)
}
return sess, nil
} | [
"func",
"(",
"c",
"*",
"SessionContext",
")",
"ExtendWebSession",
"(",
")",
"(",
"services",
".",
"WebSession",
",",
"error",
")",
"{",
"sess",
",",
"err",
":=",
"c",
".",
"clt",
".",
"ExtendWebSession",
"(",
"c",
".",
"user",
",",
"c",
".",
"sess",
... | // ExtendWebSession creates a new web session for this user
// based on the previous session | [
"ExtendWebSession",
"creates",
"a",
"new",
"web",
"session",
"for",
"this",
"user",
"based",
"on",
"the",
"previous",
"session"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/web/sessions.go#L245-L251 | train |
gravitational/teleport | lib/web/sessions.go | GetAgent | func (c *SessionContext) GetAgent() (agent.Agent, *ssh.Certificate, error) {
pub, _, _, _, err := ssh.ParseAuthorizedKey(c.sess.GetPub())
if err != nil {
return nil, nil, trace.Wrap(err)
}
cert, ok := pub.(*ssh.Certificate)
if !ok {
return nil, nil, trace.BadParameter("expected certificate, got %T", pub)
}
i... | go | func (c *SessionContext) GetAgent() (agent.Agent, *ssh.Certificate, error) {
pub, _, _, _, err := ssh.ParseAuthorizedKey(c.sess.GetPub())
if err != nil {
return nil, nil, trace.Wrap(err)
}
cert, ok := pub.(*ssh.Certificate)
if !ok {
return nil, nil, trace.BadParameter("expected certificate, got %T", pub)
}
i... | [
"func",
"(",
"c",
"*",
"SessionContext",
")",
"GetAgent",
"(",
")",
"(",
"agent",
".",
"Agent",
",",
"*",
"ssh",
".",
"Certificate",
",",
"error",
")",
"{",
"pub",
",",
"_",
",",
"_",
",",
"_",
",",
"err",
":=",
"ssh",
".",
"ParseAuthorizedKey",
... | // GetAgent returns agent that can be used to answer challenges
// for the web to ssh connection as well as certificate | [
"GetAgent",
"returns",
"agent",
"that",
"can",
"be",
"used",
"to",
"answer",
"challenges",
"for",
"the",
"web",
"to",
"ssh",
"connection",
"as",
"well",
"as",
"certificate"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/web/sessions.go#L255-L281 | train |
gravitational/teleport | lib/web/sessions.go | Close | func (c *SessionContext) Close() error {
closers := c.TransferClosers()
for _, closer := range closers {
c.Debugf("Closing %v.", closer)
closer.Close()
}
if c.clt != nil {
return trace.Wrap(c.clt.Close())
}
return nil
} | go | func (c *SessionContext) Close() error {
closers := c.TransferClosers()
for _, closer := range closers {
c.Debugf("Closing %v.", closer)
closer.Close()
}
if c.clt != nil {
return trace.Wrap(c.clt.Close())
}
return nil
} | [
"func",
"(",
"c",
"*",
"SessionContext",
")",
"Close",
"(",
")",
"error",
"{",
"closers",
":=",
"c",
".",
"TransferClosers",
"(",
")",
"\n",
"for",
"_",
",",
"closer",
":=",
"range",
"closers",
"{",
"c",
".",
"Debugf",
"(",
"\"",
"\"",
",",
"closer... | // Close cleans up connections associated with requests | [
"Close",
"cleans",
"up",
"connections",
"associated",
"with",
"requests"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/web/sessions.go#L284-L294 | train |
gravitational/teleport | lib/web/sessions.go | newSessionCache | func newSessionCache(proxyClient auth.ClientI, servers []utils.NetAddr, cipherSuites []uint16) (*sessionCache, error) {
clusterName, err := proxyClient.GetClusterName()
if err != nil {
return nil, trace.Wrap(err)
}
m, err := ttlmap.New(1024, ttlmap.CallOnExpire(closeContext))
if err != nil {
return nil, trace.... | go | func newSessionCache(proxyClient auth.ClientI, servers []utils.NetAddr, cipherSuites []uint16) (*sessionCache, error) {
clusterName, err := proxyClient.GetClusterName()
if err != nil {
return nil, trace.Wrap(err)
}
m, err := ttlmap.New(1024, ttlmap.CallOnExpire(closeContext))
if err != nil {
return nil, trace.... | [
"func",
"newSessionCache",
"(",
"proxyClient",
"auth",
".",
"ClientI",
",",
"servers",
"[",
"]",
"utils",
".",
"NetAddr",
",",
"cipherSuites",
"[",
"]",
"uint16",
")",
"(",
"*",
"sessionCache",
",",
"error",
")",
"{",
"clusterName",
",",
"err",
":=",
"pr... | // newSessionCache returns new instance of the session cache | [
"newSessionCache",
"returns",
"new",
"instance",
"of",
"the",
"session",
"cache"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/web/sessions.go#L297-L317 | train |
gravitational/teleport | lib/web/sessions.go | closeContext | func closeContext(key string, val interface{}) {
go func() {
log.Infof("[WEB] closing context %v", key)
ctx, ok := val.(*SessionContext)
if !ok {
log.Warningf("warning, not valid value type %T", val)
return
}
if err := ctx.Close(); err != nil {
log.Infof("failed to close context: %v", err)
}
}()
... | go | func closeContext(key string, val interface{}) {
go func() {
log.Infof("[WEB] closing context %v", key)
ctx, ok := val.(*SessionContext)
if !ok {
log.Warningf("warning, not valid value type %T", val)
return
}
if err := ctx.Close(); err != nil {
log.Infof("failed to close context: %v", err)
}
}()
... | [
"func",
"closeContext",
"(",
"key",
"string",
",",
"val",
"interface",
"{",
"}",
")",
"{",
"go",
"func",
"(",
")",
"{",
"log",
".",
"Infof",
"(",
"\"",
"\"",
",",
"key",
")",
"\n",
"ctx",
",",
"ok",
":=",
"val",
".",
"(",
"*",
"SessionContext",
... | // closeContext is called when session context expires from
// cache and will clean up connections | [
"closeContext",
"is",
"called",
"when",
"session",
"context",
"expires",
"from",
"cache",
"and",
"will",
"clean",
"up",
"connections"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/web/sessions.go#L341-L353 | train |
gravitational/teleport | lib/auth/github.go | populateGithubClaims | func populateGithubClaims(client githubAPIClientI) (*services.GithubClaims, error) {
// find out the username
user, err := client.getUser()
if err != nil {
return nil, trace.Wrap(err, "failed to query Github user info")
}
// build team memberships
teams, err := client.getTeams()
if err != nil {
return nil, t... | go | func populateGithubClaims(client githubAPIClientI) (*services.GithubClaims, error) {
// find out the username
user, err := client.getUser()
if err != nil {
return nil, trace.Wrap(err, "failed to query Github user info")
}
// build team memberships
teams, err := client.getTeams()
if err != nil {
return nil, t... | [
"func",
"populateGithubClaims",
"(",
"client",
"githubAPIClientI",
")",
"(",
"*",
"services",
".",
"GithubClaims",
",",
"error",
")",
"{",
"// find out the username",
"user",
",",
"err",
":=",
"client",
".",
"getUser",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil... | // populateGithubClaims retrieves information about user and its team
// memberships by calling Github API using the access token | [
"populateGithubClaims",
"retrieves",
"information",
"about",
"user",
"and",
"its",
"team",
"memberships",
"by",
"calling",
"Github",
"API",
"using",
"the",
"access",
"token"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/github.go#L366-L395 | train |
gravitational/teleport | lib/auth/github.go | getUser | func (c *githubAPIClient) getUser() (*userResponse, error) {
// Ignore pagination links, we should never get more than a single user here.
bytes, _, err := c.get("/user")
if err != nil {
return nil, trace.Wrap(err)
}
var user userResponse
err = json.Unmarshal(bytes, &user)
if err != nil {
return nil, trace.W... | go | func (c *githubAPIClient) getUser() (*userResponse, error) {
// Ignore pagination links, we should never get more than a single user here.
bytes, _, err := c.get("/user")
if err != nil {
return nil, trace.Wrap(err)
}
var user userResponse
err = json.Unmarshal(bytes, &user)
if err != nil {
return nil, trace.W... | [
"func",
"(",
"c",
"*",
"githubAPIClient",
")",
"getUser",
"(",
")",
"(",
"*",
"userResponse",
",",
"error",
")",
"{",
"// Ignore pagination links, we should never get more than a single user here.",
"bytes",
",",
"_",
",",
"err",
":=",
"c",
".",
"get",
"(",
"\""... | // getEmails retrieves a list of emails for authenticated user | [
"getEmails",
"retrieves",
"a",
"list",
"of",
"emails",
"for",
"authenticated",
"user"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/github.go#L450-L462 | train |
gravitational/teleport | lib/auth/github.go | getTeams | func (c *githubAPIClient) getTeams() ([]teamResponse, error) {
var result []teamResponse
bytes, nextPage, err := c.get("/user/teams")
if err != nil {
return nil, trace.Wrap(err)
}
// Extract the first page of results and append them to the full result set.
var teams []teamResponse
err = json.Unmarshal(bytes,... | go | func (c *githubAPIClient) getTeams() ([]teamResponse, error) {
var result []teamResponse
bytes, nextPage, err := c.get("/user/teams")
if err != nil {
return nil, trace.Wrap(err)
}
// Extract the first page of results and append them to the full result set.
var teams []teamResponse
err = json.Unmarshal(bytes,... | [
"func",
"(",
"c",
"*",
"githubAPIClient",
")",
"getTeams",
"(",
")",
"(",
"[",
"]",
"teamResponse",
",",
"error",
")",
"{",
"var",
"result",
"[",
"]",
"teamResponse",
"\n\n",
"bytes",
",",
"nextPage",
",",
"err",
":=",
"c",
".",
"get",
"(",
"\"",
"... | // getTeams retrieves a list of teams authenticated user belongs to. | [
"getTeams",
"retrieves",
"a",
"list",
"of",
"teams",
"authenticated",
"user",
"belongs",
"to",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/github.go#L481-L540 | train |
gravitational/teleport | lib/auth/github.go | get | func (c *githubAPIClient) get(url string) ([]byte, string, error) {
request, err := http.NewRequest("GET", fmt.Sprintf("%v%v", GithubAPIURL, url), nil)
if err != nil {
return nil, "", trace.Wrap(err)
}
request.Header.Set("Authorization", fmt.Sprintf("token %v", c.token))
response, err := http.DefaultClient.Do(re... | go | func (c *githubAPIClient) get(url string) ([]byte, string, error) {
request, err := http.NewRequest("GET", fmt.Sprintf("%v%v", GithubAPIURL, url), nil)
if err != nil {
return nil, "", trace.Wrap(err)
}
request.Header.Set("Authorization", fmt.Sprintf("token %v", c.token))
response, err := http.DefaultClient.Do(re... | [
"func",
"(",
"c",
"*",
"githubAPIClient",
")",
"get",
"(",
"url",
"string",
")",
"(",
"[",
"]",
"byte",
",",
"string",
",",
"error",
")",
"{",
"request",
",",
"err",
":=",
"http",
".",
"NewRequest",
"(",
"\"",
"\"",
",",
"fmt",
".",
"Sprintf",
"(... | // get makes a GET request to the provided URL using the client's token for auth | [
"get",
"makes",
"a",
"GET",
"request",
"to",
"the",
"provided",
"URL",
"using",
"the",
"client",
"s",
"token",
"for",
"auth"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/github.go#L543-L568 | train |
gravitational/teleport | lib/srv/forward/sshserver.go | CheckDefaults | func (s *ServerConfig) CheckDefaults() error {
if s.AuthClient == nil {
return trace.BadParameter("auth client required")
}
if s.DataDir == "" {
return trace.BadParameter("missing parameter DataDir")
}
if s.UserAgent == nil {
return trace.BadParameter("user agent required to connect to remote host")
}
if s... | go | func (s *ServerConfig) CheckDefaults() error {
if s.AuthClient == nil {
return trace.BadParameter("auth client required")
}
if s.DataDir == "" {
return trace.BadParameter("missing parameter DataDir")
}
if s.UserAgent == nil {
return trace.BadParameter("user agent required to connect to remote host")
}
if s... | [
"func",
"(",
"s",
"*",
"ServerConfig",
")",
"CheckDefaults",
"(",
")",
"error",
"{",
"if",
"s",
".",
"AuthClient",
"==",
"nil",
"{",
"return",
"trace",
".",
"BadParameter",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"if",
"s",
".",
"DataDir",
"==",
"\"... | // CheckDefaults makes sure all required parameters are passed in. | [
"CheckDefaults",
"makes",
"sure",
"all",
"required",
"parameters",
"are",
"passed",
"in",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/srv/forward/sshserver.go#L162-L189 | train |
gravitational/teleport | lib/srv/forward/sshserver.go | New | func New(c ServerConfig) (*Server, error) {
// Check and make sure we everything we need to build a forwarding node.
err := c.CheckDefaults()
if err != nil {
return nil, trace.Wrap(err)
}
// Build a pipe connection to hook up the client and the server. we save both
// here and will pass them along to the conte... | go | func New(c ServerConfig) (*Server, error) {
// Check and make sure we everything we need to build a forwarding node.
err := c.CheckDefaults()
if err != nil {
return nil, trace.Wrap(err)
}
// Build a pipe connection to hook up the client and the server. we save both
// here and will pass them along to the conte... | [
"func",
"New",
"(",
"c",
"ServerConfig",
")",
"(",
"*",
"Server",
",",
"error",
")",
"{",
"// Check and make sure we everything we need to build a forwarding node.",
"err",
":=",
"c",
".",
"CheckDefaults",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",... | // New creates a new unstarted Server. | [
"New",
"creates",
"a",
"new",
"unstarted",
"Server",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/srv/forward/sshserver.go#L192-L262 | train |
gravitational/teleport | lib/srv/forward/sshserver.go | EmitAuditEvent | func (s *Server) EmitAuditEvent(event events.Event, fields events.EventFields) {
auditLog := s.GetAuditLog()
if auditLog != nil {
if err := auditLog.EmitAuditEvent(event, fields); err != nil {
s.log.Error(err)
}
} else {
s.log.Warn("SSH server has no audit log")
}
} | go | func (s *Server) EmitAuditEvent(event events.Event, fields events.EventFields) {
auditLog := s.GetAuditLog()
if auditLog != nil {
if err := auditLog.EmitAuditEvent(event, fields); err != nil {
s.log.Error(err)
}
} else {
s.log.Warn("SSH server has no audit log")
}
} | [
"func",
"(",
"s",
"*",
"Server",
")",
"EmitAuditEvent",
"(",
"event",
"events",
".",
"Event",
",",
"fields",
"events",
".",
"EventFields",
")",
"{",
"auditLog",
":=",
"s",
".",
"GetAuditLog",
"(",
")",
"\n",
"if",
"auditLog",
"!=",
"nil",
"{",
"if",
... | // EmitAuditEvent sends an event to the Audit Log. | [
"EmitAuditEvent",
"sends",
"an",
"event",
"to",
"the",
"Audit",
"Log",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/srv/forward/sshserver.go#L291-L300 | train |
gravitational/teleport | lib/srv/forward/sshserver.go | Close | func (s *Server) Close() error {
conns := []io.Closer{
s.sconn,
s.clientConn,
s.serverConn,
s.targetConn,
s.remoteClient,
}
var errs []error
for _, c := range conns {
if c == nil {
continue
}
err := c.Close()
if err != nil {
errs = append(errs, err)
}
}
// Signal to waiting goroutine... | go | func (s *Server) Close() error {
conns := []io.Closer{
s.sconn,
s.clientConn,
s.serverConn,
s.targetConn,
s.remoteClient,
}
var errs []error
for _, c := range conns {
if c == nil {
continue
}
err := c.Close()
if err != nil {
errs = append(errs, err)
}
}
// Signal to waiting goroutine... | [
"func",
"(",
"s",
"*",
"Server",
")",
"Close",
"(",
")",
"error",
"{",
"conns",
":=",
"[",
"]",
"io",
".",
"Closer",
"{",
"s",
".",
"sconn",
",",
"s",
".",
"clientConn",
",",
"s",
".",
"serverConn",
",",
"s",
".",
"targetConn",
",",
"s",
".",
... | // Close will close all underlying connections that the forwarding server holds. | [
"Close",
"will",
"close",
"all",
"underlying",
"connections",
"that",
"the",
"forwarding",
"server",
"holds",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/srv/forward/sshserver.go#L436-L463 | train |
gravitational/teleport | lib/service/cfg.go | ApplyToken | func (cfg *Config) ApplyToken(token string) bool {
if token != "" {
cfg.Token = token
return true
}
return false
} | go | func (cfg *Config) ApplyToken(token string) bool {
if token != "" {
cfg.Token = token
return true
}
return false
} | [
"func",
"(",
"cfg",
"*",
"Config",
")",
"ApplyToken",
"(",
"token",
"string",
")",
"bool",
"{",
"if",
"token",
"!=",
"\"",
"\"",
"{",
"cfg",
".",
"Token",
"=",
"token",
"\n",
"return",
"true",
"\n",
"}",
"\n",
"return",
"false",
"\n",
"}"
] | // ApplyToken assigns a given token to all internal services but only if token
// is not an empty string.
//
// Returns 'true' if token was modified | [
"ApplyToken",
"assigns",
"a",
"given",
"token",
"to",
"all",
"internal",
"services",
"but",
"only",
"if",
"token",
"is",
"not",
"an",
"empty",
"string",
".",
"Returns",
"true",
"if",
"token",
"was",
"modified"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/service/cfg.go#L177-L183 | train |
gravitational/teleport | lib/service/cfg.go | RoleConfig | func (cfg *Config) RoleConfig() RoleConfig {
return RoleConfig{
DataDir: cfg.DataDir,
HostUUID: cfg.HostUUID,
HostName: cfg.Hostname,
AuthServers: cfg.AuthServers,
Auth: cfg.Auth,
Console: cfg.Console,
}
} | go | func (cfg *Config) RoleConfig() RoleConfig {
return RoleConfig{
DataDir: cfg.DataDir,
HostUUID: cfg.HostUUID,
HostName: cfg.Hostname,
AuthServers: cfg.AuthServers,
Auth: cfg.Auth,
Console: cfg.Console,
}
} | [
"func",
"(",
"cfg",
"*",
"Config",
")",
"RoleConfig",
"(",
")",
"RoleConfig",
"{",
"return",
"RoleConfig",
"{",
"DataDir",
":",
"cfg",
".",
"DataDir",
",",
"HostUUID",
":",
"cfg",
".",
"HostUUID",
",",
"HostName",
":",
"cfg",
".",
"Hostname",
",",
"Aut... | // RoleConfig is a config for particular Teleport role | [
"RoleConfig",
"is",
"a",
"config",
"for",
"particular",
"Teleport",
"role"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/service/cfg.go#L186-L195 | train |
gravitational/teleport | lib/service/cfg.go | GetRecentTTL | func (c *CachePolicy) GetRecentTTL() time.Duration {
if c.RecentTTL == nil {
return defaults.RecentCacheTTL
}
return *c.RecentTTL
} | go | func (c *CachePolicy) GetRecentTTL() time.Duration {
if c.RecentTTL == nil {
return defaults.RecentCacheTTL
}
return *c.RecentTTL
} | [
"func",
"(",
"c",
"*",
"CachePolicy",
")",
"GetRecentTTL",
"(",
")",
"time",
".",
"Duration",
"{",
"if",
"c",
".",
"RecentTTL",
"==",
"nil",
"{",
"return",
"defaults",
".",
"RecentCacheTTL",
"\n",
"}",
"\n",
"return",
"*",
"c",
".",
"RecentTTL",
"\n",
... | // GetRecentTTL either returns TTL that was set,
// or default recent TTL value | [
"GetRecentTTL",
"either",
"returns",
"TTL",
"that",
"was",
"set",
"or",
"default",
"recent",
"TTL",
"value"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/service/cfg.go#L227-L232 | train |
gravitational/teleport | lib/service/cfg.go | String | func (c CachePolicy) String() string {
if !c.Enabled {
return "no cache policy"
}
recentCachePolicy := ""
if c.GetRecentTTL() == 0 {
recentCachePolicy = "will not cache frequently accessed items"
} else {
recentCachePolicy = fmt.Sprintf("will cache frequently accessed items for %v", c.GetRecentTTL())
}
if ... | go | func (c CachePolicy) String() string {
if !c.Enabled {
return "no cache policy"
}
recentCachePolicy := ""
if c.GetRecentTTL() == 0 {
recentCachePolicy = "will not cache frequently accessed items"
} else {
recentCachePolicy = fmt.Sprintf("will cache frequently accessed items for %v", c.GetRecentTTL())
}
if ... | [
"func",
"(",
"c",
"CachePolicy",
")",
"String",
"(",
")",
"string",
"{",
"if",
"!",
"c",
".",
"Enabled",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n",
"recentCachePolicy",
":=",
"\"",
"\"",
"\n",
"if",
"c",
".",
"GetRecentTTL",
"(",
")",
"==",
"0",
... | // String returns human-friendly representation of the policy | [
"String",
"returns",
"human",
"-",
"friendly",
"representation",
"of",
"the",
"policy"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/service/cfg.go#L235-L252 | train |
gravitational/teleport | lib/service/cfg.go | ApplyDefaults | func ApplyDefaults(cfg *Config) {
// Get defaults for Cipher, Kex algorithms, and MAC algorithms from
// golang.org/x/crypto/ssh default config.
var sc ssh.Config
sc.SetDefaults()
// Remove insecure and (borderline insecure) cryptographic primitives from
// default configuration. These can still be added back in... | go | func ApplyDefaults(cfg *Config) {
// Get defaults for Cipher, Kex algorithms, and MAC algorithms from
// golang.org/x/crypto/ssh default config.
var sc ssh.Config
sc.SetDefaults()
// Remove insecure and (borderline insecure) cryptographic primitives from
// default configuration. These can still be added back in... | [
"func",
"ApplyDefaults",
"(",
"cfg",
"*",
"Config",
")",
"{",
"// Get defaults for Cipher, Kex algorithms, and MAC algorithms from",
"// golang.org/x/crypto/ssh default config.",
"var",
"sc",
"ssh",
".",
"Config",
"\n",
"sc",
".",
"SetDefaults",
"(",
")",
"\n\n",
"// Remo... | // ApplyDefaults applies default values to the existing config structure | [
"ApplyDefaults",
"applies",
"default",
"values",
"to",
"the",
"existing",
"config",
"structure"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/service/cfg.go#L412-L475 | train |
gravitational/teleport | lib/srv/keepalive.go | StartKeepAliveLoop | func StartKeepAliveLoop(p KeepAliveParams) {
var missedCount int64
log := logrus.WithFields(logrus.Fields{
trace.Component: teleport.ComponentKeepAlive,
})
log.Debugf("Starting keep-alive loop with with interval %v and max count %v.", p.Interval, p.MaxCount)
tickerCh := time.NewTicker(p.Interval)
defer ticker... | go | func StartKeepAliveLoop(p KeepAliveParams) {
var missedCount int64
log := logrus.WithFields(logrus.Fields{
trace.Component: teleport.ComponentKeepAlive,
})
log.Debugf("Starting keep-alive loop with with interval %v and max count %v.", p.Interval, p.MaxCount)
tickerCh := time.NewTicker(p.Interval)
defer ticker... | [
"func",
"StartKeepAliveLoop",
"(",
"p",
"KeepAliveParams",
")",
"{",
"var",
"missedCount",
"int64",
"\n\n",
"log",
":=",
"logrus",
".",
"WithFields",
"(",
"logrus",
".",
"Fields",
"{",
"trace",
".",
"Component",
":",
"teleport",
".",
"ComponentKeepAlive",
",",... | // StartKeepAliveLoop starts the keep-alive loop. | [
"StartKeepAliveLoop",
"starts",
"the",
"keep",
"-",
"alive",
"loop",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/srv/keepalive.go#L59-L102 | train |
gravitational/teleport | lib/srv/keepalive.go | sendKeepAliveWithTimeout | func sendKeepAliveWithTimeout(conn RequestSender, timeout time.Duration, closeContext context.Context) bool {
errorCh := make(chan error, 1)
go func() {
// SendRequest will unblock when connection or channel is closed.
_, _, err := conn.SendRequest(teleport.KeepAliveReqType, true, nil)
errorCh <- err
}()
se... | go | func sendKeepAliveWithTimeout(conn RequestSender, timeout time.Duration, closeContext context.Context) bool {
errorCh := make(chan error, 1)
go func() {
// SendRequest will unblock when connection or channel is closed.
_, _, err := conn.SendRequest(teleport.KeepAliveReqType, true, nil)
errorCh <- err
}()
se... | [
"func",
"sendKeepAliveWithTimeout",
"(",
"conn",
"RequestSender",
",",
"timeout",
"time",
".",
"Duration",
",",
"closeContext",
"context",
".",
"Context",
")",
"bool",
"{",
"errorCh",
":=",
"make",
"(",
"chan",
"error",
",",
"1",
")",
"\n\n",
"go",
"func",
... | // sendKeepAliveWithTimeout sends a keepalive@openssh.com message to the remote
// client. A manual timeout is needed here because SendRequest will wait for a
// response forever. | [
"sendKeepAliveWithTimeout",
"sends",
"a",
"keepalive"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/srv/keepalive.go#L107-L127 | train |
gravitational/teleport | lib/services/namespace.go | MarshalNamespace | func MarshalNamespace(resource Namespace, opts ...MarshalOption) ([]byte, error) {
cfg, err := collectOptions(opts)
if err != nil {
return nil, trace.Wrap(err)
}
if !cfg.PreserveResourceID {
// avoid modifying the original object
// to prevent unexpected data races
copy := resource
copy.SetResourceID(0)
... | go | func MarshalNamespace(resource Namespace, opts ...MarshalOption) ([]byte, error) {
cfg, err := collectOptions(opts)
if err != nil {
return nil, trace.Wrap(err)
}
if !cfg.PreserveResourceID {
// avoid modifying the original object
// to prevent unexpected data races
copy := resource
copy.SetResourceID(0)
... | [
"func",
"MarshalNamespace",
"(",
"resource",
"Namespace",
",",
"opts",
"...",
"MarshalOption",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"cfg",
",",
"err",
":=",
"collectOptions",
"(",
"opts",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return... | // MarshalNamespace marshals namespace to JSON | [
"MarshalNamespace",
"marshals",
"namespace",
"to",
"JSON"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/namespace.go#L128-L141 | train |
gravitational/teleport | lib/services/namespace.go | UnmarshalNamespace | func UnmarshalNamespace(data []byte, opts ...MarshalOption) (*Namespace, error) {
if len(data) == 0 {
return nil, trace.BadParameter("missing namespace data")
}
cfg, err := collectOptions(opts)
if err != nil {
return nil, trace.Wrap(err)
}
// always skip schema validation on namespaces unmarshal
// the nam... | go | func UnmarshalNamespace(data []byte, opts ...MarshalOption) (*Namespace, error) {
if len(data) == 0 {
return nil, trace.BadParameter("missing namespace data")
}
cfg, err := collectOptions(opts)
if err != nil {
return nil, trace.Wrap(err)
}
// always skip schema validation on namespaces unmarshal
// the nam... | [
"func",
"UnmarshalNamespace",
"(",
"data",
"[",
"]",
"byte",
",",
"opts",
"...",
"MarshalOption",
")",
"(",
"*",
"Namespace",
",",
"error",
")",
"{",
"if",
"len",
"(",
"data",
")",
"==",
"0",
"{",
"return",
"nil",
",",
"trace",
".",
"BadParameter",
"... | // UnmarshalNamespace unmarshals role from JSON or YAML,
// sets defaults and checks the schema | [
"UnmarshalNamespace",
"unmarshals",
"role",
"from",
"JSON",
"or",
"YAML",
"sets",
"defaults",
"and",
"checks",
"the",
"schema"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/namespace.go#L145-L174 | train |
gravitational/teleport | tool/tctl/common/top_command.go | Initialize | func (c *TopCommand) Initialize(app *kingpin.Application, config *service.Config) {
c.config = config
c.top = app.Command("top", "Report diagnostic information")
c.diagURL = c.top.Arg("diag-addr", "Diagnostic HTTP URL").Default("http://127.0.0.1:3434").String()
c.refreshPeriod = c.top.Arg("refresh", "Refresh period... | go | func (c *TopCommand) Initialize(app *kingpin.Application, config *service.Config) {
c.config = config
c.top = app.Command("top", "Report diagnostic information")
c.diagURL = c.top.Arg("diag-addr", "Diagnostic HTTP URL").Default("http://127.0.0.1:3434").String()
c.refreshPeriod = c.top.Arg("refresh", "Refresh period... | [
"func",
"(",
"c",
"*",
"TopCommand",
")",
"Initialize",
"(",
"app",
"*",
"kingpin",
".",
"Application",
",",
"config",
"*",
"service",
".",
"Config",
")",
"{",
"c",
".",
"config",
"=",
"config",
"\n",
"c",
".",
"top",
"=",
"app",
".",
"Command",
"(... | // Initialize allows TopCommand to plug itself into the CLI parser. | [
"Initialize",
"allows",
"TopCommand",
"to",
"plug",
"itself",
"into",
"the",
"CLI",
"parser",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/tool/tctl/common/top_command.go#L55-L60 | train |
gravitational/teleport | tool/tctl/common/top_command.go | Top | func (c *TopCommand) Top(client *roundtrip.Client) error {
if err := ui.Init(); err != nil {
return trace.Wrap(err)
}
defer ui.Close()
ctx, cancel := context.WithCancel(context.TODO())
defer cancel()
uiEvents := ui.PollEvents()
ticker := time.NewTicker(*c.refreshPeriod)
defer ticker.Stop()
// fetch and re... | go | func (c *TopCommand) Top(client *roundtrip.Client) error {
if err := ui.Init(); err != nil {
return trace.Wrap(err)
}
defer ui.Close()
ctx, cancel := context.WithCancel(context.TODO())
defer cancel()
uiEvents := ui.PollEvents()
ticker := time.NewTicker(*c.refreshPeriod)
defer ticker.Stop()
// fetch and re... | [
"func",
"(",
"c",
"*",
"TopCommand",
")",
"Top",
"(",
"client",
"*",
"roundtrip",
".",
"Client",
")",
"error",
"{",
"if",
"err",
":=",
"ui",
".",
"Init",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"trace",
".",
"Wrap",
"(",
"err",
")",
"... | // Top is called to execute "status" CLI command. | [
"Top",
"is",
"called",
"to",
"execute",
"status",
"CLI",
"command",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/tool/tctl/common/top_command.go#L82-L133 | train |
gravitational/teleport | tool/tctl/common/top_command.go | SortedTopRequests | func (b *BackendStats) SortedTopRequests() []Request {
out := make([]Request, 0, len(b.TopRequests))
for _, req := range b.TopRequests {
out = append(out, req)
}
sort.Slice(out, func(i, j int) bool {
if out[i].GetFreq() == out[j].GetFreq() {
return out[i].Count > out[j].Count
}
return out[i].GetFreq() > ... | go | func (b *BackendStats) SortedTopRequests() []Request {
out := make([]Request, 0, len(b.TopRequests))
for _, req := range b.TopRequests {
out = append(out, req)
}
sort.Slice(out, func(i, j int) bool {
if out[i].GetFreq() == out[j].GetFreq() {
return out[i].Count > out[j].Count
}
return out[i].GetFreq() > ... | [
"func",
"(",
"b",
"*",
"BackendStats",
")",
"SortedTopRequests",
"(",
")",
"[",
"]",
"Request",
"{",
"out",
":=",
"make",
"(",
"[",
"]",
"Request",
",",
"0",
",",
"len",
"(",
"b",
".",
"TopRequests",
")",
")",
"\n",
"for",
"_",
",",
"req",
":=",
... | // SortedTopRequests returns top requests sorted either
// by frequency if frequency is present, or by count otherwise | [
"SortedTopRequests",
"returns",
"top",
"requests",
"sorted",
"either",
"by",
"frequency",
"if",
"frequency",
"is",
"present",
"or",
"by",
"count",
"otherwise"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/tool/tctl/common/top_command.go#L393-L405 | train |
gravitational/teleport | tool/tctl/common/top_command.go | SetFreq | func (c *Counter) SetFreq(prevCount Counter, period time.Duration) {
if period == 0 {
return
}
freq := float64(c.Count-prevCount.Count) / float64(period/time.Second)
c.Freq = &freq
} | go | func (c *Counter) SetFreq(prevCount Counter, period time.Duration) {
if period == 0 {
return
}
freq := float64(c.Count-prevCount.Count) / float64(period/time.Second)
c.Freq = &freq
} | [
"func",
"(",
"c",
"*",
"Counter",
")",
"SetFreq",
"(",
"prevCount",
"Counter",
",",
"period",
"time",
".",
"Duration",
")",
"{",
"if",
"period",
"==",
"0",
"{",
"return",
"\n",
"}",
"\n",
"freq",
":=",
"float64",
"(",
"c",
".",
"Count",
"-",
"prevC... | // SetFreq sets counter frequency based on the previous value
// and the time period | [
"SetFreq",
"sets",
"counter",
"frequency",
"based",
"on",
"the",
"previous",
"value",
"and",
"the",
"time",
"period"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/tool/tctl/common/top_command.go#L487-L493 | train |
gravitational/teleport | tool/tctl/common/top_command.go | AsPercentiles | func (h Histogram) AsPercentiles() []Percentile {
if h.Count == 0 {
return nil
}
var percentiles []Percentile
for _, bucket := range h.Buckets {
if bucket.Count == 0 {
continue
}
if bucket.Count == h.Count || math.IsInf(bucket.UpperBound, 0) {
percentiles = append(percentiles, Percentile{
Percenti... | go | func (h Histogram) AsPercentiles() []Percentile {
if h.Count == 0 {
return nil
}
var percentiles []Percentile
for _, bucket := range h.Buckets {
if bucket.Count == 0 {
continue
}
if bucket.Count == h.Count || math.IsInf(bucket.UpperBound, 0) {
percentiles = append(percentiles, Percentile{
Percenti... | [
"func",
"(",
"h",
"Histogram",
")",
"AsPercentiles",
"(",
")",
"[",
"]",
"Percentile",
"{",
"if",
"h",
".",
"Count",
"==",
"0",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"var",
"percentiles",
"[",
"]",
"Percentile",
"\n",
"for",
"_",
",",
"bucket",
":... | // AsPercentiles interprets historgram as a bucket of percentiles
// and returns calculated percentiles | [
"AsPercentiles",
"interprets",
"historgram",
"as",
"a",
"bucket",
"of",
"percentiles",
"and",
"returns",
"calculated",
"percentiles"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/tool/tctl/common/top_command.go#L521-L543 | train |
gravitational/teleport | lib/fixtures/fixtures.go | ExpectNotFound | func ExpectNotFound(c *check.C, err error) {
c.Assert(trace.IsNotFound(err), check.Equals, true, check.Commentf("expected NotFound, got %T %v at %v", trace.Unwrap(err), err, string(debug.Stack())))
} | go | func ExpectNotFound(c *check.C, err error) {
c.Assert(trace.IsNotFound(err), check.Equals, true, check.Commentf("expected NotFound, got %T %v at %v", trace.Unwrap(err), err, string(debug.Stack())))
} | [
"func",
"ExpectNotFound",
"(",
"c",
"*",
"check",
".",
"C",
",",
"err",
"error",
")",
"{",
"c",
".",
"Assert",
"(",
"trace",
".",
"IsNotFound",
"(",
"err",
")",
",",
"check",
".",
"Equals",
",",
"true",
",",
"check",
".",
"Commentf",
"(",
"\"",
"... | // ExpectNotFound expects not found error | [
"ExpectNotFound",
"expects",
"not",
"found",
"error"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/fixtures/fixtures.go#L13-L15 | train |
gravitational/teleport | lib/fixtures/fixtures.go | ExpectBadParameter | func ExpectBadParameter(c *check.C, err error) {
c.Assert(trace.IsBadParameter(err), check.Equals, true, check.Commentf("expected BadParameter, got %T %v at %v", trace.Unwrap(err), err, string(debug.Stack())))
} | go | func ExpectBadParameter(c *check.C, err error) {
c.Assert(trace.IsBadParameter(err), check.Equals, true, check.Commentf("expected BadParameter, got %T %v at %v", trace.Unwrap(err), err, string(debug.Stack())))
} | [
"func",
"ExpectBadParameter",
"(",
"c",
"*",
"check",
".",
"C",
",",
"err",
"error",
")",
"{",
"c",
".",
"Assert",
"(",
"trace",
".",
"IsBadParameter",
"(",
"err",
")",
",",
"check",
".",
"Equals",
",",
"true",
",",
"check",
".",
"Commentf",
"(",
"... | // ExpectBadParameter expects bad parameter error | [
"ExpectBadParameter",
"expects",
"bad",
"parameter",
"error"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/fixtures/fixtures.go#L18-L20 | train |
gravitational/teleport | lib/fixtures/fixtures.go | ExpectCompareFailed | func ExpectCompareFailed(c *check.C, err error) {
c.Assert(trace.IsCompareFailed(err), check.Equals, true, check.Commentf("expected CompareFailed, got %T %v at %v", trace.Unwrap(err), err, string(debug.Stack())))
} | go | func ExpectCompareFailed(c *check.C, err error) {
c.Assert(trace.IsCompareFailed(err), check.Equals, true, check.Commentf("expected CompareFailed, got %T %v at %v", trace.Unwrap(err), err, string(debug.Stack())))
} | [
"func",
"ExpectCompareFailed",
"(",
"c",
"*",
"check",
".",
"C",
",",
"err",
"error",
")",
"{",
"c",
".",
"Assert",
"(",
"trace",
".",
"IsCompareFailed",
"(",
"err",
")",
",",
"check",
".",
"Equals",
",",
"true",
",",
"check",
".",
"Commentf",
"(",
... | // ExpectCompareFailed expects compare failed error | [
"ExpectCompareFailed",
"expects",
"compare",
"failed",
"error"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/fixtures/fixtures.go#L23-L25 | train |
gravitational/teleport | lib/fixtures/fixtures.go | ExpectAccessDenied | func ExpectAccessDenied(c *check.C, err error) {
c.Assert(trace.IsAccessDenied(err), check.Equals, true, check.Commentf("expected AccessDenied, got %T %v at %v", trace.Unwrap(err), err, string(debug.Stack())))
} | go | func ExpectAccessDenied(c *check.C, err error) {
c.Assert(trace.IsAccessDenied(err), check.Equals, true, check.Commentf("expected AccessDenied, got %T %v at %v", trace.Unwrap(err), err, string(debug.Stack())))
} | [
"func",
"ExpectAccessDenied",
"(",
"c",
"*",
"check",
".",
"C",
",",
"err",
"error",
")",
"{",
"c",
".",
"Assert",
"(",
"trace",
".",
"IsAccessDenied",
"(",
"err",
")",
",",
"check",
".",
"Equals",
",",
"true",
",",
"check",
".",
"Commentf",
"(",
"... | // ExpectAccessDenied expects error to be access denied | [
"ExpectAccessDenied",
"expects",
"error",
"to",
"be",
"access",
"denied"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/fixtures/fixtures.go#L28-L30 | train |
gravitational/teleport | lib/fixtures/fixtures.go | ExpectAlreadyExists | func ExpectAlreadyExists(c *check.C, err error) {
c.Assert(trace.IsAlreadyExists(err), check.Equals, true, check.Commentf("expected AlreadyExists, got %T %v at %v", trace.Unwrap(err), err, string(debug.Stack())))
} | go | func ExpectAlreadyExists(c *check.C, err error) {
c.Assert(trace.IsAlreadyExists(err), check.Equals, true, check.Commentf("expected AlreadyExists, got %T %v at %v", trace.Unwrap(err), err, string(debug.Stack())))
} | [
"func",
"ExpectAlreadyExists",
"(",
"c",
"*",
"check",
".",
"C",
",",
"err",
"error",
")",
"{",
"c",
".",
"Assert",
"(",
"trace",
".",
"IsAlreadyExists",
"(",
"err",
")",
",",
"check",
".",
"Equals",
",",
"true",
",",
"check",
".",
"Commentf",
"(",
... | // ExpectAlreadyExists expects already exists error | [
"ExpectAlreadyExists",
"expects",
"already",
"exists",
"error"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/fixtures/fixtures.go#L33-L35 | train |
gravitational/teleport | lib/fixtures/fixtures.go | ExpectConnectionProblem | func ExpectConnectionProblem(c *check.C, err error) {
c.Assert(trace.IsConnectionProblem(err), check.Equals, true, check.Commentf("expected ConnectionProblem, got %T %v at %v", trace.Unwrap(err), err, string(debug.Stack())))
} | go | func ExpectConnectionProblem(c *check.C, err error) {
c.Assert(trace.IsConnectionProblem(err), check.Equals, true, check.Commentf("expected ConnectionProblem, got %T %v at %v", trace.Unwrap(err), err, string(debug.Stack())))
} | [
"func",
"ExpectConnectionProblem",
"(",
"c",
"*",
"check",
".",
"C",
",",
"err",
"error",
")",
"{",
"c",
".",
"Assert",
"(",
"trace",
".",
"IsConnectionProblem",
"(",
"err",
")",
",",
"check",
".",
"Equals",
",",
"true",
",",
"check",
".",
"Commentf",
... | // ExpectConnectionProblem expects connection problem error | [
"ExpectConnectionProblem",
"expects",
"connection",
"problem",
"error"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/fixtures/fixtures.go#L38-L40 | train |
gravitational/teleport | lib/fixtures/fixtures.go | DeepCompare | func DeepCompare(c *check.C, a, b interface{}) {
d := &spew.ConfigState{Indent: " ", DisableMethods: true, DisablePointerMethods: true, DisablePointerAddresses: true}
c.Assert(a, check.DeepEquals, b, check.Commentf("%v\nStack:\n%v\n", diff.Diff(d.Sdump(a), d.Sdump(b)), string(debug.Stack())))
} | go | func DeepCompare(c *check.C, a, b interface{}) {
d := &spew.ConfigState{Indent: " ", DisableMethods: true, DisablePointerMethods: true, DisablePointerAddresses: true}
c.Assert(a, check.DeepEquals, b, check.Commentf("%v\nStack:\n%v\n", diff.Diff(d.Sdump(a), d.Sdump(b)), string(debug.Stack())))
} | [
"func",
"DeepCompare",
"(",
"c",
"*",
"check",
".",
"C",
",",
"a",
",",
"b",
"interface",
"{",
"}",
")",
"{",
"d",
":=",
"&",
"spew",
".",
"ConfigState",
"{",
"Indent",
":",
"\"",
"\"",
",",
"DisableMethods",
":",
"true",
",",
"DisablePointerMethods"... | // DeepCompare uses gocheck DeepEquals but provides nice diff if things are not equal | [
"DeepCompare",
"uses",
"gocheck",
"DeepEquals",
"but",
"provides",
"nice",
"diff",
"if",
"things",
"are",
"not",
"equal"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/fixtures/fixtures.go#L43-L47 | train |
gravitational/teleport | lib/sshutils/req.go | Check | func (p *PTYReqParams) Check() error {
if p.W > maxSize || p.W < minSize {
return trace.BadParameter("bad width: %v", p.W)
}
if p.H > maxSize || p.H < minSize {
return trace.BadParameter("bad height: %v", p.H)
}
return nil
} | go | func (p *PTYReqParams) Check() error {
if p.W > maxSize || p.W < minSize {
return trace.BadParameter("bad width: %v", p.W)
}
if p.H > maxSize || p.H < minSize {
return trace.BadParameter("bad height: %v", p.H)
}
return nil
} | [
"func",
"(",
"p",
"*",
"PTYReqParams",
")",
"Check",
"(",
")",
"error",
"{",
"if",
"p",
".",
"W",
">",
"maxSize",
"||",
"p",
".",
"W",
"<",
"minSize",
"{",
"return",
"trace",
".",
"BadParameter",
"(",
"\"",
"\"",
",",
"p",
".",
"W",
")",
"\n",
... | // Check validates PTY parameters. | [
"Check",
"validates",
"PTY",
"parameters",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/sshutils/req.go#L102-L111 | train |
gravitational/teleport | lib/sshutils/req.go | CheckAndSetDefaults | func (p *PTYReqParams) CheckAndSetDefaults() error {
if p.W > maxSize || p.W < minSize {
p.W = teleport.DefaultTerminalWidth
}
if p.H > maxSize || p.H < minSize {
p.H = teleport.DefaultTerminalHeight
}
return nil
} | go | func (p *PTYReqParams) CheckAndSetDefaults() error {
if p.W > maxSize || p.W < minSize {
p.W = teleport.DefaultTerminalWidth
}
if p.H > maxSize || p.H < minSize {
p.H = teleport.DefaultTerminalHeight
}
return nil
} | [
"func",
"(",
"p",
"*",
"PTYReqParams",
")",
"CheckAndSetDefaults",
"(",
")",
"error",
"{",
"if",
"p",
".",
"W",
">",
"maxSize",
"||",
"p",
".",
"W",
"<",
"minSize",
"{",
"p",
".",
"W",
"=",
"teleport",
".",
"DefaultTerminalWidth",
"\n",
"}",
"\n",
... | // CheckAndSetDefaults validates PTY parameters and ensures parameters
// are within default values. | [
"CheckAndSetDefaults",
"validates",
"PTY",
"parameters",
"and",
"ensures",
"parameters",
"are",
"within",
"default",
"values",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/sshutils/req.go#L115-L124 | train |
gravitational/teleport | lib/kube/proxy/portforward.go | removeStreamPair | func (h *portForwardProxy) removeStreamPair(requestID string) {
h.streamPairsLock.Lock()
defer h.streamPairsLock.Unlock()
delete(h.streamPairs, requestID)
} | go | func (h *portForwardProxy) removeStreamPair(requestID string) {
h.streamPairsLock.Lock()
defer h.streamPairsLock.Unlock()
delete(h.streamPairs, requestID)
} | [
"func",
"(",
"h",
"*",
"portForwardProxy",
")",
"removeStreamPair",
"(",
"requestID",
"string",
")",
"{",
"h",
".",
"streamPairsLock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"h",
".",
"streamPairsLock",
".",
"Unlock",
"(",
")",
"\n\n",
"delete",
"(",
"h",... | // removeStreamPair removes the stream pair identified by requestID from streamPairs. | [
"removeStreamPair",
"removes",
"the",
"stream",
"pair",
"identified",
"by",
"requestID",
"from",
"streamPairs",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/kube/proxy/portforward.go#L284-L289 | train |
gravitational/teleport | lib/kube/proxy/portforward.go | run | func (h *portForwardProxy) run() {
h.Debugf("Waiting for port forward streams.")
for {
select {
case <-h.context.Done():
h.Debugf("Context is closing, returning.")
return
case <-h.sourceConn.CloseChan():
h.Debugf("Upgraded connection closed.")
return
case stream := <-h.streamChan:
requestID, er... | go | func (h *portForwardProxy) run() {
h.Debugf("Waiting for port forward streams.")
for {
select {
case <-h.context.Done():
h.Debugf("Context is closing, returning.")
return
case <-h.sourceConn.CloseChan():
h.Debugf("Upgraded connection closed.")
return
case stream := <-h.streamChan:
requestID, er... | [
"func",
"(",
"h",
"*",
"portForwardProxy",
")",
"run",
"(",
")",
"{",
"h",
".",
"Debugf",
"(",
"\"",
"\"",
")",
"\n",
"for",
"{",
"select",
"{",
"case",
"<-",
"h",
".",
"context",
".",
"Done",
"(",
")",
":",
"h",
".",
"Debugf",
"(",
"\"",
"\"... | // run is the main loop for the portForwardProxy. It processes new
// streams, invoking portForward for each complete stream pair. The loop exits
// when the httpstream.Connection is closed. | [
"run",
"is",
"the",
"main",
"loop",
"for",
"the",
"portForwardProxy",
".",
"It",
"processes",
"new",
"streams",
"invoking",
"portForward",
"for",
"each",
"complete",
"stream",
"pair",
".",
"The",
"loop",
"exits",
"when",
"the",
"httpstream",
".",
"Connection",... | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/kube/proxy/portforward.go#L303-L334 | train |
gravitational/teleport | lib/kube/proxy/portforward.go | portForward | func (h *portForwardProxy) portForward(p *httpStreamPair) {
defer p.dataStream.Close()
defer p.errorStream.Close()
portString := p.dataStream.Headers().Get(PortHeader)
port, _ := strconv.ParseInt(portString, 10, 32)
h.Debugf("Forwrarding port %v -> %v.", p.requestID, portString)
err := h.forwardStreamPair(p, po... | go | func (h *portForwardProxy) portForward(p *httpStreamPair) {
defer p.dataStream.Close()
defer p.errorStream.Close()
portString := p.dataStream.Headers().Get(PortHeader)
port, _ := strconv.ParseInt(portString, 10, 32)
h.Debugf("Forwrarding port %v -> %v.", p.requestID, portString)
err := h.forwardStreamPair(p, po... | [
"func",
"(",
"h",
"*",
"portForwardProxy",
")",
"portForward",
"(",
"p",
"*",
"httpStreamPair",
")",
"{",
"defer",
"p",
".",
"dataStream",
".",
"Close",
"(",
")",
"\n",
"defer",
"p",
".",
"errorStream",
".",
"Close",
"(",
")",
"\n\n",
"portString",
":=... | // portForward invokes the portForwardProxy's forwarder.PortForward
// function for the given stream pair. | [
"portForward",
"invokes",
"the",
"portForwardProxy",
"s",
"forwarder",
".",
"PortForward",
"function",
"for",
"the",
"given",
"stream",
"pair",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/kube/proxy/portforward.go#L338-L353 | train |
gravitational/teleport | lib/kube/proxy/portforward.go | add | func (p *httpStreamPair) add(stream httpstream.Stream) (bool, error) {
p.lock.Lock()
defer p.lock.Unlock()
switch stream.Headers().Get(StreamType) {
case StreamTypeError:
if p.errorStream != nil {
return false, trace.BadParameter("error stream already assigned")
}
p.errorStream = stream
case StreamTypeDa... | go | func (p *httpStreamPair) add(stream httpstream.Stream) (bool, error) {
p.lock.Lock()
defer p.lock.Unlock()
switch stream.Headers().Get(StreamType) {
case StreamTypeError:
if p.errorStream != nil {
return false, trace.BadParameter("error stream already assigned")
}
p.errorStream = stream
case StreamTypeDa... | [
"func",
"(",
"p",
"*",
"httpStreamPair",
")",
"add",
"(",
"stream",
"httpstream",
".",
"Stream",
")",
"(",
"bool",
",",
"error",
")",
"{",
"p",
".",
"lock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"p",
".",
"lock",
".",
"Unlock",
"(",
")",
"\n\n",
... | // add adds the stream to the httpStreamPair. If the pair already
// contains a stream for the new stream's type, an error is returned. add
// returns true if both the data and error streams for this pair have been
// received. | [
"add",
"adds",
"the",
"stream",
"to",
"the",
"httpStreamPair",
".",
"If",
"the",
"pair",
"already",
"contains",
"a",
"stream",
"for",
"the",
"new",
"stream",
"s",
"type",
"an",
"error",
"is",
"returned",
".",
"add",
"returns",
"true",
"if",
"both",
"the"... | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/kube/proxy/portforward.go#L377-L399 | train |
gravitational/teleport | lib/utils/replace.go | SliceMatchesRegex | func SliceMatchesRegex(input string, expressions []string) (bool, error) {
for _, expression := range expressions {
if !strings.HasPrefix(expression, "^") || !strings.HasSuffix(expression, "$") {
// replace glob-style wildcards with regexp wildcards
// for plain strings, and quote all characters that could
... | go | func SliceMatchesRegex(input string, expressions []string) (bool, error) {
for _, expression := range expressions {
if !strings.HasPrefix(expression, "^") || !strings.HasSuffix(expression, "$") {
// replace glob-style wildcards with regexp wildcards
// for plain strings, and quote all characters that could
... | [
"func",
"SliceMatchesRegex",
"(",
"input",
"string",
",",
"expressions",
"[",
"]",
"string",
")",
"(",
"bool",
",",
"error",
")",
"{",
"for",
"_",
",",
"expression",
":=",
"range",
"expressions",
"{",
"if",
"!",
"strings",
".",
"HasPrefix",
"(",
"express... | // SliceMatchesRegex checks if input matches any of the expressions. The
// match is always evaluated as a regex either an exact match or regexp. | [
"SliceMatchesRegex",
"checks",
"if",
"input",
"matches",
"any",
"of",
"the",
"expressions",
".",
"The",
"match",
"is",
"always",
"evaluated",
"as",
"a",
"regex",
"either",
"an",
"exact",
"match",
"or",
"regexp",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/replace.go#L51-L74 | train |
gravitational/teleport | lib/auth/state.go | NewProcessStorage | func NewProcessStorage(ctx context.Context, path string) (*ProcessStorage, error) {
if path == "" {
return nil, trace.BadParameter("missing parameter path")
}
litebk, err := lite.NewWithConfig(ctx, lite.Config{Path: path, EventsOff: true})
if err != nil {
return nil, trace.Wrap(err)
}
// Import storage data
... | go | func NewProcessStorage(ctx context.Context, path string) (*ProcessStorage, error) {
if path == "" {
return nil, trace.BadParameter("missing parameter path")
}
litebk, err := lite.NewWithConfig(ctx, lite.Config{Path: path, EventsOff: true})
if err != nil {
return nil, trace.Wrap(err)
}
// Import storage data
... | [
"func",
"NewProcessStorage",
"(",
"ctx",
"context",
".",
"Context",
",",
"path",
"string",
")",
"(",
"*",
"ProcessStorage",
",",
"error",
")",
"{",
"if",
"path",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"trace",
".",
"BadParameter",
"(",
"\"",
"\""... | // NewProcessStorage returns a new instance of the process storage. | [
"NewProcessStorage",
"returns",
"a",
"new",
"instance",
"of",
"the",
"process",
"storage",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/state.go#L44-L61 | train |
gravitational/teleport | lib/auth/state.go | GetState | func (p *ProcessStorage) GetState(role teleport.Role) (*StateV2, error) {
item, err := p.Get(context.TODO(), backend.Key(statesPrefix, strings.ToLower(role.String()), stateName))
if err != nil {
return nil, trace.Wrap(err)
}
var res StateV2
if err := utils.UnmarshalWithSchema(GetStateSchema(), &res, item.Value);... | go | func (p *ProcessStorage) GetState(role teleport.Role) (*StateV2, error) {
item, err := p.Get(context.TODO(), backend.Key(statesPrefix, strings.ToLower(role.String()), stateName))
if err != nil {
return nil, trace.Wrap(err)
}
var res StateV2
if err := utils.UnmarshalWithSchema(GetStateSchema(), &res, item.Value);... | [
"func",
"(",
"p",
"*",
"ProcessStorage",
")",
"GetState",
"(",
"role",
"teleport",
".",
"Role",
")",
"(",
"*",
"StateV2",
",",
"error",
")",
"{",
"item",
",",
"err",
":=",
"p",
".",
"Get",
"(",
"context",
".",
"TODO",
"(",
")",
",",
"backend",
".... | // GetState reads rotation state from disk. | [
"GetState",
"reads",
"rotation",
"state",
"from",
"disk",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/state.go#L84-L94 | train |
gravitational/teleport | lib/auth/state.go | CreateState | func (p *ProcessStorage) CreateState(role teleport.Role, state StateV2) error {
if err := state.CheckAndSetDefaults(); err != nil {
return trace.Wrap(err)
}
value, err := json.Marshal(state)
if err != nil {
return trace.Wrap(err)
}
item := backend.Item{
Key: backend.Key(statesPrefix, strings.ToLower(role.... | go | func (p *ProcessStorage) CreateState(role teleport.Role, state StateV2) error {
if err := state.CheckAndSetDefaults(); err != nil {
return trace.Wrap(err)
}
value, err := json.Marshal(state)
if err != nil {
return trace.Wrap(err)
}
item := backend.Item{
Key: backend.Key(statesPrefix, strings.ToLower(role.... | [
"func",
"(",
"p",
"*",
"ProcessStorage",
")",
"CreateState",
"(",
"role",
"teleport",
".",
"Role",
",",
"state",
"StateV2",
")",
"error",
"{",
"if",
"err",
":=",
"state",
".",
"CheckAndSetDefaults",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"tr... | // CreateState creates process state if it does not exist yet. | [
"CreateState",
"creates",
"process",
"state",
"if",
"it",
"does",
"not",
"exist",
"yet",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/state.go#L97-L114 | train |
gravitational/teleport | lib/auth/state.go | ReadIdentity | func (p *ProcessStorage) ReadIdentity(name string, role teleport.Role) (*Identity, error) {
if name == "" {
return nil, trace.BadParameter("missing parameter name")
}
item, err := p.Get(context.TODO(), backend.Key(idsPrefix, strings.ToLower(role.String()), name))
if err != nil {
return nil, trace.Wrap(err)
}
... | go | func (p *ProcessStorage) ReadIdentity(name string, role teleport.Role) (*Identity, error) {
if name == "" {
return nil, trace.BadParameter("missing parameter name")
}
item, err := p.Get(context.TODO(), backend.Key(idsPrefix, strings.ToLower(role.String()), name))
if err != nil {
return nil, trace.Wrap(err)
}
... | [
"func",
"(",
"p",
"*",
"ProcessStorage",
")",
"ReadIdentity",
"(",
"name",
"string",
",",
"role",
"teleport",
".",
"Role",
")",
"(",
"*",
"Identity",
",",
"error",
")",
"{",
"if",
"name",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"trace",
".",
"... | // ReadIdentity reads identity using identity name and role. | [
"ReadIdentity",
"reads",
"identity",
"using",
"identity",
"name",
"and",
"role",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/state.go#L137-L156 | train |
gravitational/teleport | lib/auth/state.go | WriteIdentity | func (p *ProcessStorage) WriteIdentity(name string, id Identity) error {
res := IdentityV2{
ResourceHeader: services.ResourceHeader{
Kind: services.KindIdentity,
Version: services.V2,
Metadata: services.Metadata{
Name: name,
},
},
Spec: IdentitySpecV2{
Key: id.KeyBytes,
SSHCert: ... | go | func (p *ProcessStorage) WriteIdentity(name string, id Identity) error {
res := IdentityV2{
ResourceHeader: services.ResourceHeader{
Kind: services.KindIdentity,
Version: services.V2,
Metadata: services.Metadata{
Name: name,
},
},
Spec: IdentitySpecV2{
Key: id.KeyBytes,
SSHCert: ... | [
"func",
"(",
"p",
"*",
"ProcessStorage",
")",
"WriteIdentity",
"(",
"name",
"string",
",",
"id",
"Identity",
")",
"error",
"{",
"res",
":=",
"IdentityV2",
"{",
"ResourceHeader",
":",
"services",
".",
"ResourceHeader",
"{",
"Kind",
":",
"services",
".",
"Ki... | // WriteIdentity writes identity to the backend. | [
"WriteIdentity",
"writes",
"identity",
"to",
"the",
"backend",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/state.go#L159-L189 | train |
gravitational/teleport | lib/auth/state.go | GetIdentitySchema | func GetIdentitySchema() string {
return fmt.Sprintf(services.V2SchemaTemplate, services.MetadataSchema, IdentitySpecV2Schema, services.DefaultDefinitions)
} | go | func GetIdentitySchema() string {
return fmt.Sprintf(services.V2SchemaTemplate, services.MetadataSchema, IdentitySpecV2Schema, services.DefaultDefinitions)
} | [
"func",
"GetIdentitySchema",
"(",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"services",
".",
"V2SchemaTemplate",
",",
"services",
".",
"MetadataSchema",
",",
"IdentitySpecV2Schema",
",",
"services",
".",
"DefaultDefinitions",
")",
"\n",
"}"
] | // GetIdentitySchema returns JSON Schema for cert authorities. | [
"GetIdentitySchema",
"returns",
"JSON",
"Schema",
"for",
"cert",
"authorities",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/state.go#L289-L291 | train |
gravitational/teleport | lib/auth/state.go | GetStateSchema | func GetStateSchema() string {
return fmt.Sprintf(services.V2SchemaTemplate, services.MetadataSchema, fmt.Sprintf(StateSpecV2Schema, services.RotationSchema), services.DefaultDefinitions)
} | go | func GetStateSchema() string {
return fmt.Sprintf(services.V2SchemaTemplate, services.MetadataSchema, fmt.Sprintf(StateSpecV2Schema, services.RotationSchema), services.DefaultDefinitions)
} | [
"func",
"GetStateSchema",
"(",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"services",
".",
"V2SchemaTemplate",
",",
"services",
".",
"MetadataSchema",
",",
"fmt",
".",
"Sprintf",
"(",
"StateSpecV2Schema",
",",
"services",
".",
"RotationSchema",
... | // GetStateSchema returns JSON Schema for cert authorities. | [
"GetStateSchema",
"returns",
"JSON",
"Schema",
"for",
"cert",
"authorities",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/state.go#L304-L306 | train |
gravitational/teleport | lib/events/api.go | AsString | func (f EventFields) AsString() string {
return fmt.Sprintf("%s: login=%s, id=%v, bytes=%v",
f.GetString(EventType),
f.GetString(EventLogin),
f.GetInt(EventCursor),
f.GetInt(SessionPrintEventBytes))
} | go | func (f EventFields) AsString() string {
return fmt.Sprintf("%s: login=%s, id=%v, bytes=%v",
f.GetString(EventType),
f.GetString(EventLogin),
f.GetInt(EventCursor),
f.GetInt(SessionPrintEventBytes))
} | [
"func",
"(",
"f",
"EventFields",
")",
"AsString",
"(",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"f",
".",
"GetString",
"(",
"EventType",
")",
",",
"f",
".",
"GetString",
"(",
"EventLogin",
")",
",",
"f",
".",
"GetI... | // String returns a string representation of an event structure | [
"String",
"returns",
"a",
"string",
"representation",
"of",
"an",
"event",
"structure"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/events/api.go#L251-L257 | train |
gravitational/teleport | lib/events/api.go | GetString | func (f EventFields) GetString(key string) string {
val, found := f[key]
if !found {
return ""
}
v, _ := val.(string)
return v
} | go | func (f EventFields) GetString(key string) string {
val, found := f[key]
if !found {
return ""
}
v, _ := val.(string)
return v
} | [
"func",
"(",
"f",
"EventFields",
")",
"GetString",
"(",
"key",
"string",
")",
"string",
"{",
"val",
",",
"found",
":=",
"f",
"[",
"key",
"]",
"\n",
"if",
"!",
"found",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n",
"v",
",",
"_",
":=",
"val",
".",... | // GetString returns a string representation of a logged field | [
"GetString",
"returns",
"a",
"string",
"representation",
"of",
"a",
"logged",
"field"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/events/api.go#L280-L287 | train |
gravitational/teleport | lib/kube/proxy/remotecommand.go | waitStreamReply | func waitStreamReply(ctx context.Context, replySent <-chan struct{}, notify chan<- struct{}) {
select {
case <-replySent:
notify <- struct{}{}
case <-ctx.Done():
}
} | go | func waitStreamReply(ctx context.Context, replySent <-chan struct{}, notify chan<- struct{}) {
select {
case <-replySent:
notify <- struct{}{}
case <-ctx.Done():
}
} | [
"func",
"waitStreamReply",
"(",
"ctx",
"context",
".",
"Context",
",",
"replySent",
"<-",
"chan",
"struct",
"{",
"}",
",",
"notify",
"chan",
"<-",
"struct",
"{",
"}",
")",
"{",
"select",
"{",
"case",
"<-",
"replySent",
":",
"notify",
"<-",
"struct",
"{... | // waitStreamReply waits until either replySent or stop is closed. If replySent is closed, it sends
// an empty struct to the notify channel. | [
"waitStreamReply",
"waits",
"until",
"either",
"replySent",
"or",
"stop",
"is",
"closed",
".",
"If",
"replySent",
"is",
"closed",
"it",
"sends",
"an",
"empty",
"struct",
"to",
"the",
"notify",
"channel",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/kube/proxy/remotecommand.go#L311-L317 | train |
gravitational/teleport | lib/utils/fs.go | MkdirAll | func MkdirAll(targetDirectory string, mode os.FileMode) error {
err := os.MkdirAll(targetDirectory, mode)
if err != nil {
return trace.ConvertSystemError(err)
}
return nil
} | go | func MkdirAll(targetDirectory string, mode os.FileMode) error {
err := os.MkdirAll(targetDirectory, mode)
if err != nil {
return trace.ConvertSystemError(err)
}
return nil
} | [
"func",
"MkdirAll",
"(",
"targetDirectory",
"string",
",",
"mode",
"os",
".",
"FileMode",
")",
"error",
"{",
"err",
":=",
"os",
".",
"MkdirAll",
"(",
"targetDirectory",
",",
"mode",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"trace",
".",
"Con... | // MkdirAll creates directory and subdirectories | [
"MkdirAll",
"creates",
"directory",
"and",
"subdirectories"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/fs.go#L59-L65 | train |
gravitational/teleport | lib/utils/fs.go | Close | func (r *RemoveDirCloser) Close() error {
return trace.ConvertSystemError(os.RemoveAll(r.Path))
} | go | func (r *RemoveDirCloser) Close() error {
return trace.ConvertSystemError(os.RemoveAll(r.Path))
} | [
"func",
"(",
"r",
"*",
"RemoveDirCloser",
")",
"Close",
"(",
")",
"error",
"{",
"return",
"trace",
".",
"ConvertSystemError",
"(",
"os",
".",
"RemoveAll",
"(",
"r",
".",
"Path",
")",
")",
"\n",
"}"
] | // Close removes directory and all it's contents | [
"Close",
"removes",
"directory",
"and",
"all",
"it",
"s",
"contents"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/fs.go#L74-L76 | train |
gravitational/teleport | lib/utils/fs.go | IsFile | func IsFile(fp string) bool {
fi, err := os.Stat(fp)
if err == nil {
return !fi.IsDir()
}
return false
} | go | func IsFile(fp string) bool {
fi, err := os.Stat(fp)
if err == nil {
return !fi.IsDir()
}
return false
} | [
"func",
"IsFile",
"(",
"fp",
"string",
")",
"bool",
"{",
"fi",
",",
"err",
":=",
"os",
".",
"Stat",
"(",
"fp",
")",
"\n",
"if",
"err",
"==",
"nil",
"{",
"return",
"!",
"fi",
".",
"IsDir",
"(",
")",
"\n",
"}",
"\n",
"return",
"false",
"\n",
"}... | // IsFile returns true if a given file path points to an existing file | [
"IsFile",
"returns",
"true",
"if",
"a",
"given",
"file",
"path",
"points",
"to",
"an",
"existing",
"file"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/fs.go#L79-L85 | train |
gravitational/teleport | lib/utils/fs.go | IsDir | func IsDir(dirPath string) bool {
fi, err := os.Stat(dirPath)
if err == nil {
return fi.IsDir()
}
return false
} | go | func IsDir(dirPath string) bool {
fi, err := os.Stat(dirPath)
if err == nil {
return fi.IsDir()
}
return false
} | [
"func",
"IsDir",
"(",
"dirPath",
"string",
")",
"bool",
"{",
"fi",
",",
"err",
":=",
"os",
".",
"Stat",
"(",
"dirPath",
")",
"\n",
"if",
"err",
"==",
"nil",
"{",
"return",
"fi",
".",
"IsDir",
"(",
")",
"\n",
"}",
"\n",
"return",
"false",
"\n",
... | // IsDir is a helper function to quickly check if a given path is a valid directory | [
"IsDir",
"is",
"a",
"helper",
"function",
"to",
"quickly",
"check",
"if",
"a",
"given",
"path",
"is",
"a",
"valid",
"directory"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/fs.go#L88-L94 | train |
gravitational/teleport | lib/utils/fs.go | NormalizePath | func NormalizePath(path string) (string, error) {
s, err := filepath.Abs(path)
if err != nil {
return "", trace.ConvertSystemError(err)
}
abs, err := filepath.EvalSymlinks(s)
if err != nil {
return "", trace.ConvertSystemError(err)
}
return abs, nil
} | go | func NormalizePath(path string) (string, error) {
s, err := filepath.Abs(path)
if err != nil {
return "", trace.ConvertSystemError(err)
}
abs, err := filepath.EvalSymlinks(s)
if err != nil {
return "", trace.ConvertSystemError(err)
}
return abs, nil
} | [
"func",
"NormalizePath",
"(",
"path",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"s",
",",
"err",
":=",
"filepath",
".",
"Abs",
"(",
"path",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"trace",
".",
"ConvertSyste... | // NormalizePath normalises path, evaluating symlinks and converting local
// paths to absolute | [
"NormalizePath",
"normalises",
"path",
"evaluating",
"symlinks",
"and",
"converting",
"local",
"paths",
"to",
"absolute"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/fs.go#L117-L127 | train |
gravitational/teleport | lib/utils/fs.go | OpenFile | func OpenFile(path string) (*os.File, error) {
newPath, err := NormalizePath(path)
if err != nil {
return nil, trace.Wrap(err)
}
fi, err := os.Stat(newPath)
if err != nil {
return nil, trace.ConvertSystemError(err)
}
if fi.IsDir() {
return nil, trace.BadParameter("%v is not a file", path)
}
f, err := os.... | go | func OpenFile(path string) (*os.File, error) {
newPath, err := NormalizePath(path)
if err != nil {
return nil, trace.Wrap(err)
}
fi, err := os.Stat(newPath)
if err != nil {
return nil, trace.ConvertSystemError(err)
}
if fi.IsDir() {
return nil, trace.BadParameter("%v is not a file", path)
}
f, err := os.... | [
"func",
"OpenFile",
"(",
"path",
"string",
")",
"(",
"*",
"os",
".",
"File",
",",
"error",
")",
"{",
"newPath",
",",
"err",
":=",
"NormalizePath",
"(",
"path",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"trace",
".",
"Wrap",
... | // OpenFile opens file and returns file handle | [
"OpenFile",
"opens",
"file",
"and",
"returns",
"file",
"handle"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/fs.go#L130-L147 | train |
gravitational/teleport | lib/utils/fs.go | StatDir | func StatDir(path string) (os.FileInfo, error) {
fi, err := os.Stat(path)
if err != nil {
return nil, trace.ConvertSystemError(err)
}
if !fi.IsDir() {
return nil, trace.BadParameter("%v is not a directory", path)
}
return fi, nil
} | go | func StatDir(path string) (os.FileInfo, error) {
fi, err := os.Stat(path)
if err != nil {
return nil, trace.ConvertSystemError(err)
}
if !fi.IsDir() {
return nil, trace.BadParameter("%v is not a directory", path)
}
return fi, nil
} | [
"func",
"StatDir",
"(",
"path",
"string",
")",
"(",
"os",
".",
"FileInfo",
",",
"error",
")",
"{",
"fi",
",",
"err",
":=",
"os",
".",
"Stat",
"(",
"path",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"trace",
".",
"ConvertSyste... | // StatDir stats directory, returns error if file exists, but not a directory | [
"StatDir",
"stats",
"directory",
"returns",
"error",
"if",
"file",
"exists",
"but",
"not",
"a",
"directory"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/fs.go#L150-L159 | train |
gravitational/teleport | lib/utils/fs.go | getHomeDir | func getHomeDir() string {
switch runtime.GOOS {
case teleport.LinuxOS:
return os.Getenv(teleport.EnvHome)
case teleport.DarwinOS:
return os.Getenv(teleport.EnvHome)
case teleport.WindowsOS:
return os.Getenv(teleport.EnvUserProfile)
}
return ""
} | go | func getHomeDir() string {
switch runtime.GOOS {
case teleport.LinuxOS:
return os.Getenv(teleport.EnvHome)
case teleport.DarwinOS:
return os.Getenv(teleport.EnvHome)
case teleport.WindowsOS:
return os.Getenv(teleport.EnvUserProfile)
}
return ""
} | [
"func",
"getHomeDir",
"(",
")",
"string",
"{",
"switch",
"runtime",
".",
"GOOS",
"{",
"case",
"teleport",
".",
"LinuxOS",
":",
"return",
"os",
".",
"Getenv",
"(",
"teleport",
".",
"EnvHome",
")",
"\n",
"case",
"teleport",
".",
"DarwinOS",
":",
"return",
... | // getHomeDir returns the home directory based off the OS. | [
"getHomeDir",
"returns",
"the",
"home",
"directory",
"based",
"off",
"the",
"OS",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/fs.go#L162-L172 | train |
gravitational/teleport | lib/utils/listener.go | GetListenerFile | func GetListenerFile(listener net.Listener) (*os.File, error) {
switch t := listener.(type) {
case *net.TCPListener:
return t.File()
case *net.UnixListener:
return t.File()
}
return nil, trace.BadParameter("unsupported listener: %T", listener)
} | go | func GetListenerFile(listener net.Listener) (*os.File, error) {
switch t := listener.(type) {
case *net.TCPListener:
return t.File()
case *net.UnixListener:
return t.File()
}
return nil, trace.BadParameter("unsupported listener: %T", listener)
} | [
"func",
"GetListenerFile",
"(",
"listener",
"net",
".",
"Listener",
")",
"(",
"*",
"os",
".",
"File",
",",
"error",
")",
"{",
"switch",
"t",
":=",
"listener",
".",
"(",
"type",
")",
"{",
"case",
"*",
"net",
".",
"TCPListener",
":",
"return",
"t",
"... | // GetListenerFile returns file associated with listener | [
"GetListenerFile",
"returns",
"file",
"associated",
"with",
"listener"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/listener.go#L11-L19 | train |
gravitational/teleport | lib/utils/buf.go | NewSyncBuffer | func NewSyncBuffer() *SyncBuffer {
reader, writer := io.Pipe()
buf := &bytes.Buffer{}
go func() {
io.Copy(buf, reader)
}()
return &SyncBuffer{
reader: reader,
writer: writer,
buf: buf,
}
} | go | func NewSyncBuffer() *SyncBuffer {
reader, writer := io.Pipe()
buf := &bytes.Buffer{}
go func() {
io.Copy(buf, reader)
}()
return &SyncBuffer{
reader: reader,
writer: writer,
buf: buf,
}
} | [
"func",
"NewSyncBuffer",
"(",
")",
"*",
"SyncBuffer",
"{",
"reader",
",",
"writer",
":=",
"io",
".",
"Pipe",
"(",
")",
"\n",
"buf",
":=",
"&",
"bytes",
".",
"Buffer",
"{",
"}",
"\n",
"go",
"func",
"(",
")",
"{",
"io",
".",
"Copy",
"(",
"buf",
"... | // NewSyncBuffer returns new in memory buffer | [
"NewSyncBuffer",
"returns",
"new",
"in",
"memory",
"buffer"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/buf.go#L25-L36 | train |
gravitational/teleport | lib/utils/buf.go | Close | func (b *SyncBuffer) Close() error {
err := b.reader.Close()
err2 := b.writer.Close()
if err != nil {
return err
}
return err2
} | go | func (b *SyncBuffer) Close() error {
err := b.reader.Close()
err2 := b.writer.Close()
if err != nil {
return err
}
return err2
} | [
"func",
"(",
"b",
"*",
"SyncBuffer",
")",
"Close",
"(",
")",
"error",
"{",
"err",
":=",
"b",
".",
"reader",
".",
"Close",
"(",
")",
"\n",
"err2",
":=",
"b",
".",
"writer",
".",
"Close",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
... | // Close closes reads and writes on the buffer | [
"Close",
"closes",
"reads",
"and",
"writes",
"on",
"the",
"buffer"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/buf.go#L65-L72 | train |
gravitational/teleport | lib/reversetunnel/agent.go | NewAgent | func NewAgent(cfg AgentConfig) (*Agent, error) {
if err := cfg.CheckAndSetDefaults(); err != nil {
return nil, trace.Wrap(err)
}
ctx, cancel := context.WithCancel(cfg.Context)
a := &Agent{
AgentConfig: cfg,
ctx: ctx,
cancel: cancel,
authMethods: []ssh.AuthMethod{ssh.PublicKeys(cfg.Signers...)... | go | func NewAgent(cfg AgentConfig) (*Agent, error) {
if err := cfg.CheckAndSetDefaults(); err != nil {
return nil, trace.Wrap(err)
}
ctx, cancel := context.WithCancel(cfg.Context)
a := &Agent{
AgentConfig: cfg,
ctx: ctx,
cancel: cancel,
authMethods: []ssh.AuthMethod{ssh.PublicKeys(cfg.Signers...)... | [
"func",
"NewAgent",
"(",
"cfg",
"AgentConfig",
")",
"(",
"*",
"Agent",
",",
"error",
")",
"{",
"if",
"err",
":=",
"cfg",
".",
"CheckAndSetDefaults",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"trace",
".",
"Wrap",
"(",
"err",
")"... | // NewAgent returns a new reverse tunnel agent | [
"NewAgent",
"returns",
"a",
"new",
"reverse",
"tunnel",
"agent"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/reversetunnel/agent.go#L150-L174 | 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.