taildrop

package
v1.84.3 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 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

View Source
const SafDirectoryPrefix = "content://"

safDirectoryPrefix is used to determine if the directory is managed via SAF.

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 {

	// FileOps abstracts platform-specific file operations needed for file transfers.
	// This is currently being used for Android to use the Storage Access Framework.
	FileOps FileOps
	// 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 {
	OpenFileWriter(filename string) (io.WriteCloser, string, error)

	// RenamePartialFile finalizes a partial file.
	// It returns the new SAF URI as a string and an error.
	RenamePartialFile(partialUri, targetDirUri, targetName string) (string, error)
}

FileOps defines platform-specific file operations.

type PutMode

type PutMode int

PutMode controls how Manager.PutFile writes files to storage.

PutModeDirect    – write files directly to a filesystem path (default).
PutModeAndroidSAF – use Android’s Storage Access Framework (SAF), where
                      the OS manages the underlying directory permissions.
const (
	PutModeDirect PutMode = iota
	PutModeAndroidSAF
)

Jump to

Keyboard shortcuts

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