aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Server.Implementations/HttpServer/HttpServer.cs
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2013-05-27 14:34:03 -0400
committerLuke Pulverenti <luke.pulverenti@gmail.com>2013-05-27 14:34:03 -0400
commit085e597a2e0be1aa7341946201de774684031dd4 (patch)
treead3e6ccd9d850e83b51e0dd1998bdca742be17d0 /MediaBrowser.Server.Implementations/HttpServer/HttpServer.cs
parentd4e3c6aa52fe0bac50cb742d7fb082a61a66eb33 (diff)
improve accuracy of local ip address discovery
Diffstat (limited to 'MediaBrowser.Server.Implementations/HttpServer/HttpServer.cs')
-rw-r--r--MediaBrowser.Server.Implementations/HttpServer/HttpServer.cs29
1 files changed, 25 insertions, 4 deletions
diff --git a/MediaBrowser.Server.Implementations/HttpServer/HttpServer.cs b/MediaBrowser.Server.Implementations/HttpServer/HttpServer.cs
index 01b867bdb..893715b73 100644
--- a/MediaBrowser.Server.Implementations/HttpServer/HttpServer.cs
+++ b/MediaBrowser.Server.Implementations/HttpServer/HttpServer.cs
@@ -14,6 +14,7 @@ using ServiceStack.WebHost.Endpoints;
using ServiceStack.WebHost.Endpoints.Extensions;
using ServiceStack.WebHost.Endpoints.Support;
using System;
+using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
@@ -76,6 +77,17 @@ namespace MediaBrowser.Server.Implementations.HttpServer
/// </summary>
private readonly ContainerAdapter _containerAdapter;
+ private readonly ConcurrentDictionary<string, string> _localEndPoints = new ConcurrentDictionary<string, string>(StringComparer.OrdinalIgnoreCase);
+
+ /// <summary>
+ /// Gets the local end points.
+ /// </summary>
+ /// <value>The local end points.</value>
+ public IEnumerable<string> LocalEndPoints
+ {
+ get { return _localEndPoints.Keys.ToList(); }
+ }
+
/// <summary>
/// Initializes a new instance of the <see cref="HttpServer" /> class.
/// </summary>
@@ -340,15 +352,24 @@ namespace MediaBrowser.Server.Implementations.HttpServer
/// <param name="ctx">The CTX.</param>
private void LogHttpRequest(HttpListenerContext ctx)
{
- var log = new StringBuilder();
+ var endpoint = ctx.Request.LocalEndPoint;
- log.AppendLine("Url: " + ctx.Request.Url);
- log.AppendLine("Headers: " + string.Join(",", ctx.Request.Headers.AllKeys.Select(k => k + "=" + ctx.Request.Headers[k])));
+ if (endpoint != null)
+ {
+ var address = endpoint.ToString();
- var type = ctx.Request.IsWebSocketRequest ? "Web Socket" : "HTTP " + ctx.Request.HttpMethod;
+ _localEndPoints.AddOrUpdate(address, address, (key, existing) => address);
+ }
if (EnableHttpRequestLogging)
{
+ var log = new StringBuilder();
+
+ log.AppendLine("Url: " + ctx.Request.Url);
+ log.AppendLine("Headers: " + string.Join(",", ctx.Request.Headers.AllKeys.Select(k => k + "=" + ctx.Request.Headers[k])));
+
+ var type = ctx.Request.IsWebSocketRequest ? "Web Socket" : "HTTP " + ctx.Request.HttpMethod;
+
_logger.LogMultiline(type + " request received from " + ctx.Request.RemoteEndPoint, LogSeverity.Debug, log);
}
}