Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- C: Single line sent from client to server
- S> Single line sent from server to client
- == Establishing a connection
- Server opens tcp listening socket using winsock or berkeley socket
- Client connects to server
- Server accepts connection
- == Requesting server name and version
- C: INFO
- S> INFO
- S> FlamiNAS v1.2.potato
- == Requesting directory listing
- The list ends with a blank line, so we don't
- need to send the number of files to the client
- C: DIR C:\Test
- S> DIR C:\Test
- S> 123 1389828846 C:\Test\file one # first field: file length in bytes
- S> 512 1389828866 C:\Test\file two # second field: unix timestamp, last modified
- S> 8124 1389828878 C:\Test\file three # third field until newline: current filename
- S> 1823429 1389828887 C:\Test\file four
- == Requesting and downloading a file
- C: GET C:\Test\file one
- S> GET C:\Test\file one # repeat command to confirm
- S> 123 1389828846 # file length and last modified
- S> (flush file from fd to socket) # stream the contents
- == Uploading a file to the server
- (note that we need to include the lastmodified timestamp,
- so the server can store the same timestamp after download completed)
- C: PUT 123 1389830542 C:\Test\file one # Sending 123 bytes
- S> PUT 123 1389830542 C:\Test\file one # Confirm downloading 123 bytes
- C: (flush file from fd to socket)
- S> GOT 123 1389830542 C:\Test\file one
- == Deleting a file from the server
- C: DEL C:\Test\file one
- S> DEL C:\Test\file one
- == Renaming a file on the server
- C: REN C:\Test\file one # command and old filename
- C: C:\Test\pile one # new filename
- S> REN C:\Test\pile one # confirm new filename
- == Syncing will occur in a large number of steps, follow these in ordeer
- First things first:
- Client connects
- Server accepts
- == Getting the full list of files on server
- C: TREE C:\FlamiNAS
- S> (same answer as DIR but also include contents of all subfolders)
- == The following steps are all on CLIENT, since
- we have all knowledge of all files on server
- == First step:
- Find all files in TREE that are on server, but not on client.
- Find all files in TREE that are on client, but not on server.
- Compare files from both lists, see whether some have
- matching file size or LastModified.
- Send DEL command for all files that are only on server,
- and did not match any size/lastmod on client
- Send PUT command for all files that are only on client,
- and did not match any size/lastmod on server
- For each file with different names but with matching
- file size AND lastmodified, request MD5sum from server:
- C: MD5 C:\FlamiNAS\fascinating
- S> MD5 C:\FlamiNAS\fascinating
- S> 2e867426f51530ede645297b5dd7d090
- Compare checksum with local:
- Send REN command if they match.
- Send PUT command if mismatch.
Advertisement
Add Comment
Please, Sign In to add comment