mirror of
https://github.com/mollyim/webrtc.git
synced 2025-05-13 13:50:40 +01:00
Reland "Add addr in error msg if stun sock sent with error"
This is a reland of 9ff75a6206
Original change's description:
> Add addr in error msg if stun sock sent with error
>
> Before:
> ```
> (stun_port.cc:596): sendto : [0x00000041] No route to host
> ```
>
> After:
> ```
> (stun_port.cc:598): UDP send of 20 bytes to host stun1.l.google.com:19302 (74.125.200.127:19302) failed with error 65 : [0x00000041] No route to host
> ```
>
> Bug: None
> Change-Id: Ibcd487e97b37677225814562df30af66f655cddb
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/215000
> Reviewed-by: Harald Alvestrand <hta@webrtc.org>
> Commit-Queue: Yura Yaroshevich <yura.yaroshevich@gmail.com>
> Cr-Commit-Position: refs/heads/master@{#33694}
Bug: None
Change-Id: Ic73327b20fd08ab41f378961333dd27f0f884525
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/215926
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#33862}
This commit is contained in:
parent
2a605b1333
commit
f97afd65b2
3 changed files with 22 additions and 2 deletions
|
@ -306,7 +306,9 @@ int UDPPort::SendTo(const void* data,
|
||||||
if (send_error_count_ < kSendErrorLogLimit) {
|
if (send_error_count_ < kSendErrorLogLimit) {
|
||||||
++send_error_count_;
|
++send_error_count_;
|
||||||
RTC_LOG(LS_ERROR) << ToString() << ": UDP send of " << size
|
RTC_LOG(LS_ERROR) << ToString() << ": UDP send of " << size
|
||||||
<< " bytes failed with error " << error_;
|
<< " bytes to host " << addr.ToSensitiveString() << " ("
|
||||||
|
<< addr.ToResolvedSensitiveString()
|
||||||
|
<< ") failed with error " << error_;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
send_error_count_ = 0;
|
send_error_count_ = 0;
|
||||||
|
@ -593,7 +595,11 @@ void UDPPort::OnSendPacket(const void* data, size_t size, StunRequest* req) {
|
||||||
options.info_signaled_after_sent.packet_type = rtc::PacketType::kStunMessage;
|
options.info_signaled_after_sent.packet_type = rtc::PacketType::kStunMessage;
|
||||||
CopyPortInformationToPacketInfo(&options.info_signaled_after_sent);
|
CopyPortInformationToPacketInfo(&options.info_signaled_after_sent);
|
||||||
if (socket_->SendTo(data, size, sreq->server_addr(), options) < 0) {
|
if (socket_->SendTo(data, size, sreq->server_addr(), options) < 0) {
|
||||||
RTC_LOG_ERR_EX(LERROR, socket_->GetError()) << "sendto";
|
RTC_LOG_ERR_EX(LERROR, socket_->GetError())
|
||||||
|
<< "UDP send of " << size << " bytes to host "
|
||||||
|
<< sreq->server_addr().ToSensitiveString() << " ("
|
||||||
|
<< sreq->server_addr().ToResolvedSensitiveString()
|
||||||
|
<< ") failed with error " << error_;
|
||||||
}
|
}
|
||||||
stats_.stun_binding_requests_sent++;
|
stats_.stun_binding_requests_sent++;
|
||||||
}
|
}
|
||||||
|
|
|
@ -178,6 +178,16 @@ std::string SocketAddress::ToSensitiveString() const {
|
||||||
return sb.str();
|
return sb.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string SocketAddress::ToResolvedSensitiveString() const {
|
||||||
|
if (IsUnresolvedIP()) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
char buf[1024];
|
||||||
|
rtc::SimpleStringBuilder sb(buf);
|
||||||
|
sb << ipaddr().ToSensitiveString() << ":" << port();
|
||||||
|
return sb.str();
|
||||||
|
}
|
||||||
|
|
||||||
bool SocketAddress::FromString(const std::string& str) {
|
bool SocketAddress::FromString(const std::string& str) {
|
||||||
if (str.at(0) == '[') {
|
if (str.at(0) == '[') {
|
||||||
std::string::size_type closebracket = str.rfind(']');
|
std::string::size_type closebracket = str.rfind(']');
|
||||||
|
|
|
@ -124,6 +124,10 @@ class RTC_EXPORT SocketAddress {
|
||||||
// Same as ToString but anonymizes it by hiding the last part.
|
// Same as ToString but anonymizes it by hiding the last part.
|
||||||
std::string ToSensitiveString() const;
|
std::string ToSensitiveString() const;
|
||||||
|
|
||||||
|
// Returns hostname:port string if address is resolved, otherwise returns
|
||||||
|
// empty string.
|
||||||
|
std::string ToResolvedSensitiveString() const;
|
||||||
|
|
||||||
// Parses hostname:port and [hostname]:port.
|
// Parses hostname:port and [hostname]:port.
|
||||||
bool FromString(const std::string& str);
|
bool FromString(const std::string& str);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue