huaweicloud-devkit 1.0.2-dev.9 → 1.0.2-next.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.agents/plugins/marketplace.json +20 -20
- package/LICENSE +201 -201
- package/README.md +178 -138
- package/README.zh-CN.md +176 -138
- package/bin/setup.cjs +10 -8
- package/integrations/opencode/commands/huaweicloud-doctor.md +14 -14
- package/integrations/opencode/opencode.json +11 -14
- package/integrations/opencode/skills/huaweicloud-core/SKILL.md +32 -32
- package/package.json +60 -44
- package/plugins/huaweicloud-core/.claude-plugin/plugin.json +31 -44
- package/plugins/huaweicloud-core/.codex-plugin/plugin.json +30 -43
- package/plugins/huaweicloud-core/.cursor-plugin/plugin.json +31 -44
- package/plugins/huaweicloud-core/.mcp.json +13 -15
- package/plugins/huaweicloud-core/.workbuddy-plugin/plugin.json +31 -44
- package/plugins/huaweicloud-core/hooks/hooks.json +26 -26
- package/plugins/huaweicloud-core/hooks/huaweicloud-safety.py +136 -136
- package/plugins/huaweicloud-core/safety/policy.json +76 -100
- package/plugins/huaweicloud-core/safety/rules/cloud-risk-rules.json +227 -199
- package/plugins/huaweicloud-core/skills/huawei-apig/SKILL.md +164 -164
- package/plugins/huaweicloud-core/skills/huawei-billing/SKILL.md +48 -48
- package/plugins/huaweicloud-core/skills/huawei-cbr/SKILL.md +50 -50
- package/plugins/huaweicloud-core/skills/huawei-cce/SKILL.md +103 -101
- package/plugins/huaweicloud-core/skills/huawei-cloud-eye/SKILL.md +90 -90
- package/plugins/huaweicloud-core/skills/huawei-cloud-find-skills/SKILL.md +191 -190
- package/plugins/huaweicloud-core/skills/huawei-cloud-find-skills/scripts/search-skills.mjs +171 -124
- package/plugins/huaweicloud-core/skills/huawei-cts/SKILL.md +55 -55
- package/plugins/huaweicloud-core/skills/huawei-dds-dcs/SKILL.md +70 -70
- package/plugins/huaweicloud-core/skills/huawei-deployment/SKILL.md +57 -56
- package/plugins/huaweicloud-core/skills/huawei-dew/SKILL.md +106 -97
- package/plugins/huaweicloud-core/skills/huawei-dew/references/csms-usage.md +36 -29
- package/plugins/huaweicloud-core/skills/huawei-dew/references/kms-usage.md +29 -23
- package/plugins/huaweicloud-core/skills/huawei-ecs/SKILL.md +188 -185
- package/plugins/huaweicloud-core/skills/huawei-ecs/references/create-instance.md +144 -133
- package/plugins/huaweicloud-core/skills/huawei-ecs/references/evs.md +31 -31
- package/plugins/huaweicloud-core/skills/huawei-ecs/references/flavors.md +57 -55
- package/plugins/huaweicloud-core/skills/huawei-ecs/references/troubleshooting.md +52 -52
- package/plugins/huaweicloud-core/skills/huawei-functiongraph/SKILL.md +132 -131
- package/plugins/huaweicloud-core/skills/huawei-functiongraph/references/apig-event-format.md +60 -58
- package/plugins/huaweicloud-core/skills/huawei-functiongraph/references/create-function.md +72 -71
- package/plugins/huaweicloud-core/skills/huawei-functiongraph/references/deploy-workflow.md +119 -119
- package/plugins/huaweicloud-core/skills/huawei-functiongraph/references/triggers.md +142 -142
- package/plugins/huaweicloud-core/skills/huawei-gaussdb/SKILL.md +56 -56
- package/plugins/huaweicloud-core/skills/huawei-getting-started/SKILL.md +69 -65
- package/plugins/huaweicloud-core/skills/huawei-iam/SKILL.md +111 -111
- package/plugins/huaweicloud-core/skills/huawei-iam/references/policy-examples.md +148 -122
- package/plugins/huaweicloud-core/skills/huawei-iam/references/quick-ref.md +56 -56
- package/plugins/huaweicloud-core/skills/huawei-modelarts/SKILL.md +65 -65
- package/plugins/huaweicloud-core/skills/huawei-obs/SKILL.md +134 -127
- package/plugins/huaweicloud-core/skills/huawei-obs/references/bucket-create.md +49 -49
- package/plugins/huaweicloud-core/skills/huawei-obs/references/bucket-lifecycle.md +31 -26
- package/plugins/huaweicloud-core/skills/huawei-obs/references/common-pitfalls.md +101 -100
- package/plugins/huaweicloud-core/skills/huawei-obs/references/single-file-share.md +40 -40
- package/plugins/huaweicloud-core/skills/huawei-obs/references/static-website.md +56 -56
- package/plugins/huaweicloud-core/skills/huawei-rds/SKILL.md +229 -224
- package/plugins/huaweicloud-core/skills/huawei-sandbox/SKILL.md +173 -134
- package/plugins/huaweicloud-core/skills/huawei-smn-dms/SKILL.md +69 -69
- package/plugins/huaweicloud-core/skills/huawei-vpc/SKILL.md +84 -84
- package/plugins/huaweicloud-core/skills/huawei-vpc/references/network.md +77 -76
- package/plugins/huaweicloud-core/skills/huawei-vpc/references/security-group.md +60 -59
- package/plugins/huaweicloud-core/skills/huawei-vpc/references/subnet.md +50 -50
- package/plugins/huaweicloud-core/skills/huawei-waf-aad/SKILL.md +63 -63
- package/plugins/huaweicloud-core/skills/huaweicloud-api-and-sdk/SKILL.md +56 -56
- package/plugins/huaweicloud-core/skills/huaweicloud-api-and-sdk/agents/openai.yaml +4 -4
- package/plugins/huaweicloud-core/skills/huaweicloud-capability-discovery/SKILL.md +56 -47
- package/plugins/huaweicloud-core/skills/huaweicloud-capability-discovery/agents/openai.yaml +4 -4
- package/plugins/huaweicloud-core/skills/huaweicloud-cli-and-auth/SKILL.md +138 -128
- package/plugins/huaweicloud-core/skills/huaweicloud-cli-and-auth/agents/openai.yaml +4 -4
- package/plugins/huaweicloud-core/skills/huaweicloud-core/SKILL.md +111 -96
- package/plugins/huaweicloud-core/skills/huaweicloud-core/agents/openai.yaml +4 -4
- package/plugins/huaweicloud-core/skills/huaweicloud-core/references/report-issue.md +20 -20
- package/plugins/huaweicloud-core/skills/huaweicloud-core/references/select.md +30 -28
- package/plugins/huaweicloud-core/skills/huaweicloud-safety/SKILL.md +59 -60
- package/plugins/huaweicloud-core/skills/huaweicloud-safety/agents/openai.yaml +4 -4
- package/plugins/huaweicloud-core/skills/huaweicloud-troubleshooting/SKILL.md +83 -83
- package/plugins/huaweicloud-core/skills/huaweicloud-troubleshooting/agents/openai.yaml +4 -4
- package/plugins/huaweicloud-core/src/auth/agent-registration.mjs +54 -1
- package/plugins/huaweicloud-core/src/auth/credentials.mjs +103 -95
- package/plugins/huaweicloud-core/src/auth/service.mjs +63 -63
- package/plugins/huaweicloud-core/src/data/icons-manifest.v1.json +3517 -0
- package/plugins/huaweicloud-core/src/hcloud-cli.mjs +283 -265
- package/plugins/huaweicloud-core/src/icon-library.mjs +171 -0
- package/plugins/huaweicloud-core/src/mcp-server.mjs +130 -129
- package/plugins/huaweicloud-core/src/proxy/proxy-agent.mjs +68 -0
- package/plugins/huaweicloud-core/src/proxy/proxy-config.mjs +94 -0
- package/plugins/huaweicloud-core/src/risk-rule-engine.mjs +140 -137
- package/plugins/huaweicloud-core/src/safety-policy.mjs +356 -302
- package/plugins/huaweicloud-core/src/sandbox/hdkitservice-api.mjs +86 -87
- package/plugins/huaweicloud-core/src/sandbox/hwlink-api.mjs +150 -153
- package/plugins/huaweicloud-core/src/sandbox/session-manager.mjs +196 -105
- package/plugins/huaweicloud-core/src/search-market.mjs +208 -169
- package/plugins/huaweicloud-core/src/setup-cli.mjs +2622 -1594
- package/plugins/huaweicloud-core/src/tools.mjs +463 -111
- package/plugins/huaweicloud-core/src/ws-exec/hwlink-exec-client.js +447 -427
- package/plugins/huaweicloud-core/src/ws-exec/hwlink-fair-queue.js +128 -132
- package/plugins/huaweicloud-core/src/ws-exec/hwlink-multiplexer.js +215 -227
- package/plugins/huaweicloud-core/src/ws-exec/hwlink-packet.js +189 -202
- package/plugins/huaweicloud-core/src/ws-exec/hwlink-terminal-channel.js +164 -158
- package/plugins/huaweicloud-core/src/ws-exec/index.js +19 -19
- package/plugins/huaweicloud-core/src/ws-exec/ws-exec-client.js +338 -338
|
@@ -1,202 +1,189 @@
|
|
|
1
|
-
const FIXED_HEADER_LEN = 20;
|
|
2
|
-
const MAX_SEND_CHUNK_SIZE = 8 * 1024;
|
|
3
|
-
|
|
4
|
-
const OpCode = Object.freeze({
|
|
5
|
-
OpCreateTcpTunnel: 0x03,
|
|
6
|
-
OpTcpTunnelData: 0x04,
|
|
7
|
-
OpListenTcpTunnel: 0x05,
|
|
8
|
-
OpReverseCreateTcpTunnel: 0x43,
|
|
9
|
-
OpCmdTerminalResize: 0xfa,
|
|
10
|
-
OpNewCmdTerminal: 0xfb,
|
|
11
|
-
OpCmdTerminalInit: 0xfc,
|
|
12
|
-
OpCmdTerminalData: 0xfd,
|
|
13
|
-
|
|
14
|
-
OpFileSuccess: 0x03 << 8,
|
|
15
|
-
OpSubStreamPing: 0x06 << 8,
|
|
16
|
-
OpSubStreamPong: 0x07 << 8,
|
|
17
|
-
OpTunnelSuccess: 0x08 << 8,
|
|
18
|
-
|
|
19
|
-
OpDisconnect: 0x03 << 16,
|
|
20
|
-
|
|
21
|
-
ErrCmdTerminal: 0x0d << 24,
|
|
22
|
-
ErrTcpTunnel: 0x0e << 24,
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
const ReserveSource = Object.freeze({
|
|
26
|
-
Web: 0x00,
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
let nextId = 1;
|
|
30
|
-
|
|
31
|
-
function nextIdentifier() {
|
|
32
|
-
nextId = ((nextId + 1) & 0xffffffff) >>> 0;
|
|
33
|
-
return nextId;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
function isOpTunnelSuccess(op) {
|
|
37
|
-
return (op & 0xff00) === OpCode.OpTunnelSuccess;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
function isOpTcpTunnelData(op) {
|
|
41
|
-
return (op & 0xff) === OpCode.OpTcpTunnelData;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
function isOpFailed(op) {
|
|
45
|
-
return
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
function isOpCreateTcpTunnel(op) {
|
|
49
|
-
return (op & 0xff) === OpCode.OpCreateTcpTunnel;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
function isOpReverseCreateTcpTunnel(op) {
|
|
53
|
-
return (op & 0xff) === OpCode.OpReverseCreateTcpTunnel;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
function isOpCmdTerminalData(op) {
|
|
57
|
-
return (op & 0xff) === OpCode.OpCmdTerminalData;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
function isOpListenTcpTunnel(op) {
|
|
61
|
-
return (op & 0xff) === OpCode.OpListenTcpTunnel;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
function isSubStreamPing(op) {
|
|
65
|
-
return (op & 0xff00) === OpCode.OpSubStreamPing;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
function hex2(n) {
|
|
69
|
-
return `0x${n.toString(16).padStart(2, '0').toUpperCase()}`;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
function operationToString(op) {
|
|
73
|
-
return [
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
`[${String(packet.
|
|
89
|
-
`[${
|
|
90
|
-
`[${String(packet.
|
|
91
|
-
`[${
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
);
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
const
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
const
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
isOpCmdTerminalData,
|
|
191
|
-
isOpCreateTcpTunnel,
|
|
192
|
-
isOpFailed,
|
|
193
|
-
isOpListenTcpTunnel,
|
|
194
|
-
isOpReverseCreateTcpTunnel,
|
|
195
|
-
isOpTcpTunnelData,
|
|
196
|
-
isOpTunnelSuccess,
|
|
197
|
-
isSubStreamPing,
|
|
198
|
-
nextIdentifier,
|
|
199
|
-
operationToString,
|
|
200
|
-
parsePacket,
|
|
201
|
-
toUint8Array,
|
|
202
|
-
};
|
|
1
|
+
const FIXED_HEADER_LEN = 20;
|
|
2
|
+
const MAX_SEND_CHUNK_SIZE = 8 * 1024;
|
|
3
|
+
|
|
4
|
+
const OpCode = Object.freeze({
|
|
5
|
+
OpCreateTcpTunnel: 0x03,
|
|
6
|
+
OpTcpTunnelData: 0x04,
|
|
7
|
+
OpListenTcpTunnel: 0x05,
|
|
8
|
+
OpReverseCreateTcpTunnel: 0x43,
|
|
9
|
+
OpCmdTerminalResize: 0xfa,
|
|
10
|
+
OpNewCmdTerminal: 0xfb,
|
|
11
|
+
OpCmdTerminalInit: 0xfc,
|
|
12
|
+
OpCmdTerminalData: 0xfd,
|
|
13
|
+
|
|
14
|
+
OpFileSuccess: 0x03 << 8,
|
|
15
|
+
OpSubStreamPing: 0x06 << 8,
|
|
16
|
+
OpSubStreamPong: 0x07 << 8,
|
|
17
|
+
OpTunnelSuccess: 0x08 << 8,
|
|
18
|
+
|
|
19
|
+
OpDisconnect: 0x03 << 16,
|
|
20
|
+
|
|
21
|
+
ErrCmdTerminal: 0x0d << 24,
|
|
22
|
+
ErrTcpTunnel: 0x0e << 24,
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
const ReserveSource = Object.freeze({
|
|
26
|
+
Web: 0x00,
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
let nextId = 1;
|
|
30
|
+
|
|
31
|
+
function nextIdentifier() {
|
|
32
|
+
nextId = ((nextId + 1) & 0xffffffff) >>> 0;
|
|
33
|
+
return nextId;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function isOpTunnelSuccess(op) {
|
|
37
|
+
return (op & 0xff00) === OpCode.OpTunnelSuccess;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function isOpTcpTunnelData(op) {
|
|
41
|
+
return (op & 0xff) === OpCode.OpTcpTunnelData;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function isOpFailed(op) {
|
|
45
|
+
return op >> 24 !== 0;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function isOpCreateTcpTunnel(op) {
|
|
49
|
+
return (op & 0xff) === OpCode.OpCreateTcpTunnel;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function isOpReverseCreateTcpTunnel(op) {
|
|
53
|
+
return (op & 0xff) === OpCode.OpReverseCreateTcpTunnel;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function isOpCmdTerminalData(op) {
|
|
57
|
+
return (op & 0xff) === OpCode.OpCmdTerminalData;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function isOpListenTcpTunnel(op) {
|
|
61
|
+
return (op & 0xff) === OpCode.OpListenTcpTunnel;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function isSubStreamPing(op) {
|
|
65
|
+
return (op & 0xff00) === OpCode.OpSubStreamPing;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function hex2(n) {
|
|
69
|
+
return `0x${n.toString(16).padStart(2, '0').toUpperCase()}`;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function operationToString(op) {
|
|
73
|
+
return [hex2((op >> 24) & 0xff), hex2((op >> 16) & 0xff), hex2((op >> 8) & 0xff), hex2(op & 0xff)].join(' ');
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function formatPacketOneLine(packet) {
|
|
77
|
+
const err = (packet.operation >> 24) & 0xff;
|
|
78
|
+
const ctl = (packet.operation >> 16) & 0xff;
|
|
79
|
+
const sync = (packet.operation >> 8) & 0xff;
|
|
80
|
+
const data = packet.operation & 0xff;
|
|
81
|
+
const dataLen = packet.data ? packet.data.length : 0;
|
|
82
|
+
return (
|
|
83
|
+
`[${String(packet.headerLength).padStart(2)}]` +
|
|
84
|
+
`[${hex2(packet.reserve)}]` +
|
|
85
|
+
`[${String(packet.packetLength).padStart(5)}]` +
|
|
86
|
+
`[${hex2(err)} ${hex2(ctl)} ${hex2(sync)} ${hex2(data)}]` +
|
|
87
|
+
`[${String(packet.srcPort).padStart(5)}]` +
|
|
88
|
+
`[${String(packet.dstPort).padStart(5)}]` +
|
|
89
|
+
`[${String(packet.identifier).padStart(10)}]` +
|
|
90
|
+
`[${String(packet.source).padStart(10)}]` +
|
|
91
|
+
`[${String(dataLen).padStart(6)}B]`
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function toUint8Array(bytes) {
|
|
96
|
+
if (bytes instanceof Uint8Array) return bytes;
|
|
97
|
+
if (bytes instanceof ArrayBuffer) return new Uint8Array(bytes);
|
|
98
|
+
if (ArrayBuffer.isView(bytes)) {
|
|
99
|
+
return new Uint8Array(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
100
|
+
}
|
|
101
|
+
throw new TypeError('packet bytes must be an ArrayBuffer or Uint8Array');
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function createPacket(opts) {
|
|
105
|
+
const { operation, reserve = 0, srcPort = 0, dstPort = 0, identifier = 0, source = 0, payload = null } = opts;
|
|
106
|
+
|
|
107
|
+
const payloadLen = payload ? payload.length : 0;
|
|
108
|
+
const total = FIXED_HEADER_LEN + payloadLen;
|
|
109
|
+
const buf = new ArrayBuffer(total);
|
|
110
|
+
const view = new DataView(buf);
|
|
111
|
+
const u8 = new Uint8Array(buf);
|
|
112
|
+
|
|
113
|
+
view.setUint8(0, FIXED_HEADER_LEN / 4);
|
|
114
|
+
view.setUint8(1, reserve);
|
|
115
|
+
view.setUint16(2, total, false);
|
|
116
|
+
view.setUint32(4, operation, false);
|
|
117
|
+
view.setUint16(8, srcPort, false);
|
|
118
|
+
view.setUint16(10, dstPort, false);
|
|
119
|
+
view.setUint32(12, identifier, false);
|
|
120
|
+
view.setUint32(16, source, false);
|
|
121
|
+
|
|
122
|
+
if (payload && payloadLen) {
|
|
123
|
+
u8.set(payload, FIXED_HEADER_LEN);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
return u8;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function parsePacket(bytes) {
|
|
130
|
+
const u8 = toUint8Array(bytes);
|
|
131
|
+
if (u8.byteLength < FIXED_HEADER_LEN) {
|
|
132
|
+
throw new Error(`packet too short: ${u8.byteLength} bytes`);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
const view = new DataView(u8.buffer, u8.byteOffset, u8.byteLength);
|
|
136
|
+
const headerLength = view.getUint8(0) * 4;
|
|
137
|
+
const reserve = view.getUint8(1);
|
|
138
|
+
const packetLength = view.getUint16(2, false);
|
|
139
|
+
const operation = view.getUint32(4, false);
|
|
140
|
+
const srcPort = view.getUint16(8, false);
|
|
141
|
+
const dstPort = view.getUint16(10, false);
|
|
142
|
+
const identifier = view.getUint32(12, false);
|
|
143
|
+
const source = view.getUint32(16, false);
|
|
144
|
+
|
|
145
|
+
if (headerLength < FIXED_HEADER_LEN) {
|
|
146
|
+
throw new Error(`invalid hwlink packet header length: ${headerLength}`);
|
|
147
|
+
}
|
|
148
|
+
if (packetLength > u8.byteLength) {
|
|
149
|
+
throw new Error(`incomplete hwlink packet: ${packetLength} > ${u8.byteLength}`);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
let data = null;
|
|
153
|
+
if (packetLength > FIXED_HEADER_LEN) {
|
|
154
|
+
data = u8.subarray(FIXED_HEADER_LEN, packetLength);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
return {
|
|
158
|
+
headerLength,
|
|
159
|
+
reserve,
|
|
160
|
+
packetLength,
|
|
161
|
+
operation,
|
|
162
|
+
srcPort,
|
|
163
|
+
dstPort,
|
|
164
|
+
identifier,
|
|
165
|
+
source,
|
|
166
|
+
data,
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
export {
|
|
171
|
+
FIXED_HEADER_LEN,
|
|
172
|
+
MAX_SEND_CHUNK_SIZE,
|
|
173
|
+
OpCode,
|
|
174
|
+
ReserveSource,
|
|
175
|
+
createPacket,
|
|
176
|
+
formatPacketOneLine,
|
|
177
|
+
isOpCmdTerminalData,
|
|
178
|
+
isOpCreateTcpTunnel,
|
|
179
|
+
isOpFailed,
|
|
180
|
+
isOpListenTcpTunnel,
|
|
181
|
+
isOpReverseCreateTcpTunnel,
|
|
182
|
+
isOpTcpTunnelData,
|
|
183
|
+
isOpTunnelSuccess,
|
|
184
|
+
isSubStreamPing,
|
|
185
|
+
nextIdentifier,
|
|
186
|
+
operationToString,
|
|
187
|
+
parsePacket,
|
|
188
|
+
toUint8Array,
|
|
189
|
+
};
|