syncthing-bep.7 46 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450
  1. .\" Man page generated from reStructuredText.
  2. .
  3. .TH "SYNCTHING-BEP" "7" "April 08, 2016" "v0.12" "Syncthing"
  4. .SH NAME
  5. syncthing-bep \- Block Exchange Protocol v1
  6. .
  7. .nr rst2man-indent-level 0
  8. .
  9. .de1 rstReportMargin
  10. \\$1 \\n[an-margin]
  11. level \\n[rst2man-indent-level]
  12. level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
  13. -
  14. \\n[rst2man-indent0]
  15. \\n[rst2man-indent1]
  16. \\n[rst2man-indent2]
  17. ..
  18. .de1 INDENT
  19. .\" .rstReportMargin pre:
  20. . RS \\$1
  21. . nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin]
  22. . nr rst2man-indent-level +1
  23. .\" .rstReportMargin post:
  24. ..
  25. .de UNINDENT
  26. . RE
  27. .\" indent \\n[an-margin]
  28. .\" old: \\n[rst2man-indent\\n[rst2man-indent-level]]
  29. .nr rst2man-indent-level -1
  30. .\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
  31. .in \\n[rst2man-indent\\n[rst2man-indent-level]]u
  32. ..
  33. .SH INTRODUCTION AND DEFINITIONS
  34. .sp
  35. BEP is used between two or more \fIdevices\fP thus forming a \fIcluster\fP\&. Each
  36. device has one or more \fIfolders\fP of files described by the \fIlocal
  37. model\fP, containing metadata and block hashes. The local model is sent to
  38. the other devices in the cluster. The union of all files in the local
  39. models, with files selected for highest change version, forms the
  40. \fIglobal model\fP\&. Each device strives to get its folders in sync with the
  41. global model by requesting missing or outdated blocks from the other
  42. devices in the cluster.
  43. .sp
  44. File data is described and transferred in units of \fIblocks\fP, each being
  45. 128 KiB (131072 bytes) in size.
  46. .sp
  47. The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
  48. "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this
  49. document are to be interpreted as described in RFC 2119.
  50. .SH TRANSPORT AND AUTHENTICATION
  51. .sp
  52. BEP is deployed as the highest level in a protocol stack, with the lower
  53. level protocols providing encryption and authentication.
  54. .INDENT 0.0
  55. .INDENT 3.5
  56. .sp
  57. .nf
  58. .ft C
  59. +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+
  60. | Block Exchange Protocol |
  61. |\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-|
  62. | Encryption & Auth (TLS 1.2) |
  63. |\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-|
  64. | TCP |
  65. |\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-|
  66. v ... v
  67. .ft P
  68. .fi
  69. .UNINDENT
  70. .UNINDENT
  71. .sp
  72. The encryption and authentication layer SHALL use TLS 1.2 or a higher
  73. revision. A strong cipher suite SHALL be used, with "strong cipher
  74. suite" being defined as being without known weaknesses and providing
  75. Perfect Forward Secrecy (PFS). Examples of strong cipher suites are
  76. given at the end of this document. This is not to be taken as an
  77. exhaustive list of allowed cipher suites but represents best practices
  78. at the time of writing.
  79. .sp
  80. The exact nature of the authentication is up to the application, however
  81. it SHALL be based on the TLS certificate presented at the start of the
  82. connection. Possibilities include certificates signed by a common
  83. trusted CA, preshared certificates, preshared certificate fingerprints
  84. or certificate pinning combined with some out of band first
  85. verification. The reference implementation uses preshared certificate
  86. fingerprints (SHA\-256) referred to as "Device IDs".
  87. .sp
  88. There is no required order or synchronization among BEP messages except
  89. as noted per message type \- any message type may be sent at any time and
  90. the sender need not await a response to one message before sending
  91. another.
  92. .sp
  93. The underlying transport protocol MUST be TCP.
  94. .SH MESSAGES
  95. .sp
  96. Every message starts with one 32 bit word indicating the message version, type
  97. and ID, followed by the length of the message. The header is in network byte
  98. order, i.e. big endian. In this document, in diagrams and text, "bit 0" refers
  99. to the \fImost significant\fP bit of a word; "bit 31" is thus the least
  100. significant bit of a 32 bit word.
  101. .INDENT 0.0
  102. .INDENT 3.5
  103. .sp
  104. .nf
  105. .ft C
  106. 0 1 2 3
  107. 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
  108. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  109. | Ver | Message ID | Type | Reserved |C|
  110. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  111. | Length |
  112. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  113. .ft P
  114. .fi
  115. .UNINDENT
  116. .UNINDENT
  117. .sp
  118. For BEP v1 the \fBVersion\fP field is set to zero. Future versions with
  119. incompatible message formats will increment the Version field. A message
  120. with an unknown version is a protocol error and MUST result in the
  121. connection being terminated. A client supporting multiple versions MAY
  122. retry with a different protocol version upon disconnection.
  123. .sp
  124. The \fBMessage ID\fP is set to a unique value for each transmitted Request
  125. message. In Response messages it is set to the Message ID of the corresponding
  126. Request message. The uniqueness requirement implies that no more than 4096
  127. request messages may be outstanding at any given moment. For message types
  128. that do not have a corresponding response (Cluster Configuration, Index, etc.)
  129. the Message ID field is irrelevant and SHOULD be set to zero.
  130. .sp
  131. The \fBType\fP field indicates the type of data following the message header
  132. and is one of the integers defined below. A message of an unknown type
  133. is a protocol error and MUST result in the connection being terminated.
  134. .sp
  135. The \fBCompression\fP bit "C" indicates the compression used for the message.
  136. .sp
  137. For C=0:
  138. .INDENT 0.0
  139. .IP \(bu 2
  140. The Length field contains the length, in bytes, of the uncompressed
  141. message data.
  142. .IP \(bu 2
  143. The message is not compressed.
  144. .UNINDENT
  145. .sp
  146. For C=1:
  147. .INDENT 0.0
  148. .IP \(bu 2
  149. The Length field contains the length, in bytes, of the compressed
  150. message data plus a four byte uncompressed length field.
  151. .IP \(bu 2
  152. The compressed message data is preceeded by a 32 bit field denoting
  153. the length of the uncompressed message.
  154. .IP \(bu 2
  155. The message data is compressed using the LZ4 format and algorithm
  156. described in \fI\%http://www.lz4.org/\fP\&.
  157. .UNINDENT
  158. .sp
  159. All data within the message (post decompression, if compression is in
  160. use) MUST be in XDR (RFC 1014) encoding. All fields shorter than 32 bits
  161. and all variable length data MUST be padded to a multiple of 32 bits.
  162. The actual data types in use by BEP, in XDR naming convention, are the
  163. following:
  164. .INDENT 0.0
  165. .TP
  166. .B (unsigned) int:
  167. (unsigned) 32 bit integer
  168. .TP
  169. .B (unsigned) hyper:
  170. (unsigned) 64 bit integer
  171. .TP
  172. .B opaque<>
  173. variable length opaque data
  174. .TP
  175. .B string<>
  176. variable length string
  177. .UNINDENT
  178. .sp
  179. The transmitted length of string and opaque data is the length of actual
  180. data, excluding any added padding. The encoding of opaque<> and string<>
  181. are identical, the distinction being solely one of interpretation.
  182. Opaque data should not be interpreted but can be compared bytewise to
  183. other opaque data. All strings MUST use the Unicode UTF\-8 encoding,
  184. normalization form C.
  185. .SS Cluster Config (Type = 0)
  186. .sp
  187. This informational message provides information about the cluster
  188. configuration as it pertains to the current connection. A Cluster Config
  189. message MUST be the first message sent on a BEP connection. Additional
  190. Cluster Config messages MUST NOT be sent after the initial exchange.
  191. .SS Graphical Representation
  192. .INDENT 0.0
  193. .INDENT 3.5
  194. .sp
  195. .nf
  196. .ft C
  197. ClusterConfigMessage Structure:
  198. 0 1 2 3
  199. 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
  200. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  201. | Length of Device Name |
  202. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  203. / /
  204. \e Device Name (variable length) \e
  205. / /
  206. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  207. | Length of Client Name |
  208. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  209. / /
  210. \e Client Name (variable length) \e
  211. / /
  212. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  213. | Length of Client Version |
  214. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  215. / /
  216. \e Client Version (variable length) \e
  217. / /
  218. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  219. | Number of Folders |
  220. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  221. / /
  222. \e Zero or more Folder Structures \e
  223. / /
  224. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  225. | Number of Options |
  226. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  227. / /
  228. \e Zero or more Option Structures \e
  229. / /
  230. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  231. Folder Structure:
  232. 0 1 2 3
  233. 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
  234. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  235. | Length of ID |
  236. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  237. / /
  238. \e ID (variable length) \e
  239. / /
  240. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  241. / /
  242. \e Label (length + padded data) \e
  243. / /
  244. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  245. | Number of Devices |
  246. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  247. / /
  248. \e Zero or more Device Structures \e
  249. / /
  250. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  251. | Flags |
  252. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  253. | Number of Options |
  254. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  255. / /
  256. \e Zero or more Option Structures \e
  257. / /
  258. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  259. Device Structure:
  260. 0 1 2 3
  261. 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
  262. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  263. | Length of ID |
  264. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  265. / /
  266. \e ID (variable length) \e
  267. / /
  268. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  269. | Length of Name |
  270. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  271. / /
  272. \e Name (variable length) \e
  273. / /
  274. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  275. | Number of Addresses |
  276. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  277. | Length of Address |
  278. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  279. / /
  280. \e Address (variable length) \e
  281. / /
  282. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  283. | Compression |
  284. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  285. | Length of Cert Name |
  286. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  287. / /
  288. \e Cert Name (variable length) \e
  289. / /
  290. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  291. | |
  292. + Max Local Version (64 bits) +
  293. | |
  294. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  295. | Flags |
  296. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  297. | Number of Options |
  298. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  299. / /
  300. \e Zero or more Option Structures \e
  301. / /
  302. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  303. Option Structure:
  304. 0 1 2 3
  305. 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
  306. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  307. | Length of Key |
  308. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  309. / /
  310. \e Key (variable length) \e
  311. / /
  312. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  313. | Length of Value |
  314. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  315. / /
  316. \e Value (variable length) \e
  317. / /
  318. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  319. .ft P
  320. .fi
  321. .UNINDENT
  322. .UNINDENT
  323. .SS Fields (ClusterConfigMessage)
  324. .sp
  325. The \fBDevice Name\fP is a human readable (configured or auto detected) device
  326. name or host name, for the sending device.
  327. .sp
  328. The \fBClient Name\fP and \fBClient Version\fP identifies the implementation. The
  329. values SHOULD be simple strings identifying the implementation name, as a
  330. user would expect to see it, and the version string in the same manner. An
  331. example Client Name is "syncthing" and an example Client Version is "v0.7.2".
  332. The Client Version field SHOULD follow the patterns laid out in the \fI\%Semantic
  333. Versioning\fP <\fBhttp://semver.org/\fP> standard.
  334. .sp
  335. The \fBFolders\fP field contains the list of folders that will be synchronized
  336. over the current connection.
  337. .sp
  338. The \fBOptions\fP field is a list of options that apply to the current
  339. connection. The options are used in an implementation specific manner. The
  340. options list is conceptually a map of keys to values, although it is
  341. transmitted in the form of a list of key and value pairs, both of string type.
  342. Key ID:s are implementation specific. An implementation MUST ignore unknown
  343. keys. An implementation MAY impose limits on the length keys and values. The
  344. options list may be used to inform devices of relevant local configuration
  345. options such as rate limiting or make recommendations about request
  346. parallelism, device priorities, etc. An empty options list is valid for
  347. devices not having any such information to share. Devices MAY NOT make any
  348. assumptions about peers acting in a specific manner as a result of sent
  349. options.
  350. .SS Fields (Folder Structure)
  351. .sp
  352. The \fBID\fP field contains the folder ID, as a human readable string.
  353. .sp
  354. The \fBLabel\fP field contains the folder label, as human readable name for the folder.
  355. .sp
  356. The \fBDevices\fP field is list of devices participating in sharing this folder.
  357. .sp
  358. The \fBFlags\fP field contains flags that affect the behavior of the folder. The
  359. folder Flags field contains the following single bit flags:
  360. .INDENT 0.0
  361. .INDENT 3.5
  362. .sp
  363. .nf
  364. .ft C
  365. 0 1 2 3
  366. 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
  367. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  368. | Reserved |D|P|R|
  369. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  370. .ft P
  371. .fi
  372. .UNINDENT
  373. .UNINDENT
  374. .INDENT 0.0
  375. .TP
  376. .B Bit 31 ("R", Read Only)
  377. is set for folders that the device will accept no updates from the network
  378. for.
  379. .TP
  380. .B Bit 30 ("P", Ignore Permissions)
  381. is set for folders that the device will not accept or announce file
  382. permissions for.
  383. .TP
  384. .B Bit 29 ("D", Ignore Deletes)
  385. is set for folders that the device will ignore deletes for.
  386. .UNINDENT
  387. .sp
  388. The \fBOptions\fP field contains a list of options that apply to the folder.
  389. .SS Fields (Device Structure)
  390. .sp
  391. The device \fBID\fP field is a 32 byte number that uniquely identifies the
  392. device. For instance, the reference implementation uses the SHA\-256 of the
  393. device X.509 certificate.
  394. .sp
  395. The \fBName\fP field is a human readable name assigned to the described device
  396. by the sending device. It MAY be empty and it need not be unique.
  397. .sp
  398. The list of \fBAddressess\fP is that used by the sending device to connect to
  399. the described device.
  400. .sp
  401. The \fBCompression\fP field indicates the compression mode in use for this
  402. device and folder. The following values are valid:
  403. .INDENT 0.0
  404. .TP
  405. .B 0
  406. Compress metadata. This enables compression of metadata messages such as Index.
  407. .TP
  408. .B 1
  409. Compression disabled. No compression is used on any message.
  410. .TP
  411. .B 2
  412. Compress always. Metadata messages as well as Response messages are compressed.
  413. .UNINDENT
  414. .sp
  415. The \fBCert Name\fP field indicates the expected certificate name for this
  416. device. It is commonly blank, indicating to use the implementation default.
  417. .sp
  418. The \fBMax Local Version\fP field contains the highest local file
  419. version number of the files already known to be in the index sent by
  420. this device. If nothing is known about the index of a given device, this
  421. field MUST be set to zero. When receiving a Cluster Config message with
  422. a non\-zero Max Local Version for the local device ID, a device MAY elect
  423. to send an Index Update message containing only files with higher local
  424. version numbers in place of the initial Index message.
  425. .sp
  426. The \fBFlags\fP field indicates the sharing mode of the folder and other device
  427. & folder specific settings. See the discussion on Sharing Modes. The Device
  428. Flags field contains the following single bit flags:
  429. .INDENT 0.0
  430. .INDENT 3.5
  431. .sp
  432. .nf
  433. .ft C
  434. 0 1 2 3
  435. 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
  436. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  437. | Reserved |Pri| Reserved |I|R|T|
  438. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  439. .ft P
  440. .fi
  441. .UNINDENT
  442. .UNINDENT
  443. .INDENT 0.0
  444. .TP
  445. .B Bit 31 ("T", Trusted)
  446. is set for devices that participate in trusted
  447. mode.
  448. .TP
  449. .B Bit 30 ("R", Read Only)
  450. is set for devices that participate in read
  451. only mode.
  452. .TP
  453. .B Bit 29 ("I", Introducer)
  454. is set for devices that are trusted as
  455. cluster introducers.
  456. .TP
  457. .B Bits 16 through 28
  458. are reserved and MUST be set to zero.
  459. .TP
  460. .B Bits 14\-15 ("Pri)
  461. indicate the device\(aqs upload priority for this
  462. folder. Possible values are:
  463. .INDENT 7.0
  464. .TP
  465. .B 00
  466. The default. Normal priority.
  467. .TP
  468. .B 01
  469. High priority. Other devices SHOULD favour requesting files
  470. from this device over devices with normal or low priority.
  471. .TP
  472. .B 10
  473. Low priority. Other devices SHOULD avoid requesting files from
  474. this device when they are available from other devices.
  475. .TP
  476. .B 11
  477. Sharing disabled. Other devices SHOULD NOT request files from
  478. this device.
  479. .UNINDENT
  480. .TP
  481. .B Bits 0 through 14
  482. are reserved and MUST be set to zero.
  483. .UNINDENT
  484. .sp
  485. Exactly one of the T and R bits MUST be set.
  486. .sp
  487. The \fBOptions\fP field contains a list of options that apply to the device.
  488. .SS XDR
  489. .INDENT 0.0
  490. .INDENT 3.5
  491. .sp
  492. .nf
  493. .ft C
  494. struct ClusterConfigMessage {
  495. string DeviceName<64>;
  496. string ClientName<64>;
  497. string ClientVersion<64>;
  498. Folder Folders<1000000>;
  499. Option Options<64>;
  500. };
  501. struct Folder {
  502. string ID<256>;
  503. string Label<256>;
  504. Device Devices<1000000>;
  505. unsigned int Flags;
  506. Option Options<64>;
  507. };
  508. struct Device {
  509. opaque ID<32>;
  510. string Name<64>;
  511. string Addresses<64>;
  512. unsigned int Compression;
  513. string CertName<64>;
  514. hyper MaxLocalVersion;
  515. unsigned int Flags;
  516. Option Options<64>;
  517. };
  518. struct Option {
  519. string Key<64>;
  520. string Value<1024>;
  521. };
  522. .ft P
  523. .fi
  524. .UNINDENT
  525. .UNINDENT
  526. .SS Index (Type = 1) and Index Update (Type = 6)
  527. .sp
  528. The Index and Index Update messages define the contents of the senders
  529. folder. An Index message represents the full contents of the folder and
  530. thus supersedes any previous index. An Index Update amends an existing
  531. index with new information, not affecting any entries not included in
  532. the message. An Index Update MAY NOT be sent unless preceded by an
  533. Index, unless a non\-zero Max Local Version has been announced for the
  534. given folder by the peer device.
  535. .SS Graphical Representation
  536. .INDENT 0.0
  537. .INDENT 3.5
  538. .sp
  539. .nf
  540. .ft C
  541. IndexMessage Structure:
  542. 0 1 2 3
  543. 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
  544. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  545. | Length of Folder |
  546. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  547. / /
  548. \e Folder (variable length) \e
  549. / /
  550. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  551. | Number of Files |
  552. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  553. / /
  554. \e Zero or more FileInfo Structures \e
  555. / /
  556. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  557. | Flags |
  558. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  559. | Number of Options |
  560. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  561. / /
  562. \e Zero or more Option Structures \e
  563. / /
  564. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  565. FileInfo Structure:
  566. 0 1 2 3
  567. 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
  568. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  569. | Length of Name |
  570. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  571. / /
  572. \e Name (variable length) \e
  573. / /
  574. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  575. | Flags |
  576. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  577. | |
  578. + Modified (64 bits) +
  579. | |
  580. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  581. / /
  582. \e Version (variable length) \e
  583. / /
  584. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  585. | |
  586. + Local Version (64 bits) +
  587. | |
  588. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  589. | Number of Blocks |
  590. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  591. / /
  592. \e Zero or more BlockInfo Structures \e
  593. / /
  594. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  595. Vector Structure:
  596. 0 1 2 3
  597. 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
  598. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  599. | Number of Counters |
  600. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  601. / /
  602. \e Zero or more Counter Structures \e
  603. / /
  604. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  605. Counter Structure:
  606. 0 1 2 3
  607. 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
  608. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  609. | |
  610. + ID (64 bits) +
  611. | |
  612. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  613. | |
  614. + Value (64 bits) +
  615. | |
  616. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  617. BlockInfo Structure:
  618. 0 1 2 3
  619. 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
  620. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  621. | Size |
  622. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  623. | Length of Hash |
  624. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  625. / /
  626. \e Hash (variable length) \e
  627. / /
  628. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  629. .ft P
  630. .fi
  631. .UNINDENT
  632. .UNINDENT
  633. .SS Fields (Index Message)
  634. .sp
  635. The \fBFolder\fP field identifies the folder that the index message pertains to.
  636. .sp
  637. \fBFiles\fP
  638. .sp
  639. The \fBFlags\fP field is reserved for future use and MUST currently be set to
  640. zero.
  641. .sp
  642. The \fBOptions\fP list is implementation defined and as described in the
  643. ClusterConfig message section.
  644. .SS Fields (FileInfo Structure)
  645. .sp
  646. The \fBName\fP is the file name path relative to the folder root. Like all
  647. strings in BEP, the Name is always in UTF\-8 NFC regardless of operating
  648. system or file system specific conventions. The Name field uses the
  649. slash character ("/") as path separator, regardless of the
  650. implementation\(aqs operating system conventions. The combination of Folder
  651. and Name uniquely identifies each file in a cluster.
  652. .sp
  653. The \fBFlags\fP field is made up of the following single bit flags:
  654. .INDENT 0.0
  655. .INDENT 3.5
  656. .sp
  657. .nf
  658. .ft C
  659. 0 1 2 3
  660. 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
  661. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  662. | Reserved |U|S|P|I|D| Unix Perm. & Mode |
  663. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  664. .ft P
  665. .fi
  666. .UNINDENT
  667. .UNINDENT
  668. .INDENT 0.0
  669. .TP
  670. .B The lower 12 bits
  671. hold the common Unix permission and mode bits. An
  672. implementation MAY ignore or interpret these as is suitable on the
  673. host operating system.
  674. .TP
  675. .B Bit 19 ("D")
  676. is set when the file has been deleted. The block list
  677. SHALL be of length zero and the modification time indicates the time
  678. of deletion or, if the time of deletion is not reliably determinable,
  679. the last known modification time.
  680. .TP
  681. .B Bit 18 ("I")
  682. is set when the file is invalid and unavailable for
  683. synchronization. A peer MAY set this bit to indicate that it can
  684. temporarily not serve data for the file.
  685. .TP
  686. .B Bit 17 ("P")
  687. is set when there is no permission information for the
  688. file. This is the case when it originates on a file system which
  689. does not support permissions. Changes to only permission bits SHOULD
  690. be disregarded on files with this bit set. The permissions bits MUST
  691. be set to the octal value 0666.
  692. .TP
  693. .B Bit 16 ("S")
  694. is set when the file is a symbolic link. The block list
  695. SHALL be of one or more blocks since the target of the symlink is
  696. stored within the blocks of the file.
  697. .TP
  698. .B Bit 15 ("U")
  699. is set when the symbolic links target does not exist. On
  700. systems where symbolic links have types, this bit being means that
  701. the default file symlink SHALL be used. If this bit is unset bit 19
  702. will decide the type of symlink to be created.
  703. .TP
  704. .B Bit 0 through 14
  705. are reserved for future use and SHALL be set to
  706. zero.
  707. .UNINDENT
  708. .sp
  709. The \fBModified\fP time is expressed as the number of seconds since the Unix
  710. Epoch (1970\-01\-01 00:00:00 UTC).
  711. .sp
  712. The \fBVersion\fP field is a version vector describing the updates performed
  713. to a file by all members in the cluster. Each counter in the version
  714. vector is an ID\-Value tuple. The ID is used the first 64 bits of the
  715. device ID. The Value is a simple incrementing counter, starting at zero.
  716. The combination of Folder, Name and Version uniquely identifies the
  717. contents of a file at a given point in time.
  718. .sp
  719. The \fBLocal Version\fP field is the value of a device local monotonic clock
  720. at the time of last local database update to a file. The clock ticks on
  721. every local database update.
  722. .sp
  723. The \fBBlocks\fP list contains the size and hash for each block in the file.
  724. Each block represents a 128 KiB slice of the file, except for the last
  725. block which may represent a smaller amount of data.
  726. .sp
  727. The hash algorithm is implied by the \fBHash\fP length. Currently, the hash
  728. MUST be 32 bytes long and computed by SHA256.
  729. .SS XDR
  730. .INDENT 0.0
  731. .INDENT 3.5
  732. .sp
  733. .nf
  734. .ft C
  735. struct IndexMessage {
  736. string Folder<256>;
  737. FileInfo Files<1000000>;
  738. unsigned int Flags;
  739. Option Options<64>;
  740. };
  741. struct FileInfo {
  742. string Name<8192>;
  743. unsigned int Flags;
  744. hyper Modified;
  745. Vector Version;
  746. hyper LocalVersion;
  747. BlockInfo Blocks<10000000>;
  748. };
  749. struct Vector {
  750. Counter Counters<>;
  751. };
  752. struct Counter {
  753. unsigned hyper ID;
  754. unsigned hyper Value;
  755. };
  756. struct BlockInfo {
  757. unsigned int Size;
  758. opaque Hash<64>;
  759. };
  760. .ft P
  761. .fi
  762. .UNINDENT
  763. .UNINDENT
  764. .SS Request (Type = 2)
  765. .sp
  766. The Request message expresses the desire to receive a data block
  767. corresponding to a part of a certain file in the peer\(aqs folder.
  768. .SS Graphical Representation
  769. .INDENT 0.0
  770. .INDENT 3.5
  771. .sp
  772. .nf
  773. .ft C
  774. RequestMessage Structure:
  775. 0 1 2 3
  776. 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
  777. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  778. | Length of Folder |
  779. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  780. / /
  781. \e Folder (variable length) \e
  782. / /
  783. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  784. | Length of Name |
  785. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  786. / /
  787. \e Name (variable length) \e
  788. / /
  789. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  790. | |
  791. + Offset (64 bits) +
  792. | |
  793. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  794. | Size |
  795. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  796. | Length of Hash |
  797. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  798. / /
  799. \e Hash (variable length) \e
  800. / /
  801. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  802. | Flags |
  803. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  804. | Number of Options |
  805. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  806. / /
  807. \e Zero or more Option Structures \e
  808. / /
  809. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  810. .ft P
  811. .fi
  812. .UNINDENT
  813. .UNINDENT
  814. .SS Fields
  815. .sp
  816. The Folder and Name fields are as documented for the Index message. The
  817. Offset and Size fields specify the region of the file to be transferred.
  818. This SHOULD equate to exactly one block as seen in an Index message.
  819. .sp
  820. The Hash field MAY be set to the expected hash value of the block, or
  821. may be left empty (zero length). If set, the other device SHOULD ensure
  822. that the transmitted block matches the requested hash. The other device
  823. MAY reuse a block from a different file and offset having the same size
  824. and hash, if one exists.
  825. .sp
  826. The Flags field is reserved for future use and MUST currently be set to
  827. zero. The Options list is implementation defined and as described in the
  828. ClusterConfig message section.
  829. .SS XDR
  830. .INDENT 0.0
  831. .INDENT 3.5
  832. .sp
  833. .nf
  834. .ft C
  835. struct RequestMessage {
  836. string Folder<64>;
  837. string Name<8192>;
  838. hyper Offset;
  839. int Size;
  840. opaque Hash<64>;
  841. unsigned int Flags;
  842. Option Options<64>;
  843. };
  844. .ft P
  845. .fi
  846. .UNINDENT
  847. .UNINDENT
  848. .SS Response (Type = 3)
  849. .sp
  850. The Response message is sent in response to a Request message.
  851. .SS Graphical Representation
  852. .sp
  853. ResponseMessage Structure:
  854. .INDENT 0.0
  855. .INDENT 3.5
  856. .sp
  857. .nf
  858. .ft C
  859. 0 1 2 3
  860. 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
  861. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  862. | Length of Data |
  863. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  864. / /
  865. \e Data (variable length) \e
  866. / /
  867. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  868. | Code |
  869. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  870. .ft P
  871. .fi
  872. .UNINDENT
  873. .UNINDENT
  874. .SS Fields
  875. .sp
  876. The \fBData\fP field contains either a full 128 KiB block, a shorter block in
  877. the case of the last block in a file, or is empty (zero length) if the
  878. requested block is not available.
  879. .sp
  880. The \fBCode\fP field contains an error code describing the reason a Request
  881. could not be fulfilled, in the case where a zero length Data was
  882. returned. The following values are defined:
  883. .INDENT 0.0
  884. .TP
  885. .B 0
  886. No Error (Data should be present)
  887. .TP
  888. .B 1
  889. Generic Error
  890. .TP
  891. .B 2
  892. No Such File (the requested file does not exist, or the offset is
  893. outside the acceptable range for the file)
  894. .TP
  895. .B 3
  896. Invalid (file exists but has invalid bit set or is otherwise
  897. unavailable)
  898. .UNINDENT
  899. .SS XDR
  900. .INDENT 0.0
  901. .INDENT 3.5
  902. .sp
  903. .nf
  904. .ft C
  905. struct ResponseMessage {
  906. opaque Data<>;
  907. int Code;
  908. }
  909. .ft P
  910. .fi
  911. .UNINDENT
  912. .UNINDENT
  913. .SS Ping (Type = 4)
  914. .sp
  915. The Ping message is used to determine that a connection is alive, and to keep
  916. connections alive through state tracking network elements such as firewalls
  917. and NAT gateways. The Ping message has no contents. A Ping message is sent
  918. every 90 seconds, if no other message has been sent in the preceding 90
  919. seconds.
  920. .SS Close (Type = 7)
  921. .sp
  922. The Close message MAY be sent to indicate that the connection will be
  923. torn down due to an error condition. A Close message MUST NOT be
  924. followed by further messages.
  925. .SS Graphical Representation
  926. .INDENT 0.0
  927. .INDENT 3.5
  928. .sp
  929. .nf
  930. .ft C
  931. CloseMessage Structure:
  932. 0 1 2 3
  933. 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
  934. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  935. | Length of Reason |
  936. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  937. / /
  938. \e Reason (variable length) \e
  939. / /
  940. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  941. | Code |
  942. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  943. .ft P
  944. .fi
  945. .UNINDENT
  946. .UNINDENT
  947. .SS Fields
  948. .sp
  949. The \fBReason\fP field contains a human description of the error condition,
  950. suitable for consumption by a human. The \fBCode\fP field is for a machine
  951. readable error code. Codes are reserved for future use and MUST
  952. currently be set to zero.
  953. .INDENT 0.0
  954. .INDENT 3.5
  955. .sp
  956. .nf
  957. .ft C
  958. struct CloseMessage {
  959. string Reason<1024>;
  960. int Code;
  961. }
  962. .ft P
  963. .fi
  964. .UNINDENT
  965. .UNINDENT
  966. .SH SHARING MODES
  967. .SS Trusted
  968. .sp
  969. Trusted mode is the default sharing mode. Updates are exchanged in both
  970. directions.
  971. .INDENT 0.0
  972. .INDENT 3.5
  973. .sp
  974. .nf
  975. .ft C
  976. +\-\-\-\-\-\-\-\-\-\-\-\-+ Updates /\-\-\-\-\-\-\-\-\-\e
  977. | | \-\-\-\-\-\-\-\-\-\-\-> / \e
  978. | Device | | Cluster |
  979. | | <\-\-\-\-\-\-\-\-\-\-\- \e /
  980. +\-\-\-\-\-\-\-\-\-\-\-\-+ Updates \e\-\-\-\-\-\-\-\-\-/
  981. .ft P
  982. .fi
  983. .UNINDENT
  984. .UNINDENT
  985. .SS Read Only
  986. .sp
  987. In read only mode, a device does not apply any updates from the cluster,
  988. but publishes changes of its local folder to the cluster as usual.
  989. The local folder can be seen as a "master copy" that is never affected
  990. by the actions of other cluster devices.
  991. .INDENT 0.0
  992. .INDENT 3.5
  993. .sp
  994. .nf
  995. .ft C
  996. +\-\-\-\-\-\-\-\-\-\-\-\-+ Updates /\-\-\-\-\-\-\-\-\-\e
  997. | | \-\-\-\-\-\-\-\-\-\-\-> / \e
  998. | Device | | Cluster |
  999. | | \e /
  1000. +\-\-\-\-\-\-\-\-\-\-\-\-+ \e\-\-\-\-\-\-\-\-\-/
  1001. .ft P
  1002. .fi
  1003. .UNINDENT
  1004. .UNINDENT
  1005. .SH MESSAGE LIMITS
  1006. .sp
  1007. An implementation MAY impose reasonable limits on the length of messages
  1008. and message fields to aid robustness in the face of corruption or broken
  1009. implementations. These limits, if imposed, SHOULD NOT be more
  1010. restrictive than the following. An implementation should strive to keep
  1011. messages short and to the point, favouring more and smaller messages
  1012. over fewer and larger. For example, favour a smaller Index message
  1013. followed by one or more Index Update messages rather than sending a very
  1014. large Index message.
  1015. .TS
  1016. center;
  1017. |l|l|l|.
  1018. _
  1019. T{
  1020. Message Type
  1021. T} T{
  1022. Field
  1023. T} T{
  1024. Limit
  1025. T}
  1026. _
  1027. T{
  1028. \fBAll Messages\fP
  1029. T}
  1030. _
  1031. T{
  1032. .nf
  1033. .fi
  1034. T} T{
  1035. Total length
  1036. T} T{
  1037. 512 MiB
  1038. T}
  1039. _
  1040. T{
  1041. \fBIndex and Index Update Messages\fP
  1042. T}
  1043. _
  1044. T{
  1045. .nf
  1046. .fi
  1047. T} T{
  1048. Folder
  1049. T} T{
  1050. 64 bytes
  1051. T}
  1052. _
  1053. T{
  1054. .nf
  1055. .fi
  1056. T} T{
  1057. Number of Files
  1058. T} T{
  1059. 1.000.000
  1060. T}
  1061. _
  1062. T{
  1063. .nf
  1064. .fi
  1065. T} T{
  1066. Name
  1067. T} T{
  1068. 8192 bytes
  1069. T}
  1070. _
  1071. T{
  1072. .nf
  1073. .fi
  1074. T} T{
  1075. Number of Blocks
  1076. T} T{
  1077. 10.000.000
  1078. T}
  1079. _
  1080. T{
  1081. .nf
  1082. .fi
  1083. T} T{
  1084. Hash
  1085. T} T{
  1086. 64 bytes
  1087. T}
  1088. _
  1089. T{
  1090. .nf
  1091. .fi
  1092. T} T{
  1093. Number of Counters
  1094. T} T{
  1095. 1.000.000
  1096. T}
  1097. _
  1098. T{
  1099. \fBRequest Messages\fP
  1100. T}
  1101. _
  1102. T{
  1103. .nf
  1104. .fi
  1105. T} T{
  1106. Folder
  1107. T} T{
  1108. 64 bytes
  1109. T}
  1110. _
  1111. T{
  1112. .nf
  1113. .fi
  1114. T} T{
  1115. Name
  1116. T} T{
  1117. 8192 bytes
  1118. T}
  1119. _
  1120. T{
  1121. \fBResponse Messages\fP
  1122. T}
  1123. _
  1124. T{
  1125. .nf
  1126. .fi
  1127. T} T{
  1128. Data
  1129. T} T{
  1130. 256 KiB
  1131. T}
  1132. _
  1133. T{
  1134. \fBCluster Config Message\fP
  1135. T}
  1136. _
  1137. T{
  1138. .nf
  1139. .fi
  1140. T} T{
  1141. Number of Folders
  1142. T} T{
  1143. 1.000.000
  1144. T}
  1145. _
  1146. T{
  1147. .nf
  1148. .fi
  1149. T} T{
  1150. Number of Devices
  1151. T} T{
  1152. 1.000.000
  1153. T}
  1154. _
  1155. T{
  1156. .nf
  1157. .fi
  1158. T} T{
  1159. Number of Options
  1160. T} T{
  1161. 64
  1162. T}
  1163. _
  1164. T{
  1165. .nf
  1166. .fi
  1167. T} T{
  1168. Key
  1169. T} T{
  1170. 64 bytes
  1171. T}
  1172. _
  1173. T{
  1174. .nf
  1175. .fi
  1176. T} T{
  1177. Value
  1178. T} T{
  1179. 1024 bytes
  1180. T}
  1181. _
  1182. .TE
  1183. .sp
  1184. The currently defined values allow maximum file size of 1220 GiB
  1185. (10.000.000 x 128 KiB). The maximum message size covers an Index message
  1186. for the maximum file.
  1187. .SH EXAMPLE EXCHANGE
  1188. .TS
  1189. center;
  1190. |l|l|l|.
  1191. _
  1192. T{
  1193. #
  1194. T} T{
  1195. A
  1196. T} T{
  1197. B
  1198. T}
  1199. _
  1200. T{
  1201. 1
  1202. T} T{
  1203. ClusterConfiguration\->
  1204. T} T{
  1205. <\-ClusterConfiguration
  1206. T}
  1207. _
  1208. T{
  1209. 2
  1210. T} T{
  1211. Index\->
  1212. T} T{
  1213. <\-Index
  1214. T}
  1215. _
  1216. T{
  1217. 3
  1218. T} T{
  1219. IndexUpdate\->
  1220. T} T{
  1221. <\-IndexUpdate
  1222. T}
  1223. _
  1224. T{
  1225. 4
  1226. T} T{
  1227. IndexUpdate\->
  1228. T} T{
  1229. T}
  1230. _
  1231. T{
  1232. 5
  1233. T} T{
  1234. Request\->
  1235. T} T{
  1236. T}
  1237. _
  1238. T{
  1239. 6
  1240. T} T{
  1241. Request\->
  1242. T} T{
  1243. T}
  1244. _
  1245. T{
  1246. 7
  1247. T} T{
  1248. Request\->
  1249. T} T{
  1250. T}
  1251. _
  1252. T{
  1253. 8
  1254. T} T{
  1255. Request\->
  1256. T} T{
  1257. T}
  1258. _
  1259. T{
  1260. 9
  1261. T} T{
  1262. T} T{
  1263. <\-Response
  1264. T}
  1265. _
  1266. T{
  1267. 10
  1268. T} T{
  1269. T} T{
  1270. <\-Response
  1271. T}
  1272. _
  1273. T{
  1274. 11
  1275. T} T{
  1276. T} T{
  1277. <\-Response
  1278. T}
  1279. _
  1280. T{
  1281. 12
  1282. T} T{
  1283. T} T{
  1284. <\-Response
  1285. T}
  1286. _
  1287. T{
  1288. 13
  1289. T} T{
  1290. Index Update\->
  1291. T} T{
  1292. T}
  1293. _
  1294. T{
  1295. \&...
  1296. T} T{
  1297. T} T{
  1298. T}
  1299. _
  1300. T{
  1301. 14
  1302. T} T{
  1303. T} T{
  1304. <\-Ping
  1305. T}
  1306. _
  1307. T{
  1308. 15
  1309. T} T{
  1310. Ping\->
  1311. T} T{
  1312. T}
  1313. _
  1314. .TE
  1315. .sp
  1316. The connection is established and at 1. both peers send ClusterConfiguration
  1317. messages and then Index records. The Index records are received and both peers
  1318. recompute their knowledge of the data in the cluster. In this example, peer A
  1319. has four missing or outdated blocks. At 5 through 8 peer A sends requests for
  1320. these blocks. The requests are received by peer B, who retrieves the data from
  1321. the folder and transmits Response records (9 through 12). Device A updates
  1322. their folder contents and transmits an Index Update message (13). Both peers
  1323. enter idle state after 13. At some later time 14, the ping timer on device B
  1324. expires and a Ping message is sent. The same process occurs for device A at
  1325. 15.
  1326. .SH EXAMPLES OF STRONG CIPHER SUITES
  1327. .TS
  1328. center;
  1329. |l|l|l|.
  1330. _
  1331. T{
  1332. ID
  1333. T} T{
  1334. Name
  1335. T} T{
  1336. Description
  1337. T}
  1338. _
  1339. T{
  1340. 0x009F
  1341. T} T{
  1342. DHE\-RSA\-AES256\-GCM\-SHA384
  1343. T} T{
  1344. TLSv1.2 DH RSA AESGCM(256) AEAD
  1345. T}
  1346. _
  1347. T{
  1348. 0x006B
  1349. T} T{
  1350. DHE\-RSA\-AES256\-SHA256
  1351. T} T{
  1352. TLSv1.2 DH RSA AES(256) SHA256
  1353. T}
  1354. _
  1355. T{
  1356. 0xC030
  1357. T} T{
  1358. ECDHE\-RSA\-AES256\-GCM\-SHA384
  1359. T} T{
  1360. TLSv1.2 ECDH RSA AESGCM(256) AEAD
  1361. T}
  1362. _
  1363. T{
  1364. 0xC028
  1365. T} T{
  1366. ECDHE\-RSA\-AES256\-SHA384
  1367. T} T{
  1368. TLSv1.2 ECDH RSA AES(256) SHA384
  1369. T}
  1370. _
  1371. T{
  1372. 0x009E
  1373. T} T{
  1374. DHE\-RSA\-AES128\-GCM\-SHA256
  1375. T} T{
  1376. TLSv1.2 DH RSA AESGCM(128) AEAD
  1377. T}
  1378. _
  1379. T{
  1380. 0x0067
  1381. T} T{
  1382. DHE\-RSA\-AES128\-SHA256
  1383. T} T{
  1384. TLSv1.2 DH RSA AES(128) SHA256
  1385. T}
  1386. _
  1387. T{
  1388. 0xC02F
  1389. T} T{
  1390. ECDHE\-RSA\-AES128\-GCM\-SHA256
  1391. T} T{
  1392. TLSv1.2 ECDH RSA AESGCM(128) AEAD
  1393. T}
  1394. _
  1395. T{
  1396. 0xC027
  1397. T} T{
  1398. ECDHE\-RSA\-AES128\-SHA256
  1399. T} T{
  1400. TLSv1.2 ECDH RSA AES(128) SHA256
  1401. T}
  1402. _
  1403. .TE
  1404. .SH AUTHOR
  1405. The Syncthing Authors
  1406. .SH COPYRIGHT
  1407. 2015, The Syncthing Authors
  1408. .\" Generated by docutils manpage writer.
  1409. .