public void IpRejectsNonIpv4Address()
        {
            var context = new LocationContext(new Dictionary <string, string>());

            context.Ip = "2401:4893:f0:5c:2452:4474:03d2:9375";
            Assert.Null(context.Ip);
        }
        public void IpCanBeChangedByUserToSpecifyACustomValue()
        {
            var context = new LocationContext(new Dictionary <string, string>());

            context.Ip = "192.168.1.1";
            Assert.Equal("192.168.1.1", context.Ip);
        }
 private void UpdateClientIp(LocationContext location, IOperationContext operation)
 {
     if ( operation.HasIncomingMessageProperty(RemoteEndpointMessageProperty.Name) )
     {
         var property = (RemoteEndpointMessageProperty)
             operation.GetIncomingMessageProperty(RemoteEndpointMessageProperty.Name);
         location.Ip = property.Address;
         WcfEventSource.Log.LocationIdSet(location.Ip);
     }
 }
 public void IpRejectsNonIpv4Address()
 {
     var context = new LocationContext(new Dictionary<string, string>());
     context.Ip = "2401:4893:f0:5c:2452:4474:03d2:9375";
     Assert.Null(context.Ip);
 }
 public void IpCanBeChangedByUserToSpecifyACustomValue()
 {
     var context = new LocationContext(new Dictionary<string, string>());
     context.Ip = "192.168.1.1";
     Assert.Equal("192.168.1.1", context.Ip);
 }
 public void IpIsNullByDefaultToAvoidSendingItToEndpointUnnecessarily()
 {
     var context = new LocationContext(new Dictionary<string, string>());
     Assert.Null(context.Ip);
 }
        public void IpIsNullByDefaultToAvoidSendingItToEndpointUnnecessarily()
        {
            var context = new LocationContext(new Dictionary <string, string>());

            Assert.Null(context.Ip);
        }
        private void UpdateRequestTelemetry(HttpContext platformContext, LocationContext location)
        {
            string resultIp = null;
            foreach (var clientIpHeaderName in this.HeaderNames)
            {
                var clientIpsFromHeader = platformContext.Request.UnvalidatedGetHeader(clientIpHeaderName);

                if (!string.IsNullOrWhiteSpace(clientIpsFromHeader))
                {
                    WebEventSource.Log.WebLocationIdHeaderFound(clientIpHeaderName);

                    string ip = this.GetIpFromHeader(clientIpsFromHeader);
                    ip = CutPort(ip);
                    if (IsCorrectIpAddress(ip))
                    {
                        resultIp = ip;
                        break;
                    }
                }
            }

            location.Ip = !string.IsNullOrEmpty(resultIp) ? resultIp : platformContext.Request.UserHostAddress;

            WebEventSource.Log.WebLocationIdSet(location.Ip);
        }
 public void IpCanBeChangedByUserToSpecifyACustomValue()
 {
     var context = new LocationContext();
     context.Ip = "192.168.1.1";
     Assert.AreEqual("192.168.1.1", context.Ip);
 }
 public void IpIsNullByDefaultToAvoidSendingItToEndpointUnnecessarily()
 {
     var context = new LocationContext();
     Assert.IsNull(context.Ip);
 }
 internal void CopyTo(LocationContext target)
 {
     Tags.CopyTagValue(this.Ip, ref target.ip);
 }