Skip to content

Commit

Permalink
tailscale: update tailfs functions and vars to use drive naming (tail…
Browse files Browse the repository at this point in the history
…scale#11597)

This change updates all tailfs functions and the majority of the tailfs
variables to use the new drive naming.

Updates tailscale/corp#16827

Signed-off-by: Charlotte Brandhorst-Satzkorn <[email protected]>
  • Loading branch information
catzkorn authored Apr 3, 2024
1 parent 2409661 commit 93618a3
Show file tree
Hide file tree
Showing 27 changed files with 233 additions and 233 deletions.
26 changes: 13 additions & 13 deletions client/tailscale/localclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -1418,25 +1418,25 @@ func (lc *LocalClient) CheckUpdate(ctx context.Context) (*tailcfg.ClientVersion,
return &cv, nil
}

// TailFSSetFileServerAddr instructs TailFS to use the server at addr to access
// DriveSetServerAddr instructs Taildrive to use the server at addr to access
// the filesystem. This is used on platforms like Windows and MacOS to let
// TailFS know to use the file server running in the GUI app.
func (lc *LocalClient) TailFSSetFileServerAddr(ctx context.Context, addr string) error {
// Taildrive know to use the file server running in the GUI app.
func (lc *LocalClient) DriveSetServerAddr(ctx context.Context, addr string) error {
_, err := lc.send(ctx, "PUT", "/localapi/v0/tailfs/fileserver-address", http.StatusCreated, strings.NewReader(addr))
return err
}

// TailFSShareSet adds or updates the given share in the list of shares that
// TailFS will serve to remote nodes. If a share with the same name already
// DriveShareSet adds or updates the given share in the list of shares that
// Taildrive will serve to remote nodes. If a share with the same name already
// exists, the existing share is replaced/updated.
func (lc *LocalClient) TailFSShareSet(ctx context.Context, share *drive.Share) error {
func (lc *LocalClient) DriveShareSet(ctx context.Context, share *drive.Share) error {
_, err := lc.send(ctx, "PUT", "/localapi/v0/tailfs/shares", http.StatusCreated, jsonBody(share))
return err
}

// TailFSShareRemove removes the share with the given name from the list of
// shares that TailFS will serve to remote nodes.
func (lc *LocalClient) TailFSShareRemove(ctx context.Context, name string) error {
// DriveShareRemove removes the share with the given name from the list of
// shares that Taildrive will serve to remote nodes.
func (lc *LocalClient) DriveShareRemove(ctx context.Context, name string) error {
_, err := lc.send(
ctx,
"DELETE",
Expand All @@ -1446,8 +1446,8 @@ func (lc *LocalClient) TailFSShareRemove(ctx context.Context, name string) error
return err
}

// TailFSShareRename renames the share from old to new name.
func (lc *LocalClient) TailFSShareRename(ctx context.Context, oldName, newName string) error {
// DriveShareRename renames the share from old to new name.
func (lc *LocalClient) DriveShareRename(ctx context.Context, oldName, newName string) error {
_, err := lc.send(
ctx,
"POST",
Expand All @@ -1457,9 +1457,9 @@ func (lc *LocalClient) TailFSShareRename(ctx context.Context, oldName, newName s
return err
}

// TailFSShareList returns the list of shares that TailFS is currently serving
// DriveShareList returns the list of shares that drive is currently serving
// to remote nodes.
func (lc *LocalClient) TailFSShareList(ctx context.Context) ([]*drive.Share, error) {
func (lc *LocalClient) DriveShareList(ctx context.Context) ([]*drive.Share, error) {
result, err := lc.get200(ctx, "/localapi/v0/tailfs/shares")
if err != nil {
return nil, err
Expand Down
2 changes: 1 addition & 1 deletion cmd/tailscale/cli/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -829,7 +829,7 @@ func TestPrefFlagMapping(t *testing.T) {
// Handled by TS_DEBUG_FIREWALL_MODE env var, we don't want to have
// a CLI flag for this. The Pref is used by c2n.
continue
case "TailFSShares":
case "DriveShares":
// Handled by the tailscale share subcommand, we don't want a CLI
// flag for this.
continue
Expand Down
8 changes: 4 additions & 4 deletions cmd/tailscale/cli/share.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func runShareSet(ctx context.Context, args []string) error {

name, path := args[0], args[1]

err := localClient.TailFSShareSet(ctx, &drive.Share{
err := localClient.DriveShareSet(ctx, &drive.Share{
Name: name,
Path: path,
})
Expand All @@ -86,7 +86,7 @@ func runShareRemove(ctx context.Context, args []string) error {
}
name := args[0]

err := localClient.TailFSShareRemove(ctx, name)
err := localClient.DriveShareRemove(ctx, name)
if err == nil {
fmt.Printf("Removed share %q\n", name)
}
Expand All @@ -101,7 +101,7 @@ func runShareRename(ctx context.Context, args []string) error {
oldName := args[0]
newName := args[1]

err := localClient.TailFSShareRename(ctx, oldName, newName)
err := localClient.DriveShareRename(ctx, oldName, newName)
if err == nil {
fmt.Printf("Renamed share %q to %q\n", oldName, newName)
}
Expand All @@ -114,7 +114,7 @@ func runShareList(ctx context.Context, args []string) error {
return fmt.Errorf("usage: tailscale %v", shareListUsage)
}

shares, err := localClient.TailFSShareList(ctx)
shares, err := localClient.DriveShareList(ctx)
if err != nil {
return err
}
Expand Down
24 changes: 12 additions & 12 deletions cmd/tailscaled/tailscaled.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ var subCommands = map[string]*func([]string) error{
"uninstall-system-daemon": &uninstallSystemDaemon,
"debug": &debugModeFunc,
"be-child": &beChildFunc,
"serve-tailfs": &serveTailFSFunc,
"serve-tailfs": &serveDriveFunc,
}

var beCLI func() // non-nil if CLI is linked in
Expand Down Expand Up @@ -645,12 +645,12 @@ var tstunNew = tstun.New

func tryEngine(logf logger.Logf, sys *tsd.System, name string) (onlyNetstack bool, err error) {
conf := wgengine.Config{
ListenPort: args.port,
NetMon: sys.NetMon.Get(),
Dialer: sys.Dialer.Get(),
SetSubsystem: sys.Set,
ControlKnobs: sys.ControlKnobs(),
TailFSForLocal: driveimpl.NewFileSystemForLocal(logf),
ListenPort: args.port,
NetMon: sys.NetMon.Get(),
Dialer: sys.Dialer.Get(),
SetSubsystem: sys.Set,
ControlKnobs: sys.ControlKnobs(),
DriveForLocal: driveimpl.NewFileSystemForLocal(logf),
}

onlyNetstack = name == "userspace-networking"
Expand Down Expand Up @@ -753,7 +753,7 @@ func runDebugServer(mux *http.ServeMux, addr string) {
}

func newNetstack(logf logger.Logf, sys *tsd.System) (*netstack.Impl, error) {
tfs, _ := sys.TailFSForLocal.GetOK()
tfs, _ := sys.DriveForLocal.GetOK()
ret, err := netstack.Create(logf,
sys.Tun.Get(),
sys.Engine.Get(),
Expand Down Expand Up @@ -831,16 +831,16 @@ func beChild(args []string) error {
return f(args[1:])
}

var serveTailFSFunc = serveTailFS
var serveDriveFunc = serveDrive

// serveTailFS serves one or more tailfs on localhost using the WebDAV
// serveDrive serves one or more tailfs on localhost using the WebDAV
// protocol. On UNIX and MacOS tailscaled environment, tailfs spawns child
// tailscaled processes in serve-tailfs mode in order to access the fliesystem
// as specific (usually unprivileged) users.
//
// serveTailFS prints the address on which it's listening to stdout so that the
// serveDrive prints the address on which it's listening to stdout so that the
// parent process knows where to connect to.
func serveTailFS(args []string) error {
func serveDrive(args []string) error {
if len(args) == 0 {
return errors.New("missing shares")
}
Expand Down
2 changes: 1 addition & 1 deletion drive/driveimpl/drive_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func init() {
drive.DisallowShareAs = true
}

// The tests in this file simulate real-life TailFS scenarios, but without
// The tests in this file simulate real-life Taildrive scenarios, but without
// going over the Tailscale network stack.
func TestDirectoryListing(t *testing.T) {
s := newSystem(t)
Expand Down
2 changes: 1 addition & 1 deletion drive/driveimpl/fileserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
)

// FileServer is a standalone WebDAV server that dynamically serves up shares.
// It's typically used in a separate process from the actual TailFS server to
// It's typically used in a separate process from the actual Taildrive server to
// serve up files as an unprivileged user.
type FileServer struct {
l net.Listener
Expand Down
4 changes: 2 additions & 2 deletions drive/driveimpl/local_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ func NewFileSystemForLocal(logf logger.Logf) *FileSystemForLocal {
return fs
}

// FileSystemForLocal is the TailFS filesystem exposed to local clients. It
// provides a unified WebDAV interface to remote TailFS shares on other nodes.
// FileSystemForLocal is the Taildrive filesystem exposed to local clients. It
// provides a unified WebDAV interface to remote Taildrive shares on other nodes.
type FileSystemForLocal struct {
logf logger.Logf
h *compositedav.Handler
Expand Down
12 changes: 6 additions & 6 deletions drive/driveimpl/remote_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func NewFileSystemForRemote(logf logger.Logf) *FileSystemForRemote {
return fs
}

// FileSystemForRemote implements tailfs.FileSystemForRemote.
// FileSystemForRemote implements drive.FileSystemForRemote.
type FileSystemForRemote struct {
logf logger.Logf
lockSystem webdav.LockSystem
Expand All @@ -58,15 +58,15 @@ type FileSystemForRemote struct {
userServers map[string]*userServer
}

// SetFileServerAddr implements tailfs.FileSystemForRemote.
// SetFileServerAddr implements drive.FileSystemForRemote.
func (s *FileSystemForRemote) SetFileServerAddr(addr string) {
s.mu.Lock()
s.fileServerAddr = addr
s.mu.Unlock()
}

// SetShares implements tailfs.FileSystemForRemote. Shares must be sorted
// according to tailfs.CompareShares.
// SetShares implements drive.FileSystemForRemote. Shares must be sorted
// according to drive.CompareShares.
func (s *FileSystemForRemote) SetShares(shares []*drive.Share) {
userServers := make(map[string]*userServer)
if drive.AllowShareAs() {
Expand Down Expand Up @@ -176,7 +176,7 @@ func (s *FileSystemForRemote) buildChild(share *drive.Share) *compositedav.Child
}
}

// ServeHTTPWithPerms implements tailfs.FileSystemForRemote.
// ServeHTTPWithPerms implements drive.FileSystemForRemote.
func (s *FileSystemForRemote) ServeHTTPWithPerms(permissions drive.Permissions, w http.ResponseWriter, r *http.Request) {
isWrite := writeMethods[r.Method]
if isWrite {
Expand Down Expand Up @@ -228,7 +228,7 @@ func (s *FileSystemForRemote) closeChildren(children map[string]*compositedav.Ch
}
}

// Close() implements tailfs.FileSystemForRemote.
// Close() implements drive.FileSystemForRemote.
func (s *FileSystemForRemote) Close() error {
s.mu.Lock()
userServers := s.userServers
Expand Down
2 changes: 1 addition & 1 deletion drive/driveimpl/shared/readonlydir.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Tailscale Inc & AUTHORS
// SPDX-License-Identifier: BSD-3-Clause

// Package shared contains types and functions shared by different tailfs
// Package shared contains types and functions shared by different drive
// packages.
package shared

Expand Down
12 changes: 6 additions & 6 deletions drive/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
// SPDX-License-Identifier: BSD-3-Clause

// Package drive provides a filesystem that allows sharing folders between
// Tailscale nodes using WebDAV. The actual implementation of the core drive
// Tailscale nodes using WebDAV. The actual implementation of the core Taildrive
// functionality lives in package driveimpl. These packages are separated to
// allow users of drive to refer to the interfaces without having a hard
// dependency on drive, so that programs which don't actually use drive can
// allow users of Taildrive to refer to the interfaces without having a hard
// dependency on Taildrive, so that programs which don't actually use Taildrive can
// avoid its transitive dependencies.
package drive

Expand All @@ -14,15 +14,15 @@ import (
"net/http"
)

// Remote represents a remote TailFS node.
// Remote represents a remote Taildrive node.
type Remote struct {
Name string
URL string
Available func() bool
}

// FileSystemForLocal is the TailFS filesystem exposed to local clients. It
// provides a unified WebDAV interface to remote TailFS shares on other nodes.
// FileSystemForLocal is the Taildrive filesystem exposed to local clients. It
// provides a unified WebDAV interface to remote Taildrive shares on other nodes.
type FileSystemForLocal interface {
// HandleConn handles connections from local WebDAV clients
HandleConn(conn net.Conn, remoteAddr net.Addr) error
Expand Down
4 changes: 2 additions & 2 deletions drive/remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func AllowShareAs() bool {
return !DisallowShareAs && doAllowShareAs()
}

// Share configures a folder to be shared through TailFS.
// Share configures a folder to be shared through drive.
type Share struct {
// Name is how this share appears on remote nodes.
Name string `json:"name,omitempty"`
Expand Down Expand Up @@ -78,7 +78,7 @@ func CompareShares(a, b *Share) int {
return strings.Compare(a.Name, b.Name)
}

// FileSystemForRemote is the TailFS filesystem exposed to remote nodes. It
// FileSystemForRemote is the drive filesystem exposed to remote nodes. It
// provides a unified WebDAV interface to local directories that have been
// shared.
type FileSystemForRemote interface {
Expand Down
6 changes: 3 additions & 3 deletions ipn/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ const (
NotifyInitialNetMap // if set, the first Notify message (sent immediately) will contain the current NetMap

NotifyNoPrivateKeys // if set, private keys that would normally be sent in updates are zeroed out
NotifyInitialTailFSShares // if set, the first Notify message (sent immediately) will contain the current TailFS Shares
NotifyInitialDriveShares // if set, the first Notify message (sent immediately) will contain the current Taildrive Shares
NotifyInitialOutgoingFiles // if set, the first Notify message (sent immediately) will contain the current Taildrop OutgoingFiles
)

Expand Down Expand Up @@ -130,13 +130,13 @@ type Notify struct {
// is available.
ClientVersion *tailcfg.ClientVersion `json:",omitempty"`

// TailFSShares tracks the full set of current TailFSShares that we're
// DriveShares tracks the full set of current DriveShares that we're
// publishing. Some client applications, like the MacOS and Windows clients,
// will listen for updates to this and handle serving these shares under
// the identity of the unprivileged user that is running the application. A
// nil value here means that we're not broadcasting shares information, an
// empty value means that there are no shares.
TailFSShares views.SliceView[*drive.Share, drive.ShareView]
DriveShares views.SliceView[*drive.Share, drive.ShareView]

// type is mirrored in xcode/Shared/IPN.swift
}
Expand Down
10 changes: 5 additions & 5 deletions ipn/ipn_clone.go

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

6 changes: 3 additions & 3 deletions ipn/ipn_view.go

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

Loading

0 comments on commit 93618a3

Please sign in to comment.