define supported extensions in one place and use for both server and request-server

This commit is contained in:
Nicola Murino 2019-08-27 09:18:15 +02:00
parent a760e7925e
commit b519cb8db9
3 changed files with 8 additions and 6 deletions

View File

@ -151,7 +151,7 @@ func (rs *RequestServer) packetWorker(
var rpkt responsePacket
switch pkt := pkt.requestPacket.(type) {
case *sshFxInitPacket:
rpkt = sshFxVersionPacket{Version: sftpProtocolVersion}
rpkt = sshFxVersionPacket{Version: sftpProtocolVersion, Extensions: sftpExtensions}
case *sshFxpClosePacket:
handle := pkt.getHandle()
rpkt = statusFromError(pkt, rs.closeRequest(handle))

View File

@ -157,11 +157,8 @@ func handlePacket(s *Server, p orderedRequest) error {
switch p := p.requestPacket.(type) {
case *sshFxInitPacket:
rpkt = sshFxVersionPacket{
Version: sftpProtocolVersion,
Extensions: []sshExtensionPair{
{"hardlink@openssh.com", "1"},
{"posix-rename@openssh.com", "1"},
},
Version: sftpProtocolVersion,
Extensions: sftpExtensions,
}
case *sshFxpStatPacket:
// stat the requested file

View File

@ -85,6 +85,11 @@ const (
ssh_FXF_EXCL = 0x00000020
)
var sftpExtensions = []sshExtensionPair{
{"hardlink@openssh.com", "1"},
{"posix-rename@openssh.com", "1"},
}
type fxp uint8
func (f fxp) String() string {