跳到主要内容

Claude Cage · 面向 Claude 的隔离开发环境,支持桌面工作台、多账号、远程部署与移动端连接。上游 Lee-xeo/Claude-Cage 完整源码镜像,非灵栈原创;主许可 MIT,第三方组件遵循各自许可。来源:https://github.com/Lee-xeo/Claude-Cage 。手动同步,不附带 Release 安装包。

浏览文件

0011-windows-native-usernet-socket.patch

73 行 · 2.3 KB历史下载
1From: Cage maintainers
2Subject: [PATCH] usernet: listen on native socket paths without URL parsing
3
4On Windows an absolute socket path contains a drive letter and backslashes.
5Constructing unix://C:\\... treats the drive as a URL host and rejects the
6backslashes. The endpoint is always a Unix socket; pass the path directly to
7net.Listen, which supports AF_UNIX on Windows 10 1803 and newer.
8
9diff --git a/pkg/networks/usernet/gvproxy.go b/pkg/networks/usernet/gvproxy.go
10--- a/pkg/networks/usernet/gvproxy.go
11+++ b/pkg/networks/usernet/gvproxy.go
12@@ -20,7 +20,6 @@ import (
13 "time"
14
15 "github.com/balajiv113/fd"
16- "github.com/containers/gvisor-tap-vsock/pkg/transport"
17 "github.com/containers/gvisor-tap-vsock/pkg/types"
18 "github.com/containers/gvisor-tap-vsock/pkg/virtualnetwork"
19 "github.com/miekg/dns"
20@@ -166,7 +165,7 @@ func run(ctx context.Context, g *errgroup.Group, configuration *types.Configuration
21 return err
22 }
23
24- ln, err := transport.Listen(fmt.Sprintf("unix://%s", opts.Endpoint))
25+ ln, err := net.Listen("unix", opts.Endpoint)
26 if err != nil {
27 return err
28 }
29diff --git a/pkg/networks/usernet/endpoint_windows_test.go b/pkg/networks/usernet/endpoint_windows_test.go
30new file mode 100644
31--- /dev/null
32+++ b/pkg/networks/usernet/endpoint_windows_test.go
33@@ -0,0 +1,40 @@
34+//go:build windows
35+
36+// SPDX-FileCopyrightText: Copyright The Lima Authors
37+// SPDX-License-Identifier: Apache-2.0
38+
39+package usernet
40+
41+import (
42+ "context"
43+ "net"
44+ "os"
45+ "path/filepath"
46+ "testing"
47+)
48+
49+func TestNetstackWindowsNativeSocketPaths(t *testing.T) {
50+ // A drive letter, spaces and URL punctuation must remain a file path.
51+ dir, err := os.MkdirTemp("", "cage %23-")
52+ if err != nil {
53+ t.Fatal(err)
54+ }
55+ defer os.RemoveAll(dir)
56+ ctx, cancel := context.WithCancel(context.Background())
57+ defer cancel()
58+ endpoint := filepath.Join(dir, "ep.sock")
59+ qemu := filepath.Join(dir, "qemu.sock")
60+ if err := StartGVisorNetstack(ctx, &GVisorNetstackOpts{
61+ MTU: 1500, Endpoint: endpoint, QemuSocket: qemu,
62+ Subnet: "192.168.127.0/24", Async: true,
63+ }); err != nil {
64+ t.Fatal(err)
65+ }
66+ for _, path := range []string{endpoint, qemu} {
67+ conn, err := net.Dial("unix", path)
68+ if err != nil {
69+ t.Fatalf("cannot connect to native socket %q: %v", path, err)
70+ }
71+ conn.Close()
72+ }
73+}