gecko-dev/netwerk/base/ProxyAutoConfig.cpp
James Kitchener 2185d3a4e6 Bug 1100184 - Flatten netwerk/base/{public,src}/ directories. r=mcmanus, r=poiru
--HG--
rename : netwerk/base/src/ADivertableParentChannel.h => netwerk/base/ADivertableParentChannel.h
rename : netwerk/base/src/ArrayBufferInputStream.cpp => netwerk/base/ArrayBufferInputStream.cpp
rename : netwerk/base/src/ArrayBufferInputStream.h => netwerk/base/ArrayBufferInputStream.h
rename : netwerk/base/src/AutoClose.h => netwerk/base/AutoClose.h
rename : netwerk/base/src/BackgroundFileSaver.cpp => netwerk/base/BackgroundFileSaver.cpp
rename : netwerk/base/src/BackgroundFileSaver.h => netwerk/base/BackgroundFileSaver.h
rename : netwerk/base/src/ChannelDiverterChild.cpp => netwerk/base/ChannelDiverterChild.cpp
rename : netwerk/base/src/ChannelDiverterChild.h => netwerk/base/ChannelDiverterChild.h
rename : netwerk/base/src/ChannelDiverterParent.cpp => netwerk/base/ChannelDiverterParent.cpp
rename : netwerk/base/src/ChannelDiverterParent.h => netwerk/base/ChannelDiverterParent.h
rename : netwerk/base/src/Dashboard.cpp => netwerk/base/Dashboard.cpp
rename : netwerk/base/src/Dashboard.h => netwerk/base/Dashboard.h
rename : netwerk/base/src/DashboardTypes.h => netwerk/base/DashboardTypes.h
rename : netwerk/base/src/EventTokenBucket.cpp => netwerk/base/EventTokenBucket.cpp
rename : netwerk/base/src/EventTokenBucket.h => netwerk/base/EventTokenBucket.h
rename : netwerk/base/src/LoadContextInfo.cpp => netwerk/base/LoadContextInfo.cpp
rename : netwerk/base/src/LoadContextInfo.h => netwerk/base/LoadContextInfo.h
rename : netwerk/base/public/NetStatistics.h => netwerk/base/NetStatistics.h
rename : netwerk/base/src/NetUtil.jsm => netwerk/base/NetUtil.jsm
rename : netwerk/base/src/NetworkActivityMonitor.cpp => netwerk/base/NetworkActivityMonitor.cpp
rename : netwerk/base/src/NetworkActivityMonitor.h => netwerk/base/NetworkActivityMonitor.h
rename : netwerk/base/src/OfflineObserver.cpp => netwerk/base/OfflineObserver.cpp
rename : netwerk/base/src/OfflineObserver.h => netwerk/base/OfflineObserver.h
rename : netwerk/base/src/Predictor.cpp => netwerk/base/Predictor.cpp
rename : netwerk/base/src/Predictor.h => netwerk/base/Predictor.h
rename : netwerk/base/src/PrivateBrowsingChannel.h => netwerk/base/PrivateBrowsingChannel.h
rename : netwerk/base/src/ProxyAutoConfig.cpp => netwerk/base/ProxyAutoConfig.cpp
rename : netwerk/base/src/ProxyAutoConfig.h => netwerk/base/ProxyAutoConfig.h
rename : netwerk/base/src/RedirectChannelRegistrar.cpp => netwerk/base/RedirectChannelRegistrar.cpp
rename : netwerk/base/src/RedirectChannelRegistrar.h => netwerk/base/RedirectChannelRegistrar.h
rename : netwerk/base/public/ReferrerPolicy.h => netwerk/base/ReferrerPolicy.h
rename : netwerk/base/src/StreamingProtocolService.cpp => netwerk/base/StreamingProtocolService.cpp
rename : netwerk/base/src/StreamingProtocolService.h => netwerk/base/StreamingProtocolService.h
rename : netwerk/base/src/TLSServerSocket.cpp => netwerk/base/TLSServerSocket.cpp
rename : netwerk/base/src/TLSServerSocket.h => netwerk/base/TLSServerSocket.h
rename : netwerk/base/src/Tickler.cpp => netwerk/base/Tickler.cpp
rename : netwerk/base/src/Tickler.h => netwerk/base/Tickler.h
rename : netwerk/base/public/mozIThirdPartyUtil.idl => netwerk/base/mozIThirdPartyUtil.idl
rename : netwerk/base/public/netCore.h => netwerk/base/netCore.h
rename : netwerk/base/public/nsASocketHandler.h => netwerk/base/nsASocketHandler.h
rename : netwerk/base/src/nsAsyncRedirectVerifyHelper.cpp => netwerk/base/nsAsyncRedirectVerifyHelper.cpp
rename : netwerk/base/public/nsAsyncRedirectVerifyHelper.h => netwerk/base/nsAsyncRedirectVerifyHelper.h
rename : netwerk/base/src/nsAsyncStreamCopier.cpp => netwerk/base/nsAsyncStreamCopier.cpp
rename : netwerk/base/src/nsAsyncStreamCopier.h => netwerk/base/nsAsyncStreamCopier.h
rename : netwerk/base/src/nsAuthInformationHolder.cpp => netwerk/base/nsAuthInformationHolder.cpp
rename : netwerk/base/src/nsAuthInformationHolder.h => netwerk/base/nsAuthInformationHolder.h
rename : netwerk/base/src/nsAutodialQt.cpp => netwerk/base/nsAutodialQt.cpp
rename : netwerk/base/src/nsAutodialQt.h => netwerk/base/nsAutodialQt.h
rename : netwerk/base/src/nsAutodialWin.cpp => netwerk/base/nsAutodialWin.cpp
rename : netwerk/base/src/nsAutodialWin.h => netwerk/base/nsAutodialWin.h
rename : netwerk/base/src/nsBase64Encoder.cpp => netwerk/base/nsBase64Encoder.cpp
rename : netwerk/base/src/nsBase64Encoder.h => netwerk/base/nsBase64Encoder.h
rename : netwerk/base/src/nsBaseChannel.cpp => netwerk/base/nsBaseChannel.cpp
rename : netwerk/base/src/nsBaseChannel.h => netwerk/base/nsBaseChannel.h
rename : netwerk/base/src/nsBaseContentStream.cpp => netwerk/base/nsBaseContentStream.cpp
rename : netwerk/base/src/nsBaseContentStream.h => netwerk/base/nsBaseContentStream.h
rename : netwerk/base/src/nsBufferedStreams.cpp => netwerk/base/nsBufferedStreams.cpp
rename : netwerk/base/src/nsBufferedStreams.h => netwerk/base/nsBufferedStreams.h
rename : netwerk/base/src/nsChannelClassifier.cpp => netwerk/base/nsChannelClassifier.cpp
rename : netwerk/base/src/nsChannelClassifier.h => netwerk/base/nsChannelClassifier.h
rename : netwerk/base/src/nsDNSPrefetch.cpp => netwerk/base/nsDNSPrefetch.cpp
rename : netwerk/base/src/nsDNSPrefetch.h => netwerk/base/nsDNSPrefetch.h
rename : netwerk/base/src/nsDirectoryIndexStream.cpp => netwerk/base/nsDirectoryIndexStream.cpp
rename : netwerk/base/src/nsDirectoryIndexStream.h => netwerk/base/nsDirectoryIndexStream.h
rename : netwerk/base/src/nsDownloader.cpp => netwerk/base/nsDownloader.cpp
rename : netwerk/base/src/nsDownloader.h => netwerk/base/nsDownloader.h
rename : netwerk/base/src/nsFileStreams.cpp => netwerk/base/nsFileStreams.cpp
rename : netwerk/base/src/nsFileStreams.h => netwerk/base/nsFileStreams.h
rename : netwerk/base/public/nsIApplicationCache.idl => netwerk/base/nsIApplicationCache.idl
rename : netwerk/base/public/nsIApplicationCacheChannel.idl => netwerk/base/nsIApplicationCacheChannel.idl
rename : netwerk/base/public/nsIApplicationCacheContainer.idl => netwerk/base/nsIApplicationCacheContainer.idl
rename : netwerk/base/public/nsIApplicationCacheService.idl => netwerk/base/nsIApplicationCacheService.idl
rename : netwerk/base/public/nsIArrayBufferInputStream.idl => netwerk/base/nsIArrayBufferInputStream.idl
rename : netwerk/base/public/nsIAsyncStreamCopier.idl => netwerk/base/nsIAsyncStreamCopier.idl
rename : netwerk/base/public/nsIAsyncStreamCopier2.idl => netwerk/base/nsIAsyncStreamCopier2.idl
rename : netwerk/base/public/nsIAsyncVerifyRedirectCallback.idl => netwerk/base/nsIAsyncVerifyRedirectCallback.idl
rename : netwerk/base/public/nsIAuthInformation.idl => netwerk/base/nsIAuthInformation.idl
rename : netwerk/base/public/nsIAuthModule.idl => netwerk/base/nsIAuthModule.idl
rename : netwerk/base/public/nsIAuthPrompt.idl => netwerk/base/nsIAuthPrompt.idl
rename : netwerk/base/public/nsIAuthPrompt2.idl => netwerk/base/nsIAuthPrompt2.idl
rename : netwerk/base/public/nsIAuthPromptAdapterFactory.idl => netwerk/base/nsIAuthPromptAdapterFactory.idl
rename : netwerk/base/public/nsIAuthPromptCallback.idl => netwerk/base/nsIAuthPromptCallback.idl
rename : netwerk/base/public/nsIAuthPromptProvider.idl => netwerk/base/nsIAuthPromptProvider.idl
rename : netwerk/base/public/nsIBackgroundFileSaver.idl => netwerk/base/nsIBackgroundFileSaver.idl
rename : netwerk/base/public/nsIBrowserSearchService.idl => netwerk/base/nsIBrowserSearchService.idl
rename : netwerk/base/public/nsIBufferedStreams.idl => netwerk/base/nsIBufferedStreams.idl
rename : netwerk/base/public/nsIByteRangeRequest.idl => netwerk/base/nsIByteRangeRequest.idl
rename : netwerk/base/public/nsICacheInfoChannel.idl => netwerk/base/nsICacheInfoChannel.idl
rename : netwerk/base/public/nsICachingChannel.idl => netwerk/base/nsICachingChannel.idl
rename : netwerk/base/public/nsICancelable.idl => netwerk/base/nsICancelable.idl
rename : netwerk/base/public/nsIChannel.idl => netwerk/base/nsIChannel.idl
rename : netwerk/base/public/nsIChannelEventSink.idl => netwerk/base/nsIChannelEventSink.idl
rename : netwerk/base/public/nsIChildChannel.idl => netwerk/base/nsIChildChannel.idl
rename : netwerk/base/public/nsIClassOfService.idl => netwerk/base/nsIClassOfService.idl
rename : netwerk/base/public/nsIContentSniffer.idl => netwerk/base/nsIContentSniffer.idl
rename : netwerk/base/public/nsICryptoFIPSInfo.idl => netwerk/base/nsICryptoFIPSInfo.idl
rename : netwerk/base/public/nsICryptoHMAC.idl => netwerk/base/nsICryptoHMAC.idl
rename : netwerk/base/public/nsICryptoHash.idl => netwerk/base/nsICryptoHash.idl
rename : netwerk/base/public/nsIDashboard.idl => netwerk/base/nsIDashboard.idl
rename : netwerk/base/public/nsIDashboardEventNotifier.idl => netwerk/base/nsIDashboardEventNotifier.idl
rename : netwerk/base/public/nsIDivertableChannel.idl => netwerk/base/nsIDivertableChannel.idl
rename : netwerk/base/public/nsIDownloader.idl => netwerk/base/nsIDownloader.idl
rename : netwerk/base/public/nsIEncodedChannel.idl => netwerk/base/nsIEncodedChannel.idl
rename : netwerk/base/public/nsIExternalProtocolHandler.idl => netwerk/base/nsIExternalProtocolHandler.idl
rename : netwerk/base/public/nsIFileStreams.idl => netwerk/base/nsIFileStreams.idl
rename : netwerk/base/public/nsIFileURL.idl => netwerk/base/nsIFileURL.idl
rename : netwerk/base/public/nsIForcePendingChannel.idl => netwerk/base/nsIForcePendingChannel.idl
rename : netwerk/base/public/nsIHttpPushListener.idl => netwerk/base/nsIHttpPushListener.idl
rename : netwerk/base/public/nsIIOService.idl => netwerk/base/nsIIOService.idl
rename : netwerk/base/public/nsIIOService2.idl => netwerk/base/nsIIOService2.idl
rename : netwerk/base/public/nsIIncrementalDownload.idl => netwerk/base/nsIIncrementalDownload.idl
rename : netwerk/base/public/nsIInputStreamChannel.idl => netwerk/base/nsIInputStreamChannel.idl
rename : netwerk/base/public/nsIInputStreamPump.idl => netwerk/base/nsIInputStreamPump.idl
rename : netwerk/base/public/nsILoadContextInfo.idl => netwerk/base/nsILoadContextInfo.idl
rename : netwerk/base/public/nsILoadGroup.idl => netwerk/base/nsILoadGroup.idl
rename : netwerk/base/public/nsILoadGroupChild.idl => netwerk/base/nsILoadGroupChild.idl
rename : netwerk/base/public/nsIMIMEInputStream.idl => netwerk/base/nsIMIMEInputStream.idl
rename : netwerk/base/public/nsIMultiPartChannel.idl => netwerk/base/nsIMultiPartChannel.idl
rename : netwerk/base/public/nsINSSErrorsService.idl => netwerk/base/nsINSSErrorsService.idl
rename : netwerk/base/public/nsINestedURI.idl => netwerk/base/nsINestedURI.idl
rename : netwerk/base/public/nsINetAddr.idl => netwerk/base/nsINetAddr.idl
rename : netwerk/base/public/nsINetUtil.idl => netwerk/base/nsINetUtil.idl
rename : netwerk/base/public/nsINetworkInterceptController.idl => netwerk/base/nsINetworkInterceptController.idl
rename : netwerk/base/public/nsINetworkLinkService.idl => netwerk/base/nsINetworkLinkService.idl
rename : netwerk/base/public/nsINetworkPredictor.idl => netwerk/base/nsINetworkPredictor.idl
rename : netwerk/base/public/nsINetworkPredictorVerifier.idl => netwerk/base/nsINetworkPredictorVerifier.idl
rename : netwerk/base/public/nsINetworkProperties.idl => netwerk/base/nsINetworkProperties.idl
rename : netwerk/base/public/nsINullChannel.idl => netwerk/base/nsINullChannel.idl
rename : netwerk/base/src/nsIOService.cpp => netwerk/base/nsIOService.cpp
rename : netwerk/base/src/nsIOService.h => netwerk/base/nsIOService.h
rename : netwerk/base/public/nsIParentChannel.idl => netwerk/base/nsIParentChannel.idl
rename : netwerk/base/public/nsIParentRedirectingChannel.idl => netwerk/base/nsIParentRedirectingChannel.idl
rename : netwerk/base/public/nsIPermission.idl => netwerk/base/nsIPermission.idl
rename : netwerk/base/public/nsIPermissionManager.idl => netwerk/base/nsIPermissionManager.idl
rename : netwerk/base/public/nsIPrivateBrowsingChannel.idl => netwerk/base/nsIPrivateBrowsingChannel.idl
rename : netwerk/base/public/nsIProgressEventSink.idl => netwerk/base/nsIProgressEventSink.idl
rename : netwerk/base/public/nsIPrompt.idl => netwerk/base/nsIPrompt.idl
rename : netwerk/base/public/nsIProtocolHandler.idl => netwerk/base/nsIProtocolHandler.idl
rename : netwerk/base/public/nsIProtocolProxyCallback.idl => netwerk/base/nsIProtocolProxyCallback.idl
rename : netwerk/base/public/nsIProtocolProxyFilter.idl => netwerk/base/nsIProtocolProxyFilter.idl
rename : netwerk/base/public/nsIProtocolProxyService.idl => netwerk/base/nsIProtocolProxyService.idl
rename : netwerk/base/public/nsIProtocolProxyService2.idl => netwerk/base/nsIProtocolProxyService2.idl
rename : netwerk/base/public/nsIProxiedChannel.idl => netwerk/base/nsIProxiedChannel.idl
rename : netwerk/base/public/nsIProxiedProtocolHandler.idl => netwerk/base/nsIProxiedProtocolHandler.idl
rename : netwerk/base/public/nsIProxyInfo.idl => netwerk/base/nsIProxyInfo.idl
rename : netwerk/base/public/nsIRandomGenerator.idl => netwerk/base/nsIRandomGenerator.idl
rename : netwerk/base/public/nsIRedirectChannelRegistrar.idl => netwerk/base/nsIRedirectChannelRegistrar.idl
rename : netwerk/base/public/nsIRedirectHistory.idl => netwerk/base/nsIRedirectHistory.idl
rename : netwerk/base/public/nsIRedirectResultListener.idl => netwerk/base/nsIRedirectResultListener.idl
rename : netwerk/base/public/nsIRequest.idl => netwerk/base/nsIRequest.idl
rename : netwerk/base/public/nsIRequestObserver.idl => netwerk/base/nsIRequestObserver.idl
rename : netwerk/base/public/nsIRequestObserverProxy.idl => netwerk/base/nsIRequestObserverProxy.idl
rename : netwerk/base/public/nsIResumableChannel.idl => netwerk/base/nsIResumableChannel.idl
rename : netwerk/base/public/nsISecretDecoderRing.idl => netwerk/base/nsISecretDecoderRing.idl
rename : netwerk/base/public/nsISecureBrowserUI.idl => netwerk/base/nsISecureBrowserUI.idl
rename : netwerk/base/public/nsISecurityEventSink.idl => netwerk/base/nsISecurityEventSink.idl
rename : netwerk/base/public/nsISecurityInfoProvider.idl => netwerk/base/nsISecurityInfoProvider.idl
rename : netwerk/base/public/nsISerializationHelper.idl => netwerk/base/nsISerializationHelper.idl
rename : netwerk/base/public/nsIServerSocket.idl => netwerk/base/nsIServerSocket.idl
rename : netwerk/base/public/nsISimpleStreamListener.idl => netwerk/base/nsISimpleStreamListener.idl
rename : netwerk/base/public/nsISiteSecurityService.idl => netwerk/base/nsISiteSecurityService.idl
rename : netwerk/base/public/nsISocketTransport.idl => netwerk/base/nsISocketTransport.idl
rename : netwerk/base/public/nsISocketTransportService.idl => netwerk/base/nsISocketTransportService.idl
rename : netwerk/base/public/nsISpeculativeConnect.idl => netwerk/base/nsISpeculativeConnect.idl
rename : netwerk/base/public/nsIStandardURL.idl => netwerk/base/nsIStandardURL.idl
rename : netwerk/base/public/nsIStreamListener.idl => netwerk/base/nsIStreamListener.idl
rename : netwerk/base/public/nsIStreamListenerTee.idl => netwerk/base/nsIStreamListenerTee.idl
rename : netwerk/base/public/nsIStreamLoader.idl => netwerk/base/nsIStreamLoader.idl
rename : netwerk/base/public/nsIStreamTransportService.idl => netwerk/base/nsIStreamTransportService.idl
rename : netwerk/base/public/nsIStreamingProtocolController.idl => netwerk/base/nsIStreamingProtocolController.idl
rename : netwerk/base/public/nsIStreamingProtocolService.idl => netwerk/base/nsIStreamingProtocolService.idl
rename : netwerk/base/public/nsISyncStreamListener.idl => netwerk/base/nsISyncStreamListener.idl
rename : netwerk/base/public/nsISystemProxySettings.idl => netwerk/base/nsISystemProxySettings.idl
rename : netwerk/base/public/nsITLSServerSocket.idl => netwerk/base/nsITLSServerSocket.idl
rename : netwerk/base/public/nsIThreadRetargetableRequest.idl => netwerk/base/nsIThreadRetargetableRequest.idl
rename : netwerk/base/public/nsIThreadRetargetableStreamListener.idl => netwerk/base/nsIThreadRetargetableStreamListener.idl
rename : netwerk/base/public/nsITimedChannel.idl => netwerk/base/nsITimedChannel.idl
rename : netwerk/base/public/nsITraceableChannel.idl => netwerk/base/nsITraceableChannel.idl
rename : netwerk/base/public/nsITransport.idl => netwerk/base/nsITransport.idl
rename : netwerk/base/public/nsIUDPSocket.idl => netwerk/base/nsIUDPSocket.idl
rename : netwerk/base/public/nsIUDPSocketFilter.idl => netwerk/base/nsIUDPSocketFilter.idl
rename : netwerk/base/public/nsIURI.idl => netwerk/base/nsIURI.idl
rename : netwerk/base/public/nsIURIChecker.idl => netwerk/base/nsIURIChecker.idl
rename : netwerk/base/public/nsIURIClassifier.idl => netwerk/base/nsIURIClassifier.idl
rename : netwerk/base/public/nsIURIWithPrincipal.idl => netwerk/base/nsIURIWithPrincipal.idl
rename : netwerk/base/public/nsIURL.idl => netwerk/base/nsIURL.idl
rename : netwerk/base/public/nsIURLParser.idl => netwerk/base/nsIURLParser.idl
rename : netwerk/base/public/nsIUnicharStreamLoader.idl => netwerk/base/nsIUnicharStreamLoader.idl
rename : netwerk/base/public/nsIUploadChannel.idl => netwerk/base/nsIUploadChannel.idl
rename : netwerk/base/public/nsIUploadChannel2.idl => netwerk/base/nsIUploadChannel2.idl
rename : netwerk/base/src/nsIncrementalDownload.cpp => netwerk/base/nsIncrementalDownload.cpp
rename : netwerk/base/src/nsInputStreamChannel.cpp => netwerk/base/nsInputStreamChannel.cpp
rename : netwerk/base/src/nsInputStreamChannel.h => netwerk/base/nsInputStreamChannel.h
rename : netwerk/base/src/nsInputStreamPump.cpp => netwerk/base/nsInputStreamPump.cpp
rename : netwerk/base/src/nsInputStreamPump.h => netwerk/base/nsInputStreamPump.h
rename : netwerk/base/src/nsLoadGroup.cpp => netwerk/base/nsLoadGroup.cpp
rename : netwerk/base/src/nsLoadGroup.h => netwerk/base/nsLoadGroup.h
rename : netwerk/base/src/nsMIMEInputStream.cpp => netwerk/base/nsMIMEInputStream.cpp
rename : netwerk/base/src/nsMIMEInputStream.h => netwerk/base/nsMIMEInputStream.h
rename : netwerk/base/src/nsMediaFragmentURIParser.cpp => netwerk/base/nsMediaFragmentURIParser.cpp
rename : netwerk/base/src/nsMediaFragmentURIParser.h => netwerk/base/nsMediaFragmentURIParser.h
rename : netwerk/base/src/nsNativeConnectionHelper.cpp => netwerk/base/nsNativeConnectionHelper.cpp
rename : netwerk/base/src/nsNativeConnectionHelper.h => netwerk/base/nsNativeConnectionHelper.h
rename : netwerk/base/src/nsNetAddr.cpp => netwerk/base/nsNetAddr.cpp
rename : netwerk/base/src/nsNetAddr.h => netwerk/base/nsNetAddr.h
rename : netwerk/base/src/nsNetSegmentUtils.h => netwerk/base/nsNetSegmentUtils.h
rename : netwerk/base/src/nsNetUtil.cpp => netwerk/base/nsNetUtil.cpp
rename : netwerk/base/public/nsNetUtil.h => netwerk/base/nsNetUtil.h
rename : netwerk/base/src/nsPACMan.cpp => netwerk/base/nsPACMan.cpp
rename : netwerk/base/src/nsPACMan.h => netwerk/base/nsPACMan.h
rename : netwerk/base/public/nsPILoadGroupInternal.idl => netwerk/base/nsPILoadGroupInternal.idl
rename : netwerk/base/public/nsPISocketTransportService.idl => netwerk/base/nsPISocketTransportService.idl
rename : netwerk/base/src/nsPreloadedStream.cpp => netwerk/base/nsPreloadedStream.cpp
rename : netwerk/base/src/nsPreloadedStream.h => netwerk/base/nsPreloadedStream.h
rename : netwerk/base/src/nsProtocolProxyService.cpp => netwerk/base/nsProtocolProxyService.cpp
rename : netwerk/base/src/nsProtocolProxyService.h => netwerk/base/nsProtocolProxyService.h
rename : netwerk/base/src/nsProxyInfo.cpp => netwerk/base/nsProxyInfo.cpp
rename : netwerk/base/src/nsProxyInfo.h => netwerk/base/nsProxyInfo.h
rename : netwerk/base/public/nsReadLine.h => netwerk/base/nsReadLine.h
rename : netwerk/base/src/nsRequestObserverProxy.cpp => netwerk/base/nsRequestObserverProxy.cpp
rename : netwerk/base/src/nsRequestObserverProxy.h => netwerk/base/nsRequestObserverProxy.h
rename : netwerk/base/src/nsSerializationHelper.cpp => netwerk/base/nsSerializationHelper.cpp
rename : netwerk/base/src/nsSerializationHelper.h => netwerk/base/nsSerializationHelper.h
rename : netwerk/base/src/nsServerSocket.cpp => netwerk/base/nsServerSocket.cpp
rename : netwerk/base/src/nsServerSocket.h => netwerk/base/nsServerSocket.h
rename : netwerk/base/src/nsSimpleNestedURI.cpp => netwerk/base/nsSimpleNestedURI.cpp
rename : netwerk/base/src/nsSimpleNestedURI.h => netwerk/base/nsSimpleNestedURI.h
rename : netwerk/base/src/nsSimpleStreamListener.cpp => netwerk/base/nsSimpleStreamListener.cpp
rename : netwerk/base/src/nsSimpleStreamListener.h => netwerk/base/nsSimpleStreamListener.h
rename : netwerk/base/src/nsSimpleURI.cpp => netwerk/base/nsSimpleURI.cpp
rename : netwerk/base/src/nsSimpleURI.h => netwerk/base/nsSimpleURI.h
rename : netwerk/base/src/nsSocketTransport2.cpp => netwerk/base/nsSocketTransport2.cpp
rename : netwerk/base/src/nsSocketTransport2.h => netwerk/base/nsSocketTransport2.h
rename : netwerk/base/src/nsSocketTransportService2.cpp => netwerk/base/nsSocketTransportService2.cpp
rename : netwerk/base/src/nsSocketTransportService2.h => netwerk/base/nsSocketTransportService2.h
rename : netwerk/base/src/nsStandardURL.cpp => netwerk/base/nsStandardURL.cpp
rename : netwerk/base/src/nsStandardURL.h => netwerk/base/nsStandardURL.h
rename : netwerk/base/src/nsStreamListenerTee.cpp => netwerk/base/nsStreamListenerTee.cpp
rename : netwerk/base/src/nsStreamListenerTee.h => netwerk/base/nsStreamListenerTee.h
rename : netwerk/base/src/nsStreamListenerWrapper.cpp => netwerk/base/nsStreamListenerWrapper.cpp
rename : netwerk/base/public/nsStreamListenerWrapper.h => netwerk/base/nsStreamListenerWrapper.h
rename : netwerk/base/src/nsStreamLoader.cpp => netwerk/base/nsStreamLoader.cpp
rename : netwerk/base/src/nsStreamLoader.h => netwerk/base/nsStreamLoader.h
rename : netwerk/base/src/nsStreamTransportService.cpp => netwerk/base/nsStreamTransportService.cpp
rename : netwerk/base/src/nsStreamTransportService.h => netwerk/base/nsStreamTransportService.h
rename : netwerk/base/src/nsSyncStreamListener.cpp => netwerk/base/nsSyncStreamListener.cpp
rename : netwerk/base/src/nsSyncStreamListener.h => netwerk/base/nsSyncStreamListener.h
rename : netwerk/base/src/nsTemporaryFileInputStream.cpp => netwerk/base/nsTemporaryFileInputStream.cpp
rename : netwerk/base/src/nsTemporaryFileInputStream.h => netwerk/base/nsTemporaryFileInputStream.h
rename : netwerk/base/src/nsTransportUtils.cpp => netwerk/base/nsTransportUtils.cpp
rename : netwerk/base/src/nsTransportUtils.h => netwerk/base/nsTransportUtils.h
rename : netwerk/base/src/nsUDPSocket.cpp => netwerk/base/nsUDPSocket.cpp
rename : netwerk/base/src/nsUDPSocket.h => netwerk/base/nsUDPSocket.h
rename : netwerk/base/src/nsURIChecker.cpp => netwerk/base/nsURIChecker.cpp
rename : netwerk/base/src/nsURIChecker.h => netwerk/base/nsURIChecker.h
rename : netwerk/base/public/nsURIHashKey.h => netwerk/base/nsURIHashKey.h
rename : netwerk/base/src/nsURLHelper.cpp => netwerk/base/nsURLHelper.cpp
rename : netwerk/base/src/nsURLHelper.h => netwerk/base/nsURLHelper.h
rename : netwerk/base/src/nsURLHelperOSX.cpp => netwerk/base/nsURLHelperOSX.cpp
rename : netwerk/base/src/nsURLHelperUnix.cpp => netwerk/base/nsURLHelperUnix.cpp
rename : netwerk/base/src/nsURLHelperWin.cpp => netwerk/base/nsURLHelperWin.cpp
rename : netwerk/base/src/nsURLParsers.cpp => netwerk/base/nsURLParsers.cpp
rename : netwerk/base/src/nsURLParsers.h => netwerk/base/nsURLParsers.h
rename : netwerk/base/src/nsUnicharStreamLoader.cpp => netwerk/base/nsUnicharStreamLoader.cpp
rename : netwerk/base/src/nsUnicharStreamLoader.h => netwerk/base/nsUnicharStreamLoader.h
rename : netwerk/base/public/security-prefs.js => netwerk/base/security-prefs.js
extra : rebase_source : 1c3a3af5609aceeb11b12604aeda6f864fbcd5e0
2015-01-20 03:58:00 -05:00

