Fixed a typo in a comment.

This commit is contained in:
Sipke Schoorstra
2015-03-06 20:24:15 +01:00
parent ce23bb5a3e
commit 8a3d05779f
6 changed files with 23 additions and 24 deletions

View File

@@ -97,11 +97,11 @@
<Component Type="Orchard.Services.ClientAddressAccessor">
<Properties>
<!-- Set Value="true" to read the client host address from the specified HTTP header. -->
<Property Name="EnableClientAddressHeader" Value="false"/>
<Property Name="EnableClientHostAddressHeader" Value="false"/>
<!-- Set Value to the HTTP header name from which to read the client host address. Only used when EnableClientAddressHeader="true".
If the specified header was not found, the system will fall back to the user host address as provided by the Request object.-->
<Property Name="ClientAddressHeaderName" Value="X-Forwarded-For"/>
<!-- Set Value to the HTTP header name from which to read the client host address. Only used when EnableClientHostAddressHeader="true".
If the specified header was not found, the system will fall back to the client host address as provided by the Request object.-->
<Property Name="ClientHostAddressHeaderName" Value="X-Forwarded-For"/>
</Properties>
</Component>

View File

@@ -26,7 +26,7 @@ namespace Orchard.AuditTrail.Services {
private readonly ISiteService _siteService;
private readonly ISignals _signals;
private readonly IShapeFactory _shapeFactory;
private readonly IClientAddressAccessor _clientAddressAccessor;
private readonly IClientHostAddressAccessor _clientHostAddressAccessor;
public AuditTrailManager(
IRepository<AuditTrailEventRecord> auditTrailRepository,
@@ -38,7 +38,7 @@ namespace Orchard.AuditTrail.Services {
ISiteService siteService,
ISignals signals,
IShapeFactory shapeFactory,
IClientAddressAccessor clientAddressAccessor) {
IClientHostAddressAccessor clientHostAddressAccessor) {
_auditTrailRepository = auditTrailRepository;
_providers = providers;
@@ -49,7 +49,7 @@ namespace Orchard.AuditTrail.Services {
_siteService = siteService;
_signals = signals;
_shapeFactory = shapeFactory;
_clientAddressAccessor = clientAddressAccessor;
_clientHostAddressAccessor = clientHostAddressAccessor;
}
public IPageOfItems<AuditTrailEventRecord> GetRecords(
@@ -244,7 +244,7 @@ namespace Orchard.AuditTrail.Services {
if (!settings.EnableClientIpAddressLogging)
return null;
return _clientAddressAccessor.GetClientAddress();
return _clientHostAddressAccessor.GetClientAddress();
}
private bool IsEventEnabled(AuditTrailEventDescriptor eventDescriptor) {

View File

@@ -4,10 +4,10 @@ using Orchard.Services;
namespace Orchard.DynamicForms.Handlers {
public class IpAddressFieldHandler : FormElementEventHandlerBase {
private readonly IClientAddressAccessor _clientAddressAccessor;
private readonly IClientHostAddressAccessor _clientHostAddressAccessor;
public IpAddressFieldHandler(IClientAddressAccessor clientAddressAccessor) {
_clientAddressAccessor = clientAddressAccessor;
public IpAddressFieldHandler(IClientHostAddressAccessor clientHostAddressAccessor) {
_clientHostAddressAccessor = clientHostAddressAccessor;
}
public override void GetElementValue(FormElement element, ReadElementValuesContext context) {
@@ -17,7 +17,7 @@ namespace Orchard.DynamicForms.Handlers {
return;
var key = ipAddressField.Name;
context.Output[key] = _clientAddressAccessor.GetClientAddress();
context.Output[key] = _clientHostAddressAccessor.GetClientAddress();
}
}
}

View File

@@ -349,9 +349,9 @@
<Compile Include="Security\CurrentUserWorkContext.cs" />
<Compile Include="Security\Providers\DefaultEncryptionService.cs" />
<Compile Include="Services\Clock.cs" />
<Compile Include="Services\ClientAddressAccessor.cs" />
<Compile Include="Services\ClientHostAddressAccessor.cs" />
<Compile Include="Services\DefaultJsonConverter.cs" />
<Compile Include="Services\IClientAddressAccessor.cs" />
<Compile Include="Services\IClientHostAddressAccessor.cs" />
<Compile Include="Services\IJsonConverter.cs" />
<Compile Include="Settings\CurrentSiteWorkContext.cs" />
<Compile Include="Settings\ResourceDebugMode.cs" />

View File

@@ -1,34 +1,33 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Orchard.ContentManagement;
namespace Orchard.Services {
/// <summary>
/// Provides access to the client host address.
/// </summary>
public class ClientAddressAccessor : IClientAddressAccessor {
public class ClientHostAddressAccessor : IClientHostAddressAccessor {
private readonly IWorkContextAccessor _wca;
public ClientAddressAccessor(IWorkContextAccessor wca) {
public ClientHostAddressAccessor(IWorkContextAccessor wca) {
_wca = wca;
}
/// <summary>
/// Indicates whether the client host address should be read from an HTTP header, specified via <see cref="ClientAddressHeaderName"/>
/// Indicates whether the client host address should be read from an HTTP header, specified via <see cref="ClientHostAddressHeaderName"/>.
/// </summary>
public bool EnableClientAddressHeader { get; set; }
public bool EnableClientHostAddressHeader { get; set; }
/// <summary>
/// The HTTP header name to read the client host address from if <see cref="EnableClientAddressHeader"/> is set to true.
/// The HTTP header name to read the client host address from if <see cref="EnableClientHostAddressHeader"/> is set to true.
/// If the specified header was not found, the system will fall back to the user host address as provided by the Request object.
/// </summary>
public string ClientAddressHeaderName { get; set; }
public string ClientHostAddressHeaderName { get; set; }
public string GetClientAddress() {
var request = _wca.GetContext().HttpContext.Request;
if (EnableClientAddressHeader && !String.IsNullOrWhiteSpace(ClientAddressHeaderName)) {
var headerName = ClientAddressHeaderName.Trim();
if (EnableClientHostAddressHeader && !String.IsNullOrWhiteSpace(ClientHostAddressHeaderName)) {
var headerName = ClientHostAddressHeaderName.Trim();
var customAddresses = ParseAddresses(request.Headers[headerName]).ToArray();
if (customAddresses.Any())

View File

@@ -2,7 +2,7 @@ namespace Orchard.Services {
/// <summary>
/// Provides access to the user host address.
/// </summary>
public interface IClientAddressAccessor : IDependency {
public interface IClientHostAddressAccessor : IDependency {
string GetClientAddress();
}
}