Commit Graph

42 Commits

Author SHA1 Message Date
Dave Cheney ea1a7bcdfc conn: seperate io.Reader and io.WriteCloser (#118)
Reading and Writing are less coupled in the sftp client and server than
they may be over a traditional ReadWriter. This mirrors the full duplex
/ half close nature of a TCP connection.

In essence conn.Reader cannot be closed locally, it can only close in
response to the remote side using conn.WriteCloser.Close(), or a network
error, which is effectively the same thing.

Make this behaviour super clear by no longer smooshing the type into a
ReadWriteCloser.
2016-06-15 20:19:51 +10: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 7d4fc94878 Introduce sftp.conn type to handle common send/recv behaviour (#113)
Introduce sftp.conn type to bind packet send/recv to a
io.ReadWriteCloser.
2016-06-15 11:50:02 +10:00
Dave Cheney c5050bbe83 removed unused code 2016-06-15 11:33:39 +10:00
Dave Cheney 4c7551ad7e Refactor all the calls to sendPacket(statusFromError(...)) to a sendError helper (#114)
* statusFromError now takes a type with an id() uint32 method

* Introduce sendError

Refactor all the calls to sendPacket(statusFromError(...)) to a
sendError helper.
2016-06-14 21:11:15 +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 4f0e386862 Cleanup server code (#106)
Cleanup server code, especially around the shutdown logic, now there are
no more errors about leaking files during the tests.
2016-05-29 17:59:23 +10:00
Dave Cheney f3fc26f1c3 General server cleanups (#103)
- no need to initalise mutexes, their zero value is valid
- make NewServer simpler, 90% of use cases already had an
  io.ReadWriteCloser, in the single case that it it is easy to provide a
  simple wrapper.
2016-05-29 16:32:05 +10:00
Dave Cheney dfb5f84e82 Use pkg/errors for error handling (#101) (#102) 2016-05-23 20:54:08 +10:00
Dave Cheney 5e9ad277fc Use pkg/errors for error handling (#101) 2016-05-19 15:16:48 +10:00
Dave Cheney ca0111c37f server: fix ignored error handling in server (#100) 2016-05-19 15:04:32 +10:00
Dave Cheney bd4f7a70da server: refactor packet decoding and read only handling 2016-05-19 14:49:23 +10:00
Matt Layher 8e47c759f5 server: remote rootDir parameter, as it does nothing 2016-01-16 12:41:01 -05:00
Matt Layher 7d53b6d4ab server: return ServerOption for godoc documentation 2016-01-11 12:21:15 -05:00
Matt Layher d396b1b4cb Merge pull request #80 from pkg/functional-options
server: use functional options for NewServer
2016-01-11 11:56:30 -05:00
Matt Layher 403657b31e server: use functional options for NewServer 2016-01-11 11:52:51 -05:00
Matt Layher 167a495725 packet, server: use a single read-only check 2016-01-11 11:50:10 -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
Dave Cheney 94fb4ddd0c Add -testserver permutation
Fixes #69

io.Pipe is unbuffered and provides a poor replacement for a net.Conn, use an os.Pipe instead.

Also skip some tests which don't work under the Go server as it runs in process.
2016-01-02 10:28:56 +01:00
Matt Layher 7b7864c7f4 server: simplify code and improve readability 2015-12-30 12:56:52 -05:00
Mark Sheahan d7309968cd add more tests; bug setting S_IFREG caused openssh sftp to refuse to get the file 2015-09-08 17:03:18 -07: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 c69ab311ab all tests invoking external binaries considered integration tests to satisfy wercker 2015-09-07 02:28:33 -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 c36e806e57 runLs output matching openssh for some stuff 2015-09-06 21:37:33 -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 f9e831be30 proper ssh closing sequence 2015-08-05 23:24:33 -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 7ab0966023 readonly (only for open right now) 2015-07-30 23:43:00 -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
Mark Sheahan 91d0c9e68a mkdir 2015-07-25 19:07:33 -07:00
Mark Sheahan 5b6348f034 version, lstat 2015-07-25 01:19:29 -07:00