diff options
Diffstat (limited to 'OpenSim/Server/Handlers')
5 files changed, 81 insertions, 9 deletions
diff --git a/OpenSim/Server/Handlers/Authentication/OpenIdServerHandler.cs b/OpenSim/Server/Handlers/Authentication/OpenIdServerHandler.cs index dfed761..18cef15 100644 --- a/OpenSim/Server/Handlers/Authentication/OpenIdServerHandler.cs +++ b/OpenSim/Server/Handlers/Authentication/OpenIdServerHandler.cs | |||
@@ -191,6 +191,8 @@ For more information, see <a href='http://openid.net/'>http://openid.net/</a>. | |||
191 | 191 | ||
192 | #endregion HTML | 192 | #endregion HTML |
193 | 193 | ||
194 | public string Name { get { return "OpenId"; } } | ||
195 | public string Description { get { return null; } } | ||
194 | public string ContentType { get { return m_contentType; } } | 196 | public string ContentType { get { return m_contentType; } } |
195 | public string HttpMethod { get { return m_httpMethod; } } | 197 | public string HttpMethod { get { return m_httpMethod; } } |
196 | public string Path { get { return m_path; } } | 198 | public string Path { get { return m_path; } } |
diff --git a/OpenSim/Server/Handlers/Friends/FriendsServerPostHandler.cs b/OpenSim/Server/Handlers/Friends/FriendsServerPostHandler.cs index 59420f5..ef9b96f 100644 --- a/OpenSim/Server/Handlers/Friends/FriendsServerPostHandler.cs +++ b/OpenSim/Server/Handlers/Friends/FriendsServerPostHandler.cs | |||
@@ -95,7 +95,8 @@ namespace OpenSim.Server.Handlers.Friends | |||
95 | return DeleteFriendString(request); | 95 | return DeleteFriendString(request); |
96 | 96 | ||
97 | } | 97 | } |
98 | m_log.DebugFormat("[FRIENDS HANDLER]: unknown method {0} request {1}", method.Length, method); | 98 | |
99 | m_log.DebugFormat("[FRIENDS HANDLER]: unknown method request {0}", method); | ||
99 | } | 100 | } |
100 | catch (Exception e) | 101 | catch (Exception e) |
101 | { | 102 | { |
@@ -103,7 +104,6 @@ namespace OpenSim.Server.Handlers.Friends | |||
103 | } | 104 | } |
104 | 105 | ||
105 | return FailureResult(); | 106 | return FailureResult(); |
106 | |||
107 | } | 107 | } |
108 | 108 | ||
109 | #region Method-specific handlers | 109 | #region Method-specific handlers |
diff --git a/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs b/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs index bebf482..91d14cb 100644 --- a/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs +++ b/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs | |||
@@ -116,7 +116,7 @@ namespace OpenSim.Server.Handlers.Grid | |||
116 | return GetRegionFlags(request); | 116 | return GetRegionFlags(request); |
117 | } | 117 | } |
118 | 118 | ||
119 | m_log.DebugFormat("[GRID HANDLER]: unknown method {0} request {1}", method.Length, method); | 119 | m_log.DebugFormat("[GRID HANDLER]: unknown method request {0}", method); |
120 | } | 120 | } |
121 | catch (Exception e) | 121 | catch (Exception e) |
122 | { | 122 | { |
diff --git a/OpenSim/Server/Handlers/Hypergrid/HGFriendsServerPostHandler.cs b/OpenSim/Server/Handlers/Hypergrid/HGFriendsServerPostHandler.cs index 8ef03e7..c2f127c 100644 --- a/OpenSim/Server/Handlers/Hypergrid/HGFriendsServerPostHandler.cs +++ b/OpenSim/Server/Handlers/Hypergrid/HGFriendsServerPostHandler.cs | |||
@@ -122,7 +122,8 @@ namespace OpenSim.Server.Handlers.Hypergrid | |||
122 | return GrantRights(request); | 122 | return GrantRights(request); |
123 | */ | 123 | */ |
124 | } | 124 | } |
125 | m_log.DebugFormat("[HGFRIENDS HANDLER]: unknown method {0} request {1}", method.Length, method); | 125 | |
126 | m_log.DebugFormat("[HGFRIENDS HANDLER]: unknown method {0}", method); | ||
126 | } | 127 | } |
127 | catch (Exception e) | 128 | catch (Exception e) |
128 | { | 129 | { |
diff --git a/OpenSim/Server/Handlers/Map/MapAddServerConnector.cs b/OpenSim/Server/Handlers/Map/MapAddServerConnector.cs index 75dd711..4a61969 100644 --- a/OpenSim/Server/Handlers/Map/MapAddServerConnector.cs +++ b/OpenSim/Server/Handlers/Map/MapAddServerConnector.cs | |||
@@ -33,17 +33,24 @@ using System.Xml; | |||
33 | 33 | ||
34 | using Nini.Config; | 34 | using Nini.Config; |
35 | using log4net; | 35 | using log4net; |
36 | using OpenMetaverse; | ||
36 | 37 | ||
38 | using OpenSim.Framework; | ||
37 | using OpenSim.Server.Base; | 39 | using OpenSim.Server.Base; |
38 | using OpenSim.Services.Interfaces; | 40 | using OpenSim.Services.Interfaces; |
39 | using OpenSim.Framework.Servers.HttpServer; | 41 | using OpenSim.Framework.Servers.HttpServer; |
40 | using OpenSim.Server.Handlers.Base; | 42 | using OpenSim.Server.Handlers.Base; |
41 | 43 | ||
44 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | ||
45 | |||
42 | namespace OpenSim.Server.Handlers.MapImage | 46 | namespace OpenSim.Server.Handlers.MapImage |
43 | { | 47 | { |
44 | public class MapAddServiceConnector : ServiceConnector | 48 | public class MapAddServiceConnector : ServiceConnector |
45 | { | 49 | { |
50 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
51 | |||
46 | private IMapImageService m_MapService; | 52 | private IMapImageService m_MapService; |
53 | private IGridService m_GridService; | ||
47 | private string m_ConfigName = "MapImageService"; | 54 | private string m_ConfigName = "MapImageService"; |
48 | 55 | ||
49 | public MapAddServiceConnector(IConfigSource config, IHttpServer server, string configName) : | 56 | public MapAddServiceConnector(IConfigSource config, IHttpServer server, string configName) : |
@@ -53,16 +60,27 @@ namespace OpenSim.Server.Handlers.MapImage | |||
53 | if (serverConfig == null) | 60 | if (serverConfig == null) |
54 | throw new Exception(String.Format("No section {0} in config file", m_ConfigName)); | 61 | throw new Exception(String.Format("No section {0} in config file", m_ConfigName)); |
55 | 62 | ||
56 | string gridService = serverConfig.GetString("LocalServiceModule", | 63 | string mapService = serverConfig.GetString("LocalServiceModule", |
57 | String.Empty); | 64 | String.Empty); |
58 | 65 | ||
59 | if (gridService == String.Empty) | 66 | if (mapService == String.Empty) |
60 | throw new Exception("No LocalServiceModule in config file"); | 67 | throw new Exception("No LocalServiceModule in config file"); |
61 | 68 | ||
62 | Object[] args = new Object[] { config }; | 69 | Object[] args = new Object[] { config }; |
63 | m_MapService = ServerUtils.LoadPlugin<IMapImageService>(gridService, args); | 70 | m_MapService = ServerUtils.LoadPlugin<IMapImageService>(mapService, args); |
71 | |||
72 | string gridService = serverConfig.GetString("GridService", String.Empty); | ||
73 | if (gridService != string.Empty) | ||
74 | m_GridService = ServerUtils.LoadPlugin<IGridService>(gridService, args); | ||
75 | |||
76 | if (m_GridService != null) | ||
77 | m_log.InfoFormat("[MAP IMAGE HANDLER]: GridService check is ON"); | ||
78 | else | ||
79 | m_log.InfoFormat("[MAP IMAGE HANDLER]: GridService check is OFF"); | ||
80 | |||
81 | bool proxy = serverConfig.GetBoolean("HasProxy", false); | ||
82 | server.AddStreamHandler(new MapServerPostHandler(m_MapService, m_GridService, proxy)); | ||
64 | 83 | ||
65 | server.AddStreamHandler(new MapServerPostHandler(m_MapService)); | ||
66 | } | 84 | } |
67 | } | 85 | } |
68 | 86 | ||
@@ -70,11 +88,15 @@ namespace OpenSim.Server.Handlers.MapImage | |||
70 | { | 88 | { |
71 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 89 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
72 | private IMapImageService m_MapService; | 90 | private IMapImageService m_MapService; |
91 | private IGridService m_GridService; | ||
92 | bool m_Proxy; | ||
73 | 93 | ||
74 | public MapServerPostHandler(IMapImageService service) : | 94 | public MapServerPostHandler(IMapImageService service, IGridService grid, bool proxy) : |
75 | base("POST", "/map") | 95 | base("POST", "/map") |
76 | { | 96 | { |
77 | m_MapService = service; | 97 | m_MapService = service; |
98 | m_GridService = grid; | ||
99 | m_Proxy = proxy; | ||
78 | } | 100 | } |
79 | 101 | ||
80 | 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) |
@@ -105,6 +127,27 @@ namespace OpenSim.Server.Handlers.MapImage | |||
105 | // if (request.ContainsKey("TYPE")) | 127 | // if (request.ContainsKey("TYPE")) |
106 | // type = request["TYPE"].ToString(); | 128 | // type = request["TYPE"].ToString(); |
107 | 129 | ||
130 | if (m_GridService != null) | ||
131 | { | ||
132 | System.Net.IPAddress ipAddr = GetCallerIP(httpRequest); | ||
133 | GridRegion r = m_GridService.GetRegionByPosition(UUID.Zero, x * (int)Constants.RegionSize, y * (int)Constants.RegionSize); | ||
134 | if (r != null) | ||
135 | { | ||
136 | if (r.ExternalEndPoint.Address.ToString() != ipAddr.ToString()) | ||
137 | { | ||
138 | m_log.WarnFormat("[MAP IMAGE HANDLER]: IP address {0} may be trying to impersonate region in IP {1}", ipAddr, r.ExternalEndPoint.Address); | ||
139 | return FailureResult("IP address of caller does not match IP address of registered region"); | ||
140 | } | ||
141 | |||
142 | } | ||
143 | else | ||
144 | { | ||
145 | m_log.WarnFormat("[MAP IMAGE HANDLER]: IP address {0} may be rogue. Region not found at coordinates {1}-{2}", | ||
146 | ipAddr, x, y); | ||
147 | return FailureResult("Region not found at given coordinates"); | ||
148 | } | ||
149 | } | ||
150 | |||
108 | byte[] data = Convert.FromBase64String(request["DATA"].ToString()); | 151 | byte[] data = Convert.FromBase64String(request["DATA"].ToString()); |
109 | 152 | ||
110 | string reason = string.Empty; | 153 | string reason = string.Empty; |
@@ -183,5 +226,31 @@ namespace OpenSim.Server.Handlers.MapImage | |||
183 | 226 | ||
184 | return ms.ToArray(); | 227 | return ms.ToArray(); |
185 | } | 228 | } |
229 | |||
230 | private System.Net.IPAddress GetCallerIP(IOSHttpRequest request) | ||
231 | { | ||
232 | if (!m_Proxy) | ||
233 | return request.RemoteIPEndPoint.Address; | ||
234 | |||
235 | // We're behind a proxy | ||
236 | string xff = "X-Forwarded-For"; | ||
237 | string xffValue = request.Headers[xff.ToLower()]; | ||
238 | if (xffValue == null || (xffValue != null && xffValue == string.Empty)) | ||
239 | xffValue = request.Headers[xff]; | ||
240 | |||
241 | if (xffValue == null || (xffValue != null && xffValue == string.Empty)) | ||
242 | { | ||
243 | m_log.WarnFormat("[MAP IMAGE HANDLER]: No XFF header"); | ||
244 | return request.RemoteIPEndPoint.Address; | ||
245 | } | ||
246 | |||
247 | System.Net.IPEndPoint ep = Util.GetClientIPFromXFF(xffValue); | ||
248 | if (ep != null) | ||
249 | return ep.Address; | ||
250 | |||
251 | // Oops | ||
252 | return request.RemoteIPEndPoint.Address; | ||
253 | } | ||
254 | |||
186 | } | 255 | } |
187 | } | 256 | } |