remote

package
v0.0.0-...-80a9e2a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 16, 2024 License: BSD-3-Clause Imports: 28 Imported by: 0

README

Go Reference

golang.org/x/build/internal/coordinator/remote

Package remote provides remote access to resources in the build infrastructure.

Documentation

Overview

Package remote provides remote access to resources in the build infrastructure.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SSHKeyPair

func SSHKeyPair() (privateKey []byte, publicKey []byte, err error)

SSHKeyPair generates a set of ecdsa256 SSH Keys. The public key is serialized for inclusion in an OpenSSH authorized_keys file. The private key is PEM encoded.

func SignPublicSSHKey

func SignPublicSSHKey(ctx context.Context, caPriKey ssh.Signer, rawPubKey []byte, sessionID, ownerID string, d time.Duration) ([]byte, error)

SignPublicSSHKey signs a public SSH key using the certificate authority. These keys are intended for use with the specified gomote and owner. The public SSH are intended to be used in OpenSSH certificate authentication with the gomote SSH server.

func WriteSSHPrivateKeyToTempFile

func WriteSSHPrivateKeyToTempFile(key []byte) (path string, err error)

WriteSSHPrivateKeyToTempFile writes a key to a temporary file on the local file system. It also sets the permissions on the file to what is expected by OpenSSH implementations of SSH.

Types

type Buildlet

type Buildlet struct {
	User        string // "user-foo" build key
	Name        string // dup of key
	HostType    string
	BuilderType string // default builder config to use if not overwritten
	Created     time.Time
	Expires     time.Time
	// contains filtered or unexported fields
}

Buildlet is the representation of the legacy remote buildlet.

func (*Buildlet) Buildlet

func (rb *Buildlet) Buildlet() buildlet.Client

Buildlet returns the buildlet client for the associated legacy buildlet.

func (*Buildlet) Renew

func (rb *Buildlet) Renew(ctx context.Context, rbs *Buildlets)

Renew renews rb's idle timeout if ctx hasn't expired. Renew should run in its own goroutine.

func (*Buildlet) SetBuildlet

func (rb *Buildlet) SetBuildlet(b buildlet.Client)

SetBuildlet sets the buildlet client for a legacy buildlet.

type Buildlets

type Buildlets struct {
	sync.Mutex
	M map[string]*Buildlet // keyed by buildletName
}

Buildlets is a store for the legacy remote buildlets.

type SSHOption

type SSHOption func(*SSHServer)

SSHOption are options to set for the SSH server.

func EnableLUCIOption

func EnableLUCIOption() SSHOption

EnableLUCIOption sets the configuration needed for swarming bots to connect to the SSH server.

type SSHServer

type SSHServer struct {
	// contains filtered or unexported fields
}

SSHServer is the SSH server that the coordinator provides.

func NewSSHServer

func NewSSHServer(addr string, hostPrivateKey, gomotePublicKey, caPrivateKey []byte, sp *SessionPool, opts ...SSHOption) (*SSHServer, error)

NewSSHServer creates an SSH server used to access remote buildlet sessions.

func (*SSHServer) Close

func (ss *SSHServer) Close() error

Close immediately closes all active listeners and connections.

func (*SSHServer) HandleIncomingSSHPostAuth

func (ss *SSHServer) HandleIncomingSSHPostAuth(s gssh.Session)

HandleIncomingSSHPostAuth handles post-authentication requests for the SSH server. This handler uses Sessions for session management.

func (*SSHServer) HandleIncomingSSHPostAuthSwarming

func (ss *SSHServer) HandleIncomingSSHPostAuthSwarming(s gssh.Session)

HandleIncomingSSHPostAuthSwarming handles post-authentication requests for the SSH server. This handler uses Sessions for session management.

func (*SSHServer) ListenAndServe

func (ss *SSHServer) ListenAndServe() error

ListenAndServe attempts to start the SSH server. This blocks until the server stops.

type Session

type Session struct {
	BuilderType string // default builder config to use if not overwritten
	Created     time.Time
	Expires     time.Time
	HostType    string
	ID          string // unique identifier for instance "user-bradfitz-linux-amd64-0"
	OwnerID     string // identity aware proxy user id: "accounts.google.com:userIDvalue"
	// contains filtered or unexported fields
}

Session stores the metadata for a remote buildlet Session.

type SessionPool

type SessionPool struct {
	// contains filtered or unexported fields
}

SessionPool contains active remote buildlet sessions.

func NewSessionPool

func NewSessionPool(ctx context.Context) *SessionPool

NewSessionPool creates a session pool which stores and provides access to active remote buildlet sessions. Either cancelling the context or calling close on the session pool will terminate any polling functions.

func (*SessionPool) AddSession

func (sp *SessionPool) AddSession(ownerID, username, builderType, hostType string, bc buildlet.Client) (name string)

AddSession adds the provided session to the session pool.

func (*SessionPool) BuildletClient

func (sp *SessionPool) BuildletClient(buildletName string) (buildlet.Client, error)

BuildletClient returns the buildlet client associated with the Session.

func (*SessionPool) Close

func (sp *SessionPool) Close()

Close cancels the polling performed by the session pool. It waits for polling to conclude before returning.

func (*SessionPool) DestroySession

func (sp *SessionPool) DestroySession(buildletName string) error

DestroySession destroys a session.

func (*SessionPool) IsSession

func (sp *SessionPool) IsSession(instName string) bool

IsSession is true if the instance is found in the session pool. The instance name is the not the public name of the instance. It is the name of the instance as it is tracked in the cloud service.

func (*SessionPool) KeepAlive

func (sp *SessionPool) KeepAlive(ctx context.Context, buildletName string) error

KeepAlive will renew the remote buildlet session by extending the expiration value. It will periodically extend the value until the provided context has been cancelled.

func (*SessionPool) Len

func (sp *SessionPool) Len() int

Len gives a count of how many sessions are in the pool.

func (*SessionPool) List

func (sp *SessionPool) List() []*Session

List returns a list of all active sessions sorted by session ID.

func (*SessionPool) RenewTimeout

func (sp *SessionPool) RenewTimeout(buildletName string) error

RenewTimeout will renew the remote buildlet session by extending the expiration value.

func (*SessionPool) Session

func (sp *SessionPool) Session(buildletName string) (*Session, error)

Session retrieves information about the instance associated with a session from the pool.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL