I’d really like to port the Syncthing stack to Swift as a personal project and, if that turns out well, I would be very pleased to make it available to the community. However, I’d like to have an overview of the protocols (the ones at https://docs.syncthing.net/specs/) and what you think on which one I should implement first. Thanks in advance
Syncthing needs BEP protocol to talk to others, so not sure there is much use implementing relays and discovery before that has any use.
Yeah, start with that. There are protocol buffer schemas that you use for most of the protocol wire stuff. I’ve found it rather annoying to do raw TLS connections with certificate authentication in Swift, which is sort of the first thing you need to do to get anywhere…
Would this be easier now that this is out?
That was there ten months ago as well. The wire format is anyway a rather small piece of the effort.
Sorry if I’m resurrecting the thread but is there a way to check my generated messages? Just to check if they’re correctly generated and encoded.
I.E. I have this Hello message and I’d like to know if it’s correct:
Thanks in advance
There’s no tool or so. But looking at that, after guessing it’s base64 and decoding:
00000000 2e a7 d9 0b 1e 00 0a 0a 54 65 73 74 44 65 76 69 |........TestDevi| 00000010 63 65 12 09 73 77 69 66 74 68 69 6e 67 1a 05 30 |ce..swifthing..0| 00000020 2e 30 2e 31 |.0.1|
… there is one issue with it. Magic is fine, and I’m going to trust the protobuf marshaller has done its job, but the length is wrong. You set
1e 00 which is little endian / “reverse” byte order, but we always use big endian for lengths so it should be
Ah thanks! this is Swift’s bad I think…
Yeah, if you just hammer out an int16 in memory you’ll get the hardware endianness, which on x86 is indeed little endian. There’s typically some sort of marshalling tool where you get to specify what you want. It might also be referred to as “network byte order” as it’s the traditional order of sending things over the wire.
2e a7 d9 0b 00 1e 0a 0a 54 65 73 74 44 65 76 69 63 65 12 09 73 77 69 66 74 68 69 6e 67 1a 05 30 2e 30 2e 31
It was enough to just append
Could you confirm that this is a valid cluster configuration base64-encoded message?
Don’t worry, I won’t ask for all kind of messages to be checked but only for this one.