Chromium Code Reviews

Unified Diff: webrtc/p2p/base/turnserver.h

Issue 1595613004: Reset TURN port NONCE when a new socket is created. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: merge with head Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
« no previous file with comments | « webrtc/p2p/base/turnport_unittest.cc ('k') | webrtc/p2p/base/turnserver.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/p2p/base/turnserver.h
diff --git a/webrtc/p2p/base/turnserver.h b/webrtc/p2p/base/turnserver.h
index 113bd4c4623d06c118a1b05ede79bceee2d72ad6..44a8b3827899904b514e8f23742361466a36713e 100644
--- a/webrtc/p2p/base/turnserver.h
+++ b/webrtc/p2p/base/turnserver.h
@@ -199,8 +199,14 @@ class TurnServer : public sigslot::has_slots<> {
// Specifies the factory to use for creating external sockets.
void SetExternalSocketFactory(rtc::PacketSocketFactory* factory,
const rtc::SocketAddress& address);
+ // For testing only.
+ std::string SetTimestampForNextNonce(uint32_t timestamp) {
+ ts_for_next_nonce_ = timestamp;
+ return GenerateNonce(timestamp);
+ }
private:
+ std::string GenerateNonce(uint32_t now) const;
void OnInternalPacket(rtc::AsyncPacketSocket* socket, const char* data,
size_t size, const rtc::SocketAddress& address,
const rtc::PacketTime& packet_time);
@@ -221,7 +227,6 @@ class TurnServer : public sigslot::has_slots<> {
bool CheckAuthorization(TurnServerConnection* conn, const StunMessage* msg,
const char* data, size_t size,
const std::string& key);
- std::string GenerateNonce() const;
bool ValidateNonce(const std::string& nonce) const;
TurnServerAllocation* FindAllocation(TurnServerConnection* conn);
@@ -270,6 +275,10 @@ class TurnServer : public sigslot::has_slots<> {
AllocationMap allocations_;
+ // For testing only. If this is non-zero, the next NONCE will be generated
+ // from this value, and it will be reset to 0 after generating the NONCE.
+ uint32_t ts_for_next_nonce_ = 0;
+
friend class TurnServerAllocation;
};
« no previous file with comments | « webrtc/p2p/base/turnport_unittest.cc ('k') | webrtc/p2p/base/turnserver.cc » ('j') | no next file with comments »

Powered by Google App Engine