跳到主要内容

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

浏览文件

interface_linux_test.go

31 行 · 1.1 KB历史下载
1package managedproxy
2
3import "testing"
4
5func TestLinuxPhysicalRouteSkipsTUNAndUsesLowestMetric(t *testing.T) {
6 const routes = `Iface Destination Gateway Flags RefCnt Use Metric Mask MTU Window IRTT
7tun0 00000000 00000000 0001 0 0 0 00000000 0 0 0
8ens5 00000000 0100000A 0003 0 0 100 00000000 0 0 0
9eth1 00000000 0100000A 0003 0 0 20 00000000 0 0 0
10eth2 00000000 0100000A 0203 0 0 1 00000000 0 0 0
11eth3 00000000 0100000A 0002 0 0 1 00000000 0 0 0
12eth4 00000000 0100000A 0003 0 0 1 0000FFFF 0 0 0
13`
14 for _, tc := range []struct {
15 name string
16 usable map[string]bool
17 want string
18 }{
19 {"physical metric", map[string]bool{"ens5": true, "eth1": true, "eth2": true, "eth3": true, "eth4": true}, "eth1"},
20 {"cloud virtio", map[string]bool{"ens5": true}, "ens5"},
21 {"disconnected physical interfaces", map[string]bool{}, ""},
22 {"reject and inactive routes", map[string]bool{"eth2": true, "eth3": true, "eth4": true}, ""},
23 } {
24 t.Run(tc.name, func(t *testing.T) {
25 got, err := selectLinuxPhysicalInterface(routes, tc.usable)
26 if got != tc.want || (err != nil) != (tc.want == "") {
27 t.Fatalf("got %q, %v; want %q", got, err, tc.want)
28 }
29 })
30 }
31}