Skip to content

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.

chore(core): show whether each device receives files in the CLI

baiyuze080814b238ad
diff --git a/client-core/cmd/pasteferry-cli/main.go b/client-core/cmd/pasteferry-cli/main.go
index 0f43295..80a030f 100644
--- a/client-core/cmd/pasteferry-cli/main.go
+++ b/client-core/cmd/pasteferry-cli/main.go
@@ -130,13 +130,31 @@ func showDevices(ctx context.Context, c pb.DaemonServiceClient) error {
return nil
}
for _, p := range resp.GetPeers() {
- fmt.Printf("%-16s %-10s %-8s %s\n",
+ fmt.Printf("%-16s %-10s %-8s %-10s %s\n",
p.GetName(), p.GetPlatform(),
- connectionLabel(p), p.GetPublicKeyFingerprint())
+ connectionLabel(p), receiveLabel(p), p.GetPublicKeyFingerprint())
}
return nil
}
+// receiveLabel 是对方能不能收隔空传送,后面带上它声明的版本号。
+// 还没收到它的功能声明时只能说「未知」,不能当成旧版本
+func receiveLabel(d *pb.Device) string {
+ label := "收文件"
+ switch {
+ case !d.GetFeaturesKnown() && !d.GetReceivesFiles():
+ return "未知"
+ case !d.GetReceivesFiles():
+ return "需要更新"
+ case d.GetReceiveDisabled():
+ label = "不收文件"
+ }
+ if v := d.GetAppVersion(); v != "" {
+ label += " " + v
+ }
+ return label
+}
+
// connectionLabel 区分直连与中转,便于排查网络问题:
// 一直显示「中转」说明 NAT 打洞没成功,走的是服务器带宽。
func connectionLabel(d *pb.Device) string {