跳到主要内容

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

浏览文件

npipe_windows.go

42 行 · 1005 B历史下载
1package sshclient
2
3import (
4 "fmt"
5 "net"
6 "net/url"
7 "os/user"
8 "strings"
9
10 winio "github.com/Microsoft/go-winio"
11 "github.com/sirupsen/logrus"
12)
13
14// https://docs.microsoft.com/en-us/windows-hardware/drivers/kernel/sddl-for-device-objects
15// Allow built-in admins and system/kernel components
16const SddlDevObjSysAllAdmAll = "D:P(A;;GA;;;SY)(A;;GA;;;BA)"
17
18func ListenNpipe(socketURI *url.URL) (net.Listener, error) {
19 user, err := user.Current()
20 if err != nil {
21 return nil, err
22 }
23
24 // Also allow current user
25 sddl := fmt.Sprintf("%s(A;;GA;;;%s)", SddlDevObjSysAllAdmAll, user.Uid)
26 config := winio.PipeConfig{
27 SecurityDescriptor: sddl,
28 MessageMode: true,
29 InputBufferSize: 65536,
30 OutputBufferSize: 65536,
31 }
32 path := strings.ReplaceAll(socketURI.Path, "/", "\\")
33
34 listener, err := winio.ListenPipe(path, &config)
35 if err != nil {
36 return listener, fmt.Errorf("error listening on socket: %s: %w", socketURI, err)
37 }
38
39 logrus.Info("Listening on: " + path)
40
41 return listener, nil
42}