Documentation ¶
Overview ¶
Package filexfer implements the wire encoding for secsh-filexfer as described in https://tools.ietf.org/html/draft-ietf-secsh-filexfer-02
Index ¶
- Constants
- Variables
- func ComposePacket(header, payload []byte, err error) ([]byte, error)
- func RegisterExtendedPacketType(extension string, constructor ExtendedDataConstructor)
- type Attributes
- func (a *Attributes) GetACModTime() (atime, mtime uint32, ok bool)
- func (a *Attributes) GetPermissions() (perms FileMode, ok bool)
- func (a *Attributes) GetSize() (size uint64, ok bool)
- func (a *Attributes) GetUIDGID() (uid, gid uint32, ok bool)
- func (a *Attributes) Len() int
- func (a *Attributes) MarshalBinary() ([]byte, error)
- func (a *Attributes) MarshalInto(b *Buffer)
- func (a *Attributes) SetACModTime(atime, mtime uint32)
- func (a *Attributes) SetPermissions(perms FileMode)
- func (a *Attributes) SetSize(size uint64)
- func (a *Attributes) SetUIDGID(uid, gid uint32)
- func (a *Attributes) UnmarshalBinary(data []byte) error
- func (a *Attributes) UnmarshalFrom(b *Buffer) (err error)
- func (a *Attributes) XXX_UnmarshalByFlags(flags uint32, b *Buffer) (err error)
- type AttrsPacket
- type Buffer
- func (b *Buffer) AppendBool(v bool)
- func (b *Buffer) AppendByteSlice(v []byte)
- func (b *Buffer) AppendInt64(v int64)
- func (b *Buffer) AppendString(v string)
- func (b *Buffer) AppendUint16(v uint16)
- func (b *Buffer) AppendUint32(v uint32)
- func (b *Buffer) AppendUint64(v uint64)
- func (b *Buffer) AppendUint8(v uint8)
- func (b *Buffer) Bytes() []byte
- func (b *Buffer) Cap() int
- func (b *Buffer) ConsumeBool() (bool, error)
- func (b *Buffer) ConsumeByteSlice() ([]byte, error)
- func (b *Buffer) ConsumeInt64() (int64, error)
- func (b *Buffer) ConsumeString() (string, error)
- func (b *Buffer) ConsumeUint16() (uint16, error)
- func (b *Buffer) ConsumeUint32() (uint32, error)
- func (b *Buffer) ConsumeUint64() (uint64, error)
- func (b *Buffer) ConsumeUint8() (uint8, error)
- func (b *Buffer) Len() int
- func (b *Buffer) MarshalBinary() ([]byte, error)
- func (b *Buffer) Packet(payload []byte) (header, payloadPassThru []byte, err error)
- func (b *Buffer) PutLength(size int)
- func (b *Buffer) Reset()
- func (b *Buffer) StartPacket(packetType PacketType, requestID uint32)
- func (b *Buffer) UnmarshalBinary(data []byte) error
- type ClosePacket
- type DataPacket
- type ExtendedAttribute
- type ExtendedData
- type ExtendedDataConstructor
- type ExtendedPacket
- type ExtendedReplyPacket
- type ExtensionPair
- type FSetstatPacket
- type FStatPacket
- type FileMode
- type HandlePacket
- type InitPacket
- type LStatPacket
- type MkdirPacket
- type NameEntry
- type NamePacket
- type OpenDirPacket
- type OpenPacket
- type Packet
- type PacketMarshaller
- type PacketType
- type RawPacket
- func (p *RawPacket) MarshalBinary() ([]byte, error)
- func (p *RawPacket) MarshalPacket(reqid uint32, b []byte) (header, payload []byte, err error)
- func (p *RawPacket) ReadFrom(r io.Reader, b []byte, maxPacketLength uint32) error
- func (p *RawPacket) Reset()
- func (p *RawPacket) Type() PacketType
- func (p *RawPacket) UnmarshalBinary(data []byte) error
- func (p *RawPacket) UnmarshalFrom(buf *Buffer) error
- type ReadDirPacket
- type ReadLinkPacket
- type ReadPacket
- type RealPathPacket
- type RemovePacket
- type RenamePacket
- type RequestPacket
- func (p *RequestPacket) MarshalBinary() ([]byte, error)
- func (p *RequestPacket) MarshalPacket(reqid uint32, b []byte) (header, payload []byte, err error)
- func (p *RequestPacket) ReadFrom(r io.Reader, b []byte, maxPacketLength uint32) error
- func (p *RequestPacket) Reset()
- func (p *RequestPacket) Type() PacketType
- func (p *RequestPacket) UnmarshalBinary(data []byte) error
- func (p *RequestPacket) UnmarshalFrom(buf *Buffer) error
- type RmdirPacket
- type SetstatPacket
- type StatPacket
- type Status
- type StatusPacket
- type SymlinkPacket
- type VersionPacket
- type WritePacket
Constants ¶
const ( AttrSize = 1 << iota // SSH_FILEXFER_ATTR_SIZE AttrUIDGID // SSH_FILEXFER_ATTR_UIDGID AttrPermissions // SSH_FILEXFER_ATTR_PERMISSIONS AttrACModTime // SSH_FILEXFER_ACMODTIME AttrExtended = 1 << 31 // SSH_FILEXFER_ATTR_EXTENDED )
Attributes related flags.
const ( DefaultMaxPacketLength = 34000 DefaultMaxDataLength = 32768 )
Default length values, Defined in draft-ietf-secsh-filexfer-02 section 3.
const ( // see draft-ietf-secsh-filexfer-02 // https://tools.ietf.org/html/draft-ietf-secsh-filexfer-02#section-7 StatusOK = Status(iota) StatusEOF StatusNoSuchFile StatusPermissionDenied StatusFailure StatusBadMessage StatusNoConnection StatusConnectionLost StatusOPUnsupported // https://tools.ietf.org/html/draft-ietf-secsh-filexfer-03#section-7 StatusV4InvalidHandle StatusV4NoSuchPath StatusV4FileAlreadyExists StatusV4WriteProtect // https://tools.ietf.org/html/draft-ietf-secsh-filexfer-04#section-7 StatusV4NoMedia // https://tools.ietf.org/html/draft-ietf-secsh-filexfer-05#section-7 StatusV5NoSpaceOnFilesystem StatusV5QuotaExceeded StatusV5UnknownPrincipal StatusV5LockConflict // https://tools.ietf.org/html/draft-ietf-secsh-filexfer-06#section-8 StatusV6DirNotEmpty StatusV6NotADirectory StatusV6InvalidFilename StatusV6LinkLoop // https://tools.ietf.org/html/draft-ietf-secsh-filexfer-07#section-8 StatusV6CannotDelete StatusV6InvalidParameter StatusV6FileIsADirectory StatusV6ByteRangeLockConflict StatusV6ByteRangeLockRefused StatusV6DeletePending // https://tools.ietf.org/html/draft-ietf-secsh-filexfer-08#section-8.1 StatusV6FileCorrupt // https://tools.ietf.org/html/draft-ietf-secsh-filexfer-10#section-9.1 StatusV6OwnerInvalid StatusV6GroupInvalid // https://tools.ietf.org/html/draft-ietf-secsh-filexfer-13#section-9.1 StatusV6NoMatchingByteRangeLock )
Defines the various SSH_FX_* values.
const ( // https://tools.ietf.org/html/draft-ietf-secsh-filexfer-02#section-3 PacketTypeInit = PacketType(iota + 1) PacketTypeVersion PacketTypeOpen PacketTypeClose PacketTypeRead PacketTypeWrite PacketTypeLStat PacketTypeFStat PacketTypeSetstat PacketTypeFSetstat PacketTypeOpenDir PacketTypeReadDir PacketTypeRemove PacketTypeMkdir PacketTypeRmdir PacketTypeRealPath PacketTypeStat PacketTypeRename PacketTypeReadLink PacketTypeSymlink // https://tools.ietf.org/html/draft-ietf-secsh-filexfer-07#section-3.3 PacketTypeV6Link // https://tools.ietf.org/html/draft-ietf-secsh-filexfer-08#section-3.3 PacketTypeV6Block PacketTypeV6Unblock )
Request packet types.
const ( // https://tools.ietf.org/html/draft-ietf-secsh-filexfer-02#section-3 PacketTypeStatus = PacketType(iota + 101) PacketTypeHandle PacketTypeData PacketTypeName PacketTypeAttrs )
Response packet types.
const ( // https://tools.ietf.org/html/draft-ietf-secsh-filexfer-02#section-3 PacketTypeExtended = PacketType(iota + 200) PacketTypeExtendedReply )
Extended packet types.
const ( FlagRead = 1 << iota // SSH_FXF_READ FlagWrite // SSH_FXF_WRITE FlagAppend // SSH_FXF_APPEND FlagCreate // SSH_FXF_CREAT FlagTruncate // SSH_FXF_TRUNC FlagExclusive // SSH_FXF_EXCL )
SSH_FXF_* flags.
Variables ¶
var ( ErrShortPacket = errors.New("packet too short") ErrLongPacket = errors.New("packet too long") )
Various encoding errors.
Functions ¶
func ComposePacket ¶
ComposePacket converts returns from MarshalPacket into an equivalent call to MarshalBinary.
func RegisterExtendedPacketType ¶
func RegisterExtendedPacketType(extension string, constructor ExtendedDataConstructor)
RegisterExtendedPacketType defines a specific ExtendedDataConstructor for the given extension string.
Types ¶
type Attributes ¶
type Attributes struct { Flags uint32 // AttrSize Size uint64 // AttrUIDGID UID uint32 GID uint32 // AttrPermissions Permissions FileMode // AttrACmodTime ATime uint32 MTime uint32 // AttrExtended ExtendedAttributes []ExtendedAttribute }
Attributes defines the file attributes type defined in draft-ietf-secsh-filexfer-02
Defined in: https://tools.ietf.org/html/draft-ietf-secsh-filexfer-02#section-5
func (*Attributes) GetACModTime ¶
func (a *Attributes) GetACModTime() (atime, mtime uint32, ok bool)
GetACModTime returns the ATime and MTime fields and a bool that is true if and only if the values are valid/defined.
func (*Attributes) GetPermissions ¶
func (a *Attributes) GetPermissions() (perms FileMode, ok bool)
GetPermissions returns the Permissions field and a bool that is true if and only if the value is valid/defined.
func (*Attributes) GetSize ¶
func (a *Attributes) GetSize() (size uint64, ok bool)
GetSize returns the Size field and a bool that is true if and only if the value is valid/defined.
func (*Attributes) GetUIDGID ¶
func (a *Attributes) GetUIDGID() (uid, gid uint32, ok bool)
GetUIDGID returns the UID and GID fields and a bool that is true if and only if the values are valid/defined.
func (*Attributes) Len ¶
func (a *Attributes) Len() int
Len returns the number of bytes a would marshal into.
func (*Attributes) MarshalBinary ¶
func (a *Attributes) MarshalBinary() ([]byte, error)
MarshalBinary returns a as the binary encoding of a.
func (*Attributes) MarshalInto ¶
func (a *Attributes) MarshalInto(b *Buffer)
MarshalInto marshals e onto the end of the given Buffer.
func (*Attributes) SetACModTime ¶
func (a *Attributes) SetACModTime(atime, mtime uint32)
SetACModTime is a convenience function that sets the ATime and MTime fields, and marks the fields as valid/defined in Flags.
func (*Attributes) SetPermissions ¶
func (a *Attributes) SetPermissions(perms FileMode)
SetPermissions is a convenience function that sets the Permissions field, and marks the field as valid/defined in Flags.
func (*Attributes) SetSize ¶
func (a *Attributes) SetSize(size uint64)
SetSize is a convenience function that sets the Size field, and marks the field as valid/defined in Flags.
func (*Attributes) SetUIDGID ¶
func (a *Attributes) SetUIDGID(uid, gid uint32)
SetUIDGID is a convenience function that sets the UID and GID fields, and marks the fields as valid/defined in Flags.
func (*Attributes) UnmarshalBinary ¶
func (a *Attributes) UnmarshalBinary(data []byte) error
UnmarshalBinary decodes the binary encoding of Attributes into e.
func (*Attributes) UnmarshalFrom ¶
func (a *Attributes) UnmarshalFrom(b *Buffer) (err error)
UnmarshalFrom unmarshals an Attributes from the given Buffer into e.
NOTE: The values of fields not covered in the a.Flags are explicitly undefined.
func (*Attributes) XXX_UnmarshalByFlags ¶
func (a *Attributes) XXX_UnmarshalByFlags(flags uint32, b *Buffer) (err error)
XXX_UnmarshalByFlags uses the pre-existing a.Flags field to determine which fields to decode. DO NOT USE THIS: it is an anti-corruption function to implement existing internal usage in pkg/sftp. This function is not a part of any compatibility promise.
type AttrsPacket ¶
type AttrsPacket struct {
Attrs Attributes
}
AttrsPacket defines the SSH_FXP_ATTRS packet.
func (*AttrsPacket) MarshalPacket ¶
func (p *AttrsPacket) MarshalPacket(reqid uint32, b []byte) (header, payload []byte, err error)
MarshalPacket returns p as a two-part binary encoding of p.
func (*AttrsPacket) Type ¶
func (p *AttrsPacket) Type() PacketType
Type returns the SSH_FXP_xy value associated with this packet type.
func (*AttrsPacket) UnmarshalPacketBody ¶
func (p *AttrsPacket) UnmarshalPacketBody(buf *Buffer) (err error)
UnmarshalPacketBody unmarshals the packet body from the given Buffer. It is assumed that the uint32(request-id) has already been consumed.
type Buffer ¶
type Buffer struct {
// contains filtered or unexported fields
}
Buffer wraps up the various encoding details of the SSH format.
Data types are encoded as per section 4 from https://tools.ietf.org/html/draft-ietf-secsh-architecture-09#page-8
func NewBuffer ¶
NewBuffer creates and initializes a new buffer using buf as its initial contents. The new buffer takes ownership of buf, and the caller should not use buf after this call.
In most cases, new(Buffer) (or just declaring a Buffer variable) is sufficient to initialize a Buffer.
func NewMarshalBuffer ¶
NewMarshalBuffer creates a new Buffer ready to start marshaling a Packet into. It preallocates enough space for uint32(length), uint8(type), uint32(request-id) and size more bytes.
func (*Buffer) AppendBool ¶
AppendBool appends a single bool into the buffer. It encodes it as a single byte, with false as 0, and true as 1.
func (*Buffer) AppendByteSlice ¶
AppendByteSlice appends a single string of raw binary data into the buffer. A string is a uint32 length, followed by that number of raw bytes.
func (*Buffer) AppendInt64 ¶
AppendInt64 appends a single int64 into the buffer, in network byte order (big-endian) with two’s complement.
func (*Buffer) AppendString ¶
AppendString appends a single string of binary data into the buffer. A string is a uint32 length, followed by that number of raw bytes.
func (*Buffer) AppendUint16 ¶
AppendUint16 appends single uint16 into the buffer, in network byte order (big-endian).
func (*Buffer) AppendUint32 ¶
AppendUint32 appends a single uint32 into the buffer, in network byte order (big-endian).
func (*Buffer) AppendUint64 ¶
AppendUint64 appends a single uint64 into the buffer, in network byte order (big-endian).
func (*Buffer) AppendUint8 ¶
AppendUint8 appends a single byte into the buffer.
func (*Buffer) Bytes ¶
Bytes returns a slice of length b.Len() holding the unconsumed bytes in the Buffer. The slice is valid for use only until the next buffer modification (that is, only until the next call to an Append or Consume method).
func (*Buffer) Cap ¶
Cap returns the capacity of the buffer’s underlying byte slice, that is, the total space allocated for the buffer’s data.
func (*Buffer) ConsumeBool ¶
ConsumeBool consumes a single byte from the buffer, and returns true if that byte is non-zero. If the buffer does not have enough data, it will return ErrShortPacket.
func (*Buffer) ConsumeByteSlice ¶
ConsumeByteSlice consumes a single string of raw binary data from the buffer. A string is a uint32 length, followed by that number of raw bytes. If the buffer does not have enough data, or defines a length larger than available, it will return ErrShortPacket.
The returned slice aliases the buffer contents, and is valid only as long as the buffer is not reused (that is, only until the next call to Reset, PutLength, StartPacket, or UnmarshalBinary).
In no case will any Consume calls return overlapping slice aliases, and Append calls are guaranteed to not disturb this slice alias.
func (*Buffer) ConsumeInt64 ¶
ConsumeInt64 consumes a single int64 from the buffer, in network byte order (big-endian) with two’s complement. If the buffer does not have enough data, it will return ErrShortPacket.
func (*Buffer) ConsumeString ¶
ConsumeString consumes a single string of binary data from the buffer. A string is a uint32 length, followed by that number of raw bytes. If the buffer does not have enough data, or defines a length larger than available, it will return ErrShortPacket.
NOTE: Go implicitly assumes that strings contain UTF-8 encoded data. All caveats on using arbitrary binary data in Go strings applies.
func (*Buffer) ConsumeUint16 ¶
ConsumeUint16 consumes a single uint16 from the buffer, in network byte order (big-endian). If the buffer does not have enough data, it will return ErrShortPacket.
func (*Buffer) ConsumeUint32 ¶
ConsumeUint32 consumes a single uint32 from the buffer, in network byte order (big-endian). If the buffer does not have enough data, it will return ErrShortPacket.
func (*Buffer) ConsumeUint64 ¶
ConsumeUint64 consumes a single uint64 from the buffer, in network byte order (big-endian). If the buffer does not have enough data, it will return ErrShortPacket.
func (*Buffer) ConsumeUint8 ¶
ConsumeUint8 consumes a single byte from the buffer. If the buffer does not have enough data, it will return ErrShortPacket.
func (*Buffer) MarshalBinary ¶
MarshalBinary returns a clone of the full internal buffer.
func (*Buffer) Packet ¶
Packet finalizes the packet started from StartPacket. It is expected that this will end the ownership of the underlying byte-slice, and so the returned byte-slices may be reused the same as any other byte-slice, the caller should not use this buffer after this call.
It writes the packet body length into the first four bytes of the buffer in network byte order (big endian). The packet body length is the length of this buffer less the 4-byte length itself, plus the length of payload.
It is assumed that no Consume methods have been called on this buffer, and so it returns the whole underlying slice.
func (*Buffer) PutLength ¶
PutLength writes the given size into the first four bytes of the buffer in network byte order (big endian).
func (*Buffer) Reset ¶
func (b *Buffer) Reset()
Reset resets the buffer to be empty, but it retains the underlying storage for use by future Appends.
func (*Buffer) StartPacket ¶
func (b *Buffer) StartPacket(packetType PacketType, requestID uint32)
StartPacket resets and initializes the buffer to be ready to start marshaling a packet into. It truncates the buffer, reserves space for uint32(length), then appends the given packetType and requestID.
func (*Buffer) UnmarshalBinary ¶
UnmarshalBinary sets the internal buffer of b to be a clone of data, and zeros the internal offset.
type ClosePacket ¶
type ClosePacket struct {
Handle string
}
ClosePacket defines the SSH_FXP_CLOSE packet.
func (*ClosePacket) MarshalPacket ¶
func (p *ClosePacket) MarshalPacket(reqid uint32, b []byte) (header, payload []byte, err error)
MarshalPacket returns p as a two-part binary encoding of p.
func (*ClosePacket) Type ¶
func (p *ClosePacket) Type() PacketType
Type returns the SSH_FXP_xy value associated with this packet type.
func (*ClosePacket) UnmarshalPacketBody ¶
func (p *ClosePacket) UnmarshalPacketBody(buf *Buffer) (err error)
UnmarshalPacketBody unmarshals the packet body from the given Buffer. It is assumed that the uint32(request-id) has already been consumed.
type DataPacket ¶
type DataPacket struct {
Data []byte
}
DataPacket defines the SSH_FXP_DATA packet.
func (*DataPacket) MarshalPacket ¶
func (p *DataPacket) MarshalPacket(reqid uint32, b []byte) (header, payload []byte, err error)
MarshalPacket returns p as a two-part binary encoding of p.
func (*DataPacket) Type ¶
func (p *DataPacket) Type() PacketType
Type returns the SSH_FXP_xy value associated with this packet type.
func (*DataPacket) UnmarshalPacketBody ¶
func (p *DataPacket) UnmarshalPacketBody(buf *Buffer) (err error)
UnmarshalPacketBody unmarshals the packet body from the given Buffer. It is assumed that the uint32(request-id) has already been consumed.
If p.Data is already populated, and of sufficient length to hold the data, then this will copy the data into that byte slice.
If p.Data has a length insufficient to hold the data, then this will make a new slice of sufficient length, and copy the data into that.
This means this _does not_ alias any of the data buffer that is passed in.
type ExtendedAttribute ¶
ExtendedAttribute defines the extended file attribute type defined in draft-ietf-secsh-filexfer-02
Defined in: https://tools.ietf.org/html/draft-ietf-secsh-filexfer-02#section-5
func (*ExtendedAttribute) Len ¶
func (e *ExtendedAttribute) Len() int
Len returns the number of bytes e would marshal into.
func (*ExtendedAttribute) MarshalBinary ¶
func (e *ExtendedAttribute) MarshalBinary() ([]byte, error)
MarshalBinary returns e as the binary encoding of e.
func (*ExtendedAttribute) MarshalInto ¶
func (e *ExtendedAttribute) MarshalInto(b *Buffer)
MarshalInto marshals e onto the end of the given Buffer.
func (*ExtendedAttribute) UnmarshalBinary ¶
func (e *ExtendedAttribute) UnmarshalBinary(data []byte) error
UnmarshalBinary decodes the binary encoding of ExtendedAttribute into e.
func (*ExtendedAttribute) UnmarshalFrom ¶
func (e *ExtendedAttribute) UnmarshalFrom(b *Buffer) (err error)
UnmarshalFrom unmarshals an ExtendedAattribute from the given Buffer into e.
type ExtendedData ¶
type ExtendedData = interface { encoding.BinaryMarshaler encoding.BinaryUnmarshaler }
ExtendedData aliases the untyped interface composition of encoding.BinaryMarshaler and encoding.BinaryUnmarshaler.
type ExtendedDataConstructor ¶
type ExtendedDataConstructor func() ExtendedData
ExtendedDataConstructor defines a function that returns a new(ArbitraryExtendedPacket).
type ExtendedPacket ¶
type ExtendedPacket struct { ExtendedRequest string Data ExtendedData }
ExtendedPacket defines the SSH_FXP_CLOSE packet.
func (*ExtendedPacket) MarshalPacket ¶
func (p *ExtendedPacket) MarshalPacket(reqid uint32, b []byte) (header, payload []byte, err error)
MarshalPacket returns p as a two-part binary encoding of p.
The Data is marshaled into binary, and returned as the payload.
func (*ExtendedPacket) Type ¶
func (p *ExtendedPacket) Type() PacketType
Type returns the SSH_FXP_xy value associated with this packet type.
func (*ExtendedPacket) UnmarshalPacketBody ¶
func (p *ExtendedPacket) UnmarshalPacketBody(buf *Buffer) (err error)
UnmarshalPacketBody unmarshals the packet body from the given Buffer. It is assumed that the uint32(request-id) has already been consumed.
If p.Data is nil, and the extension has been registered, a new type will be made from the registration. If the extension has not been registered, then a new Buffer will be allocated. Then the request-specific-data will be unmarshaled from the rest of the buffer.
type ExtendedReplyPacket ¶
type ExtendedReplyPacket struct {
Data ExtendedData
}
ExtendedReplyPacket defines the SSH_FXP_CLOSE packet.
func (*ExtendedReplyPacket) MarshalPacket ¶
func (p *ExtendedReplyPacket) MarshalPacket(reqid uint32, b []byte) (header, payload []byte, err error)
MarshalPacket returns p as a two-part binary encoding of p.
The Data is marshaled into binary, and returned as the payload.
func (*ExtendedReplyPacket) Type ¶
func (p *ExtendedReplyPacket) Type() PacketType
Type returns the SSH_FXP_xy value associated with this packet type.
func (*ExtendedReplyPacket) UnmarshalPacketBody ¶
func (p *ExtendedReplyPacket) UnmarshalPacketBody(buf *Buffer) (err error)
UnmarshalPacketBody unmarshals the packet body from the given Buffer. It is assumed that the uint32(request-id) has already been consumed.
If p.Data is nil, and there is request-specific-data, then the request-specific-data will be wrapped in a Buffer and assigned to p.Data.
type ExtensionPair ¶
ExtensionPair defines the extension-pair type defined in draft-ietf-secsh-filexfer-13. This type is backwards-compatible with how draft-ietf-secsh-filexfer-02 defines extensions.
Defined in: https://tools.ietf.org/html/draft-ietf-secsh-filexfer-13#section-4.2
func (*ExtensionPair) Len ¶
func (e *ExtensionPair) Len() int
Len returns the number of bytes e would marshal into.
func (*ExtensionPair) MarshalBinary ¶
func (e *ExtensionPair) MarshalBinary() ([]byte, error)
MarshalBinary returns e as the binary encoding of e.
func (*ExtensionPair) MarshalInto ¶
func (e *ExtensionPair) MarshalInto(buf *Buffer)
MarshalInto marshals e onto the end of the given Buffer.
func (*ExtensionPair) UnmarshalBinary ¶
func (e *ExtensionPair) UnmarshalBinary(data []byte) error
UnmarshalBinary decodes the binary encoding of ExtensionPair into e.
func (*ExtensionPair) UnmarshalFrom ¶
func (e *ExtensionPair) UnmarshalFrom(buf *Buffer) (err error)
UnmarshalFrom unmarshals an ExtensionPair from the given Buffer into e.
type FSetstatPacket ¶
type FSetstatPacket struct { Handle string Attrs Attributes }
FSetstatPacket defines the SSH_FXP_FSETSTAT packet.
func (*FSetstatPacket) MarshalPacket ¶
func (p *FSetstatPacket) MarshalPacket(reqid uint32, b []byte) (header, payload []byte, err error)
MarshalPacket returns p as a two-part binary encoding of p.
func (*FSetstatPacket) Type ¶
func (p *FSetstatPacket) Type() PacketType
Type returns the SSH_FXP_xy value associated with this packet type.
func (*FSetstatPacket) UnmarshalPacketBody ¶
func (p *FSetstatPacket) UnmarshalPacketBody(buf *Buffer) (err error)
UnmarshalPacketBody unmarshals the packet body from the given Buffer. It is assumed that the uint32(request-id) has already been consumed.
type FStatPacket ¶
type FStatPacket struct {
Handle string
}
FStatPacket defines the SSH_FXP_FSTAT packet.
func (*FStatPacket) MarshalPacket ¶
func (p *FStatPacket) MarshalPacket(reqid uint32, b []byte) (header, payload []byte, err error)
MarshalPacket returns p as a two-part binary encoding of p.
func (*FStatPacket) Type ¶
func (p *FStatPacket) Type() PacketType
Type returns the SSH_FXP_xy value associated with this packet type.
func (*FStatPacket) UnmarshalPacketBody ¶
func (p *FStatPacket) UnmarshalPacketBody(buf *Buffer) (err error)
UnmarshalPacketBody unmarshals the packet body from the given Buffer. It is assumed that the uint32(request-id) has already been consumed.
type FileMode ¶
type FileMode uint32
FileMode represents a file’s mode and permission bits. The bits are defined according to POSIX standards, and may not apply to the OS being built for.
const ( ModePerm FileMode = 0o0777 // S_IRWXU | S_IRWXG | S_IRWXO ModeUserRead FileMode = 0o0400 // S_IRUSR ModeUserWrite FileMode = 0o0200 // S_IWUSR ModeUserExec FileMode = 0o0100 // S_IXUSR ModeGroupRead FileMode = 0o0040 // S_IRGRP ModeGroupWrite FileMode = 0o0020 // S_IWGRP ModeGroupExec FileMode = 0o0010 // S_IXGRP ModeOtherRead FileMode = 0o0004 // S_IROTH ModeOtherWrite FileMode = 0o0002 // S_IWOTH ModeOtherExec FileMode = 0o0001 // S_IXOTH ModeSetUID FileMode = 0o4000 // S_ISUID ModeSetGID FileMode = 0o2000 // S_ISGID ModeSticky FileMode = 0o1000 // S_ISVTX ModeType FileMode = 0xF000 // S_IFMT ModeNamedPipe FileMode = 0x1000 // S_IFIFO ModeCharDevice FileMode = 0x2000 // S_IFCHR ModeDir FileMode = 0x4000 // S_IFDIR ModeDevice FileMode = 0x6000 // S_IFBLK ModeRegular FileMode = 0x8000 // S_IFREG ModeSymlink FileMode = 0xA000 // S_IFLNK ModeSocket FileMode = 0xC000 // S_IFSOCK )
Permission flags, defined here to avoid potential inconsistencies in individual OS implementations.
func (FileMode) IsDir ¶
IsDir reports whether m describes a directory. That is, it tests for m.Type() == ModeDir.
func (FileMode) IsRegular ¶
IsRegular reports whether m describes a regular file. That is, it tests for m.Type() == ModeRegular
type HandlePacket ¶
type HandlePacket struct {
Handle string
}
HandlePacket defines the SSH_FXP_HANDLE packet.
func (*HandlePacket) MarshalPacket ¶
func (p *HandlePacket) MarshalPacket(reqid uint32, b []byte) (header, payload []byte, err error)
MarshalPacket returns p as a two-part binary encoding of p.
func (*HandlePacket) Type ¶
func (p *HandlePacket) Type() PacketType
Type returns the SSH_FXP_xy value associated with this packet type.
func (*HandlePacket) UnmarshalPacketBody ¶
func (p *HandlePacket) UnmarshalPacketBody(buf *Buffer) (err error)
UnmarshalPacketBody unmarshals the packet body from the given Buffer. It is assumed that the uint32(request-id) has already been consumed.
type InitPacket ¶
type InitPacket struct { Version uint32 Extensions []*ExtensionPair }
InitPacket defines the SSH_FXP_INIT packet.
func (*InitPacket) MarshalBinary ¶
func (p *InitPacket) MarshalBinary() ([]byte, error)
MarshalBinary returns p as the binary encoding of p.
func (*InitPacket) UnmarshalBinary ¶
func (p *InitPacket) UnmarshalBinary(data []byte) (err error)
UnmarshalBinary unmarshals a full raw packet out of the given data. It is assumed that the uint32(length) has already been consumed to receive the data. It is also assumed that the uint8(type) has already been consumed to which packet to unmarshal into.
type LStatPacket ¶
type LStatPacket struct {
Path string
}
LStatPacket defines the SSH_FXP_LSTAT packet.
func (*LStatPacket) MarshalPacket ¶
func (p *LStatPacket) MarshalPacket(reqid uint32, b []byte) (header, payload []byte, err error)
MarshalPacket returns p as a two-part binary encoding of p.
func (*LStatPacket) Type ¶
func (p *LStatPacket) Type() PacketType
Type returns the SSH_FXP_xy value associated with this packet type.
func (*LStatPacket) UnmarshalPacketBody ¶
func (p *LStatPacket) UnmarshalPacketBody(buf *Buffer) (err error)
UnmarshalPacketBody unmarshals the packet body from the given Buffer. It is assumed that the uint32(request-id) has already been consumed.
type MkdirPacket ¶
type MkdirPacket struct { Path string Attrs Attributes }
MkdirPacket defines the SSH_FXP_MKDIR packet.
func (*MkdirPacket) MarshalPacket ¶
func (p *MkdirPacket) MarshalPacket(reqid uint32, b []byte) (header, payload []byte, err error)
MarshalPacket returns p as a two-part binary encoding of p.
func (*MkdirPacket) Type ¶
func (p *MkdirPacket) Type() PacketType
Type returns the SSH_FXP_xy value associated with this packet type.
func (*MkdirPacket) UnmarshalPacketBody ¶
func (p *MkdirPacket) UnmarshalPacketBody(buf *Buffer) (err error)
UnmarshalPacketBody unmarshals the packet body from the given Buffer. It is assumed that the uint32(request-id) has already been consumed.
type NameEntry ¶
type NameEntry struct { Filename string Longname string Attrs Attributes }
NameEntry implements the SSH_FXP_NAME repeated data type from draft-ietf-secsh-filexfer-02
This type is incompatible with versions 4 or higher.
func (*NameEntry) MarshalBinary ¶
MarshalBinary returns e as the binary encoding of e.
func (*NameEntry) MarshalInto ¶
MarshalInto marshals e onto the end of the given Buffer.
func (*NameEntry) UnmarshalBinary ¶
UnmarshalBinary decodes the binary encoding of NameEntry into e.
func (*NameEntry) UnmarshalFrom ¶
UnmarshalFrom unmarshals an NameEntry from the given Buffer into e.
NOTE: The values of fields not covered in the a.Flags are explicitly undefined.
type NamePacket ¶
type NamePacket struct {
Entries []*NameEntry
}
NamePacket defines the SSH_FXP_NAME packet.
func (*NamePacket) MarshalPacket ¶
func (p *NamePacket) MarshalPacket(reqid uint32, b []byte) (header, payload []byte, err error)
MarshalPacket returns p as a two-part binary encoding of p.
func (*NamePacket) Type ¶
func (p *NamePacket) Type() PacketType
Type returns the SSH_FXP_xy value associated with this packet type.
func (*NamePacket) UnmarshalPacketBody ¶
func (p *NamePacket) UnmarshalPacketBody(buf *Buffer) (err error)
UnmarshalPacketBody unmarshals the packet body from the given Buffer. It is assumed that the uint32(request-id) has already been consumed.
type OpenDirPacket ¶
type OpenDirPacket struct {
Path string
}
OpenDirPacket defines the SSH_FXP_OPENDIR packet.
func (*OpenDirPacket) MarshalPacket ¶
func (p *OpenDirPacket) MarshalPacket(reqid uint32, b []byte) (header, payload []byte, err error)
MarshalPacket returns p as a two-part binary encoding of p.
func (*OpenDirPacket) Type ¶
func (p *OpenDirPacket) Type() PacketType
Type returns the SSH_FXP_xy value associated with this packet type.
func (*OpenDirPacket) UnmarshalPacketBody ¶
func (p *OpenDirPacket) UnmarshalPacketBody(buf *Buffer) (err error)
UnmarshalPacketBody unmarshals the packet body from the given Buffer. It is assumed that the uint32(request-id) has already been consumed.
type OpenPacket ¶
type OpenPacket struct { Filename string PFlags uint32 Attrs Attributes }
OpenPacket defines the SSH_FXP_OPEN packet.
func (*OpenPacket) MarshalPacket ¶
func (p *OpenPacket) MarshalPacket(reqid uint32, b []byte) (header, payload []byte, err error)
MarshalPacket returns p as a two-part binary encoding of p.
func (*OpenPacket) Type ¶
func (p *OpenPacket) Type() PacketType
Type returns the SSH_FXP_xy value associated with this packet type.
func (*OpenPacket) UnmarshalPacketBody ¶
func (p *OpenPacket) UnmarshalPacketBody(buf *Buffer) (err error)
UnmarshalPacketBody unmarshals the packet body from the given Buffer. It is assumed that the uint32(request-id) has already been consumed.
type Packet ¶
type Packet interface { PacketMarshaller // Type returns the SSH_FXP_xy value associated with the specific packet. Type() PacketType // UnmarshalPacketBody decodes a packet body from the given Buffer. // It is assumed that the common header values of the length, type and request-id have already been consumed. // // Implementations should not alias the given Buffer, // instead they can consider prepopulating an internal buffer as a hint, // and copying into that buffer if it has sufficient length. UnmarshalPacketBody(buf *Buffer) error }
Packet defines the behavior of a full generic SFTP packet.
InitPacket, and VersionPacket are not generic SFTP packets, and instead implement (Un)MarshalBinary.
ExtendedPacket types should not iplement this interface, since decoding the whole packet body of an ExtendedPacket can only be done dependent on the ExtendedRequest field.
type PacketMarshaller ¶
type PacketMarshaller interface { // MarshalPacket is the primary intended way to encode a packet. // The request-id for the packet is set from reqid. // // An optional buffer may be given in b. // If the buffer has a minimum capacity, it shall be truncated and used to marshal the header into. // The minimum capacity for the packet must be a constant expression, and should be at least 9. // // It shall return the main body of the encoded packet in header, // and may optionally return an additional payload to be written immediately after the header. // // It shall encode in the first 4-bytes of the header the proper length of the rest of the header+payload. MarshalPacket(reqid uint32, b []byte) (header, payload []byte, err error) }
PacketMarshaller narrowly defines packets that will only be transmitted.
ExtendedPacket types will often only implement this interface, since decoding the whole packet body of an ExtendedPacket can only be done dependent on the ExtendedRequest field.
type PacketType ¶
type PacketType uint8
PacketType defines the various SFTP packet types.
func (PacketType) String ¶
func (f PacketType) String() string
type RawPacket ¶
type RawPacket struct { PacketType PacketType RequestID uint32 Data Buffer }
RawPacket implements the general packet format from draft-ietf-secsh-filexfer-02
RawPacket is intended for use in clients receiving responses, where a response will be expected to be of a limited number of types, and unmarshaling unknown/unexpected response packets is unnecessary.
For servers expecting to receive arbitrary request packet types, use RequestPacket.
Defined in https://tools.ietf.org/html/draft-ietf-secsh-filexfer-02#section-3
func (*RawPacket) MarshalBinary ¶
MarshalBinary returns p as the binary encoding of p.
This is a convenience implementation primarily intended for tests, because it is inefficient with allocations.
func (*RawPacket) MarshalPacket ¶
MarshalPacket returns p as a two-part binary encoding of p.
The internal p.RequestID is overridden by the reqid argument.
func (*RawPacket) ReadFrom ¶
ReadFrom provides a simple functional packet reader, using the given byte slice as a backing array.
To protect against potential denial of service attacks, if the read packet length is longer than maxPacketLength, then no packet data will be read, and ErrLongPacket will be returned. (On 32-bit int architectures, all packets >= 2^31 in length will return ErrLongPacket regardless of maxPacketLength.)
If the read packet length is longer than cap(b), then a throw-away slice will allocated to meet the exact packet length. This can be used to limit the length of reused buffers, while still allowing reception of occasional large packets.
The Data field may alias the passed in byte slice, so the byte slice passed in should not be reused before RawPacket.Reset().
func (*RawPacket) Reset ¶
func (p *RawPacket) Reset()
Reset clears the pointers and reference-semantic variables of RawPacket, releasing underlying resources, and making them and the RawPacket suitable to be reused, so long as no other references have been kept.
func (*RawPacket) Type ¶
func (p *RawPacket) Type() PacketType
Type returns the Type field defining the SSH_FXP_xy type for this packet.
func (*RawPacket) UnmarshalBinary ¶
UnmarshalBinary decodes a full raw packet out of the given data. It is assumed that the uint32(length) has already been consumed to receive the data.
This is a convenience implementation primarily intended for tests, because this must clone the given data byte slice, as Data is not allowed to alias any part of the data byte slice.
func (*RawPacket) UnmarshalFrom ¶
UnmarshalFrom decodes a RawPacket from the given Buffer into p.
The Data field will alias the passed in Buffer, so the buffer passed in should not be reused before RawPacket.Reset().
type ReadDirPacket ¶
type ReadDirPacket struct {
Handle string
}
ReadDirPacket defines the SSH_FXP_READDIR packet.
func (*ReadDirPacket) MarshalPacket ¶
func (p *ReadDirPacket) MarshalPacket(reqid uint32, b []byte) (header, payload []byte, err error)
MarshalPacket returns p as a two-part binary encoding of p.
func (*ReadDirPacket) Type ¶
func (p *ReadDirPacket) Type() PacketType
Type returns the SSH_FXP_xy value associated with this packet type.
func (*ReadDirPacket) UnmarshalPacketBody ¶
func (p *ReadDirPacket) UnmarshalPacketBody(buf *Buffer) (err error)
UnmarshalPacketBody unmarshals the packet body from the given Buffer. It is assumed that the uint32(request-id) has already been consumed.
type ReadLinkPacket ¶
type ReadLinkPacket struct {
Path string
}
ReadLinkPacket defines the SSH_FXP_READLINK packet.
func (*ReadLinkPacket) MarshalPacket ¶
func (p *ReadLinkPacket) MarshalPacket(reqid uint32, b []byte) (header, payload []byte, err error)
MarshalPacket returns p as a two-part binary encoding of p.
func (*ReadLinkPacket) Type ¶
func (p *ReadLinkPacket) Type() PacketType
Type returns the SSH_FXP_xy value associated with this packet type.
func (*ReadLinkPacket) UnmarshalPacketBody ¶
func (p *ReadLinkPacket) UnmarshalPacketBody(buf *Buffer) (err error)
UnmarshalPacketBody unmarshals the packet body from the given Buffer. It is assumed that the uint32(request-id) has already been consumed.
type ReadPacket ¶
ReadPacket defines the SSH_FXP_READ packet.
func (*ReadPacket) MarshalPacket ¶
func (p *ReadPacket) MarshalPacket(reqid uint32, b []byte) (header, payload []byte, err error)
MarshalPacket returns p as a two-part binary encoding of p.
func (*ReadPacket) Type ¶
func (p *ReadPacket) Type() PacketType
Type returns the SSH_FXP_xy value associated with this packet type.
func (*ReadPacket) UnmarshalPacketBody ¶
func (p *ReadPacket) UnmarshalPacketBody(buf *Buffer) (err error)
UnmarshalPacketBody unmarshals the packet body from the given Buffer. It is assumed that the uint32(request-id) has already been consumed.
type RealPathPacket ¶
type RealPathPacket struct {
Path string
}
RealPathPacket defines the SSH_FXP_REALPATH packet.
func (*RealPathPacket) MarshalPacket ¶
func (p *RealPathPacket) MarshalPacket(reqid uint32, b []byte) (header, payload []byte, err error)
MarshalPacket returns p as a two-part binary encoding of p.
func (*RealPathPacket) Type ¶
func (p *RealPathPacket) Type() PacketType
Type returns the SSH_FXP_xy value associated with this packet type.
func (*RealPathPacket) UnmarshalPacketBody ¶
func (p *RealPathPacket) UnmarshalPacketBody(buf *Buffer) (err error)
UnmarshalPacketBody unmarshals the packet body from the given Buffer. It is assumed that the uint32(request-id) has already been consumed.
type RemovePacket ¶
type RemovePacket struct {
Path string
}
RemovePacket defines the SSH_FXP_REMOVE packet.
func (*RemovePacket) MarshalPacket ¶
func (p *RemovePacket) MarshalPacket(reqid uint32, b []byte) (header, payload []byte, err error)
MarshalPacket returns p as a two-part binary encoding of p.
func (*RemovePacket) Type ¶
func (p *RemovePacket) Type() PacketType
Type returns the SSH_FXP_xy value associated with this packet type.
func (*RemovePacket) UnmarshalPacketBody ¶
func (p *RemovePacket) UnmarshalPacketBody(buf *Buffer) (err error)
UnmarshalPacketBody unmarshals the packet body from the given Buffer. It is assumed that the uint32(request-id) has already been consumed.
type RenamePacket ¶
RenamePacket defines the SSH_FXP_RENAME packet.
func (*RenamePacket) MarshalPacket ¶
func (p *RenamePacket) MarshalPacket(reqid uint32, b []byte) (header, payload []byte, err error)
MarshalPacket returns p as a two-part binary encoding of p.
func (*RenamePacket) Type ¶
func (p *RenamePacket) Type() PacketType
Type returns the SSH_FXP_xy value associated with this packet type.
func (*RenamePacket) UnmarshalPacketBody ¶
func (p *RenamePacket) UnmarshalPacketBody(buf *Buffer) (err error)
UnmarshalPacketBody unmarshals the packet body from the given Buffer. It is assumed that the uint32(request-id) has already been consumed.
type RequestPacket ¶
RequestPacket implements the general packet format from draft-ietf-secsh-filexfer-02 but also automatically decode/encodes valid request packets (2 < type < 100 || type == 200).
RequestPacket is intended for use in servers receiving requests, where any arbitrary request may be received, and so decoding them automatically is useful.
For clients expecting to receive specific response packet types, where automatic unmarshaling of the packet body does not make sense, use RawPacket.
Defined in https://tools.ietf.org/html/draft-ietf-secsh-filexfer-02#section-3
func (*RequestPacket) MarshalBinary ¶
func (p *RequestPacket) MarshalBinary() ([]byte, error)
MarshalBinary returns p as the binary encoding of p.
This is a convenience implementation primarily intended for tests, because it is inefficient with allocations.
func (*RequestPacket) MarshalPacket ¶
func (p *RequestPacket) MarshalPacket(reqid uint32, b []byte) (header, payload []byte, err error)
MarshalPacket returns p as a two-part binary encoding of p.
The internal p.RequestID is overridden by the reqid argument.
func (*RequestPacket) ReadFrom ¶
ReadFrom provides a simple functional packet reader, using the given byte slice as a backing array.
To protect against potential denial of service attacks, if the read packet length is longer than maxPacketLength, then no packet data will be read, and ErrLongPacket will be returned. (On 32-bit int architectures, all packets >= 2^31 in length will return ErrLongPacket regardless of maxPacketLength.)
If the read packet length is longer than cap(b), then a throw-away slice will allocated to meet the exact packet length. This can be used to limit the length of reused buffers, while still allowing reception of occasional large packets.
The Request field may alias the passed in byte slice, so the byte slice passed in should not be reused before RawPacket.Reset().
func (*RequestPacket) Reset ¶
func (p *RequestPacket) Reset()
Reset clears the pointers and reference-semantic variables in RequestPacket, releasing underlying resources, and making them and the RequestPacket suitable to be reused, so long as no other references have been kept.
func (*RequestPacket) Type ¶
func (p *RequestPacket) Type() PacketType
Type returns the SSH_FXP_xy value associated with the underlying packet.
func (*RequestPacket) UnmarshalBinary ¶
func (p *RequestPacket) UnmarshalBinary(data []byte) error
UnmarshalBinary decodes a full request packet out of the given data. It is assumed that the uint32(length) has already been consumed to receive the data.
This is a convenience implementation primarily intended for tests, because this must clone the given data byte slice, as Request is not allowed to alias any part of the data byte slice.
func (*RequestPacket) UnmarshalFrom ¶
func (p *RequestPacket) UnmarshalFrom(buf *Buffer) error
UnmarshalFrom decodes a RequestPacket from the given Buffer into p.
The Request field may alias the passed in Buffer, (e.g. SSH_FXP_WRITE), so the buffer passed in should not be reused before RequestPacket.Reset().
type RmdirPacket ¶
type RmdirPacket struct {
Path string
}
RmdirPacket defines the SSH_FXP_RMDIR packet.
func (*RmdirPacket) MarshalPacket ¶
func (p *RmdirPacket) MarshalPacket(reqid uint32, b []byte) (header, payload []byte, err error)
MarshalPacket returns p as a two-part binary encoding of p.
func (*RmdirPacket) Type ¶
func (p *RmdirPacket) Type() PacketType
Type returns the SSH_FXP_xy value associated with this packet type.
func (*RmdirPacket) UnmarshalPacketBody ¶
func (p *RmdirPacket) UnmarshalPacketBody(buf *Buffer) (err error)
UnmarshalPacketBody unmarshals the packet body from the given Buffer. It is assumed that the uint32(request-id) has already been consumed.
type SetstatPacket ¶
type SetstatPacket struct { Path string Attrs Attributes }
SetstatPacket defines the SSH_FXP_SETSTAT packet.
func (*SetstatPacket) MarshalPacket ¶
func (p *SetstatPacket) MarshalPacket(reqid uint32, b []byte) (header, payload []byte, err error)
MarshalPacket returns p as a two-part binary encoding of p.
func (*SetstatPacket) Type ¶
func (p *SetstatPacket) Type() PacketType
Type returns the SSH_FXP_xy value associated with this packet type.
func (*SetstatPacket) UnmarshalPacketBody ¶
func (p *SetstatPacket) UnmarshalPacketBody(buf *Buffer) (err error)
UnmarshalPacketBody unmarshals the packet body from the given Buffer. It is assumed that the uint32(request-id) has already been consumed.
type StatPacket ¶
type StatPacket struct {
Path string
}
StatPacket defines the SSH_FXP_STAT packet.
func (*StatPacket) MarshalPacket ¶
func (p *StatPacket) MarshalPacket(reqid uint32, b []byte) (header, payload []byte, err error)
MarshalPacket returns p as a two-part binary encoding of p.
func (*StatPacket) Type ¶
func (p *StatPacket) Type() PacketType
Type returns the SSH_FXP_xy value associated with this packet type.
func (*StatPacket) UnmarshalPacketBody ¶
func (p *StatPacket) UnmarshalPacketBody(buf *Buffer) (err error)
UnmarshalPacketBody unmarshals the packet body from the given Buffer. It is assumed that the uint32(request-id) has already been consumed.
type Status ¶
type Status uint32
Status defines the SFTP error codes used in SSH_FXP_STATUS response packets.
type StatusPacket ¶
StatusPacket defines the SSH_FXP_STATUS packet.
Specified in https://tools.ietf.org/html/draft-ietf-secsh-filexfer-02#section-7
func (*StatusPacket) Error ¶
func (p *StatusPacket) Error() string
Error makes StatusPacket an error type.
func (*StatusPacket) Is ¶
func (p *StatusPacket) Is(target error) bool
Is returns true if target is a StatusPacket with the same StatusCode, or target is a Status code which is the same as SatusCode.
func (*StatusPacket) MarshalPacket ¶
func (p *StatusPacket) MarshalPacket(reqid uint32, b []byte) (header, payload []byte, err error)
MarshalPacket returns p as a two-part binary encoding of p.
func (*StatusPacket) Type ¶
func (p *StatusPacket) Type() PacketType
Type returns the SSH_FXP_xy value associated with this packet type.
func (*StatusPacket) UnmarshalPacketBody ¶
func (p *StatusPacket) UnmarshalPacketBody(buf *Buffer) (err error)
UnmarshalPacketBody unmarshals the packet body from the given Buffer. It is assumed that the uint32(request-id) has already been consumed.
type SymlinkPacket ¶
SymlinkPacket defines the SSH_FXP_SYMLINK packet.
The order of the arguments to the SSH_FXP_SYMLINK method was inadvertently reversed. Unfortunately, the reversal was not noticed until the server was widely deployed. Covered in Section 4.1 of https://github.com/openssh/openssh-portable/blob/master/PROTOCOL
func (*SymlinkPacket) MarshalPacket ¶
func (p *SymlinkPacket) MarshalPacket(reqid uint32, b []byte) (header, payload []byte, err error)
MarshalPacket returns p as a two-part binary encoding of p.
func (*SymlinkPacket) Type ¶
func (p *SymlinkPacket) Type() PacketType
Type returns the SSH_FXP_xy value associated with this packet type.
func (*SymlinkPacket) UnmarshalPacketBody ¶
func (p *SymlinkPacket) UnmarshalPacketBody(buf *Buffer) (err error)
UnmarshalPacketBody unmarshals the packet body from the given Buffer. It is assumed that the uint32(request-id) has already been consumed.
type VersionPacket ¶
type VersionPacket struct { Version uint32 Extensions []*ExtensionPair }
VersionPacket defines the SSH_FXP_VERSION packet.
func (*VersionPacket) MarshalBinary ¶
func (p *VersionPacket) MarshalBinary() ([]byte, error)
MarshalBinary returns p as the binary encoding of p.
func (*VersionPacket) UnmarshalBinary ¶
func (p *VersionPacket) UnmarshalBinary(data []byte) (err error)
UnmarshalBinary unmarshals a full raw packet out of the given data. It is assumed that the uint32(length) has already been consumed to receive the data. It is also assumed that the uint8(type) has already been consumed to which packet to unmarshal into.
type WritePacket ¶
WritePacket defines the SSH_FXP_WRITE packet.
func (*WritePacket) MarshalPacket ¶
func (p *WritePacket) MarshalPacket(reqid uint32, b []byte) (header, payload []byte, err error)
MarshalPacket returns p as a two-part binary encoding of p.
func (*WritePacket) Type ¶
func (p *WritePacket) Type() PacketType
Type returns the SSH_FXP_xy value associated with this packet type.
func (*WritePacket) UnmarshalPacketBody ¶
func (p *WritePacket) UnmarshalPacketBody(buf *Buffer) (err error)
UnmarshalPacketBody unmarshals the packet body from the given Buffer. It is assumed that the uint32(request-id) has already been consumed.
If p.Data is already populated, and of sufficient length to hold the data, then this will copy the data into that byte slice.
If p.Data has a length insufficient to hold the data, then this will make a new slice of sufficient length, and copy the data into that.
This means this _does not_ alias any of the data buffer that is passed in.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package openssh implements the openssh secsh-filexfer extensions as described in https://github.com/openssh/openssh-portable/blob/master/PROTOCOL
|
Package openssh implements the openssh secsh-filexfer extensions as described in https://github.com/openssh/openssh-portable/blob/master/PROTOCOL |