Commit 4b595ec1 authored by Ryan Alderete's avatar Ryan Alderete
Browse files

Bug 1570158 - Add proxy information to candidates table in about:webrtc r=bwc,baku

This adds a field to about:webrtc which indicates whether an associated
candidate is behind a proxy or not.

Differential Revision: https://phabricator.services.mozilla.com/D39974

--HG--
extra : moz-landing-system : lando
parent 6d66ec3b
......@@ -216,6 +216,7 @@ const statsExpectedByType = {
],
optional: [
"relayProtocol",
"proxied",
],
unimplemented: [
"networkType",
......@@ -244,6 +245,7 @@ const statsExpectedByType = {
],
optional: [
"relayProtocol",
"proxied",
],
unimplemented: [
"networkType",
......@@ -775,6 +777,12 @@ var pedanticChecks = report => {
`relayProtocol is undefined for candidates that are not relay and ` +
`local. value=${stat.relayProtocol}`);
}
// proxied
if (stat.proxied) {
ok(stat.proxied == "proxied" || stat.proxied == "non-proxied",
`${stat.type} has proxied. value=${stat.proxied}`);
}
}
//
......
......@@ -214,6 +214,7 @@ struct ParamTraits<mozilla::dom::RTCIceCandidateStats> {
WriteParam(aMsg, aParam.mRelayProtocol);
WriteParam(aMsg, aParam.mPort);
WriteParam(aMsg, aParam.mProtocol);
WriteParam(aMsg, aParam.mProxied);
WriteRTCStats(aMsg, aParam);
}
......@@ -226,6 +227,7 @@ struct ParamTraits<mozilla::dom::RTCIceCandidateStats> {
!ReadParam(aMsg, aIter, &(aResult->mRelayProtocol)) ||
!ReadParam(aMsg, aIter, &(aResult->mPort)) ||
!ReadParam(aMsg, aIter, &(aResult->mProtocol)) ||
!ReadParam(aMsg, aIter, &(aResult->mProxied)) ||
!ReadRTCStats(aMsg, aIter, aResult)) {
return false;
}
......
......@@ -136,6 +136,8 @@ dictionary RTCIceCandidateStats : RTCStats {
// we need to keep the field as ChromeOnly. Bug 1225723
[ChromeOnly]
DOMString transportId;
[ChromeOnly]
DOMString proxied;
};
// This is the internal representation of the report in this implementation
......
......@@ -86,6 +86,8 @@ class NrSocketProxy : public NrSocketBase, public WebrtcProxyChannelCallback {
int listen(int aBacklog) override;
int accept(nr_transport_addr* aAddr, nr_socket** aSocket) override;
bool IsProxied() const override { return true; }
// WebrtcProxyChannelCallback
void OnClose(nsresult aReason) override;
void OnConnected() override;
......
......@@ -127,6 +127,8 @@ class NrSocketBase {
virtual int listen(int backlog) = 0;
virtual int accept(nr_transport_addr* addrp, nr_socket** sockp) = 0;
virtual bool IsProxied() const = 0;
// Implementations of the async_event APIs
virtual int async_wait(int how, NR_async_cb cb, void* cb_arg, char* function,
int line);
......@@ -189,6 +191,8 @@ class NrSocket : public NrSocketBase, public nsASocketHandler {
virtual int listen(int backlog) override;
virtual int accept(nr_transport_addr* addrp, nr_socket** sockp) override;
virtual bool IsProxied() const override { return false; }
protected:
virtual ~NrSocket() {
if (fd_) PR_Close(fd_);
......@@ -267,6 +271,8 @@ class NrUdpSocketIpc : public NrSocketIpc {
virtual int listen(int backlog) override;
virtual int accept(nr_transport_addr* addrp, nr_socket** sockp) override;
virtual bool IsProxied() const override { return false; }
private:
virtual ~NrUdpSocketIpc();
......@@ -353,6 +359,8 @@ class NrTcpSocketIpc : public NrSocketIpc, public nsITCPSocketCallback {
virtual int listen(int backlog) override;
virtual int accept(nr_transport_addr* addrp, nr_socket** sockp) override;
virtual bool IsProxied() const override { return false; }
private:
class TcpSocketReadyRunner;
DISALLOW_COPY_ASSIGN(NrTcpSocketIpc);
......
......@@ -1066,6 +1066,10 @@ int nr_socket_local_create(void* obj, nr_transport_addr* addr,
if (r) {
ABORT(r);
}
// TODO(bug 1569183): This will start out false, and may become true once the
// socket class figures out whether a proxy needs to be used (this may be as
// late as when it establishes a connection).
addr->is_proxied = sock->IsProxied();
r = nr_socket_create_int(static_cast<void*>(sock), sock->vtbl(), sockp);
if (r) ABORT(r);
......
......@@ -123,6 +123,8 @@ static bool ToNrIceCandidate(const nr_ice_candidate& candc,
r = nr_socket_getaddr(cand->isock->sock, &addr);
if (r) return false;
out->is_proxied = addr.is_proxied;
if (!ToNrIceAddr(addr, &out->local_addr)) return false;
}
......
......@@ -87,6 +87,7 @@ struct NrIceCandidate {
std::string label;
bool trickled;
uint32_t priority;
bool is_proxied = false;
};
struct NrIceCandidatePair {
......
......@@ -91,6 +91,8 @@ class DummySocket : public NrSocketBase {
return 0;
}
virtual bool IsProxied() const override { return false; }
virtual int write(const void* msg, size_t len, size_t* written) override {
size_t to_write = std::min(len, writable_);
......
......@@ -282,6 +282,17 @@ int TestNrSocket::accept(nr_transport_addr* addrp, nr_socket** sockp) {
return 0;
}
bool TestNrSocket::IsProxied() const {
if (internal_socket_->my_addr().protocol == IPPROTO_UDP ||
port_mappings_.empty()) {
// UDP and the no-nat case
return internal_socket_->IsProxied();
}
// This is TCP only
MOZ_ASSERT(port_mappings_.size() == 1);
return port_mappings_.front()->external_socket_->IsProxied();
}
void TestNrSocket::process_delayed_cb(NR_SOCKET s, int how, void* cb_arg) {
DeferredPacket* op = static_cast<DeferredPacket*>(cb_arg);
op->socket_->timer_handle_ = nullptr;
......
......@@ -225,6 +225,7 @@ class TestNrSocket : public NrSocketBase {
int listen(int backlog) override;
int accept(nr_transport_addr* addrp, nr_socket** sockp) override;
bool IsProxied() const override;
int async_wait(int how, NR_async_cb cb, void* cb_arg, char* function,
int line) override;
int cancel(int how) override;
......
......@@ -35,6 +35,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef _transport_addr_h
#define _transport_addr_h
#include <stdbool.h>
#include <sys/types.h>
#ifdef WIN32
#include <winsock2.h>
......@@ -69,6 +70,7 @@ typedef struct nr_transport_addr_ {
56 = 5 ("IP6:[") + 39 (ipv6 address) + 2 ("]:") + 5 (port) + 4 (/UDP) + 1 (null) */
char as_string[56];
char tls_host[256];
bool is_proxied;
} nr_transport_addr;
typedef struct nr_transport_addr_mask_ {
......
......@@ -1153,6 +1153,8 @@ static void ToRTCIceCandidateStats(
cand.mRelayProtocol.Construct(
NS_ConvertASCIItoUTF16(candidate.local_addr.transport.c_str()));
}
cand.mProxied.Construct(NS_ConvertASCIItoUTF16(
candidate.is_proxied ? "proxied" : "non-proxied"));
report->mIceCandidateStats.Value().AppendElement(cand, fallible);
if (candidate.trickled) {
report->mTrickledIceCandidateStats.Value().AppendElement(cand, fallible);
......
......@@ -911,7 +911,12 @@ ICEStats.prototype = {
type = `${c.candidateType}-${c.relayProtocol}`;
}
return `${c.address}:${c.port}/${c.protocol}(${type})`;
var proxied = "";
if (c.type == "local-candidate") {
proxied = `[${c.proxied}]`;
}
return `${c.address}:${c.port}/${c.protocol}(${type}) ${proxied}`;
},
};
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment