aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Server/Handlers/Map/MapAddServerConnector.cs
diff options
context:
space:
mode:
authorDavid Walter Seikel2016-11-03 21:44:39 +1000
committerDavid Walter Seikel2016-11-03 21:44:39 +1000
commit134f86e8d5c414409631b25b8c6f0ee45fbd8631 (patch)
tree216b89d3fb89acfb81be1e440c25c41ab09fa96d /OpenSim/Server/Handlers/Map/MapAddServerConnector.cs
parentMore changing to production grid. Double oops. (diff)
downloadopensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.zip
opensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.gz
opensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.bz2
opensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.xz
Initial update to OpenSim 0.8.2.1 source code.
Diffstat (limited to 'OpenSim/Server/Handlers/Map/MapAddServerConnector.cs')
-rw-r--r--OpenSim/Server/Handlers/Map/MapAddServerConnector.cs35
1 files changed, 13 insertions, 22 deletions
diff --git a/OpenSim/Server/Handlers/Map/MapAddServerConnector.cs b/OpenSim/Server/Handlers/Map/MapAddServerConnector.cs
index 4a61969..649a27e 100644
--- a/OpenSim/Server/Handlers/Map/MapAddServerConnector.cs
+++ b/OpenSim/Server/Handlers/Map/MapAddServerConnector.cs
@@ -38,6 +38,7 @@ using OpenMetaverse;
38using OpenSim.Framework; 38using OpenSim.Framework;
39using OpenSim.Server.Base; 39using OpenSim.Server.Base;
40using OpenSim.Services.Interfaces; 40using OpenSim.Services.Interfaces;
41using OpenSim.Framework.ServiceAuth;
41using OpenSim.Framework.Servers.HttpServer; 42using OpenSim.Framework.Servers.HttpServer;
42using OpenSim.Server.Handlers.Base; 43using OpenSim.Server.Handlers.Base;
43 44
@@ -79,7 +80,8 @@ namespace OpenSim.Server.Handlers.MapImage
79 m_log.InfoFormat("[MAP IMAGE HANDLER]: GridService check is OFF"); 80 m_log.InfoFormat("[MAP IMAGE HANDLER]: GridService check is OFF");
80 81
81 bool proxy = serverConfig.GetBoolean("HasProxy", false); 82 bool proxy = serverConfig.GetBoolean("HasProxy", false);
82 server.AddStreamHandler(new MapServerPostHandler(m_MapService, m_GridService, proxy)); 83 IServiceAuth auth = ServiceAuth.Create(config, m_ConfigName);
84 server.AddStreamHandler(new MapServerPostHandler(m_MapService, m_GridService, proxy, auth));
83 85
84 } 86 }
85 } 87 }
@@ -91,15 +93,15 @@ namespace OpenSim.Server.Handlers.MapImage
91 private IGridService m_GridService; 93 private IGridService m_GridService;
92 bool m_Proxy; 94 bool m_Proxy;
93 95
94 public MapServerPostHandler(IMapImageService service, IGridService grid, bool proxy) : 96 public MapServerPostHandler(IMapImageService service, IGridService grid, bool proxy, IServiceAuth auth) :
95 base("POST", "/map") 97 base("POST", "/map", auth)
96 { 98 {
97 m_MapService = service; 99 m_MapService = service;
98 m_GridService = grid; 100 m_GridService = grid;
99 m_Proxy = proxy; 101 m_Proxy = proxy;
100 } 102 }
101 103
102 public override byte[] Handle(string path, Stream requestData, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) 104 protected override byte[] ProcessRequest(string path, Stream requestData, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
103 { 105 {
104// m_log.DebugFormat("[MAP SERVICE IMAGE HANDLER]: Received {0}", path); 106// m_log.DebugFormat("[MAP SERVICE IMAGE HANDLER]: Received {0}", path);
105 StreamReader sr = new StreamReader(requestData); 107 StreamReader sr = new StreamReader(requestData);
@@ -116,9 +118,9 @@ namespace OpenSim.Server.Handlers.MapImage
116 httpResponse.StatusCode = (int)OSHttpStatusCode.ClientErrorBadRequest; 118 httpResponse.StatusCode = (int)OSHttpStatusCode.ClientErrorBadRequest;
117 return FailureResult("Bad request."); 119 return FailureResult("Bad request.");
118 } 120 }
119 int x = 0, y = 0; 121 uint x = 0, y = 0;
120 Int32.TryParse(request["X"].ToString(), out x); 122 UInt32.TryParse(request["X"].ToString(), out x);
121 Int32.TryParse(request["Y"].ToString(), out y); 123 UInt32.TryParse(request["Y"].ToString(), out y);
122 124
123 m_log.DebugFormat("[MAP ADD SERVER CONNECTOR]: Received map data for region at {0}-{1}", x, y); 125 m_log.DebugFormat("[MAP ADD SERVER CONNECTOR]: Received map data for region at {0}-{1}", x, y);
124 126
@@ -130,7 +132,7 @@ namespace OpenSim.Server.Handlers.MapImage
130 if (m_GridService != null) 132 if (m_GridService != null)
131 { 133 {
132 System.Net.IPAddress ipAddr = GetCallerIP(httpRequest); 134 System.Net.IPAddress ipAddr = GetCallerIP(httpRequest);
133 GridRegion r = m_GridService.GetRegionByPosition(UUID.Zero, x * (int)Constants.RegionSize, y * (int)Constants.RegionSize); 135 GridRegion r = m_GridService.GetRegionByPosition(UUID.Zero, (int)Util.RegionToWorldLoc(x), (int)Util.RegionToWorldLoc(y));
134 if (r != null) 136 if (r != null)
135 { 137 {
136 if (r.ExternalEndPoint.Address.ToString() != ipAddr.ToString()) 138 if (r.ExternalEndPoint.Address.ToString() != ipAddr.ToString())
@@ -151,7 +153,7 @@ namespace OpenSim.Server.Handlers.MapImage
151 byte[] data = Convert.FromBase64String(request["DATA"].ToString()); 153 byte[] data = Convert.FromBase64String(request["DATA"].ToString());
152 154
153 string reason = string.Empty; 155 string reason = string.Empty;
154 bool result = m_MapService.AddMapTile(x, y, data, out reason); 156 bool result = m_MapService.AddMapTile((int)x, (int)y, data, out reason);
155 157
156 if (result) 158 if (result)
157 return SuccessResult(); 159 return SuccessResult();
@@ -186,7 +188,7 @@ namespace OpenSim.Server.Handlers.MapImage
186 188
187 rootElement.AppendChild(result); 189 rootElement.AppendChild(result);
188 190
189 return DocToBytes(doc); 191 return Util.DocToBytes(doc);
190 } 192 }
191 193
192 private byte[] FailureResult(string msg) 194 private byte[] FailureResult(string msg)
@@ -213,18 +215,7 @@ namespace OpenSim.Server.Handlers.MapImage
213 215
214 rootElement.AppendChild(message); 216 rootElement.AppendChild(message);
215 217
216 return DocToBytes(doc); 218 return Util.DocToBytes(doc);
217 }
218
219 private byte[] DocToBytes(XmlDocument doc)
220 {
221 MemoryStream ms = new MemoryStream();
222 XmlTextWriter xw = new XmlTextWriter(ms, null);
223 xw.Formatting = Formatting.Indented;
224 doc.WriteTo(xw);
225 xw.Flush();
226
227 return ms.ToArray();
228 } 219 }
229 220
230 private System.Net.IPAddress GetCallerIP(IOSHttpRequest request) 221 private System.Net.IPAddress GetCallerIP(IOSHttpRequest request)