mirror of
https://github.com/tailscale/tailscale.git
synced 2025-10-10 09:45:08 +00:00
ipn{,/ipnlocal}, client/tailscale: move Taildrop recv notifications to LocalAPI HTTP method
Updates #6417 Change-Id: Iec544c477a0e5e9f1c6bf23555afec06255e2e22 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:

committed by
Brad Fitzpatrick

parent
f053f16460
commit
0f7da5c7dc
@@ -7,6 +7,7 @@ package localapi
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"crypto/rand"
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
@@ -680,8 +681,20 @@ func (h *Handler) serveFiles(w http.ResponseWriter, r *http.Request) {
|
||||
http.Error(w, "want GET to list files", 400)
|
||||
return
|
||||
}
|
||||
wfs, err := h.b.WaitingFiles()
|
||||
if err != nil {
|
||||
ctx := r.Context()
|
||||
if s := r.FormValue("waitsec"); s != "" && s != "0" {
|
||||
d, err := strconv.Atoi(s)
|
||||
if err != nil {
|
||||
http.Error(w, "invalid waitsec", http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
deadline := time.Now().Add(time.Duration(d) * time.Second)
|
||||
var cancel context.CancelFunc
|
||||
ctx, cancel = context.WithDeadline(ctx, deadline)
|
||||
defer cancel()
|
||||
}
|
||||
wfs, err := h.b.AwaitWaitingFiles(ctx)
|
||||
if err != nil && ctx.Err() == nil {
|
||||
http.Error(w, err.Error(), 500)
|
||||
return
|
||||
}
|
||||
|
Reference in New Issue
Block a user