Fixes for unusual rendezvous connection rejection cases #414
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This fixes the problem that arisen when the KMX process failed due to either no password set or bad password. The transmission should fail anyway, but the connection should be still set up correctly, and the transmission should send the packets - they shall be only unable to be decrypted. In the opposite direction the transmission should be allowed anyway. It should also show correct encryption state. This fixes the problem that in case when BADSECRET or NOSECRET situation the repeated handshake attempt was trying to extract the recorded key from previous KMREQ, which wasn't recorded due to that error, and it resulted in rejection instead of sending back the 1-word KMX failure status, if there's no key possible to be sent. The peer should receive the KMX failure, but only setup a failed encryption state on itself, not break the connection, and the transmission from a party that set no encryption should be anyway possible.
Another fix repairs the problem when a rendezvous handshake comes in when it is already received due to having bound socket, but before
registerConnector
was called (these things happen in two different threads), which means that in this period any packet incoming from peer has no chance to be dispatched and it's treated as a rogue packet. The incorrect reaction was to reject the handshake and cause the connection process to be broken. This, instead, ignores the packet, which means that the peer will simply send it again, this time most likely when the connector is already registerred and therefore the packet will be correctly dispatched.