Documentation ¶
Overview ¶
Package drive provides a filesystem that allows sharing folders between Tailscale nodes using WebDAV. The actual implementation of the core Taildrive functionality lives in package driveimpl. These packages are separated to 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.
Index ¶
- Variables
- func AllowShareAs() bool
- func Clone(dst, src any) bool
- func CompareShares(a, b *Share) int
- func NormalizeShareName(name string) (string, error)
- func ShareViewsEqual(a, b ShareView) bool
- func SharesEqual(a, b *Share) bool
- type FileSystemForLocal
- type FileSystemForRemote
- type Permission
- type Permissions
- type Remote
- type Share
- type ShareView
- func (v ShareView) As() string
- func (v ShareView) AsStruct() *Share
- func (v ShareView) BookmarkData() views.ByteSlice[[]byte]
- func (v ShareView) MarshalJSON() ([]byte, error)
- func (v ShareView) Name() string
- func (v ShareView) Path() string
- func (v *ShareView) UnmarshalJSON(b []byte) error
- func (v ShareView) Valid() bool
Constants ¶
This section is empty.
Variables ¶
var ( // DisallowShareAs forcibly disables sharing as a specific user, only used // for testing. ErrDriveNotEnabled = errors.New("Taildrive not enabled") )
Functions ¶
func AllowShareAs ¶
func AllowShareAs() bool
AllowShareAs reports whether sharing files as a specific user is allowed.
func Clone ¶
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 ¶
func NormalizeShareName ¶
NormalizeShareName normalizes the given share name and returns an error if it contains any disallowed characters.
func ShareViewsEqual ¶
func SharesEqual ¶
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 Taildrive filesystem exposed to local clients. It provides a unified WebDAV interface to remote Taildrive 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. // // Note that this includes both the file server's secret token and its // address, delimited by a pipe |. SetFileServerAddr(addr string) // 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 drive 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 Share ¶
type Share struct { string `json:"name,omitempty"` Path string `json:"path,omitempty"` // 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"` // 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"` }Name
Share configures a folder to be shared through drive.
type ShareView ¶
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) AsStruct ¶
AsStruct returns a clone of the underlying value which aliases no memory with the original.
func (ShareView) MarshalJSON ¶
func (*ShareView) UnmarshalJSON ¶
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package driveimpl provides an implementation of package drive.
|
Package driveimpl provides an implementation of package drive. |
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 drive packages.
|
Package shared contains types and functions shared by different drive packages. |