Used to store the Ipaddress used instread of CallContext as CallContext data has different lifetime on mono compared to .NET.
コード例 #1
0
        /// <summary>
        /// If the connected client isn't localhost throws SecurityException
        /// </summary>
        internal void EnsureClientIsLocalHost()
        {
            IPAddress clientIpAddress = CallContextExtensions.GetIpAddress();

            if (clientIpAddress == null)
            {
                throw new SecurityException("This method can only be executed on the server. ClientIPAddress not set.");
            }

            if (IsLocalHost(clientIpAddress.ToString()))
            {
                return;
            }

            throw new SecurityException(String.Format("This method can only be executed on the server. ClientIPAddress is {0}", clientIpAddress));
        }
コード例 #2
0
        private static void SetClientIpAddressDataHelper(ITransportHeaders headers)
        {
            var ip = headers[CommonTransportKeys.IPAddress] as IPAddress;

            CallContextExtensions.SetIpAddress(ip);
        }