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