id int32 0 167k | 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 listlengths 21 1.41k | docstring stringlengths 6 2.61k | docstring_tokens listlengths 3 215 | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
23,000 | 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 |
23,001 | 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 |
23,002 | 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 |
23,003 | 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 |
23,004 | 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 |
23,005 | 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 |
23,006 | 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 |
23,007 | 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 |
23,008 | 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 |
23,009 | 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 |
23,010 | 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 |
23,011 | 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 |
23,012 | 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 |
23,013 | 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 |
23,014 | 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 |
23,015 | 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 |
23,016 | 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 |
23,017 | 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 |
23,018 | 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 |
23,019 | 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 |
23,020 | 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 |
23,021 | 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 |
23,022 | 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 |
23,023 | 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 |
23,024 | 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 |
23,025 | 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 |
23,026 | 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 |
23,027 | 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 |
23,028 | 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 |
23,029 | 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 |
23,030 | 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 |
23,031 | 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 |
23,032 | 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 |
23,033 | 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 |
23,034 | 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 |
23,035 | 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 |
23,036 | 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 |
23,037 | 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 |
23,038 | 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 |
23,039 | 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 |
23,040 | 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 |
23,041 | 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 |
23,042 | 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 |
23,043 | 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 |
23,044 | 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 |
23,045 | 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 |
23,046 | 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 |
23,047 | 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 |
23,048 | 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 |
23,049 | 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 |
23,050 | 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 |
23,051 | 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 |
23,052 | 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 |
23,053 | 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 |
23,054 | 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 |
23,055 | 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 |
23,056 | 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 |
23,057 | 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 |
23,058 | 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 |
23,059 | 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 |
23,060 | 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 |
23,061 | 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 |
23,062 | 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 |
23,063 | 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 |
23,064 | 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 |
23,065 | 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 |
23,066 | 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 |
23,067 | 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 |
23,068 | 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 |
23,069 | 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 |
23,070 | 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 |
23,071 | 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 |
23,072 | 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 |
23,073 | 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 |
23,074 | 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 |
23,075 | 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 |
23,076 | gravitational/teleport | lib/reversetunnel/agent.go | connectedTo | func (a *Agent) connectedTo(proxy services.Server) bool {
principals := a.getPrincipals()
proxyID := fmt.Sprintf("%v.%v", proxy.GetName(), a.ClusterName)
if _, ok := principals[proxyID]; ok {
return true
}
return false
} | go | func (a *Agent) connectedTo(proxy services.Server) bool {
principals := a.getPrincipals()
proxyID := fmt.Sprintf("%v.%v", proxy.GetName(), a.ClusterName)
if _, ok := principals[proxyID]; ok {
return true
}
return false
} | [
"func",
"(",
"a",
"*",
"Agent",
")",
"connectedTo",
"(",
"proxy",
"services",
".",
"Server",
")",
"bool",
"{",
"principals",
":=",
"a",
".",
"getPrincipals",
"(",
")",
"\n",
"proxyID",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"proxy",
".",
... | // connectedTo returns true if connected services.Server passed in. | [
"connectedTo",
"returns",
"true",
"if",
"connected",
"services",
".",
"Server",
"passed",
"in",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/reversetunnel/agent.go#L230-L237 |
23,077 | gravitational/teleport | lib/reversetunnel/agent.go | connectedToRightProxy | func (a *Agent) connectedToRightProxy() bool {
for _, proxy := range a.DiscoverProxies {
if a.connectedTo(proxy) {
return true
}
}
return false
} | go | func (a *Agent) connectedToRightProxy() bool {
for _, proxy := range a.DiscoverProxies {
if a.connectedTo(proxy) {
return true
}
}
return false
} | [
"func",
"(",
"a",
"*",
"Agent",
")",
"connectedToRightProxy",
"(",
")",
"bool",
"{",
"for",
"_",
",",
"proxy",
":=",
"range",
"a",
".",
"DiscoverProxies",
"{",
"if",
"a",
".",
"connectedTo",
"(",
"proxy",
")",
"{",
"return",
"true",
"\n",
"}",
"\n",
... | // connectedToRightProxy returns true if it connected to a proxy in the
// discover list. | [
"connectedToRightProxy",
"returns",
"true",
"if",
"it",
"connected",
"to",
"a",
"proxy",
"in",
"the",
"discover",
"list",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/reversetunnel/agent.go#L241-L248 |
23,078 | gravitational/teleport | lib/reversetunnel/agent.go | run | func (a *Agent) run() {
defer a.setState(agentStateDisconnected)
if len(a.DiscoverProxies) != 0 {
a.setStateAndPrincipals(agentStateDiscovering, nil)
} else {
a.setStateAndPrincipals(agentStateConnecting, nil)
}
// Try and connect to remote cluster.
conn, err := a.connect()
if err != nil || conn == nil {
... | go | func (a *Agent) run() {
defer a.setState(agentStateDisconnected)
if len(a.DiscoverProxies) != 0 {
a.setStateAndPrincipals(agentStateDiscovering, nil)
} else {
a.setStateAndPrincipals(agentStateConnecting, nil)
}
// Try and connect to remote cluster.
conn, err := a.connect()
if err != nil || conn == nil {
... | [
"func",
"(",
"a",
"*",
"Agent",
")",
"run",
"(",
")",
"{",
"defer",
"a",
".",
"setState",
"(",
"agentStateDisconnected",
")",
"\n\n",
"if",
"len",
"(",
"a",
".",
"DiscoverProxies",
")",
"!=",
"0",
"{",
"a",
".",
"setStateAndPrincipals",
"(",
"agentStat... | // run is the main agent loop. It tries to establish a connection to the
// remote proxy and then process requests that come over the tunnel.
//
// Once run connects to a proxy it starts processing requests from the proxy
// via SSH channels opened by the remote Proxy.
//
// Agent sends periodic heartbeats back to the ... | [
"run",
"is",
"the",
"main",
"agent",
"loop",
".",
"It",
"tries",
"to",
"establish",
"a",
"connection",
"to",
"the",
"remote",
"proxy",
"and",
"then",
"process",
"requests",
"that",
"come",
"over",
"the",
"tunnel",
".",
"Once",
"run",
"connects",
"to",
"a... | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/reversetunnel/agent.go#L324-L376 |
23,079 | gravitational/teleport | lib/reversetunnel/agent.go | processRequests | func (a *Agent) processRequests(conn *ssh.Client) error {
defer conn.Close()
ticker := time.NewTicker(defaults.ReverseTunnelAgentHeartbeatPeriod)
defer ticker.Stop()
hb, reqC, err := conn.OpenChannel(chanHeartbeat, nil)
if err != nil {
return trace.Wrap(err)
}
newTransportC := conn.HandleChannelOpen(chanTrans... | go | func (a *Agent) processRequests(conn *ssh.Client) error {
defer conn.Close()
ticker := time.NewTicker(defaults.ReverseTunnelAgentHeartbeatPeriod)
defer ticker.Stop()
hb, reqC, err := conn.OpenChannel(chanHeartbeat, nil)
if err != nil {
return trace.Wrap(err)
}
newTransportC := conn.HandleChannelOpen(chanTrans... | [
"func",
"(",
"a",
"*",
"Agent",
")",
"processRequests",
"(",
"conn",
"*",
"ssh",
".",
"Client",
")",
"error",
"{",
"defer",
"conn",
".",
"Close",
"(",
")",
"\n",
"ticker",
":=",
"time",
".",
"NewTicker",
"(",
"defaults",
".",
"ReverseTunnelAgentHeartbeat... | // processRequests is a blocking function which runs in a loop sending heartbeats
// to the given SSH connection and processes inbound requests from the
// remote proxy | [
"processRequests",
"is",
"a",
"blocking",
"function",
"which",
"runs",
"in",
"a",
"loop",
"sending",
"heartbeats",
"to",
"the",
"given",
"SSH",
"connection",
"and",
"processes",
"inbound",
"requests",
"from",
"the",
"remote",
"proxy"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/reversetunnel/agent.go#L384-L454 |
23,080 | gravitational/teleport | lib/utils/retry.go | NewLinear | func NewLinear(cfg LinearConfig) (*Linear, error) {
if err := cfg.CheckAndSetDefaults(); err != nil {
return nil, trace.Wrap(err)
}
closedChan := make(chan time.Time)
close(closedChan)
return &Linear{LinearConfig: cfg, closedChan: closedChan}, nil
} | go | func NewLinear(cfg LinearConfig) (*Linear, error) {
if err := cfg.CheckAndSetDefaults(); err != nil {
return nil, trace.Wrap(err)
}
closedChan := make(chan time.Time)
close(closedChan)
return &Linear{LinearConfig: cfg, closedChan: closedChan}, nil
} | [
"func",
"NewLinear",
"(",
"cfg",
"LinearConfig",
")",
"(",
"*",
"Linear",
",",
"error",
")",
"{",
"if",
"err",
":=",
"cfg",
".",
"CheckAndSetDefaults",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"trace",
".",
"Wrap",
"(",
"err",
... | // NewLinear returns a new instance of linear retry | [
"NewLinear",
"returns",
"a",
"new",
"instance",
"of",
"linear",
"retry"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/retry.go#L66-L73 |
23,081 | gravitational/teleport | lib/utils/retry.go | Duration | func (r *Linear) Duration() time.Duration {
a := r.First + time.Duration(r.attempt)*r.Step
if a < 0 {
return 0
}
if a <= r.Max {
return a
}
return r.Max
} | go | func (r *Linear) Duration() time.Duration {
a := r.First + time.Duration(r.attempt)*r.Step
if a < 0 {
return 0
}
if a <= r.Max {
return a
}
return r.Max
} | [
"func",
"(",
"r",
"*",
"Linear",
")",
"Duration",
"(",
")",
"time",
".",
"Duration",
"{",
"a",
":=",
"r",
".",
"First",
"+",
"time",
".",
"Duration",
"(",
"r",
".",
"attempt",
")",
"*",
"r",
".",
"Step",
"\n",
"if",
"a",
"<",
"0",
"{",
"retur... | // Duration returns retry duration based on state | [
"Duration",
"returns",
"retry",
"duration",
"based",
"on",
"state"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/retry.go#L98-L107 |
23,082 | gravitational/teleport | lib/utils/retry.go | After | func (r *Linear) After() <-chan time.Time {
if r.Duration() == 0 {
return r.closedChan
}
return time.After(r.Duration())
} | go | func (r *Linear) After() <-chan time.Time {
if r.Duration() == 0 {
return r.closedChan
}
return time.After(r.Duration())
} | [
"func",
"(",
"r",
"*",
"Linear",
")",
"After",
"(",
")",
"<-",
"chan",
"time",
".",
"Time",
"{",
"if",
"r",
".",
"Duration",
"(",
")",
"==",
"0",
"{",
"return",
"r",
".",
"closedChan",
"\n",
"}",
"\n",
"return",
"time",
".",
"After",
"(",
"r",
... | // After returns channel that fires with timeout
// defined in Duration method, as a special case
// if Duration is 0 returns a closed channel | [
"After",
"returns",
"channel",
"that",
"fires",
"with",
"timeout",
"defined",
"in",
"Duration",
"method",
"as",
"a",
"special",
"case",
"if",
"Duration",
"is",
"0",
"returns",
"a",
"closed",
"channel"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/retry.go#L112-L117 |
23,083 | gravitational/teleport | lib/utils/retry.go | String | func (r *Linear) String() string {
return fmt.Sprintf("Linear(attempt=%v, duration=%v)", r.attempt, r.Duration())
} | go | func (r *Linear) String() string {
return fmt.Sprintf("Linear(attempt=%v, duration=%v)", r.attempt, r.Duration())
} | [
"func",
"(",
"r",
"*",
"Linear",
")",
"String",
"(",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"r",
".",
"attempt",
",",
"r",
".",
"Duration",
"(",
")",
")",
"\n",
"}"
] | // String returns user-friendly representation of the LinearPeriod | [
"String",
"returns",
"user",
"-",
"friendly",
"representation",
"of",
"the",
"LinearPeriod"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/retry.go#L120-L122 |
23,084 | gravitational/teleport | lib/shell/shell_unix.go | getLoginShell | func getLoginShell(username string) (string, error) {
// See if the username is valid.
_, err := user.Lookup(username)
if err != nil {
return "", trace.Wrap(err)
}
// Based on stdlib user/lookup_unix.go packages which does not return
// user shell: https://golang.org/src/os/user/lookup_unix.go
var pwd C.struc... | go | func getLoginShell(username string) (string, error) {
// See if the username is valid.
_, err := user.Lookup(username)
if err != nil {
return "", trace.Wrap(err)
}
// Based on stdlib user/lookup_unix.go packages which does not return
// user shell: https://golang.org/src/os/user/lookup_unix.go
var pwd C.struc... | [
"func",
"getLoginShell",
"(",
"username",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"// See if the username is valid.",
"_",
",",
"err",
":=",
"user",
".",
"Lookup",
"(",
"username",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"... | // getLoginShell determines the login shell for a given username | [
"getLoginShell",
"determines",
"the",
"login",
"shell",
"for",
"a",
"given",
"username"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/shell/shell_unix.go#L46-L88 |
23,085 | gravitational/teleport | lib/sshutils/fingerprint.go | AuthorizedKeyFingerprint | func AuthorizedKeyFingerprint(publicKey []byte) (string, error) {
key, _, _, _, err := ssh.ParseAuthorizedKey(publicKey)
if err != nil {
return "", trace.Wrap(err)
}
return Fingerprint(key), nil
} | go | func AuthorizedKeyFingerprint(publicKey []byte) (string, error) {
key, _, _, _, err := ssh.ParseAuthorizedKey(publicKey)
if err != nil {
return "", trace.Wrap(err)
}
return Fingerprint(key), nil
} | [
"func",
"AuthorizedKeyFingerprint",
"(",
"publicKey",
"[",
"]",
"byte",
")",
"(",
"string",
",",
"error",
")",
"{",
"key",
",",
"_",
",",
"_",
",",
"_",
",",
"err",
":=",
"ssh",
".",
"ParseAuthorizedKey",
"(",
"publicKey",
")",
"\n",
"if",
"err",
"!=... | // AuthorizedKeyFingerprint returns fingerprint from public key
// in authorized key format | [
"AuthorizedKeyFingerprint",
"returns",
"fingerprint",
"from",
"public",
"key",
"in",
"authorized",
"key",
"format"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/sshutils/fingerprint.go#L15-L21 |
23,086 | gravitational/teleport | lib/sshutils/fingerprint.go | PrivateKeyFingerprint | func PrivateKeyFingerprint(keyBytes []byte) (string, error) {
signer, err := ssh.ParsePrivateKey(keyBytes)
if err != nil {
return "", trace.Wrap(err)
}
return Fingerprint(signer.PublicKey()), nil
} | go | func PrivateKeyFingerprint(keyBytes []byte) (string, error) {
signer, err := ssh.ParsePrivateKey(keyBytes)
if err != nil {
return "", trace.Wrap(err)
}
return Fingerprint(signer.PublicKey()), nil
} | [
"func",
"PrivateKeyFingerprint",
"(",
"keyBytes",
"[",
"]",
"byte",
")",
"(",
"string",
",",
"error",
")",
"{",
"signer",
",",
"err",
":=",
"ssh",
".",
"ParsePrivateKey",
"(",
"keyBytes",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
... | // PrivateKeyFingerprint returns fingerprint of the public key
// extracted from the PEM encoded private key | [
"PrivateKeyFingerprint",
"returns",
"fingerprint",
"of",
"the",
"public",
"key",
"extracted",
"from",
"the",
"PEM",
"encoded",
"private",
"key"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/sshutils/fingerprint.go#L25-L31 |
23,087 | gravitational/teleport | lib/utils/anonymizer.go | NewHMACAnonymizer | func NewHMACAnonymizer(key string) (*hmacAnonymizer, error) {
if strings.TrimSpace(key) == "" {
return nil, trace.BadParameter("HMAC key must not be empty")
}
return &hmacAnonymizer{
key: key,
}, nil
} | go | func NewHMACAnonymizer(key string) (*hmacAnonymizer, error) {
if strings.TrimSpace(key) == "" {
return nil, trace.BadParameter("HMAC key must not be empty")
}
return &hmacAnonymizer{
key: key,
}, nil
} | [
"func",
"NewHMACAnonymizer",
"(",
"key",
"string",
")",
"(",
"*",
"hmacAnonymizer",
",",
"error",
")",
"{",
"if",
"strings",
".",
"TrimSpace",
"(",
"key",
")",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"trace",
".",
"BadParameter",
"(",
"\"",
"\"",
... | // NewHMACAnonymizer returns a new HMAC-based anonymizer | [
"NewHMACAnonymizer",
"returns",
"a",
"new",
"HMAC",
"-",
"based",
"anonymizer"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/anonymizer.go#L41-L48 |
23,088 | gravitational/teleport | lib/utils/anonymizer.go | Anonymize | func (a *hmacAnonymizer) Anonymize(data []byte) string {
h := hmac.New(sha256.New, []byte(a.key))
h.Write(data)
return base64.StdEncoding.EncodeToString(h.Sum(nil))
} | go | func (a *hmacAnonymizer) Anonymize(data []byte) string {
h := hmac.New(sha256.New, []byte(a.key))
h.Write(data)
return base64.StdEncoding.EncodeToString(h.Sum(nil))
} | [
"func",
"(",
"a",
"*",
"hmacAnonymizer",
")",
"Anonymize",
"(",
"data",
"[",
"]",
"byte",
")",
"string",
"{",
"h",
":=",
"hmac",
".",
"New",
"(",
"sha256",
".",
"New",
",",
"[",
"]",
"byte",
"(",
"a",
".",
"key",
")",
")",
"\n",
"h",
".",
"Wr... | // Anonymize anonymizes the provided data using HMAC | [
"Anonymize",
"anonymizes",
"the",
"provided",
"data",
"using",
"HMAC"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/anonymizer.go#L51-L55 |
23,089 | gravitational/teleport | lib/utils/schema.go | UnmarshalWithSchema | func UnmarshalWithSchema(schemaDefinition string, object interface{}, data []byte) error {
schema, err := jsonschema.New([]byte(schemaDefinition))
if err != nil {
return trace.Wrap(err)
}
jsonData, err := ToJSON(data)
if err != nil {
return trace.Wrap(err)
}
raw := map[string]interface{}{}
if err := json.U... | go | func UnmarshalWithSchema(schemaDefinition string, object interface{}, data []byte) error {
schema, err := jsonschema.New([]byte(schemaDefinition))
if err != nil {
return trace.Wrap(err)
}
jsonData, err := ToJSON(data)
if err != nil {
return trace.Wrap(err)
}
raw := map[string]interface{}{}
if err := json.U... | [
"func",
"UnmarshalWithSchema",
"(",
"schemaDefinition",
"string",
",",
"object",
"interface",
"{",
"}",
",",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"schema",
",",
"err",
":=",
"jsonschema",
".",
"New",
"(",
"[",
"]",
"byte",
"(",
"schemaDefinition",
... | // UnmarshalWithSchema processes YAML or JSON encoded object with JSON schema, sets defaults
// and unmarshals resulting object into given struct | [
"UnmarshalWithSchema",
"processes",
"YAML",
"or",
"JSON",
"encoded",
"object",
"with",
"JSON",
"schema",
"sets",
"defaults",
"and",
"unmarshals",
"resulting",
"object",
"into",
"given",
"struct"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/schema.go#L28-L57 |
23,090 | gravitational/teleport | lib/events/archive.go | NewSessionArchive | func NewSessionArchive(dataDir, serverID, namespace string, sessionID session.ID) (io.ReadCloser, error) {
index, err := readSessionIndex(
dataDir, []string{serverID}, namespace, sessionID)
if err != nil {
return nil, trace.Wrap(err)
}
// io.Pipe allows to generate the archive part by part
// without writing ... | go | func NewSessionArchive(dataDir, serverID, namespace string, sessionID session.ID) (io.ReadCloser, error) {
index, err := readSessionIndex(
dataDir, []string{serverID}, namespace, sessionID)
if err != nil {
return nil, trace.Wrap(err)
}
// io.Pipe allows to generate the archive part by part
// without writing ... | [
"func",
"NewSessionArchive",
"(",
"dataDir",
",",
"serverID",
",",
"namespace",
"string",
",",
"sessionID",
"session",
".",
"ID",
")",
"(",
"io",
".",
"ReadCloser",
",",
"error",
")",
"{",
"index",
",",
"err",
":=",
"readSessionIndex",
"(",
"dataDir",
",",... | // NewSessionArchive returns generated tar archive with all components | [
"NewSessionArchive",
"returns",
"generated",
"tar",
"archive",
"with",
"all",
"components"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/events/archive.go#L30-L49 |
23,091 | gravitational/teleport | lib/utils/certs.go | ParseSigningKeyStorePEM | func ParseSigningKeyStorePEM(keyPEM, certPEM string) (*SigningKeyStore, error) {
_, err := ParseCertificatePEM([]byte(certPEM))
if err != nil {
return nil, trace.Wrap(err)
}
key, err := ParsePrivateKeyPEM([]byte(keyPEM))
if err != nil {
return nil, trace.Wrap(err)
}
rsaKey, ok := key.(*rsa.PrivateKey)
if !o... | go | func ParseSigningKeyStorePEM(keyPEM, certPEM string) (*SigningKeyStore, error) {
_, err := ParseCertificatePEM([]byte(certPEM))
if err != nil {
return nil, trace.Wrap(err)
}
key, err := ParsePrivateKeyPEM([]byte(keyPEM))
if err != nil {
return nil, trace.Wrap(err)
}
rsaKey, ok := key.(*rsa.PrivateKey)
if !o... | [
"func",
"ParseSigningKeyStorePEM",
"(",
"keyPEM",
",",
"certPEM",
"string",
")",
"(",
"*",
"SigningKeyStore",
",",
"error",
")",
"{",
"_",
",",
"err",
":=",
"ParseCertificatePEM",
"(",
"[",
"]",
"byte",
"(",
"certPEM",
")",
")",
"\n",
"if",
"err",
"!=",
... | // ParseSigningKeyStore parses signing key store from PEM encoded key pair | [
"ParseSigningKeyStore",
"parses",
"signing",
"key",
"store",
"from",
"PEM",
"encoded",
"key",
"pair"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/certs.go#L36-L54 |
23,092 | gravitational/teleport | lib/utils/certs.go | ParseCertificateRequestPEM | func ParseCertificateRequestPEM(bytes []byte) (*x509.CertificateRequest, error) {
block, _ := pem.Decode(bytes)
if block == nil {
return nil, trace.BadParameter("expected PEM-encoded block")
}
csr, err := x509.ParseCertificateRequest(block.Bytes)
if err != nil {
return nil, trace.BadParameter(err.Error())
}
... | go | func ParseCertificateRequestPEM(bytes []byte) (*x509.CertificateRequest, error) {
block, _ := pem.Decode(bytes)
if block == nil {
return nil, trace.BadParameter("expected PEM-encoded block")
}
csr, err := x509.ParseCertificateRequest(block.Bytes)
if err != nil {
return nil, trace.BadParameter(err.Error())
}
... | [
"func",
"ParseCertificateRequestPEM",
"(",
"bytes",
"[",
"]",
"byte",
")",
"(",
"*",
"x509",
".",
"CertificateRequest",
",",
"error",
")",
"{",
"block",
",",
"_",
":=",
"pem",
".",
"Decode",
"(",
"bytes",
")",
"\n",
"if",
"block",
"==",
"nil",
"{",
"... | // ParseCertificateRequestPEM parses PEM-encoded certificate signing request | [
"ParseCertificateRequestPEM",
"parses",
"PEM",
"-",
"encoded",
"certificate",
"signing",
"request"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/certs.go#L105-L115 |
23,093 | gravitational/teleport | lib/utils/certs.go | ParseCertificatePEM | func ParseCertificatePEM(bytes []byte) (*x509.Certificate, error) {
block, _ := pem.Decode(bytes)
if block == nil {
return nil, trace.BadParameter("expected PEM-encoded block")
}
cert, err := x509.ParseCertificate(block.Bytes)
if err != nil {
return nil, trace.BadParameter(err.Error())
}
return cert, nil
} | go | func ParseCertificatePEM(bytes []byte) (*x509.Certificate, error) {
block, _ := pem.Decode(bytes)
if block == nil {
return nil, trace.BadParameter("expected PEM-encoded block")
}
cert, err := x509.ParseCertificate(block.Bytes)
if err != nil {
return nil, trace.BadParameter(err.Error())
}
return cert, nil
} | [
"func",
"ParseCertificatePEM",
"(",
"bytes",
"[",
"]",
"byte",
")",
"(",
"*",
"x509",
".",
"Certificate",
",",
"error",
")",
"{",
"block",
",",
"_",
":=",
"pem",
".",
"Decode",
"(",
"bytes",
")",
"\n",
"if",
"block",
"==",
"nil",
"{",
"return",
"ni... | // ParseCertificatePEM parses PEM-encoded certificate | [
"ParseCertificatePEM",
"parses",
"PEM",
"-",
"encoded",
"certificate"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/certs.go#L118-L128 |
23,094 | gravitational/teleport | lib/utils/certs.go | ParsePrivateKeyPEM | func ParsePrivateKeyPEM(bytes []byte) (crypto.Signer, error) {
block, _ := pem.Decode(bytes)
if block == nil {
return nil, trace.BadParameter("expected PEM-encoded block")
}
return ParsePrivateKeyDER(block.Bytes)
} | go | func ParsePrivateKeyPEM(bytes []byte) (crypto.Signer, error) {
block, _ := pem.Decode(bytes)
if block == nil {
return nil, trace.BadParameter("expected PEM-encoded block")
}
return ParsePrivateKeyDER(block.Bytes)
} | [
"func",
"ParsePrivateKeyPEM",
"(",
"bytes",
"[",
"]",
"byte",
")",
"(",
"crypto",
".",
"Signer",
",",
"error",
")",
"{",
"block",
",",
"_",
":=",
"pem",
".",
"Decode",
"(",
"bytes",
")",
"\n",
"if",
"block",
"==",
"nil",
"{",
"return",
"nil",
",",
... | // ParsePrivateKeyPEM parses PEM-encoded private key | [
"ParsePrivateKeyPEM",
"parses",
"PEM",
"-",
"encoded",
"private",
"key"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/certs.go#L131-L137 |
23,095 | gravitational/teleport | lib/utils/certs.go | ParsePrivateKeyDER | func ParsePrivateKeyDER(der []byte) (crypto.Signer, error) {
generalKey, err := x509.ParsePKCS8PrivateKey(der)
if err != nil {
generalKey, err = x509.ParsePKCS1PrivateKey(der)
if err != nil {
generalKey, err = x509.ParseECPrivateKey(der)
if err != nil {
logrus.Errorf("Failed to parse key: %v.", err)
... | go | func ParsePrivateKeyDER(der []byte) (crypto.Signer, error) {
generalKey, err := x509.ParsePKCS8PrivateKey(der)
if err != nil {
generalKey, err = x509.ParsePKCS1PrivateKey(der)
if err != nil {
generalKey, err = x509.ParseECPrivateKey(der)
if err != nil {
logrus.Errorf("Failed to parse key: %v.", err)
... | [
"func",
"ParsePrivateKeyDER",
"(",
"der",
"[",
"]",
"byte",
")",
"(",
"crypto",
".",
"Signer",
",",
"error",
")",
"{",
"generalKey",
",",
"err",
":=",
"x509",
".",
"ParsePKCS8PrivateKey",
"(",
"der",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"generalKe... | // ParsePrivateKeyDER parses unencrypted DER-encoded private key | [
"ParsePrivateKeyDER",
"parses",
"unencrypted",
"DER",
"-",
"encoded",
"private",
"key"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/certs.go#L140-L161 |
23,096 | gravitational/teleport | lib/utils/certs.go | ReadCertificateChain | func ReadCertificateChain(certificateChainBytes []byte) ([]*x509.Certificate, error) {
// build the certificate chain next
var certificateBlock *pem.Block
var remainingBytes []byte = bytes.TrimSpace(certificateChainBytes)
var certificateChain [][]byte
for {
certificateBlock, remainingBytes = pem.Decode(remainin... | go | func ReadCertificateChain(certificateChainBytes []byte) ([]*x509.Certificate, error) {
// build the certificate chain next
var certificateBlock *pem.Block
var remainingBytes []byte = bytes.TrimSpace(certificateChainBytes)
var certificateChain [][]byte
for {
certificateBlock, remainingBytes = pem.Decode(remainin... | [
"func",
"ReadCertificateChain",
"(",
"certificateChainBytes",
"[",
"]",
"byte",
")",
"(",
"[",
"]",
"*",
"x509",
".",
"Certificate",
",",
"error",
")",
"{",
"// build the certificate chain next",
"var",
"certificateBlock",
"*",
"pem",
".",
"Block",
"\n",
"var",
... | // ReadCertificateChain parses PEM encoded bytes that can contain one or
// multiple certificates and returns a slice of x509.Certificate. | [
"ReadCertificateChain",
"parses",
"PEM",
"encoded",
"bytes",
"that",
"can",
"contain",
"one",
"or",
"multiple",
"certificates",
"and",
"returns",
"a",
"slice",
"of",
"x509",
".",
"Certificate",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/certs.go#L226-L260 |
23,097 | gravitational/teleport | lib/utils/loadbalancer.go | NewLoadBalancer | func NewLoadBalancer(ctx context.Context, frontend NetAddr, backends ...NetAddr) (*LoadBalancer, error) {
if ctx == nil {
return nil, trace.BadParameter("missing parameter context")
}
waitCtx, waitCancel := context.WithCancel(ctx)
return &LoadBalancer{
frontend: frontend,
ctx: ctx,
backends: ... | go | func NewLoadBalancer(ctx context.Context, frontend NetAddr, backends ...NetAddr) (*LoadBalancer, error) {
if ctx == nil {
return nil, trace.BadParameter("missing parameter context")
}
waitCtx, waitCancel := context.WithCancel(ctx)
return &LoadBalancer{
frontend: frontend,
ctx: ctx,
backends: ... | [
"func",
"NewLoadBalancer",
"(",
"ctx",
"context",
".",
"Context",
",",
"frontend",
"NetAddr",
",",
"backends",
"...",
"NetAddr",
")",
"(",
"*",
"LoadBalancer",
",",
"error",
")",
"{",
"if",
"ctx",
"==",
"nil",
"{",
"return",
"nil",
",",
"trace",
".",
"... | // NewLoadBalancer returns new load balancer listening on frontend
// and redirecting requests to backends using round robin algo | [
"NewLoadBalancer",
"returns",
"new",
"load",
"balancer",
"listening",
"on",
"frontend",
"and",
"redirecting",
"requests",
"to",
"backends",
"using",
"round",
"robin",
"algo"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/loadbalancer.go#L32-L52 |
23,098 | gravitational/teleport | lib/utils/loadbalancer.go | trackConnection | func (l *LoadBalancer) trackConnection(backend NetAddr, conn net.Conn) int64 {
l.Lock()
defer l.Unlock()
l.connID += 1
tracker, ok := l.connections[backend]
if !ok {
tracker = make(map[int64]net.Conn)
l.connections[backend] = tracker
}
tracker[l.connID] = conn
return l.connID
} | go | func (l *LoadBalancer) trackConnection(backend NetAddr, conn net.Conn) int64 {
l.Lock()
defer l.Unlock()
l.connID += 1
tracker, ok := l.connections[backend]
if !ok {
tracker = make(map[int64]net.Conn)
l.connections[backend] = tracker
}
tracker[l.connID] = conn
return l.connID
} | [
"func",
"(",
"l",
"*",
"LoadBalancer",
")",
"trackConnection",
"(",
"backend",
"NetAddr",
",",
"conn",
"net",
".",
"Conn",
")",
"int64",
"{",
"l",
".",
"Lock",
"(",
")",
"\n",
"defer",
"l",
".",
"Unlock",
"(",
")",
"\n",
"l",
".",
"connID",
"+=",
... | // trackeConnection adds connection to the connection tracker | [
"trackeConnection",
"adds",
"connection",
"to",
"the",
"connection",
"tracker"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/loadbalancer.go#L72-L83 |
23,099 | gravitational/teleport | lib/utils/loadbalancer.go | untrackConnection | func (l *LoadBalancer) untrackConnection(backend NetAddr, id int64) {
l.Lock()
defer l.Unlock()
tracker, ok := l.connections[backend]
if !ok {
return
}
delete(tracker, id)
} | go | func (l *LoadBalancer) untrackConnection(backend NetAddr, id int64) {
l.Lock()
defer l.Unlock()
tracker, ok := l.connections[backend]
if !ok {
return
}
delete(tracker, id)
} | [
"func",
"(",
"l",
"*",
"LoadBalancer",
")",
"untrackConnection",
"(",
"backend",
"NetAddr",
",",
"id",
"int64",
")",
"{",
"l",
".",
"Lock",
"(",
")",
"\n",
"defer",
"l",
".",
"Unlock",
"(",
")",
"\n",
"tracker",
",",
"ok",
":=",
"l",
".",
"connecti... | // untrackConnection removes connection from connection tracker | [
"untrackConnection",
"removes",
"connection",
"from",
"connection",
"tracker"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/loadbalancer.go#L86-L94 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.