diff options
Diffstat (limited to 'OpenSim/Server')
5 files changed, 226 insertions, 6 deletions
diff --git a/OpenSim/Server/Base/ServicesServerBase.cs b/OpenSim/Server/Base/ServicesServerBase.cs index aeba35f..a6f4e47 100644 --- a/OpenSim/Server/Base/ServicesServerBase.cs +++ b/OpenSim/Server/Base/ServicesServerBase.cs | |||
@@ -126,11 +126,10 @@ namespace OpenSim.Server.Base | |||
126 | m_Config = new IniConfigSource(iniFile); | 126 | m_Config = new IniConfigSource(iniFile); |
127 | } | 127 | } |
128 | } | 128 | } |
129 | catch (Exception) | 129 | catch (Exception e) |
130 | { | 130 | { |
131 | System.Console.WriteLine("Error reading from config source {0}", | 131 | System.Console.WriteLine("Error reading from config source. {0}", e.Message); |
132 | iniFile); | 132 | Environment.Exit(1); |
133 | Thread.CurrentThread.Abort(); | ||
134 | } | 133 | } |
135 | 134 | ||
136 | // Merge the configuration from the command line into the | 135 | // Merge the configuration from the command line into the |
diff --git a/OpenSim/Server/Handlers/Asset/AssetServerConnector.cs b/OpenSim/Server/Handlers/Asset/AssetServerConnector.cs index df571fa..9b80245 100644 --- a/OpenSim/Server/Handlers/Asset/AssetServerConnector.cs +++ b/OpenSim/Server/Handlers/Asset/AssetServerConnector.cs | |||
@@ -26,7 +26,11 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.IO; | ||
29 | using Nini.Config; | 30 | using Nini.Config; |
31 | using OpenMetaverse; | ||
32 | using OpenSim.Framework; | ||
33 | using OpenSim.Framework.Console; | ||
30 | using OpenSim.Server.Base; | 34 | using OpenSim.Server.Base; |
31 | using OpenSim.Services.Interfaces; | 35 | using OpenSim.Services.Interfaces; |
32 | using OpenSim.Framework.Servers.HttpServer; | 36 | using OpenSim.Framework.Servers.HttpServer; |
@@ -67,6 +71,129 @@ namespace OpenSim.Server.Handlers.Asset | |||
67 | server.AddStreamHandler(new AssetServerGetHandler(m_AssetService)); | 71 | server.AddStreamHandler(new AssetServerGetHandler(m_AssetService)); |
68 | server.AddStreamHandler(new AssetServerPostHandler(m_AssetService)); | 72 | server.AddStreamHandler(new AssetServerPostHandler(m_AssetService)); |
69 | server.AddStreamHandler(new AssetServerDeleteHandler(m_AssetService, allowDelete)); | 73 | server.AddStreamHandler(new AssetServerDeleteHandler(m_AssetService, allowDelete)); |
74 | |||
75 | MainConsole.Instance.Commands.AddCommand("kfs", false, | ||
76 | "show asset", | ||
77 | "show asset <ID>", | ||
78 | "Show asset information", | ||
79 | HandleShowAsset); | ||
80 | |||
81 | MainConsole.Instance.Commands.AddCommand("kfs", false, | ||
82 | "delete asset", | ||
83 | "delete asset <ID>", | ||
84 | "Delete asset from database", | ||
85 | HandleDeleteAsset); | ||
86 | |||
87 | MainConsole.Instance.Commands.AddCommand("kfs", false, | ||
88 | "dump asset", | ||
89 | "dump asset <ID>", | ||
90 | "Dump asset to a file", | ||
91 | "The filename is the same as the ID given.", | ||
92 | HandleDumpAsset); | ||
93 | } | ||
94 | |||
95 | void HandleDeleteAsset(string module, string[] args) | ||
96 | { | ||
97 | if (args.Length < 3) | ||
98 | { | ||
99 | MainConsole.Instance.Output("Syntax: delete asset <ID>"); | ||
100 | return; | ||
101 | } | ||
102 | |||
103 | AssetBase asset = m_AssetService.Get(args[2]); | ||
104 | |||
105 | if (asset == null || asset.Data.Length == 0) | ||
106 | { | ||
107 | MainConsole.Instance.Output("Asset not found"); | ||
108 | return; | ||
109 | } | ||
110 | |||
111 | m_AssetService.Delete(args[2]); | ||
112 | |||
113 | //MainConsole.Instance.Output("Asset deleted"); | ||
114 | // TODO: Implement this | ||
115 | |||
116 | MainConsole.Instance.Output("Asset deletion not supported by database"); | ||
117 | } | ||
118 | |||
119 | void HandleDumpAsset(string module, string[] args) | ||
120 | { | ||
121 | if (args.Length < 3) | ||
122 | { | ||
123 | MainConsole.Instance.Output("Usage is dump asset <ID>"); | ||
124 | return; | ||
125 | } | ||
126 | |||
127 | UUID assetId; | ||
128 | string rawAssetId = args[2]; | ||
129 | |||
130 | if (!UUID.TryParse(rawAssetId, out assetId)) | ||
131 | { | ||
132 | MainConsole.Instance.OutputFormat("ERROR: {0} is not a valid ID format", rawAssetId); | ||
133 | return; | ||
134 | } | ||
135 | |||
136 | AssetBase asset = m_AssetService.Get(assetId.ToString()); | ||
137 | if (asset == null) | ||
138 | { | ||
139 | MainConsole.Instance.OutputFormat("ERROR: No asset found with ID {0}", assetId); | ||
140 | return; | ||
141 | } | ||
142 | |||
143 | string fileName = rawAssetId; | ||
144 | |||
145 | using (FileStream fs = new FileStream(fileName, FileMode.CreateNew)) | ||
146 | { | ||
147 | using (BinaryWriter bw = new BinaryWriter(fs)) | ||
148 | { | ||
149 | bw.Write(asset.Data); | ||
150 | } | ||
151 | } | ||
152 | |||
153 | MainConsole.Instance.OutputFormat("Asset dumped to file {0}", fileName); | ||
154 | } | ||
155 | |||
156 | void HandleShowAsset(string module, string[] args) | ||
157 | { | ||
158 | if (args.Length < 3) | ||
159 | { | ||
160 | MainConsole.Instance.Output("Syntax: show asset <ID>"); | ||
161 | return; | ||
162 | } | ||
163 | |||
164 | AssetBase asset = m_AssetService.Get(args[2]); | ||
165 | |||
166 | if (asset == null || asset.Data.Length == 0) | ||
167 | { | ||
168 | MainConsole.Instance.Output("Asset not found"); | ||
169 | return; | ||
170 | } | ||
171 | |||
172 | int i; | ||
173 | |||
174 | MainConsole.Instance.OutputFormat("Name: {0}", asset.Name); | ||
175 | MainConsole.Instance.OutputFormat("Description: {0}", asset.Description); | ||
176 | MainConsole.Instance.OutputFormat("Type: {0} (type number = {1})", (AssetType)asset.Type, asset.Type); | ||
177 | MainConsole.Instance.OutputFormat("Content-type: {0}", asset.Metadata.ContentType); | ||
178 | MainConsole.Instance.OutputFormat("Size: {0} bytes", asset.Data.Length); | ||
179 | MainConsole.Instance.OutputFormat("Temporary: {0}", asset.Temporary ? "yes" : "no"); | ||
180 | MainConsole.Instance.OutputFormat("Flags: {0}", asset.Metadata.Flags); | ||
181 | |||
182 | for (i = 0 ; i < 5 ; i++) | ||
183 | { | ||
184 | int off = i * 16; | ||
185 | if (asset.Data.Length <= off) | ||
186 | break; | ||
187 | int len = 16; | ||
188 | if (asset.Data.Length < off + len) | ||
189 | len = asset.Data.Length - off; | ||
190 | |||
191 | byte[] line = new byte[len]; | ||
192 | Array.Copy(asset.Data, off, line, 0, len); | ||
193 | |||
194 | string text = BitConverter.ToString(line); | ||
195 | MainConsole.Instance.Output(String.Format("{0:x4}: {1}", off, text)); | ||
196 | } | ||
70 | } | 197 | } |
71 | } | 198 | } |
72 | } | 199 | } \ No newline at end of file |
diff --git a/OpenSim/Server/Handlers/Grid/GridInfoHandlers.cs b/OpenSim/Server/Handlers/Grid/GridInfoHandlers.cs index 645a77f..965a54e 100644 --- a/OpenSim/Server/Handlers/Grid/GridInfoHandlers.cs +++ b/OpenSim/Server/Handlers/Grid/GridInfoHandlers.cs | |||
@@ -37,13 +37,14 @@ using Nini.Config; | |||
37 | using Nwc.XmlRpc; | 37 | using Nwc.XmlRpc; |
38 | using OpenSim.Framework; | 38 | using OpenSim.Framework; |
39 | using OpenSim.Framework.Servers.HttpServer; | 39 | using OpenSim.Framework.Servers.HttpServer; |
40 | using OpenMetaverse.StructuredData; | ||
40 | 41 | ||
41 | namespace OpenSim.Server.Handlers.Grid | 42 | namespace OpenSim.Server.Handlers.Grid |
42 | { | 43 | { |
43 | public class GridInfoHandlers | 44 | public class GridInfoHandlers |
44 | { | 45 | { |
45 | private static readonly ILog _log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 46 | private static readonly ILog _log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
46 | 47 | private IConfigSource m_Config; | |
47 | private Hashtable _info = new Hashtable(); | 48 | private Hashtable _info = new Hashtable(); |
48 | 49 | ||
49 | /// <summary> | 50 | /// <summary> |
@@ -59,6 +60,7 @@ namespace OpenSim.Server.Handlers.Grid | |||
59 | /// </remarks> | 60 | /// </remarks> |
60 | public GridInfoHandlers(IConfigSource configSource) | 61 | public GridInfoHandlers(IConfigSource configSource) |
61 | { | 62 | { |
63 | m_Config = configSource; | ||
62 | loadGridInfo(configSource); | 64 | loadGridInfo(configSource); |
63 | } | 65 | } |
64 | 66 | ||
@@ -142,5 +144,53 @@ namespace OpenSim.Server.Handlers.Grid | |||
142 | 144 | ||
143 | return sb.ToString(); | 145 | return sb.ToString(); |
144 | } | 146 | } |
147 | |||
148 | /// <summary> | ||
149 | /// Get GridInfo in json format: Used bu the OSSL osGetGrid* | ||
150 | /// Adding the SRV_HomeIRI to the kvp returned for use in scripts | ||
151 | /// </summary> | ||
152 | /// <returns> | ||
153 | /// json string | ||
154 | /// </returns> | ||
155 | /// <param name='request'> | ||
156 | /// Request. | ||
157 | /// </param> | ||
158 | /// <param name='path'> | ||
159 | /// /json_grid_info | ||
160 | /// </param> | ||
161 | /// <param name='param'> | ||
162 | /// Parameter. | ||
163 | /// </param> | ||
164 | /// <param name='httpRequest'> | ||
165 | /// Http request. | ||
166 | /// </param> | ||
167 | /// <param name='httpResponse'> | ||
168 | /// Http response. | ||
169 | /// </param> | ||
170 | public string JsonGetGridInfoMethod(string request, string path, string param, | ||
171 | IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) | ||
172 | { | ||
173 | string HomeURI = String.Empty; | ||
174 | IConfig cfg = m_Config.Configs["LoginService"]; | ||
175 | |||
176 | if (null != cfg) | ||
177 | { | ||
178 | HomeURI = cfg.GetString("SRV_HomeURI", HomeURI); | ||
179 | } | ||
180 | |||
181 | OSDMap map = new OSDMap(); | ||
182 | |||
183 | foreach (string k in _info.Keys) | ||
184 | { | ||
185 | map[k] = OSD.FromString(_info[k].ToString()); | ||
186 | } | ||
187 | |||
188 | if (!String.IsNullOrEmpty(HomeURI)) | ||
189 | { | ||
190 | map["home"] = OSD.FromString(HomeURI); | ||
191 | } | ||
192 | |||
193 | return OSDParser.SerializeJsonString(map).ToString(); | ||
194 | } | ||
145 | } | 195 | } |
146 | } | 196 | } |
diff --git a/OpenSim/Server/Handlers/Grid/GridInfoServerInConnector.cs b/OpenSim/Server/Handlers/Grid/GridInfoServerInConnector.cs index 8472d34..f9b5915 100644 --- a/OpenSim/Server/Handlers/Grid/GridInfoServerInConnector.cs +++ b/OpenSim/Server/Handlers/Grid/GridInfoServerInConnector.cs | |||
@@ -48,6 +48,8 @@ namespace OpenSim.Server.Handlers.Grid | |||
48 | 48 | ||
49 | server.AddStreamHandler(new RestStreamHandler("GET", "/get_grid_info", | 49 | server.AddStreamHandler(new RestStreamHandler("GET", "/get_grid_info", |
50 | handlers.RestGetGridInfoMethod)); | 50 | handlers.RestGetGridInfoMethod)); |
51 | server.AddStreamHandler(new RestStreamHandler("GET", "/json_grid_info", | ||
52 | handlers.JsonGetGridInfoMethod)); | ||
51 | server.AddXmlRPCHandler("get_grid_info", handlers.XmlRpcGridInfoMethod); | 53 | server.AddXmlRPCHandler("get_grid_info", handlers.XmlRpcGridInfoMethod); |
52 | } | 54 | } |
53 | 55 | ||
diff --git a/OpenSim/Server/Handlers/GridUser/GridUserServerPostHandler.cs b/OpenSim/Server/Handlers/GridUser/GridUserServerPostHandler.cs index 4c0d52e..bf21255 100644 --- a/OpenSim/Server/Handlers/GridUser/GridUserServerPostHandler.cs +++ b/OpenSim/Server/Handlers/GridUser/GridUserServerPostHandler.cs | |||
@@ -88,6 +88,8 @@ namespace OpenSim.Server.Handlers.GridUser | |||
88 | return SetPosition(request); | 88 | return SetPosition(request); |
89 | case "getgriduserinfo": | 89 | case "getgriduserinfo": |
90 | return GetGridUserInfo(request); | 90 | return GetGridUserInfo(request); |
91 | case "getgriduserinfos": | ||
92 | return GetGridUserInfos(request); | ||
91 | } | 93 | } |
92 | m_log.DebugFormat("[GRID USER HANDLER]: unknown method request: {0}", method); | 94 | m_log.DebugFormat("[GRID USER HANDLER]: unknown method request: {0}", method); |
93 | } | 95 | } |
@@ -193,6 +195,46 @@ namespace OpenSim.Server.Handlers.GridUser | |||
193 | 195 | ||
194 | } | 196 | } |
195 | 197 | ||
198 | byte[] GetGridUserInfos(Dictionary<string, object> request) | ||
199 | { | ||
200 | |||
201 | string[] userIDs; | ||
202 | |||
203 | if (!request.ContainsKey("AgentIDs")) | ||
204 | { | ||
205 | m_log.DebugFormat("[GRID USER HANDLER]: GetGridUserInfos called without required uuids argument"); | ||
206 | return FailureResult(); | ||
207 | } | ||
208 | |||
209 | if (!(request["AgentIDs"] is List<string>)) | ||
210 | { | ||
211 | m_log.DebugFormat("[GRID USER HANDLER]: GetGridUserInfos input argument was of unexpected type {0}", request["uuids"].GetType().ToString()); | ||
212 | return FailureResult(); | ||
213 | } | ||
214 | |||
215 | userIDs = ((List<string>)request["AgentIDs"]).ToArray(); | ||
216 | |||
217 | GridUserInfo[] pinfos = m_GridUserService.GetGridUserInfo(userIDs); | ||
218 | |||
219 | Dictionary<string, object> result = new Dictionary<string, object>(); | ||
220 | if ((pinfos == null) || ((pinfos != null) && (pinfos.Length == 0))) | ||
221 | result["result"] = "null"; | ||
222 | else | ||
223 | { | ||
224 | int i = 0; | ||
225 | foreach (GridUserInfo pinfo in pinfos) | ||
226 | { | ||
227 | Dictionary<string, object> rinfoDict = pinfo.ToKeyValuePairs(); | ||
228 | result["griduser" + i] = rinfoDict; | ||
229 | i++; | ||
230 | } | ||
231 | } | ||
232 | |||
233 | string xmlString = ServerUtils.BuildXmlResponse(result); | ||
234 | UTF8Encoding encoding = new UTF8Encoding(); | ||
235 | return encoding.GetBytes(xmlString); | ||
236 | } | ||
237 | |||
196 | private bool UnpackArgs(Dictionary<string, object> request, out string user, out UUID region, out Vector3 position, out Vector3 lookAt) | 238 | private bool UnpackArgs(Dictionary<string, object> request, out string user, out UUID region, out Vector3 position, out Vector3 lookAt) |
197 | { | 239 | { |
198 | user = string.Empty; | 240 | user = string.Empty; |