syncthing-relay.7 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679
  1. '\" t
  2. .\" Man page generated from reStructuredText.
  3. .
  4. .
  5. .nr rst2man-indent-level 0
  6. .
  7. .de1 rstReportMargin
  8. \\$1 \\n[an-margin]
  9. level \\n[rst2man-indent-level]
  10. level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
  11. -
  12. \\n[rst2man-indent0]
  13. \\n[rst2man-indent1]
  14. \\n[rst2man-indent2]
  15. ..
  16. .de1 INDENT
  17. .\" .rstReportMargin pre:
  18. . RS \\$1
  19. . nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin]
  20. . nr rst2man-indent-level +1
  21. .\" .rstReportMargin post:
  22. ..
  23. .de UNINDENT
  24. . RE
  25. .\" indent \\n[an-margin]
  26. .\" old: \\n[rst2man-indent\\n[rst2man-indent-level]]
  27. .nr rst2man-indent-level -1
  28. .\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
  29. .in \\n[rst2man-indent\\n[rst2man-indent-level]]u
  30. ..
  31. .TH "SYNCTHING-RELAY" "7" "Jun 02, 2024" "v1.27.7" "Syncthing"
  32. .SH NAME
  33. syncthing-relay \- Relay Protocol v1
  34. .SH WHAT IS A RELAY?
  35. .sp
  36. Relay is a service which relays data between two \fIdevices\fP which are not able to
  37. connect to each other directly otherwise. This is usually due to both devices
  38. being behind a NAT and neither side being able to open a port which would
  39. be directly accessible from the internet.
  40. .sp
  41. A relay was designed to relay BEP protocol, hence the reliance on device ID’s
  42. in the protocol spec, but at the same time it is general enough that could be
  43. reused by other protocols or applications, as the data transferred between two
  44. devices which use a relay is completely obscure and does not affect the
  45. relaying.
  46. .SH OPERATION MODES
  47. .sp
  48. Relay listens on a single TCP socket, but has two different connection modes,
  49. where a connection mode is a predefined set of messages which the relay and
  50. the device are expecting to exchange.
  51. .sp
  52. The first mode is the \fIprotocol\fP mode which allows a client to interact
  53. with the relay, for example join the relay, or request to connect to a device,
  54. given it is available on the relay. Similarly to BEP, protocol mode requires
  55. the device to connect via TLS using a strong suite of ciphers (same as BEP),
  56. which allows the relay to verify and derive the identity (Device ID) of the
  57. device.
  58. .sp
  59. The second mode is the \fIsession\fP mode which after a few initial messages
  60. connects two devices directly to each other via the relay, and is a plain\-text
  61. protocol, which for every byte written by one device, sends the same set of
  62. bytes to the other device and vica versa.
  63. .SH IDENTIFYING THE CONNECTION MODE
  64. .sp
  65. Because both connection modes operate over the same single socket, a method
  66. of detecting the connection mode is required.
  67. .sp
  68. When a new client connects to the relay, the relay checks the first byte
  69. that the client has sent, and if that matches 0x16, that implies to us that
  70. the connection is a protocol mode connection, due to 0x16 being the first byte
  71. in the TLS handshake, and only protocol mode connections use TLS.
  72. .sp
  73. If the first byte is not 0x16, then we assume that the connection is a session
  74. mode connection.
  75. .SH PROTOCOL MODE
  76. .sp
  77. Protocol mode uses TLS and protocol name defined by the TLS header should be
  78. \fIbep\-relay\fP\&.
  79. .sp
  80. Protocol mode has two submodes:
  81. 1. Permanent protocol submode \- Joining the relay, and waiting for messages from
  82. the relay asking to connect to some device which is interested in having a
  83. session with you.
  84. 2. Temporary protocol submode \- Only used to request a session with a device
  85. which is connected to the relay using the permanent protocol submode.
  86. .SS Permanent protocol submode
  87. .sp
  88. A permanent protocol submode begins with the client sending a JoinRelayRequest
  89. message, which the relay responds to with either a ResponseSuccess or
  90. ResponseAlreadyConnected message if a client with the same device ID already
  91. exists.
  92. .sp
  93. After the client has joined, no more messages are exchanged apart from
  94. Ping/Pong messages for general connection keep alive checking.
  95. .sp
  96. From this point onwards, the client stand\-by’s and waits for SessionInvitation
  97. messages from the relay, which implies that some other device is trying to
  98. connect with you. SessionInvitation message contains the unique session key
  99. which then can be used to establish a connection in session mode.
  100. .sp
  101. If the client fails to send a JoinSessionRequest message within the first ping
  102. interval, the connection is terminated.
  103. If the client fails to send a message (even if it’s a ping message) every minute
  104. (by default), the connection is terminated.
  105. .SS Temporary protocol submode
  106. .sp
  107. A temporary protocol submode begins with ConnectRequest message, to which the
  108. relay responds with either ResponseNotFound if the device the client it is after
  109. is not available, or with a SessionInvitation, which contains the unique session
  110. key which then can be used to establish a connection in session mode.
  111. .sp
  112. The connection is terminated immediately after that.
  113. .SS Example Exchange
  114. .sp
  115. Client A \- Permanent protocol submode
  116. Client B \- Temporary protocol submode
  117. .TS
  118. box center;
  119. l|l|l|l.
  120. T{
  121. #
  122. T} T{
  123. Client (A)
  124. T} T{
  125. Relay
  126. T} T{
  127. Client (B)
  128. T}
  129. _
  130. T{
  131. 1
  132. T} T{
  133. JoinRelayRequest\->
  134. T} T{
  135. T} T{
  136. T}
  137. _
  138. T{
  139. 2
  140. T} T{
  141. T} T{
  142. <\-ResponseSuccess
  143. T} T{
  144. T}
  145. _
  146. T{
  147. 3
  148. T} T{
  149. Ping\->
  150. T} T{
  151. T} T{
  152. T}
  153. _
  154. T{
  155. 4
  156. T} T{
  157. T} T{
  158. <\-Pong
  159. T} T{
  160. T}
  161. _
  162. T{
  163. 5
  164. T} T{
  165. T} T{
  166. T} T{
  167. <\-ConnectRequest(A)
  168. T}
  169. _
  170. T{
  171. 6
  172. T} T{
  173. T} T{
  174. SessionInvitation(A)\->
  175. T} T{
  176. T}
  177. _
  178. T{
  179. 7
  180. T} T{
  181. T} T{
  182. <\-SessionInvitation(B)
  183. T} T{
  184. T}
  185. _
  186. T{
  187. 8
  188. T} T{
  189. T} T{
  190. T} T{
  191. (Disconnects)
  192. T}
  193. _
  194. T{
  195. 9
  196. T} T{
  197. Ping\->
  198. T} T{
  199. T} T{
  200. T}
  201. _
  202. T{
  203. 10
  204. T} T{
  205. T} T{
  206. <\-Pong
  207. T} T{
  208. T}
  209. _
  210. T{
  211. 11
  212. T} T{
  213. Ping\->
  214. T} T{
  215. T} T{
  216. T}
  217. _
  218. T{
  219. 12
  220. T} T{
  221. T} T{
  222. <\-Pong
  223. T} T{
  224. T}
  225. .TE
  226. .SH SESSION MODE
  227. .sp
  228. The first and only message the client sends in the session mode is the
  229. JoinSessionRequest message which contains the session key identifying which
  230. session you are trying to join. The relay responds with one of the following
  231. Response messages:
  232. .INDENT 0.0
  233. .IP 1. 3
  234. ResponseNotFound \- Session key is invalid
  235. .IP 2. 3
  236. ResponseAlreadyConnected \- Session is full (both sides already connected)
  237. .IP 3. 3
  238. ResponseSuccess \- You have successfully joined the session
  239. .UNINDENT
  240. .sp
  241. After the successful response, all the bytes written and received will be
  242. relayed between the two devices in the session directly.
  243. .SS Example Exchange
  244. .sp
  245. Client A \- Permanent protocol mode
  246. Client B \- Temporary protocol mode
  247. .TS
  248. box center;
  249. l|l|l|l.
  250. T{
  251. #
  252. T} T{
  253. Client (A)
  254. T} T{
  255. Relay
  256. T} T{
  257. Client (B)
  258. T}
  259. _
  260. T{
  261. 1
  262. T} T{
  263. JoinSessionRequest(A)\->
  264. T} T{
  265. T} T{
  266. T}
  267. _
  268. T{
  269. 2
  270. T} T{
  271. T} T{
  272. <\-ResponseSuccess
  273. T} T{
  274. T}
  275. _
  276. T{
  277. 3
  278. T} T{
  279. Data\->
  280. T} T{
  281. (Buffers data)
  282. T} T{
  283. T}
  284. _
  285. T{
  286. 4
  287. T} T{
  288. Data\->
  289. T} T{
  290. (Buffers data)
  291. T} T{
  292. T}
  293. _
  294. T{
  295. 5
  296. T} T{
  297. T} T{
  298. T} T{
  299. <\-JoinSessionRequest(B)
  300. T}
  301. _
  302. T{
  303. 6
  304. T} T{
  305. T} T{
  306. ResponseSuccess\->
  307. T} T{
  308. T}
  309. _
  310. T{
  311. 7
  312. T} T{
  313. T} T{
  314. Relays data \->
  315. T} T{
  316. T}
  317. _
  318. T{
  319. 8
  320. T} T{
  321. T} T{
  322. Relays data \->
  323. T} T{
  324. T}
  325. _
  326. T{
  327. 9
  328. T} T{
  329. T} T{
  330. <\-Relays data
  331. T} T{
  332. <\-Data
  333. T}
  334. .TE
  335. .SH MESSAGES
  336. .sp
  337. All messages are preceded by a header message. Header message contains the
  338. magic value 0x9E79BC40, message type integer, and message length.
  339. .sp
  340. \fBWARNING:\fP
  341. .INDENT 0.0
  342. .INDENT 3.5
  343. Some messages have no content, apart from the implied header which allows
  344. us to identify what type of message it is.
  345. .UNINDENT
  346. .UNINDENT
  347. .SS Header structure
  348. .INDENT 0.0
  349. .INDENT 3.5
  350. .sp
  351. .EX
  352. 0 1 2 3
  353. 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
  354. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  355. | Magic |
  356. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  357. | Message Type |
  358. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  359. | Message Length |
  360. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  361. struct Header {
  362. unsigned int Magic;
  363. int MessageType;
  364. int MessageLength;
  365. }
  366. .EE
  367. .UNINDENT
  368. .UNINDENT
  369. .SS Ping message (Type = 0)
  370. .INDENT 0.0
  371. .INDENT 3.5
  372. .sp
  373. .EX
  374. 0 1 2 3
  375. 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
  376. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  377. struct Ping {
  378. }
  379. .EE
  380. .UNINDENT
  381. .UNINDENT
  382. .SS Pong message (Type = 1)
  383. .INDENT 0.0
  384. .INDENT 3.5
  385. .sp
  386. .EX
  387. 0 1 2 3
  388. 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
  389. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  390. struct Pong {
  391. }
  392. .EE
  393. .UNINDENT
  394. .UNINDENT
  395. .SS JoinRelayRequest message (Type = 2)
  396. .INDENT 0.0
  397. .INDENT 3.5
  398. .sp
  399. .EX
  400. 0 1 2 3
  401. 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
  402. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  403. struct JoinRelayRequest {
  404. }
  405. .EE
  406. .UNINDENT
  407. .UNINDENT
  408. .SS JoinSessionRequest message (Type = 3)
  409. .INDENT 0.0
  410. .INDENT 3.5
  411. .sp
  412. .EX
  413. 0 1 2 3
  414. 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
  415. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  416. | Length of Key |
  417. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  418. / /
  419. \e Key (variable length) \e
  420. / /
  421. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  422. struct JoinSessionRequest {
  423. opaque Key<32>;
  424. }
  425. .EE
  426. .UNINDENT
  427. .UNINDENT
  428. .INDENT 0.0
  429. .TP
  430. .B : Key
  431. This is a unique random session key generated by the relay server. It is
  432. used to identify which session you are trying to connect to.
  433. .UNINDENT
  434. .SS Response message (Type = 4)
  435. .INDENT 0.0
  436. .INDENT 3.5
  437. .sp
  438. .EX
  439. 0 1 2 3
  440. 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
  441. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  442. | Code |
  443. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  444. | Length of Message |
  445. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  446. / /
  447. \e Message (variable length) \e
  448. / /
  449. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  450. struct Response {
  451. int Code;
  452. string Message<>;
  453. }
  454. .EE
  455. .UNINDENT
  456. .UNINDENT
  457. .INDENT 0.0
  458. .TP
  459. .B : Code
  460. An integer representing the status code.
  461. .TP
  462. .B : Message
  463. Message associated with the code.
  464. .UNINDENT
  465. .SS ConnectRequest message (Type = 5)
  466. .INDENT 0.0
  467. .INDENT 3.5
  468. .sp
  469. .EX
  470. 0 1 2 3
  471. 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
  472. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  473. | Length of ID |
  474. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  475. / /
  476. \e ID (variable length) \e
  477. / /
  478. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  479. struct ConnectRequest {
  480. opaque ID<32>;
  481. }
  482. .EE
  483. .UNINDENT
  484. .UNINDENT
  485. .INDENT 0.0
  486. .TP
  487. .B : ID
  488. Device ID to which the client would like to connect.
  489. .UNINDENT
  490. .SS SessionInvitation message (Type = 6)
  491. .INDENT 0.0
  492. .INDENT 3.5
  493. .sp
  494. .EX
  495. 0 1 2 3
  496. 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
  497. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  498. | Length of From |
  499. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  500. / /
  501. \e From (variable length) \e
  502. / /
  503. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  504. | Length of Key |
  505. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  506. / /
  507. \e Key (variable length) \e
  508. / /
  509. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  510. | Length of Address |
  511. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  512. / /
  513. \e Address (variable length) \e
  514. / /
  515. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  516. | 0x0000 | Port |
  517. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  518. | Server Socket (V=0 or 1) |V|
  519. +\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+\-+
  520. struct SessionInvitation {
  521. opaque From<32>;
  522. opaque Key<32>;
  523. opaque Address<32>;
  524. unsigned int Port;
  525. bool ServerSocket;
  526. }
  527. .EE
  528. .UNINDENT
  529. .UNINDENT
  530. .INDENT 0.0
  531. .TP
  532. .B : From
  533. Device ID identifying who you will be connecting with.
  534. .TP
  535. .B : Key
  536. A unique random session key generated by the relay server. It is used to
  537. identify which session you are trying to connect to.
  538. .TP
  539. .B : Address
  540. An optional IP address on which the relay server is expecting you to
  541. connect, in order to start a connection in session mode.
  542. Empty/all zero IP should be replaced with the relay’s public IP address that
  543. was used when establishing the protocol mode connection.
  544. .TP
  545. .B : Port
  546. The port on which the relay server is expecting you to connect,
  547. in order to start a connection in session mode.
  548. .TP
  549. .B : Server Socket
  550. Because both sides connecting to the relay use the client side of the socket,
  551. and some protocols behave differently depending if the connection starts on
  552. the server side or the client side, this boolean indicates which side of the
  553. connection this client should assume it’s getting. The value is inverted in
  554. the invitation which is sent to the other device, so that there is always
  555. one client socket, and one server socket.
  556. .UNINDENT
  557. .SH HOW SYNCTHING USES RELAYS, AND GENERAL SECURITY
  558. .sp
  559. In the case of Syncthing and BEP, when two devices connect via relay, they
  560. start their standard TLS connection encapsulated within the relay’s plain\-text
  561. session connection, effectively upgrading the plain\-text connection to a TLS
  562. connection.
  563. .sp
  564. Even though the relay could be used for man\-in\-the\-middle attack, using TLS
  565. at the application/BEP level ensures that all the traffic is safely encrypted,
  566. and is completely meaningless to the relay. Furthermore, the secure suite of
  567. ciphers used by BEP provides forward secrecy, meaning that even if the relay
  568. did capture all the traffic, and even if the attacker did get their hands on the
  569. device keys, they would still not be able to recover/decrypt any traffic which
  570. was transported via the relay.
  571. .sp
  572. After establishing a relay session, Syncthing looks at the SessionInvitation
  573. message, and depending which side it has received, wraps the raw socket in
  574. either a TLS client socket or a TLS server socket depending on the ServerSocket
  575. boolean value in the SessionInvitation, and starts the TLS handshake.
  576. .sp
  577. From that point onwards it functions exactly the same way as if Syncthing was
  578. establishing a direct connection with the other device over the internet,
  579. performing device ID validation, and full TLS encryption, and provides the same
  580. security properties as it would provide when connecting over the internet.
  581. .SH EXAMPLES OF STRONG CIPHER SUITES
  582. .TS
  583. box center;
  584. l|l|l.
  585. T{
  586. ID
  587. T} T{
  588. Name
  589. T} T{
  590. Description
  591. T}
  592. _
  593. T{
  594. 0x009F
  595. T} T{
  596. DHE\-RSA\-AES256\-GCM\-SHA384
  597. T} T{
  598. TLSv1.2 DH RSA AESGCM(256) AEAD
  599. T}
  600. _
  601. T{
  602. 0x006B
  603. T} T{
  604. DHE\-RSA\-AES256\-SHA256
  605. T} T{
  606. TLSv1.2 DH RSA AES(256) SHA256
  607. T}
  608. _
  609. T{
  610. 0xC030
  611. T} T{
  612. ECDHE\-RSA\-AES256\-GCM\-SHA384
  613. T} T{
  614. TLSv1.2 ECDH RSA AESGCM(256) AEAD
  615. T}
  616. _
  617. T{
  618. 0xC028
  619. T} T{
  620. ECDHE\-RSA\-AES256\-SHA384
  621. T} T{
  622. TLSv1.2 ECDH RSA AES(256) SHA384
  623. T}
  624. _
  625. T{
  626. 0x009E
  627. T} T{
  628. DHE\-RSA\-AES128\-GCM\-SHA256
  629. T} T{
  630. TLSv1.2 DH RSA AESGCM(128) AEAD
  631. T}
  632. _
  633. T{
  634. 0x0067
  635. T} T{
  636. DHE\-RSA\-AES128\-SHA256
  637. T} T{
  638. TLSv1.2 DH RSA AES(128) SHA256
  639. T}
  640. _
  641. T{
  642. 0xC02F
  643. T} T{
  644. ECDHE\-RSA\-AES128\-GCM\-SHA256
  645. T} T{
  646. TLSv1.2 ECDH RSA AESGCM(128) AEAD
  647. T}
  648. _
  649. T{
  650. 0xC027
  651. T} T{
  652. ECDHE\-RSA\-AES128\-SHA256
  653. T} T{
  654. TLSv1.2 ECDH RSA AES(128) SHA256
  655. T}
  656. .TE
  657. .SH AUTHOR
  658. The Syncthing Authors
  659. .SH COPYRIGHT
  660. 2014-2019, The Syncthing Authors
  661. .\" Generated by docutils manpage writer.
  662. .