跳到主要内容

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

浏览文件

fxp_test.go

85 行 · 2.0 KB历史下载
1package sshfx
2
3import (
4 "bufio"
5 "regexp"
6 "strconv"
7 "strings"
8 "testing"
9)
10
11// This string data is copied verbatim from https://filezilla-project.org/specs/draft-ietf-secsh-filexfer-13.txt
12// except where commented that it was taken from a different source.
13var fxpStandardsText = `
14SSH_FXP_INIT 1
15SSH_FXP_VERSION 2
16SSH_FXP_OPEN 3
17SSH_FXP_CLOSE 4
18SSH_FXP_READ 5
19SSH_FXP_WRITE 6
20SSH_FXP_LSTAT 7
21SSH_FXP_FSTAT 8
22SSH_FXP_SETSTAT 9
23SSH_FXP_FSETSTAT 10
24SSH_FXP_OPENDIR 11
25SSH_FXP_READDIR 12
26SSH_FXP_REMOVE 13
27SSH_FXP_MKDIR 14
28SSH_FXP_RMDIR 15
29SSH_FXP_REALPATH 16
30SSH_FXP_STAT 17
31SSH_FXP_RENAME 18
32SSH_FXP_READLINK 19
33SSH_FXP_SYMLINK 20 // Deprecated in filexfer-13 added from filexfer-02
34SSH_FXP_LINK 21
35SSH_FXP_BLOCK 22
36SSH_FXP_UNBLOCK 23
37
38SSH_FXP_STATUS 101
39SSH_FXP_HANDLE 102
40SSH_FXP_DATA 103
41SSH_FXP_NAME 104
42SSH_FXP_ATTRS 105
43
44SSH_FXP_EXTENDED 200
45SSH_FXP_EXTENDED_REPLY 201
46`
47
48func TestFxpNames(t *testing.T) {
49 whitespace := regexp.MustCompile(`[[:space:]]+`)
50
51 scan := bufio.NewScanner(strings.NewReader(fxpStandardsText))
52
53 for scan.Scan() {
54 line := scan.Text()
55 if i := strings.Index(line, "//"); i >= 0 {
56 line = line[:i]
57 }
58
59 line = strings.TrimSpace(line)
60 if line == "" {
61 continue
62 }
63
64 fields := whitespace.Split(line, 2)
65 if len(fields) < 2 {
66 t.Fatalf("unexpected standards text line: %q", line)
67 }
68
69 name, value := fields[0], fields[1]
70 n, err := strconv.Atoi(value)
71 if err != nil {
72 t.Fatal("unexpected error:", err)
73 }
74
75 fxp := PacketType(n)
76
77 if got := fxp.String(); got != name {
78 t.Errorf("fxp name mismatch for %d: got %q, but want %q", n, got, name)
79 }
80 }
81
82 if err := scan.Err(); err != nil {
83 t.Fatal("unexpected error:", err)
84 }
85}