diff options
author | Diva Canto | 2012-04-27 09:59:46 -0700 |
---|---|---|
committer | Diva Canto | 2012-04-27 09:59:46 -0700 |
commit | ac64fe03d8992a041933c303fa12933393cf1713 (patch) | |
tree | ed1f5cea9f5bd852cfa4750acdd750694b6949a0 | |
parent | Merge branch 'master' of ssh://opensimulator.org/var/git/opensim (diff) | |
download | opensim-SC-ac64fe03d8992a041933c303fa12933393cf1713.zip opensim-SC-ac64fe03d8992a041933c303fa12933393cf1713.tar.gz opensim-SC-ac64fe03d8992a041933c303fa12933393cf1713.tar.bz2 opensim-SC-ac64fe03d8992a041933c303fa12933393cf1713.tar.xz |
Amend to last commit: account for the existence of proxies.
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Server/Handlers/Map/MapAddServerConnector.cs | 35 | ||||
-rw-r--r-- | bin/Robust.HG.ini.example | 3 | ||||
-rw-r--r-- | bin/Robust.ini.example | 4 |
3 files changed, 39 insertions, 3 deletions
diff --git a/OpenSim/Server/Handlers/Map/MapAddServerConnector.cs b/OpenSim/Server/Handlers/Map/MapAddServerConnector.cs index c87de92..cc7ef9d 100644 --- a/OpenSim/Server/Handlers/Map/MapAddServerConnector.cs +++ b/OpenSim/Server/Handlers/Map/MapAddServerConnector.cs | |||
@@ -78,7 +78,8 @@ namespace OpenSim.Server.Handlers.MapImage | |||
78 | else | 78 | else |
79 | m_log.InfoFormat("[MAP IMAGE HANDLER]: GridService check is OFF"); | 79 | m_log.InfoFormat("[MAP IMAGE HANDLER]: GridService check is OFF"); |
80 | 80 | ||
81 | server.AddStreamHandler(new MapServerPostHandler(m_MapService, m_GridService)); | 81 | bool proxy = serverConfig.GetBoolean("HasProxy", false); |
82 | server.AddStreamHandler(new MapServerPostHandler(m_MapService, m_GridService, proxy)); | ||
82 | 83 | ||
83 | } | 84 | } |
84 | } | 85 | } |
@@ -88,12 +89,14 @@ namespace OpenSim.Server.Handlers.MapImage | |||
88 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 89 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
89 | private IMapImageService m_MapService; | 90 | private IMapImageService m_MapService; |
90 | private IGridService m_GridService; | 91 | private IGridService m_GridService; |
92 | bool m_Proxy; | ||
91 | 93 | ||
92 | public MapServerPostHandler(IMapImageService service, IGridService grid) : | 94 | public MapServerPostHandler(IMapImageService service, IGridService grid, bool proxy) : |
93 | base("POST", "/map") | 95 | base("POST", "/map") |
94 | { | 96 | { |
95 | m_MapService = service; | 97 | m_MapService = service; |
96 | m_GridService = grid; | 98 | m_GridService = grid; |
99 | m_Proxy = proxy; | ||
97 | } | 100 | } |
98 | 101 | ||
99 | public override byte[] Handle(string path, Stream requestData, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) | 102 | public override byte[] Handle(string path, Stream requestData, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) |
@@ -129,7 +132,7 @@ namespace OpenSim.Server.Handlers.MapImage | |||
129 | GridRegion r = m_GridService.GetRegionByPosition(UUID.Zero, x * (int)Constants.RegionSize, y * (int)Constants.RegionSize); | 132 | GridRegion r = m_GridService.GetRegionByPosition(UUID.Zero, x * (int)Constants.RegionSize, y * (int)Constants.RegionSize); |
130 | if (r != null) | 133 | if (r != null) |
131 | { | 134 | { |
132 | if (r.ExternalEndPoint.Address != httpRequest.RemoteIPEndPoint.Address) | 135 | if (r.ExternalEndPoint.Address != GetCallerIP(httpRequest)) |
133 | { | 136 | { |
134 | m_log.WarnFormat("[MAP IMAGE HANDLER]: IP address {0} may be rogue", httpRequest.RemoteIPEndPoint.Address); | 137 | m_log.WarnFormat("[MAP IMAGE HANDLER]: IP address {0} may be rogue", httpRequest.RemoteIPEndPoint.Address); |
135 | return FailureResult("IP address of caller does not match IP address of registered region"); | 138 | return FailureResult("IP address of caller does not match IP address of registered region"); |
@@ -221,5 +224,31 @@ namespace OpenSim.Server.Handlers.MapImage | |||
221 | 224 | ||
222 | return ms.ToArray(); | 225 | return ms.ToArray(); |
223 | } | 226 | } |
227 | |||
228 | private System.Net.IPAddress GetCallerIP(IOSHttpRequest request) | ||
229 | { | ||
230 | if (!m_Proxy) | ||
231 | return request.RemoteIPEndPoint.Address; | ||
232 | |||
233 | // We're behind a proxy | ||
234 | string xff = "X-Forwarded-For"; | ||
235 | string xffValue = request.Headers[xff.ToLower()]; | ||
236 | if (xffValue == null || (xffValue != null && xffValue == string.Empty)) | ||
237 | xffValue = request.Headers[xff]; | ||
238 | |||
239 | if (xffValue == null || (xffValue != null && xffValue == string.Empty)) | ||
240 | { | ||
241 | m_log.WarnFormat("[MAP IMAGE HANDLER]: No XFF header"); | ||
242 | return request.RemoteIPEndPoint.Address; | ||
243 | } | ||
244 | |||
245 | System.Net.IPEndPoint ep = Util.GetClientIPFromXFF(xffValue); | ||
246 | if (ep != null) | ||
247 | return ep.Address; | ||
248 | |||
249 | // Oops | ||
250 | return request.RemoteIPEndPoint.Address; | ||
251 | } | ||
252 | |||
224 | } | 253 | } |
225 | } | 254 | } |
diff --git a/bin/Robust.HG.ini.example b/bin/Robust.HG.ini.example index 1b5d37c..be75407 100644 --- a/bin/Robust.HG.ini.example +++ b/bin/Robust.HG.ini.example | |||
@@ -283,6 +283,9 @@ ServiceConnectors = "8003/OpenSim.Server.Handlers.dll:AssetServiceConnector,8003 | |||
283 | ; If for some reason you have the AddMapTile service outside the firewall (e.g. 8002), | 283 | ; If for some reason you have the AddMapTile service outside the firewall (e.g. 8002), |
284 | ; you may want to set this. Otherwise, don't set it, because it's already protected. | 284 | ; you may want to set this. Otherwise, don't set it, because it's already protected. |
285 | ; GridService = "OpenSim.Services.GridService.dll:GridService" | 285 | ; GridService = "OpenSim.Services.GridService.dll:GridService" |
286 | ; | ||
287 | ; Additionally, if you run this server behind a proxy, set this to true | ||
288 | ; HasProxy = false | ||
286 | 289 | ||
287 | [GridInfoService] | 290 | [GridInfoService] |
288 | ; These settings are used to return information on a get_grid_info call. | 291 | ; These settings are used to return information on a get_grid_info call. |
diff --git a/bin/Robust.ini.example b/bin/Robust.ini.example index 40b8d83..582af27 100644 --- a/bin/Robust.ini.example +++ b/bin/Robust.ini.example | |||
@@ -258,6 +258,10 @@ ServiceConnectors = "8003/OpenSim.Server.Handlers.dll:AssetServiceConnector,8003 | |||
258 | ; If for some reason you have the AddMapTile service outside the firewall (e.g. 8002), | 258 | ; If for some reason you have the AddMapTile service outside the firewall (e.g. 8002), |
259 | ; you may want to set this. Otherwise, don't set it, because it's already protected. | 259 | ; you may want to set this. Otherwise, don't set it, because it's already protected. |
260 | ; GridService = "OpenSim.Services.GridService.dll:GridService" | 260 | ; GridService = "OpenSim.Services.GridService.dll:GridService" |
261 | ; | ||
262 | ; Additionally, if you run this server behind a proxy, set this to true | ||
263 | ; HasProxy = false | ||
264 | |||
261 | 265 | ||
262 | 266 | ||
263 | [GridInfoService] | 267 | [GridInfoService] |