跳到主要内容

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

浏览文件

proxy_interface.go

58 行 · 1.5 KB历史下载
1package workbench
2
3import (
4 "path/filepath"
5
6 "github.com/sylvinus/agent-vm/internal/managedproxy"
7)
8
9var physicalProxyInterface = managedproxy.PhysicalInterface
10
11// The lifecycle lock is held by monitorNetwork. Schedule a regular job so a
12// user stop can cancel recovery and pause can still revoke the gate immediately.
13func (s *Server) monitorProxyInterface() {
14 if s.busy() {
15 return
16 }
17 cfg, err := loadConfig(s.configPath)
18 if err != nil || cfg.RequireManagedProxy(s.profile) != nil {
19 return
20 }
21 name, err := physicalProxyInterface(s.lifetimeContext())
22 if err != nil {
23 _ = s.closeProxyGate(err.Error())
24 s.mu.Lock()
25 s.safety.monitorError = err.Error()
26 s.proxyNetworkLost = true
27 s.mu.Unlock()
28 return
29 }
30 s.mu.Lock()
31 lost := s.proxyNetworkLost
32 s.mu.Unlock()
33 bound, err := managedproxy.BoundInterface(filepath.Join(managedproxy.Dir(s.profile), "config.yaml"))
34 if err != nil || (bound == name && !lost) {
35 return
36 }
37 // Revoke the previous report before the asynchronous recovery can start.
38 if err := s.closeProxyGate("物理网卡已变化,正在重新绑定代理并检查出口"); err != nil {
39 return
40 }
41 s.mu.Lock()
42 s.proxyNetworkLost = false
43 s.mu.Unlock()
44 _, _ = s.submitJob("proxy-network", s.rebindProxyInterface)
45}
46
47func (s *Server) rebindProxyInterface() error {
48 s.setMessage("正在识别物理网卡并重新绑定代理…")
49 cfg, err := loadConfig(s.configPath)
50 if err != nil {
51 return err
52 }
53 p, err := managedproxy.Applied(s.profile, cfg.ProxyURL, cfg.ProxyRevision)
54 if err != nil {
55 return err
56 }
57 return s.applyProxy(p, cfg, nil)
58}