willardf / Hazel-Networking

Hazel Networking is a low level networking library for C# providing connection-oriented, message-based communication via RUDP.
MIT License
391 stars 60 forks source link

[Do Not Merge] Optionally zero out DTLS version flag #46

Closed Mukikaizoku closed 2 years ago

Mukikaizoku commented 2 years ago

Context: For certain reasons, we'd like to be able to obfuscate the DTLS version flag, but also need to support clients that do provide the flag. This PR allows the client to declare its version (allowing for "0", no flag) on the initial ClientHello packet. The version is stored in PeerData so the version is maintained for that respective connection.

Note 1: I left in the validation of the version flag to respect existing validation, but that may be unnecessary. I'd presume it is supposed to be there per spec.

Note 2: In general, I passed the protocol version value through the Encode method. Quite possibly could pass this in on the struct constructor as well - at the moment in my mind the two options feel somewhat equivalent overall? I'd be happy to change it though.