Hi all,
I would like to implement rsync compatibility in my app. I'm building an
ssh server and I want to support rsync.
For example I execute this command:
1) rsync -avvvvvvvv -e "ssh -p 2022" /home/nicola/test.sh nicola at
127.0.0.1:/
and I get this exec command over ssh:
2) rsync --server -vvvvvvvvlogDtpre.iLsfxC . /
I could simply execute the requested command and let it communicate with
the remote rsync command at point 1.
This should work but I need more control over the uploaded files and
their paths. I need to check for user quota ecc.. so basically I need to
emulate the protocol implemented in rsync CLI inside my app.
There are several libraries that implement rsync protocol itself out of
there (for example to create and apply deltas) but I cannot find
libraries or documentation about rsync CLI itself.
To be more clear, after I receive the rsync command over ssh I get this
4 bytes:
1f 00 00 00
since 1f = 31 this is the protocol version
I have to answer with the remote protocol version for example, if I want
to emulate protocol version 31:
1f 00 00 00
and then I need to send this 5 (magic) bytes:
3f 94 8b b4 5d
after this the rsync client prints:
(Client) Protocol versions: remote=31, negotiated=31
FILE_STRUCT_LEN=24, EXTRA_LEN=4
and then sends the file lists.
Inside the bytes I receive server side I can read the file name but I
need some docs on how to parse these bytes and what I need to expect.
I would like to have some documentation about this protocol for rsync
CLI, is this documented somewhere?
For example I implemented scp support in my app and I found very useful
this blog post:
https://web.archive.org/web/20170215184048/https://blogs.oracle.com/janp/entry/how_the_scp_protocol_works
is there something similar for rsync?
Even some suggestions about the relevant source code to study would be
helpful,
thanks
Nicola