taildrop

package
v1.92.4 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2025 License: BSD-3-Clause Imports: 55 Imported by: 0

Documentation

Overview

Package taildrop registers the taildrop (file sending) feature.

Package taildrop contains the implementation of the Taildrop functionality including sending and retrieving files. This package does not validate permissions, the caller should be responsible for ensuring correct authorization.

For related documentation see: http://go/taildrop-how-does-it-work

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoTaildrop      = errors.New("Taildrop disabled; no storage directory")
	ErrInvalidFileName = errors.New("invalid filename")
	ErrFileExists      = errors.New("file already exists")
	ErrNotAccessible   = errors.New("Taildrop folder not configured or accessible")
)

Functions

This section is empty.

Types

type Extension

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

Extension implements Taildrop.

func (*Extension) AwaitWaitingFiles

func (e *Extension) AwaitWaitingFiles(ctx context.Context) ([]apitype.WaitingFile, error)

AwaitWaitingFiles is like WaitingFiles but blocks while ctx is not done, waiting for any files to be available.

On return, exactly one of the results will be non-empty or non-nil, respectively.

func (*Extension) Clock

func (e *Extension) Clock() tstime.Clock

func (*Extension) DeleteFile

func (e *Extension) DeleteFile(name string) error

func (*Extension) FileTargets

func (e *Extension) FileTargets() ([]*apitype.FileTarget, error)

FileTargets lists nodes that the current node can send files to.

func (*Extension) Init

func (e *Extension) Init(h ipnext.Host) error

func (*Extension) Name

func (e *Extension) Name() string

func (*Extension) OpenFile

func (e *Extension) OpenFile(name string) (rc io.ReadCloser, size int64, err error)

func (*Extension) SetDirectFileRoot

func (e *Extension) SetDirectFileRoot(root string)

SetDirectFileRoot sets the directory where received files are written.

This must be called before Tailscale is started.

func (*Extension) SetFileOps

func (e *Extension) SetFileOps(fileOps FileOps)

SetFileOps sets the platform specific file operations. This is used to call Android's Storage Access Framework APIs.

func (*Extension) Shutdown

func (e *Extension) Shutdown() error

func (*Extension) WaitingFiles

func (e *Extension) WaitingFiles() ([]apitype.WaitingFile, error)

type FileOps

type FileOps interface {
	// OpenWriter creates or truncates a file named relative to the receiver's root,
	// seeking to the specified offset. If the file does not exist, it is created with mode perm
	// on platforms that support it.
	//
	// It returns an [io.WriteCloser] and the file's absolute path, or an error.
	// This call may block. Callers should avoid holding locks when calling OpenWriter.
	OpenWriter(name string, offset int64, perm os.FileMode) (wc io.WriteCloser, path string, err error)

	// Remove deletes a file or directory relative to the receiver's root.
	// It returns [io.ErrNotExist] if the file or directory does not exist.
	Remove(name string) error

	// Rename atomically renames oldPath to a new file named newName,
	// returning the full new path or an error.
	Rename(oldPath, newName string) (newPath string, err error)

	// ListFiles returns just the basenames of all regular files
	// in the root directory.
	ListFiles() ([]string, error)

	// Stat returns the FileInfo for the given name or an error.
	Stat(name string) (fs.FileInfo, error)

	// OpenReader opens the given basename for the given name or an error.
	OpenReader(name string) (io.ReadCloser, error)
}

FileOps abstracts over both local‐FS paths and Android SAF URIs.