repo stringlengths 5 54 | path stringlengths 4 155 | func_name stringlengths 1 118 | original_string stringlengths 52 85.5k | language stringclasses 1
value | code stringlengths 52 85.5k | code_tokens list | docstring stringlengths 6 2.61k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 85 252 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
gravitational/teleport | lib/client/redirect.go | callback | func (rd *Redirector) callback(w http.ResponseWriter, r *http.Request) (*auth.SSHLoginResponse, error) {
if r.URL.Path != "/callback" {
return nil, trace.NotFound("path not found")
}
// Decrypt ciphertext to get login response.
plaintext, err := rd.key.Open([]byte(r.URL.Query().Get("response")))
if err != nil {... | go | func (rd *Redirector) callback(w http.ResponseWriter, r *http.Request) (*auth.SSHLoginResponse, error) {
if r.URL.Path != "/callback" {
return nil, trace.NotFound("path not found")
}
// Decrypt ciphertext to get login response.
plaintext, err := rd.key.Open([]byte(r.URL.Query().Get("response")))
if err != nil {... | [
"func",
"(",
"rd",
"*",
"Redirector",
")",
"callback",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"(",
"*",
"auth",
".",
"SSHLoginResponse",
",",
"error",
")",
"{",
"if",
"r",
".",
"URL",
".",
"Path",
"!=",... | // callback is used by Teleport proxy to send back credentials
// issued by Teleport proxy | [
"callback",
"is",
"used",
"by",
"Teleport",
"proxy",
"to",
"send",
"back",
"credentials",
"issued",
"by",
"Teleport",
"proxy"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/redirect.go#L191-L209 | train |
gravitational/teleport | lib/client/redirect.go | Close | func (rd *Redirector) Close() error {
rd.cancel()
if rd.server != nil {
rd.server.Close()
}
return nil
} | go | func (rd *Redirector) Close() error {
rd.cancel()
if rd.server != nil {
rd.server.Close()
}
return nil
} | [
"func",
"(",
"rd",
"*",
"Redirector",
")",
"Close",
"(",
")",
"error",
"{",
"rd",
".",
"cancel",
"(",
")",
"\n",
"if",
"rd",
".",
"server",
"!=",
"nil",
"{",
"rd",
".",
"server",
".",
"Close",
"(",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
... | // Close closes redirector and releases all resources | [
"Close",
"closes",
"redirector",
"and",
"releases",
"all",
"resources"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/redirect.go#L212-L218 | train |
gravitational/teleport | lib/client/redirect.go | wrapCallback | func (rd *Redirector) wrapCallback(fn func(http.ResponseWriter, *http.Request) (*auth.SSHLoginResponse, error)) http.Handler {
clone := *rd.proxyURL
clone.Path = "/web/msg/error/login_failed"
errorURL := clone.String()
clone.Path = "/web/msg/info/login_success"
successURL := clone.String()
return http.HandlerFun... | go | func (rd *Redirector) wrapCallback(fn func(http.ResponseWriter, *http.Request) (*auth.SSHLoginResponse, error)) http.Handler {
clone := *rd.proxyURL
clone.Path = "/web/msg/error/login_failed"
errorURL := clone.String()
clone.Path = "/web/msg/info/login_success"
successURL := clone.String()
return http.HandlerFun... | [
"func",
"(",
"rd",
"*",
"Redirector",
")",
"wrapCallback",
"(",
"fn",
"func",
"(",
"http",
".",
"ResponseWriter",
",",
"*",
"http",
".",
"Request",
")",
"(",
"*",
"auth",
".",
"SSHLoginResponse",
",",
"error",
")",
")",
"http",
".",
"Handler",
"{",
"... | // wrapCallback is a helper wrapper method that wraps callback HTTP handler
// and sends a result to the channel and redirect users to error page | [
"wrapCallback",
"is",
"a",
"helper",
"wrapper",
"method",
"that",
"wraps",
"callback",
"HTTP",
"handler",
"and",
"sends",
"a",
"result",
"to",
"the",
"channel",
"and",
"redirect",
"users",
"to",
"error",
"page"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/redirect.go#L222-L253 | train |
gravitational/teleport | lib/services/license.go | NewLicense | func NewLicense(name string, spec LicenseSpecV3) (License, error) {
return &LicenseV3{
Kind: KindLicense,
Version: V3,
Metadata: Metadata{
Name: name,
Namespace: defaults.Namespace,
},
Spec: spec,
}, nil
} | go | func NewLicense(name string, spec LicenseSpecV3) (License, error) {
return &LicenseV3{
Kind: KindLicense,
Version: V3,
Metadata: Metadata{
Name: name,
Namespace: defaults.Namespace,
},
Spec: spec,
}, nil
} | [
"func",
"NewLicense",
"(",
"name",
"string",
",",
"spec",
"LicenseSpecV3",
")",
"(",
"License",
",",
"error",
")",
"{",
"return",
"&",
"LicenseV3",
"{",
"Kind",
":",
"KindLicense",
",",
"Version",
":",
"V3",
",",
"Metadata",
":",
"Metadata",
"{",
"Name",... | // NewLicense is a convenience method to to create LicenseV3. | [
"NewLicense",
"is",
"a",
"convenience",
"method",
"to",
"to",
"create",
"LicenseV3",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/license.go#L73-L83 | train |
gravitational/teleport | lib/services/license.go | SetLabels | func (c *LicenseV3) SetLabels(labels map[string]string) {
c.Metadata.Labels = labels
} | go | func (c *LicenseV3) SetLabels(labels map[string]string) {
c.Metadata.Labels = labels
} | [
"func",
"(",
"c",
"*",
"LicenseV3",
")",
"SetLabels",
"(",
"labels",
"map",
"[",
"string",
"]",
"string",
")",
"{",
"c",
".",
"Metadata",
".",
"Labels",
"=",
"labels",
"\n",
"}"
] | // SetLabels sets metadata labels | [
"SetLabels",
"sets",
"metadata",
"labels"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/license.go#L139-L141 | train |
gravitational/teleport | lib/services/license.go | String | func (c *LicenseV3) String() string {
var features []string
if !c.Expiry().IsZero() {
features = append(features, fmt.Sprintf("expires at %v", c.Expiry()))
}
if c.Spec.ReportsUsage.Value() {
features = append(features, "reports usage")
}
if c.Spec.SupportsKubernetes.Value() {
features = append(features, "su... | go | func (c *LicenseV3) String() string {
var features []string
if !c.Expiry().IsZero() {
features = append(features, fmt.Sprintf("expires at %v", c.Expiry()))
}
if c.Spec.ReportsUsage.Value() {
features = append(features, "reports usage")
}
if c.Spec.SupportsKubernetes.Value() {
features = append(features, "su... | [
"func",
"(",
"c",
"*",
"LicenseV3",
")",
"String",
"(",
")",
"string",
"{",
"var",
"features",
"[",
"]",
"string",
"\n",
"if",
"!",
"c",
".",
"Expiry",
"(",
")",
".",
"IsZero",
"(",
")",
"{",
"features",
"=",
"append",
"(",
"features",
",",
"fmt"... | // String represents a human readable version of license enabled features | [
"String",
"represents",
"a",
"human",
"readable",
"version",
"of",
"license",
"enabled",
"features"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/license.go#L227-L248 | train |
gravitational/teleport | lib/services/license.go | UnmarshalLicense | func UnmarshalLicense(bytes []byte) (License, error) {
if len(bytes) == 0 {
return nil, trace.BadParameter("missing resource data")
}
schema := fmt.Sprintf(V2SchemaTemplate, MetadataSchema, LicenseSpecV3Template, DefaultDefinitions)
var license LicenseV3
err := utils.UnmarshalWithSchema(schema, &license, bytes... | go | func UnmarshalLicense(bytes []byte) (License, error) {
if len(bytes) == 0 {
return nil, trace.BadParameter("missing resource data")
}
schema := fmt.Sprintf(V2SchemaTemplate, MetadataSchema, LicenseSpecV3Template, DefaultDefinitions)
var license LicenseV3
err := utils.UnmarshalWithSchema(schema, &license, bytes... | [
"func",
"UnmarshalLicense",
"(",
"bytes",
"[",
"]",
"byte",
")",
"(",
"License",
",",
"error",
")",
"{",
"if",
"len",
"(",
"bytes",
")",
"==",
"0",
"{",
"return",
"nil",
",",
"trace",
".",
"BadParameter",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
... | // UnmarshalLicense unmarshals License from JSON or YAML
// and validates schema | [
"UnmarshalLicense",
"unmarshals",
"License",
"from",
"JSON",
"or",
"YAML",
"and",
"validates",
"schema"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/license.go#L292-L314 | train |
gravitational/teleport | lib/services/license.go | MarshalLicense | func MarshalLicense(license License, opts ...MarshalOption) ([]byte, error) {
cfg, err := collectOptions(opts)
if err != nil {
return nil, trace.Wrap(err)
}
switch resource := license.(type) {
case *LicenseV3:
if !cfg.PreserveResourceID {
// avoid modifying the original object
// to prevent unexpected da... | go | func MarshalLicense(license License, opts ...MarshalOption) ([]byte, error) {
cfg, err := collectOptions(opts)
if err != nil {
return nil, trace.Wrap(err)
}
switch resource := license.(type) {
case *LicenseV3:
if !cfg.PreserveResourceID {
// avoid modifying the original object
// to prevent unexpected da... | [
"func",
"MarshalLicense",
"(",
"license",
"License",
",",
"opts",
"...",
"MarshalOption",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"cfg",
",",
"err",
":=",
"collectOptions",
"(",
"opts",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
... | // MarshalLicense marshals role to JSON or YAML. | [
"MarshalLicense",
"marshals",
"role",
"to",
"JSON",
"or",
"YAML",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/license.go#L317-L335 | train |
gravitational/teleport | lib/reversetunnel/agentpool.go | NewAgentPool | func NewAgentPool(cfg AgentPoolConfig) (*AgentPool, error) {
if err := cfg.CheckAndSetDefaults(); err != nil {
return nil, trace.Wrap(err)
}
ctx, cancel := context.WithCancel(cfg.Context)
pool := &AgentPool{
agents: make(map[agentKey][]*Agent),
cfg: cfg,
ctx: ctx,
cancel: cancel,
d... | go | func NewAgentPool(cfg AgentPoolConfig) (*AgentPool, error) {
if err := cfg.CheckAndSetDefaults(); err != nil {
return nil, trace.Wrap(err)
}
ctx, cancel := context.WithCancel(cfg.Context)
pool := &AgentPool{
agents: make(map[agentKey][]*Agent),
cfg: cfg,
ctx: ctx,
cancel: cancel,
d... | [
"func",
"NewAgentPool",
"(",
"cfg",
"AgentPoolConfig",
")",
"(",
"*",
"AgentPool",
",",
"error",
")",
"{",
"if",
"err",
":=",
"cfg",
".",
"CheckAndSetDefaults",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"trace",
".",
"Wrap",
"(",
... | // NewAgentPool returns new isntance of the agent pool | [
"NewAgentPool",
"returns",
"new",
"isntance",
"of",
"the",
"agent",
"pool"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/reversetunnel/agentpool.go#L114-L133 | train |
gravitational/teleport | lib/reversetunnel/agentpool.go | reportStats | func (m *AgentPool) reportStats() {
var logReport bool
if m.cfg.Clock.Now().Sub(m.lastReport) > defaults.ReportingPeriod {
m.lastReport = m.cfg.Clock.Now()
logReport = true
}
for key, agents := range m.agents {
m.Debugf("Outbound tunnel for %v connected to %v proxies.", key.tunnelID, len(agents))
countPer... | go | func (m *AgentPool) reportStats() {
var logReport bool
if m.cfg.Clock.Now().Sub(m.lastReport) > defaults.ReportingPeriod {
m.lastReport = m.cfg.Clock.Now()
logReport = true
}
for key, agents := range m.agents {
m.Debugf("Outbound tunnel for %v connected to %v proxies.", key.tunnelID, len(agents))
countPer... | [
"func",
"(",
"m",
"*",
"AgentPool",
")",
"reportStats",
"(",
")",
"{",
"var",
"logReport",
"bool",
"\n",
"if",
"m",
".",
"cfg",
".",
"Clock",
".",
"Now",
"(",
")",
".",
"Sub",
"(",
"m",
".",
"lastReport",
")",
">",
"defaults",
".",
"ReportingPeriod... | // reportStats submits report about agents state once in a while at info
// level. Always logs more detailed information at debug level. | [
"reportStats",
"submits",
"report",
"about",
"agents",
"state",
"once",
"in",
"a",
"while",
"at",
"info",
"level",
".",
"Always",
"logs",
"more",
"detailed",
"information",
"at",
"debug",
"level",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/reversetunnel/agentpool.go#L356-L388 | train |
gravitational/teleport | lib/reversetunnel/agentpool.go | removeDisconnected | func (m *AgentPool) removeDisconnected() {
for agentKey, agentSlice := range m.agents {
// Filter and close all disconnected agents.
validAgents := filterAndClose(agentSlice, func(agent *Agent) bool {
if agent.getState() == agentStateDisconnected {
return true
}
return false
})
// Update (or dele... | go | func (m *AgentPool) removeDisconnected() {
for agentKey, agentSlice := range m.agents {
// Filter and close all disconnected agents.
validAgents := filterAndClose(agentSlice, func(agent *Agent) bool {
if agent.getState() == agentStateDisconnected {
return true
}
return false
})
// Update (or dele... | [
"func",
"(",
"m",
"*",
"AgentPool",
")",
"removeDisconnected",
"(",
")",
"{",
"for",
"agentKey",
",",
"agentSlice",
":=",
"range",
"m",
".",
"agents",
"{",
"// Filter and close all disconnected agents.",
"validAgents",
":=",
"filterAndClose",
"(",
"agentSlice",
",... | // removeDisconnected removes disconnected agents from the list of agents.
// This function should be called under a lock. | [
"removeDisconnected",
"removes",
"disconnected",
"agents",
"from",
"the",
"list",
"of",
"agents",
".",
"This",
"function",
"should",
"be",
"called",
"under",
"a",
"lock",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/reversetunnel/agentpool.go#L447-L464 | train |
gravitational/teleport | lib/utils/storage.go | SetAddresses | func (fs *FileAddrStorage) SetAddresses(addrs []NetAddr) error {
bytes, err := json.Marshal(addrs)
if err != nil {
return trace.Wrap(err)
}
err = ioutil.WriteFile(fs.filePath, bytes, 0666)
if err != nil {
log.Error(err)
return trace.ConvertSystemError(err)
}
return nil
} | go | func (fs *FileAddrStorage) SetAddresses(addrs []NetAddr) error {
bytes, err := json.Marshal(addrs)
if err != nil {
return trace.Wrap(err)
}
err = ioutil.WriteFile(fs.filePath, bytes, 0666)
if err != nil {
log.Error(err)
return trace.ConvertSystemError(err)
}
return nil
} | [
"func",
"(",
"fs",
"*",
"FileAddrStorage",
")",
"SetAddresses",
"(",
"addrs",
"[",
"]",
"NetAddr",
")",
"error",
"{",
"bytes",
",",
"err",
":=",
"json",
".",
"Marshal",
"(",
"addrs",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"trace",
".",
... | // SetAddresses updates storage with new address list | [
"SetAddresses",
"updates",
"storage",
"with",
"new",
"address",
"list"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/storage.go#L43-L54 | train |
gravitational/teleport | lib/utils/storage.go | GetAddresses | func (fs *FileAddrStorage) GetAddresses() ([]NetAddr, error) {
bytes, err := ioutil.ReadFile(fs.filePath)
if err != nil {
return nil, trace.ConvertSystemError(err)
}
var addrs []NetAddr
if len(bytes) > 0 {
err = json.Unmarshal(bytes, &addrs)
if err != nil {
return nil, trace.Wrap(err)
}
}
return addrs... | go | func (fs *FileAddrStorage) GetAddresses() ([]NetAddr, error) {
bytes, err := ioutil.ReadFile(fs.filePath)
if err != nil {
return nil, trace.ConvertSystemError(err)
}
var addrs []NetAddr
if len(bytes) > 0 {
err = json.Unmarshal(bytes, &addrs)
if err != nil {
return nil, trace.Wrap(err)
}
}
return addrs... | [
"func",
"(",
"fs",
"*",
"FileAddrStorage",
")",
"GetAddresses",
"(",
")",
"(",
"[",
"]",
"NetAddr",
",",
"error",
")",
"{",
"bytes",
",",
"err",
":=",
"ioutil",
".",
"ReadFile",
"(",
"fs",
".",
"filePath",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
... | // GetAddresses returns saved address list | [
"GetAddresses",
"returns",
"saved",
"address",
"list"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/storage.go#L57-L70 | train |
gravitational/teleport | lib/utils/tlsdial.go | TLSDial | func TLSDial(ctx context.Context, dial DialWithContextFunc, network, addr string, tlsConfig *tls.Config) (*tls.Conn, error) {
if tlsConfig == nil {
tlsConfig = &tls.Config{}
}
plainConn, err := dial(ctx, network, addr)
if err != nil {
return nil, trace.Wrap(err)
}
colonPos := strings.LastIndex(addr, ":")
i... | go | func TLSDial(ctx context.Context, dial DialWithContextFunc, network, addr string, tlsConfig *tls.Config) (*tls.Conn, error) {
if tlsConfig == nil {
tlsConfig = &tls.Config{}
}
plainConn, err := dial(ctx, network, addr)
if err != nil {
return nil, trace.Wrap(err)
}
colonPos := strings.LastIndex(addr, ":")
i... | [
"func",
"TLSDial",
"(",
"ctx",
"context",
".",
"Context",
",",
"dial",
"DialWithContextFunc",
",",
"network",
",",
"addr",
"string",
",",
"tlsConfig",
"*",
"tls",
".",
"Config",
")",
"(",
"*",
"tls",
".",
"Conn",
",",
"error",
")",
"{",
"if",
"tlsConfi... | // TLSDial dials and establishes TLS connection using custom dialer
// is similar to tls.DialWithDialer | [
"TLSDial",
"dials",
"and",
"establishes",
"TLS",
"connection",
"using",
"custom",
"dialer",
"is",
"similar",
"to",
"tls",
".",
"DialWithDialer"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/tlsdial.go#L22-L75 | train |
gravitational/teleport | lib/web/ui/usercontext.go | NewUserContext | func NewUserContext(user services.User, userRoles services.RoleSet) (*userContext, error) {
ctx := &services.Context{User: user}
sessionAccess := newAccess(userRoles, ctx, services.KindSession)
roleAccess := newAccess(userRoles, ctx, services.KindRole)
authConnectors := newAccess(userRoles, ctx, services.KindAuthCo... | go | func NewUserContext(user services.User, userRoles services.RoleSet) (*userContext, error) {
ctx := &services.Context{User: user}
sessionAccess := newAccess(userRoles, ctx, services.KindSession)
roleAccess := newAccess(userRoles, ctx, services.KindRole)
authConnectors := newAccess(userRoles, ctx, services.KindAuthCo... | [
"func",
"NewUserContext",
"(",
"user",
"services",
".",
"User",
",",
"userRoles",
"services",
".",
"RoleSet",
")",
"(",
"*",
"userContext",
",",
"error",
")",
"{",
"ctx",
":=",
"&",
"services",
".",
"Context",
"{",
"User",
":",
"user",
"}",
"\n",
"sess... | // NewUserContext constructs user context from roles assigned to user | [
"NewUserContext",
"constructs",
"user",
"context",
"from",
"roles",
"assigned",
"to",
"user"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/web/ui/usercontext.go#L110-L145 | train |
gravitational/teleport | lib/auth/middleware.go | Serve | func (t *TLSServer) Serve(listener net.Listener) error {
return t.Server.Serve(tls.NewListener(listener, t.TLS))
} | go | func (t *TLSServer) Serve(listener net.Listener) error {
return t.Server.Serve(tls.NewListener(listener, t.TLS))
} | [
"func",
"(",
"t",
"*",
"TLSServer",
")",
"Serve",
"(",
"listener",
"net",
".",
"Listener",
")",
"error",
"{",
"return",
"t",
".",
"Server",
".",
"Serve",
"(",
"tls",
".",
"NewListener",
"(",
"listener",
",",
"t",
".",
"TLS",
")",
")",
"\n",
"}"
] | // Serve takes TCP listener, upgrades to TLS using config and starts serving | [
"Serve",
"takes",
"TCP",
"listener",
"upgrades",
"to",
"TLS",
"using",
"config",
"and",
"starts",
"serving"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/middleware.go#L126-L128 | train |
gravitational/teleport | lib/auth/middleware.go | GetUser | func (a *AuthMiddleware) GetUser(r *http.Request) (interface{}, error) {
peers := r.TLS.PeerCertificates
if len(peers) > 1 {
// when turning intermediaries on, don't forget to verify
// https://github.com/kubernetes/kubernetes/pull/34524/files#diff-2b283dde198c92424df5355f39544aa4R59
return nil, trace.AccessDen... | go | func (a *AuthMiddleware) GetUser(r *http.Request) (interface{}, error) {
peers := r.TLS.PeerCertificates
if len(peers) > 1 {
// when turning intermediaries on, don't forget to verify
// https://github.com/kubernetes/kubernetes/pull/34524/files#diff-2b283dde198c92424df5355f39544aa4R59
return nil, trace.AccessDen... | [
"func",
"(",
"a",
"*",
"AuthMiddleware",
")",
"GetUser",
"(",
"r",
"*",
"http",
".",
"Request",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"peers",
":=",
"r",
".",
"TLS",
".",
"PeerCertificates",
"\n",
"if",
"len",
"(",
"peers",
")",
... | // GetUser returns authenticated user based on request metadata set by HTTP server | [
"GetUser",
"returns",
"authenticated",
"user",
"based",
"on",
"request",
"metadata",
"set",
"by",
"HTTP",
"server"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/middleware.go#L189-L282 | train |
gravitational/teleport | lib/auth/middleware.go | ServeHTTP | func (a *AuthMiddleware) ServeHTTP(w http.ResponseWriter, r *http.Request) {
baseContext := r.Context()
if baseContext == nil {
baseContext = context.TODO()
}
user, err := a.GetUser(r)
if err != nil {
trace.WriteError(w, err)
return
}
// determine authenticated user based on the request parameters
reques... | go | func (a *AuthMiddleware) ServeHTTP(w http.ResponseWriter, r *http.Request) {
baseContext := r.Context()
if baseContext == nil {
baseContext = context.TODO()
}
user, err := a.GetUser(r)
if err != nil {
trace.WriteError(w, err)
return
}
// determine authenticated user based on the request parameters
reques... | [
"func",
"(",
"a",
"*",
"AuthMiddleware",
")",
"ServeHTTP",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"{",
"baseContext",
":=",
"r",
".",
"Context",
"(",
")",
"\n",
"if",
"baseContext",
"==",
"nil",
"{",
"bas... | // ServeHTTP serves HTTP requests | [
"ServeHTTP",
"serves",
"HTTP",
"requests"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/middleware.go#L296-L310 | train |
gravitational/teleport | lib/auth/middleware.go | ClientCertPool | func ClientCertPool(client AccessCache, clusterName string) (*x509.CertPool, error) {
pool := x509.NewCertPool()
var authorities []services.CertAuthority
if clusterName == "" {
hostCAs, err := client.GetCertAuthorities(services.HostCA, false, services.SkipValidation())
if err != nil {
return nil, trace.Wrap(e... | go | func ClientCertPool(client AccessCache, clusterName string) (*x509.CertPool, error) {
pool := x509.NewCertPool()
var authorities []services.CertAuthority
if clusterName == "" {
hostCAs, err := client.GetCertAuthorities(services.HostCA, false, services.SkipValidation())
if err != nil {
return nil, trace.Wrap(e... | [
"func",
"ClientCertPool",
"(",
"client",
"AccessCache",
",",
"clusterName",
"string",
")",
"(",
"*",
"x509",
".",
"CertPool",
",",
"error",
")",
"{",
"pool",
":=",
"x509",
".",
"NewCertPool",
"(",
")",
"\n",
"var",
"authorities",
"[",
"]",
"services",
".... | // ClientCertPool returns trusted x509 cerificate authority pool | [
"ClientCertPool",
"returns",
"trusted",
"x509",
"cerificate",
"authority",
"pool"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/middleware.go#L313-L355 | train |
gravitational/teleport | lib/config/configuration.go | applySSHConfig | func applySSHConfig(fc *FileConfig, cfg *service.Config) error {
if fc.SSH.ListenAddress != "" {
addr, err := utils.ParseHostPortAddr(fc.SSH.ListenAddress, int(defaults.SSHServerListenPort))
if err != nil {
return trace.Wrap(err)
}
cfg.SSH.Addr = *addr
}
if fc.SSH.Labels != nil {
cfg.SSH.Labels = make(m... | go | func applySSHConfig(fc *FileConfig, cfg *service.Config) error {
if fc.SSH.ListenAddress != "" {
addr, err := utils.ParseHostPortAddr(fc.SSH.ListenAddress, int(defaults.SSHServerListenPort))
if err != nil {
return trace.Wrap(err)
}
cfg.SSH.Addr = *addr
}
if fc.SSH.Labels != nil {
cfg.SSH.Labels = make(m... | [
"func",
"applySSHConfig",
"(",
"fc",
"*",
"FileConfig",
",",
"cfg",
"*",
"service",
".",
"Config",
")",
"error",
"{",
"if",
"fc",
".",
"SSH",
".",
"ListenAddress",
"!=",
"\"",
"\"",
"{",
"addr",
",",
"err",
":=",
"utils",
".",
"ParseHostPortAddr",
"(",... | // applySSHConfig applies file configuration for the "ssh_service" section. | [
"applySSHConfig",
"applies",
"file",
"configuration",
"for",
"the",
"ssh_service",
"section",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/config/configuration.go#L560-L620 | train |
gravitational/teleport | lib/config/configuration.go | parseAuthorizedKeys | func parseAuthorizedKeys(bytes []byte, allowedLogins []string) (services.CertAuthority, services.Role, error) {
pubkey, comment, _, _, err := ssh.ParseAuthorizedKey(bytes)
if err != nil {
return nil, nil, trace.Wrap(err)
}
comments, err := url.ParseQuery(comment)
if err != nil {
return nil, nil, trace.Wrap(er... | go | func parseAuthorizedKeys(bytes []byte, allowedLogins []string) (services.CertAuthority, services.Role, error) {
pubkey, comment, _, _, err := ssh.ParseAuthorizedKey(bytes)
if err != nil {
return nil, nil, trace.Wrap(err)
}
comments, err := url.ParseQuery(comment)
if err != nil {
return nil, nil, trace.Wrap(er... | [
"func",
"parseAuthorizedKeys",
"(",
"bytes",
"[",
"]",
"byte",
",",
"allowedLogins",
"[",
"]",
"string",
")",
"(",
"services",
".",
"CertAuthority",
",",
"services",
".",
"Role",
",",
"error",
")",
"{",
"pubkey",
",",
"comment",
",",
"_",
",",
"_",
","... | // parseAuthorizedKeys parses keys in the authorized_keys format and
// returns a services.CertAuthority. | [
"parseAuthorizedKeys",
"parses",
"keys",
"in",
"the",
"authorized_keys",
"format",
"and",
"returns",
"a",
"services",
".",
"CertAuthority",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/config/configuration.go#L624-L653 | train |
gravitational/teleport | lib/config/configuration.go | parseKnownHosts | func parseKnownHosts(bytes []byte, allowedLogins []string) (services.CertAuthority, services.Role, error) {
marker, options, pubKey, comment, _, err := ssh.ParseKnownHosts(bytes)
if marker != "cert-authority" {
return nil, nil, trace.BadParameter("invalid file format. expected '@cert-authority` marker")
}
if err ... | go | func parseKnownHosts(bytes []byte, allowedLogins []string) (services.CertAuthority, services.Role, error) {
marker, options, pubKey, comment, _, err := ssh.ParseKnownHosts(bytes)
if marker != "cert-authority" {
return nil, nil, trace.BadParameter("invalid file format. expected '@cert-authority` marker")
}
if err ... | [
"func",
"parseKnownHosts",
"(",
"bytes",
"[",
"]",
"byte",
",",
"allowedLogins",
"[",
"]",
"string",
")",
"(",
"services",
".",
"CertAuthority",
",",
"services",
".",
"Role",
",",
"error",
")",
"{",
"marker",
",",
"options",
",",
"pubKey",
",",
"comment"... | // parseKnownHosts parses keys in known_hosts format and returns a
// services.CertAuthority. | [
"parseKnownHosts",
"parses",
"keys",
"in",
"known_hosts",
"format",
"and",
"returns",
"a",
"services",
".",
"CertAuthority",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/config/configuration.go#L657-L687 | train |
gravitational/teleport | lib/config/configuration.go | certificateAuthorityFormat | func certificateAuthorityFormat(bytes []byte) (string, error) {
_, _, _, _, err := ssh.ParseAuthorizedKey(bytes)
if err != nil {
_, _, _, _, _, err := ssh.ParseKnownHosts(bytes)
if err != nil {
return "", trace.BadParameter("unknown ca format")
}
return teleport.KnownHosts, nil
}
return teleport.Authoriz... | go | func certificateAuthorityFormat(bytes []byte) (string, error) {
_, _, _, _, err := ssh.ParseAuthorizedKey(bytes)
if err != nil {
_, _, _, _, _, err := ssh.ParseKnownHosts(bytes)
if err != nil {
return "", trace.BadParameter("unknown ca format")
}
return teleport.KnownHosts, nil
}
return teleport.Authoriz... | [
"func",
"certificateAuthorityFormat",
"(",
"bytes",
"[",
"]",
"byte",
")",
"(",
"string",
",",
"error",
")",
"{",
"_",
",",
"_",
",",
"_",
",",
"_",
",",
"err",
":=",
"ssh",
".",
"ParseAuthorizedKey",
"(",
"bytes",
")",
"\n",
"if",
"err",
"!=",
"ni... | // certificateAuthorityFormat parses bytes and determines if they are in
// known_hosts format or authorized_keys format. | [
"certificateAuthorityFormat",
"parses",
"bytes",
"and",
"determines",
"if",
"they",
"are",
"in",
"known_hosts",
"format",
"or",
"authorized_keys",
"format",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/config/configuration.go#L691-L701 | train |
gravitational/teleport | lib/config/configuration.go | parseCAKey | func parseCAKey(bytes []byte, allowedLogins []string) (services.CertAuthority, services.Role, error) {
caFormat, err := certificateAuthorityFormat(bytes)
if err != nil {
return nil, nil, trace.Wrap(err)
}
if caFormat == teleport.AuthorizedKeys {
return parseAuthorizedKeys(bytes, allowedLogins)
}
return parse... | go | func parseCAKey(bytes []byte, allowedLogins []string) (services.CertAuthority, services.Role, error) {
caFormat, err := certificateAuthorityFormat(bytes)
if err != nil {
return nil, nil, trace.Wrap(err)
}
if caFormat == teleport.AuthorizedKeys {
return parseAuthorizedKeys(bytes, allowedLogins)
}
return parse... | [
"func",
"parseCAKey",
"(",
"bytes",
"[",
"]",
"byte",
",",
"allowedLogins",
"[",
"]",
"string",
")",
"(",
"services",
".",
"CertAuthority",
",",
"services",
".",
"Role",
",",
"error",
")",
"{",
"caFormat",
",",
"err",
":=",
"certificateAuthorityFormat",
"(... | // parseCAKey parses bytes either in known_hosts or authorized_keys format
// and returns a services.CertAuthority. | [
"parseCAKey",
"parses",
"bytes",
"either",
"in",
"known_hosts",
"or",
"authorized_keys",
"format",
"and",
"returns",
"a",
"services",
".",
"CertAuthority",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/config/configuration.go#L705-L715 | train |
gravitational/teleport | lib/config/configuration.go | readTrustedClusters | func readTrustedClusters(clusters []TrustedCluster, conf *service.Config) error {
if len(clusters) == 0 {
return nil
}
// go over all trusted clusters:
for i := range clusters {
tc := &clusters[i]
// parse "allow_logins"
var allowedLogins []string
for _, login := range strings.Split(tc.AllowedLogins, ",")... | go | func readTrustedClusters(clusters []TrustedCluster, conf *service.Config) error {
if len(clusters) == 0 {
return nil
}
// go over all trusted clusters:
for i := range clusters {
tc := &clusters[i]
// parse "allow_logins"
var allowedLogins []string
for _, login := range strings.Split(tc.AllowedLogins, ",")... | [
"func",
"readTrustedClusters",
"(",
"clusters",
"[",
"]",
"TrustedCluster",
",",
"conf",
"*",
"service",
".",
"Config",
")",
"error",
"{",
"if",
"len",
"(",
"clusters",
")",
"==",
"0",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"// go over all trusted clusters:"... | // readTrustedClusters parses the content of "trusted_clusters" YAML structure
// and modifies Teleport 'conf' by adding "authorities" and "reverse tunnels"
// to it | [
"readTrustedClusters",
"parses",
"the",
"content",
"of",
"trusted_clusters",
"YAML",
"structure",
"and",
"modifies",
"Teleport",
"conf",
"by",
"adding",
"authorities",
"and",
"reverse",
"tunnels",
"to",
"it"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/config/configuration.go#L720-L786 | train |
gravitational/teleport | lib/config/configuration.go | applyString | func applyString(src string, target *string) bool {
if src != "" {
*target = src
return true
}
return false
} | go | func applyString(src string, target *string) bool {
if src != "" {
*target = src
return true
}
return false
} | [
"func",
"applyString",
"(",
"src",
"string",
",",
"target",
"*",
"string",
")",
"bool",
"{",
"if",
"src",
"!=",
"\"",
"\"",
"{",
"*",
"target",
"=",
"src",
"\n",
"return",
"true",
"\n",
"}",
"\n",
"return",
"false",
"\n",
"}"
] | // applyString takes 'src' and overwrites target with it, unless 'src' is empty
// returns 'True' if 'src' was not empty | [
"applyString",
"takes",
"src",
"and",
"overwrites",
"target",
"with",
"it",
"unless",
"src",
"is",
"empty",
"returns",
"True",
"if",
"src",
"was",
"not",
"empty"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/config/configuration.go#L790-L796 | train |
gravitational/teleport | lib/config/configuration.go | applyListenIP | func applyListenIP(ip net.IP, cfg *service.Config) {
listeningAddresses := []*utils.NetAddr{
&cfg.Auth.SSHAddr,
&cfg.Auth.SSHAddr,
&cfg.Proxy.SSHAddr,
&cfg.Proxy.WebAddr,
&cfg.SSH.Addr,
&cfg.Proxy.ReverseTunnelListenAddr,
}
for _, addr := range listeningAddresses {
replaceHost(addr, ip.String())
}
} | go | func applyListenIP(ip net.IP, cfg *service.Config) {
listeningAddresses := []*utils.NetAddr{
&cfg.Auth.SSHAddr,
&cfg.Auth.SSHAddr,
&cfg.Proxy.SSHAddr,
&cfg.Proxy.WebAddr,
&cfg.SSH.Addr,
&cfg.Proxy.ReverseTunnelListenAddr,
}
for _, addr := range listeningAddresses {
replaceHost(addr, ip.String())
}
} | [
"func",
"applyListenIP",
"(",
"ip",
"net",
".",
"IP",
",",
"cfg",
"*",
"service",
".",
"Config",
")",
"{",
"listeningAddresses",
":=",
"[",
"]",
"*",
"utils",
".",
"NetAddr",
"{",
"&",
"cfg",
".",
"Auth",
".",
"SSHAddr",
",",
"&",
"cfg",
".",
"Auth... | // applyListenIP replaces all 'listen addr' settings for all services with
// a given IP | [
"applyListenIP",
"replaces",
"all",
"listen",
"addr",
"settings",
"for",
"all",
"services",
"with",
"a",
"given",
"IP"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/config/configuration.go#L1001-L1013 | train |
gravitational/teleport | lib/config/configuration.go | replaceHost | func replaceHost(addr *utils.NetAddr, newHost string) {
_, port, err := net.SplitHostPort(addr.Addr)
if err != nil {
log.Errorf("failed parsing address: '%v'", addr.Addr)
}
addr.Addr = net.JoinHostPort(newHost, port)
} | go | func replaceHost(addr *utils.NetAddr, newHost string) {
_, port, err := net.SplitHostPort(addr.Addr)
if err != nil {
log.Errorf("failed parsing address: '%v'", addr.Addr)
}
addr.Addr = net.JoinHostPort(newHost, port)
} | [
"func",
"replaceHost",
"(",
"addr",
"*",
"utils",
".",
"NetAddr",
",",
"newHost",
"string",
")",
"{",
"_",
",",
"port",
",",
"err",
":=",
"net",
".",
"SplitHostPort",
"(",
"addr",
".",
"Addr",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"log",
".",
... | // replaceHost takes utils.NetAddr and replaces the hostname in it, preserving
// the original port | [
"replaceHost",
"takes",
"utils",
".",
"NetAddr",
"and",
"replaces",
"the",
"hostname",
"in",
"it",
"preserving",
"the",
"original",
"port"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/config/configuration.go#L1017-L1023 | train |
gravitational/teleport | lib/services/legacy/metadata.go | MarshalJSON | func (d Duration) MarshalJSON() ([]byte, error) {
return json.Marshal(fmt.Sprintf("%v", d.Duration))
} | go | func (d Duration) MarshalJSON() ([]byte, error) {
return json.Marshal(fmt.Sprintf("%v", d.Duration))
} | [
"func",
"(",
"d",
"Duration",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"return",
"json",
".",
"Marshal",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"d",
".",
"Duration",
")",
")",
"\n",
"}"
] | // MarshalJSON marshals Duration to string | [
"MarshalJSON",
"marshals",
"Duration",
"to",
"string"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/legacy/metadata.go#L54-L56 | train |
gravitational/teleport | lib/auth/new_web_user.go | initializeTOTP | func (s *AuthServer) initializeTOTP(accountName string) (key string, qr []byte, err error) {
// create totp key
otpKey, err := totp.Generate(totp.GenerateOpts{
Issuer: "Teleport",
AccountName: accountName,
})
if err != nil {
return "", nil, trace.Wrap(err)
}
// create QR code
var otpQRBuf bytes.Buffe... | go | func (s *AuthServer) initializeTOTP(accountName string) (key string, qr []byte, err error) {
// create totp key
otpKey, err := totp.Generate(totp.GenerateOpts{
Issuer: "Teleport",
AccountName: accountName,
})
if err != nil {
return "", nil, trace.Wrap(err)
}
// create QR code
var otpQRBuf bytes.Buffe... | [
"func",
"(",
"s",
"*",
"AuthServer",
")",
"initializeTOTP",
"(",
"accountName",
"string",
")",
"(",
"key",
"string",
",",
"qr",
"[",
"]",
"byte",
",",
"err",
"error",
")",
"{",
"// create totp key",
"otpKey",
",",
"err",
":=",
"totp",
".",
"Generate",
... | // initializeTOTP creates TOTP algorithm and returns the key and QR code. | [
"initializeTOTP",
"creates",
"TOTP",
"algorithm",
"and",
"returns",
"the",
"key",
"and",
"QR",
"code",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/new_web_user.go#L119-L138 | train |
gravitational/teleport | lib/auth/new_web_user.go | rotateAndFetchSignupToken | func (s *AuthServer) rotateAndFetchSignupToken(token string) (*services.SignupToken, error) {
var err error
// Fetch original signup token.
st, err := s.GetSignupToken(token)
if err != nil {
return nil, trace.Wrap(err)
}
// Generate and set new OTP code for user in *services.SignupToken.
accountName := st.Us... | go | func (s *AuthServer) rotateAndFetchSignupToken(token string) (*services.SignupToken, error) {
var err error
// Fetch original signup token.
st, err := s.GetSignupToken(token)
if err != nil {
return nil, trace.Wrap(err)
}
// Generate and set new OTP code for user in *services.SignupToken.
accountName := st.Us... | [
"func",
"(",
"s",
"*",
"AuthServer",
")",
"rotateAndFetchSignupToken",
"(",
"token",
"string",
")",
"(",
"*",
"services",
".",
"SignupToken",
",",
"error",
")",
"{",
"var",
"err",
"error",
"\n\n",
"// Fetch original signup token.",
"st",
",",
"err",
":=",
"s... | // rotateAndFetchSignupToken rotates the signup token everytime it's fetched.
// This ensures that an attacker that gains the signup link can not view it,
// extract the OTP key from the QR code, then allow the user to signup with
// the same OTP token. | [
"rotateAndFetchSignupToken",
"rotates",
"the",
"signup",
"token",
"everytime",
"it",
"s",
"fetched",
".",
"This",
"ensures",
"that",
"an",
"attacker",
"that",
"gains",
"the",
"signup",
"link",
"can",
"not",
"view",
"it",
"extract",
"the",
"OTP",
"key",
"from",... | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/new_web_user.go#L144-L167 | train |
gravitational/teleport | lib/auth/new_web_user.go | CreateUserWithOTP | func (s *AuthServer) CreateUserWithOTP(token string, password string, otpToken string) (services.WebSession, error) {
tokenData, err := s.GetSignupToken(token)
if err != nil {
log.Debugf("failed to get signup token: %v", err)
return nil, trace.AccessDenied("expired or incorrect signup token")
}
err = s.UpsertT... | go | func (s *AuthServer) CreateUserWithOTP(token string, password string, otpToken string) (services.WebSession, error) {
tokenData, err := s.GetSignupToken(token)
if err != nil {
log.Debugf("failed to get signup token: %v", err)
return nil, trace.AccessDenied("expired or incorrect signup token")
}
err = s.UpsertT... | [
"func",
"(",
"s",
"*",
"AuthServer",
")",
"CreateUserWithOTP",
"(",
"token",
"string",
",",
"password",
"string",
",",
"otpToken",
"string",
")",
"(",
"services",
".",
"WebSession",
",",
"error",
")",
"{",
"tokenData",
",",
"err",
":=",
"s",
".",
"GetSig... | // CreateUserWithOTP creates account with provided token and password.
// Account username and hotp generator are taken from token data.
// Deletes token after account creation. | [
"CreateUserWithOTP",
"creates",
"account",
"with",
"provided",
"token",
"and",
"password",
".",
"Account",
"username",
"and",
"hotp",
"generator",
"are",
"taken",
"from",
"token",
"data",
".",
"Deletes",
"token",
"after",
"account",
"creation",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/new_web_user.go#L232-L262 | train |
gravitational/teleport | lib/auth/new_web_user.go | CreateUserWithoutOTP | func (s *AuthServer) CreateUserWithoutOTP(token string, password string) (services.WebSession, error) {
authPreference, err := s.GetAuthPreference()
if err != nil {
return nil, trace.Wrap(err)
}
if authPreference.GetSecondFactor() != teleport.OFF {
return nil, trace.AccessDenied("missing second factor")
}
tok... | go | func (s *AuthServer) CreateUserWithoutOTP(token string, password string) (services.WebSession, error) {
authPreference, err := s.GetAuthPreference()
if err != nil {
return nil, trace.Wrap(err)
}
if authPreference.GetSecondFactor() != teleport.OFF {
return nil, trace.AccessDenied("missing second factor")
}
tok... | [
"func",
"(",
"s",
"*",
"AuthServer",
")",
"CreateUserWithoutOTP",
"(",
"token",
"string",
",",
"password",
"string",
")",
"(",
"services",
".",
"WebSession",
",",
"error",
")",
"{",
"authPreference",
",",
"err",
":=",
"s",
".",
"GetAuthPreference",
"(",
")... | // CreateUserWithoutOTP creates an account with the provided password and deletes the token afterwards. | [
"CreateUserWithoutOTP",
"creates",
"an",
"account",
"with",
"the",
"provided",
"password",
"and",
"deletes",
"the",
"token",
"afterwards",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/new_web_user.go#L265-L291 | train |
gravitational/teleport | lib/services/statictokens.go | NewStaticTokens | func NewStaticTokens(spec StaticTokensSpecV2) (StaticTokens, error) {
st := StaticTokensV2{
Kind: KindStaticTokens,
Version: V2,
Metadata: Metadata{
Name: MetaNameStaticTokens,
Namespace: defaults.Namespace,
},
Spec: spec,
}
if err := st.CheckAndSetDefaults(); err != nil {
return nil, trace... | go | func NewStaticTokens(spec StaticTokensSpecV2) (StaticTokens, error) {
st := StaticTokensV2{
Kind: KindStaticTokens,
Version: V2,
Metadata: Metadata{
Name: MetaNameStaticTokens,
Namespace: defaults.Namespace,
},
Spec: spec,
}
if err := st.CheckAndSetDefaults(); err != nil {
return nil, trace... | [
"func",
"NewStaticTokens",
"(",
"spec",
"StaticTokensSpecV2",
")",
"(",
"StaticTokens",
",",
"error",
")",
"{",
"st",
":=",
"StaticTokensV2",
"{",
"Kind",
":",
"KindStaticTokens",
",",
"Version",
":",
"V2",
",",
"Metadata",
":",
"Metadata",
"{",
"Name",
":",... | // NewStaticTokens is a convenience wrapper to create a StaticTokens resource. | [
"NewStaticTokens",
"is",
"a",
"convenience",
"wrapper",
"to",
"create",
"a",
"StaticTokens",
"resource",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/statictokens.go#L47-L62 | train |
gravitational/teleport | lib/services/statictokens.go | GetStaticTokensSchema | func GetStaticTokensSchema(extensionSchema string) string {
var staticTokensSchema string
if staticTokensSchema == "" {
staticTokensSchema = fmt.Sprintf(StaticTokensSpecSchemaTemplate, "")
} else {
staticTokensSchema = fmt.Sprintf(StaticTokensSpecSchemaTemplate, ","+extensionSchema)
}
return fmt.Sprintf(V2Sche... | go | func GetStaticTokensSchema(extensionSchema string) string {
var staticTokensSchema string
if staticTokensSchema == "" {
staticTokensSchema = fmt.Sprintf(StaticTokensSpecSchemaTemplate, "")
} else {
staticTokensSchema = fmt.Sprintf(StaticTokensSpecSchemaTemplate, ","+extensionSchema)
}
return fmt.Sprintf(V2Sche... | [
"func",
"GetStaticTokensSchema",
"(",
"extensionSchema",
"string",
")",
"string",
"{",
"var",
"staticTokensSchema",
"string",
"\n",
"if",
"staticTokensSchema",
"==",
"\"",
"\"",
"{",
"staticTokensSchema",
"=",
"fmt",
".",
"Sprintf",
"(",
"StaticTokensSpecSchemaTemplat... | // GetStaticTokensSchema returns the schema with optionally injected
// schema for extensions. | [
"GetStaticTokensSchema",
"returns",
"the",
"schema",
"with",
"optionally",
"injected",
"schema",
"for",
"extensions",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/statictokens.go#L197-L205 | train |
gravitational/teleport | lib/services/statictokens.go | Unmarshal | func (t *TeleportStaticTokensMarshaler) Unmarshal(bytes []byte, opts ...MarshalOption) (StaticTokens, error) {
var staticTokens StaticTokensV2
if len(bytes) == 0 {
return nil, trace.BadParameter("missing resource data")
}
cfg, err := collectOptions(opts)
if err != nil {
return nil, trace.Wrap(err)
}
if cf... | go | func (t *TeleportStaticTokensMarshaler) Unmarshal(bytes []byte, opts ...MarshalOption) (StaticTokens, error) {
var staticTokens StaticTokensV2
if len(bytes) == 0 {
return nil, trace.BadParameter("missing resource data")
}
cfg, err := collectOptions(opts)
if err != nil {
return nil, trace.Wrap(err)
}
if cf... | [
"func",
"(",
"t",
"*",
"TeleportStaticTokensMarshaler",
")",
"Unmarshal",
"(",
"bytes",
"[",
"]",
"byte",
",",
"opts",
"...",
"MarshalOption",
")",
"(",
"StaticTokens",
",",
"error",
")",
"{",
"var",
"staticTokens",
"StaticTokensV2",
"\n\n",
"if",
"len",
"("... | // Unmarshal unmarshals StaticTokens from JSON. | [
"Unmarshal",
"unmarshals",
"StaticTokens",
"from",
"JSON",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/statictokens.go#L234-L269 | train |
gravitational/teleport | lib/services/statictokens.go | Marshal | func (t *TeleportStaticTokensMarshaler) Marshal(c StaticTokens, opts ...MarshalOption) ([]byte, error) {
cfg, err := collectOptions(opts)
if err != nil {
return nil, trace.Wrap(err)
}
switch resource := c.(type) {
case *StaticTokensV2:
if !cfg.PreserveResourceID {
// avoid modifying the original object
/... | go | func (t *TeleportStaticTokensMarshaler) Marshal(c StaticTokens, opts ...MarshalOption) ([]byte, error) {
cfg, err := collectOptions(opts)
if err != nil {
return nil, trace.Wrap(err)
}
switch resource := c.(type) {
case *StaticTokensV2:
if !cfg.PreserveResourceID {
// avoid modifying the original object
/... | [
"func",
"(",
"t",
"*",
"TeleportStaticTokensMarshaler",
")",
"Marshal",
"(",
"c",
"StaticTokens",
",",
"opts",
"...",
"MarshalOption",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"cfg",
",",
"err",
":=",
"collectOptions",
"(",
"opts",
")",
"\n",
... | // Marshal marshals StaticTokens to JSON. | [
"Marshal",
"marshals",
"StaticTokens",
"to",
"JSON",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/statictokens.go#L272-L290 | train |
gravitational/teleport | lib/services/local/trust.go | DeleteAllCertAuthorities | func (s *CA) DeleteAllCertAuthorities(caType services.CertAuthType) error {
startKey := backend.Key(authoritiesPrefix, string(caType))
return s.DeleteRange(context.TODO(), startKey, backend.RangeEnd(startKey))
} | go | func (s *CA) DeleteAllCertAuthorities(caType services.CertAuthType) error {
startKey := backend.Key(authoritiesPrefix, string(caType))
return s.DeleteRange(context.TODO(), startKey, backend.RangeEnd(startKey))
} | [
"func",
"(",
"s",
"*",
"CA",
")",
"DeleteAllCertAuthorities",
"(",
"caType",
"services",
".",
"CertAuthType",
")",
"error",
"{",
"startKey",
":=",
"backend",
".",
"Key",
"(",
"authoritiesPrefix",
",",
"string",
"(",
"caType",
")",
")",
"\n",
"return",
"s",... | // DeleteAllCertAuthorities deletes all certificate authorities of a certain type | [
"DeleteAllCertAuthorities",
"deletes",
"all",
"certificate",
"authorities",
"of",
"a",
"certain",
"type"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/local/trust.go#L26-L29 | train |
gravitational/teleport | lib/services/local/trust.go | CreateCertAuthority | func (s *CA) CreateCertAuthority(ca services.CertAuthority) error {
if err := ca.Check(); err != nil {
return trace.Wrap(err)
}
value, err := services.GetCertAuthorityMarshaler().MarshalCertAuthority(ca)
if err != nil {
return trace.Wrap(err)
}
item := backend.Item{
Key: backend.Key(authoritiesPrefix, s... | go | func (s *CA) CreateCertAuthority(ca services.CertAuthority) error {
if err := ca.Check(); err != nil {
return trace.Wrap(err)
}
value, err := services.GetCertAuthorityMarshaler().MarshalCertAuthority(ca)
if err != nil {
return trace.Wrap(err)
}
item := backend.Item{
Key: backend.Key(authoritiesPrefix, s... | [
"func",
"(",
"s",
"*",
"CA",
")",
"CreateCertAuthority",
"(",
"ca",
"services",
".",
"CertAuthority",
")",
"error",
"{",
"if",
"err",
":=",
"ca",
".",
"Check",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"trace",
".",
"Wrap",
"(",
"err",
")",... | // CreateCertAuthority updates or inserts a new certificate authority | [
"CreateCertAuthority",
"updates",
"or",
"inserts",
"a",
"new",
"certificate",
"authority"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/local/trust.go#L32-L54 | train |
gravitational/teleport | lib/services/local/trust.go | UpsertCertAuthority | func (s *CA) UpsertCertAuthority(ca services.CertAuthority) error {
if err := ca.Check(); err != nil {
return trace.Wrap(err)
}
value, err := services.GetCertAuthorityMarshaler().MarshalCertAuthority(ca)
if err != nil {
return trace.Wrap(err)
}
item := backend.Item{
Key: backend.Key(authoritiesPrefix, s... | go | func (s *CA) UpsertCertAuthority(ca services.CertAuthority) error {
if err := ca.Check(); err != nil {
return trace.Wrap(err)
}
value, err := services.GetCertAuthorityMarshaler().MarshalCertAuthority(ca)
if err != nil {
return trace.Wrap(err)
}
item := backend.Item{
Key: backend.Key(authoritiesPrefix, s... | [
"func",
"(",
"s",
"*",
"CA",
")",
"UpsertCertAuthority",
"(",
"ca",
"services",
".",
"CertAuthority",
")",
"error",
"{",
"if",
"err",
":=",
"ca",
".",
"Check",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"trace",
".",
"Wrap",
"(",
"err",
")",... | // UpsertCertAuthority updates or inserts a new certificate authority | [
"UpsertCertAuthority",
"updates",
"or",
"inserts",
"a",
"new",
"certificate",
"authority"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/local/trust.go#L57-L77 | train |
gravitational/teleport | lib/services/local/trust.go | CompareAndSwapCertAuthority | func (s *CA) CompareAndSwapCertAuthority(new, existing services.CertAuthority) error {
if err := new.Check(); err != nil {
return trace.Wrap(err)
}
newValue, err := services.GetCertAuthorityMarshaler().MarshalCertAuthority(new)
if err != nil {
return trace.Wrap(err)
}
newItem := backend.Item{
Key: backe... | go | func (s *CA) CompareAndSwapCertAuthority(new, existing services.CertAuthority) error {
if err := new.Check(); err != nil {
return trace.Wrap(err)
}
newValue, err := services.GetCertAuthorityMarshaler().MarshalCertAuthority(new)
if err != nil {
return trace.Wrap(err)
}
newItem := backend.Item{
Key: backe... | [
"func",
"(",
"s",
"*",
"CA",
")",
"CompareAndSwapCertAuthority",
"(",
"new",
",",
"existing",
"services",
".",
"CertAuthority",
")",
"error",
"{",
"if",
"err",
":=",
"new",
".",
"Check",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"trace",
".",
... | // CompareAndSwapCertAuthority updates the cert authority value
// if the existing value matches existing parameter, returns nil if succeeds,
// trace.CompareFailed otherwise. | [
"CompareAndSwapCertAuthority",
"updates",
"the",
"cert",
"authority",
"value",
"if",
"the",
"existing",
"value",
"matches",
"existing",
"parameter",
"returns",
"nil",
"if",
"succeeds",
"trace",
".",
"CompareFailed",
"otherwise",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/local/trust.go#L82-L114 | train |
gravitational/teleport | lib/services/local/trust.go | DeleteCertAuthority | func (s *CA) DeleteCertAuthority(id services.CertAuthID) error {
if err := id.Check(); err != nil {
return trace.Wrap(err)
}
// when removing a services.CertAuthority also remove any deactivated
// services.CertAuthority as well if they exist.
err := s.Delete(context.TODO(), backend.Key(authoritiesPrefix, deacti... | go | func (s *CA) DeleteCertAuthority(id services.CertAuthID) error {
if err := id.Check(); err != nil {
return trace.Wrap(err)
}
// when removing a services.CertAuthority also remove any deactivated
// services.CertAuthority as well if they exist.
err := s.Delete(context.TODO(), backend.Key(authoritiesPrefix, deacti... | [
"func",
"(",
"s",
"*",
"CA",
")",
"DeleteCertAuthority",
"(",
"id",
"services",
".",
"CertAuthID",
")",
"error",
"{",
"if",
"err",
":=",
"id",
".",
"Check",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"trace",
".",
"Wrap",
"(",
"err",
")",
... | // DeleteCertAuthority deletes particular certificate authority | [
"DeleteCertAuthority",
"deletes",
"particular",
"certificate",
"authority"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/local/trust.go#L117-L134 | train |
gravitational/teleport | lib/services/local/trust.go | ActivateCertAuthority | func (s *CA) ActivateCertAuthority(id services.CertAuthID) error {
item, err := s.Get(context.TODO(), backend.Key(authoritiesPrefix, deactivatedPrefix, string(id.Type), id.DomainName))
if err != nil {
if trace.IsNotFound(err) {
return trace.BadParameter("can not activate cert authority %q which has not been deac... | go | func (s *CA) ActivateCertAuthority(id services.CertAuthID) error {
item, err := s.Get(context.TODO(), backend.Key(authoritiesPrefix, deactivatedPrefix, string(id.Type), id.DomainName))
if err != nil {
if trace.IsNotFound(err) {
return trace.BadParameter("can not activate cert authority %q which has not been deac... | [
"func",
"(",
"s",
"*",
"CA",
")",
"ActivateCertAuthority",
"(",
"id",
"services",
".",
"CertAuthID",
")",
"error",
"{",
"item",
",",
"err",
":=",
"s",
".",
"Get",
"(",
"context",
".",
"TODO",
"(",
")",
",",
"backend",
".",
"Key",
"(",
"authoritiesPre... | // ActivateCertAuthority moves a CertAuthority from the deactivated list to
// the normal list. | [
"ActivateCertAuthority",
"moves",
"a",
"CertAuthority",
"from",
"the",
"deactivated",
"list",
"to",
"the",
"normal",
"list",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/local/trust.go#L138-L164 | train |
gravitational/teleport | lib/services/local/trust.go | DeactivateCertAuthority | func (s *CA) DeactivateCertAuthority(id services.CertAuthID) error {
certAuthority, err := s.GetCertAuthority(id, true)
if err != nil {
if trace.IsNotFound(err) {
return trace.NotFound("can not deactivate cert authority %q which does not exist", id.DomainName)
}
return trace.Wrap(err)
}
err = s.DeleteCert... | go | func (s *CA) DeactivateCertAuthority(id services.CertAuthID) error {
certAuthority, err := s.GetCertAuthority(id, true)
if err != nil {
if trace.IsNotFound(err) {
return trace.NotFound("can not deactivate cert authority %q which does not exist", id.DomainName)
}
return trace.Wrap(err)
}
err = s.DeleteCert... | [
"func",
"(",
"s",
"*",
"CA",
")",
"DeactivateCertAuthority",
"(",
"id",
"services",
".",
"CertAuthID",
")",
"error",
"{",
"certAuthority",
",",
"err",
":=",
"s",
".",
"GetCertAuthority",
"(",
"id",
",",
"true",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",... | // DeactivateCertAuthority moves a CertAuthority from the normal list to
// the deactivated list. | [
"DeactivateCertAuthority",
"moves",
"a",
"CertAuthority",
"from",
"the",
"normal",
"list",
"to",
"the",
"deactivated",
"list",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/local/trust.go#L168-L199 | train |
gravitational/teleport | lib/client/session.go | newSession | func newSession(client *NodeClient,
joinSession *session.Session,
env map[string]string,
stdin io.Reader,
stdout io.Writer,
stderr io.Writer) (*NodeSession, error) {
if stdin == nil {
stdin = os.Stdin
}
if stdout == nil {
stdout = os.Stdout
}
if stderr == nil {
stderr = os.Stderr
}
if env == nil {
... | go | func newSession(client *NodeClient,
joinSession *session.Session,
env map[string]string,
stdin io.Reader,
stdout io.Writer,
stderr io.Writer) (*NodeSession, error) {
if stdin == nil {
stdin = os.Stdin
}
if stdout == nil {
stdout = os.Stdout
}
if stderr == nil {
stderr = os.Stderr
}
if env == nil {
... | [
"func",
"newSession",
"(",
"client",
"*",
"NodeClient",
",",
"joinSession",
"*",
"session",
".",
"Session",
",",
"env",
"map",
"[",
"string",
"]",
"string",
",",
"stdin",
"io",
".",
"Reader",
",",
"stdout",
"io",
".",
"Writer",
",",
"stderr",
"io",
"."... | // newSession creates a new Teleport session with the given remote node
// if 'joinSessin' is given, the session will join the existing session
// of another user | [
"newSession",
"creates",
"a",
"new",
"Teleport",
"session",
"with",
"the",
"given",
"remote",
"node",
"if",
"joinSessin",
"is",
"given",
"the",
"session",
"will",
"join",
"the",
"existing",
"session",
"of",
"another",
"user"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/session.go#L75-L128 | train |
gravitational/teleport | lib/client/session.go | interactiveSession | func (ns *NodeSession) interactiveSession(callback interactiveCallback) error {
// determine what kind of a terminal we need
termType := os.Getenv("TERM")
if termType == "" {
termType = teleport.SafeTerminalType
}
// create the server-side session:
sess, err := ns.createServerSession()
if err != nil {
return... | go | func (ns *NodeSession) interactiveSession(callback interactiveCallback) error {
// determine what kind of a terminal we need
termType := os.Getenv("TERM")
if termType == "" {
termType = teleport.SafeTerminalType
}
// create the server-side session:
sess, err := ns.createServerSession()
if err != nil {
return... | [
"func",
"(",
"ns",
"*",
"NodeSession",
")",
"interactiveSession",
"(",
"callback",
"interactiveCallback",
")",
"error",
"{",
"// determine what kind of a terminal we need",
"termType",
":=",
"os",
".",
"Getenv",
"(",
"\"",
"\"",
")",
"\n",
"if",
"termType",
"==",
... | // interactiveSession creates an interactive session on the remote node, executes
// the given callback on it, and waits for the session to end | [
"interactiveSession",
"creates",
"an",
"interactive",
"session",
"on",
"the",
"remote",
"node",
"executes",
"the",
"given",
"callback",
"on",
"it",
"and",
"waits",
"for",
"the",
"session",
"to",
"end"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/session.go#L189-L234 | train |
gravitational/teleport | lib/client/session.go | runShell | func (ns *NodeSession) runShell(callback ShellCreatedCallback) error {
return ns.interactiveSession(func(s *ssh.Session, shell io.ReadWriteCloser) error {
// start the shell on the server:
if err := s.Shell(); err != nil {
return trace.Wrap(err)
}
// call the client-supplied callback
if callback != nil {
... | go | func (ns *NodeSession) runShell(callback ShellCreatedCallback) error {
return ns.interactiveSession(func(s *ssh.Session, shell io.ReadWriteCloser) error {
// start the shell on the server:
if err := s.Shell(); err != nil {
return trace.Wrap(err)
}
// call the client-supplied callback
if callback != nil {
... | [
"func",
"(",
"ns",
"*",
"NodeSession",
")",
"runShell",
"(",
"callback",
"ShellCreatedCallback",
")",
"error",
"{",
"return",
"ns",
".",
"interactiveSession",
"(",
"func",
"(",
"s",
"*",
"ssh",
".",
"Session",
",",
"shell",
"io",
".",
"ReadWriteCloser",
")... | // runShell executes user's shell on the remote node under an interactive session | [
"runShell",
"executes",
"user",
"s",
"shell",
"on",
"the",
"remote",
"node",
"under",
"an",
"interactive",
"session"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/session.go#L397-L412 | train |
gravitational/teleport | lib/client/session.go | watchSignals | func (ns *NodeSession) watchSignals(shell io.Writer) {
exitSignals := make(chan os.Signal, 1)
// catch SIGTERM
signal.Notify(exitSignals, syscall.SIGTERM)
go func() {
defer ns.closer.Close()
<-exitSignals
}()
// Catch Ctrl-C signal
ctrlCSignal := make(chan os.Signal, 1)
signal.Notify(ctrlCSignal, syscall.SI... | go | func (ns *NodeSession) watchSignals(shell io.Writer) {
exitSignals := make(chan os.Signal, 1)
// catch SIGTERM
signal.Notify(exitSignals, syscall.SIGTERM)
go func() {
defer ns.closer.Close()
<-exitSignals
}()
// Catch Ctrl-C signal
ctrlCSignal := make(chan os.Signal, 1)
signal.Notify(ctrlCSignal, syscall.SI... | [
"func",
"(",
"ns",
"*",
"NodeSession",
")",
"watchSignals",
"(",
"shell",
"io",
".",
"Writer",
")",
"{",
"exitSignals",
":=",
"make",
"(",
"chan",
"os",
".",
"Signal",
",",
"1",
")",
"\n",
"// catch SIGTERM",
"signal",
".",
"Notify",
"(",
"exitSignals",
... | // watchSignals register UNIX signal handlers and properly terminates a remote shell session
// must be called as a goroutine right after a remote shell is created | [
"watchSignals",
"register",
"UNIX",
"signal",
"handlers",
"and",
"properly",
"terminates",
"a",
"remote",
"shell",
"session",
"must",
"be",
"called",
"as",
"a",
"goroutine",
"right",
"after",
"a",
"remote",
"shell",
"is",
"created"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/session.go#L488-L520 | train |
gravitational/teleport | lib/multiplexer/multiplexer.go | CheckAndSetDefaults | func (c *Config) CheckAndSetDefaults() error {
if c.Listener == nil {
return trace.BadParameter("missing parameter Listener")
}
if c.Context == nil {
c.Context = context.TODO()
}
if c.ReadDeadline == 0 {
c.ReadDeadline = defaults.ReadHeadersTimeout
}
if c.Clock == nil {
c.Clock = clockwork.NewRealClock()... | go | func (c *Config) CheckAndSetDefaults() error {
if c.Listener == nil {
return trace.BadParameter("missing parameter Listener")
}
if c.Context == nil {
c.Context = context.TODO()
}
if c.ReadDeadline == 0 {
c.ReadDeadline = defaults.ReadHeadersTimeout
}
if c.Clock == nil {
c.Clock = clockwork.NewRealClock()... | [
"func",
"(",
"c",
"*",
"Config",
")",
"CheckAndSetDefaults",
"(",
")",
"error",
"{",
"if",
"c",
".",
"Listener",
"==",
"nil",
"{",
"return",
"trace",
".",
"BadParameter",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"if",
"c",
".",
"Context",
"==",
"nil"... | // CheckAndSetDefaults verifies configuration and sets defaults | [
"CheckAndSetDefaults",
"verifies",
"configuration",
"and",
"sets",
"defaults"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/multiplexer/multiplexer.go#L66-L80 | train |
gravitational/teleport | lib/multiplexer/multiplexer.go | New | func New(cfg Config) (*Mux, error) {
if err := cfg.CheckAndSetDefaults(); err != nil {
return nil, trace.Wrap(err)
}
ctx, cancel := context.WithCancel(cfg.Context)
waitContext, waitCancel := context.WithCancel(context.TODO())
return &Mux{
Entry: log.WithFields(log.Fields{
trace.Component: teleport.Componen... | go | func New(cfg Config) (*Mux, error) {
if err := cfg.CheckAndSetDefaults(); err != nil {
return nil, trace.Wrap(err)
}
ctx, cancel := context.WithCancel(cfg.Context)
waitContext, waitCancel := context.WithCancel(context.TODO())
return &Mux{
Entry: log.WithFields(log.Fields{
trace.Component: teleport.Componen... | [
"func",
"New",
"(",
"cfg",
"Config",
")",
"(",
"*",
"Mux",
",",
"error",
")",
"{",
"if",
"err",
":=",
"cfg",
".",
"CheckAndSetDefaults",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"trace",
".",
"Wrap",
"(",
"err",
")",
"\n",
... | // New returns a new instance of multiplexer | [
"New",
"returns",
"a",
"new",
"instance",
"of",
"multiplexer"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/multiplexer/multiplexer.go#L83-L102 | train |
gravitational/teleport | lib/multiplexer/multiplexer.go | Serve | func (m *Mux) Serve() error {
defer m.waitCancel()
backoffTimer := time.NewTicker(5 * time.Second)
defer backoffTimer.Stop()
for {
conn, err := m.Listener.Accept()
if err == nil {
if tcpConn, ok := conn.(*net.TCPConn); ok {
tcpConn.SetKeepAlive(true)
tcpConn.SetKeepAlivePeriod(3 * time.Minute)
}
... | go | func (m *Mux) Serve() error {
defer m.waitCancel()
backoffTimer := time.NewTicker(5 * time.Second)
defer backoffTimer.Stop()
for {
conn, err := m.Listener.Accept()
if err == nil {
if tcpConn, ok := conn.(*net.TCPConn); ok {
tcpConn.SetKeepAlive(true)
tcpConn.SetKeepAlivePeriod(3 * time.Minute)
}
... | [
"func",
"(",
"m",
"*",
"Mux",
")",
"Serve",
"(",
")",
"error",
"{",
"defer",
"m",
".",
"waitCancel",
"(",
")",
"\n",
"backoffTimer",
":=",
"time",
".",
"NewTicker",
"(",
"5",
"*",
"time",
".",
"Second",
")",
"\n",
"defer",
"backoffTimer",
".",
"Sto... | // Serve is a blocking function that serves on the listening socket
// and accepts requests. Every request is served in a separate goroutine | [
"Serve",
"is",
"a",
"blocking",
"function",
"that",
"serves",
"on",
"the",
"listening",
"socket",
"and",
"accepts",
"requests",
".",
"Every",
"request",
"is",
"served",
"in",
"a",
"separate",
"goroutine"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/multiplexer/multiplexer.go#L164-L188 | train |
gravitational/teleport | lib/auth/grpcserver.go | SendKeepAlives | func (g *GRPCServer) SendKeepAlives(stream proto.AuthService_SendKeepAlivesServer) error {
defer stream.SendAndClose(&empty.Empty{})
auth, err := g.authenticate(stream.Context())
if err != nil {
return trail.ToGRPC(err)
}
g.Debugf("Got heartbeat connection from %v.", auth.User.GetName())
for {
keepAlive, err ... | go | func (g *GRPCServer) SendKeepAlives(stream proto.AuthService_SendKeepAlivesServer) error {
defer stream.SendAndClose(&empty.Empty{})
auth, err := g.authenticate(stream.Context())
if err != nil {
return trail.ToGRPC(err)
}
g.Debugf("Got heartbeat connection from %v.", auth.User.GetName())
for {
keepAlive, err ... | [
"func",
"(",
"g",
"*",
"GRPCServer",
")",
"SendKeepAlives",
"(",
"stream",
"proto",
".",
"AuthService_SendKeepAlivesServer",
")",
"error",
"{",
"defer",
"stream",
".",
"SendAndClose",
"(",
"&",
"empty",
".",
"Empty",
"{",
"}",
")",
"\n",
"auth",
",",
"err"... | // SendKeepAlives allows node to send a stream of keep alive requests | [
"SendKeepAlives",
"allows",
"node",
"to",
"send",
"a",
"stream",
"of",
"keep",
"alive",
"requests"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/grpcserver.go#L48-L70 | train |
gravitational/teleport | lib/auth/grpcserver.go | WatchEvents | func (g *GRPCServer) WatchEvents(watch *proto.Watch, stream proto.AuthService_WatchEventsServer) error {
auth, err := g.authenticate(stream.Context())
if err != nil {
return trail.ToGRPC(err)
}
servicesWatch := services.Watch{
Name: auth.User.GetName(),
}
for _, kind := range watch.Kinds {
servicesWatch.Kin... | go | func (g *GRPCServer) WatchEvents(watch *proto.Watch, stream proto.AuthService_WatchEventsServer) error {
auth, err := g.authenticate(stream.Context())
if err != nil {
return trail.ToGRPC(err)
}
servicesWatch := services.Watch{
Name: auth.User.GetName(),
}
for _, kind := range watch.Kinds {
servicesWatch.Kin... | [
"func",
"(",
"g",
"*",
"GRPCServer",
")",
"WatchEvents",
"(",
"watch",
"*",
"proto",
".",
"Watch",
",",
"stream",
"proto",
".",
"AuthService_WatchEventsServer",
")",
"error",
"{",
"auth",
",",
"err",
":=",
"g",
".",
"authenticate",
"(",
"stream",
".",
"C... | // WatchEvents returns a new stream of cluster events | [
"WatchEvents",
"returns",
"a",
"new",
"stream",
"of",
"cluster",
"events"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/grpcserver.go#L73-L110 | train |
gravitational/teleport | lib/auth/grpcserver.go | UpsertNode | func (g *GRPCServer) UpsertNode(ctx context.Context, server *services.ServerV2) (*services.KeepAlive, error) {
auth, err := g.authenticate(ctx)
if err != nil {
return nil, trail.ToGRPC(err)
}
keepAlive, err := auth.UpsertNode(server)
if err != nil {
return nil, trail.ToGRPC(err)
}
return keepAlive, nil
} | go | func (g *GRPCServer) UpsertNode(ctx context.Context, server *services.ServerV2) (*services.KeepAlive, error) {
auth, err := g.authenticate(ctx)
if err != nil {
return nil, trail.ToGRPC(err)
}
keepAlive, err := auth.UpsertNode(server)
if err != nil {
return nil, trail.ToGRPC(err)
}
return keepAlive, nil
} | [
"func",
"(",
"g",
"*",
"GRPCServer",
")",
"UpsertNode",
"(",
"ctx",
"context",
".",
"Context",
",",
"server",
"*",
"services",
".",
"ServerV2",
")",
"(",
"*",
"services",
".",
"KeepAlive",
",",
"error",
")",
"{",
"auth",
",",
"err",
":=",
"g",
".",
... | // UpsertNode upserts node | [
"UpsertNode",
"upserts",
"node"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/grpcserver.go#L113-L123 | train |
gravitational/teleport | lib/auth/grpcserver.go | authenticate | func (g *GRPCServer) authenticate(ctx context.Context) (*grpcContext, error) {
// HTTPS server expects auth context to be set by the auth middleware
authContext, err := g.Authorizer.Authorize(ctx)
if err != nil {
// propagate connection problem error so we can differentiate
// between connection failed and acce... | go | func (g *GRPCServer) authenticate(ctx context.Context) (*grpcContext, error) {
// HTTPS server expects auth context to be set by the auth middleware
authContext, err := g.Authorizer.Authorize(ctx)
if err != nil {
// propagate connection problem error so we can differentiate
// between connection failed and acce... | [
"func",
"(",
"g",
"*",
"GRPCServer",
")",
"authenticate",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"*",
"grpcContext",
",",
"error",
")",
"{",
"// HTTPS server expects auth context to be set by the auth middleware",
"authContext",
",",
"err",
":=",
"g",
"... | // authenticate extracts authentication context and returns initialized auth server | [
"authenticate",
"extracts",
"authentication",
"context",
"and",
"returns",
"initialized",
"auth",
"server"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/grpcserver.go#L131-L157 | train |
gravitational/teleport | lib/auth/grpcserver.go | NewGRPCServer | func NewGRPCServer(cfg APIConfig) http.Handler {
authServer := &GRPCServer{
APIConfig: cfg,
Entry: logrus.WithFields(logrus.Fields{
trace.Component: teleport.Component(teleport.ComponentAuth, teleport.ComponentGRPC),
}),
httpHandler: NewAPIServer(&cfg),
grpcHandler: grpc.NewServer(),
}
proto.RegisterAut... | go | func NewGRPCServer(cfg APIConfig) http.Handler {
authServer := &GRPCServer{
APIConfig: cfg,
Entry: logrus.WithFields(logrus.Fields{
trace.Component: teleport.Component(teleport.ComponentAuth, teleport.ComponentGRPC),
}),
httpHandler: NewAPIServer(&cfg),
grpcHandler: grpc.NewServer(),
}
proto.RegisterAut... | [
"func",
"NewGRPCServer",
"(",
"cfg",
"APIConfig",
")",
"http",
".",
"Handler",
"{",
"authServer",
":=",
"&",
"GRPCServer",
"{",
"APIConfig",
":",
"cfg",
",",
"Entry",
":",
"logrus",
".",
"WithFields",
"(",
"logrus",
".",
"Fields",
"{",
"trace",
".",
"Com... | // NewGRPCServer returns a new instance of GRPC server | [
"NewGRPCServer",
"returns",
"a",
"new",
"instance",
"of",
"GRPC",
"server"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/grpcserver.go#L160-L171 | train |
gravitational/teleport | lib/auth/grpcserver.go | ServeHTTP | func (g *GRPCServer) ServeHTTP(w http.ResponseWriter, r *http.Request) {
// magic combo match signifying GRPC request
// https://grpc.io/blog/coreos
if r.ProtoMajor == 2 && strings.Contains(r.Header.Get("Content-Type"), "application/grpc") {
g.grpcHandler.ServeHTTP(w, r)
} else {
g.httpHandler.ServeHTTP(w, r)
... | go | func (g *GRPCServer) ServeHTTP(w http.ResponseWriter, r *http.Request) {
// magic combo match signifying GRPC request
// https://grpc.io/blog/coreos
if r.ProtoMajor == 2 && strings.Contains(r.Header.Get("Content-Type"), "application/grpc") {
g.grpcHandler.ServeHTTP(w, r)
} else {
g.httpHandler.ServeHTTP(w, r)
... | [
"func",
"(",
"g",
"*",
"GRPCServer",
")",
"ServeHTTP",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"{",
"// magic combo match signifying GRPC request",
"// https://grpc.io/blog/coreos",
"if",
"r",
".",
"ProtoMajor",
"==",
... | // ServeHTTP dispatches requests based on the request type | [
"ServeHTTP",
"dispatches",
"requests",
"based",
"on",
"the",
"request",
"type"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/grpcserver.go#L174-L182 | train |
gravitational/teleport | lib/srv/regular/sites.go | Start | func (t *proxySitesSubsys) Start(sconn *ssh.ServerConn, ch ssh.Channel, req *ssh.Request, ctx *srv.ServerContext) error {
log.Debugf("proxysites.start(%v)", ctx)
remoteSites := t.srv.proxyTun.GetSites()
// build an arary of services.Site structures:
retval := make([]services.Site, 0, len(remoteSites))
for _, s :=... | go | func (t *proxySitesSubsys) Start(sconn *ssh.ServerConn, ch ssh.Channel, req *ssh.Request, ctx *srv.ServerContext) error {
log.Debugf("proxysites.start(%v)", ctx)
remoteSites := t.srv.proxyTun.GetSites()
// build an arary of services.Site structures:
retval := make([]services.Site, 0, len(remoteSites))
for _, s :=... | [
"func",
"(",
"t",
"*",
"proxySitesSubsys",
")",
"Start",
"(",
"sconn",
"*",
"ssh",
".",
"ServerConn",
",",
"ch",
"ssh",
".",
"Channel",
",",
"req",
"*",
"ssh",
".",
"Request",
",",
"ctx",
"*",
"srv",
".",
"ServerContext",
")",
"error",
"{",
"log",
... | // Start serves a request for "proxysites" custom SSH subsystem. It builds an array of
// service.Site structures, and writes it serialized as JSON back to the SSH client | [
"Start",
"serves",
"a",
"request",
"for",
"proxysites",
"custom",
"SSH",
"subsystem",
".",
"It",
"builds",
"an",
"array",
"of",
"service",
".",
"Site",
"structures",
"and",
"writes",
"it",
"serialized",
"as",
"JSON",
"back",
"to",
"the",
"SSH",
"client"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/srv/regular/sites.go#L53-L75 | train |
gravitational/teleport | lib/events/multilog.go | Close | func (m *MultiLog) Close() error {
var errors []error
for _, log := range m.loggers {
errors = append(errors, log.Close())
}
return trace.NewAggregate(errors...)
} | go | func (m *MultiLog) Close() error {
var errors []error
for _, log := range m.loggers {
errors = append(errors, log.Close())
}
return trace.NewAggregate(errors...)
} | [
"func",
"(",
"m",
"*",
"MultiLog",
")",
"Close",
"(",
")",
"error",
"{",
"var",
"errors",
"[",
"]",
"error",
"\n",
"for",
"_",
",",
"log",
":=",
"range",
"m",
".",
"loggers",
"{",
"errors",
"=",
"append",
"(",
"errors",
",",
"log",
".",
"Close",
... | // Closer releases connections and resources associated with logs if any | [
"Closer",
"releases",
"connections",
"and",
"resources",
"associated",
"with",
"logs",
"if",
"any"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/events/multilog.go#L49-L55 | train |
gravitational/teleport | lib/client/client.go | FindServersByLabels | func (proxy *ProxyClient) FindServersByLabels(ctx context.Context, namespace string, labels map[string]string) ([]services.Server, error) {
if namespace == "" {
return nil, trace.BadParameter(auth.MissingNamespaceError)
}
nodes := make([]services.Server, 0)
site, err := proxy.CurrentClusterAccessPoint(ctx, false)... | go | func (proxy *ProxyClient) FindServersByLabels(ctx context.Context, namespace string, labels map[string]string) ([]services.Server, error) {
if namespace == "" {
return nil, trace.BadParameter(auth.MissingNamespaceError)
}
nodes := make([]services.Server, 0)
site, err := proxy.CurrentClusterAccessPoint(ctx, false)... | [
"func",
"(",
"proxy",
"*",
"ProxyClient",
")",
"FindServersByLabels",
"(",
"ctx",
"context",
".",
"Context",
",",
"namespace",
"string",
",",
"labels",
"map",
"[",
"string",
"]",
"string",
")",
"(",
"[",
"]",
"services",
".",
"Server",
",",
"error",
")",... | // FindServersByLabels returns list of the nodes which have labels exactly matching
// the given label set.
//
// A server is matched when ALL labels match.
// If no labels are passed, ALL nodes are returned. | [
"FindServersByLabels",
"returns",
"list",
"of",
"the",
"nodes",
"which",
"have",
"labels",
"exactly",
"matching",
"the",
"given",
"label",
"set",
".",
"A",
"server",
"is",
"matched",
"when",
"ALL",
"labels",
"match",
".",
"If",
"no",
"labels",
"are",
"passed... | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/client.go#L116-L138 | train |
gravitational/teleport | lib/client/client.go | CurrentClusterAccessPoint | func (proxy *ProxyClient) CurrentClusterAccessPoint(ctx context.Context, quiet bool) (auth.AccessPoint, error) {
// get the current cluster:
cluster, err := proxy.currentCluster()
if err != nil {
return nil, trace.Wrap(err)
}
return proxy.ClusterAccessPoint(ctx, cluster.Name, quiet)
} | go | func (proxy *ProxyClient) CurrentClusterAccessPoint(ctx context.Context, quiet bool) (auth.AccessPoint, error) {
// get the current cluster:
cluster, err := proxy.currentCluster()
if err != nil {
return nil, trace.Wrap(err)
}
return proxy.ClusterAccessPoint(ctx, cluster.Name, quiet)
} | [
"func",
"(",
"proxy",
"*",
"ProxyClient",
")",
"CurrentClusterAccessPoint",
"(",
"ctx",
"context",
".",
"Context",
",",
"quiet",
"bool",
")",
"(",
"auth",
".",
"AccessPoint",
",",
"error",
")",
"{",
"// get the current cluster:",
"cluster",
",",
"err",
":=",
... | // CurrentClusterAccessPoint returns cluster access point to the currently
// selected cluster and is used for discovery
// and could be cached based on the access policy | [
"CurrentClusterAccessPoint",
"returns",
"cluster",
"access",
"point",
"to",
"the",
"currently",
"selected",
"cluster",
"and",
"is",
"used",
"for",
"discovery",
"and",
"could",
"be",
"cached",
"based",
"on",
"the",
"access",
"policy"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/client.go#L143-L150 | train |
gravitational/teleport | lib/client/client.go | ClusterAccessPoint | func (proxy *ProxyClient) ClusterAccessPoint(ctx context.Context, clusterName string, quiet bool) (auth.AccessPoint, error) {
if clusterName == "" {
return nil, trace.BadParameter("parameter clusterName is missing")
}
clt, err := proxy.ConnectToCluster(ctx, clusterName, quiet)
if err != nil {
return nil, trace.... | go | func (proxy *ProxyClient) ClusterAccessPoint(ctx context.Context, clusterName string, quiet bool) (auth.AccessPoint, error) {
if clusterName == "" {
return nil, trace.BadParameter("parameter clusterName is missing")
}
clt, err := proxy.ConnectToCluster(ctx, clusterName, quiet)
if err != nil {
return nil, trace.... | [
"func",
"(",
"proxy",
"*",
"ProxyClient",
")",
"ClusterAccessPoint",
"(",
"ctx",
"context",
".",
"Context",
",",
"clusterName",
"string",
",",
"quiet",
"bool",
")",
"(",
"auth",
".",
"AccessPoint",
",",
"error",
")",
"{",
"if",
"clusterName",
"==",
"\"",
... | // ClusterAccessPoint returns cluster access point used for discovery
// and could be cached based on the access policy | [
"ClusterAccessPoint",
"returns",
"cluster",
"access",
"point",
"used",
"for",
"discovery",
"and",
"could",
"be",
"cached",
"based",
"on",
"the",
"access",
"policy"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/client.go#L154-L163 | train |
gravitational/teleport | lib/client/client.go | ConnectToCurrentCluster | func (proxy *ProxyClient) ConnectToCurrentCluster(ctx context.Context, quiet bool) (auth.ClientI, error) {
cluster, err := proxy.currentCluster()
if err != nil {
return nil, trace.Wrap(err)
}
return proxy.ConnectToCluster(ctx, cluster.Name, quiet)
} | go | func (proxy *ProxyClient) ConnectToCurrentCluster(ctx context.Context, quiet bool) (auth.ClientI, error) {
cluster, err := proxy.currentCluster()
if err != nil {
return nil, trace.Wrap(err)
}
return proxy.ConnectToCluster(ctx, cluster.Name, quiet)
} | [
"func",
"(",
"proxy",
"*",
"ProxyClient",
")",
"ConnectToCurrentCluster",
"(",
"ctx",
"context",
".",
"Context",
",",
"quiet",
"bool",
")",
"(",
"auth",
".",
"ClientI",
",",
"error",
")",
"{",
"cluster",
",",
"err",
":=",
"proxy",
".",
"currentCluster",
... | // ConnectToCurrentCluster connects to the auth server of the currently selected
// cluster via proxy. It returns connected and authenticated auth server client
//
// if 'quiet' is set to true, no errors will be printed to stdout, otherwise
// any connection errors are visible to a user. | [
"ConnectToCurrentCluster",
"connects",
"to",
"the",
"auth",
"server",
"of",
"the",
"currently",
"selected",
"cluster",
"via",
"proxy",
".",
"It",
"returns",
"connected",
"and",
"authenticated",
"auth",
"server",
"client",
"if",
"quiet",
"is",
"set",
"to",
"true"... | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/client.go#L170-L176 | train |
gravitational/teleport | lib/client/client.go | ConnectToCluster | func (proxy *ProxyClient) ConnectToCluster(ctx context.Context, clusterName string, quiet bool) (auth.ClientI, error) {
dialer := func(ctx context.Context, network, _ string) (net.Conn, error) {
return proxy.dialAuthServer(ctx, clusterName)
}
if proxy.teleportClient.SkipLocalAuth {
return auth.NewTLSClient(auth... | go | func (proxy *ProxyClient) ConnectToCluster(ctx context.Context, clusterName string, quiet bool) (auth.ClientI, error) {
dialer := func(ctx context.Context, network, _ string) (net.Conn, error) {
return proxy.dialAuthServer(ctx, clusterName)
}
if proxy.teleportClient.SkipLocalAuth {
return auth.NewTLSClient(auth... | [
"func",
"(",
"proxy",
"*",
"ProxyClient",
")",
"ConnectToCluster",
"(",
"ctx",
"context",
".",
"Context",
",",
"clusterName",
"string",
",",
"quiet",
"bool",
")",
"(",
"auth",
".",
"ClientI",
",",
"error",
")",
"{",
"dialer",
":=",
"func",
"(",
"ctx",
... | // ConnectToCluster connects to the auth server of the given cluster via proxy.
// It returns connected and authenticated auth server client
//
// if 'quiet' is set to true, no errors will be printed to stdout, otherwise
// any connection errors are visible to a user. | [
"ConnectToCluster",
"connects",
"to",
"the",
"auth",
"server",
"of",
"the",
"given",
"cluster",
"via",
"proxy",
".",
"It",
"returns",
"connected",
"and",
"authenticated",
"auth",
"server",
"client",
"if",
"quiet",
"is",
"set",
"to",
"true",
"no",
"errors",
"... | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/client.go#L183-L226 | train |
gravitational/teleport | lib/client/client.go | addCloser | func (c *closerConn) addCloser(closer io.Closer) {
c.closers = append(c.closers, closer)
} | go | func (c *closerConn) addCloser(closer io.Closer) {
c.closers = append(c.closers, closer)
} | [
"func",
"(",
"c",
"*",
"closerConn",
")",
"addCloser",
"(",
"closer",
"io",
".",
"Closer",
")",
"{",
"c",
".",
"closers",
"=",
"append",
"(",
"c",
".",
"closers",
",",
"closer",
")",
"\n",
"}"
] | // addCloser adds any closer in ctx that will be called
// whenever server closes session channel | [
"addCloser",
"adds",
"any",
"closer",
"in",
"ctx",
"that",
"will",
"be",
"called",
"whenever",
"server",
"closes",
"session",
"channel"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/client.go#L236-L238 | train |
gravitational/teleport | lib/client/client.go | nodeName | func nodeName(node string) string {
n, _, err := net.SplitHostPort(node)
if err != nil {
return node
}
return n
} | go | func nodeName(node string) string {
n, _, err := net.SplitHostPort(node)
if err != nil {
return node
}
return n
} | [
"func",
"nodeName",
"(",
"node",
"string",
")",
"string",
"{",
"n",
",",
"_",
",",
"err",
":=",
"net",
".",
"SplitHostPort",
"(",
"node",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"node",
"\n",
"}",
"\n",
"return",
"n",
"\n",
"}"
] | // nodeName removes the port number from the hostname, if present | [
"nodeName",
"removes",
"the",
"port",
"number",
"from",
"the",
"hostname",
"if",
"present"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/client.go#L250-L256 | train |
gravitational/teleport | lib/client/client.go | isRecordingProxy | func (proxy *ProxyClient) isRecordingProxy() (bool, error) {
responseCh := make(chan proxyResponse)
// we have to run this in a goroutine because older version of Teleport handled
// global out-of-band requests incorrectly: Teleport would ignore requests it
// does not know about and never reply to them. So if we ... | go | func (proxy *ProxyClient) isRecordingProxy() (bool, error) {
responseCh := make(chan proxyResponse)
// we have to run this in a goroutine because older version of Teleport handled
// global out-of-band requests incorrectly: Teleport would ignore requests it
// does not know about and never reply to them. So if we ... | [
"func",
"(",
"proxy",
"*",
"ProxyClient",
")",
"isRecordingProxy",
"(",
")",
"(",
"bool",
",",
"error",
")",
"{",
"responseCh",
":=",
"make",
"(",
"chan",
"proxyResponse",
")",
"\n\n",
"// we have to run this in a goroutine because older version of Teleport handled",
... | // isRecordingProxy returns true if the proxy is in recording mode. Note, this
// function can only be called after authentication has occurred and should be
// called before the first session is created. | [
"isRecordingProxy",
"returns",
"true",
"if",
"the",
"proxy",
"is",
"in",
"recording",
"mode",
".",
"Note",
"this",
"function",
"can",
"only",
"be",
"called",
"after",
"authentication",
"has",
"occurred",
"and",
"should",
"be",
"called",
"before",
"the",
"first... | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/client.go#L266-L305 | train |
gravitational/teleport | lib/client/client.go | dialAuthServer | func (proxy *ProxyClient) dialAuthServer(ctx context.Context, clusterName string) (net.Conn, error) {
log.Debugf("Client %v is connecting to auth server on cluster %q.", proxy.clientAddr, clusterName)
address := "@" + clusterName
// parse destination first:
localAddr, err := utils.ParseAddr("tcp://" + proxy.proxy... | go | func (proxy *ProxyClient) dialAuthServer(ctx context.Context, clusterName string) (net.Conn, error) {
log.Debugf("Client %v is connecting to auth server on cluster %q.", proxy.clientAddr, clusterName)
address := "@" + clusterName
// parse destination first:
localAddr, err := utils.ParseAddr("tcp://" + proxy.proxy... | [
"func",
"(",
"proxy",
"*",
"ProxyClient",
")",
"dialAuthServer",
"(",
"ctx",
"context",
".",
"Context",
",",
"clusterName",
"string",
")",
"(",
"net",
".",
"Conn",
",",
"error",
")",
"{",
"log",
".",
"Debugf",
"(",
"\"",
"\"",
",",
"proxy",
".",
"cli... | // dialAuthServer returns auth server connection forwarded via proxy | [
"dialAuthServer",
"returns",
"auth",
"server",
"connection",
"forwarded",
"via",
"proxy"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/client.go#L308-L355 | train |
gravitational/teleport | lib/client/client.go | newClientConn | func newClientConn(ctx context.Context,
conn net.Conn,
nodeAddress string,
config *ssh.ClientConfig) (ssh.Conn, <-chan ssh.NewChannel, <-chan *ssh.Request, error) {
type response struct {
conn ssh.Conn
chanCh <-chan ssh.NewChannel
reqCh <-chan *ssh.Request
err error
}
respCh := make(chan response,... | go | func newClientConn(ctx context.Context,
conn net.Conn,
nodeAddress string,
config *ssh.ClientConfig) (ssh.Conn, <-chan ssh.NewChannel, <-chan *ssh.Request, error) {
type response struct {
conn ssh.Conn
chanCh <-chan ssh.NewChannel
reqCh <-chan *ssh.Request
err error
}
respCh := make(chan response,... | [
"func",
"newClientConn",
"(",
"ctx",
"context",
".",
"Context",
",",
"conn",
"net",
".",
"Conn",
",",
"nodeAddress",
"string",
",",
"config",
"*",
"ssh",
".",
"ClientConfig",
")",
"(",
"ssh",
".",
"Conn",
",",
"<-",
"chan",
"ssh",
".",
"NewChannel",
",... | // newClientConn is a wrapper around ssh.NewClientConn | [
"newClientConn",
"is",
"a",
"wrapper",
"around",
"ssh",
".",
"NewClientConn"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/client.go#L517-L550 | train |
gravitational/teleport | lib/client/client.go | listenAndForward | func (c *NodeClient) listenAndForward(ctx context.Context, ln net.Listener, remoteAddr string) {
defer ln.Close()
defer c.Close()
for {
// Accept connections from the client.
conn, err := ln.Accept()
if err != nil {
log.Errorf("Port forwarding failed: %v.", err)
break
}
// Proxy the connection to t... | go | func (c *NodeClient) listenAndForward(ctx context.Context, ln net.Listener, remoteAddr string) {
defer ln.Close()
defer c.Close()
for {
// Accept connections from the client.
conn, err := ln.Accept()
if err != nil {
log.Errorf("Port forwarding failed: %v.", err)
break
}
// Proxy the connection to t... | [
"func",
"(",
"c",
"*",
"NodeClient",
")",
"listenAndForward",
"(",
"ctx",
"context",
".",
"Context",
",",
"ln",
"net",
".",
"Listener",
",",
"remoteAddr",
"string",
")",
"{",
"defer",
"ln",
".",
"Close",
"(",
")",
"\n",
"defer",
"c",
".",
"Close",
"(... | // listenAndForward listens on a given socket and forwards all incoming
// commands to the remote address through the SSH tunnel. | [
"listenAndForward",
"listens",
"on",
"a",
"given",
"socket",
"and",
"forwards",
"all",
"incoming",
"commands",
"to",
"the",
"remote",
"address",
"through",
"the",
"SSH",
"tunnel",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/client.go#L675-L695 | train |
gravitational/teleport | lib/client/client.go | dynamicListenAndForward | func (c *NodeClient) dynamicListenAndForward(ctx context.Context, ln net.Listener) {
defer ln.Close()
defer c.Close()
for {
// Accept connection from the client. Here the client is typically
// something like a web browser or other SOCKS5 aware application.
conn, err := ln.Accept()
if err != nil {
log.Er... | go | func (c *NodeClient) dynamicListenAndForward(ctx context.Context, ln net.Listener) {
defer ln.Close()
defer c.Close()
for {
// Accept connection from the client. Here the client is typically
// something like a web browser or other SOCKS5 aware application.
conn, err := ln.Accept()
if err != nil {
log.Er... | [
"func",
"(",
"c",
"*",
"NodeClient",
")",
"dynamicListenAndForward",
"(",
"ctx",
"context",
".",
"Context",
",",
"ln",
"net",
".",
"Listener",
")",
"{",
"defer",
"ln",
".",
"Close",
"(",
")",
"\n",
"defer",
"c",
".",
"Close",
"(",
")",
"\n\n",
"for",... | // dynamicListenAndForward listens for connections, performs a SOCKS5
// handshake, and then proxies the connection to the requested address. | [
"dynamicListenAndForward",
"listens",
"for",
"connections",
"performs",
"a",
"SOCKS5",
"handshake",
"and",
"then",
"proxies",
"the",
"connection",
"to",
"the",
"requested",
"address",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/client.go#L699-L729 | train |
gravitational/teleport | lib/client/client.go | currentCluster | func (proxy *ProxyClient) currentCluster() (*services.Site, error) {
sites, err := proxy.GetSites()
if err != nil {
return nil, trace.Wrap(err)
}
if len(sites) == 0 {
return nil, trace.NotFound("no clusters registered")
}
if proxy.siteName == "" {
return &sites[0], nil
}
for _, site := range sites {
if ... | go | func (proxy *ProxyClient) currentCluster() (*services.Site, error) {
sites, err := proxy.GetSites()
if err != nil {
return nil, trace.Wrap(err)
}
if len(sites) == 0 {
return nil, trace.NotFound("no clusters registered")
}
if proxy.siteName == "" {
return &sites[0], nil
}
for _, site := range sites {
if ... | [
"func",
"(",
"proxy",
"*",
"ProxyClient",
")",
"currentCluster",
"(",
")",
"(",
"*",
"services",
".",
"Site",
",",
"error",
")",
"{",
"sites",
",",
"err",
":=",
"proxy",
".",
"GetSites",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil... | // currentCluster returns the connection to the API of the current cluster | [
"currentCluster",
"returns",
"the",
"connection",
"to",
"the",
"API",
"of",
"the",
"current",
"cluster"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/client.go#L737-L754 | train |
gravitational/teleport | lib/sshutils/scp/scp.go | CreateDownloadCommand | func CreateDownloadCommand(cfg Config) (Command, error) {
cfg.Flags.Sink = true
cfg.Flags.Source = false
cmd, err := CreateCommand(cfg)
if err != nil {
return nil, trace.Wrap(err)
}
return cmd, nil
} | go | func CreateDownloadCommand(cfg Config) (Command, error) {
cfg.Flags.Sink = true
cfg.Flags.Source = false
cmd, err := CreateCommand(cfg)
if err != nil {
return nil, trace.Wrap(err)
}
return cmd, nil
} | [
"func",
"CreateDownloadCommand",
"(",
"cfg",
"Config",
")",
"(",
"Command",
",",
"error",
")",
"{",
"cfg",
".",
"Flags",
".",
"Sink",
"=",
"true",
"\n",
"cfg",
".",
"Flags",
".",
"Source",
"=",
"false",
"\n",
"cmd",
",",
"err",
":=",
"CreateCommand",
... | // CreateDownloadCommand configures and returns a command used
// to download a file | [
"CreateDownloadCommand",
"configures",
"and",
"returns",
"a",
"command",
"used",
"to",
"download",
"a",
"file"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/sshutils/scp/scp.go#L129-L138 | train |
gravitational/teleport | lib/sshutils/scp/scp.go | CreateCommand | func CreateCommand(cfg Config) (Command, error) {
err := cfg.CheckAndSetDefaults()
if err != nil {
return nil, trace.Wrap(err)
}
cmd := command{
Config: cfg,
}
cmd.log = log.WithFields(log.Fields{
trace.Component: "SCP",
trace.ComponentFields: log.Fields{
"LocalAddr": cfg.Flags.LocalAddr,
"Re... | go | func CreateCommand(cfg Config) (Command, error) {
err := cfg.CheckAndSetDefaults()
if err != nil {
return nil, trace.Wrap(err)
}
cmd := command{
Config: cfg,
}
cmd.log = log.WithFields(log.Fields{
trace.Component: "SCP",
trace.ComponentFields: log.Fields{
"LocalAddr": cfg.Flags.LocalAddr,
"Re... | [
"func",
"CreateCommand",
"(",
"cfg",
"Config",
")",
"(",
"Command",
",",
"error",
")",
"{",
"err",
":=",
"cfg",
".",
"CheckAndSetDefaults",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"trace",
".",
"Wrap",
"(",
"err",
")",
... | // CreateCommand creates and returns a new Command | [
"CreateCommand",
"creates",
"and",
"returns",
"a",
"new",
"Command"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/sshutils/scp/scp.go#L167-L190 | train |
gravitational/teleport | lib/sshutils/scp/scp.go | sendError | func (cmd *command) sendError(ch io.ReadWriter, err error) error {
if err == nil {
return nil
}
cmd.log.Error(err)
message := err.Error()
bytes := make([]byte, 0, len(message)+2)
bytes = append(bytes, ErrByte)
bytes = append(bytes, message...)
bytes = append(bytes, []byte{'\n'}...)
_, writeErr := ch.Write(by... | go | func (cmd *command) sendError(ch io.ReadWriter, err error) error {
if err == nil {
return nil
}
cmd.log.Error(err)
message := err.Error()
bytes := make([]byte, 0, len(message)+2)
bytes = append(bytes, ErrByte)
bytes = append(bytes, message...)
bytes = append(bytes, []byte{'\n'}...)
_, writeErr := ch.Write(by... | [
"func",
"(",
"cmd",
"*",
"command",
")",
"sendError",
"(",
"ch",
"io",
".",
"ReadWriter",
",",
"err",
"error",
")",
"error",
"{",
"if",
"err",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"cmd",
".",
"log",
".",
"Error",
"(",
"err",
")",
... | // sendError gets called during all errors during SCP transmission.
// It writes it back to the SCP client | [
"sendError",
"gets",
"called",
"during",
"all",
"errors",
"during",
"SCP",
"transmission",
".",
"It",
"writes",
"it",
"back",
"to",
"the",
"SCP",
"client"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/sshutils/scp/scp.go#L515-L530 | train |
gravitational/teleport | lib/sshutils/scp/scp.go | read | func (r *reader) read() error {
n, err := r.r.Read(r.b)
if err != nil {
return trace.Wrap(err)
}
if n < 1 {
return trace.Errorf("unexpected error, read 0 bytes")
}
switch r.b[0] {
case OKByte:
return nil
case WarnByte, ErrByte:
r.s.Scan()
if err := r.s.Err(); err != nil {
return trace.Wrap(err)
... | go | func (r *reader) read() error {
n, err := r.r.Read(r.b)
if err != nil {
return trace.Wrap(err)
}
if n < 1 {
return trace.Errorf("unexpected error, read 0 bytes")
}
switch r.b[0] {
case OKByte:
return nil
case WarnByte, ErrByte:
r.s.Scan()
if err := r.s.Err(); err != nil {
return trace.Wrap(err)
... | [
"func",
"(",
"r",
"*",
"reader",
")",
"read",
"(",
")",
"error",
"{",
"n",
",",
"err",
":=",
"r",
".",
"r",
".",
"Read",
"(",
"r",
".",
"b",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"trace",
".",
"Wrap",
"(",
"err",
")",
"\n",
... | // read is used to "ask" for response messages after each SCP transmission
// it only reads text data until a newline and returns 'nil' for "OK" responses
// and errors for everything else | [
"read",
"is",
"used",
"to",
"ask",
"for",
"response",
"messages",
"after",
"each",
"SCP",
"transmission",
"it",
"only",
"reads",
"text",
"data",
"until",
"a",
"newline",
"and",
"returns",
"nil",
"for",
"OK",
"responses",
"and",
"errors",
"for",
"everything",... | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/sshutils/scp/scp.go#L639-L659 | train |
gravitational/teleport | lib/client/keystore.go | AddKey | func (fs *FSLocalKeyStore) AddKey(host, username string, key *Key) error {
dirPath, err := fs.dirFor(host, true)
if err != nil {
return trace.Wrap(err)
}
writeBytes := func(fname string, data []byte) error {
fp := filepath.Join(dirPath, fname)
err := ioutil.WriteFile(fp, data, keyFilePerms)
if err != nil {
... | go | func (fs *FSLocalKeyStore) AddKey(host, username string, key *Key) error {
dirPath, err := fs.dirFor(host, true)
if err != nil {
return trace.Wrap(err)
}
writeBytes := func(fname string, data []byte) error {
fp := filepath.Join(dirPath, fname)
err := ioutil.WriteFile(fp, data, keyFilePerms)
if err != nil {
... | [
"func",
"(",
"fs",
"*",
"FSLocalKeyStore",
")",
"AddKey",
"(",
"host",
",",
"username",
"string",
",",
"key",
"*",
"Key",
")",
"error",
"{",
"dirPath",
",",
"err",
":=",
"fs",
".",
"dirFor",
"(",
"host",
",",
"true",
")",
"\n",
"if",
"err",
"!=",
... | // AddKey adds a new key to the session store. If a key for the host is already
// stored, overwrites it. | [
"AddKey",
"adds",
"a",
"new",
"key",
"to",
"the",
"session",
"store",
".",
"If",
"a",
"key",
"for",
"the",
"host",
"is",
"already",
"stored",
"overwrites",
"it",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/keystore.go#L142-L168 | train |
gravitational/teleport | lib/client/keystore.go | DeleteKey | func (fs *FSLocalKeyStore) DeleteKey(host string, username string) error {
dirPath, err := fs.dirFor(host, false)
if err != nil {
return trace.Wrap(err)
}
files := []string{
filepath.Join(dirPath, username+fileExtCert),
filepath.Join(dirPath, username+fileExtTLSCert),
filepath.Join(dirPath, username+fileExt... | go | func (fs *FSLocalKeyStore) DeleteKey(host string, username string) error {
dirPath, err := fs.dirFor(host, false)
if err != nil {
return trace.Wrap(err)
}
files := []string{
filepath.Join(dirPath, username+fileExtCert),
filepath.Join(dirPath, username+fileExtTLSCert),
filepath.Join(dirPath, username+fileExt... | [
"func",
"(",
"fs",
"*",
"FSLocalKeyStore",
")",
"DeleteKey",
"(",
"host",
"string",
",",
"username",
"string",
")",
"error",
"{",
"dirPath",
",",
"err",
":=",
"fs",
".",
"dirFor",
"(",
"host",
",",
"false",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
... | // DeleteKey deletes a key from the local store | [
"DeleteKey",
"deletes",
"a",
"key",
"from",
"the",
"local",
"store"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/keystore.go#L171-L188 | train |
gravitational/teleport | lib/client/keystore.go | DeleteKeys | func (fs *FSLocalKeyStore) DeleteKeys() error {
dirPath := filepath.Join(fs.KeyDir, sessionKeyDir)
err := os.RemoveAll(dirPath)
if err != nil {
return trace.Wrap(err)
}
return nil
} | go | func (fs *FSLocalKeyStore) DeleteKeys() error {
dirPath := filepath.Join(fs.KeyDir, sessionKeyDir)
err := os.RemoveAll(dirPath)
if err != nil {
return trace.Wrap(err)
}
return nil
} | [
"func",
"(",
"fs",
"*",
"FSLocalKeyStore",
")",
"DeleteKeys",
"(",
")",
"error",
"{",
"dirPath",
":=",
"filepath",
".",
"Join",
"(",
"fs",
".",
"KeyDir",
",",
"sessionKeyDir",
")",
"\n\n",
"err",
":=",
"os",
".",
"RemoveAll",
"(",
"dirPath",
")",
"\n",... | // DeleteKeys removes all session keys from disk. | [
"DeleteKeys",
"removes",
"all",
"session",
"keys",
"from",
"disk",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/keystore.go#L191-L200 | train |
gravitational/teleport | lib/client/keystore.go | GetKey | func (fs *FSLocalKeyStore) GetKey(proxyHost string, username string) (*Key, error) {
dirPath, err := fs.dirFor(proxyHost, false)
if err != nil {
return nil, trace.Wrap(err)
}
_, err = ioutil.ReadDir(dirPath)
if err != nil {
return nil, trace.NotFound("no session keys for %v in %v", username, proxyHost)
}
ce... | go | func (fs *FSLocalKeyStore) GetKey(proxyHost string, username string) (*Key, error) {
dirPath, err := fs.dirFor(proxyHost, false)
if err != nil {
return nil, trace.Wrap(err)
}
_, err = ioutil.ReadDir(dirPath)
if err != nil {
return nil, trace.NotFound("no session keys for %v in %v", username, proxyHost)
}
ce... | [
"func",
"(",
"fs",
"*",
"FSLocalKeyStore",
")",
"GetKey",
"(",
"proxyHost",
"string",
",",
"username",
"string",
")",
"(",
"*",
"Key",
",",
"error",
")",
"{",
"dirPath",
",",
"err",
":=",
"fs",
".",
"dirFor",
"(",
"proxyHost",
",",
"false",
")",
"\n"... | // GetKey returns a key for a given host. If the key is not found,
// returns trace.NotFound error. | [
"GetKey",
"returns",
"a",
"key",
"for",
"a",
"given",
"host",
".",
"If",
"the",
"key",
"is",
"not",
"found",
"returns",
"trace",
".",
"NotFound",
"error",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/keystore.go#L204-L263 | train |
gravitational/teleport | lib/client/keystore.go | SaveCerts | func (fs *FSLocalKeyStore) SaveCerts(proxy string, cas []auth.TrustedCerts) error {
dir, err := fs.dirFor(proxy, true)
if err != nil {
return trace.Wrap(err)
}
fp, err := os.OpenFile(filepath.Join(dir, fileNameTLSCerts), os.O_CREATE|os.O_RDWR|os.O_TRUNC, 0640)
if err != nil {
return trace.Wrap(err)
}
defer f... | go | func (fs *FSLocalKeyStore) SaveCerts(proxy string, cas []auth.TrustedCerts) error {
dir, err := fs.dirFor(proxy, true)
if err != nil {
return trace.Wrap(err)
}
fp, err := os.OpenFile(filepath.Join(dir, fileNameTLSCerts), os.O_CREATE|os.O_RDWR|os.O_TRUNC, 0640)
if err != nil {
return trace.Wrap(err)
}
defer f... | [
"func",
"(",
"fs",
"*",
"FSLocalKeyStore",
")",
"SaveCerts",
"(",
"proxy",
"string",
",",
"cas",
"[",
"]",
"auth",
".",
"TrustedCerts",
")",
"error",
"{",
"dir",
",",
"err",
":=",
"fs",
".",
"dirFor",
"(",
"proxy",
",",
"true",
")",
"\n",
"if",
"er... | // SaveCerts saves trusted TLS certificates of certificate authorities | [
"SaveCerts",
"saves",
"trusted",
"TLS",
"certificates",
"of",
"certificate",
"authorities"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/keystore.go#L266-L290 | train |
gravitational/teleport | lib/client/keystore.go | GetCertsPEM | func (fs *FSLocalKeyStore) GetCertsPEM(proxy string) ([]byte, error) {
dir, err := fs.dirFor(proxy, false)
if err != nil {
return nil, trace.Wrap(err)
}
return ioutil.ReadFile(filepath.Join(dir, fileNameTLSCerts))
} | go | func (fs *FSLocalKeyStore) GetCertsPEM(proxy string) ([]byte, error) {
dir, err := fs.dirFor(proxy, false)
if err != nil {
return nil, trace.Wrap(err)
}
return ioutil.ReadFile(filepath.Join(dir, fileNameTLSCerts))
} | [
"func",
"(",
"fs",
"*",
"FSLocalKeyStore",
")",
"GetCertsPEM",
"(",
"proxy",
"string",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"dir",
",",
"err",
":=",
"fs",
".",
"dirFor",
"(",
"proxy",
",",
"false",
")",
"\n",
"if",
"err",
"!=",
"ni... | // GetCertsPEM returns trusted TLS certificates of certificate authorities PEM block | [
"GetCertsPEM",
"returns",
"trusted",
"TLS",
"certificates",
"of",
"certificate",
"authorities",
"PEM",
"block"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/keystore.go#L293-L299 | train |
gravitational/teleport | lib/client/keystore.go | GetCerts | func (fs *FSLocalKeyStore) GetCerts(proxy string) (*x509.CertPool, error) {
dir, err := fs.dirFor(proxy, false)
if err != nil {
return nil, trace.Wrap(err)
}
bytes, err := ioutil.ReadFile(filepath.Join(dir, fileNameTLSCerts))
if err != nil {
return nil, trace.ConvertSystemError(err)
}
pool := x509.NewCertPoo... | go | func (fs *FSLocalKeyStore) GetCerts(proxy string) (*x509.CertPool, error) {
dir, err := fs.dirFor(proxy, false)
if err != nil {
return nil, trace.Wrap(err)
}
bytes, err := ioutil.ReadFile(filepath.Join(dir, fileNameTLSCerts))
if err != nil {
return nil, trace.ConvertSystemError(err)
}
pool := x509.NewCertPoo... | [
"func",
"(",
"fs",
"*",
"FSLocalKeyStore",
")",
"GetCerts",
"(",
"proxy",
"string",
")",
"(",
"*",
"x509",
".",
"CertPool",
",",
"error",
")",
"{",
"dir",
",",
"err",
":=",
"fs",
".",
"dirFor",
"(",
"proxy",
",",
"false",
")",
"\n",
"if",
"err",
... | // GetCerts returns trusted TLS certificates of certificate authorities | [
"GetCerts",
"returns",
"trusted",
"TLS",
"certificates",
"of",
"certificate",
"authorities"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/keystore.go#L302-L331 | train |
gravitational/teleport | lib/client/keystore.go | AddKnownHostKeys | func (fs *FSLocalKeyStore) AddKnownHostKeys(hostname string, hostKeys []ssh.PublicKey) error {
fp, err := os.OpenFile(filepath.Join(fs.KeyDir, fileNameKnownHosts), os.O_CREATE|os.O_RDWR, 0640)
if err != nil {
return trace.Wrap(err)
}
defer fp.Sync()
defer fp.Close()
// read all existing entries into a map (this... | go | func (fs *FSLocalKeyStore) AddKnownHostKeys(hostname string, hostKeys []ssh.PublicKey) error {
fp, err := os.OpenFile(filepath.Join(fs.KeyDir, fileNameKnownHosts), os.O_CREATE|os.O_RDWR, 0640)
if err != nil {
return trace.Wrap(err)
}
defer fp.Sync()
defer fp.Close()
// read all existing entries into a map (this... | [
"func",
"(",
"fs",
"*",
"FSLocalKeyStore",
")",
"AddKnownHostKeys",
"(",
"hostname",
"string",
",",
"hostKeys",
"[",
"]",
"ssh",
".",
"PublicKey",
")",
"error",
"{",
"fp",
",",
"err",
":=",
"os",
".",
"OpenFile",
"(",
"filepath",
".",
"Join",
"(",
"fs"... | // AddKnownHostKeys adds a new entry to 'known_hosts' file | [
"AddKnownHostKeys",
"adds",
"a",
"new",
"entry",
"to",
"known_hosts",
"file"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/keystore.go#L334-L373 | train |
gravitational/teleport | lib/client/keystore.go | GetKnownHostKeys | func (fs *FSLocalKeyStore) GetKnownHostKeys(hostname string) ([]ssh.PublicKey, error) {
bytes, err := ioutil.ReadFile(filepath.Join(fs.KeyDir, fileNameKnownHosts))
if err != nil {
if os.IsNotExist(err) {
return nil, nil
}
return nil, trace.Wrap(err)
}
var (
pubKey ssh.PublicKey
retval []ssh.Publi... | go | func (fs *FSLocalKeyStore) GetKnownHostKeys(hostname string) ([]ssh.PublicKey, error) {
bytes, err := ioutil.ReadFile(filepath.Join(fs.KeyDir, fileNameKnownHosts))
if err != nil {
if os.IsNotExist(err) {
return nil, nil
}
return nil, trace.Wrap(err)
}
var (
pubKey ssh.PublicKey
retval []ssh.Publi... | [
"func",
"(",
"fs",
"*",
"FSLocalKeyStore",
")",
"GetKnownHostKeys",
"(",
"hostname",
"string",
")",
"(",
"[",
"]",
"ssh",
".",
"PublicKey",
",",
"error",
")",
"{",
"bytes",
",",
"err",
":=",
"ioutil",
".",
"ReadFile",
"(",
"filepath",
".",
"Join",
"(",... | // GetKnownHostKeys returns all known public keys from 'known_hosts' | [
"GetKnownHostKeys",
"returns",
"all",
"known",
"public",
"keys",
"from",
"known_hosts"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/keystore.go#L376-L411 | train |
gravitational/teleport | tool/tctl/common/node_command.go | Initialize | func (c *NodeCommand) Initialize(app *kingpin.Application, config *service.Config) {
c.config = config
// add node command
nodes := app.Command("nodes", "Issue invites for other nodes to join the cluster")
c.nodeAdd = nodes.Command("add", "Generate a node invitation token")
c.nodeAdd.Flag("roles", "Comma-separate... | go | func (c *NodeCommand) Initialize(app *kingpin.Application, config *service.Config) {
c.config = config
// add node command
nodes := app.Command("nodes", "Issue invites for other nodes to join the cluster")
c.nodeAdd = nodes.Command("add", "Generate a node invitation token")
c.nodeAdd.Flag("roles", "Comma-separate... | [
"func",
"(",
"c",
"*",
"NodeCommand",
")",
"Initialize",
"(",
"app",
"*",
"kingpin",
".",
"Application",
",",
"config",
"*",
"service",
".",
"Config",
")",
"{",
"c",
".",
"config",
"=",
"config",
"\n\n",
"// add node command",
"nodes",
":=",
"app",
".",
... | // Initialize allows NodeCommand to plug itself into the CLI parser | [
"Initialize",
"allows",
"NodeCommand",
"to",
"plug",
"itself",
"into",
"the",
"CLI",
"parser"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/tool/tctl/common/node_command.go#L57-L72 | train |
gravitational/teleport | tool/tctl/common/node_command.go | Invite | func (c *NodeCommand) Invite(client auth.ClientI) error {
// parse --roles flag
roles, err := teleport.ParseRoles(c.roles)
if err != nil {
return trace.Wrap(err)
}
token, err := client.GenerateToken(auth.GenerateTokenRequest{Roles: roles, TTL: c.ttl, Token: c.token})
if err != nil {
return trace.Wrap(err)
}
... | go | func (c *NodeCommand) Invite(client auth.ClientI) error {
// parse --roles flag
roles, err := teleport.ParseRoles(c.roles)
if err != nil {
return trace.Wrap(err)
}
token, err := client.GenerateToken(auth.GenerateTokenRequest{Roles: roles, TTL: c.ttl, Token: c.token})
if err != nil {
return trace.Wrap(err)
}
... | [
"func",
"(",
"c",
"*",
"NodeCommand",
")",
"Invite",
"(",
"client",
"auth",
".",
"ClientI",
")",
"error",
"{",
"// parse --roles flag",
"roles",
",",
"err",
":=",
"teleport",
".",
"ParseRoles",
"(",
"c",
".",
"roles",
")",
"\n",
"if",
"err",
"!=",
"nil... | // Invite generates a token which can be used to add another SSH node
// to a cluster | [
"Invite",
"generates",
"a",
"token",
"which",
"can",
"be",
"used",
"to",
"add",
"another",
"SSH",
"node",
"to",
"a",
"cluster"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/tool/tctl/common/node_command.go#L113-L166 | train |
gravitational/teleport | tool/tctl/common/node_command.go | ListActive | func (c *NodeCommand) ListActive(client auth.ClientI) error {
nodes, err := client.GetNodes(c.namespace, services.SkipValidation())
if err != nil {
return trace.Wrap(err)
}
coll := &serverCollection{servers: nodes}
coll.writeText(os.Stdout)
return nil
} | go | func (c *NodeCommand) ListActive(client auth.ClientI) error {
nodes, err := client.GetNodes(c.namespace, services.SkipValidation())
if err != nil {
return trace.Wrap(err)
}
coll := &serverCollection{servers: nodes}
coll.writeText(os.Stdout)
return nil
} | [
"func",
"(",
"c",
"*",
"NodeCommand",
")",
"ListActive",
"(",
"client",
"auth",
".",
"ClientI",
")",
"error",
"{",
"nodes",
",",
"err",
":=",
"client",
".",
"GetNodes",
"(",
"c",
".",
"namespace",
",",
"services",
".",
"SkipValidation",
"(",
")",
")",
... | // ListActive retreives the list of nodes who recently sent heartbeats to
// to a cluster and prints it to stdout | [
"ListActive",
"retreives",
"the",
"list",
"of",
"nodes",
"who",
"recently",
"sent",
"heartbeats",
"to",
"to",
"a",
"cluster",
"and",
"prints",
"it",
"to",
"stdout"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/tool/tctl/common/node_command.go#L170-L178 | train |
gravitational/teleport | lib/client/hotp_mock.go | GetTokenFromHOTPMockFile | func GetTokenFromHOTPMockFile(path string) (token string, e error) {
otp, err := LoadHOTPMockFromFile(path)
if err != nil {
return "", trace.Wrap(err)
}
token = otp.OTP()
err = otp.SaveToFile(path)
if err != nil {
return "", trace.Wrap(err)
}
return token, nil
} | go | func GetTokenFromHOTPMockFile(path string) (token string, e error) {
otp, err := LoadHOTPMockFromFile(path)
if err != nil {
return "", trace.Wrap(err)
}
token = otp.OTP()
err = otp.SaveToFile(path)
if err != nil {
return "", trace.Wrap(err)
}
return token, nil
} | [
"func",
"GetTokenFromHOTPMockFile",
"(",
"path",
"string",
")",
"(",
"token",
"string",
",",
"e",
"error",
")",
"{",
"otp",
",",
"err",
":=",
"LoadHOTPMockFromFile",
"(",
"path",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"tra... | // GetTokenFromHOTPMockFile opens HOTPMock from file, gets token value,
// increases hotp and saves it to the file. Returns hotp token value. | [
"GetTokenFromHOTPMockFile",
"opens",
"HOTPMock",
"from",
"file",
"gets",
"token",
"value",
"increases",
"hotp",
"and",
"saves",
"it",
"to",
"the",
"file",
".",
"Returns",
"hotp",
"token",
"value",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/hotp_mock.go#L73-L87 | train |
gravitational/teleport | lib/utils/proxy/noproxy.go | useProxy | func useProxy(addr string) bool {
if len(addr) == 0 {
return true
}
var noProxy string
for _, env := range []string{teleport.NoProxy, strings.ToLower(teleport.NoProxy)} {
noProxy = os.Getenv(env)
if noProxy != "" {
break
}
}
if noProxy == "" {
return true
}
if noProxy == "*" {
return false
}
... | go | func useProxy(addr string) bool {
if len(addr) == 0 {
return true
}
var noProxy string
for _, env := range []string{teleport.NoProxy, strings.ToLower(teleport.NoProxy)} {
noProxy = os.Getenv(env)
if noProxy != "" {
break
}
}
if noProxy == "" {
return true
}
if noProxy == "*" {
return false
}
... | [
"func",
"useProxy",
"(",
"addr",
"string",
")",
"bool",
"{",
"if",
"len",
"(",
"addr",
")",
"==",
"0",
"{",
"return",
"true",
"\n",
"}",
"\n",
"var",
"noProxy",
"string",
"\n",
"for",
"_",
",",
"env",
":=",
"range",
"[",
"]",
"string",
"{",
"tele... | // useProxy reports whether requests to addr should use a proxy,
// according to the NO_PROXY or no_proxy environment variable.
// addr is always a canonicalAddr with a host and port. | [
"useProxy",
"reports",
"whether",
"requests",
"to",
"addr",
"should",
"use",
"a",
"proxy",
"according",
"to",
"the",
"NO_PROXY",
"or",
"no_proxy",
"environment",
"variable",
".",
"addr",
"is",
"always",
"a",
"canonicalAddr",
"with",
"a",
"host",
"and",
"port",... | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/proxy/noproxy.go#L22-L70 | train |
gravitational/teleport | lib/utils/agentconn/agent_windows.go | Dial | func Dial(socket string) (net.Conn, error) {
conn, err := winio.DialPipe(defaults.WindowsOpenSSHNamedPipe, nil)
if err != nil {
return nil, trace.Wrap(err)
}
return conn, nil
} | go | func Dial(socket string) (net.Conn, error) {
conn, err := winio.DialPipe(defaults.WindowsOpenSSHNamedPipe, nil)
if err != nil {
return nil, trace.Wrap(err)
}
return conn, nil
} | [
"func",
"Dial",
"(",
"socket",
"string",
")",
"(",
"net",
".",
"Conn",
",",
"error",
")",
"{",
"conn",
",",
"err",
":=",
"winio",
".",
"DialPipe",
"(",
"defaults",
".",
"WindowsOpenSSHNamedPipe",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
... | // Dial creates net.Conn to a SSH agent listening on a Windows named pipe.
// This is behind a build flag because winio.DialPipe is only available on
// Windows. | [
"Dial",
"creates",
"net",
".",
"Conn",
"to",
"a",
"SSH",
"agent",
"listening",
"on",
"a",
"Windows",
"named",
"pipe",
".",
"This",
"is",
"behind",
"a",
"build",
"flag",
"because",
"winio",
".",
"DialPipe",
"is",
"only",
"available",
"on",
"Windows",
"."
... | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/agentconn/agent_windows.go#L34-L41 | train |
gravitational/teleport | lib/auth/grpclog.go | Infoln | func (g *GLogger) Infoln(args ...interface{}) {
// GRPC is very verbose, so this is intentionally
// pushes info level statements as Teleport's debug level ones
g.Entry.Debug(fmt.Sprintln(args...))
} | go | func (g *GLogger) Infoln(args ...interface{}) {
// GRPC is very verbose, so this is intentionally
// pushes info level statements as Teleport's debug level ones
g.Entry.Debug(fmt.Sprintln(args...))
} | [
"func",
"(",
"g",
"*",
"GLogger",
")",
"Infoln",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"{",
"// GRPC is very verbose, so this is intentionally",
"// pushes info level statements as Teleport's debug level ones",
"g",
".",
"Entry",
".",
"Debug",
"(",
"fmt",
".... | // Infoln logs to INFO log. Arguments are handled in the manner of fmt.Println. | [
"Infoln",
"logs",
"to",
"INFO",
"log",
".",
"Arguments",
"are",
"handled",
"in",
"the",
"manner",
"of",
"fmt",
".",
"Println",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/grpclog.go#L54-L58 | train |
gravitational/teleport | lib/auth/grpclog.go | Infof | func (g *GLogger) Infof(format string, args ...interface{}) {
// GRPC is very verbose, so this is intentionally
// pushes info level statements as Teleport's debug level ones
g.Entry.Debugf(format, args...)
} | go | func (g *GLogger) Infof(format string, args ...interface{}) {
// GRPC is very verbose, so this is intentionally
// pushes info level statements as Teleport's debug level ones
g.Entry.Debugf(format, args...)
} | [
"func",
"(",
"g",
"*",
"GLogger",
")",
"Infof",
"(",
"format",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"{",
"// GRPC is very verbose, so this is intentionally",
"// pushes info level statements as Teleport's debug level ones",
"g",
".",
"Entry",
".",
... | // Infof logs to INFO log. Arguments are handled in the manner of fmt.Printf. | [
"Infof",
"logs",
"to",
"INFO",
"log",
".",
"Arguments",
"are",
"handled",
"in",
"the",
"manner",
"of",
"fmt",
".",
"Printf",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/grpclog.go#L61-L65 | train |
gravitational/teleport | lib/auth/grpclog.go | Warningln | func (g *GLogger) Warningln(args ...interface{}) {
g.Entry.Warning(fmt.Sprintln(args...))
} | go | func (g *GLogger) Warningln(args ...interface{}) {
g.Entry.Warning(fmt.Sprintln(args...))
} | [
"func",
"(",
"g",
"*",
"GLogger",
")",
"Warningln",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"{",
"g",
".",
"Entry",
".",
"Warning",
"(",
"fmt",
".",
"Sprintln",
"(",
"args",
"...",
")",
")",
"\n",
"}"
] | // Warningln logs to WARNING log. Arguments are handled in the manner of fmt.Println. | [
"Warningln",
"logs",
"to",
"WARNING",
"log",
".",
"Arguments",
"are",
"handled",
"in",
"the",
"manner",
"of",
"fmt",
".",
"Println",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/grpclog.go#L73-L75 | train |
gravitational/teleport | lib/auth/grpclog.go | Warningf | func (g *GLogger) Warningf(format string, args ...interface{}) {
g.Entry.Warningf(format, args...)
} | go | func (g *GLogger) Warningf(format string, args ...interface{}) {
g.Entry.Warningf(format, args...)
} | [
"func",
"(",
"g",
"*",
"GLogger",
")",
"Warningf",
"(",
"format",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"{",
"g",
".",
"Entry",
".",
"Warningf",
"(",
"format",
",",
"args",
"...",
")",
"\n",
"}"
] | // Warningf logs to WARNING log. Arguments are handled in the manner of fmt.Printf. | [
"Warningf",
"logs",
"to",
"WARNING",
"log",
".",
"Arguments",
"are",
"handled",
"in",
"the",
"manner",
"of",
"fmt",
".",
"Printf",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/grpclog.go#L78-L80 | train |
gravitational/teleport | lib/auth/grpclog.go | Errorln | func (g *GLogger) Errorln(args ...interface{}) {
g.Entry.Error(fmt.Sprintln(args...))
} | go | func (g *GLogger) Errorln(args ...interface{}) {
g.Entry.Error(fmt.Sprintln(args...))
} | [
"func",
"(",
"g",
"*",
"GLogger",
")",
"Errorln",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"{",
"g",
".",
"Entry",
".",
"Error",
"(",
"fmt",
".",
"Sprintln",
"(",
"args",
"...",
")",
")",
"\n",
"}"
] | // Errorln logs to ERROR log. Arguments are handled in the manner of fmt.Println. | [
"Errorln",
"logs",
"to",
"ERROR",
"log",
".",
"Arguments",
"are",
"handled",
"in",
"the",
"manner",
"of",
"fmt",
".",
"Println",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/grpclog.go#L88-L90 | train |
gravitational/teleport | lib/utils/socks/socks.go | Handshake | func Handshake(conn net.Conn) (string, error) {
// Read in the version and reject anything other than SOCKS5.
version, err := readByte(conn)
if err != nil {
return "", trace.Wrap(err)
}
if version != socks5Version {
return "", trace.BadParameter("only SOCKS5 is supported")
}
// Read in the authentication me... | go | func Handshake(conn net.Conn) (string, error) {
// Read in the version and reject anything other than SOCKS5.
version, err := readByte(conn)
if err != nil {
return "", trace.Wrap(err)
}
if version != socks5Version {
return "", trace.BadParameter("only SOCKS5 is supported")
}
// Read in the authentication me... | [
"func",
"Handshake",
"(",
"conn",
"net",
".",
"Conn",
")",
"(",
"string",
",",
"error",
")",
"{",
"// Read in the version and reject anything other than SOCKS5.",
"version",
",",
"err",
":=",
"readByte",
"(",
"conn",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
... | // Handshake performs a SOCKS5 handshake with the client and returns
// the remote address to proxy the connection to. | [
"Handshake",
"performs",
"a",
"SOCKS5",
"handshake",
"with",
"the",
"client",
"and",
"returns",
"the",
"remote",
"address",
"to",
"proxy",
"the",
"connection",
"to",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/socks/socks.go#L49-L87 | train |
gravitational/teleport | lib/utils/socks/socks.go | readAuthenticationMethod | func readAuthenticationMethod(conn net.Conn) ([]byte, error) {
// Read in the number of authentication methods supported.
nmethods, err := readByte(conn)
if err != nil {
return nil, trace.Wrap(err)
}
// Read nmethods number of bytes from the connection return the list of
// supported authentication methods to ... | go | func readAuthenticationMethod(conn net.Conn) ([]byte, error) {
// Read in the number of authentication methods supported.
nmethods, err := readByte(conn)
if err != nil {
return nil, trace.Wrap(err)
}
// Read nmethods number of bytes from the connection return the list of
// supported authentication methods to ... | [
"func",
"readAuthenticationMethod",
"(",
"conn",
"net",
".",
"Conn",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"// Read in the number of authentication methods supported.",
"nmethods",
",",
"err",
":=",
"readByte",
"(",
"conn",
")",
"\n",
"if",
"err",
... | // readAuthenticationMethod reads in the authentication methods the client
// supports. | [
"readAuthenticationMethod",
"reads",
"in",
"the",
"authentication",
"methods",
"the",
"client",
"supports",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/socks/socks.go#L91-L111 | train |
gravitational/teleport | lib/utils/socks/socks.go | writeMethodSelection | func writeMethodSelection(conn net.Conn) error {
message := []byte{socks5Version, socks5AuthNotRequired}
n, err := conn.Write(message)
if err != nil {
return trace.Wrap(err)
}
if n != len(message) {
return trace.BadParameter("wrote: %v wanted to write: %v", n, len(message))
}
return nil
} | go | func writeMethodSelection(conn net.Conn) error {
message := []byte{socks5Version, socks5AuthNotRequired}
n, err := conn.Write(message)
if err != nil {
return trace.Wrap(err)
}
if n != len(message) {
return trace.BadParameter("wrote: %v wanted to write: %v", n, len(message))
}
return nil
} | [
"func",
"writeMethodSelection",
"(",
"conn",
"net",
".",
"Conn",
")",
"error",
"{",
"message",
":=",
"[",
"]",
"byte",
"{",
"socks5Version",
",",
"socks5AuthNotRequired",
"}",
"\n\n",
"n",
",",
"err",
":=",
"conn",
".",
"Write",
"(",
"message",
")",
"\n"... | // writeMethodSelection writes out the response to the authentication methods.
// Right now, only SOCKS5 and "no authentication methods" is supported. | [
"writeMethodSelection",
"writes",
"out",
"the",
"response",
"to",
"the",
"authentication",
"methods",
".",
"Right",
"now",
"only",
"SOCKS5",
"and",
"no",
"authentication",
"methods",
"is",
"supported",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/socks/socks.go#L115-L127 | train |
gravitational/teleport | lib/utils/socks/socks.go | readAddrType | func readAddrType(conn net.Conn) (int, error) {
// Read in the type of the remote host.
addrType, err := readByte(conn)
if err != nil {
return 0, trace.Wrap(err)
}
// Based off the type, determine how many more bytes to read in for the
// remote address. For IPv4 it's 4 bytes, for IPv6 it's 16, and for domain
... | go | func readAddrType(conn net.Conn) (int, error) {
// Read in the type of the remote host.
addrType, err := readByte(conn)
if err != nil {
return 0, trace.Wrap(err)
}
// Based off the type, determine how many more bytes to read in for the
// remote address. For IPv4 it's 4 bytes, for IPv6 it's 16, and for domain
... | [
"func",
"readAddrType",
"(",
"conn",
"net",
".",
"Conn",
")",
"(",
"int",
",",
"error",
")",
"{",
"// Read in the type of the remote host.",
"addrType",
",",
"err",
":=",
"readByte",
"(",
"conn",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"0",
"... | // readAddrType reads in the address type and returns the length of the dest
// addr field. | [
"readAddrType",
"reads",
"in",
"the",
"address",
"type",
"and",
"returns",
"the",
"length",
"of",
"the",
"dest",
"addr",
"field",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/socks/socks.go#L182-L206 | train |
Subsets and Splits
SQL Console for semeru/code-text-go
Retrieves a limited set of code samples with their languages, with a specific case adjustment for 'Go' language.