repo stringlengths 5 67 | sha stringlengths 40 40 | path stringlengths 4 234 | url stringlengths 85 339 | language stringclasses 6
values | split stringclasses 3
values | doc stringlengths 3 51.2k | sign stringlengths 5 8.01k | problem stringlengths 13 51.2k | output stringlengths 0 3.87M |
|---|---|---|---|---|---|---|---|---|---|
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/client/api.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/api.go#L289-L291 | go | train | // IsExpired returns true if profile is not expired yet | func (p *ProfileStatus) IsExpired(clock clockwork.Clock) bool | // IsExpired returns true if profile is not expired yet
func (p *ProfileStatus) IsExpired(clock clockwork.Clock) bool | {
return p.ValidUntil.Sub(clock.Now()) <= 0
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/client/api.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/api.go#L295-L327 | go | train | // RetryWithRelogin is a helper error handling method,
// attempts to relogin and retry the function once | func RetryWithRelogin(ctx context.Context, tc *TeleportClient, fn func() error) error | // RetryWithRelogin is a helper error handling method,
// attempts to relogin and retry the function once
func RetryWithRelogin(ctx context.Context, tc *TeleportClient, fn func() error) error | {
err := fn()
if err == nil {
return nil
}
// Assume that failed handshake is a result of expired credentials,
// retry the login procedure
if !utils.IsHandshakeFailedError(err) && !utils.IsCertExpiredError(err) && !trace.IsBadParameter(err) && trace.IsTrustError(err) {
return err
}
key, err := tc.Login(ct... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/client/api.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/api.go#L332-L397 | go | train | // readProfile reads in the profile as well as the associated certificate
// and returns a *ProfileStatus which can be used to print the status of the
// profile. | func readProfile(profileDir string, profileName string) (*ProfileStatus, error) | // readProfile reads in the profile as well as the associated certificate
// and returns a *ProfileStatus which can be used to print the status of the
// profile.
func readProfile(profileDir string, profileName string) (*ProfileStatus, error) | {
var err error
// Read in the profile for this proxy.
profile, err := ProfileFromFile(filepath.Join(profileDir, profileName))
if err != nil {
return nil, trace.Wrap(err)
}
// Read in the SSH certificate for the user logged into this proxy.
store, err := NewFSLocalKeyStore(profileDir)
if err != nil {
ret... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/client/api.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/api.go#L401-L423 | go | train | // fullProfileName takes a profile directory and the host the user is trying
// to connect to and returns the name of the profile file. | func fullProfileName(profileDir string, proxyHost string) (string, error) | // fullProfileName takes a profile directory and the host the user is trying
// to connect to and returns the name of the profile file.
func fullProfileName(profileDir string, proxyHost string) (string, error) | {
var err error
var profileName string
// If no profile name was passed in, try and extract the active profile from
// the ~/.tsh/profile symlink. If one was passed in, append .yaml to name.
if proxyHost == "" {
profileName, err = os.Readlink(filepath.Join(profileDir, "profile"))
if err != nil {
return ""... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/client/api.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/api.go#L426-L506 | go | train | // Status returns the active profile as well as a list of available profiles. | func Status(profileDir string, proxyHost string) (*ProfileStatus, []*ProfileStatus, error) | // Status returns the active profile as well as a list of available profiles.
func Status(profileDir string, proxyHost string) (*ProfileStatus, []*ProfileStatus, error) | {
var err error
var profile *ProfileStatus
var others []*ProfileStatus
// remove ports from proxy host, because profile name is stored
// by host name
if proxyHost != "" {
proxyHost, err = utils.Host(proxyHost)
if err != nil {
return nil, nil, trace.Wrap(err)
}
}
// Construct the full path to the pr... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/client/api.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/api.go#L511-L562 | go | train | // LoadProfile populates Config with the values stored in the given
// profiles directory. If profileDir is an empty string, the default profile
// directory ~/.tsh is used. | func (c *Config) LoadProfile(profileDir string, proxyName string) error | // LoadProfile populates Config with the values stored in the given
// profiles directory. If profileDir is an empty string, the default profile
// directory ~/.tsh is used.
func (c *Config) LoadProfile(profileDir string, proxyName string) error | {
profileDir = FullProfilePath(profileDir)
// read the profile:
cp, err := ProfileFromDir(profileDir, ProxyHost(proxyName))
if err != nil {
if trace.IsNotFound(err) {
return nil
}
return trace.Wrap(err)
}
// DELETE IN: 3.1.0
// The "proxy_host" field (and associated ports) have been deprecated and
//... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/client/api.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/api.go#L566-L607 | go | train | // SaveProfile updates the given profiles directory with the current configuration
// If profileDir is an empty string, the default ~/.tsh is used | func (c *Config) SaveProfile(profileAliasHost, profileDir string, profileOptions ...ProfileOptions) error | // SaveProfile updates the given profiles directory with the current configuration
// If profileDir is an empty string, the default ~/.tsh is used
func (c *Config) SaveProfile(profileAliasHost, profileDir string, profileOptions ...ProfileOptions) error | {
if c.WebProxyAddr == "" {
return nil
}
// The profile is saved to a directory with the name of the proxy web endpoint.
webProxyHost, _ := c.WebProxyHostPort()
profileDir = FullProfilePath(profileDir)
profilePath := path.Join(profileDir, webProxyHost) + ".yaml"
profileAliasPath := ""
if profileAliasHost !... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/client/api.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/api.go#L613-L653 | go | train | // ParseProxyHost parses the proxyHost string and updates the config.
//
// Format of proxyHost string:
// proxy_web_addr:<proxy_web_port>,<proxy_ssh_port> | func (c *Config) ParseProxyHost(proxyHost string) error | // ParseProxyHost parses the proxyHost string and updates the config.
//
// Format of proxyHost string:
// proxy_web_addr:<proxy_web_port>,<proxy_ssh_port>
func (c *Config) ParseProxyHost(proxyHost string) error | {
host, port, err := net.SplitHostPort(proxyHost)
if err != nil {
host = proxyHost
port = ""
}
// Split on comma.
parts := strings.Split(port, ",")
switch {
// Default ports for both the SSH and Web proxy.
case len(parts) == 0:
c.WebProxyAddr = net.JoinHostPort(host, strconv.Itoa(defaults.HTTPListenPor... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/client/api.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/api.go#L656-L666 | go | train | // KubeProxyHostPort returns the host and port of the Kubernetes proxy. | func (c *Config) KubeProxyHostPort() (string, int) | // KubeProxyHostPort returns the host and port of the Kubernetes proxy.
func (c *Config) KubeProxyHostPort() (string, int) | {
if c.KubeProxyAddr != "" {
addr, err := utils.ParseAddr(c.KubeProxyAddr)
if err == nil {
return addr.Host(), addr.Port(defaults.KubeProxyListenPort)
}
}
webProxyHost, _ := c.WebProxyHostPort()
return webProxyHost, defaults.KubeProxyListenPort
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/client/api.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/api.go#L669-L679 | go | train | // WebProxyHostPort returns the host and port of the web proxy. | func (c *Config) WebProxyHostPort() (string, int) | // WebProxyHostPort returns the host and port of the web proxy.
func (c *Config) WebProxyHostPort() (string, int) | {
if c.WebProxyAddr != "" {
addr, err := utils.ParseAddr(c.WebProxyAddr)
if err == nil {
return addr.Host(), addr.Port(defaults.HTTPListenPort)
}
}
webProxyHost, _ := c.WebProxyHostPort()
return webProxyHost, defaults.HTTPListenPort
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/client/api.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/api.go#L682-L692 | go | train | // SSHProxyHostPort returns the host and port of the SSH proxy. | func (c *Config) SSHProxyHostPort() (string, int) | // SSHProxyHostPort returns the host and port of the SSH proxy.
func (c *Config) SSHProxyHostPort() (string, int) | {
if c.SSHProxyAddr != "" {
addr, err := utils.ParseAddr(c.SSHProxyAddr)
if err == nil {
return addr.Host(), addr.Port(defaults.SSHProxyListenPort)
}
}
webProxyHost, _ := c.WebProxyHostPort()
return webProxyHost, defaults.SSHProxyListenPort
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/client/api.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/api.go#L695-L701 | go | train | // ProxyHost returns the hostname of the proxy server (without any port numbers) | func ProxyHost(proxyHost string) string | // ProxyHost returns the hostname of the proxy server (without any port numbers)
func ProxyHost(proxyHost string) string | {
host, _, err := net.SplitHostPort(proxyHost)
if err != nil {
return proxyHost
}
return host
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/client/api.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/api.go#L735-L810 | go | train | // NewClient creates a TeleportClient object and fully configures it | func NewClient(c *Config) (tc *TeleportClient, err error) | // NewClient creates a TeleportClient object and fully configures it
func NewClient(c *Config) (tc *TeleportClient, err error) | {
// validate configuration
if c.Username == "" {
c.Username, err = Username()
if err != nil {
return nil, trace.Wrap(err)
}
log.Infof("No teleport login given. defaulting to %s", c.Username)
}
if c.WebProxyAddr == "" {
return nil, trace.BadParameter("No proxy address specified, missed --proxy flag?")... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/client/api.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/api.go#L813-L822 | go | train | // accessPoint returns access point based on the cache policy | func (tc *TeleportClient) accessPoint(clt auth.AccessPoint, proxyHostPort string, clusterName string) (auth.AccessPoint, error) | // accessPoint returns access point based on the cache policy
func (tc *TeleportClient) accessPoint(clt auth.AccessPoint, proxyHostPort string, clusterName string) (auth.AccessPoint, error) | {
// If no caching policy was set or on Windows (where Teleport does not
// support file locking at the moment), return direct access to the access
// point.
if tc.CachePolicy == nil || runtime.GOOS == teleport.WindowsOS {
log.Debugf("not using caching access point")
return clt, nil
}
return clt, nil
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/client/api.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/api.go#L830-L849 | go | train | // getTargetNodes returns a list of node addresses this SSH command needs to
// operate on. | func (tc *TeleportClient) getTargetNodes(ctx context.Context, proxy *ProxyClient) ([]string, error) | // getTargetNodes returns a list of node addresses this SSH command needs to
// operate on.
func (tc *TeleportClient) getTargetNodes(ctx context.Context, proxy *ProxyClient) ([]string, error) | {
var (
err error
nodes []services.Server
retval = make([]string, 0)
)
if tc.Labels != nil && len(tc.Labels) > 0 {
nodes, err = proxy.FindServersByLabels(ctx, tc.Namespace, tc.Labels)
if err != nil {
return nil, trace.Wrap(err)
}
for i := 0; i < len(nodes); i++ {
retval = append(retval, node... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/client/api.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/api.go#L855-L910 | go | train | // SSH connects to a node and, if 'command' is specified, executes the command on it,
// otherwise runs interactive shell
//
// Returns nil if successful, or (possibly) *exec.ExitError | func (tc *TeleportClient) SSH(ctx context.Context, command []string, runLocally bool) error | // SSH connects to a node and, if 'command' is specified, executes the command on it,
// otherwise runs interactive shell
//
// Returns nil if successful, or (possibly) *exec.ExitError
func (tc *TeleportClient) SSH(ctx context.Context, command []string, runLocally bool) error | {
// connect to proxy first:
if !tc.Config.ProxySpecified() {
return trace.BadParameter("proxy server is not specified")
}
proxyClient, err := tc.ConnectToProxy(ctx)
if err != nil {
return trace.Wrap(err)
}
defer proxyClient.Close()
siteInfo, err := proxyClient.currentCluster()
if err != nil {
return tr... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/client/api.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/api.go#L939-L1016 | go | train | // Join connects to the existing/active SSH session | func (tc *TeleportClient) Join(ctx context.Context, namespace string, sessionID session.ID, input io.Reader) (err error) | // Join connects to the existing/active SSH session
func (tc *TeleportClient) Join(ctx context.Context, namespace string, sessionID session.ID, input io.Reader) (err error) | {
if namespace == "" {
return trace.BadParameter(auth.MissingNamespaceError)
}
tc.Stdin = input
if sessionID.Check() != nil {
return trace.Errorf("Invalid session ID format: %s", string(sessionID))
}
var notFoundErrorMessage = fmt.Sprintf("session '%s' not found or it has ended", sessionID)
// connect to p... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/client/api.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/api.go#L1019-L1108 | go | train | // Play replays the recorded session | func (tc *TeleportClient) Play(ctx context.Context, namespace, sessionId string) (err error) | // Play replays the recorded session
func (tc *TeleportClient) Play(ctx context.Context, namespace, sessionId string) (err error) | {
if namespace == "" {
return trace.BadParameter(auth.MissingNamespaceError)
}
sid, err := session.ParseID(sessionId)
if err != nil {
return fmt.Errorf("'%v' is not a valid session ID (must be GUID)", sid)
}
// connect to the auth server (site) who made the recording
proxyClient, err := tc.ConnectToProxy(ct... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/client/api.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/api.go#L1112-L1160 | go | train | // ExecuteSCP executes SCP command. It executes scp.Command using
// lower-level API integrations that mimic SCP CLI command behavior | func (tc *TeleportClient) ExecuteSCP(ctx context.Context, cmd scp.Command) (err error) | // ExecuteSCP executes SCP command. It executes scp.Command using
// lower-level API integrations that mimic SCP CLI command behavior
func (tc *TeleportClient) ExecuteSCP(ctx context.Context, cmd scp.Command) (err error) | {
// connect to proxy first:
if !tc.Config.ProxySpecified() {
return trace.BadParameter("proxy server is not specified")
}
proxyClient, err := tc.ConnectToProxy(ctx)
if err != nil {
return trace.Wrap(err)
}
defer proxyClient.Close()
clusterInfo, err := proxyClient.currentCluster()
if err != nil {
retu... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/client/api.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/api.go#L1163-L1288 | go | train | // SCP securely copies file(s) from one SSH server to another | func (tc *TeleportClient) SCP(ctx context.Context, args []string, port int, recursive bool, quiet bool) (err error) | // SCP securely copies file(s) from one SSH server to another
func (tc *TeleportClient) SCP(ctx context.Context, args []string, port int, recursive bool, quiet bool) (err error) | {
if len(args) < 2 {
return trace.Errorf("Need at least two arguments for scp")
}
first := args[0]
last := args[len(args)-1]
// local copy?
if !isRemoteDest(first) && !isRemoteDest(last) {
return trace.BadParameter("making local copies is not supported")
}
if !tc.Config.ProxySpecified() {
return trace.... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/client/api.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/api.go#L1295-L1313 | go | train | // ListNodes returns a list of nodes connected to a proxy | func (tc *TeleportClient) ListNodes(ctx context.Context) ([]services.Server, error) | // ListNodes returns a list of nodes connected to a proxy
func (tc *TeleportClient) ListNodes(ctx context.Context) ([]services.Server, error) | {
var err error
// userhost is specified? that must be labels
if tc.Host != "" {
tc.Labels, err = ParseLabelSpec(tc.Host)
if err != nil {
return nil, trace.Wrap(err)
}
}
// connect to the proxy and ask it to return a full list of servers
proxyClient, err := tc.ConnectToProxy(ctx)
if err != nil {
ret... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/client/api.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/api.go#L1316-L1370 | go | train | // runCommand executes a given bash command on a bunch of remote nodes | func (tc *TeleportClient) runCommand(
ctx context.Context, siteName string, nodeAddresses []string, proxyClient *ProxyClient, command []string) error | // runCommand executes a given bash command on a bunch of remote nodes
func (tc *TeleportClient) runCommand(
ctx context.Context, siteName string, nodeAddresses []string, proxyClient *ProxyClient, command []string) error | {
resultsC := make(chan error, len(nodeAddresses))
for _, address := range nodeAddresses {
go func(address string) {
var (
err error
nodeSession *NodeSession
)
defer func() {
resultsC <- err
}()
var nodeClient *NodeClient
nodeClient, err = proxyClient.ConnectToNode(ctx, addre... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/client/api.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/api.go#L1374-L1388 | go | train | // runShell starts an interactive SSH session/shell.
// sessionID : when empty, creates a new shell. otherwise it tries to join the existing session. | func (tc *TeleportClient) runShell(nodeClient *NodeClient, sessToJoin *session.Session) error | // runShell starts an interactive SSH session/shell.
// sessionID : when empty, creates a new shell. otherwise it tries to join the existing session.
func (tc *TeleportClient) runShell(nodeClient *NodeClient, sessToJoin *session.Session) error | {
nodeSession, err := newSession(nodeClient, sessToJoin, tc.Env, tc.Stdin, tc.Stdout, tc.Stderr)
if err != nil {
return trace.Wrap(err)
}
if err = nodeSession.runShell(tc.OnShellCreated); err != nil {
return trace.Wrap(err)
}
if nodeSession.ExitMsg == "" {
fmt.Fprintln(tc.Stderr, "the connection was closed... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/client/api.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/api.go#L1391-L1408 | go | train | // getProxyLogin determines which SSH principal to use when connecting to proxy. | func (tc *TeleportClient) getProxySSHPrincipal() string | // getProxyLogin determines which SSH principal to use when connecting to proxy.
func (tc *TeleportClient) getProxySSHPrincipal() string | {
proxyPrincipal := tc.Config.HostLogin
if tc.DefaultPrincipal != "" {
proxyPrincipal = tc.DefaultPrincipal
}
// see if we already have a signed key in the cache, we'll use that instead
if !tc.Config.SkipLocalAuth && tc.LocalAgent() != nil {
signers, err := tc.LocalAgent().Signers()
if err != nil || len(sig... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/client/api.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/api.go#L1412-L1418 | go | train | // authMethods returns a list (slice) of all SSH auth methods this client
// can use to try to authenticate | func (tc *TeleportClient) authMethods() []ssh.AuthMethod | // authMethods returns a list (slice) of all SSH auth methods this client
// can use to try to authenticate
func (tc *TeleportClient) authMethods() []ssh.AuthMethod | {
m := append([]ssh.AuthMethod(nil), tc.Config.AuthMethods...)
if tc.LocalAgent() != nil {
m = append(m, tc.LocalAgent().AuthMethods()...)
}
return m
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/client/api.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/api.go#L1423-L1444 | go | train | // ConnectToProxy will dial to the proxy server and return a ProxyClient when
// successful. If the passed in context is canceled, this function will return
// a trace.ConnectionProblem right away. | func (tc *TeleportClient) ConnectToProxy(ctx context.Context) (*ProxyClient, error) | // ConnectToProxy will dial to the proxy server and return a ProxyClient when
// successful. If the passed in context is canceled, this function will return
// a trace.ConnectionProblem right away.
func (tc *TeleportClient) ConnectToProxy(ctx context.Context) (*ProxyClient, error) | {
var err error
var proxyClient *ProxyClient
// Use connectContext and the cancel function to signal when a response is
// returned from connectToProxy.
connectContext, cancel := context.WithCancel(context.Background())
go func() {
defer cancel()
proxyClient, err = tc.connectToProxy(ctx)
}()
select {
//... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/client/api.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/api.go#L1448-L1491 | go | train | // connectToProxy will dial to the proxy server and return a ProxyClient when
// successful. | func (tc *TeleportClient) connectToProxy(ctx context.Context) (*ProxyClient, error) | // connectToProxy will dial to the proxy server and return a ProxyClient when
// successful.
func (tc *TeleportClient) connectToProxy(ctx context.Context) (*ProxyClient, error) | {
var err error
proxyPrincipal := tc.getProxySSHPrincipal()
sshConfig := &ssh.ClientConfig{
User: proxyPrincipal,
HostKeyCallback: tc.HostKeyCallback,
}
// helper to create a ProxyClient struct
makeProxyClient := func(sshClient *ssh.Client, m ssh.AuthMethod) *ProxyClient {
return &ProxyClient{... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/client/api.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/api.go#L1495-L1502 | go | train | // Logout removes certificate and key for the currently logged in user from
// the filesystem and agent. | func (tc *TeleportClient) Logout() error | // Logout removes certificate and key for the currently logged in user from
// the filesystem and agent.
func (tc *TeleportClient) Logout() error | {
err := tc.localAgent.DeleteKey()
if err != nil {
return trace.Wrap(err)
}
return nil
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/client/api.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/api.go#L1506-L1512 | go | train | // LogoutAll removes all certificates for all users from the filesystem
// and agent. | func (tc *TeleportClient) LogoutAll() error | // LogoutAll removes all certificates for all users from the filesystem
// and agent.
func (tc *TeleportClient) LogoutAll() error | {
err := tc.localAgent.DeleteKeys()
if err != nil {
return trace.Wrap(err)
}
return nil
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/client/api.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/api.go#L1519-L1627 | go | train | // Login logs the user into a Teleport cluster by talking to a Teleport proxy.
//
// If 'activateKey' is true, saves the received session cert into the local
// keystore (and into the ssh-agent) for future use.
// | func (tc *TeleportClient) Login(ctx context.Context, activateKey bool) (*Key, error) | // Login logs the user into a Teleport cluster by talking to a Teleport proxy.
//
// If 'activateKey' is true, saves the received session cert into the local
// keystore (and into the ssh-agent) for future use.
//
func (tc *TeleportClient) Login(ctx context.Context, activateKey bool) (*Key, error) | {
// Ping the endpoint to see if it's up and find the type of authentication
// supported.
pr, err := tc.credClient.Ping(ctx, tc.AuthConnector)
if err != nil {
return nil, trace.Wrap(err)
}
// If version checking was requested and the server advertises a minimum version.
if tc.CheckVersions && pr.MinClientVe... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/client/api.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/api.go#L1631-L1650 | go | train | // GetTrustedCA returns a list of host certificate authorities
// trusted by the cluster client is authenticated with. | func (tc *TeleportClient) GetTrustedCA(ctx context.Context, clusterName string) ([]services.CertAuthority, error) | // GetTrustedCA returns a list of host certificate authorities
// trusted by the cluster client is authenticated with.
func (tc *TeleportClient) GetTrustedCA(ctx context.Context, clusterName string) ([]services.CertAuthority, error) | {
// Connect to the proxy.
if !tc.Config.ProxySpecified() {
return nil, trace.BadParameter("proxy server is not specified")
}
proxyClient, err := tc.ConnectToProxy(ctx)
if err != nil {
return nil, trace.Wrap(err)
}
defer proxyClient.Close()
// Get a client to the Auth Server.
clt, err := proxyClient.Clus... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/client/api.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/api.go#L1654-L1676 | go | train | // UpdateTrustedCA connects to the Auth Server and fetches all host certificates
// and updates ~/.tsh/keys/proxy/certs.pem and ~/.tsh/known_hosts. | func (tc *TeleportClient) UpdateTrustedCA(ctx context.Context, clusterName string) error | // UpdateTrustedCA connects to the Auth Server and fetches all host certificates
// and updates ~/.tsh/keys/proxy/certs.pem and ~/.tsh/known_hosts.
func (tc *TeleportClient) UpdateTrustedCA(ctx context.Context, clusterName string) error | {
// Get the list of host certificates that this cluster knows about.
hostCerts, err := tc.GetTrustedCA(ctx, clusterName)
if err != nil {
return trace.Wrap(err)
}
trustedCerts := auth.AuthoritiesToTrustedCerts(hostCerts)
// Update the ~/.tsh/known_hosts file to include all the CA the cluster
// knows about.
... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/client/api.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/api.go#L1681-L1738 | go | train | // applyProxySettings updates configuration changes based on the advertised
// proxy settings, user supplied values take precedence - will be preserved
// if set | func (tc *TeleportClient) applyProxySettings(proxySettings ProxySettings) error | // applyProxySettings updates configuration changes based on the advertised
// proxy settings, user supplied values take precedence - will be preserved
// if set
func (tc *TeleportClient) applyProxySettings(proxySettings ProxySettings) error | {
// Kubernetes proxy settings.
if proxySettings.Kube.Enabled && proxySettings.Kube.PublicAddr != "" && tc.KubeProxyAddr == "" {
_, err := utils.ParseAddr(proxySettings.Kube.PublicAddr)
if err != nil {
return trace.BadParameter(
"failed to parse value received from the server: %q, contact your administrat... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/client/api.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/api.go#L1763-L1779 | go | train | // Adds a new CA as trusted CA for this client, used in tests | func (tc *TeleportClient) AddTrustedCA(ca services.CertAuthority) error | // Adds a new CA as trusted CA for this client, used in tests
func (tc *TeleportClient) AddTrustedCA(ca services.CertAuthority) error | {
err := tc.LocalAgent().AddHostSignersToCache(auth.AuthoritiesToTrustedCerts([]services.CertAuthority{ca}))
if err != nil {
return trace.Wrap(err)
}
// only host CA has TLS certificates, user CA will overwrite trusted certs
// to empty file if called
if ca.GetType() == services.HostCA {
err = tc.LocalAgent... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/client/api.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/api.go#L1786-L1816 | go | train | // directLogin asks for a password + HOTP token, makes a request to CA via proxy | func (tc *TeleportClient) directLogin(ctx context.Context, secondFactorType string, pub []byte) (*auth.SSHLoginResponse, error) | // directLogin asks for a password + HOTP token, makes a request to CA via proxy
func (tc *TeleportClient) directLogin(ctx context.Context, secondFactorType string, pub []byte) (*auth.SSHLoginResponse, error) | {
var err error
var password string
var otpToken string
password, err = tc.AskPassword()
if err != nil {
return nil, trace.Wrap(err)
}
// only ask for a second factor if it's enabled
if secondFactorType != teleport.OFF {
otpToken, err = tc.AskOTP()
if err != nil {
return nil, trace.Wrap(err)
}
}... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/client/api.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/api.go#L1819-L1832 | go | train | // samlLogin opens browser window and uses OIDC or SAML redirect cycle with browser | func (tc *TeleportClient) ssoLogin(ctx context.Context, connectorID string, pub []byte, protocol string) (*auth.SSHLoginResponse, error) | // samlLogin opens browser window and uses OIDC or SAML redirect cycle with browser
func (tc *TeleportClient) ssoLogin(ctx context.Context, connectorID string, pub []byte, protocol string) (*auth.SSHLoginResponse, error) | {
log.Debugf("samlLogin start")
// ask the CA (via proxy) to sign our public key:
response, err := tc.credClient.SSHAgentSSOLogin(SSHLogin{
Context: ctx,
ConnectorID: connectorID,
PubKey: pub,
TTL: tc.KeyTTL,
Protocol: protocol,
Compatibility: tc.CertificateFormat,
BindAd... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/client/api.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/api.go#L1835-L1856 | go | train | // directLogin asks for a password and performs the challenge-response authentication | func (tc *TeleportClient) u2fLogin(ctx context.Context, pub []byte) (*auth.SSHLoginResponse, error) | // directLogin asks for a password and performs the challenge-response authentication
func (tc *TeleportClient) u2fLogin(ctx context.Context, pub []byte) (*auth.SSHLoginResponse, error) | {
// U2F login requires the official u2f-host executable
_, err := exec.LookPath("u2f-host")
if err != nil {
return nil, trace.Wrap(err)
}
password, err := tc.AskPassword()
if err != nil {
return nil, trace.Wrap(err)
}
response, err := tc.credClient.SSHAgentU2FLogin(
ctx,
tc.Config.Username,
passwo... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/client/api.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/api.go#L1859-L1868 | go | train | // SendEvent adds a events.EventFields to the channel. | func (tc *TeleportClient) SendEvent(ctx context.Context, e events.EventFields) error | // SendEvent adds a events.EventFields to the channel.
func (tc *TeleportClient) SendEvent(ctx context.Context, e events.EventFields) error | {
// Try and send the event to the eventsCh. If blocking, keep blocking until
// the passed in context in canceled.
select {
case tc.eventsCh <- e:
return nil
case <-ctx.Done():
return trace.Wrap(ctx.Err())
}
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/client/api.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/api.go#L1878-L1908 | go | train | // loopbackPool reads trusted CAs if it finds it in a predefined location
// and will work only if target proxy address is loopback | func loopbackPool(proxyAddr string) *x509.CertPool | // loopbackPool reads trusted CAs if it finds it in a predefined location
// and will work only if target proxy address is loopback
func loopbackPool(proxyAddr string) *x509.CertPool | {
if !utils.IsLoopback(proxyAddr) {
log.Debugf("not using loopback pool for remote proxy addr: %v", proxyAddr)
return nil
}
log.Debugf("attempting to use loopback pool for local proxy addr: %v", proxyAddr)
certPool := x509.NewCertPool()
certPath := filepath.Join(defaults.DataDir, defaults.SelfSignedCertPath)... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/client/api.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/api.go#L1911-L1921 | go | train | // connectToSSHAgent connects to the local SSH agent and returns a agent.Agent. | func connectToSSHAgent() agent.Agent | // connectToSSHAgent connects to the local SSH agent and returns a agent.Agent.
func connectToSSHAgent() agent.Agent | {
socketPath := os.Getenv(teleport.SSHAuthSock)
conn, err := agentconn.Dial(socketPath)
if err != nil {
log.Errorf("[KEY AGENT] Unable to connect to SSH agent on socket: %q.", socketPath)
return nil
}
log.Infof("[KEY AGENT] Connected to the system agent: %q", socketPath)
return agent.NewClient(conn)
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/client/api.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/api.go#L1924-L1930 | go | train | // Username returns the current user's username | func Username() (string, error) | // Username returns the current user's username
func Username() (string, error) | {
u, err := user.Current()
if err != nil {
return "", trace.Wrap(err)
}
return u.Username, nil
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/client/api.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/api.go#L1933-L1941 | go | train | // AskOTP prompts the user to enter the OTP token. | func (tc *TeleportClient) AskOTP() (token string, err error) | // AskOTP prompts the user to enter the OTP token.
func (tc *TeleportClient) AskOTP() (token string, err error) | {
fmt.Printf("Enter your OTP token:\n")
token, err = lineFromConsole()
if err != nil {
fmt.Fprintln(tc.Stderr, err)
return "", trace.Wrap(err)
}
return token, nil
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/client/api.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/api.go#L1944-L1953 | go | train | // AskPassword prompts the user to enter the password | func (tc *TeleportClient) AskPassword() (pwd string, err error) | // AskPassword prompts the user to enter the password
func (tc *TeleportClient) AskPassword() (pwd string, err error) | {
fmt.Printf("Enter password for Teleport user %v:\n", tc.Config.Username)
pwd, err = passwordFromConsole()
if err != nil {
fmt.Fprintln(tc.Stderr, err)
return "", trace.Wrap(err)
}
return pwd, nil
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/client/api.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/api.go#L1956-L1982 | go | train | // passwordFromConsole reads from stdin without echoing typed characters to stdout | func passwordFromConsole() (string, error) | // passwordFromConsole reads from stdin without echoing typed characters to stdout
func passwordFromConsole() (string, error) | {
fd := syscall.Stdin
state, err := terminal.GetState(int(fd))
// intercept Ctr+C and restore terminal
sigCh := make(chan os.Signal, 1)
closeCh := make(chan int)
if err != nil {
log.Warnf("failed reading terminal state: %v", err)
} else {
signal.Notify(sigCh, syscall.SIGINT)
go func() {
select {
ca... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/client/api.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/api.go#L1985-L1988 | go | train | // lineFromConsole reads a line from stdin | func lineFromConsole() (string, error) | // lineFromConsole reads a line from stdin
func lineFromConsole() (string, error) | {
bytes, _, err := bufio.NewReader(os.Stdin).ReadLine()
return string(bytes), err
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/client/api.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/api.go#L1992-L2032 | go | train | // ParseLabelSpec parses a string like 'name=value,"long name"="quoted value"` into a map like
// { "name" -> "value", "long name" -> "quoted value" } | func ParseLabelSpec(spec string) (map[string]string, error) | // ParseLabelSpec parses a string like 'name=value,"long name"="quoted value"` into a map like
// { "name" -> "value", "long name" -> "quoted value" }
func ParseLabelSpec(spec string) (map[string]string, error) | {
tokens := []string{}
var openQuotes = false
var tokenStart, assignCount int
var specLen = len(spec)
// tokenize the label spec:
for i, ch := range spec {
endOfToken := false
// end of line?
if i+utf8.RuneLen(ch) == specLen {
i += utf8.RuneLen(ch)
endOfToken = true
}
switch ch {
case '"':
o... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/client/api.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/api.go#L2036-L2053 | go | train | // Executes the given command on the client machine (localhost). If no command is given,
// executes shell | func runLocalCommand(command []string) error | // Executes the given command on the client machine (localhost). If no command is given,
// executes shell
func runLocalCommand(command []string) error | {
if len(command) == 0 {
user, err := user.Current()
if err != nil {
return trace.Wrap(err)
}
shell, err := shell.GetLoginShell(user.Username)
if err != nil {
return trace.Wrap(err)
}
command = []string{shell}
}
cmd := exec.Command(command[0], command[1:]...)
cmd.Stderr = os.Stderr
cmd.Stdin =... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/client/api.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/api.go#L2065-L2093 | go | train | // ParsePortForwardSpec parses parameter to -L flag, i.e. strings like "[ip]:80:remote.host:3000"
// The opposite of this function (spec generation) is ForwardedPorts.String() | func ParsePortForwardSpec(spec []string) (ports ForwardedPorts, err error) | // ParsePortForwardSpec parses parameter to -L flag, i.e. strings like "[ip]:80:remote.host:3000"
// The opposite of this function (spec generation) is ForwardedPorts.String()
func ParsePortForwardSpec(spec []string) (ports ForwardedPorts, err error) | {
if len(spec) == 0 {
return ports, nil
}
const errTemplate = "Invalid port forwarding spec: '%s'. Could be like `80:remote.host:80`"
ports = make([]ForwardedPort, len(spec), len(spec))
for i, str := range spec {
parts := strings.Split(str, ":")
if len(parts) < 3 || len(parts) > 4 {
return nil, fmt.Erro... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/client/api.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/api.go#L2097-L2102 | go | train | // String returns the same string spec which can be parsed by
// ParseDynamicPortForwardSpec. | func (fp DynamicForwardedPorts) String() (retval []string) | // String returns the same string spec which can be parsed by
// ParseDynamicPortForwardSpec.
func (fp DynamicForwardedPorts) String() (retval []string) | {
for _, p := range fp {
retval = append(retval, p.ToString())
}
return retval
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/client/api.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/api.go#L2107-L2133 | go | train | // ParseDynamicPortForwardSpec parses the dynamic port forwarding spec
// passed in the -D flag. The format of the dynamic port forwarding spec
// is [bind_address:]port. | func ParseDynamicPortForwardSpec(spec []string) (DynamicForwardedPorts, error) | // ParseDynamicPortForwardSpec parses the dynamic port forwarding spec
// passed in the -D flag. The format of the dynamic port forwarding spec
// is [bind_address:]port.
func ParseDynamicPortForwardSpec(spec []string) (DynamicForwardedPorts, error) | {
result := make(DynamicForwardedPorts, 0, len(spec))
for _, str := range spec {
host, port, err := net.SplitHostPort(str)
if err != nil {
return nil, trace.Wrap(err)
}
// If no host is provided, bind to localhost.
if host == "" {
host = defaults.Localhost
}
srcPort, err := strconv.Atoi(port)
... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/client/api.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/api.go#L2137-L2139 | go | train | // InsecureSkipHostKeyChecking is used when the user passes in
// "StrictHostKeyChecking yes". | func InsecureSkipHostKeyChecking(host string, remote net.Addr, key ssh.PublicKey) error | // InsecureSkipHostKeyChecking is used when the user passes in
// "StrictHostKeyChecking yes".
func InsecureSkipHostKeyChecking(host string, remote net.Addr, key ssh.PublicKey) error | {
return nil
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/reversetunnel/conn.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/reversetunnel/conn.go#L149-L156 | go | train | // OpenChannel will open a SSH channel to the remote side. | func (c *remoteConn) OpenChannel(name string, data []byte) (ssh.Channel, error) | // OpenChannel will open a SSH channel to the remote side.
func (c *remoteConn) OpenChannel(name string, data []byte) (ssh.Channel, error) | {
channel, _, err := c.sconn.OpenChannel(name, data)
if err != nil {
return nil, trace.Wrap(err)
}
return channel, nil
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/reversetunnel/conn.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/reversetunnel/conn.go#L159-L161 | go | train | // ChannelConn creates a net.Conn over a SSH channel. | func (c *remoteConn) ChannelConn(channel ssh.Channel) net.Conn | // ChannelConn creates a net.Conn over a SSH channel.
func (c *remoteConn) ChannelConn(channel ssh.Channel) net.Conn | {
return utils.NewChConn(c.sconn, channel)
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/reversetunnel/conn.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/reversetunnel/conn.go#L232-L258 | go | train | // sendDiscovery requests sends special "Discovery Requests" back to the
// connected agent. Discovery request consists of the proxies that are part
// of the cluster, but did not receive the connection from the agent. Agent
// will act on a discovery request attempting to establish connection to the
// proxies that we... | func (c *remoteConn) findAndSend() error | // sendDiscovery requests sends special "Discovery Requests" back to the
// connected agent. Discovery request consists of the proxies that are part
// of the cluster, but did not receive the connection from the agent. Agent
// will act on a discovery request attempting to establish connection to the
// proxies that we... | {
// Find all proxies that don't have a connection to a remote agent. If all
// proxies have connections, return right away.
disconnectedProxies, err := c.findDisconnectedProxies()
if err != nil {
return trace.Wrap(err)
}
if len(disconnectedProxies) == 0 {
return nil
}
c.log.Debugf("Proxy %v sending %v di... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/reversetunnel/conn.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/reversetunnel/conn.go#L262-L295 | go | train | // findDisconnectedProxies finds proxies that do not have inbound reverse tunnel
// connections. | func (c *remoteConn) findDisconnectedProxies() ([]services.Server, error) | // findDisconnectedProxies finds proxies that do not have inbound reverse tunnel
// connections.
func (c *remoteConn) findDisconnectedProxies() ([]services.Server, error) | {
// Find all proxies that have connection from the remote domain.
conns, err := c.accessPoint.GetTunnelConnections(c.clusterName, services.SkipValidation())
if err != nil {
return nil, trace.Wrap(err)
}
connected := make(map[string]bool)
for _, conn := range conns {
if c.isOnline(conn) {
connected[conn.G... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/reversetunnel/conn.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/reversetunnel/conn.go#L298-L317 | go | train | // sendDiscoveryRequests sends a discovery request with missing proxies. | func (c *remoteConn) sendDiscoveryRequests(req discoveryRequest) error | // sendDiscoveryRequests sends a discovery request with missing proxies.
func (c *remoteConn) sendDiscoveryRequests(req discoveryRequest) error | {
discoveryCh, err := c.openDiscoveryChannel()
if err != nil {
return trace.Wrap(err)
}
// Marshal and send the request. If the connection failed, mark the
// connection as invalid so it will be removed later.
payload, err := marshalDiscoveryRequest(req)
if err != nil {
return trace.Wrap(err)
}
_, err = ... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/reversetunnel/conn.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/reversetunnel/conn.go#L341-L356 | go | train | // TunnelAuthDialer connects to the Auth Server through the reverse tunnel. | func TunnelAuthDialer(proxyAddr string, sshConfig *ssh.ClientConfig) auth.DialContext | // TunnelAuthDialer connects to the Auth Server through the reverse tunnel.
func TunnelAuthDialer(proxyAddr string, sshConfig *ssh.ClientConfig) auth.DialContext | {
return func(ctx context.Context, network string, addr string) (net.Conn, error) {
// Connect to the reverse tunnel server.
dialer := proxy.DialerFromEnvironment(proxyAddr)
sconn, err := dialer.Dial("tcp", proxyAddr, sshConfig)
if err != nil {
return nil, trace.Wrap(err)
}
conn, err := connectProxyTr... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/reversetunnel/conn.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/reversetunnel/conn.go#L360-L387 | go | train | // connectProxyTransport opens a channel over the remote tunnel and connects
// to the requested host. | func connectProxyTransport(sconn ssh.Conn, addr string) (net.Conn, error) | // connectProxyTransport opens a channel over the remote tunnel and connects
// to the requested host.
func connectProxyTransport(sconn ssh.Conn, addr string) (net.Conn, error) | {
channel, _, err := sconn.OpenChannel(chanTransport, nil)
if err != nil {
return nil, trace.Wrap(err)
}
// Send a special SSH out-of-band request called "teleport-transport"
// the agent on the other side will create a new TCP/IP connection to
// 'addr' on its network and will start proxying that connection ... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/reversetunnel/conn.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/reversetunnel/conn.go#L392-L528 | go | train | // proxyTransport runs either in the agent or reverse tunnel itself. It's
// used to establish connections from remote clusters into the main cluster
// or for remote nodes that have no direct network access to the cluster. | func proxyTransport(p *transportParams) | // proxyTransport runs either in the agent or reverse tunnel itself. It's
// used to establish connections from remote clusters into the main cluster
// or for remote nodes that have no direct network access to the cluster.
func proxyTransport(p *transportParams) | {
defer p.channel.Close()
// Always push space into stderr to make sure the caller can always
// safely call read (stderr) without blocking. This stderr is only used
// to request proxying of TCP/IP via reverse tunnel.
fmt.Fprint(p.channel.Stderr(), " ")
// Wait for a request to come in from the other side tel... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/service/service.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/service/service.go#L179-L184 | go | train | // Close closes resources associated with connector | func (c *Connector) Close() error | // Close closes resources associated with connector
func (c *Connector) Close() error | {
if c.Client != nil {
return c.Close()
}
return nil
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/service/service.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/service/service.go#L279-L288 | go | train | // getConnectors returns a copy of the identities registered for auth server | func (process *TeleportProcess) getConnectors() []*Connector | // getConnectors returns a copy of the identities registered for auth server
func (process *TeleportProcess) getConnectors() []*Connector | {
process.Lock()
defer process.Unlock()
out := make([]*Connector, 0, len(process.connectors))
for role := range process.connectors {
out = append(out, process.connectors[role])
}
return out
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/service/service.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/service/service.go#L292-L297 | go | train | // addConnector adds connector to registered connectors list,
// it will overwrite the connector for the same role | func (process *TeleportProcess) addConnector(connector *Connector) | // addConnector adds connector to registered connectors list,
// it will overwrite the connector for the same role
func (process *TeleportProcess) addConnector(connector *Connector) | {
process.Lock()
defer process.Unlock()
process.connectors[connector.ClientIdentity.ID.Role] = connector
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/service/service.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/service/service.go#L302-L345 | go | train | // GetIdentity returns the process identity (credentials to the auth server) for a given
// teleport Role. A teleport process can have any combination of 3 roles: auth, node, proxy
// and they have their own identities | func (process *TeleportProcess) GetIdentity(role teleport.Role) (i *auth.Identity, err error) | // GetIdentity returns the process identity (credentials to the auth server) for a given
// teleport Role. A teleport process can have any combination of 3 roles: auth, node, proxy
// and they have their own identities
func (process *TeleportProcess) GetIdentity(role teleport.Role) (i *auth.Identity, err error) | {
var found bool
process.Lock()
defer process.Unlock()
i, found = process.Identities[role]
if found {
return i, nil
}
i, err = process.storage.ReadIdentity(auth.IdentityCurrent, role)
id := auth.IdentityID{
Role: role,
HostUUID: process.Config.HostUUID,
NodeName: process.Config.Hostname,
}
if e... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/service/service.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/service/service.go#L379-L406 | go | train | // Run starts teleport processes, waits for signals
// and handles internal process reloads. | func Run(ctx context.Context, cfg Config, newTeleport NewProcess) error | // Run starts teleport processes, waits for signals
// and handles internal process reloads.
func Run(ctx context.Context, cfg Config, newTeleport NewProcess) error | {
if newTeleport == nil {
newTeleport = newTeleportProcess
}
copyCfg := cfg
srv, err := newTeleport(©Cfg)
if err != nil {
return trace.Wrap(err, "initialization failed")
}
if srv == nil {
return trace.BadParameter("process has returned nil server")
}
if err := srv.Start(); err != nil {
return trac... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/service/service.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/service/service.go#L486-L662 | go | train | // NewTeleport takes the daemon configuration, instantiates all required services
// and starts them under a supervisor, returning the supervisor object. | func NewTeleport(cfg *Config) (*TeleportProcess, error) | // NewTeleport takes the daemon configuration, instantiates all required services
// and starts them under a supervisor, returning the supervisor object.
func NewTeleport(cfg *Config) (*TeleportProcess, error) | {
// before we do anything reset the SIGINT handler back to the default
system.ResetInterruptSignalHandler()
if err := validateConfig(cfg); err != nil {
return nil, trace.Wrap(err, "configuration error")
}
// create the data directory if it's missing
_, err := os.Stat(cfg.DataDir)
if os.IsNotExist(err) {
... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/service/service.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/service/service.go#L666-L699 | go | train | // notifyParent notifies parent process that this process has started
// by writing to in-memory pipe used by communication channel. | func (process *TeleportProcess) notifyParent() | // notifyParent notifies parent process that this process has started
// by writing to in-memory pipe used by communication channel.
func (process *TeleportProcess) notifyParent() | {
signalPipe, err := process.importSignalPipe()
if err != nil {
if !trace.IsNotFound(err) {
process.Warningf("Failed to import signal pipe")
}
process.Debugf("No signal pipe to import, must be first Teleport process.")
return
}
defer signalPipe.Close()
ctx, cancel := context.WithTimeout(process.ExitCo... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/service/service.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/service/service.go#L714-L730 | go | train | // adminCreds returns admin UID and GID settings based on the OS | func adminCreds() (*int, *int, error) | // adminCreds returns admin UID and GID settings based on the OS
func adminCreds() (*int, *int, error) | {
if runtime.GOOS != teleport.LinuxOS {
return nil, nil, nil
}
// if the user member of adm linux group,
// make audit log folder readable by admins
isAdmin, err := utils.IsGroupMember(teleport.LinuxAdminGID)
if err != nil {
return nil, nil, trace.Wrap(err)
}
if !isAdmin {
return nil, nil, nil
}
uid :=... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/service/service.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/service/service.go#L735-L775 | go | train | // initUploadHandler initializes upload handler based on the config settings,
// currently the only upload handler supported is S3
// the call can return trace.NotFOund if no upload handler is setup | func initUploadHandler(auditConfig services.AuditConfig) (events.UploadHandler, error) | // initUploadHandler initializes upload handler based on the config settings,
// currently the only upload handler supported is S3
// the call can return trace.NotFOund if no upload handler is setup
func initUploadHandler(auditConfig services.AuditConfig) (events.UploadHandler, error) | {
if auditConfig.AuditSessionsURI == "" {
return nil, trace.NotFound("no upload handler is setup")
}
uri, err := utils.ParseSessionsURI(auditConfig.AuditSessionsURI)
if err != nil {
return nil, trace.Wrap(err)
}
switch uri.Scheme {
case teleport.SchemeS3:
region := auditConfig.Region
if uriRegion := ur... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/service/service.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/service/service.go#L779-L843 | go | train | // initExternalLog initializes external storage, if the storage is not
// setup, returns nil | func initExternalLog(auditConfig services.AuditConfig) (events.IAuditLog, error) | // initExternalLog initializes external storage, if the storage is not
// setup, returns nil
func initExternalLog(auditConfig services.AuditConfig) (events.IAuditLog, error) | {
if auditConfig.AuditTableName != "" {
log.Warningf("Please note that 'audit_table_name' is deprecated and will be removed in several releases. Use audit_events_uri: '%v://%v' instead.", dynamo.GetName(), auditConfig.AuditTableName)
if len(auditConfig.AuditEventsURI) != 0 {
return nil, trace.BadParameter("Det... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/service/service.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/service/service.go#L846-L1146 | go | train | // initAuthService can be called to initialize auth server service | func (process *TeleportProcess) initAuthService() error | // initAuthService can be called to initialize auth server service
func (process *TeleportProcess) initAuthService() error | {
var err error
cfg := process.Config
// Initialize the storage back-ends for keys, events and records
b, err := process.initAuthStorage()
if err != nil {
return trace.Wrap(err)
}
process.backend = b
// create the audit log, which will be consuming (and recording) all events
// and recording all sessions... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/service/service.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/service/service.go#L1160-L1170 | go | train | // onExit allows individual services to register a callback function which will be
// called when Teleport Process is asked to exit. Usually services terminate themselves
// when the callback is called | func (process *TeleportProcess) onExit(serviceName string, callback func(interface{})) | // onExit allows individual services to register a callback function which will be
// called when Teleport Process is asked to exit. Usually services terminate themselves
// when the callback is called
func (process *TeleportProcess) onExit(serviceName string, callback func(interface{})) | {
process.RegisterFunc(serviceName, func() error {
eventC := make(chan Event)
process.WaitForEvent(context.TODO(), TeleportExitEvent, eventC)
select {
case event := <-eventC:
callback(event.Payload)
}
return nil
})
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/service/service.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/service/service.go#L1209-L1264 | go | train | // newAccessCache returns new local cache access point | func (process *TeleportProcess) newAccessCache(cfg accessCacheConfig) (*cache.Cache, error) | // newAccessCache returns new local cache access point
func (process *TeleportProcess) newAccessCache(cfg accessCacheConfig) (*cache.Cache, error) | {
if err := cfg.CheckAndSetDefaults(); err != nil {
return nil, trace.Wrap(err)
}
var cacheBackend backend.Backend
if cfg.inMemory {
mem, err := memory.New(memory.Config{
Context: process.ExitContext(),
EventsOff: !cfg.events,
Mirror: true,
})
if err != nil {
return nil, trace.Wrap(err)
... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/service/service.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/service/service.go#L1268-L1278 | go | train | // setupCachePolicy sets up cache policy based on teleport configuration,
// it is a wrapper function, that sets up configuration | func (process *TeleportProcess) setupCachePolicy(in cache.SetupConfigFn) cache.SetupConfigFn | // setupCachePolicy sets up cache policy based on teleport configuration,
// it is a wrapper function, that sets up configuration
func (process *TeleportProcess) setupCachePolicy(in cache.SetupConfigFn) cache.SetupConfigFn | {
return func(c cache.Config) cache.Config {
config := in(c)
config.PreferRecent = cache.PreferRecent{
Enabled: process.Config.CachePolicy.Enabled,
NeverExpires: process.Config.CachePolicy.NeverExpires,
MaxTTL: process.Config.CachePolicy.TTL,
}
return config
}
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/service/service.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/service/service.go#L1281-L1283 | go | train | // newAccessPointCache returns new instance of access point configured for proxy | func (process *TeleportProcess) newLocalCacheForProxy(clt auth.ClientI, cacheName []string) (auth.AccessPoint, error) | // newAccessPointCache returns new instance of access point configured for proxy
func (process *TeleportProcess) newLocalCacheForProxy(clt auth.ClientI, cacheName []string) (auth.AccessPoint, error) | {
return process.newLocalCache(clt, cache.ForProxy, cacheName)
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/service/service.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/service/service.go#L1286-L1300 | go | train | // newAccessPointCache returns new instance of access point | func (process *TeleportProcess) newLocalCache(clt auth.ClientI, setupConfig cache.SetupConfigFn, cacheName []string) (auth.AccessPoint, error) | // newAccessPointCache returns new instance of access point
func (process *TeleportProcess) newLocalCache(clt auth.ClientI, setupConfig cache.SetupConfigFn, cacheName []string) (auth.AccessPoint, error) | {
// if caching is disabled, return access point
if !process.Config.CachePolicy.Enabled {
return clt, nil
}
cache, err := process.newAccessCache(accessCacheConfig{
services: clt,
setup: process.setupCachePolicy(setupConfig),
cacheName: cacheName,
})
if err != nil {
return nil, trace.Wrap(err)
}
... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/service/service.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/service/service.go#L1318-L1484 | go | train | // initSSH initializes the "node" role, i.e. a simple SSH server connected to the auth server. | func (process *TeleportProcess) initSSH() error | // initSSH initializes the "node" role, i.e. a simple SSH server connected to the auth server.
func (process *TeleportProcess) initSSH() error | {
process.registerWithAuthServer(teleport.RoleNode, SSHIdentityEvent)
eventsC := make(chan Event)
process.WaitForEvent(process.ExitContext(), SSHIdentityEvent, eventsC)
log := logrus.WithFields(logrus.Fields{
trace.Component: teleport.Component(teleport.ComponentNode, process.id),
})
var conn *Connector
var... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/service/service.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/service/service.go#L1521-L1538 | go | train | // registerWithAuthServer uses one time provisioning token obtained earlier
// from the server to get a pair of SSH keys signed by Auth server host
// certificate authority | func (process *TeleportProcess) registerWithAuthServer(role teleport.Role, eventName string) | // registerWithAuthServer uses one time provisioning token obtained earlier
// from the server to get a pair of SSH keys signed by Auth server host
// certificate authority
func (process *TeleportProcess) registerWithAuthServer(role teleport.Role, eventName string) | {
serviceName := strings.ToLower(role.String())
process.RegisterCriticalFunc(fmt.Sprintf("register.%v", serviceName), func() error {
connector, err := process.reconnectToAuthService(role)
if err != nil {
return trace.Wrap(err)
}
process.onExit(fmt.Sprintf("auth.client.%v", serviceName), func(interface{}) ... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/service/service.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/service/service.go#L1599-L1694 | go | train | // initDiagnosticService starts diagnostic service currently serving healthz
// and prometheus endpoints | func (process *TeleportProcess) initDiagnosticService() error | // initDiagnosticService starts diagnostic service currently serving healthz
// and prometheus endpoints
func (process *TeleportProcess) initDiagnosticService() error | {
mux := http.NewServeMux()
mux.Handle("/metrics", prometheus.Handler())
if process.Config.Debug {
log.Infof("Adding diagnostic debugging handlers. To connect with profiler, use `go tool pprof %v`.", process.Config.DiagnosticAddr.Addr)
mux.HandleFunc("/debug/pprof/", pprof.Index)
mux.HandleFunc("/debug/ppro... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/service/service.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/service/service.go#L1698-L1748 | go | train | // getAdditionalPrincipals returns a list of additional principals to add
// to role's service certificates. | func (process *TeleportProcess) getAdditionalPrincipals(role teleport.Role) ([]string, []string, error) | // getAdditionalPrincipals returns a list of additional principals to add
// to role's service certificates.
func (process *TeleportProcess) getAdditionalPrincipals(role teleport.Role) ([]string, []string, error) | {
var principals []string
var dnsNames []string
if process.Config.Hostname != "" {
principals = append(principals, process.Config.Hostname)
}
var addrs []utils.NetAddr
switch role {
case teleport.RoleProxy:
addrs = append(process.Config.Proxy.PublicAddrs, utils.NetAddr{Addr: reversetunnel.RemoteKubeProxy})
... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/service/service.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/service/service.go#L1755-L1790 | go | train | // initProxy gets called if teleport runs with 'proxy' role enabled.
// this means it will do two things:
// 1. serve a web UI
// 2. proxy SSH connections to nodes running with 'node' role
// 3. take care of reverse tunnels | func (process *TeleportProcess) initProxy() error | // initProxy gets called if teleport runs with 'proxy' role enabled.
// this means it will do two things:
// 1. serve a web UI
// 2. proxy SSH connections to nodes running with 'node' role
// 3. take care of reverse tunnels
func (process *TeleportProcess) initProxy() error | {
// if no TLS key was provided for the web UI, generate a self signed cert
if process.Config.Proxy.TLSKey == "" && !process.Config.Proxy.DisableTLS && !process.Config.Proxy.DisableWebService {
err := initSelfSignedHTTPSCert(process.Config)
if err != nil {
return trace.Wrap(err)
}
}
process.registerWithAu... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/service/service.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/service/service.go#L1815-L1899 | go | train | // setupProxyListeners sets up web proxy listeners based on the configuration | func (process *TeleportProcess) setupProxyListeners() (*proxyListeners, error) | // setupProxyListeners sets up web proxy listeners based on the configuration
func (process *TeleportProcess) setupProxyListeners() (*proxyListeners, error) | {
cfg := process.Config
process.Debugf("Setup Proxy: Web Proxy Address: %v, Reverse Tunnel Proxy Address: %v", cfg.Proxy.WebAddr.Addr, cfg.Proxy.ReverseTunnelListenAddr.Addr)
var err error
var listeners proxyListeners
if cfg.Proxy.Kube.Enabled {
process.Debugf("Setup Proxy: turning on Kubernetes proxy.")
lis... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/service/service.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/service/service.go#L2225-L2281 | go | train | // initAuthStorage initializes the storage backend for the auth service. | func (process *TeleportProcess) initAuthStorage() (bk backend.Backend, err error) | // initAuthStorage initializes the storage backend for the auth service.
func (process *TeleportProcess) initAuthStorage() (bk backend.Backend, err error) | {
bc := &process.Config.Auth.StorageConfig
process.Debugf("Using %v backend.", bc.Type)
switch bc.Type {
case lite.GetName():
bk, err = lite.New(context.TODO(), bc.Params)
// legacy bolt backend, import all data into SQLite and return
// SQLite data
case boltbk.GetName():
litebk, err := lite.New(context.T... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/service/service.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/service/service.go#L2296-L2306 | go | train | // WaitWithContext waits until all internal services stop. | func (process *TeleportProcess) WaitWithContext(ctx context.Context) | // WaitWithContext waits until all internal services stop.
func (process *TeleportProcess) WaitWithContext(ctx context.Context) | {
local, cancel := context.WithCancel(ctx)
go func() {
defer cancel()
process.Supervisor.Wait()
}()
select {
case <-local.Done():
return
}
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/service/service.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/service/service.go#L2310-L2326 | go | train | // StartShutdown launches non-blocking graceful shutdown process that signals
// completion, returns context that will be closed once the shutdown is done | func (process *TeleportProcess) StartShutdown(ctx context.Context) context.Context | // StartShutdown launches non-blocking graceful shutdown process that signals
// completion, returns context that will be closed once the shutdown is done
func (process *TeleportProcess) StartShutdown(ctx context.Context) context.Context | {
process.BroadcastEvent(Event{Name: TeleportExitEvent, Payload: ctx})
localCtx, cancel := context.WithCancel(ctx)
go func() {
defer cancel()
process.Supervisor.Wait()
process.Debugf("All supervisor functions are completed.")
localAuth := process.getLocalAuth()
if localAuth != nil {
if err := process.l... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/service/service.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/service/service.go#L2330-L2337 | go | train | // Shutdown launches graceful shutdown process and waits
// for it to complete | func (process *TeleportProcess) Shutdown(ctx context.Context) | // Shutdown launches graceful shutdown process and waits
// for it to complete
func (process *TeleportProcess) Shutdown(ctx context.Context) | {
localCtx := process.StartShutdown(ctx)
// wait until parent context closes
select {
case <-localCtx.Done():
process.Debugf("Process completed.")
}
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/service/service.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/service/service.go#L2340-L2356 | go | train | // Close broadcasts close signals and exits immediately | func (process *TeleportProcess) Close() error | // Close broadcasts close signals and exits immediately
func (process *TeleportProcess) Close() error | {
process.BroadcastEvent(Event{Name: TeleportExitEvent})
process.Config.Keygen.Close()
var errors []error
localAuth := process.getLocalAuth()
if localAuth != nil {
errors = append(errors, process.localAuth.Close())
}
if process.storage != nil {
errors = append(errors, process.storage.Close())
}
return... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/service/service.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/service/service.go#L2401-L2432 | go | train | // initSelfSignedHTTPSCert generates and self-signs a TLS key+cert pair for https connection
// to the proxy server. | func initSelfSignedHTTPSCert(cfg *Config) (err error) | // initSelfSignedHTTPSCert generates and self-signs a TLS key+cert pair for https connection
// to the proxy server.
func initSelfSignedHTTPSCert(cfg *Config) (err error) | {
log.Warningf("No TLS Keys provided, using self signed certificate.")
keyPath := filepath.Join(cfg.DataDir, defaults.SelfSignedKeyPath)
certPath := filepath.Join(cfg.DataDir, defaults.SelfSignedCertPath)
cfg.Proxy.TLSKey = keyPath
cfg.Proxy.TLSCert = certPath
// return the existing pair if they have already ... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/kube/utils/utils.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/kube/utils/utils.go#L16-L36 | go | train | // GetKubeClient returns instance of client to the kubernetes cluster
// using in-cluster configuration if available and falling back to
// configuration file under configPath otherwise | func GetKubeClient(configPath string) (client *kubernetes.Clientset, config *rest.Config, err error) | // GetKubeClient returns instance of client to the kubernetes cluster
// using in-cluster configuration if available and falling back to
// configuration file under configPath otherwise
func GetKubeClient(configPath string) (client *kubernetes.Clientset, config *rest.Config, err error) | {
// if path to kubeconfig was provided, init config from it
if configPath != "" {
config, err = clientcmd.BuildConfigFromFlags("", configPath)
if err != nil {
return nil, nil, trace.Wrap(err)
}
} else {
// otherwise attempt to init as if connecting from cluster
config, err = rest.InClusterConfig()
i... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/kube/utils/utils.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/kube/utils/utils.go#L40-L46 | go | train | // GetKubeConfig returns kubernetes configuration
// from configPath file or, by default reads in-cluster configuration | func GetKubeConfig(configPath string) (*rest.Config, error) | // GetKubeConfig returns kubernetes configuration
// from configPath file or, by default reads in-cluster configuration
func GetKubeConfig(configPath string) (*rest.Config, error) | {
// if path to kubeconfig was provided, init config from it
if configPath != "" {
return clientcmd.BuildConfigFromFlags("", configPath)
}
return rest.InClusterConfig()
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/provisioning.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/provisioning.go#L33-L39 | go | train | // MustCreateProvisionToken returns a new valid provision token
// or panics, used in testes | func MustCreateProvisionToken(token string, roles teleport.Roles, expires time.Time) ProvisionToken | // MustCreateProvisionToken returns a new valid provision token
// or panics, used in testes
func MustCreateProvisionToken(token string, roles teleport.Roles, expires time.Time) ProvisionToken | {
t, err := NewProvisionToken(token, roles, expires)
if err != nil {
panic(err)
}
return t
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/provisioning.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/provisioning.go#L42-L59 | go | train | // NewProvisionToken returns a new instance of provision token resource | func NewProvisionToken(token string, roles teleport.Roles, expires time.Time) (ProvisionToken, error) | // NewProvisionToken returns a new instance of provision token resource
func NewProvisionToken(token string, roles teleport.Roles, expires time.Time) (ProvisionToken, error) | {
t := &ProvisionTokenV2{
Kind: KindToken,
Version: V2,
Metadata: Metadata{
Name: token,
Expires: &expires,
Namespace: defaults.Namespace,
},
Spec: ProvisionTokenSpecV2{
Roles: roles,
},
}
if err := t.CheckAndSetDefaults(); err != nil {
return nil, trace.Wrap(err)
}
return t, n... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/provisioning.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/provisioning.go#L97-L106 | go | train | // ProvisionTokensToV1 converts provision tokens to V1 list | func ProvisionTokensToV1(in []ProvisionToken) []ProvisionTokenV1 | // ProvisionTokensToV1 converts provision tokens to V1 list
func ProvisionTokensToV1(in []ProvisionToken) []ProvisionTokenV1 | {
if in == nil {
return nil
}
out := make([]ProvisionTokenV1, len(in))
for i := range in {
out[i] = *in[i].V1()
}
return out
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/provisioning.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/provisioning.go#L109-L118 | go | train | // ProvisionTokensFromV1 converts V1 provision tokens to resource list | func ProvisionTokensFromV1(in []ProvisionTokenV1) []ProvisionToken | // ProvisionTokensFromV1 converts V1 provision tokens to resource list
func ProvisionTokensFromV1(in []ProvisionTokenV1) []ProvisionToken | {
if in == nil {
return nil
}
out := make([]ProvisionToken, len(in))
for i := range in {
out[i] = in[i].V2()
}
return out
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/provisioning.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/provisioning.go#L121-L134 | go | train | // CheckAndSetDefaults checks and set default values for any missing fields. | func (p *ProvisionTokenV2) CheckAndSetDefaults() error | // CheckAndSetDefaults checks and set default values for any missing fields.
func (p *ProvisionTokenV2) CheckAndSetDefaults() error | {
p.Kind = KindToken
err := p.Metadata.CheckAndSetDefaults()
if err != nil {
return trace.Wrap(err)
}
if len(p.Spec.Roles) == 0 {
return trace.BadParameter("provisioning token is missing roles")
}
if err := teleport.Roles(p.Spec.Roles).Check(); err != nil {
return trace.Wrap(err)
}
return nil
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/provisioning.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/provisioning.go#L149-L151 | go | train | // SetRoles sets teleport roles | func (p *ProvisionTokenV2) SetRoles(r teleport.Roles) | // SetRoles sets teleport roles
func (p *ProvisionTokenV2) SetRoles(r teleport.Roles) | {
p.Spec.Roles = r
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/provisioning.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/provisioning.go#L184-L190 | go | train | // V1 returns V1 version of the resource | func (p *ProvisionTokenV2) V1() *ProvisionTokenV1 | // V1 returns V1 version of the resource
func (p *ProvisionTokenV2) V1() *ProvisionTokenV1 | {
return &ProvisionTokenV1{
Roles: p.Spec.Roles,
Expires: p.Metadata.Expiry(),
Token: p.Metadata.Name,
}
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/provisioning.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/provisioning.go#L198-L200 | go | train | // SetExpiry sets expiry time for the object | func (p *ProvisionTokenV2) SetExpiry(expires time.Time) | // SetExpiry sets expiry time for the object
func (p *ProvisionTokenV2) SetExpiry(expires time.Time) | {
p.Metadata.SetExpiry(expires)
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/provisioning.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/provisioning.go#L208-L210 | go | train | // SetTTL sets Expires header using realtime clock | func (p *ProvisionTokenV2) SetTTL(clock clockwork.Clock, ttl time.Duration) | // SetTTL sets Expires header using realtime clock
func (p *ProvisionTokenV2) SetTTL(clock clockwork.Clock, ttl time.Duration) | {
p.Metadata.SetTTL(clock, ttl)
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/provisioning.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/provisioning.go#L223-L229 | go | train | // String returns the human readable representation of a provisioning token. | func (p ProvisionTokenV2) String() string | // String returns the human readable representation of a provisioning token.
func (p ProvisionTokenV2) String() string | {
expires := "never"
if !p.Expiry().IsZero() {
expires = p.Expiry().String()
}
return fmt.Sprintf("ProvisionToken(Roles=%v, Expires=%v)", p.Spec.Roles, expires)
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/provisioning.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/provisioning.go#L237-L253 | go | train | // V2 returns V2 version of the resource | func (p *ProvisionTokenV1) V2() *ProvisionTokenV2 | // V2 returns V2 version of the resource
func (p *ProvisionTokenV1) V2() *ProvisionTokenV2 | {
t := &ProvisionTokenV2{
Kind: KindToken,
Version: V2,
Metadata: Metadata{
Name: p.Token,
Namespace: defaults.Namespace,
},
Spec: ProvisionTokenSpecV2{
Roles: p.Roles,
},
}
if !p.Expires.IsZero() {
t.SetExpiry(p.Expires)
}
return t
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.