adding support for IP EndPoint whitelisting in HttpServer code.

0.6.0-stable
Dr Scofield 2008-07-07 11:25:09 +00:00
parent c5333af7a2
commit aaf8fff57e
2 changed files with 24 additions and 10 deletions

View File

@ -56,6 +56,7 @@ namespace OpenSim.Framework.Servers
private Uri _url;
private NameValueCollection _queryString;
private string _userAgent;
private IPEndPoint _ipEndPoint;
private HttpRequest _request;
// private HttpClientContext _context;
@ -146,6 +147,11 @@ namespace OpenSim.Framework.Servers
get { return _queryString; }
}
public IPEndPoint RemoteIPEndPoint
{
get { return _ipEndPoint; }
}
public HttpRequest HttpRequest
{
get { return _request; }
@ -161,18 +167,20 @@ namespace OpenSim.Framework.Servers
_contentEncoding = req.ContentEncoding;
_contentLength64 = req.ContentLength64;
_contentType = req.ContentType;
// _cookies = req.Cookies;
_headers = req.Headers;
_httpMethod = req.HttpMethod;
_hasbody = req.HasEntityBody;
_inputStream = req.InputStream;
// _isSecureConnection = req.IsSecureConnection;
// _isAuthenticated = req.IsAuthenticated;
_keepAlive = req.KeepAlive;
_rawUrl = req.RawUrl;
_url = req.Url;
_queryString = req.QueryString;
_userAgent = req.UserAgent;
_ipEndPoint = req.RemoteEndPoint;
// _cookies = req.Cookies;
// _isSecureConnection = req.IsSecureConnection;
// _isAuthenticated = req.IsAuthenticated;
}
public OSHttpRequest(HttpClientContext context, HttpRequest req)
@ -186,13 +194,10 @@ namespace OpenSim.Framework.Servers
_contentLength64 = req.ContentLength;
if (null != req.Headers["content-type"])
_contentType = _request.Headers["content-type"];
// _cookies = req.Cookies;
_headers = req.Headers;
_httpMethod = req.Method;
_hasbody = req.ContentLength != 0;
_inputStream = req.Body;
// _isSecureConnection = req.IsSecureConnection;
// _isAuthenticated = req.IsAuthenticated;
_keepAlive = ConnectionType.KeepAlive == req.Connection;
_rawUrl = req.Uri.AbsolutePath;
_url = req.Uri;
@ -203,6 +208,12 @@ namespace OpenSim.Framework.Servers
{
_queryString.Add(q.Key, q.Value.Value);
}
// TODO: requires change to HttpServer.HttpRequest
_ipEndPoint = null;
// _cookies = req.Cookies;
// _isSecureConnection = req.IsSecureConnection;
// _isAuthenticated = req.IsAuthenticated;
}
}
}

View File

@ -165,11 +165,14 @@ namespace OpenSim.Framework.Servers
if (null != endPointsRegex)
{
// TODO: following code requires code changes to
// HttpServer.HttpRequest
// HttpServer.HttpRequest to become functional
// IPEndPoint remote = HttpServer.HttpRequest.RemoteIPEndPoint;
// Match epm = endPointsRegex.Match(remote.ToString());
// if (!epm.Success) continue;
IPEndPoint remote = req.RemoteIPEndPoint;
if (null != remote)
{
Match epm = endPointsRegex.Match(remote.ToString());
if (!epm.Success) continue;
}
}
// whitelist ok, now check path