Fix bug in recently introduced TurnCustomizer
The problem was that TurnCustomizerMaybeModifyOutgoingStunMessage
was called before the message was constructed. This is now fixed
and tested in TestTurnCustomizer.
BUG=webrtc:8313
Change-Id: Ie9a69cc2ff514796af0da987de733b3db8382883
Reviewed-on: https://webrtc-review.googlesource.com/8840
Reviewed-by: Taylor Brandstetter <deadbeef@webrtc.org>
Commit-Queue: Jonas Oreland <jonaso@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#20261}
diff --git a/p2p/base/testturncustomizer.h b/p2p/base/testturncustomizer.h
index 33f48fb..012306f 100644
--- a/p2p/base/testturncustomizer.h
+++ b/p2p/base/testturncustomizer.h
@@ -12,6 +12,7 @@
#define P2P_BASE_TESTTURNCUSTOMIZER_H_
#include "api/turncustomizer.h"
+#include "rtc_base/gunit.h"
#include "rtc_base/ptr_util.h"
namespace cricket {
@@ -31,6 +32,7 @@
cricket::StunMessage* message) override {
modify_cnt_ ++;
+ ASSERT_NE(0, message->type());
if (add_counter_) {
message->AddAttribute(rtc::MakeUnique<cricket::StunUInt32Attribute>(
STUN_ATTR_COUNTER, modify_cnt_));
diff --git a/p2p/base/turnport.cc b/p2p/base/turnport.cc
index a0b98bb..6c8f3e5 100644
--- a/p2p/base/turnport.cc
+++ b/p2p/base/turnport.cc
@@ -956,7 +956,6 @@
}
void TurnPort::SendRequest(StunRequest* req, int delay) {
- TurnCustomizerMaybeModifyOutgoingStunMessage(req->mutable_msg());
request_manager_.SendDelayed(req, delay);
}
@@ -1180,6 +1179,7 @@
if (!port_->hash().empty()) {
port_->AddRequestAuthInfo(request);
}
+ port_->TurnCustomizerMaybeModifyOutgoingStunMessage(request);
}
void TurnAllocateRequest::OnSent() {
@@ -1354,6 +1354,7 @@
}
port_->AddRequestAuthInfo(request);
+ port_->TurnCustomizerMaybeModifyOutgoingStunMessage(request);
}
void TurnRefreshRequest::OnSent() {
@@ -1422,6 +1423,7 @@
request->AddAttribute(rtc::MakeUnique<StunXorAddressAttribute>(
STUN_ATTR_XOR_PEER_ADDRESS, ext_addr_));
port_->AddRequestAuthInfo(request);
+ port_->TurnCustomizerMaybeModifyOutgoingStunMessage(request);
}
void TurnCreatePermissionRequest::OnSent() {
@@ -1484,6 +1486,7 @@
request->AddAttribute(rtc::MakeUnique<StunXorAddressAttribute>(
STUN_ATTR_XOR_PEER_ADDRESS, ext_addr_));
port_->AddRequestAuthInfo(request);
+ port_->TurnCustomizerMaybeModifyOutgoingStunMessage(request);
}
void TurnChannelBindRequest::OnSent() {