share

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnsureUnique

func EnsureUnique(dir, name string) (string, error)

EnsureUnique finds a non-conflicting filename in the destination directory.

func ReceiveSideChannel

func ReceiveSideChannel(ctx context.Context, ip net.IP, port int, size int64, dest string, tlsConfig *tls.Config, onProgress func(int64, int64), logger *zap.Logger) error

ReceiveSideChannel connects to the peer's TLS port and streams the payload to a local file. It ensures no memory is buffered by using io.Copy with an io.LimitReader. KDE Connect requires TLS for file transfers using the same certificates as the main connection.

func SanitizeFilename

func SanitizeFilename(name string) string

SanitizeFilename strips path components and prevents traversal.

func SendSideChannel

func SendSideChannel(ctx context.Context, filePath string, tlsConfig *tls.Config, expectedDeviceID string, onProgress func(int64, int64), logger *zap.Logger) (int, error)

SendSideChannel starts a TLS listener on a random port and streams a file to the first connecting peer. KDE Connect requires TLS for file transfers using the same certificates as the main connection.

Types

type ShareBody

type ShareBody struct {
	Filename         string `json:"filename"`
	NumberOfFiles    int    `json:"numberOfFiles,omitempty"`
	TotalPayloadSize int64  `json:"totalPayloadSize,omitempty"`
	Text             string `json:"text,omitempty"`
	Url              string `json:"url,omitempty"`
}

ShareBody represents the body of a kdeconnect.share.request packet.

type SharePlugin

type SharePlugin struct {
	DownloadDir string
	TLSConfig   *tls.Config
	Logger      *zap.Logger
	// contains filtered or unexported fields
}

SharePlugin handles file transfers.

func NewSharePlugin

func NewSharePlugin(downloadDir string, tlsConfig *tls.Config, bus *events.Bus, logger *zap.Logger) *SharePlugin

NewSharePlugin creates a new SharePlugin instance.

func (*SharePlugin) Handle

func (p *SharePlugin) Handle(ctx context.Context, dev device.Sender, pkt *protocol.Packet) error

Handle processes incoming share requests by initiating a side-channel transfer.

func (*SharePlugin) IncomingTypes

func (p *SharePlugin) IncomingTypes() []string

IncomingTypes returns the packet types this plugin handles.

func (*SharePlugin) Name

func (p *SharePlugin) Name() string

func (*SharePlugin) OnConnect

func (p *SharePlugin) OnConnect(dev device.Sender)

func (*SharePlugin) OnDisconnect

func (p *SharePlugin) OnDisconnect(dev device.Sender)

func (*SharePlugin) OutgoingTypes

func (p *SharePlugin) OutgoingTypes() []string

OutgoingTypes returns the packet types this plugin may send.

func (*SharePlugin) SendFile

func (p *SharePlugin) SendFile(ctx context.Context, dev device.Sender, filePath string) error

SendFile prepares and initiates an outbound file transfer.

func (*SharePlugin) Timeout

func (p *SharePlugin) Timeout() time.Duration

Jump to

Keyboard shortcuts

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