跳到主要内容

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

浏览文件

extensions.go

43 行 · 1.2 KB历史下载
1package sshfx
2
3// ExtensionPair defines the extension-pair type defined in draft-ietf-secsh-filexfer-13.
4// This type is backwards-compatible with how draft-ietf-secsh-filexfer-02 defines extensions.
5//
6// Defined in: https://tools.ietf.org/html/draft-ietf-secsh-filexfer-13#section-4.2
7type ExtensionPair struct {
8 Name string
9 Data string
10}
11
12// Len returns the number of bytes e would marshal into.
13func (e *ExtensionPair) Len() int {
14 return 4 + len(e.Name) + 4 + len(e.Data)
15}
16
17// MarshalInto marshals e onto the end of the given Buffer.
18func (e *ExtensionPair) MarshalInto(buf *Buffer) {
19 buf.AppendString(e.Name)
20 buf.AppendString(e.Data)
21}
22
23// MarshalBinary returns e as the binary encoding of e.
24func (e *ExtensionPair) MarshalBinary() ([]byte, error) {
25 buf := NewBuffer(make([]byte, 0, e.Len()))
26 e.MarshalInto(buf)
27 return buf.Bytes(), nil
28}
29
30// UnmarshalFrom unmarshals an ExtensionPair from the given Buffer into e.
31func (e *ExtensionPair) UnmarshalFrom(buf *Buffer) (err error) {
32 *e = ExtensionPair{
33 Name: buf.ConsumeString(),
34 Data: buf.ConsumeString(),
35 }
36
37 return buf.Err
38}
39
40// UnmarshalBinary decodes the binary encoding of ExtensionPair into e.
41func (e *ExtensionPair) UnmarshalBinary(data []byte) error {
42 return e.UnmarshalFrom(NewBuffer(data))
43}