跳到主要内容

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

浏览文件

gate_ipv6_test.go

49 行 · 1.3 KB历史下载
1package cage
2
3import (
4 "encoding/binary"
5 "net/netip"
6 "testing"
7)
8
9func TestMacIPv6DropRequiresThisCheckingInstance(t *testing.T) {
10 g := fixtureGate(t)
11 if err := g.BeginCheck(); err != nil {
12 t.Fatal(err)
13 }
14 s := g.Status()
15 payload := []byte(MacIPv6ProbePrefix + s.RunID + " " + s.CheckID)
16 packet := make([]byte, 48+len(payload))
17 packet[0] = 0x60
18 packet[6] = 17
19 packet[7] = 1
20 binary.BigEndian.PutUint16(packet[4:6], uint16(8+len(payload)))
21 a := netip.MustParseAddr("fe80::1").As16()
22 copy(packet[8:24], a[:])
23 a = netip.MustParseAddr("ff02::2").As16()
24 copy(packet[24:40], a[:])
25 binary.BigEndian.PutUint16(packet[42:44], MacIPv6ProbePort)
26 binary.BigEndian.PutUint16(packet[44:46], uint16(8+len(payload)))
27 packet[47] = 1
28 copy(packet[48:], payload)
29 for _, position := range []int{0, 5, 6, 7, 8, 24, 42, 45, 48, len(packet) - 1} {
30 wrong := append([]byte(nil), packet...)
31 wrong[position] ^= 0xff
32 g.ObserveDroppedIPv6(wrong)
33 if g.Status().IPv6LinkProbeCheck != "" {
34 t.Fatalf("unrelated datagram accepted (byte %d)", position)
35 }
36 }
37 g.ObserveDroppedIPv6(packet)
38 if g.Status().IPv6LinkProbeCheck != s.CheckID {
39 t.Fatal("matching received datagram not recorded")
40 }
41 g.Close("reset")
42 if err := g.BeginCheck(); err != nil {
43 t.Fatal(err)
44 }
45 g.ObserveDroppedIPv6(packet)
46 if g.Status().IPv6LinkProbeCheck != "" {
47 t.Fatal("replayed earlier check")
48 }
49}