跳到主要内容

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

浏览文件

control_windows.go

31 行 · 856 B历史下载
1// SPDX-FileCopyrightText: Copyright The Lima Authors
2// SPDX-License-Identifier: Apache-2.0
3
4package portfwd
5
6import (
7 "errors"
8 "syscall"
9
10 "golang.org/x/sys/windows"
11)
12
13// soExclusiveAddrUse is SO_EXCLUSIVEADDRUSE, ~SO_REUSEADDR in winsock2.h. On
14// Windows, SO_REUSEADDR lets a socket bind an address another program is
15// listening on, and take its connections: exclusive use is what other systems
16// do by default.
17const soExclusiveAddrUse = ^windows.SO_REUSEADDR
18
19func Control(_, _ string, c syscall.RawConn) (err error) {
20 controlErr := c.Control(func(fd uintptr) {
21 err = windows.SetsockoptInt(windows.Handle(int(fd)), windows.SOL_SOCKET, soExclusiveAddrUse, 1)
22 })
23 if controlErr != nil {
24 err = controlErr
25 }
26 return err
27}
28
29func addrInUse(err error) bool {
30 return errors.Is(err, windows.WSAEADDRINUSE) || errors.Is(err, windows.WSAEACCES)
31}