927 lines
26 KiB
C++

/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:set ts=2 sw=2 sts=2 et cindent: */
/* 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/. */
#include "ProxyAutoConfig.h"
#include "nsICancelable.h"
#include "nsIDNSListener.h"
#include "nsIDNSRecord.h"
#include "nsIDNSService.h"
#include "nsThreadUtils.h"
#include "nsIConsoleService.h"
#include "nsJSUtils.h"
#include "jsfriendapi.h"
#include "prnetdb.h"
#include "nsITimer.h"
#include "mozilla/net/DNS.h"
#include "nsServiceManagerUtils.h"
#include "nsNetCID.h"
namespace mozilla {
namespace net {
// These are some global helper symbols the PAC format requires that we provide that
// are initialized as part of the global javascript context used for PAC evaluations.
// Additionally dnsResolve(host) and myIpAddress() are supplied in the same context
// but are implemented as c++ helpers. alert(msg) is similarly defined.
static const char *sPacUtils =
"function dnsDomainIs(host, domain) {\n"
" return (host.length >= domain.length &&\n"
" host.substring(host.length - domain.length) == domain);\n"
"}\n"
""
"function dnsDomainLevels(host) {\n"
" return host.split('.').length - 1;\n"
"}\n"
""
"function convert_addr(ipchars) {\n"
" var bytes = ipchars.split('.');\n"
" var result = ((bytes[0] & 0xff) << 24) |\n"
" ((bytes[1] & 0xff) << 16) |\n"
" ((bytes[2] & 0xff) << 8) |\n"
" (bytes[3] & 0xff);\n"
" return result;\n"
"}\n"
""
"function isInNet(ipaddr, pattern, maskstr) {\n"
" var test = /^(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})$/.exec(ipaddr);\n"
" if (test == null) {\n"
" ipaddr = dnsResolve(ipaddr);\n"
" if (ipaddr == null)\n"
" return false;\n"
" } else if (test[1] > 255 || test[2] > 255 || \n"
" test[3] > 255 || test[4] > 255) {\n"
" return false; // not an IP address\n"
" }\n"
" var host = convert_addr(ipaddr);\n"
" var pat = convert_addr(pattern);\n"
" var mask = convert_addr(maskstr);\n"
" return ((host & mask) == (pat & mask));\n"
" \n"
"}\n"
""
"function isPlainHostName(host) {\n"
" return (host.search('\\\\.') == -1);\n"
"}\n"
""
"function isResolvable(host) {\n"
" var ip = dnsResolve(host);\n"
" return (ip != null);\n"
"}\n"
""
"function localHostOrDomainIs(host, hostdom) {\n"
" return (host == hostdom) ||\n"
" (hostdom.lastIndexOf(host + '.', 0) == 0);\n"
"}\n"
""
"function shExpMatch(url, pattern) {\n"
" pattern = pattern.replace(/\\./g, '\\\\.');\n"
" pattern = pattern.replace(/\\*/g, '.*');\n"
" pattern = pattern.replace(/\\?/g, '.');\n"
" var newRe = new RegExp('^'+pattern+'$');\n"
" return newRe.test(url);\n"
"}\n"
""
"var wdays = {SUN: 0, MON: 1, TUE: 2, WED: 3, THU: 4, FRI: 5, SAT: 6};\n"
"var months = {JAN: 0, FEB: 1, MAR: 2, APR: 3, MAY: 4, JUN: 5, JUL: 6, AUG: 7, SEP: 8, OCT: 9, NOV: 10, DEC: 11};\n"
""
"function weekdayRange() {\n"
" function getDay(weekday) {\n"
" if (weekday in wdays) {\n"
" return wdays[weekday];\n"
" }\n"
" return -1;\n"
" }\n"
" var date = new Date();\n"
" var argc = arguments.length;\n"
" var wday;\n"
" if (argc < 1)\n"
" return false;\n"
" if (arguments[argc - 1] == 'GMT') {\n"
" argc--;\n"
" wday = date.getUTCDay();\n"
" } else {\n"
" wday = date.getDay();\n"
" }\n"
" var wd1 = getDay(arguments[0]);\n"
" var wd2 = (argc == 2) ? getDay(arguments[1]) : wd1;\n"
" return (wd1 == -1 || wd2 == -1) ? false\n"
" : (wd1 <= wday && wday <= wd2);\n"
"}\n"
""
"function dateRange() {\n"
" function getMonth(name) {\n"
" if (name in months) {\n"
" return months[name];\n"
" }\n"
" return -1;\n"
" }\n"
" var date = new Date();\n"
" var argc = arguments.length;\n"
" if (argc < 1) {\n"
" return false;\n"
" }\n"
" var isGMT = (arguments[argc - 1] == 'GMT');\n"
"\n"
" if (isGMT) {\n"
" argc--;\n"
" }\n"
" // function will work even without explict handling of this case\n"
" if (argc == 1) {\n"
" var tmp = parseInt(arguments[0]);\n"
" if (isNaN(tmp)) {\n"
" return ((isGMT ? date.getUTCMonth() : date.getMonth()) ==\n"
" getMonth(arguments[0]));\n"
" } else if (tmp < 32) {\n"
" return ((isGMT ? date.getUTCDate() : date.getDate()) == tmp);\n"
" } else { \n"
" return ((isGMT ? date.getUTCFullYear() : date.getFullYear()) ==\n"
" tmp);\n"
" }\n"
" }\n"
" var year = date.getFullYear();\n"
" var date1, date2;\n"
" date1 = new Date(year, 0, 1, 0, 0, 0);\n"
" date2 = new Date(year, 11, 31, 23, 59, 59);\n"
" var adjustMonth = false;\n"
" for (var i = 0; i < (argc >> 1); i++) {\n"
" var tmp = parseInt(arguments[i]);\n"
" if (isNaN(tmp)) {\n"
" var mon = getMonth(arguments[i]);\n"
" date1.setMonth(mon);\n"
" } else if (tmp < 32) {\n"
" adjustMonth = (argc <= 2);\n"
" date1.setDate(tmp);\n"
" } else {\n"
" date1.setFullYear(tmp);\n"
" }\n"
" }\n"
" for (var i = (argc >> 1); i < argc; i++) {\n"
" var tmp = parseInt(arguments[i]);\n"
" if (isNaN(tmp)) {\n"
" var mon = getMonth(arguments[i]);\n"
" date2.setMonth(mon);\n"
" } else if (tmp < 32) {\n"
" date2.setDate(tmp);\n"
" } else {\n"
" date2.setFullYear(tmp);\n"
" }\n"
" }\n"
" if (adjustMonth) {\n"
" date1.setMonth(date.getMonth());\n"
" date2.setMonth(date.getMonth());\n"
" }\n"
" if (isGMT) {\n"
" var tmp = date;\n"
" tmp.setFullYear(date.getUTCFullYear());\n"
" tmp.setMonth(date.getUTCMonth());\n"
" tmp.setDate(date.getUTCDate());\n"
" tmp.setHours(date.getUTCHours());\n"
" tmp.setMinutes(date.getUTCMinutes());\n"
" tmp.setSeconds(date.getUTCSeconds());\n"
" date = tmp;\n"
" }\n"
" return ((date1 <= date) && (date <= date2));\n"
"}\n"
""
"function timeRange() {\n"
" var argc = arguments.length;\n"
" var date = new Date();\n"
" var isGMT= false;\n"
""
" if (argc < 1) {\n"
" return false;\n"
" }\n"
" if (arguments[argc - 1] == 'GMT') {\n"
" isGMT = true;\n"
" argc--;\n"
" }\n"
"\n"
" var hour = isGMT ? date.getUTCHours() : date.getHours();\n"
" var date1, date2;\n"
" date1 = new Date();\n"
" date2 = new Date();\n"
"\n"
" if (argc == 1) {\n"
" return (hour == arguments[0]);\n"
" } else if (argc == 2) {\n"
" return ((arguments[0] <= hour) && (hour <= arguments[1]));\n"
" } else {\n"
" switch (argc) {\n"
" case 6:\n"
" date1.setSeconds(arguments[2]);\n"
" date2.setSeconds(arguments[5]);\n"
" case 4:\n"
" var middle = argc >> 1;\n"
" date1.setHours(arguments[0]);\n"
" date1.setMinutes(arguments[1]);\n"
" date2.setHours(arguments[middle]);\n"
" date2.setMinutes(arguments[middle + 1]);\n"
" if (middle == 2) {\n"
" date2.setSeconds(59);\n"
" }\n"
" break;\n"
" default:\n"
" throw 'timeRange: bad number of arguments'\n"
" }\n"
" }\n"
"\n"
" if (isGMT) {\n"
" date.setFullYear(date.getUTCFullYear());\n"
" date.setMonth(date.getUTCMonth());\n"
" date.setDate(date.getUTCDate());\n"
" date.setHours(date.getUTCHours());\n"
" date.setMinutes(date.getUTCMinutes());\n"
" date.setSeconds(date.getUTCSeconds());\n"
" }\n"
" return ((date1 <= date) && (date <= date2));\n"
"}\n"
"";
// sRunning is defined for the helper functions only while the
// Javascript engine is running and the PAC object cannot be deleted
// or reset.
static uint32_t sRunningIndex = 0xdeadbeef;
static ProxyAutoConfig *GetRunning()
{
MOZ_ASSERT(sRunningIndex != 0xdeadbeef);
return static_cast<ProxyAutoConfig *>(PR_GetThreadPrivate(sRunningIndex));
}
static void SetRunning(ProxyAutoConfig *arg)
{
MOZ_ASSERT(sRunningIndex != 0xdeadbeef);
PR_SetThreadPrivate(sRunningIndex, arg);
}
// The PACResolver is used for dnsResolve()
class PACResolver MOZ_FINAL : public nsIDNSListener
, public nsITimerCallback
{
public:
NS_DECL_THREADSAFE_ISUPPORTS
PACResolver()
: mStatus(NS_ERROR_FAILURE)
{
}
// nsIDNSListener
NS_IMETHODIMP OnLookupComplete(nsICancelable *request,
nsIDNSRecord *record,
nsresult status) MOZ_OVERRIDE
{
if (mTimer) {
mTimer->Cancel();
mTimer = nullptr;
}
mRequest = nullptr;
mStatus = status;
mResponse = record;
return NS_OK;
}
// nsITimerCallback
NS_IMETHODIMP Notify(nsITimer *timer) MOZ_OVERRIDE
{
if (mRequest)
mRequest->Cancel(NS_ERROR_NET_TIMEOUT);
mTimer = nullptr;
return NS_OK;
}
nsresult mStatus;
nsCOMPtr<nsICancelable> mRequest;
nsCOMPtr<nsIDNSRecord> mResponse;
nsCOMPtr<nsITimer> mTimer;
private:
~PACResolver() {}
};
NS_IMPL_ISUPPORTS(PACResolver, nsIDNSListener, nsITimerCallback)
static
void PACLogToConsole(nsString &aMessage)
{
nsCOMPtr<nsIConsoleService> consoleService =
do_GetService(NS_CONSOLESERVICE_CONTRACTID);
if (!consoleService)
return;
consoleService->LogStringMessage(aMessage.get());
}
// Javascript errors are logged to the main error console
static void
PACErrorReporter(JSContext *cx, const char *message, JSErrorReport *report)
{
nsString formattedMessage(NS_LITERAL_STRING("PAC Execution Error: "));
formattedMessage += report->ucmessage;
formattedMessage += NS_LITERAL_STRING(" [");
formattedMessage += report->uclinebuf;
formattedMessage += NS_LITERAL_STRING("]");
PACLogToConsole(formattedMessage);
}
// timeout of 0 means the normal necko timeout strategy, otherwise the dns request
// will be canceled after aTimeout milliseconds
static
bool PACResolve(const nsCString &aHostName, NetAddr *aNetAddr,
unsigned int aTimeout)
{
if (!GetRunning()) {
NS_WARNING("PACResolve without a running ProxyAutoConfig object");
return false;
}
return GetRunning()->ResolveAddress(aHostName, aNetAddr, aTimeout);
}
ProxyAutoConfig::ProxyAutoConfig()
: mJSRuntime(nullptr)
, mJSNeedsSetup(false)
, mShutdown(false)
{
MOZ_COUNT_CTOR(ProxyAutoConfig);
}
bool
ProxyAutoConfig::ResolveAddress(const nsCString &aHostName,
NetAddr *aNetAddr,
unsigned int aTimeout)
{
nsCOMPtr<nsIDNSService> dns = do_GetService(NS_DNSSERVICE_CONTRACTID);
if (!dns)
return false;
nsRefPtr<PACResolver> helper = new PACResolver();
if (NS_FAILED(dns->AsyncResolve(aHostName,
nsIDNSService::RESOLVE_PRIORITY_MEDIUM,
helper,
NS_GetCurrentThread(),
getter_AddRefs(helper->mRequest))))
return false;
if (aTimeout && helper->mRequest) {
if (!mTimer)
mTimer = do_CreateInstance(NS_TIMER_CONTRACTID);
if (mTimer) {
mTimer->InitWithCallback(helper, aTimeout, nsITimer::TYPE_ONE_SHOT);
helper->mTimer = mTimer;
}
}
// Spin the event loop of the pac thread until lookup is complete.
// nsPACman is responsible for keeping a queue and only allowing
// one PAC execution at a time even when it is called re-entrantly.
while (helper->mRequest)
NS_ProcessNextEvent(NS_GetCurrentThread());
if (NS_FAILED(helper->mStatus) ||
NS_FAILED(helper->mResponse->GetNextAddr(0, aNetAddr)))
return false;
return true;
}
static
bool PACResolveToString(const nsCString &aHostName,
nsCString &aDottedDecimal,
unsigned int aTimeout)
{
NetAddr netAddr;
if (!PACResolve(aHostName, &netAddr, aTimeout))
return false;
char dottedDecimal[128];
if (!NetAddrToString(&netAddr, dottedDecimal, sizeof(dottedDecimal)))
return false;
aDottedDecimal.Assign(dottedDecimal);
return true;
}
// dnsResolve(host) javascript implementation
static
bool PACDnsResolve(JSContext *cx, unsigned int argc, JS::Value *vp)
{
JS::CallArgs args = CallArgsFromVp(argc, vp);
if (NS_IsMainThread()) {
NS_WARNING("DNS Resolution From PAC on Main Thread. How did that happen?");
return false;
}
JS::Rooted<JSString*> arg1(cx);
if (!JS_ConvertArguments(cx, args, "S", arg1.address()))
return false;
nsAutoJSString hostName;
nsAutoCString dottedDecimal;
if (!hostName.init(cx, arg1))
return false;
if (PACResolveToString(NS_ConvertUTF16toUTF8(hostName), dottedDecimal, 0)) {
JSString *dottedDecimalString = JS_NewStringCopyZ(cx, dottedDecimal.get());
if (!dottedDecimalString) {
return false;
}
args.rval().setString(dottedDecimalString);
}
else {
args.rval().setNull();
}
return true;
}
// myIpAddress() javascript implementation
static
bool PACMyIpAddress(JSContext *cx, unsigned int argc, JS::Value *vp)
{
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
if (NS_IsMainThread()) {
NS_WARNING("DNS Resolution From PAC on Main Thread. How did that happen?");
return false;
}
if (!GetRunning()) {
NS_WARNING("PAC myIPAddress without a running ProxyAutoConfig object");
return false;
}
return GetRunning()->MyIPAddress(args);
}
// proxyAlert(msg) javascript implementation
static
bool PACProxyAlert(JSContext *cx, unsigned int argc, JS::Value *vp)
{
JS::CallArgs args = CallArgsFromVp(argc, vp);
JS::Rooted<JSString*> arg1(cx);
if (!JS_ConvertArguments(cx, args, "S", arg1.address()))
return false;
nsAutoJSString message;
if (!message.init(cx, arg1))
return false;
nsAutoString alertMessage;
alertMessage.SetCapacity(32 + message.Length());
alertMessage += NS_LITERAL_STRING("PAC-alert: ");
alertMessage += message;
PACLogToConsole(alertMessage);
args.rval().setUndefined(); /* return undefined */
return true;
}
static const JSFunctionSpec PACGlobalFunctions[] = {
JS_FS("dnsResolve", PACDnsResolve, 1, 0),
// a global "var pacUseMultihomedDNS = true;" will change behavior
// of myIpAddress to actively use DNS
JS_FS("myIpAddress", PACMyIpAddress, 0, 0),
JS_FS("alert", PACProxyAlert, 1, 0),
JS_FS_END
};
// JSRuntimeWrapper is a c++ object that manages the runtime and context
// for the JS engine used on the PAC thread. It is initialized and destroyed
// on the PAC thread.
class JSRuntimeWrapper
{
public:
static JSRuntimeWrapper *Create()
{
JSRuntime *runtime = JS_NewRuntime(sRuntimeHeapSize);
if (NS_WARN_IF(!runtime))
return nullptr;
JSRuntimeWrapper *entry = new JSRuntimeWrapper(runtime);
if (NS_FAILED(entry->Init())) {
delete entry;
return nullptr;
}
return entry;
}
JSContext *Context() const
{
return mContext;
}
JSObject *Global() const
{
return mGlobal;
}
~JSRuntimeWrapper()
{
mGlobal = nullptr;
MOZ_COUNT_DTOR(JSRuntimeWrapper);
if (mContext) {
JS_DestroyContext(mContext);
}
if (mRuntime) {
JS_DestroyRuntime(mRuntime);
}
}
void SetOK()
{
mOK = true;
}
bool IsOK()
{
return mOK;
}
private:
static const unsigned sRuntimeHeapSize = 2 << 20;
JSRuntime *mRuntime;
JSContext *mContext;
JS::PersistentRooted<JSObject*> mGlobal;
bool mOK;
static const JSClass sGlobalClass;
explicit JSRuntimeWrapper(JSRuntime* rt)
: mRuntime(rt), mContext(nullptr), mGlobal(rt, nullptr), mOK(false)
{
MOZ_COUNT_CTOR(JSRuntimeWrapper);
}
nsresult Init()
{
/*
* Not setting this will cause JS_CHECK_RECURSION to report false
* positives
*/
JS_SetNativeStackQuota(mRuntime, 128 * sizeof(size_t) * 1024);
JS_SetErrorReporter(mRuntime, PACErrorReporter);
mContext = JS_NewContext(mRuntime, 0);
NS_ENSURE_TRUE(mContext, NS_ERROR_OUT_OF_MEMORY);
JSAutoRequest ar(mContext);
JS::CompartmentOptions options;
options.setZone(JS::SystemZone)
.setVersion(JSVERSION_LATEST);
mGlobal = JS_NewGlobalObject(mContext, &sGlobalClass, nullptr,
JS::DontFireOnNewGlobalHook, options);
NS_ENSURE_TRUE(mGlobal, NS_ERROR_OUT_OF_MEMORY);
JS::Rooted<JSObject*> global(mContext, mGlobal);
JSAutoCompartment ac(mContext, global);
JS_InitStandardClasses(mContext, global);
if (!JS_DefineFunctions(mContext, global, PACGlobalFunctions))
return NS_ERROR_FAILURE;
JS_FireOnNewGlobalObject(mContext, global);
return NS_OK;
}
};
const JSClass JSRuntimeWrapper::sGlobalClass = {
"PACResolutionThreadGlobal",
JSCLASS_GLOBAL_FLAGS,
nullptr, nullptr, nullptr, nullptr,
nullptr, nullptr, nullptr,
nullptr, nullptr, nullptr, nullptr,
JS_GlobalObjectTraceHook
};
void
ProxyAutoConfig::SetThreadLocalIndex(uint32_t index)
{
sRunningIndex = index;
}
nsresult
ProxyAutoConfig::Init(const nsCString &aPACURI,
const nsCString &aPACScript)
{
mPACURI = aPACURI;
mPACScript = sPacUtils;
mPACScript.Append(aPACScript);
if (!GetRunning())
return SetupJS();
mJSNeedsSetup = true;
return NS_OK;
}
nsresult
ProxyAutoConfig::SetupJS()
{
mJSNeedsSetup = false;
NS_ABORT_IF_FALSE(!GetRunning(), "JIT is running");
delete mJSRuntime;
mJSRuntime = nullptr;
if (mPACScript.IsEmpty())
return NS_ERROR_FAILURE;
mJSRuntime = JSRuntimeWrapper::Create();
if (!mJSRuntime)
return NS_ERROR_FAILURE;
JSContext* cx = mJSRuntime->Context();
JSAutoRequest ar(cx);
JSAutoCompartment ac(cx, mJSRuntime->Global());
// check if this is a data: uri so that we don't spam the js console with
// huge meaningless strings. this is not on the main thread, so it can't
// use nsIRUI scheme methods
bool isDataURI = nsDependentCSubstring(mPACURI, 0, 5).LowerCaseEqualsASCII("data:", 5);
SetRunning(this);
JS::Rooted<JSObject*> global(cx, mJSRuntime->Global());
JS::CompileOptions options(cx);
options.setFileAndLine(mPACURI.get(), 1);
JS::Rooted<JSScript*> script(cx);
if (!JS_CompileScript(cx, global, mPACScript.get(),
mPACScript.Length(), options, &script) ||
!JS_ExecuteScript(cx, global, script))
{
nsString alertMessage(NS_LITERAL_STRING("PAC file failed to install from "));
if (isDataURI) {
alertMessage += NS_LITERAL_STRING("data: URI");
}
else {
alertMessage += NS_ConvertUTF8toUTF16(mPACURI);
}
PACLogToConsole(alertMessage);
SetRunning(nullptr);
return NS_ERROR_FAILURE;
}
SetRunning(nullptr);
mJSRuntime->SetOK();
nsString alertMessage(NS_LITERAL_STRING("PAC file installed from "));
if (isDataURI) {
alertMessage += NS_LITERAL_STRING("data: URI");
}
else {
alertMessage += NS_ConvertUTF8toUTF16(mPACURI);
}
PACLogToConsole(alertMessage);
// we don't need these now
mPACScript.Truncate();
mPACURI.Truncate();
return NS_OK;
}
nsresult
ProxyAutoConfig::GetProxyForURI(const nsCString &aTestURI,
const nsCString &aTestHost,
nsACString &result)
{
if (mJSNeedsSetup)
SetupJS();
if (!mJSRuntime || !mJSRuntime->IsOK())
return NS_ERROR_NOT_AVAILABLE;
JSContext *cx = mJSRuntime->Context();
JSAutoRequest ar(cx);
JSAutoCompartment ac(cx, mJSRuntime->Global());
// the sRunning flag keeps a new PAC file from being installed
// while the event loop is spinning on a DNS function. Don't early return.
SetRunning(this);
mRunningHost = aTestHost;
nsresult rv = NS_ERROR_FAILURE;
JS::RootedString uriString(cx, JS_NewStringCopyZ(cx, aTestURI.get()));
JS::RootedString hostString(cx, JS_NewStringCopyZ(cx, aTestHost.get()));
if (uriString && hostString) {
JS::AutoValueArray<2> args(cx);
args[0].setString(uriString);
args[1].setString(hostString);
JS::Rooted<JS::Value> rval(cx);
JS::Rooted<JSObject*> global(cx, mJSRuntime->Global());
bool ok = JS_CallFunctionName(cx, global, "FindProxyForURL", args, &rval);
if (ok && rval.isString()) {
nsAutoJSString pacString;
if (pacString.init(cx, rval.toString())) {
CopyUTF16toUTF8(pacString, result);
rv = NS_OK;
}
}
}
mRunningHost.Truncate();
SetRunning(nullptr);
return rv;
}
void
ProxyAutoConfig::GC()
{
if (!mJSRuntime || !mJSRuntime->IsOK())
return;
JSAutoCompartment ac(mJSRuntime->Context(), mJSRuntime->Global());
JS_MaybeGC(mJSRuntime->Context());
}
ProxyAutoConfig::~ProxyAutoConfig()
{
MOZ_COUNT_DTOR(ProxyAutoConfig);
NS_ASSERTION(!mJSRuntime,
"~ProxyAutoConfig leaking JS runtime that "
"should have been deleted on pac thread");
}
void
ProxyAutoConfig::Shutdown()
{
NS_ABORT_IF_FALSE(!NS_IsMainThread(), "wrong thread for shutdown");
if (GetRunning() || mShutdown)
return;
mShutdown = true;
delete mJSRuntime;
mJSRuntime = nullptr;
}
bool
ProxyAutoConfig::SrcAddress(const NetAddr *remoteAddress, nsCString &localAddress)
{
PRFileDesc *fd;
fd = PR_OpenUDPSocket(remoteAddress->raw.family);
if (!fd)
return false;
PRNetAddr prRemoteAddress;
NetAddrToPRNetAddr(remoteAddress, &prRemoteAddress);
if (PR_Connect(fd, &prRemoteAddress, 0) != PR_SUCCESS) {
PR_Close(fd);
return false;
}
PRNetAddr localName;
if (PR_GetSockName(fd, &localName) != PR_SUCCESS) {
PR_Close(fd);
return false;
}
PR_Close(fd);
char dottedDecimal[128];
if (PR_NetAddrToString(&localName, dottedDecimal, sizeof(dottedDecimal)) != PR_SUCCESS)
return false;
localAddress.Assign(dottedDecimal);
return true;
}
// hostName is run through a dns lookup and then a udp socket is connected
// to the result. If that all works, the local IP address of the socket is
// returned to the javascript caller and |*aResult| is set to true. Otherwise
// |*aResult| is set to false.
bool
ProxyAutoConfig::MyIPAddressTryHost(const nsCString &hostName,
unsigned int timeout,
const JS::CallArgs &aArgs,
bool* aResult)
{
*aResult = false;
NetAddr remoteAddress;
nsAutoCString localDottedDecimal;
JSContext *cx = mJSRuntime->Context();
if (PACResolve(hostName, &remoteAddress, timeout) &&
SrcAddress(&remoteAddress, localDottedDecimal)) {
JSString *dottedDecimalString =
JS_NewStringCopyZ(cx, localDottedDecimal.get());
if (!dottedDecimalString) {
return false;
}
*aResult = true;
aArgs.rval().setString(dottedDecimalString);
}
return true;
}
bool
ProxyAutoConfig::MyIPAddress(const JS::CallArgs &aArgs)
{
nsAutoCString remoteDottedDecimal;
nsAutoCString localDottedDecimal;
JSContext *cx = mJSRuntime->Context();
JS::RootedValue v(cx);
JS::Rooted<JSObject*> global(cx, mJSRuntime->Global());
bool useMultihomedDNS =
JS_GetProperty(cx, global, "pacUseMultihomedDNS", &v) &&
!v.isUndefined() && ToBoolean(v);
// first, lookup the local address of a socket connected
// to the host of uri being resolved by the pac file. This is
// v6 safe.. but is the last step like that
bool rvalAssigned = false;
if (useMultihomedDNS) {
if (!MyIPAddressTryHost(mRunningHost, kTimeout, aArgs, &rvalAssigned) ||
rvalAssigned) {
return rvalAssigned;
}
} else {
// we can still do the fancy multi homing thing if the host is a literal
PRNetAddr tempAddr;
memset(&tempAddr, 0, sizeof(PRNetAddr));
if ((PR_StringToNetAddr(mRunningHost.get(), &tempAddr) == PR_SUCCESS) &&
(!MyIPAddressTryHost(mRunningHost, kTimeout, aArgs, &rvalAssigned) ||
rvalAssigned)) {
return rvalAssigned;
}
}
// next, look for a route to a public internet address that doesn't need DNS.
// This is the google anycast dns address, but it doesn't matter if it
// remains operable (as we don't contact it) as long as the address stays
// in commonly routed IP address space.
remoteDottedDecimal.AssignLiteral("8.8.8.8");
if (!MyIPAddressTryHost(remoteDottedDecimal, 0, aArgs, &rvalAssigned) ||
rvalAssigned) {
return rvalAssigned;
}
// finally, use the old algorithm based on the local hostname
nsAutoCString hostName;
nsCOMPtr<nsIDNSService> dns = do_GetService(NS_DNSSERVICE_CONTRACTID);
// without multihomedDNS use such a short timeout that we are basically
// just looking at the cache for raw dotted decimals
uint32_t timeout = useMultihomedDNS ? kTimeout : 1;
if (dns && NS_SUCCEEDED(dns->GetMyHostName(hostName)) &&
PACResolveToString(hostName, localDottedDecimal, timeout)) {
JSString *dottedDecimalString =
JS_NewStringCopyZ(cx, localDottedDecimal.get());
if (!dottedDecimalString) {
return false;
}
aArgs.rval().setString(dottedDecimalString);
return true;
}
// next try a couple RFC 1918 variants.. maybe there is a
// local route
remoteDottedDecimal.AssignLiteral("192.168.0.1");
if (!MyIPAddressTryHost(remoteDottedDecimal, 0, aArgs, &rvalAssigned) ||
rvalAssigned) {
return rvalAssigned;
}
// more RFC 1918
remoteDottedDecimal.AssignLiteral("10.0.0.1");
if (!MyIPAddressTryHost(remoteDottedDecimal, 0, aArgs, &rvalAssigned) ||
rvalAssigned) {
return rvalAssigned;
}
// who knows? let's fallback to localhost
localDottedDecimal.AssignLiteral("127.0.0.1");
JSString *dottedDecimalString =
JS_NewStringCopyZ(cx, localDottedDecimal.get());
if (!dottedDecimalString) {
return false;
}
aArgs.rval().setString(dottedDecimalString);
return true;
}
} // namespace mozilla
} // namespace mozilla::net