According to RFC 4254 section 5.1, SSH_MSG_CHANNEL_OPEN_CONFIRMATION can contain some type specific data, we have mapping for this extra payload but currently the field is unused.
I propose to add API to allow setting this field when accepting a channel on the server side and to retrieve the value on the client side.
Proposed API for the server side part:
// NewChannelWithPayload is a NewChannel that allows to send an arbitrary
// payload in SSH_MSG_CHANNEL_OPEN_CONFIRMATION.
type NewChannelWithPayload interface {
NewChannel
// AcceptWithPayload allows to set an arbitrary payload to send in
// SSH_MSG_CHANNEL_OPEN_CONFIRMATION.
AcceptWithPayload(payload []byte) (Channel, <-chan *Request, error)
}
Proposed API for the client side part:
// ChannelWithPayload is a Channel that allows to retrieve the type specific
// data received in SSH_MSG_CHANNEL_OPEN_CONFIRMATION.
type ChannelWithPayload interface {
Channel
// Payload returns the channel type specific data received in
// SSH_MSG_CHANNEL_OPEN_CONFIRMATION.
Payload() []byte
}
for the client side part we can also evaluate an interface extension for Conn to add something like this:
OpenChannelPayload(name string, data []byte) (Channel, <-chan *Request, []byte, error)
this way the payload is returned directly after opening the channel without the need to call the Payload() method on the channel as proposed above.
I prefer the first option because I'm not a big fan of methods that return multiple values, but that's just a personal preference.
Thank you!
cc @golang/proposal-review
According to RFC 4254 section 5.1,
SSH_MSG_CHANNEL_OPEN_CONFIRMATIONcan contain some type specific data, we have mapping for this extra payload but currently the field is unused.I propose to add API to allow setting this field when accepting a channel on the server side and to retrieve the value on the client side.
Proposed API for the server side part:
Proposed API for the client side part:
for the client side part we can also evaluate an interface extension for Conn to add something like this:
this way the payload is returned directly after opening the channel without the need to call the
Payload()method on the channel as proposed above.I prefer the first option because I'm not a big fan of methods that return multiple values, but that's just a personal preference.
Thank you!
cc @golang/proposal-review