Cassondra Foesch
5e8f9f4960
MarshalBinary now gives a 4-byte header for length, marshalPacket gives a two-stage write
2021-02-22 12:04:43 +00:00
Cassondra Foesch
d4ff5aeb4f
remove unnecessary append()s
2021-02-22 12:04:43 +00:00
greatroar
cb1556337d
Don't crash when the packet length is zero
2020-11-02 17:07:10 +01:00
greatroar
d352a1d176
Add Client.Sync method
...
This uses the fsync@openssh.com extension:
https://github.com/openssh/openssh-portable/blob/master/PROTOCOL , §3.6.
2020-10-23 13:09:54 +02:00
Nicola Murino
3177348ca5
pack structures so they have less size
...
This is a micro optimization, it fixes warnings like this one:
packet.go:707:24: struct of size 32 bytes could be of size 24 bytes
2020-09-08 10:18:15 +02:00
Nicola Murino
1f178f9671
the allocator can now be enabled per request
...
Other minor changes as per review comments
2020-03-18 09:36:07 +01:00
Nicola Murino
3f969fcd59
add optional AllocationModeOptimized
...
after processing a packet we keep in memory the allocated slices and we reuse
them for new packets.
Slices are allocated in:
- recvPacket
- when we receive a sshFxpReadPacket (downloads)
The allocated slices have a fixed size = maxMsgLength.
Allocated slices are referenced to the request order id and are marked for reuse
after a request is served in maybeSendPackets.
The allocator is added to the packetManager struct and it is cleaned at the end
of the Serve() function.
This allocation mode is optional and disabled by default
2020-03-14 19:42:19 +01:00
John Eikenberry
18dc4db7a4
Merge pull request #343 from drakkan/allocations
...
fileget: allocate a slice with enough capacity
2020-03-10 15:48:33 -07:00
Nicola Murino
0a45bc4b6d
sshFxpDataPacket: document the required capacity to avoid a new allocation
2020-03-10 22:56:41 +01:00
Nicola Murino
0f0e40a3a6
minor changes as requested in the review
2020-03-10 15:35:56 +01:00
Nicola Murino
eeafeeff60
FxpReadPacket: add an helper method for slice allocation
...
This way we can use the same method in both server and request-server
2020-03-10 11:46:46 +01:00
Nicola Murino
44e44d716f
fileget: allocate a slice with enough capacity
...
so a new allocation is not needed in MarshalBinary and sendPacket.
Here are some profiling results while downloading a file (file size is about 1GB),
before this patch:
1254.24MB 55.18% 55.18% 1254.24MB 55.18% github.com/pkg/sftp.sshFxpDataPacket.MarshalBinary
991.81MB 43.63% 98.81% 991.81MB 43.63% github.com/pkg/sftp.fileget
1MB 0.044% 98.86% 1255.24MB 55.22% github.com/pkg/sftp.(*packetManager).maybeSendPackets
0.50MB 0.022% 98.88% 1260.24MB 55.44% github.com/pkg/sftp.(*packetManager).controller
0 0% 98.88% 991.81MB 43.63% github.com/pkg/sftp.(*Request).call
0 0% 98.88% 993.31MB 43.70% github.com/pkg/sftp.(*RequestServer).Serve.func1.1
0 0% 98.88% 993.31MB 43.70% github.com/pkg/sftp.(*RequestServer).packetWorker
0 0% 98.88% 1254.24MB 55.18% github.com/pkg/sftp.(*conn).sendPacket
0 0% 98.88% 1254.24MB 55.18% github.com/pkg/sftp.sendPacket
with this patch:
1209.48MB 98.46% 98.46% 1209.48MB 98.46% github.com/pkg/sftp.fileget
2MB 0.16% 98.63% 7.50MB 0.61% github.com/pkg/sftp.recvPacket
0 0% 98.63% 8MB 0.65% github.com/drakkan/sftpgo/sftpd.Configuration.handleSftpConnection
0 0% 98.63% 1209.48MB 98.46% github.com/pkg/sftp.(*Request).call
0 0% 98.63% 8MB 0.65% github.com/pkg/sftp.(*RequestServer).Serve
0 0% 98.63% 1209.98MB 98.50% github.com/pkg/sftp.(*RequestServer).Serve.func1.1
0 0% 98.63% 1209.98MB 98.50% github.com/pkg/sftp.(*RequestServer).packetWorker
0 0% 98.63% 7.50MB 0.61% github.com/pkg/sftp.(*conn).recvPacket (inline)
2020-03-09 19:22:48 +01:00
Nicola Murino
01ec2e2e14
write packet UnmarshalBinary: reuse already allocated data
2020-02-26 12:04:13 +01:00
Nicola Murino
4eda1f42bb
data packet unmarshal binary: remove uneeded copy
2020-02-16 21:52:13 +01:00
John Eikenberry
84e6527392
Merge pull request #309 from wutz/master
...
fix: received packet too long
2019-09-29 14:37:50 -07:00
Taizeng Wu
cfce8a5728
fix: received packet too long
...
Close #308
2019-09-29 14:39:33 +08:00
Nicola Murino
b4ea0fd6f6
fix lint issues
...
These lint issues remain:
- request-errors.go, aliases for new error types
- request-attrs.go, UidGid. Changing this will break compatibility
2019-08-30 17:04:37 +02:00
Tommie Gannert
2c24eaad1c
Implement the hardlink@openssh.com extension.
...
Both client and server. This is documented in
https://github.com/openssh/openssh-portable/blob/master/PROTOCOL
Draft 7 of SFTP added support for SSH_FXP_LINK which supports both
symlinks and hardlinks, but unfortunately OpenSSH doesn't support
that:
https://tools.ietf.org/html/draft-ietf-secsh-filexfer-07#section-7.7
Adding support for this as an option would be a nice extension to
this.
2019-08-25 20:16:37 -07:00
John Eikenberry
d4a0cecfdc
remove unstandard error
...
All unmarshall calls return the same errShortPacket except this one for
no reason. Fix that.
2019-08-25 18:21:33 -07:00
John Eikenberry
b9345f483d
Merge pull request #248 from perkeep/packetwrite
...
Write packet length header & payload together on the wire.
2018-08-24 15:50:03 -07:00
John Eikenberry
1afc1d9a78
refactor server response to allow for extending
...
Instead of sendPacket/sendError being sprayed all over the place, this
change has all those places instead return a responsePacket (eventually)
back to the main handling function which then calls sendPacket in one
place.
Behaviour of the code should remain exactly the same.
This makes it much easier to work with the response packets (eg. for the
packet ordering issue I'm working on).
2018-07-25 15:01:43 -07:00
John Eikenberry
b50b1f9eaf
fix sendError usage to match packet type signature
...
sendError takes a requestPacket but was simplifying it to an ider
interface. Future work needed it to be requestPacket but I wanted to fix
didn't up type usage in its own commit.
2018-07-23 16:53:51 -07:00
Brad Fitzpatrick
fbf066c9de
Write packet length header & payload together on the wire.
2018-05-11 21:44:57 -07:00
Allan Feid
820ccceeef
Send unsupported error on extended packets.
...
Following the rules outlined here:
https://tools.ietf.org/html/draft-ietf-secsh-filexfer-extensions-00
Return an SSH_FXP_STATUS with appropriate status error for extended
packets that we do not support.
2018-03-19 10:32:22 -04:00
John Eikenberry
9649a986f0
remove unused variables
2018-02-15 11:00:22 -08:00
Iain Wade
9b6cdb8fab
Add PosixRename method which uses the posix-rename@openssh.com extension
...
to support actual rename() operations rather than the link() call
effectively mandated by the sftp v3/draft-2 requirement that targets
not be overwritten.
2017-09-05 04:46:03 -07:00
unclejack
94df0a367c
client,packet: remove redundant select & return
...
Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com>
2017-02-25 12:56:13 -08:00
Dave Cheney
9d52a809ce
Always close client conn when clientConn.recv exits ( #117 )
...
If recv has exited then nobody will retrive the response, so
make sure we cannot send anything by shutting down the Write side of the
connection.
2016-06-15 20:04:26 +10:00
Dave Cheney
04d5f67e72
Small cleanups
2016-06-14 18:05:33 +10:00
Mark Sheahan
9ff4de5c31
add serverside StatVFS function, implemented for darwin and linux ( #89 )
2016-06-13 14:45:13 +10:00
Dave Cheney
8bf4044e7f
remove svr.in svr.out, replace with svr.rwc ( #107 )
2016-05-29 18:22:40 +10:00
Dave Cheney
5e9ad277fc
Use pkg/errors for error handling ( #101 )
2016-05-19 15:16:48 +10:00
Mark Sheahan
7e2e721fdf
use ssh_FXP_STAT for Stat(); previously Stat() and Lstat() were both Lstat()
2016-04-26 12:07:21 -07:00
Matt Layher
051287be6d
*: remove all named and naked returns
2016-01-07 15:56:04 -05:00
Matt Layher
9374ae613d
*: golint: add and fix up comments on exported types
2016-01-07 15:16:34 -05:00
Matt Layher
b348482b1a
*: golint (part 1)
2016-01-07 12:10:24 -05:00
Matthew Sykes
f5afc8315a
Add Getwd to client
2015-12-22 09:04:46 -05:00
Mark Sheahan
bce43f23ac
Address review comments; alter server test to allow the user / group words to be different
2015-09-07 22:50:46 -07:00
Mark Sheahan
cbd08aeb80
implement setstat & fsetstat
2015-09-07 02:13:07 -07:00
Mark Sheahan
d80ae36051
rmdir and symlink packet handling
2015-09-07 01:05:16 -07:00
Mark Sheahan
7bb2083ca9
Address review comments; about to change decodePacket()
2015-09-06 23:55:15 -07:00
Mark Sheahan
0d8e136458
removing sftp server to client layer; using straight os.* calls
2015-09-06 19:36:47 -07:00
Mark Sheahan
4325c3654b
fix format of 'name' packets (shortname, longname, attrs), add Stat
2015-08-05 12:57:28 -07:00
Mark Sheahan
2f3ef8b897
Merge branch 'master' into server
2015-08-04 21:11:01 -07:00
Mark Sheahan
0f2bc1aa17
server is passing the client integration tests now. I don't understand the ATTRs field, it has a name in it.
2015-07-31 23:09:51 -07:00
Mark Sheahan
435f753792
readdir, rename, remove
2015-07-31 15:46:13 -07:00
Mark Sheahan
bf6b5bce28
fstat
2015-07-30 09:21:59 -07:00
Mark Sheahan
c9cee8ac6f
implement write
2015-07-29 17:37:58 -07:00
Mark Sheahan
2888b4a6b1
implement read
2015-07-29 17:24:24 -07:00
Mark Sheahan
058e1bee58
open & close
2015-07-26 01:32:19 -07:00