send

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package send implements the sending side: collecting local paths and pushing them to a peer.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Send

func Send(ctx context.Context, opts Options) error

Send transfers all entries to the target device.

func TotalSize

func TotalSize(entries []Entry) int64

TotalSize sums the size of all entries.

Types

type Entry

type Entry struct {
	// Path is the local file to read.
	Path string

	// Name is the fileName sent over the wire. For a directory it carries the
	// relative path below the directory, always with "/" separators.
	Name string

	Size     int64
	Modified time.Time
}

Entry is one file to transfer.

func Collect

func Collect(paths []string) ([]Entry, error)

Collect expands the given paths into the files to send.

Files are taken by their base name; directories are walked recursively and contribute "<dir>/<relative path>" names, which is how LocalSend transfers a folder — the protocol has no folder concept of its own.

Symlinks below a directory are skipped: following them risks cycles and sending data from outside the selected tree.

type Options

type Options struct {
	Identity *identity.Identity
	Target   proto.Device
	Entries  []Entry

	// PIN is appended to prepare-upload when the receiver asks for one.
	PIN string

	// Parallel is the number of concurrent uploads. Values below 2 upload one
	// file after another, which keeps the progress display readable.
	Parallel int

	// Port is announced to the receiver so it can send something back. The
	// default port is right whenever a daemon runs on this host, which is the
	// common setup.
	Port int
}

Options configures a transfer.

Jump to

Keyboard shortcuts

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