PasteFerry (隔空贴): clipboard and file sync across macOS, Windows and Linux. Direct-first, end-to-end encrypted. Optional official access: no server to host. Independent self-hosting remains available.
Dart airdrop-alternativeclipboardclipboard-sharingclipboard-synccopy-pastecross-platformend-to-end-encryptionfile-syncfile-transferfluttergolanglinuxmacosnat-traversalp2pself-hostedtailscaleuniversal-clipboardwebrtcwindows
feat(tools): list nearby devices and avatars in the CLI
baiyuze3f28e8920154
diff --git a/client-core/cmd/pasteferry-cli/friends.go b/client-core/cmd/pasteferry-cli/friends.goindex 9087b57..b2334d1 100644--- a/client-core/cmd/pasteferry-cli/friends.go+++ b/client-core/cmd/pasteferry-cli/friends.go@@ -50,6 +50,9 @@ func showFriends(ctx context.Context, c pb.DaemonServiceClient) error {if f.GetAutoAccept() {extra += " 自动接收"}+ if f.GetHasAvatar() {+ extra += fmt.Sprintf(" 头像 %x", f.GetAvatarHash()[:min(4, len(f.GetAvatarHash()))])+ }if f.GetReachability() != "" {extra += " " + f.GetReachability()}@@ -258,3 +261,24 @@ func setReceiveFrom(ctx context.Context, c pb.DaemonServiceClient, v string) errfmt.Println(out.GetReceiveFrom())return nil}++// showStrangers 列出附近开着「所有人」的陌生设备(发文件时用它的 ID:lan:实例名)+func showStrangers(ctx context.Context, c pb.DaemonServiceClient) error {+ ctx, cancel := context.WithTimeout(ctx, 5*time.Second)+ defer cancel()+ stream, err := c.WatchStrangers(ctx, &pb.Empty{})+ if err != nil {+ return err+ }+ list, err := stream.Recv()+ if err != nil {+ return err+ }+ if len(list.GetStrangers()) == 0 {+ fmt.Println("(附近没有开着「所有人」的设备)")+ }+ for _, s := range list.GetStrangers() {+ fmt.Printf("%-16s %-8s %s\n", s.GetDisplayName(), s.GetPlatform(), s.GetId())+ }+ return nil+}diff --git a/client-core/cmd/pasteferry-cli/main.go b/client-core/cmd/pasteferry-cli/main.goindex 682d12e..754f2ea 100644--- a/client-core/cmd/pasteferry-cli/main.go+++ b/client-core/cmd/pasteferry-cli/main.go@@ -120,6 +120,8 @@ func run(cmd, dataDir string) error {return setName(ctx, client, flag.Arg(1))case "avatar":return setAvatar(ctx, client, flag.Arg(1))+ case "strangers":+ return showStrangers(ctx, client)case "receive-from":return setReceiveFrom(ctx, client, flag.Arg(1))default:diff --git a/client-core/cmd/pasteferry-cli/send.go b/client-core/cmd/pasteferry-cli/send.goindex 8007078..447dbbc 100644--- a/client-core/cmd/pasteferry-cli/send.go+++ b/client-core/cmd/pasteferry-cli/send.go@@ -101,7 +101,7 @@ func sendFiles(ctx context.Context, c pb.DaemonServiceClient, args []string) errreturn nilcase "failed", "declined", "cancelled", "expired":fmt.Println()- return fmt.Errorf("没有发出:%s", u.GetError())+ return fmt.Errorf("没有发出:%s", declineText(u.GetError()))case "interrupted", "paused":fmt.Println("\n已中断,重新连上后会自动继续(pasteferry-cli transfers 查看)")return nil@@ -116,7 +116,7 @@ func transferLine(t *pb.Transfer) string {case "asking":return "等待对方接受…"case "declined":- return "declined " + t.GetError()+ return declineText(t.GetError())case "active":pct := 0.0if t.GetTotalBytes() > 0 {@@ -199,3 +199,18 @@ func cancelTransfer(ctx context.Context, c pb.DaemonServiceClient, prefix stringfmt.Println("已取消")return nil}++// declineText 把对方不收的原因说成人话;其他错误原样返回+func declineText(reason string) string {+ switch reason {+ case "declined":+ return "对方拒绝了"+ case "timeout":+ return "对方没有回应"+ case "not_allowed":+ return "对方没有允许你发文件"+ case "rate_limited":+ return "被拒绝太多次,稍后再试"+ }+ return reason+}