summaryrefslogtreecommitdiffhomepage
path: root/ipn
diff options
context:
space:
mode:
Diffstat (limited to 'ipn')
-rw-r--r--ipn/backend.go22
-rw-r--r--ipn/ipnlocal/local.go21
2 files changed, 22 insertions, 21 deletions
diff --git a/ipn/backend.go b/ipn/backend.go
index ad5dbd4bf..1cabc5788 100644
--- a/ipn/backend.go
+++ b/ipn/backend.go
@@ -6,10 +6,10 @@ package ipn
import (
"fmt"
"strings"
- "time"
"tailscale.com/ipn/ipnstate"
"tailscale.com/tailcfg"
+ "tailscale.com/taildrop"
"tailscale.com/types/empty"
"tailscale.com/types/key"
"tailscale.com/types/netmap"
@@ -109,7 +109,7 @@ type Notify struct {
// of being transferred.
//
// Deprecated: use LocalClient.AwaitWaitingFiles instead.
- IncomingFiles []PartialFile `json:",omitempty"`
+ IncomingFiles []taildrop.PartialFile `json:",omitempty"`
// LocalTCPPort, if non-nil, informs the UI frontend which
// (non-zero) localhost TCP port it's listening on.
@@ -164,24 +164,6 @@ func (n Notify) String() string {
return s[0:len(s)-1] + "}"
}
-// PartialFile represents an in-progress file transfer.
-type PartialFile struct {
- Name string // e.g. "foo.jpg"
- Started time.Time // time transfer started
- DeclaredSize int64 // or -1 if unknown
- Received int64 // bytes copied thus far
-
- // PartialPath is set non-empty in "direct" file mode to the
- // in-progress '*.partial' file's path when the peerapi isn't
- // being used; see LocalBackend.SetDirectFileRoot.
- PartialPath string `json:",omitempty"`
-
- // Done is set in "direct" mode when the partial file has been
- // closed and is ready for the caller to rename away the
- // ".partial" suffix.
- Done bool `json:",omitempty"`
-}
-
// StateKey is an opaque identifier for a set of LocalBackend state
// (preferences, private keys, etc.). It is also used as a key for
// the various LoginProfiles that the instance may be signed into.
diff --git a/ipn/ipnlocal/local.go b/ipn/ipnlocal/local.go
index c4ed545a7..1357e7304 100644
--- a/ipn/ipnlocal/local.go
+++ b/ipn/ipnlocal/local.go
@@ -240,6 +240,7 @@ type LocalBackend struct {
peerAPIServer *peerAPIServer // or nil
peerAPIListeners []*peerAPIListener
loginFlags controlclient.LoginFlags
+ incomingFiles map[*taildrop.IncomingFile]bool
fileWaiters set.HandleSet[context.CancelFunc] // of wake-up funcs
notifyWatchers set.HandleSet[*watchSession]
lastStatusTime time.Time // status.AsOf value of the last processed status update
@@ -2278,7 +2279,12 @@ func (b *LocalBackend) sendFileNotify() {
// Make sure we always set n.IncomingFiles non-nil so it gets encoded
// in JSON to clients. They distinguish between empty and non-nil
// to know whether a Notify should be able about files.
- n.IncomingFiles = apiSrv.taildrop.IncomingFiles()
+
+ //// n.IncomingFiles = apiSrv.taildrop.IncomingFiles()
+ n.IncomingFiles = make([]taildrop.PartialFile, 0)
+ for f := range b.incomingFiles {
+ n.IncomingFiles = append(n.IncomingFiles, f.PartialFile())
+ }
b.mu.Unlock()
sort.Slice(n.IncomingFiles, func(i, j int) bool {
@@ -4657,6 +4663,19 @@ func (b *LocalBackend) SetDNS(ctx context.Context, name, value string) error {
return cc.SetDNS(ctx, req)
}
+func (b *LocalBackend) registerIncomingFile(inf *taildrop.IncomingFile, active bool) {
+ b.mu.Lock()
+ defer b.mu.Unlock()
+ if b.incomingFiles == nil {
+ b.incomingFiles = make(map[*taildrop.IncomingFile]bool)
+ }
+ if active {
+ b.incomingFiles[inf] = true
+ } else {
+ delete(b.incomingFiles, inf)
+ }
+}
+
func peerAPIPorts(peer tailcfg.NodeView) (p4, p6 uint16) {
svcs := peer.Hostinfo().Services()
for i := range svcs.LenIter() {