mirror of
https://github.com/permissionlesstech/bitchat.git
synced 2026-07-25 22:05:21 +00:00
Add protocol version negotiation for future compatibility
- Add version negotiation messages (0x20 versionHello, 0x21 versionAck) - Implement VersionHello and VersionAck message types with platform info - Add ProtocolVersion struct for version management and negotiation - Update BinaryProtocol to check supported versions - Add version negotiation to connection flow before Noise handshake - Maintain backward compatibility with legacy peers (assume v1) - Add comprehensive test suite with 40+ test cases - Update documentation with version negotiation details This ensures BitChat clients can negotiate protocol versions for smooth upgrades while maintaining full backward compatibility with existing clients.
This commit is contained in:
@@ -199,6 +199,26 @@ enum NoiseError: Error {
|
||||
- Automatic cleanup of stale sessions
|
||||
- Efficient key rotation
|
||||
|
||||
## Protocol Version Negotiation
|
||||
|
||||
BitChat implements protocol version negotiation to ensure compatibility between different client versions:
|
||||
|
||||
### Version Negotiation Flow
|
||||
1. **Version Hello**: Upon connection, peers exchange supported protocol versions
|
||||
2. **Version Agreement**: Peers agree on the highest common version
|
||||
3. **Graceful Fallback**: Legacy peers without version negotiation assume protocol v1
|
||||
|
||||
### Message Types
|
||||
```swift
|
||||
case versionHello = 0x20 // Announce supported versions
|
||||
case versionAck = 0x21 // Acknowledge and agree on version
|
||||
```
|
||||
|
||||
### Backward Compatibility
|
||||
- Peers that don't send version negotiation messages are assumed to support v1
|
||||
- Future protocol versions can be added to `ProtocolVersion.supportedVersions`
|
||||
- Incompatible peers receive a rejection message and disconnect gracefully
|
||||
|
||||
## Future Enhancements
|
||||
|
||||
### Post-Quantum Readiness
|
||||
|
||||
Reference in New Issue
Block a user