drive
packageThis package is not in the latest version of its module.
Details
Validgo.mod file
The Go module system was introduced in Go 1.11 and is the official dependency management solution for Go.
Redistributable license
Redistributable licenses place minimal restrictions on how software can be used, modified, and redistributed.
Tagged version
Modules with tagged versions give importers more predictable builds.
Stable version
When a project reaches major version v1 it is considered stable.
- Learn more about best practices
Repository
Links
Documentation¶
Overview¶
Package drive provides a filesystem that allows sharing folders betweenTailscale nodes using WebDAV. The actual implementation of the core Taildrivefunctionality lives in package driveimpl. These packages are separated toallow users of Taildrive to refer to the interfaces without having a harddependency on Taildrive, so that programs which don't actually use Taildrive canavoid 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) MarshalJSONTo(enc *jsontext.Encoder) error
- func (v ShareView) Name() string
- func (v ShareView) Path() string
- func (v *ShareView) UnmarshalJSON(b []byte) error
- func (v *ShareView) UnmarshalJSONFrom(dec *jsontext.Decoder) 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.DisallowShareAs =falseErrDriveNotEnabled =errors.New("Taildrive not enabled")ErrInvalidShareName =errors.New("Share names may only contain the letters a-z, underscore _, parentheses (), or spaces"))
Functions¶
funcAllowShareAs¶
func AllowShareAs()bool
AllowShareAs reports whether sharing files as a specific user is allowed.
funcClone¶
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.
funcCompareShares¶
funcNormalizeShareName¶
NormalizeShareName normalizes the given share name and returns an error ifit contains any disallowed characters.
funcShareViewsEqual¶
funcSharesEqual¶
Types¶
typeFileSystemForLocal¶
type FileSystemForLocal interface {// HandleConn handles connections from local WebDAV clientsHandleConn(connnet.Conn, remoteAddrnet.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(domainstring, remotes []*Remote, transporthttp.RoundTripper)// Close() stops serving the WebDAV contentClose()error}FileSystemForLocal is the Taildrive filesystem exposed to local clients. Itprovides a unified WebDAV interface to remote Taildrive shares on other nodes.
typeFileSystemForRemote¶
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(addrstring)// 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(permissionsPermissions, whttp.ResponseWriter, r *http.Request)// Close() stops serving the WebDAV contentClose()error}FileSystemForRemote is the drive filesystem exposed to remote nodes. Itprovides a unified WebDAV interface to local directories that have beenshared.
typePermission¶
type Permissionuint8
const (PermissionNonePermission =iotaPermissionReadOnlyPermissionReadWrite)
typePermissions¶
type Permissions map[string]Permission
Permissions represents the set of permissions for a given principal to aset of shares.
funcParsePermissions¶
func ParsePermissions(rawGrants [][]byte) (Permissions,error)
ParsePermissions builds a Permissions map from a list of raw grants.
func (Permissions)For¶
func (pPermissions) For(sharestring)Permission
typeShare¶
type Share struct {// Name is how this share appears on remote nodes.Namestring `json:"name,omitempty"`// Path is the path to the directory on this machine that's being shared.Pathstring `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".Asstring `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#4144043BookmarkData []byte `json:"bookmarkData,omitempty"`}Share configures a folder to be shared through drive.
typeShareView¶
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¶
As is the UNIX or Windows username of the local account used for thisshare. File read/write permissions are enforced based on this username.Can be left blank to use the default value of "whoever is running theTailscale GUI".
func (ShareView)AsStruct¶
AsStruct returns a clone of the underlying value which aliases no memory withthe original.
func (ShareView)BookmarkData¶
BookmarkData contains security-scoped bookmark data for the SandboxedMac application. The Sandboxed Mac application gains permission toaccess the Share's folder as a result of a user selecting it in a filepicker. In order to retain access to it across restarts, it needs tohold on to a security-scoped bookmark. That bookmark is stored here. Seehttps://developer.apple.com/documentation/security/app_sandbox/accessing_files_from_the_macos_app_sandbox#4144043
func (ShareView)MarshalJSON¶
MarshalJSON implementsjsonv1.Marshaler.
func (ShareView)MarshalJSONTo¶added inv1.88.0
MarshalJSONTo implementsjsonv2.MarshalerTo.
func (*ShareView)UnmarshalJSON¶
UnmarshalJSON implementsjsonv1.Unmarshaler.
func (*ShareView)UnmarshalJSONFrom¶added inv1.88.0
UnmarshalJSONFrom implementsjsonv2.UnmarshalerFrom.
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. |