syncthing-relay.7 17 KB

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