mkv

FlamiNAS protocol

mkv
Jan 15th, 2014
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.89 KB | None | 0 0
  1. C: Single line sent from client to server
  2. S> Single line sent from server to client
  3.  
  4. == Establishing a connection
  5. Server opens tcp listening socket using winsock or berkeley socket
  6. Client connects to server
  7. Server accepts connection
  8.  
  9. == Requesting server name and version
  10. C: INFO
  11. S> INFO
  12. S> FlamiNAS v1.2.potato
  13.  
  14. == Requesting directory listing
  15. The list ends with a blank line, so we don't
  16. need to send the number of files to the client
  17. C: DIR C:\Test
  18. S> DIR C:\Test
  19. S> 123 1389828846 C:\Test\file one # first field: file length in bytes
  20. S> 512 1389828866 C:\Test\file two # second field: unix timestamp, last modified
  21. S> 8124 1389828878 C:\Test\file three # third field until newline: current filename
  22. S> 1823429 1389828887 C:\Test\file four
  23.  
  24. == Requesting and downloading a file
  25. C: GET C:\Test\file one
  26. S> GET C:\Test\file one # repeat command to confirm
  27. S> 123 1389828846 # file length and last modified
  28. S> (flush file from fd to socket) # stream the contents
  29.  
  30. == Uploading a file to the server
  31. (note that we need to include the lastmodified timestamp,
  32. so the server can store the same timestamp after download completed)
  33.  
  34. C: PUT 123 1389830542 C:\Test\file one # Sending 123 bytes
  35. S> PUT 123 1389830542 C:\Test\file one # Confirm downloading 123 bytes
  36. C: (flush file from fd to socket)
  37. S> GOT 123 1389830542 C:\Test\file one
  38.  
  39.  
  40. == Deleting a file from the server
  41. C: DEL C:\Test\file one
  42. S> DEL C:\Test\file one
  43.  
  44. == Renaming a file on the server
  45. C: REN C:\Test\file one # command and old filename
  46. C: C:\Test\pile one # new filename
  47. S> REN C:\Test\pile one # confirm new filename
  48.  
  49.  
  50.  
  51.  
  52.  
  53. == Syncing will occur in a large number of steps, follow these in ordeer
  54. First things first:
  55.  
  56. Client connects
  57. Server accepts
  58.  
  59. == Getting the full list of files on server
  60. C: TREE C:\FlamiNAS
  61. S> (same answer as DIR but also include contents of all subfolders)
  62.  
  63.  
  64. == The following steps are all on CLIENT, since
  65. we have all knowledge of all files on server
  66.  
  67. == First step:
  68.  
  69. Find all files in TREE that are on server, but not on client.
  70. Find all files in TREE that are on client, but not on server.
  71.  
  72. Compare files from both lists, see whether some have
  73. matching file size or LastModified.
  74.  
  75. Send DEL command for all files that are only on server,
  76. and did not match any size/lastmod on client
  77.  
  78. Send PUT command for all files that are only on client,
  79. and did not match any size/lastmod on server
  80.  
  81. For each file with different names but with matching
  82. file size AND lastmodified, request MD5sum from server:
  83. C: MD5 C:\FlamiNAS\fascinating
  84. S> MD5 C:\FlamiNAS\fascinating
  85. S> 2e867426f51530ede645297b5dd7d090
  86.  
  87. Compare checksum with local:
  88. Send REN command if they match.
  89. Send PUT command if mismatch.
Advertisement
Add Comment
Please, Sign In to add comment