Questions about the discovery protocol

Hello, I have a few questions/suggestions about protocol/DISCOVERY.md:

  • for local discovery, it mentions that it is with a broadcast message, but fails to mention the port, 21025/UDP.

  • Device ID. The XDR syntax is string DeviceID<>, while it seems to me that ST accepts only the SHA-256 of the certificate (see code), so the XDR should be string DeviceID<32> and the text should mention that the only allowed length is 32.

  • Device ID. Probably the text should mention that the Device ID is the SHA-256 of the certificate, and maybe point to the device ID documentation page.

  • Device ID again :wink: . Call me nitpicker, but the SHA-256 is a binary blob, not a string (there is a presentation transformation as explained at deviceid, but on the wire it is just a binary blob). As such, the XDR type should be opaque, not string. (Yes I know that they are encoded the same, but the semantics are different).

  • Port. The XDR for struct Address contains unsigned short Port, but the type short doesn’t exist in XDR. The text should be unsigned int Port, and the text should mention that the value should fit in a 16-bit unsigned integer, since that is the size of a UDP port.

  • Query. The XDR has a typo, it says struct Announcement instead of struct Query.

Let me know if you want a pull request with the suggested changes.

Cheers, and thanks for ST!

The human readable protocol definition is a bit out of date with the code I think (code is []byte which is equivalent to opaque and not string, for example). The nits haven’t really been picked with the discovery stuff since it wasn’t really intended to be an interopable thing from the beginning. You’re very welcome to clean it up!

Created pull request https://github.com/syncthing/syncthing/pull/1136

1 Like