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
fix(core): allow the fast link between two peers on one computer
baiyuze7a4e3b1b8333
diff --git a/client-core/internal/transport/p2p/lanaddr_test.go b/client-core/internal/transport/p2p/lanaddr_test.goindex c85afa4..a90302e 100644--- a/client-core/internal/transport/p2p/lanaddr_test.go+++ b/client-core/internal/transport/p2p/lanaddr_test.go@@ -5,7 +5,8 @@ import ("testing")-// 本机两端直连(host 对 host):LANAddr 给出一个本机网卡上的真实地址,能在上面监听+// 本机两端直连(host 对 host):LANAddr 给出一个能在上面监听的本机地址。+// CI 的机器上两端经回环地址连,这时给的也是回环地址func TestLANAddrOnDirectConnection(t *testing.T) {alice, bob := connectPair(t)for _, c := range []struct {@@ -16,7 +17,7 @@ func TestLANAddrOnDirectConnection(t *testing.T) {if !ok {t.Fatalf("对 %s 应当是局域网直连", c.peer)}- if addr.IsLoopback() || addr.IsUnspecified() {+ if addr.IsUnspecified() {t.Fatalf("地址不能是 %v", addr)}ln, err := net.Listen("tcp", net.JoinHostPort(addr.String(), "0"))diff --git a/client-core/internal/transport/p2p/peer.go b/client-core/internal/transport/p2p/peer.goindex d43015e..306119a 100644--- a/client-core/internal/transport/p2p/peer.go+++ b/client-core/internal/transport/p2p/peer.go@@ -249,7 +249,7 @@ func (p *Peer) LANAddr() (netip.Addr, bool) {return netip.Addr{}, false}remote, err := netip.ParseAddr(pair.Remote.Address)- if err != nil || remote.IsLoopback() || remote.IsUnspecified() {+ if err != nil || remote.IsUnspecified() {p.log.Info("对端地址不能用来开快速通道", "remote", pair.Remote.Address)return netip.Addr{}, false}@@ -269,7 +269,8 @@ func sourceAddrFor(dst netip.Addr) (netip.Addr, error) {}defer c.Close()local := c.LocalAddr().(*net.UDPAddr).AddrPort().Addr().Unmap()- if !local.IsValid() || local.IsLoopback() || local.IsUnspecified() {+ // 两端在同一台电脑上时(对端是回环地址),回环地址也能用+ if !local.IsValid() || local.IsUnspecified() || (local.IsLoopback() && !dst.IsLoopback()) {return netip.Addr{}, errors.New("没有可用的本机地址")}return local, nil