mirror of
https://github.com/opensim/opensim.git
synced 2026-08-01 06:06:06 +08:00
also expose the request client IP as seen by server port
This commit is contained in:
@@ -89,7 +89,7 @@ namespace OSHttpServer
|
||||
/// </summary>
|
||||
public event EventHandler Started;
|
||||
|
||||
public IPEndPoint LocalRemoteEndPoint {get; set;}
|
||||
public IPEndPoint LocalIPEndPoint {get; set;}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="HttpClientContext"/> class.
|
||||
@@ -107,7 +107,7 @@ namespace OSHttpServer
|
||||
if (!stream.CanWrite || !stream.CanRead)
|
||||
throw new ArgumentException("Stream must be writable and readable.");
|
||||
|
||||
LocalRemoteEndPoint = remoteEndPoint;
|
||||
LocalIPEndPoint = remoteEndPoint;
|
||||
_log = NullLogWriter.Instance;
|
||||
m_parser = parserFactory.CreateParser(_log);
|
||||
m_parser.RequestCompleted += OnRequestCompleted;
|
||||
@@ -186,8 +186,8 @@ namespace OSHttpServer
|
||||
m_currentRequest.Method = e.HttpMethod;
|
||||
m_currentRequest.HttpVersion = e.HttpVersion;
|
||||
m_currentRequest.UriPath = e.UriPath;
|
||||
m_currentRequest.AddHeader("remote_addr", LocalRemoteEndPoint.Address.ToString());
|
||||
m_currentRequest.AddHeader("remote_port", LocalRemoteEndPoint.Port.ToString());
|
||||
m_currentRequest.AddHeader("remote_addr", LocalIPEndPoint.Address.ToString());
|
||||
m_currentRequest.AddHeader("remote_port", LocalIPEndPoint.Port.ToString());
|
||||
|
||||
FirstRequestLineReceived = true;
|
||||
TriggerKeepalive = false;
|
||||
|
||||
@@ -54,7 +54,7 @@ namespace OSHttpServer
|
||||
|
||||
context.Stream = stream;
|
||||
context.IsSecured = isSecured;
|
||||
context.LocalRemoteEndPoint = endPoint;
|
||||
context.LocalIPEndPoint = endPoint;
|
||||
ContextTimeoutManager.StartMonitoringContext(context);
|
||||
m_activeContexts[context.contextID] = context;
|
||||
context.Start();
|
||||
|
||||
@@ -271,6 +271,8 @@ namespace OSHttpServer
|
||||
Cookies = cookies;
|
||||
}
|
||||
|
||||
public IPEndPoint LocalIPEndPoint { get {return m_context.LocalIPEndPoint; }}
|
||||
|
||||
public IPEndPoint RemoteIPEndPoint
|
||||
{
|
||||
get
|
||||
@@ -280,7 +282,7 @@ namespace OSHttpServer
|
||||
string addr = m_headers["x-forwarded-for"];
|
||||
if(!string.IsNullOrEmpty(addr))
|
||||
{
|
||||
int port = m_context.LocalRemoteEndPoint.Port;
|
||||
int port = m_context.LocalIPEndPoint.Port;
|
||||
try
|
||||
{
|
||||
m_remoteIPEndPoint = new IPEndPoint(IPAddress.Parse(addr), port);
|
||||
@@ -292,7 +294,7 @@ namespace OSHttpServer
|
||||
}
|
||||
}
|
||||
if (m_remoteIPEndPoint == null)
|
||||
m_remoteIPEndPoint = m_context.LocalRemoteEndPoint;
|
||||
m_remoteIPEndPoint = m_context.LocalIPEndPoint;
|
||||
|
||||
return m_remoteIPEndPoint;
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace OSHttpServer
|
||||
/// </summary>
|
||||
string SSLCommonName { get; }
|
||||
|
||||
IPEndPoint LocalRemoteEndPoint {get; set;}
|
||||
IPEndPoint LocalIPEndPoint {get; set;}
|
||||
|
||||
/// <summary>
|
||||
/// Using SSL or other encryption method.
|
||||
|
||||
@@ -136,6 +136,7 @@ namespace OSHttpServer
|
||||
/// <param name="cookies">The cookies.</param>
|
||||
void SetCookies(RequestCookies cookies);
|
||||
|
||||
IPEndPoint LocalIPEndPoint { get; }
|
||||
IPEndPoint RemoteIPEndPoint { get; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user