Skip to content

Commit

Permalink
VNet in Connect: Send notification about bg item if not already enabl…
Browse files Browse the repository at this point in the history
…ed (#44219)

* Make serviceStatus public

* Print to stdout when VNet is ready

* Use executable name instead of saying "current executable"

This error bubbles up to the UI in Connect. In that context, "the current
executable" is ambiguous.

* Send notification about bg item if not already enabled

* Adjust notification copy

Co-authored-by: Grzegorz Zdunek <gzdunek@users.noreply.github.com>

---------

Co-authored-by: Grzegorz Zdunek <gzdunek@users.noreply.github.com>
  • Loading branch information
ravicious and gzdunek authored Jul 16, 2024
1 parent 372d5db commit 1de89b6
Show file tree
Hide file tree
Showing 12 changed files with 621 additions and 77 deletions.
305 changes: 258 additions & 47 deletions gen/proto/go/teleport/lib/teleterm/vnet/v1/vnet_service.pb.go

Large diffs are not rendered by default.

48 changes: 45 additions & 3 deletions gen/proto/go/teleport/lib/teleterm/vnet/v1/vnet_service_grpc.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

124 changes: 123 additions & 1 deletion gen/proto/ts/teleport/lib/teleterm/vnet/v1/vnet_service_pb.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

61 changes: 61 additions & 0 deletions lib/teleterm/vnet/service_daemon_darwin.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
// Teleport
// Copyright (C) 2024 Gravitational, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

//go:build vnetdaemon
// +build vnetdaemon

package vnet

import (
"context"
"os"

"github.com/gravitational/trace"

api "github.com/gravitational/teleport/gen/proto/go/teleport/lib/teleterm/vnet/v1"
"github.com/gravitational/teleport/lib/vnet"
vnetdaemon "github.com/gravitational/teleport/lib/vnet/daemon"
)

func (s *Service) GetBackgroundItemStatus(ctx context.Context, req *api.GetBackgroundItemStatusRequest) (*api.GetBackgroundItemStatusResponse, error) {
if os.Getenv(vnet.EnvFeatureFlag) != "yes" {
return nil, trace.NotImplemented("tsh was built with VNet daemon support, but the feature flag is not enabled")
}

status, err := vnetdaemon.DaemonStatus()
if err != nil {
return nil, trace.Wrap(err)
}

return &api.GetBackgroundItemStatusResponse{
Status: backgroundItemStatusFromServiceStatus(status),
}, nil
}

func backgroundItemStatusFromServiceStatus(status vnetdaemon.ServiceStatus) api.BackgroundItemStatus {
switch status {
case vnetdaemon.ServiceStatusNotRegistered:
return api.BackgroundItemStatus_BACKGROUND_ITEM_STATUS_NOT_REGISTERED
case vnetdaemon.ServiceStatusEnabled:
return api.BackgroundItemStatus_BACKGROUND_ITEM_STATUS_ENABLED
case vnetdaemon.ServiceStatusRequiresApproval:
return api.BackgroundItemStatus_BACKGROUND_ITEM_STATUS_REQUIRES_APPROVAL
case vnetdaemon.ServiceStatusNotFound:
return api.BackgroundItemStatus_BACKGROUND_ITEM_STATUS_NOT_FOUND
default:
return api.BackgroundItemStatus_BACKGROUND_ITEM_STATUS_UNSPECIFIED
}
}
Loading

0 comments on commit 1de89b6

Please sign in to comment.