tailfs

package
v1.62.1 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2024 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Overview

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

Index

Constants

This section is empty.

Variables

View Source
var (
	// DisallowShareAs forcibly disables sharing as a specific user, only used
	// for testing.
	DisallowShareAs = false
)

Functions

func AllowShareAs

func AllowShareAs() bool

AllowShareAs reports whether sharing files as a specific user is allowed.

func Clone added in v1.62.0

func Clone(dst, src any) bool

Clone duplicates src into dst and reports whether it succeeded. To succeed, <src, dst> must be of types <*T, *T> or <*T, **T>, where T is one of Share.

func CompareShares added in v1.62.0

func CompareShares(a, b *Share) int

func ShareViewsEqual added in v1.62.0

func ShareViewsEqual(a, b ShareView) bool

func SharesEqual added in v1.62.0

func SharesEqual(a, b *Share) bool

Types

type FileSystemForLocal

type FileSystemForLocal interface {
	// HandleConn handles connections from local WebDAV clients
	HandleConn(conn net.Conn, remoteAddr net.Addr) error

	// SetRemotes sets the complete set of remotes on the given tailnet domain
	// using a map of name -> url. If transport is specified, that transport
	// will be used to connect to these remotes.
	SetRemotes(domain string, remotes []*Remote, transport http.RoundTripper)

	// Close() stops serving the WebDAV content
	Close() error
}

FileSystemForLocal is the TailFS filesystem exposed to local clients. It provides a unified WebDAV interface to remote TailFS shares on other nodes.

type FileSystemForRemote

type FileSystemForRemote interface {
	// SetFileServerAddr sets the address of the file server to which we
	// should proxy. This is used on platforms like Windows and MacOS
	// sandboxed where we can't spawn user-specific sub-processes and instead
	// rely on the UI application that's already running as an unprivileged
	// user to access the filesystem for us.
	SetFileServerAddr(addr string)

	// SetShares sets the complete set of shares exposed by this node. If
	// AllowShareAs() reports true, we will use one subprocess per user to
	// access the filesystem (see userServer). Otherwise, we will use the file
	// server configured via SetFileServerAddr.
	SetShares(shares []*Share)

	// ServeHTTPWithPerms behaves like the similar method from http.Handler but
	// also accepts a Permissions map that captures the permissions of the
	// connecting node.
	ServeHTTPWithPerms(permissions Permissions, w http.ResponseWriter, r *http.Request)

	// Close() stops serving the WebDAV content
	Close() error
}

FileSystemForRemote is the TailFS filesystem exposed to remote nodes. It provides a unified WebDAV interface to local directories that have been shared.

type Permission

type Permission uint8
const (
	PermissionNone Permission = iota
	PermissionReadOnly
	PermissionReadWrite
)

type Permissions

type Permissions map[string]Permission

Permissions represents the set of permissions for a given principal to a set of shares.

func ParsePermissions

func ParsePermissions(rawGrants [][]byte) (Permissions, error)

ParsePermissions builds a Permissions map from a lis of raw grants.

func (Permissions) For

func (p Permissions) For(share string) Permission

type Remote

type Remote struct {
	Name      string
	URL       string
	Available func() bool
}

Remote represents a remote TailFS node.

type Share

type Share struct {
	// Name is how this share appears on remote nodes.
	Name string `json:"name,omitempty"`

	// Path is the path to the directory on this machine that's being shared.
	Path string `json:"path,omitempty"`

	// As is the UNIX or Windows username of the local account used for this
	// share. File read/write permissions are enforced based on this username.
	// Can be left blank to use the default value of "whoever is running the
	// Tailscale GUI".
	As string `json:"who,omitempty"`

	// BookmarkData contains security-scoped bookmark data for the Sandboxed
	// Mac application. The Sandboxed Mac application gains permission to
	// access the Share's folder as a result of a user selecting it in a file
	// picker. In order to retain access to it across restarts, it needs to
	// hold on to a security-scoped bookmark. That bookmark is stored here. See
	// https://developer.apple.com/documentation/security/app_sandbox/accessing_files_from_the_macos_app_sandbox#4144043
	BookmarkData []byte `json:"bookmarkData,omitempty"`
}

Share configures a folder to be shared through TailFS.

func (*Share) Clone added in v1.62.0

func (src *Share) Clone() *Share

Clone makes a deep copy of Share. The result aliases no memory with the original.

func (*Share) View added in v1.62.0

func (p *Share) View() ShareView

View returns a readonly view of Share.

type ShareView added in v1.62.0

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

ShareView provides a read-only view over Share.

Its methods should only be called if `Valid()` returns true.

func (ShareView) As added in v1.62.0

func (v ShareView) As() string

func (ShareView) AsStruct added in v1.62.0

func (v ShareView) AsStruct() *Share

AsStruct returns a clone of the underlying value which aliases no memory with the original.

func (ShareView) BookmarkData added in v1.62.0

func (v ShareView) BookmarkData() views.ByteSlice[[]byte]

func (ShareView) MarshalJSON added in v1.62.0

func (v ShareView) MarshalJSON() ([]byte, error)

func (ShareView) Name added in v1.62.0

func (v ShareView) Name() string

func (ShareView) Path added in v1.62.0

func (v ShareView) Path() string

func (*ShareView) UnmarshalJSON added in v1.62.0

func (v *ShareView) UnmarshalJSON(b []byte) error

func (ShareView) Valid added in v1.62.0

func (v ShareView) Valid() bool

Valid reports whether underlying value is non-nil.

Directories

Path Synopsis
Package tailfsimpl provides an implementation of package tailfs.
Package tailfsimpl provides an implementation of package tailfs.
compositedav
Package compositedav provides an http.Handler that composes multiple WebDAV services into a single WebDAV service that presents each of them as its own folder.
Package compositedav provides an http.Handler that composes multiple WebDAV services into a single WebDAV service that presents each of them as its own folder.
dirfs
Package dirfs provides a webdav.FileSystem that looks like a read-only directory containing only subdirectories.
Package dirfs provides a webdav.FileSystem that looks like a read-only directory containing only subdirectories.
shared
Package shared contains types and functions shared by different tailfs packages.
Package shared contains types and functions shared by different tailfs packages.

Jump to

Keyboard shortcuts

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