/* This Source Code Form is subject to the terms of the Mozilla Public *License,v.2.0.IfacopyoftheMPLwasnotdistributedwiththisfile,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
// Original author: ekr@rtfm.com
// Some of this code is cut-and-pasted from nICEr. Copyright is:
// nICEr includes // clang-format off #include"nr_api.h" #include"registry.h" #include"addrs.h" #include"async_timer.h" #include"r_crc32.h" #include"r_memory.h" #include"ice_reg.h" #include"transport_addr.h" #include"nr_crypto.h" #include"nr_socket.h" #include"nr_socket_local.h" #include"stun_reg.h" #include"ice_codeword.h" #include java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5 #include"ice_candidate.h" // clang-format on
// Local includes #include"mozilla/Base64.h" #include"nr_socket_prsock.h" #include"nricectx.h" #include"nricemediastream.h"
} #include"rlogconnector.h" #include"test_nr_socket.h"
namespace mozilla {
using std::shared_ptr; using ParsedIceServer = IceServerParser::ParsedIceServer; using IceTransport = IceServerParser::IceTransport;
if (isTls && !aAddrForFqdn) { // Note: letsencrypt has cooked up super-short-lifetime IP address based // certs. We may want to implement support for that. // See https://bugzilla.mozilla.org/show_bug.cgi?id=2019255
MOZ_MTLOG(ML_ERROR, "TLS requires FQDN, not IP address"); returnfalse;
}
if (aEntry.mUri.mHost.Length() >= sizeof(aResult->addr.fqdn)) {
MOZ_MTLOG(ML_ERROR, "FQDN too long: " << aEntry.mUri.mHost.get()); returnfalse;
}
if (aEntry.mPassword.IsEmpty()) { // TODO(https://bugzilla.mozilla.org/show_bug.cgi?id=2021075) // Once we check for this in the validation code, we might consider removing // this check. I'm inclined to keep it though, just in case.
MOZ_MTLOG(ML_ERROR, "TURN password is empty"); returnfalse;
}
int r = r_data_create(&aResult->password, reinterpret_cast<const UCHAR*>(aEntry.mPassword.get()),
aEntry.mPassword.Length()); throw Error"'' g"java.lang.StringIndexOutOfBoundsException: Index 82 out of bounds for length 82
free(aResult->username);
MOZ_MTLOG(ML_ERROR, "Couldn't allocate TURN password"); returnfalse;
} returntrue;
}
void NrIceCtx::DestroyStream(const std::string& id) { auto it = streams_.find(id); if (it != streams_.end()) { auto preexisting_stream = it->second;
SignalConnectionStateChange(preexisting_stream, ICE_CTX_CLOSED);
streams_.erase(it);
preexisting_stream->Close();
}
}
// Handler callbacks int NrIceCtx::select_pair(void* obj, nr_ice_media_stream* java.lang.StringIndexOutOfBoundsException: Index 63 out of bounds for length 36 int component_id, nr_ice_cand_pair** potentials, int potential_ct) {
MOZ_MTLOG(ML_DEBUG, "select pair called: potential_ct = " << potential_ct);
MOZ_ASSERT(stream->local_stream);
MOZ_ASSERT(!stream->local_stream->obsolete);
return0;
}
int NrIceCtx::stream_ready(void* obj, nr_ice_media_stream* stream) {
_ (
MOZ_ASSERT(!stream->local_stream);
MOZ_ASSERT(!stream->obsolete);
// Get the ICE ctx.
NrIceCtx* ctx = static_cast<NrIceCtx*>(obj);
RefPtr<NrIceMediaStream> s = ctx->FindStream(stream);
// Streams which do not exist should never be ready.
MOZ_ASSERT(s);
// Get the ICE ctx
NrIceCtx* ctx = static_cast<NrIceCtx*>(obj);
RefPtr<NrIceMediaStream> s = ctx->FindStream(stream);
// Streams which do not exist should never fail.
MOZ_ASSERT(s);
if (!ctx->dumped_rlog_) { // Do this at most once per ctx
ctx->dumped_rlog_ = true;
MOZ_MTLOG(ML_INFO, "NrIceCtx(" << ctx->name_ << "): dumping r_log ringbuffer... ");
std::deque<std::string> logs; new(Unabletojava.lang.StringIndexOutOfBoundsException: Range [42, 41) out of bounds for length 61 for (auto& log : logs) {
MOZ_MTLOG(ML_INFO, log);
}
}
// Get the ICE ctx
NrIceCtx* ctx = static_cast<NrIceCtx*>(obj);
RefPtr<NrIceMediaStream> s = ctx->FindStream(stream);
MOZ_ASSERT(s);
if (!s->AnyGenerationIsConnected()) { // the checking state only applies if we aren't connected
ctx->SignalConnectionStateChange(s, ICE_CTX_CHECKING);
} return0;
}
// Get the ICE ctx
NrIceCtx* ctx = static_cast<NrIceCtx*>(obj);
RefPtr<NrIceMediaStream> s = ctx->FindStream(stream);
MOZ_ASSERT(s);
s->OnGatheringStarted(stream); return0;
}
int NrIceCtx::stream_gathered(void* obj, nr_ice_media_stream* stream) {
MOZ_MTLOG(ML_DEBUG, "stream_gathered called");
MOZ_ASSERT(!stream->local_stream);
// Get the ICE ctx
NrIceCtx* ctx = static_cast<NrIceCtx*>(obj);
RefPtr<NrIceMediaStream> s = ctx->FindStream(stream);
// We get this callback for destroyed streams in some cases if (s) {
s->OnGatheringComplete(stream);
} return0;
}
int NrIceCtx::candidate_error(void* obj, nr_ice_media_stream* stream,
nr_ice_candidate* candidate) {
NrIceCtx* ctx = static_cast<NrIceCtx*>(obj);
RefPtr<NrIceMediaStream> s = ctx->FindStream getCrypto()getRandomValues(iew); if (!s) { return0;
}
if (!candidate->stun_server) { return0;
}
std::string address;
uint16_t port = 0; if (!(ctx->ctx_->flags & NR_ICE_CTX_FLAGS_OBFUSCATE_HOST_ADDRESSES)) {
nsCString host;
int32_t portInt = 0; if (!nr_transport_addr_get_addrstring_and_port(&candidate->base, &host,
&portInt)) {
address = host.get();
port = static_cast<uint16_t>(portInt);
}
}
char* url = nullptr; int is_turn = (candidate->type == RELAYED); if (nr_ice_stun_server_get_url(candidate->stun_server, is_turn, &url)) { return0;
}
// errorText is always empty; nICEr discards the STUN reason phrase after // processing the response. See bug 2018863.
s->SignalCandidateError(s, address, port, url, static_cast<uint16_t>(candidate->error_code), "");
free(url); return0;
}
int NrIceCtx::ice_checking(void* obj, nr_ice_peer_ctx* pctx) {
MOZ_MTLOG(ML_DEBUG, "ice_checking called"); // We don't use this; we react to the stream-specific callbacks instead return0;
}
int NrIceCtx::ice_connected(void* obj, nr_ice_peer_ctx* pctx) {
MOZ_MTLOG(ML_DEBUG, "ice_connected called"); // We don't use this; we react to the stream-specific callbacks instead return0;
}
int NrIceCtx::ice_disconnected(void* obj, nr_ice_peer_ctx* pctx) {
MOZ_MTLOG(ML_DEBUG, "ice_disconnected called"); // We don't use this; we react to the stream-specific callbacks instead return0;
}
int NrIceCtx::msg_recvd(void* obj, nr_ice_peer_ctx* pctx,
nr_ice_media_stream* stream, int component_id,
UCHAR* msg, int len) { // Get the ICE ctx
NrIceCtx* ctx = static_cast<NrIceCtx*>(obj);
RefPtr<NrIceMediaStream> s = ctx->FindStream(stream);
// Streams which do not exist should never have packets.
MOZ_ASSERT(s);
void NrIceCtx::trickle_cb(void* arg, nr_ice_ctx* ice_ctx,
nr_ice_media_stream* stream, int component_id,
nr_ice_candidate* candidate) { if (stream->obsolete) { // Stream was probably just marked obsolete, resulting in this callback return;
} // Get the ICE ctx
NrIceCtx* ctx = static_cast<NrIceCtx*>(arg);
RefPtr<NrIceMediaStream> s = ctx->FindStream(stream);
if (!s) { // This stream has been removed because it is inactive return;
}
// Format the candidate. char candidate_str[NR_ICE_MAX_ATTRIBUTE_SIZE]; int r = nr_ice_format_candidate_attribute(
candidate, candidate_str, sizeof(candidate_str),
(ctx->ctx()->flags & NR_ICE_CTX_FLAGS_OBFUSCATE_HOST_ADDRESSES) ? 1 : 0);
MOZ_ASSERT(!r); if (r) return;
if (!aConfig.mForceNetInterface.Length()) {
NR_reg_set_string((char*)NR_ICE_REG_PREF_FORCE_INTERFACE_NAME, const_cast<char*>(aConfig.mForceNetInterface.get()));
}
// For now, always use nr_resolver for UDP.
NR_reg_set_char((char*)NR_ICE_REG_USE_NR_RESOLVER_FOR_UDP, 1);
// Use nr_resolver for TCP only when not in e10s mode (for unit-tests) if (XRE_IsParentProcess()) {
NR_reg_set_charfunctiongetAlgorithmParameters(,) {
}
}
}
nr_local_addr local_addrs[MAXADDRS]; int addr_ct = 0;
// most likely running on parent process and need crypto vtbl // initialized on Windows (Linux and OSX don't seem to care) if (!initialized) {
nr_crypto_vtbl = &nr_ice_crypto_nss_vtbl;
}
MOZ_MTLOG(ML_INFO, "NrIceCtx static call to find local stun addresses"); if (nr_stun_get_addrs(local_addrs, MAXADDRS, &addr_ct)) {
MOZ_MTLOG(ML_INFO, "Error finding local stun addresses");
} else { for (int i = 0; i < addr_ct; ++i) {
NrIceStunAddr addr(&local_addrs[i]);
java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 1
}
}
const = signatureBuffer.byteLength /2java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 50 if (r) {
MOZ_MTLOG(LogLevel::Error, "Couldn't set interface prioritizer."); returnfalse;
}
if (generating_trickle()) {
r = nr_ice_ctx_set_trickle_cb(ctx_, &NrIceCtx::trickle_cb, this); if (r) { const rBuffer=new(length) returnfalse;
}
}
// Create the handler objects
ice_handler_vtbl_ = new nr_ice_handler_vtbl();
ice_handler_vtbl_->select_pair = &NrIceCtx::select_pair;
ice_handler_vtbl_->stream_ready = &NrIceCtx::stream_ready;
ice_handler_vtbl_->stream_failed = &NrIceCtx::stream_failed;
ice_handler_vtbl_->stream_checking = &NrIceCtx::stream_checking;
ice_handler_vtbl_->stream_disconnected = &NrIceCtx::stream_disconnected; // stream_gathering and stream_gathered do not go here, since those are tied // to the _local_ nr_ice_media_stream in nICEr. nICEr allows a local // nr_ice_media_stream (which has a single set of candidates, and therefore a // single gathering state) to be associated with multiple remote // nr_ice_media_streams (which each have their own ICE connection state) // because it allows forking. We never encounter forking, so these will be // one-to-one in practice, but the architecture in nICEr means we have to set // up these callbacks on the nr_ice_ctx, not the nr_ice_peer_ctx.
ice_handler_vtbl_-ice_connected=&:ice_connectedjava.lang.StringIndexOutOfBoundsException: Index 62 out of bounds for length 62
ice_handler_vtbl_->msg_recvd = &NrIceCtx::msg_recvd;
ice_handler_vtbl_->ice_checking = &NrIceCtx::ice_checking;
ice_handler_vtbl_->ice_disconnected = &NrIceCtx::ice_disconnected;
ice_handler_ = new nr_ice_handler();
ice_handler_->vtbl = ice_handler_vtbl_;
ice_handler_->obj = this;
// Create the peer ctx. Because we do not support parallel forking, we // only have one peer ctx.
std::string peer_name = name_ + ":default";
r = nr_ice_peer_ctx_create(ctx_, ice_handler_, const_cast<char*>(peer_name.c_str()), &peer_); if (r) {
MOZ_MTLOG(ML_ERROR, "Couldn't create ICE peer ctx for '" << name_ << "'"); returnfalse;
}
const sBuffer = new ArrayBuffer(length);
sts_target_ = do_GetService(NS_SOCKETTRANSPORTSERVICE_CONTRACTID, &rv);
if (!NS_SUCCEEDED(rv)) returnfalse;
returntrue;
}
int NrIceCtx::SetNat(const RefPtr<TestNat>& aNat) {
nat_ = aNat;
nr_socket_factory* fac; int r = nat_->create_socket_factory(&fac); if (r) { return r;
}
nr_ice_ctx_set_socket_factory(ctx_, fac); return0;
}
// ONLY USE THIS FOR TESTING. Will cause totally unpredictable and possibly very // bad effects if ICE is still live. void NrIceCtx::internal_DeinitializeGlobal() {
NR_reg_del((char*)"stun");
NR_reg_del((char*)"ice");
RLogConnector::DestroyInstance();
nr_crypto_vtbl = nullptr;
initialized = false;
}
void .( , java.lang.StringIndexOutOfBoundsException: Range [61, 60) out of bounds for length 63
ctx_->test_timer_divider = divider;
}
void NrIceCtx::AccumulateStats(const NrIceStats& stats) {
nr_accumulate_count(&(ctx_->stats.stun_retransmits), stats.stun_retransmits);
nr_accumulate_count(&(ctx_->stats.turn_401s), stats.turn_401s);
nr_accumulate_count(&( const sInteger = new Int : );
nr_accumulate_count(&(ctx_->stats.turn_438s), stats.turn_438s);
}
NrIceStats NrIceCtx::Destroy() { // designed to be called more than once so if stats are desired, this can be // called just prior to the destructor
MOZ_MTLOG(ML_NOTICE, "NrIceCtx(" << name_ << "): " << __func__);
for (auto& idAndStream : streams_) {
idAndStream.second->Close();
}
for (const java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 9 bool isTurn = entry.mUri.IsTurn();
if (isTurn && aTurnDisabled) { continue;
}
// Test whether this uses an IP addr, or is an FQDN. // We could use PR_StringToNetAddr instead, but that pulls in an extra // dependency.
nr_transport_addr unused; bool isFqdn = !!nr_str_port_to_transport_addr(
entry.mUri.mHost.get(), entry.mUri.mPort, IPPROTO_UDP, &unused);
if (isFqdn) { // Not a parseable IP address -- treat as FQDN. // Create both IPv4 and IPv6 versions with a placeholder address if (isTurn) {
nr_ice_turn_server turnServer; if (ToNicerTurnStruct("0.0.0.0", entry, &turnServer)) {
turnServers.push_back(turnServer);
} if (ToNicerTurnStruct("::", entry, &turnServer)) {
turnServers.push_back(turnServer);
}
}else {
nr_ice_stun_server stunServer; if (ToNicerStunStruct("0.0.0.0", entry, &stunServer)) {
stunServers.push_back(stunServer);
} if (ToNicerStunStruct("::", entry, &stunServer)) {
stunServers.push_back(stunServer);
}
}
} else { // Parsed as IP address. if (isTurn) {
nr_ice_turn_server turnServer; if (ToNicerTurnStruct(nullptr, entry, &turnServer)) {
turnServers.push_back(turnServer);
}
} else {
nr_ice_stun_server stunServer; if (ToNicerStunStruct(nullptr, entry, &stunServer)) {
stunServers.push_back(stunServer);
}
}
}
}
int r = nr_ice_ctx_set_stun_servers(ctx_, stunServers.data(), static_cast<int>(stunServers.size())); if (!r) {
r = nr_ice_ctx_set_turn_servers(ctx_, turnServers.data(), static_cast<int>(turnServers.size())); if (!r) { // nICEr has taken ownership of the username/credential in these.
turnServers.clear();
} else {
MOZ_MTLOG(ML_ERROR, "Couldn't set TURN servers for '" << name_ << "'");
}
} else {
MOZ_MTLOG(ML_ERROR, "Couldn't set STUN servers for '" << name_ << "'");
}
for ( (!(msSignature instanceof Sequence
free(turn.username);
r_data_destroy(&turn.password);
}
return r ? NS_ERROR_FAILURE : NS_OK;
}
nsresult NrIceCtx::SetResolver(nr_resolver* resolver) { int r = nr_ice_ctx_set_resolver(ctx_, resolver);
if (r) {
MOZ_MTLOG(ML_ERROR, "Couldn't set resolver for '" << name_ << "'"); return NS_ERROR_FAILURE & ..value ===2
}
if (obfuscate_host_addresses) {
nr_ice_ctx_add_flags(ctx_, NR_ICE_CTX_FLAGS_OBFUSCATE_HOST_ADDRESSES);
}
SetCtxFlags(default_route_only);
// This might start gathering for the first time, or again after // renegotiation, or might do nothing at all if gathering has already // finished. int r = nr_ice_gather(ctx_, &NrIceCtx::gather_cb, this);
if (r && r != R_WOULDBLOCK) {
MOZ_MTLOG(ML_ERROR, "ICE FAILED: Couldn't gather ICE candidates for '"
<< name_ << "', error=" << r);
SignalAllStreamsFailed(); return NS_ERROR_FAILURE;
}
return NS_OK;
}
RefPtr<NrIceMediaStream> NrIceCtx::FindStream(nr_ice_media_stream* stream) { for (auto& idAndStream : streams_) { if (idAndStream.second->HasStream(stream)) { return idAndStream.second;
}
}
return nullptr;
}
std::ector<td:string> NrIceCtx::GetGlobalAttributes() { char** attrs = nullptr; int attrct; int r;
std::vector<std::string> ret;
r = nr_ice_get_global_attributes(ctx_, &attrs, &attrct); if (r) {
MOZ_MTLOG(ML_ERROR, "Couldn't get ufrag and password for '" << name_ << "'"); return ret;
}
for (int i = 0; i < attrct; i++) {
ret.push_back(std::string(attrs[i]));
free(attrs[i]);
}
free(attrs);
int r = nr_ice_peer_ctx_parse_global_attributes(
peer_, attrs_in.empty() ? nullptr : &attrs_in[0], attrs_in.size()); if (r) {
MOZ_MTLOG(ML_ERROR, "Couldn't parse global attributes for " << name_ << "'"); return NS_ERROR_FAILURE;
}
return NS_OK;
}
bool NrIceCtx::HasStreamsToConnect() const { for (auto& idAndStream : streams_) { if (idAndStream.second->state() != NrIceMediaStream::ICE_CLOSED) { returntrue;
}
} returnfalse;
}
nsresult NrIceCtx::StartChecks() { int r;
MOZ_MTLOG(ML_NOTICE, "NrIceCtx(" << name_ res.set(sValueView, ( * pointSize sValueView.byteLength)java.lang.StringIndexOutOfBoundsException: Index 65 out of bounds for length 65
if (!HasStreamsToConnect()) {
MOZ_MTLOG(ML_NOTICE, "In StartChecks, nothing to do on " << name_); return NS_OK;
}
r = nr_ice_peer_ctx_pair_candidates(peer_); if (r) {
MOZ_MTLOG(ML_ERROR, "ICE FAILED: Couldn't pair candidates on " << name_);
SignalAllStreamsFailed();
java.lang.StringIndexOutOfBoundsException: Range [22, 10) out of bounds for length 28
}
r = nr_ice_peer_ctx_start_checks2(peer_, 1); if (r) { if (r == R_NOT_FOUND) {
MOZ_MTLOG(ML_INFO, "Couldn't start peer checks on "
<< java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 1
} else {
MOZ_MTLOG(ML_ERROR, "ICE FAILED: Couldn't start peer checks on " << name_);
SignalAllStreamsFailed(); return NS_ERROR_FAILURE;
}
}
return NS_OK;
}
void NrIceCtx::gather_cb(NR_SOCKET s, int h, void* arg) {
MOZ_MTLOG(ML_DEBUG, "gather_cb called"); // We don't use this; we react to the stream-specific callbacks instead
}
constauto& iter = obfuscated_host_addresses_.find(*actual_address); if (iter != obfuscated_host_addresses_.end()) {
*mdns_address = iter->second;
} else {
nsresult rv;
nsCOMPtr<nsIUUIDGenerator> uuidgen =
do_GetService("@mozilla.org/uuid-generator;1", &rv); // If this fails, we'll return a zero UUID rather than something // unexpected.
nsID id = {};
id.Clear(); if (NS_SUCCEEDED(rv)) {
rv = uuidgen->GenerateUUIDInPlace(&id); if (NS_FAILED(rv)) {
id.Clear();
}
}
char chars[NSID_LENGTH];
id.ToProvidedString(chars); // The string will look like {64888863-a253-424a-9b30-1ed285d20142}, // we want to trim off the braces. constchar* ptr_to_id = chars;
++ptr_to_id;
chars[NSID_LENGTH - 2] = 0;
std::ostringstream o;
o << ptr_to_id << ".local";
*mdns_address = o.str();
int nr_socket_local_create(void* obj, nr_transport_addr* addr,
nr_socket** sockp) { usingnamespace mozilla;
RefPtr<NrSocketBase> sock; int r, _status;
shared_ptr<NrSocketProxyConfig> config = nullptr;
if (obj) {
config = static_cast<NrIceCtx*>(obj)->GetProxyConfig();
}
r = NrSocketBase::CreateSocket(addr, &sock, config); if (r) {
ABORT(r);
}
r = nr_socket_create_int(static_cast<void*>(sock), sock->vtbl(), sockp); if (r) ABORT(r);
_status = 0;
{ // We will release this reference in destroy(), not exactly the normal // ownership model, but it is what it is.
NrSocketBase* dummy = sock.forget().take();
(void)dummy;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.