id int32 0 167k | repo stringlengths 5 54 | path stringlengths 4 155 | func_name stringlengths 1 118 | original_string stringlengths 52 85.5k | language stringclasses 1
value | code stringlengths 52 85.5k | code_tokens listlengths 21 1.41k | docstring stringlengths 6 2.61k | docstring_tokens listlengths 3 215 | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
23,300 | 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 |
23,301 | 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 |
23,302 | 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 |
23,303 | 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 |
23,304 | 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 |
23,305 | 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 |
23,306 | 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 |
23,307 | 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 |
23,308 | 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 |
23,309 | 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 |
23,310 | 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 |
23,311 | 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 |
23,312 | 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 |
23,313 | 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 |
23,314 | 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 |
23,315 | 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 |
23,316 | 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 |
23,317 | 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 |
23,318 | 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 |
23,319 | 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 |
23,320 | 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 |
23,321 | 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 |
23,322 | 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 |
23,323 | 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 |
23,324 | 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 |
23,325 | 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 |
23,326 | 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 |
23,327 | 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 |
23,328 | 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 |
23,329 | 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 |
23,330 | 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 |
23,331 | 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 |
23,332 | 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 |
23,333 | 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 |
23,334 | 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 |
23,335 | 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 |
23,336 | 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 |
23,337 | 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 |
23,338 | 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 |
23,339 | 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 |
23,340 | 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 |
23,341 | 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 |
23,342 | 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 |
23,343 | 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 |
23,344 | 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 |
23,345 | 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 |
23,346 | 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 |
23,347 | 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 |
23,348 | 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 |
23,349 | 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 |
23,350 | 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 |
23,351 | 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 |
23,352 | 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 |
23,353 | 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 |
23,354 | 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 |
23,355 | 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 |
23,356 | 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 |
23,357 | 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 |
23,358 | 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 |
23,359 | 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 |
23,360 | 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 |
23,361 | 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 |
23,362 | 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 |
23,363 | 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 |
23,364 | 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 |
23,365 | 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 |
23,366 | 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 |
23,367 | 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 |
23,368 | 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 |
23,369 | 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 |
23,370 | 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 |
23,371 | 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 |
23,372 | 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 |
23,373 | 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 |
23,374 | 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 |
23,375 | 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 |
23,376 | gravitational/teleport | lib/utils/socks/socks.go | writeReply | func writeReply(conn net.Conn) error {
// Write success reply, similar to OpenSSH only success is written.
// https://github.com/openssh/openssh-portable/blob/5d14019/channels.c#L1442-L1452
message := []byte{
socks5Version,
socks5Succeeded,
socks5Reserved,
socks5AddressTypeIPv4,
}
n, err := conn.Write(mess... | go | func writeReply(conn net.Conn) error {
// Write success reply, similar to OpenSSH only success is written.
// https://github.com/openssh/openssh-portable/blob/5d14019/channels.c#L1442-L1452
message := []byte{
socks5Version,
socks5Succeeded,
socks5Reserved,
socks5AddressTypeIPv4,
}
n, err := conn.Write(mess... | [
"func",
"writeReply",
"(",
"conn",
"net",
".",
"Conn",
")",
"error",
"{",
"// Write success reply, similar to OpenSSH only success is written.",
"// https://github.com/openssh/openssh-portable/blob/5d14019/channels.c#L1442-L1452",
"message",
":=",
"[",
"]",
"byte",
"{",
"socks5Ve... | // Write the response to the client. | [
"Write",
"the",
"response",
"to",
"the",
"client",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/socks/socks.go#L209-L238 |
23,377 | gravitational/teleport | lib/utils/socks/socks.go | readByte | func readByte(conn net.Conn) (byte, error) {
b := make([]byte, 1)
_, err := io.ReadFull(conn, b)
if err != nil {
return 0, trace.Wrap(err)
}
return b[0], nil
} | go | func readByte(conn net.Conn) (byte, error) {
b := make([]byte, 1)
_, err := io.ReadFull(conn, b)
if err != nil {
return 0, trace.Wrap(err)
}
return b[0], nil
} | [
"func",
"readByte",
"(",
"conn",
"net",
".",
"Conn",
")",
"(",
"byte",
",",
"error",
")",
"{",
"b",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"1",
")",
"\n",
"_",
",",
"err",
":=",
"io",
".",
"ReadFull",
"(",
"conn",
",",
"b",
")",
"\n",
"i... | // readByte a single byte from the passed in net.Conn. | [
"readByte",
"a",
"single",
"byte",
"from",
"the",
"passed",
"in",
"net",
".",
"Conn",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/socks/socks.go#L241-L249 |
23,378 | gravitational/teleport | lib/utils/socks/socks.go | byteSliceContains | func byteSliceContains(a []byte, b byte) bool {
for _, v := range a {
if v == b {
return true
}
}
return false
} | go | func byteSliceContains(a []byte, b byte) bool {
for _, v := range a {
if v == b {
return true
}
}
return false
} | [
"func",
"byteSliceContains",
"(",
"a",
"[",
"]",
"byte",
",",
"b",
"byte",
")",
"bool",
"{",
"for",
"_",
",",
"v",
":=",
"range",
"a",
"{",
"if",
"v",
"==",
"b",
"{",
"return",
"true",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"false",
"\n",
"}"
... | // byteSliceContains checks if the slice a contains the byte b. | [
"byteSliceContains",
"checks",
"if",
"the",
"slice",
"a",
"contains",
"the",
"byte",
"b",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/socks/socks.go#L252-L260 |
23,379 | gravitational/teleport | lib/shell/shell.go | GetLoginShell | func GetLoginShell(username string) (string, error) {
var err error
var shellcmd string
shellcmd, err = getLoginShell(username)
if err != nil {
if !trace.IsNotFound(err) {
logrus.Warnf("No shell specified for %v, using default %v.", username, DefaultShell)
return DefaultShell, nil
}
return "", trace.Wr... | go | func GetLoginShell(username string) (string, error) {
var err error
var shellcmd string
shellcmd, err = getLoginShell(username)
if err != nil {
if !trace.IsNotFound(err) {
logrus.Warnf("No shell specified for %v, using default %v.", username, DefaultShell)
return DefaultShell, nil
}
return "", trace.Wr... | [
"func",
"GetLoginShell",
"(",
"username",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"var",
"err",
"error",
"\n",
"var",
"shellcmd",
"string",
"\n\n",
"shellcmd",
",",
"err",
"=",
"getLoginShell",
"(",
"username",
")",
"\n",
"if",
"err",
"!=",... | // GetLoginShell determines the login shell for a given username. | [
"GetLoginShell",
"determines",
"the",
"login",
"shell",
"for",
"a",
"given",
"username",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/shell/shell.go#L30-L44 |
23,380 | gravitational/teleport | integration/helpers.go | GetRoles | func (s *InstanceSecrets) GetRoles() []services.Role {
var roles []services.Role
for _, ca := range s.GetCAs() {
if ca.GetType() != services.UserCA {
continue
}
role := services.RoleForCertAuthority(ca)
role.SetLogins(services.Allow, s.AllowedLogins())
roles = append(roles, role)
}
return roles
} | go | func (s *InstanceSecrets) GetRoles() []services.Role {
var roles []services.Role
for _, ca := range s.GetCAs() {
if ca.GetType() != services.UserCA {
continue
}
role := services.RoleForCertAuthority(ca)
role.SetLogins(services.Allow, s.AllowedLogins())
roles = append(roles, role)
}
return roles
} | [
"func",
"(",
"s",
"*",
"InstanceSecrets",
")",
"GetRoles",
"(",
")",
"[",
"]",
"services",
".",
"Role",
"{",
"var",
"roles",
"[",
"]",
"services",
".",
"Role",
"\n",
"for",
"_",
",",
"ca",
":=",
"range",
"s",
".",
"GetCAs",
"(",
")",
"{",
"if",
... | // GetRoles returns a list of roles to initiate for this secret | [
"GetRoles",
"returns",
"a",
"list",
"of",
"roles",
"to",
"initiate",
"for",
"this",
"secret"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/integration/helpers.go#L231-L242 |
23,381 | gravitational/teleport | integration/helpers.go | SetupUserCreds | func SetupUserCreds(tc *client.TeleportClient, proxyHost string, creds UserCreds) error {
_, err := tc.AddKey(proxyHost, &creds.Key)
if err != nil {
return trace.Wrap(err)
}
err = tc.AddTrustedCA(creds.HostCA)
if err != nil {
return trace.Wrap(err)
}
return nil
} | go | func SetupUserCreds(tc *client.TeleportClient, proxyHost string, creds UserCreds) error {
_, err := tc.AddKey(proxyHost, &creds.Key)
if err != nil {
return trace.Wrap(err)
}
err = tc.AddTrustedCA(creds.HostCA)
if err != nil {
return trace.Wrap(err)
}
return nil
} | [
"func",
"SetupUserCreds",
"(",
"tc",
"*",
"client",
".",
"TeleportClient",
",",
"proxyHost",
"string",
",",
"creds",
"UserCreds",
")",
"error",
"{",
"_",
",",
"err",
":=",
"tc",
".",
"AddKey",
"(",
"proxyHost",
",",
"&",
"creds",
".",
"Key",
")",
"\n",... | // SetupUserCreds sets up user credentials for client | [
"SetupUserCreds",
"sets",
"up",
"user",
"credentials",
"for",
"client"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/integration/helpers.go#L357-L367 |
23,382 | gravitational/teleport | integration/helpers.go | SetupUser | func SetupUser(process *service.TeleportProcess, username string, roles []services.Role) error {
auth := process.GetAuthServer()
teleUser, err := services.NewUser(username)
if err != nil {
return trace.Wrap(err)
}
if len(roles) == 0 {
role := services.RoleForUser(teleUser)
role.SetLogins(services.Allow, []st... | go | func SetupUser(process *service.TeleportProcess, username string, roles []services.Role) error {
auth := process.GetAuthServer()
teleUser, err := services.NewUser(username)
if err != nil {
return trace.Wrap(err)
}
if len(roles) == 0 {
role := services.RoleForUser(teleUser)
role.SetLogins(services.Allow, []st... | [
"func",
"SetupUser",
"(",
"process",
"*",
"service",
".",
"TeleportProcess",
",",
"username",
"string",
",",
"roles",
"[",
"]",
"services",
".",
"Role",
")",
"error",
"{",
"auth",
":=",
"process",
".",
"GetAuthServer",
"(",
")",
"\n",
"teleUser",
",",
"e... | // SetupUser sets up user in the cluster | [
"SetupUser",
"sets",
"up",
"user",
"in",
"the",
"cluster"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/integration/helpers.go#L370-L405 |
23,383 | gravitational/teleport | integration/helpers.go | GenerateUserCreds | func GenerateUserCreds(process *service.TeleportProcess, username string) (*UserCreds, error) {
priv, pub, err := testauthority.New().GenerateKeyPair("")
if err != nil {
return nil, trace.Wrap(err)
}
a := process.GetAuthServer()
sshCert, x509Cert, err := a.GenerateUserCerts(pub, username, time.Hour, teleport.Cer... | go | func GenerateUserCreds(process *service.TeleportProcess, username string) (*UserCreds, error) {
priv, pub, err := testauthority.New().GenerateKeyPair("")
if err != nil {
return nil, trace.Wrap(err)
}
a := process.GetAuthServer()
sshCert, x509Cert, err := a.GenerateUserCerts(pub, username, time.Hour, teleport.Cer... | [
"func",
"GenerateUserCreds",
"(",
"process",
"*",
"service",
".",
"TeleportProcess",
",",
"username",
"string",
")",
"(",
"*",
"UserCreds",
",",
"error",
")",
"{",
"priv",
",",
"pub",
",",
"err",
":=",
"testauthority",
".",
"New",
"(",
")",
".",
"Generat... | // GenerateUserCreds generates key to be used by client | [
"GenerateUserCreds",
"generates",
"key",
"to",
"be",
"used",
"by",
"client"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/integration/helpers.go#L408-L438 |
23,384 | gravitational/teleport | integration/helpers.go | StartNode | func (i *TeleInstance) StartNode(tconf *service.Config) (*service.TeleportProcess, error) {
dataDir, err := ioutil.TempDir("", "cluster-"+i.Secrets.SiteName)
if err != nil {
return nil, trace.Wrap(err)
}
tconf.DataDir = dataDir
authServer := utils.MustParseAddr(net.JoinHostPort(i.Hostname, i.GetPortAuth()))
tc... | go | func (i *TeleInstance) StartNode(tconf *service.Config) (*service.TeleportProcess, error) {
dataDir, err := ioutil.TempDir("", "cluster-"+i.Secrets.SiteName)
if err != nil {
return nil, trace.Wrap(err)
}
tconf.DataDir = dataDir
authServer := utils.MustParseAddr(net.JoinHostPort(i.Hostname, i.GetPortAuth()))
tc... | [
"func",
"(",
"i",
"*",
"TeleInstance",
")",
"StartNode",
"(",
"tconf",
"*",
"service",
".",
"Config",
")",
"(",
"*",
"service",
".",
"TeleportProcess",
",",
"error",
")",
"{",
"dataDir",
",",
"err",
":=",
"ioutil",
".",
"TempDir",
"(",
"\"",
"\"",
",... | // StartNode starts a SSH node and connects it to the cluster. | [
"StartNode",
"starts",
"a",
"SSH",
"node",
"and",
"connects",
"it",
"to",
"the",
"cluster",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/integration/helpers.go#L603-L655 |
23,385 | gravitational/teleport | integration/helpers.go | StartNodeAndProxy | func (i *TeleInstance) StartNodeAndProxy(name string, sshPort, proxyWebPort, proxySSHPort int) error {
dataDir, err := ioutil.TempDir("", "cluster-"+i.Secrets.SiteName)
if err != nil {
return trace.Wrap(err)
}
tconf := service.MakeDefaultConfig()
authServer := utils.MustParseAddr(net.JoinHostPort(i.Hostname, i... | go | func (i *TeleInstance) StartNodeAndProxy(name string, sshPort, proxyWebPort, proxySSHPort int) error {
dataDir, err := ioutil.TempDir("", "cluster-"+i.Secrets.SiteName)
if err != nil {
return trace.Wrap(err)
}
tconf := service.MakeDefaultConfig()
authServer := utils.MustParseAddr(net.JoinHostPort(i.Hostname, i... | [
"func",
"(",
"i",
"*",
"TeleInstance",
")",
"StartNodeAndProxy",
"(",
"name",
"string",
",",
"sshPort",
",",
"proxyWebPort",
",",
"proxySSHPort",
"int",
")",
"error",
"{",
"dataDir",
",",
"err",
":=",
"ioutil",
".",
"TempDir",
"(",
"\"",
"\"",
",",
"\"",... | // StartNodeAndProxy starts a SSH node and a Proxy Server and connects it to
// the cluster. | [
"StartNodeAndProxy",
"starts",
"a",
"SSH",
"node",
"and",
"a",
"Proxy",
"Server",
"and",
"connects",
"it",
"to",
"the",
"cluster",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/integration/helpers.go#L659-L725 |
23,386 | gravitational/teleport | integration/helpers.go | StartProxy | func (i *TeleInstance) StartProxy(cfg ProxyConfig) error {
dataDir, err := ioutil.TempDir("", "cluster-"+i.Secrets.SiteName+"-"+cfg.Name)
if err != nil {
return trace.Wrap(err)
}
tconf := service.MakeDefaultConfig()
authServer := utils.MustParseAddr(net.JoinHostPort(i.Hostname, i.GetPortAuth()))
tconf.AuthSer... | go | func (i *TeleInstance) StartProxy(cfg ProxyConfig) error {
dataDir, err := ioutil.TempDir("", "cluster-"+i.Secrets.SiteName+"-"+cfg.Name)
if err != nil {
return trace.Wrap(err)
}
tconf := service.MakeDefaultConfig()
authServer := utils.MustParseAddr(net.JoinHostPort(i.Hostname, i.GetPortAuth()))
tconf.AuthSer... | [
"func",
"(",
"i",
"*",
"TeleInstance",
")",
"StartProxy",
"(",
"cfg",
"ProxyConfig",
")",
"error",
"{",
"dataDir",
",",
"err",
":=",
"ioutil",
".",
"TempDir",
"(",
"\"",
"\"",
",",
"\"",
"\"",
"+",
"i",
".",
"Secrets",
".",
"SiteName",
"+",
"\"",
"... | // StartProxy starts another Proxy Server and connects it to the cluster. | [
"StartProxy",
"starts",
"another",
"Proxy",
"Server",
"and",
"connects",
"it",
"to",
"the",
"cluster",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/integration/helpers.go#L740-L802 |
23,387 | gravitational/teleport | integration/helpers.go | Reset | func (i *TeleInstance) Reset() (err error) {
i.Process, err = service.NewTeleport(i.Config)
if err != nil {
return trace.Wrap(err)
}
return nil
} | go | func (i *TeleInstance) Reset() (err error) {
i.Process, err = service.NewTeleport(i.Config)
if err != nil {
return trace.Wrap(err)
}
return nil
} | [
"func",
"(",
"i",
"*",
"TeleInstance",
")",
"Reset",
"(",
")",
"(",
"err",
"error",
")",
"{",
"i",
".",
"Process",
",",
"err",
"=",
"service",
".",
"NewTeleport",
"(",
"i",
".",
"Config",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"trace... | // Reset re-creates the teleport instance based on the same configuration
// This is needed if you want to stop the instance, reset it and start again | [
"Reset",
"re",
"-",
"creates",
"the",
"teleport",
"instance",
"based",
"on",
"the",
"same",
"configuration",
"This",
"is",
"needed",
"if",
"you",
"want",
"to",
"stop",
"the",
"instance",
"reset",
"it",
"and",
"start",
"again"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/integration/helpers.go#L806-L812 |
23,388 | gravitational/teleport | integration/helpers.go | AddUserWithRole | func (i *TeleInstance) AddUserWithRole(username string, role services.Role) *User {
user := &User{
Username: username,
Roles: []services.Role{role},
}
i.Secrets.Users[username] = user
return user
} | go | func (i *TeleInstance) AddUserWithRole(username string, role services.Role) *User {
user := &User{
Username: username,
Roles: []services.Role{role},
}
i.Secrets.Users[username] = user
return user
} | [
"func",
"(",
"i",
"*",
"TeleInstance",
")",
"AddUserWithRole",
"(",
"username",
"string",
",",
"role",
"services",
".",
"Role",
")",
"*",
"User",
"{",
"user",
":=",
"&",
"User",
"{",
"Username",
":",
"username",
",",
"Roles",
":",
"[",
"]",
"services",... | // AddUserUserWithRole adds user with assigned role | [
"AddUserUserWithRole",
"adds",
"user",
"with",
"assigned",
"role"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/integration/helpers.go#L815-L822 |
23,389 | gravitational/teleport | integration/helpers.go | AddUser | func (i *TeleInstance) AddUser(username string, mappings []string) *User {
log.Infof("teleInstance.AddUser(%v) mapped to %v", username, mappings)
if mappings == nil {
mappings = make([]string, 0)
}
user := &User{
Username: username,
AllowedLogins: mappings,
}
i.Secrets.Users[username] = user
return us... | go | func (i *TeleInstance) AddUser(username string, mappings []string) *User {
log.Infof("teleInstance.AddUser(%v) mapped to %v", username, mappings)
if mappings == nil {
mappings = make([]string, 0)
}
user := &User{
Username: username,
AllowedLogins: mappings,
}
i.Secrets.Users[username] = user
return us... | [
"func",
"(",
"i",
"*",
"TeleInstance",
")",
"AddUser",
"(",
"username",
"string",
",",
"mappings",
"[",
"]",
"string",
")",
"*",
"User",
"{",
"log",
".",
"Infof",
"(",
"\"",
"\"",
",",
"username",
",",
"mappings",
")",
"\n",
"if",
"mappings",
"==",
... | // Adds a new user into i Teleport instance. 'mappings' is a comma-separated
// list of OS users | [
"Adds",
"a",
"new",
"user",
"into",
"i",
"Teleport",
"instance",
".",
"mappings",
"is",
"a",
"comma",
"-",
"separated",
"list",
"of",
"OS",
"users"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/integration/helpers.go#L826-L837 |
23,390 | gravitational/teleport | integration/helpers.go | Start | func (i *TeleInstance) Start() error {
// Build a list of expected events to wait for before unblocking based off
// the configuration passed in.
expectedEvents := []string{}
if i.Config.Auth.Enabled {
expectedEvents = append(expectedEvents, service.AuthTLSReady)
}
if i.Config.Proxy.Enabled {
expectedEvents =... | go | func (i *TeleInstance) Start() error {
// Build a list of expected events to wait for before unblocking based off
// the configuration passed in.
expectedEvents := []string{}
if i.Config.Auth.Enabled {
expectedEvents = append(expectedEvents, service.AuthTLSReady)
}
if i.Config.Proxy.Enabled {
expectedEvents =... | [
"func",
"(",
"i",
"*",
"TeleInstance",
")",
"Start",
"(",
")",
"error",
"{",
"// Build a list of expected events to wait for before unblocking based off",
"// the configuration passed in.",
"expectedEvents",
":=",
"[",
"]",
"string",
"{",
"}",
"\n",
"if",
"i",
".",
"C... | // Start will start the TeleInstance and then block until it is ready to
// process requests based off the passed in configuration. | [
"Start",
"will",
"start",
"the",
"TeleInstance",
"and",
"then",
"block",
"until",
"it",
"is",
"ready",
"to",
"process",
"requests",
"based",
"off",
"the",
"passed",
"in",
"configuration",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/integration/helpers.go#L841-L886 |
23,391 | gravitational/teleport | integration/helpers.go | NewClientWithCreds | func (i *TeleInstance) NewClientWithCreds(cfg ClientConfig, creds UserCreds) (tc *client.TeleportClient, err error) {
clt, err := i.NewUnauthenticatedClient(cfg)
if err != nil {
return nil, trace.Wrap(err)
}
err = SetupUserCreds(clt, i.Config.Proxy.SSHAddr.Addr, creds)
if err != nil {
return nil, trace.Wrap(er... | go | func (i *TeleInstance) NewClientWithCreds(cfg ClientConfig, creds UserCreds) (tc *client.TeleportClient, err error) {
clt, err := i.NewUnauthenticatedClient(cfg)
if err != nil {
return nil, trace.Wrap(err)
}
err = SetupUserCreds(clt, i.Config.Proxy.SSHAddr.Addr, creds)
if err != nil {
return nil, trace.Wrap(er... | [
"func",
"(",
"i",
"*",
"TeleInstance",
")",
"NewClientWithCreds",
"(",
"cfg",
"ClientConfig",
",",
"creds",
"UserCreds",
")",
"(",
"tc",
"*",
"client",
".",
"TeleportClient",
",",
"err",
"error",
")",
"{",
"clt",
",",
"err",
":=",
"i",
".",
"NewUnauthent... | // NewClientWithCreds creates client with credentials | [
"NewClientWithCreds",
"creates",
"client",
"with",
"credentials"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/integration/helpers.go#L906-L916 |
23,392 | gravitational/teleport | integration/helpers.go | StopProxy | func (i *TeleInstance) StopProxy() error {
var errors []error
for _, p := range i.Nodes {
if p.Config.Proxy.Enabled {
if err := p.Close(); err != nil {
errors = append(errors, err)
log.Errorf("Failed closing extra proxy: %v.", err)
}
if err := p.Wait(); err != nil {
errors = append(errors, err... | go | func (i *TeleInstance) StopProxy() error {
var errors []error
for _, p := range i.Nodes {
if p.Config.Proxy.Enabled {
if err := p.Close(); err != nil {
errors = append(errors, err)
log.Errorf("Failed closing extra proxy: %v.", err)
}
if err := p.Wait(); err != nil {
errors = append(errors, err... | [
"func",
"(",
"i",
"*",
"TeleInstance",
")",
"StopProxy",
"(",
")",
"error",
"{",
"var",
"errors",
"[",
"]",
"error",
"\n\n",
"for",
"_",
",",
"p",
":=",
"range",
"i",
".",
"Nodes",
"{",
"if",
"p",
".",
"Config",
".",
"Proxy",
".",
"Enabled",
"{",... | // StopProxy loops over the extra nodes in a TeleInstance and stops all
// nodes where the proxy server is enabled. | [
"StopProxy",
"loops",
"over",
"the",
"extra",
"nodes",
"in",
"a",
"TeleInstance",
"and",
"stops",
"all",
"nodes",
"where",
"the",
"proxy",
"server",
"is",
"enabled",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/integration/helpers.go#L993-L1010 |
23,393 | gravitational/teleport | integration/helpers.go | StopNodes | func (i *TeleInstance) StopNodes() error {
var errors []error
for _, node := range i.Nodes {
if err := node.Close(); err != nil {
errors = append(errors, err)
log.Errorf("failed closing extra node %v", err)
}
if err := node.Wait(); err != nil {
errors = append(errors, err)
log.Errorf("failed stoppin... | go | func (i *TeleInstance) StopNodes() error {
var errors []error
for _, node := range i.Nodes {
if err := node.Close(); err != nil {
errors = append(errors, err)
log.Errorf("failed closing extra node %v", err)
}
if err := node.Wait(); err != nil {
errors = append(errors, err)
log.Errorf("failed stoppin... | [
"func",
"(",
"i",
"*",
"TeleInstance",
")",
"StopNodes",
"(",
")",
"error",
"{",
"var",
"errors",
"[",
"]",
"error",
"\n",
"for",
"_",
",",
"node",
":=",
"range",
"i",
".",
"Nodes",
"{",
"if",
"err",
":=",
"node",
".",
"Close",
"(",
")",
";",
"... | // StopNodes stops additional nodes | [
"StopNodes",
"stops",
"additional",
"nodes"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/integration/helpers.go#L1013-L1026 |
23,394 | gravitational/teleport | integration/helpers.go | ServeHTTP | func (p *proxyServer) ServeHTTP(w http.ResponseWriter, r *http.Request) {
// Validate http connect parameters.
if r.Method != http.MethodConnect {
trace.WriteError(w, trace.BadParameter("%v not supported", r.Method))
return
}
if r.Host == "" {
trace.WriteError(w, trace.BadParameter("host not set"))
return
... | go | func (p *proxyServer) ServeHTTP(w http.ResponseWriter, r *http.Request) {
// Validate http connect parameters.
if r.Method != http.MethodConnect {
trace.WriteError(w, trace.BadParameter("%v not supported", r.Method))
return
}
if r.Host == "" {
trace.WriteError(w, trace.BadParameter("host not set"))
return
... | [
"func",
"(",
"p",
"*",
"proxyServer",
")",
"ServeHTTP",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"{",
"// Validate http connect parameters.",
"if",
"r",
".",
"Method",
"!=",
"http",
".",
"MethodConnect",
"{",
"tr... | // ServeHTTP only accepts the CONNECT verb and will tunnel your connection to
// the specified host. Also tracks the number of connections that it proxies for
// debugging purposes. | [
"ServeHTTP",
"only",
"accepts",
"the",
"CONNECT",
"verb",
"and",
"will",
"tunnel",
"your",
"connection",
"to",
"the",
"specified",
"host",
".",
"Also",
"tracks",
"the",
"number",
"of",
"connections",
"that",
"it",
"proxies",
"for",
"debugging",
"purposes",
"."... | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/integration/helpers.go#L1093-L1149 |
23,395 | gravitational/teleport | integration/helpers.go | Count | func (p *proxyServer) Count() int {
p.Lock()
defer p.Unlock()
return p.count
} | go | func (p *proxyServer) Count() int {
p.Lock()
defer p.Unlock()
return p.count
} | [
"func",
"(",
"p",
"*",
"proxyServer",
")",
"Count",
"(",
")",
"int",
"{",
"p",
".",
"Lock",
"(",
")",
"\n",
"defer",
"p",
".",
"Unlock",
"(",
")",
"\n",
"return",
"p",
".",
"count",
"\n",
"}"
] | // Count returns the number of connections that have been proxied. | [
"Count",
"returns",
"the",
"number",
"of",
"connections",
"that",
"have",
"been",
"proxied",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/integration/helpers.go#L1152-L1156 |
23,396 | gravitational/teleport | integration/helpers.go | createAgent | func createAgent(me *user.User, privateKeyByte []byte, certificateBytes []byte) (*teleagent.AgentServer, string, string, error) {
// create a path to the unix socket
sockDir, err := ioutil.TempDir("", "int-test")
if err != nil {
return nil, "", "", trace.Wrap(err)
}
sockPath := filepath.Join(sockDir, "agent.sock... | go | func createAgent(me *user.User, privateKeyByte []byte, certificateBytes []byte) (*teleagent.AgentServer, string, string, error) {
// create a path to the unix socket
sockDir, err := ioutil.TempDir("", "int-test")
if err != nil {
return nil, "", "", trace.Wrap(err)
}
sockPath := filepath.Join(sockDir, "agent.sock... | [
"func",
"createAgent",
"(",
"me",
"*",
"user",
".",
"User",
",",
"privateKeyByte",
"[",
"]",
"byte",
",",
"certificateBytes",
"[",
"]",
"byte",
")",
"(",
"*",
"teleagent",
".",
"AgentServer",
",",
"string",
",",
"string",
",",
"error",
")",
"{",
"// cr... | // createAgent creates a SSH agent with the passed in private key and
// certificate that can be used in tests. This is useful so tests don't
// clobber your system agent. | [
"createAgent",
"creates",
"a",
"SSH",
"agent",
"with",
"the",
"passed",
"in",
"private",
"key",
"and",
"certificate",
"that",
"can",
"be",
"used",
"in",
"tests",
".",
"This",
"is",
"useful",
"so",
"tests",
"don",
"t",
"clobber",
"your",
"system",
"agent",
... | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/integration/helpers.go#L1307-L1353 |
23,397 | gravitational/teleport | lib/auth/native/native.go | SetClock | func SetClock(clock clockwork.Clock) KeygenOption {
return func(k *Keygen) error {
k.clock = clock
return nil
}
} | go | func SetClock(clock clockwork.Clock) KeygenOption {
return func(k *Keygen) error {
k.clock = clock
return nil
}
} | [
"func",
"SetClock",
"(",
"clock",
"clockwork",
".",
"Clock",
")",
"KeygenOption",
"{",
"return",
"func",
"(",
"k",
"*",
"Keygen",
")",
"error",
"{",
"k",
".",
"clock",
"=",
"clock",
"\n",
"return",
"nil",
"\n",
"}",
"\n",
"}"
] | // SetClock sets the clock to use for key generation. | [
"SetClock",
"sets",
"the",
"clock",
"to",
"use",
"for",
"key",
"generation",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/native/native.go#L70-L75 |
23,398 | gravitational/teleport | lib/auth/native/native.go | PrecomputeKeys | func PrecomputeKeys(count int) KeygenOption {
return func(k *Keygen) error {
k.precomputeCount = count
return nil
}
} | go | func PrecomputeKeys(count int) KeygenOption {
return func(k *Keygen) error {
k.precomputeCount = count
return nil
}
} | [
"func",
"PrecomputeKeys",
"(",
"count",
"int",
")",
"KeygenOption",
"{",
"return",
"func",
"(",
"k",
"*",
"Keygen",
")",
"error",
"{",
"k",
".",
"precomputeCount",
"=",
"count",
"\n",
"return",
"nil",
"\n",
"}",
"\n",
"}"
] | // PrecomputeKeys sets up a number of private keys to pre-compute
// in background, 0 disables the process | [
"PrecomputeKeys",
"sets",
"up",
"a",
"number",
"of",
"private",
"keys",
"to",
"pre",
"-",
"compute",
"in",
"background",
"0",
"disables",
"the",
"process"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/native/native.go#L79-L84 |
23,399 | gravitational/teleport | lib/auth/native/native.go | New | func New(ctx context.Context, opts ...KeygenOption) (*Keygen, error) {
ctx, cancel := context.WithCancel(ctx)
k := &Keygen{
ctx: ctx,
cancel: cancel,
precomputeCount: PrecomputedNum,
clock: clockwork.NewRealClock(),
}
for _, opt := range opts {
if err := opt(k); err != nil {... | go | func New(ctx context.Context, opts ...KeygenOption) (*Keygen, error) {
ctx, cancel := context.WithCancel(ctx)
k := &Keygen{
ctx: ctx,
cancel: cancel,
precomputeCount: PrecomputedNum,
clock: clockwork.NewRealClock(),
}
for _, opt := range opts {
if err := opt(k); err != nil {... | [
"func",
"New",
"(",
"ctx",
"context",
".",
"Context",
",",
"opts",
"...",
"KeygenOption",
")",
"(",
"*",
"Keygen",
",",
"error",
")",
"{",
"ctx",
",",
"cancel",
":=",
"context",
".",
"WithCancel",
"(",
"ctx",
")",
"\n",
"k",
":=",
"&",
"Keygen",
"{... | // New returns a new key generator. | [
"New",
"returns",
"a",
"new",
"key",
"generator",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/native/native.go#L87-L110 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.