also expose the request client IP as seen by server port
parent
e0ba96055c
commit
b419f71a68
|
@ -55,6 +55,7 @@ namespace OpenSim.Framework.Servers.HttpServer
|
||||||
Dictionary<string, string> QueryAsDictionary { get; } //faster than Query
|
Dictionary<string, string> QueryAsDictionary { get; } //faster than Query
|
||||||
string RawUrl { get; }
|
string RawUrl { get; }
|
||||||
IPEndPoint RemoteIPEndPoint { get; }
|
IPEndPoint RemoteIPEndPoint { get; }
|
||||||
|
IPEndPoint LocalIPEndPoint { get; }
|
||||||
Uri Url { get; }
|
Uri Url { get; }
|
||||||
string UserAgent { get; }
|
string UserAgent { get; }
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,7 +89,7 @@ namespace OSHttpServer
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public event EventHandler Started;
|
public event EventHandler Started;
|
||||||
|
|
||||||
public IPEndPoint LocalRemoteEndPoint {get; set;}
|
public IPEndPoint LocalIPEndPoint {get; set;}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="HttpClientContext"/> class.
|
/// Initializes a new instance of the <see cref="HttpClientContext"/> class.
|
||||||
|
@ -107,7 +107,7 @@ namespace OSHttpServer
|
||||||
if (!stream.CanWrite || !stream.CanRead)
|
if (!stream.CanWrite || !stream.CanRead)
|
||||||
throw new ArgumentException("Stream must be writable and readable.");
|
throw new ArgumentException("Stream must be writable and readable.");
|
||||||
|
|
||||||
LocalRemoteEndPoint = remoteEndPoint;
|
LocalIPEndPoint = remoteEndPoint;
|
||||||
_log = NullLogWriter.Instance;
|
_log = NullLogWriter.Instance;
|
||||||
m_parser = parserFactory.CreateParser(_log);
|
m_parser = parserFactory.CreateParser(_log);
|
||||||
m_parser.RequestCompleted += OnRequestCompleted;
|
m_parser.RequestCompleted += OnRequestCompleted;
|
||||||
|
@ -186,8 +186,8 @@ namespace OSHttpServer
|
||||||
m_currentRequest.Method = e.HttpMethod;
|
m_currentRequest.Method = e.HttpMethod;
|
||||||
m_currentRequest.HttpVersion = e.HttpVersion;
|
m_currentRequest.HttpVersion = e.HttpVersion;
|
||||||
m_currentRequest.UriPath = e.UriPath;
|
m_currentRequest.UriPath = e.UriPath;
|
||||||
m_currentRequest.AddHeader("remote_addr", LocalRemoteEndPoint.Address.ToString());
|
m_currentRequest.AddHeader("remote_addr", LocalIPEndPoint.Address.ToString());
|
||||||
m_currentRequest.AddHeader("remote_port", LocalRemoteEndPoint.Port.ToString());
|
m_currentRequest.AddHeader("remote_port", LocalIPEndPoint.Port.ToString());
|
||||||
|
|
||||||
FirstRequestLineReceived = true;
|
FirstRequestLineReceived = true;
|
||||||
TriggerKeepalive = false;
|
TriggerKeepalive = false;
|
||||||
|
|
|
@ -54,7 +54,7 @@ namespace OSHttpServer
|
||||||
|
|
||||||
context.Stream = stream;
|
context.Stream = stream;
|
||||||
context.IsSecured = isSecured;
|
context.IsSecured = isSecured;
|
||||||
context.LocalRemoteEndPoint = endPoint;
|
context.LocalIPEndPoint = endPoint;
|
||||||
ContextTimeoutManager.StartMonitoringContext(context);
|
ContextTimeoutManager.StartMonitoringContext(context);
|
||||||
m_activeContexts[context.contextID] = context;
|
m_activeContexts[context.contextID] = context;
|
||||||
context.Start();
|
context.Start();
|
||||||
|
|
|
@ -271,6 +271,8 @@ namespace OSHttpServer
|
||||||
Cookies = cookies;
|
Cookies = cookies;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IPEndPoint LocalIPEndPoint { get {return m_context.LocalIPEndPoint; }}
|
||||||
|
|
||||||
public IPEndPoint RemoteIPEndPoint
|
public IPEndPoint RemoteIPEndPoint
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
@ -280,7 +282,7 @@ namespace OSHttpServer
|
||||||
string addr = m_headers["x-forwarded-for"];
|
string addr = m_headers["x-forwarded-for"];
|
||||||
if(!string.IsNullOrEmpty(addr))
|
if(!string.IsNullOrEmpty(addr))
|
||||||
{
|
{
|
||||||
int port = m_context.LocalRemoteEndPoint.Port;
|
int port = m_context.LocalIPEndPoint.Port;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
m_remoteIPEndPoint = new IPEndPoint(IPAddress.Parse(addr), port);
|
m_remoteIPEndPoint = new IPEndPoint(IPAddress.Parse(addr), port);
|
||||||
|
@ -292,7 +294,7 @@ namespace OSHttpServer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (m_remoteIPEndPoint == null)
|
if (m_remoteIPEndPoint == null)
|
||||||
m_remoteIPEndPoint = m_context.LocalRemoteEndPoint;
|
m_remoteIPEndPoint = m_context.LocalIPEndPoint;
|
||||||
|
|
||||||
return m_remoteIPEndPoint;
|
return m_remoteIPEndPoint;
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@ namespace OSHttpServer
|
||||||
/// </summary>
|
/// </summary>
|
||||||
string SSLCommonName { get; }
|
string SSLCommonName { get; }
|
||||||
|
|
||||||
IPEndPoint LocalRemoteEndPoint {get; set;}
|
IPEndPoint LocalIPEndPoint {get; set;}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Using SSL or other encryption method.
|
/// Using SSL or other encryption method.
|
||||||
|
|
|
@ -136,6 +136,7 @@ namespace OSHttpServer
|
||||||
/// <param name="cookies">The cookies.</param>
|
/// <param name="cookies">The cookies.</param>
|
||||||
void SetCookies(RequestCookies cookies);
|
void SetCookies(RequestCookies cookies);
|
||||||
|
|
||||||
|
IPEndPoint LocalIPEndPoint { get; }
|
||||||
IPEndPoint RemoteIPEndPoint { get; }
|
IPEndPoint RemoteIPEndPoint { get; }
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -165,7 +165,15 @@ namespace OpenSim.Tests.Common
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
throw new NotImplementedException ();
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public IPEndPoint LocalIPEndPoint
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue