Movatterモバイル変換


[0]ホーム

URL:


drive

package
v1.92.2Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2025 License:BSD-3-ClauseImports:11Imported by:9

Details

Repository

github.com/tailscale/tailscale

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

Constants

This section is empty.

Variables

View Source
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

func Clone(dst, srcany)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.

funcCompareShares

func CompareShares(a, b *Share)int

funcNormalizeShareName

func NormalizeShareName(namestring) (string,error)

NormalizeShareName normalizes the given share name and returns an error ifit contains any disallowed characters.

funcShareViewsEqual

func ShareViewsEqual(a, bShareView)bool

funcSharesEqual

func SharesEqual(a, b *Share)bool

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

typeRemote

type Remote struct {NamestringURL       func()stringAvailable func()bool}

Remote represents a remote Taildrive node.

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.

func (*Share)Clone

func (src *Share) Clone() *Share

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

func (*Share)View

func (p *Share) View()ShareView

View returns a read-only view of Share.

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

func (vShareView) As()string

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

func (vShareView) AsStruct() *Share

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

func (ShareView)BookmarkData

func (vShareView) BookmarkData()views.ByteSlice[[]byte]

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

func (vShareView) MarshalJSON() ([]byte,error)

MarshalJSON implementsjsonv1.Marshaler.

func (ShareView)MarshalJSONToadded inv1.88.0

func (vShareView) MarshalJSONTo(enc *jsontext.Encoder)error

MarshalJSONTo implementsjsonv2.MarshalerTo.

func (ShareView)Name

func (vShareView) Name()string

Name is how this share appears on remote nodes.

func (ShareView)Path

func (vShareView) Path()string

Path is the path to the directory on this machine that's being shared.

func (*ShareView)UnmarshalJSON

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

UnmarshalJSON implementsjsonv1.Unmarshaler.

func (*ShareView)UnmarshalJSONFromadded inv1.88.0

func (v *ShareView) UnmarshalJSONFrom(dec *jsontext.Decoder)error

UnmarshalJSONFrom implementsjsonv2.UnmarshalerFrom.

func (ShareView)Valid

func (vShareView) Valid()bool

Valid reports whether v's underlying value is non-nil.

Source Files

View all Source files

Directories

PathSynopsis
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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f orF : Jump to
y orY : Canonical URL
go.dev uses cookies from Google to deliver and enhance the quality of its services and to analyze traffic.Learn more.

[8]ページ先頭

©2009-2025 Movatter.jp