} // HttpServerChannel private void SetupMachineName() { if (_forcedMachineName != null) { // an explicitly configured machine name was used _machineName = CoreChannel.DecodeMachineName(_forcedMachineName); } else { if (!_bUseIpAddress) { _machineName = CoreChannel.GetMachineName(); } else { if (_bindToAddr == IPAddress.Any) { _machineName = CoreChannel.GetMachineIp(); } else { _machineName = _bindToAddr.ToString(); } } } } // SetupMachineName
private void SetupMachineName() { if (this._forcedMachineName != null) { this._machineName = CoreChannel.DecodeMachineName(this._forcedMachineName); } else if (!this._bUseIpAddress) { this._machineName = CoreChannel.GetMachineName(); } else { if ((this._bindToAddr == IPAddress.Any) || (this._bindToAddr == IPAddress.IPv6Any)) { this._machineName = CoreChannel.GetMachineIp(); } else { this._machineName = this._bindToAddr.ToString(); } if (this._bindToAddr.AddressFamily == AddressFamily.InterNetworkV6) { this._machineName = "[" + this._machineName + "]"; } } }
private void SetupMachineName() { if (_forcedMachineName != null) { // an explicitly configured machine name was used _machineName = CoreChannel.DecodeMachineName(_forcedMachineName); } else { if (!_bUseIpAddress) { _machineName = CoreChannel.GetMachineName(); } else { if (_bindToAddr == IPAddress.Any || _bindToAddr == IPAddress.IPv6Any) { _machineName = CoreChannel.GetMachineIp(); } else { _machineName = _bindToAddr.ToString(); } // Add [] around the ipadress for IPv6 if (_bindToAddr.AddressFamily == AddressFamily.InterNetworkV6) { _machineName = "[" + _machineName + "]"; } } } } // SetupMachineName
private void UpdateProxy() { if (((this._proxyName != null) && (this._proxyName.Length > 0)) && (this._proxyPort > 0)) { WebProxy proxy = new WebProxy(this._proxyName, this._proxyPort) { BypassProxyOnLocal = true }; proxy.BypassList = new string[] { CoreChannel.GetMachineIp() }; this._proxyObject = proxy; } else { this._proxyObject = new WebProxy(); } }
} // Keys // // end of Support for properties // // // Helper functions for processing settings and properties // // Called to recreate proxy object whenever the proxy name or port is changed. private void UpdateProxy() { if ((_proxyName != null) && (_proxyName.Length > 0) && (_proxyPort > 0)) { WebProxy proxy = new WebProxy(_proxyName, _proxyPort); // disable proxy use when the host is local. i.e. without periods proxy.BypassProxyOnLocal = true; // setup bypasslist to include local ip address String[] bypassList = new String[] { CoreChannel.GetMachineIp() }; proxy.BypassList = bypassList; _proxyObject = proxy; } else { _proxyObject = new WebProxy(); } } // UpdateProxy
// // Internal // // Transform the ASP+ Request and Response Structures in // Channel Structures: // ** Request.ServerVariables // ** Request.InputStream // ** Response.Headers // // This is needed to reduce the between dependency COR Channels // and ASP+ // private void InternalProcessRequest(HttpContext context) { try { HttpRequest httpRequest = context.Request; // check if have previously loaded configuration if (!bLoadedConfiguration) { // locking a random static variable, so we can lock the class lock (HttpRemotingHandler.ApplicationConfigurationFile) { if (!bLoadedConfiguration) { // Initialize IIS information IisHelper.Initialize(); // set application name if (RemotingConfiguration.ApplicationName == null) { RemotingConfiguration.ApplicationName = httpRequest.ApplicationPath; } String filename = String.Concat(httpRequest.PhysicalApplicationPath, ApplicationConfigurationFile); if (File.Exists(filename)) { try { RemotingConfiguration.Configure(filename, false /*enableSecurity*/); } catch (Exception e) { s_fatalException = e; WriteException(context, e); return; } } try { // do a search for a registered channel that wants to listen IChannelReceiverHook httpChannel = null; IChannel[] channels = ChannelServices.RegisteredChannels; foreach (IChannel channel in channels) { IChannelReceiverHook hook = channel as IChannelReceiverHook; if (hook != null) { if (String.Compare(hook.ChannelScheme, "http", StringComparison.OrdinalIgnoreCase) == 0) { if (hook.WantsToListen) { httpChannel = hook; break; } } } } if (httpChannel == null) { // No http channel that was listening found. // Create a new channel. HttpChannel newHttpChannel = new HttpChannel(); ChannelServices.RegisterChannel(newHttpChannel, false /*enableSecurity*/); httpChannel = newHttpChannel; } String scheme = null; if (IisHelper.IsSslRequired) { scheme = "https"; } else { scheme = "http"; } String hookChannelUri = scheme + "://" + CoreChannel.GetMachineIp(); int port = context.Request.Url.Port; String restOfUri = ":" + port + "/" + RemotingConfiguration.ApplicationName; hookChannelUri += restOfUri; // add hook uri for this channel httpChannel.AddHookChannelUri(hookChannelUri); // If it uses ChannelDataStore, re-retrieve updated url in case it was updated. ChannelDataStore cds = ((IChannelReceiver)httpChannel).ChannelData as ChannelDataStore; if (cds != null) { hookChannelUri = cds.ChannelUris[0]; } IisHelper.ApplicationUrl = hookChannelUri; // This is a hack to refresh the channel data. // In V-Next, we will add a ChannelServices.RefreshChannelData() api. ChannelServices.UnregisterChannel(null); s_transportSink = new HttpHandlerTransportSink(httpChannel.ChannelSinkChain); } catch (Exception e) { s_fatalException = e; WriteException(context, e); return; } bLoadedConfiguration = true; } } } if (s_fatalException == null) { if (!CanServiceRequest(context)) { WriteException(context, new RemotingException(CoreChannel.GetResourceString("Remoting_ChnlSink_UriNotPublished"))); } else { s_transportSink.HandleRequest(context); } } else { WriteException(context, s_fatalException); } } catch (Exception e) { WriteException(context, e); } } // InternalProcessRequest
public void AddHookChannelUri(string channelUri) { if (this._channelData.ChannelUris != null) { throw new RemotingException(CoreChannel.GetResourceString("Remoting_Http_LimitListenerOfOne")); } if (this._forcedMachineName != null) { channelUri = HttpChannelHelper.ReplaceMachineNameWithThisString(channelUri, this._forcedMachineName); } else if (this._bUseIpAddress) { channelUri = HttpChannelHelper.ReplaceMachineNameWithThisString(channelUri, CoreChannel.GetMachineIp()); } this._channelData.ChannelUris = new string[] { channelUri }; this._wantsToListen = false; this._bHooked = true; }
/// <include file='doc\HttpServerChannel.uex' path='docs/doc[@for="HttpServerChannel.AddHookChannelUri"]/*' /> public void AddHookChannelUri(String channelUri) { if (_channelData.ChannelUris != null) { throw new RemotingException( CoreChannel.GetResourceString("Remoting_Http_LimitListenerOfOne")); } else { // replace machine name with explicitly configured // machine name or ip address if necessary if (_forcedMachineName != null) { channelUri = HttpChannelHelper.ReplaceMachineNameWithThisString(channelUri, _forcedMachineName); } else if (_bUseIpAddress) { channelUri = HttpChannelHelper.ReplaceMachineNameWithThisString(channelUri, CoreChannel.GetMachineIp()); } _channelData.ChannelUris = new String[] { channelUri }; _wantsToListen = false; _bHooked = true; } } // AddHookChannelUri
private void InternalProcessRequest(HttpContext context) { try { HttpRequest request = context.Request; if (!bLoadedConfiguration) { lock (ApplicationConfigurationFile) { if (!bLoadedConfiguration) { IisHelper.Initialize(); if (RemotingConfiguration.ApplicationName == null) { RemotingConfiguration.ApplicationName = request.ApplicationPath; } string path = request.PhysicalApplicationPath + ApplicationConfigurationFile; if (File.Exists(path)) { try { RemotingConfiguration.Configure(path, false); } catch (Exception exception) { s_fatalException = exception; this.WriteException(context, exception); return; } } try { IChannelReceiverHook hook = null; foreach (IChannel channel in ChannelServices.RegisteredChannels) { IChannelReceiverHook hook2 = channel as IChannelReceiverHook; if (((hook2 != null) && (string.Compare(hook2.ChannelScheme, "http", StringComparison.OrdinalIgnoreCase) == 0)) && hook2.WantsToListen) { hook = hook2; break; } } if (hook == null) { HttpChannel chnl = new HttpChannel(); ChannelServices.RegisterChannel(chnl, false); hook = chnl; } string str2 = null; if (IisHelper.IsSslRequired) { str2 = "https"; } else { str2 = "http"; } string channelUri = str2 + "://" + CoreChannel.GetMachineIp(); int port = context.Request.Url.Port; string str4 = string.Concat(new object[] { ":", port, "/", RemotingConfiguration.ApplicationName }); channelUri = channelUri + str4; hook.AddHookChannelUri(channelUri); ChannelDataStore channelData = ((IChannelReceiver)hook).ChannelData as ChannelDataStore; if (channelData != null) { channelUri = channelData.ChannelUris[0]; } IisHelper.ApplicationUrl = channelUri; ChannelServices.UnregisterChannel(null); s_transportSink = new HttpHandlerTransportSink(hook.ChannelSinkChain); } catch (Exception exception2) { s_fatalException = exception2; this.WriteException(context, exception2); return; } bLoadedConfiguration = true; } } } if (s_fatalException == null) { if (!this.CanServiceRequest(context)) { this.WriteException(context, new RemotingException(CoreChannel.GetResourceString("Remoting_ChnlSink_UriNotPublished"))); } else { s_transportSink.HandleRequest(context); } } else { this.WriteException(context, s_fatalException); } } catch (Exception exception3) { this.WriteException(context, exception3); } }