/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set sw=2 ts=8 et tw=80 : */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// HttpLog.h should generally be included first #include"HttpLog.h"
// Log on level :5, instead of default :4. #undef LOG #define LOG(args) LOG5(args) #undef LOG_ENABLED #define LOG_ENABLED() LOG5_ENABLED()
void nsHttpConnectionInfo::BuildHashKey() { // // build hash key: // // the hash key uniquely identifies the connection type. two connections // are "equal" if they end up talking the same protocol to the same server // and are both used for anonymous or non-anonymous connection only; // anonymity of the connection is setup later from nsHttpChannel::AsyncOpen // where we know we use anonymous connection (LOAD_ANONYMOUS load flag) //
// The hashkey has 9 fields followed by host connection info // byte 0 is P/T/. {P,T} for Plaintext/TLS Proxy over HTTP // byte 1 is S/. S is for end to end ssl such as https:// uris // byte 2 is A/. A is for an anonymous channel (no cookies, etc..) // byte 3 is P/. P is for a private browising channel // byte 4 is I/. I is for insecure scheme on TLS for http:// uris // byte 5 is X/. X is for disallow_spdy flag // byte 6 is C/. C is for be Conservative // byte 7 is B/. B is for allowing client certs on an anonymous channel // byte 8 is F/. F is for indicating a fallback connection // byte 9 is W/. W is for indicating a webTransport // Note: when adding/removing fields from this list which do not have // corresponding data fields on the object itself, you may also need to // modify RebuildHashKey.
mHashKey.Append(keyHost);
mHashKey.Append(':');
mHashKey.AppendInt(keyPort); if (!mUsername.IsEmpty()) {
mHashKey.Append('[');
mHashKey.Append(mUsername);
mHashKey.Append(']');
}
if (mUsingHttpsProxy) {
SetHashCharAt('T', HashKeyIndex::Proxy);
} elseif (mUsingHttpProxy) {
SetHashCharAt('P', HashKeyIndex::Proxy);
} if (mEndToEndSSL) {
SetHashCharAt('S', HashKeyIndex::EndToEndSSL);
}
if (mWebTransport) {
SetHashCharAt('W', HashKeyIndex::WebTransport);
}
// NOTE: for transparent proxies (e.g., SOCKS) we need to encode the proxy // info in the hash key (this ensures that we will continue to speak the // right protocol even if our proxy preferences change). // // NOTE: for SSL tunnels add the proxy information to the cache key. // We cannot use the proxy as the host parameter (as we do for non SSL) // because this is a single host tunnel, but we need to include the proxy // information so that a change in proxy config will mean this connection // is not reused
// NOTE: Adding the username and the password provides a means to isolate // keep-alive to the URL bar domain as well: If the username is the URL bar // domain, keep-alive connections are not reused by resources bound to // different URL bar domains as the respective hash keys are not matching.
if (!mRoutedHost.IsEmpty()) {
mHashKey.AppendLiteral(" );
mHashKey.Append(mRoutedHost);
mHashKey.Append(':');
mHashKey.AppendInt(mRoutedPort);
mHashKey.Append('>');
}
if (!mNPNToken.IsEmpty()) {
mHashKey.AppendLiteral(" {NPN-TOKEN ");
mHashKey.Append(mNPNToken);
mHashKey.AppendLiteral("}");
}
if (GetTRRMode() != nsIRequest::TRR_DEFAULT_MODE) { // When connecting with another TRR mode, we enforce a separate connection // hashkey so that we also can trigger a fresh DNS resolver that then // doesn't use TRR as the previous connection might have.
mHashKey.AppendLiteral("[TRR:");
mHashKey.AppendInt(GetTRRMode());
mHashKey.AppendLiteral("]");
}
if (GetIPv4Disabled()) {
mHashKey.AppendLiteral("[!v4]");
}
if (GetIPv6Disabled()) {
mHashKey.AppendLiteral("[!v6]");
}
if (mProxyInfo) { const nsCString& connectionIsolationKey =
mProxyInfo->ConnectionIsolationKey(); if (!connectionIsolationKey.IsEmpty()) {
mHashKey.AppendLiteral("{CIK ");
mHashKey.Append(connectionIsolationKey);
mHashKey.AppendLiteral("}");
} if (mProxyInfo->Flags() & nsIProxyInfo::TRANSPARENT_PROXY_RESOLVES_HOST) {
mHashKey.AppendLiteral("{TPRH}");
}
}
if (mWebTransportId) {
mHashKey.AppendLiteral("{wId");
mHashKey.AppendInt(mWebTransportId, 16);
mHashKey.AppendLiteral("}");
}
// Restore all of those properties.
SetAnonymous(isAnonymous);
SetPrivate(isPrivate);
SetInsecureScheme(isInsecureScheme);
SetNoSpdy(isNoSpdy);
SetBeConservative(isBeConservative);
SetAnonymousAllowClientCert(isAnonymousAllowClientCert);
SetFallbackConnection(isFallback);
}
void nsHttpConnectionInfo::SetOriginServer(const nsACString& host,
int32_t port) {
mOrigin = host;
mOriginPort = port == -1 ? DefaultPort() : port; // Use BuildHashKey() since this can only be called when constructing an // nsHttpConnectionInfo object.
MOZ_DIAGNOSTIC_ASSERT(mHashKey.IsEmpty());
BuildHashKey();
}
// Note that this function needs to be synced with // nsHttpConnectionInfo::DeserializeHttpConnectionInfoCloneArgs to make sure // nsHttpConnectionInfo can be serialized/deserialized.
already_AddRefed<nsHttpConnectionInfo> nsHttpConnectionInfo::Clone() const {
RefPtr<nsHttpConnectionInfo> clone; if (mRoutedHost.IsEmpty()) {
clone = new nsHttpConnectionInfo(mOrigin, mOriginPort, mNPNToken, mUsername,
mProxyInfo, mOriginAttributes,
mEndToEndSSL, mIsHttp3, mWebTransport);
} else {
MOZ_ASSERT(mEndToEndSSL);
clone = new nsHttpConnectionInfo(mOrigin, mOriginPort, mNPNToken, mUsername,
mProxyInfo, mOriginAttributes, mRoutedHost,
mRoutedPort, mIsHttp3, mWebTransport);
}
// Make sure the anonymous, insecure-scheme, and private flags are transferred
clone->SetAnonymous(GetAnonymous());
clone->SetPrivate(GetPrivate());
clone->SetInsecureScheme(GetInsecureScheme());
clone->SetNoSpdy(GetNoSpdy());
clone->SetBeConservative(GetBeConservative());
clone->SetAnonymousAllowClientCert(GetAnonymousAllowClientCert());
clone->SetFallbackConnection(GetFallbackConnection());
clone->SetTlsFlags(GetTlsFlags());
clone->SetIsTrrServiceChannel(GetIsTrrServiceChannel());
clone->SetTRRMode(GetTRRMode());
clone->SetIPv4Disabled(GetIPv4Disabled());
clone->SetIPv6Disabled(GetIPv6Disabled());
clone->SetHasIPHintAddress(HasIPHintAddress());
clone->SetEchConfig(GetEchConfig());
clone->SetWebTransportId(GetWebTransportId());
MOZ_ASSERT(clone->Equals(this));
// Get the domain name of this HTTPS RR. This name will be assigned to // mRoutedHost in the new connection info.
nsAutoCString name;
aRecord->GetName(name);
// Try to get the port and Alpn. If this record has SvcParamKeyPort defined, // the new port will be used as mRoutedPort.
Maybe<uint16_t> port = aRecord->GetPort();
Maybe<std::tuple<nsCString, SupportedAlpnRank>> alpn = aRecord->GetAlpn();
// Let the new conn info learn h3 will be used. bool isHttp3 = alpn ? mozilla::net::IsHttp3(std::get<1>(*alpn)) : false;
LOG(("HTTPSSVC: use new routed host (%s) and new npnToken (%s)", name.get(),
alpn ? std::get<0>(*alpn).get() : "None"));
bool nsHttpConnectionInfo::UsingProxy() { if (!mProxyInfo) returnfalse; return !mProxyInfo->IsDirect();
}
bool nsHttpConnectionInfo::HostIsLocalIPLiteral() const {
NetAddr netAddr; // If the host/proxy host is not an IP address literal, return false.
nsAutoCString host(ProxyHost() ? ProxyHost() : Origin()); if (NS_FAILED(netAddr.InitFromString(host))) { returnfalse;
} return netAddr.IsIPAddrLocal();
}
} // namespace net
} // namespace mozilla
¤ Dauer der Verarbeitung: 0.39 Sekunden
(vorverarbeitet)
¤
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 ist noch experimentell.