aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServerCommands.cs
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2014-10-02 23:18:21 +0100
committerJustin Clark-Casey (justincc)2014-11-25 23:18:39 +0000
commit12daa3c3d9731c67ebd0459dc79b81366514c855 (patch)
treefc3b43c336ed7d1967da27214360dcaa3f2a5904 /OpenSim/Region/ClientStack/Linden/UDP/LLUDPServerCommands.cs
parentrefactor: rename "debug lludp throttle status" to "debug lludp throttle get" ... (diff)
downloadopensim-SC-12daa3c3d9731c67ebd0459dc79b81366514c855.zip
opensim-SC-12daa3c3d9731c67ebd0459dc79b81366514c855.tar.gz
opensim-SC-12daa3c3d9731c67ebd0459dc79b81366514c855.tar.bz2
opensim-SC-12daa3c3d9731c67ebd0459dc79b81366514c855.tar.xz
refactor: Move LLUDPServer console commands into their own class.
Diffstat (limited to 'OpenSim/Region/ClientStack/Linden/UDP/LLUDPServerCommands.cs')
-rw-r--r--OpenSim/Region/ClientStack/Linden/UDP/LLUDPServerCommands.cs518
1 files changed, 518 insertions, 0 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServerCommands.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServerCommands.cs
new file mode 100644
index 0000000..5b23080
--- /dev/null
+++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServerCommands.cs
@@ -0,0 +1,518 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using NDesk.Options;
31using OpenSim.Framework;
32using OpenSim.Framework.Console;
33using OpenSim.Region.Framework.Scenes;
34
35namespace OpenSim.Region.ClientStack.LindenUDP
36{
37 public class LLUDPServerCommands
38 {
39 private ICommandConsole m_console;
40 private LLUDPServer m_udpServer;
41
42 public LLUDPServerCommands(ICommandConsole console, LLUDPServer udpServer)
43 {
44 m_console = console;
45 m_udpServer = udpServer;
46 }
47
48 public void Register()
49 {
50 m_console.Commands.AddCommand(
51 "Debug", false, "debug lludp packet",
52 "debug lludp packet [--default | --all] <level> [<avatar-first-name> <avatar-last-name>]",
53 "Turn on packet debugging. This logs information when the client stack hands a processed packet off to downstream code or when upstream code first requests that a certain packet be sent.",
54 "If level > 255 then all incoming and outgoing packets are logged.\n"
55 + "If level <= 255 then incoming AgentUpdate and outgoing SimStats and SimulatorViewerTimeMessage packets are not logged.\n"
56 + "If level <= 200 then incoming RequestImage and outgoing ImagePacket, ImageData, LayerData and CoarseLocationUpdate packets are not logged.\n"
57 + "If level <= 100 then incoming ViewerEffect and AgentAnimation and outgoing ViewerEffect and AvatarAnimation packets are not logged.\n"
58 + "If level <= 50 then outgoing ImprovedTerseObjectUpdate packets are not logged.\n"
59 + "If level <= 0 then no packets are logged.\n"
60 + "If --default is specified then the level becomes the default logging level for all subsequent agents.\n"
61 + "If --all is specified then the level becomes the default logging level for all current and subsequent agents.\n"
62 + "In these cases, you cannot also specify an avatar name.\n"
63 + "If an avatar name is given then only packets from that avatar are logged.",
64 HandlePacketCommand);
65
66 m_console.Commands.AddCommand(
67 "Debug", false, "debug lludp data out",
68 "debug lludp data out <level> <avatar-first-name> <avatar-last-name>\"",
69 "Turn on debugging for final outgoing data to the given user's client.",
70 "This operates at a much lower level than the packet command and prints out available details when the data is actually sent.\n"
71 + "If level > 0 then information about all outgoing UDP data for this avatar is logged.\n"
72 + "If level <= 0 then no information about outgoing UDP data for this avatar is logged.",
73 HandleDataCommand);
74
75 m_console.Commands.AddCommand(
76 "Debug", false, "debug lludp drop",
77 "debug lludp drop <in|out> <add|remove> <packet-name>",
78 "Drop all in or outbound packets that match the given name",
79 "For test purposes.",
80 HandleDropCommand);
81
82 m_console.Commands.AddCommand(
83 "Debug",
84 false,
85 "debug lludp start",
86 "debug lludp start <in|out|all>",
87 "Control LLUDP packet processing.",
88 "No effect if packet processing has already started.\n"
89 + "in - start inbound processing.\n"
90 + "out - start outbound processing.\n"
91 + "all - start in and outbound processing.\n",
92 HandleStartCommand);
93
94 m_console.Commands.AddCommand(
95 "Debug",
96 false,
97 "debug lludp stop",
98 "debug lludp stop <in|out|all>",
99 "Stop LLUDP packet processing.",
100 "No effect if packet processing has already stopped.\n"
101 + "in - stop inbound processing.\n"
102 + "out - stop outbound processing.\n"
103 + "all - stop in and outbound processing.\n",
104 HandleStopCommand);
105
106 m_console.Commands.AddCommand(
107 "Debug",
108 false,
109 "debug lludp pool",
110 "debug lludp pool <on|off>",
111 "Turn object pooling within the lludp component on or off.",
112 HandlePoolCommand);
113
114 m_console.Commands.AddCommand(
115 "Debug",
116 false,
117 "debug lludp status",
118 "debug lludp status",
119 "Return status of LLUDP packet processing.",
120 HandleStatusCommand);
121
122 m_console.Commands.AddCommand(
123 "Debug",
124 false,
125 "debug lludp throttle log",
126 "debug lludp throttle log <level> <avatar-first-name> <avatar-last-name>",
127 "Change debug logging level for throttles.",
128 "If level >= 0 then throttle debug logging is performed.\n"
129 + "If level <= 0 then no throttle debug logging is performed.",
130 HandleThrottleCommand);
131
132 m_console.Commands.AddCommand(
133 "Debug",
134 false,
135 "debug lludp throttle get",
136 "debug lludp throttle get <avatar-first-name> <avatar-last-name>",
137 "Return debug settings for throttles.",
138 HandleThrottleGetCommand);
139
140 m_console.Commands.AddCommand(
141 "Debug",
142 false,
143 "debug lludp throttle set",
144 "debug lludp throttle set <param> <value> <avatar-first-name> <avatar-last-name>",
145 "Set a throttle parameter for the given client.",
146 "Only current setting is 'adaptive' which must be 'true' or 'false'",
147 HandleThrottleSetCommand);
148
149 m_console.Commands.AddCommand(
150 "Debug",
151 false,
152 "debug lludp toggle agentupdate",
153 "debug lludp toggle agentupdate",
154 "Toggle whether agentupdate packets are processed or simply discarded.",
155 HandleAgentUpdateCommand);
156 }
157
158 private void HandleDataCommand(string module, string[] args)
159 {
160 if (SceneManager.Instance.CurrentScene != null && SceneManager.Instance.CurrentScene != m_udpServer.Scene)
161 return;
162
163 if (args.Length != 7)
164 {
165 MainConsole.Instance.OutputFormat("Usage: debug lludp data out <true|false> <avatar-first-name> <avatar-last-name>");
166 return;
167 }
168
169 int level;
170 if (!ConsoleUtil.TryParseConsoleInt(MainConsole.Instance, args[4], out level))
171 return;
172
173 string firstName = args[5];
174 string lastName = args[6];
175
176 m_udpServer.Scene.ForEachScenePresence(sp =>
177 {
178 if (sp.Firstname == firstName && sp.Lastname == lastName)
179 {
180 MainConsole.Instance.OutputFormat(
181 "Data debug for {0} ({1}) set to {2} in {3}",
182 sp.Name, sp.IsChildAgent ? "child" : "root", level, m_udpServer.Scene.Name);
183
184 ((LLClientView)sp.ControllingClient).UDPClient.DebugDataOutLevel = level;
185 }
186 });
187 }
188
189 private void HandleThrottleCommand(string module, string[] args)
190 {
191 if (SceneManager.Instance.CurrentScene != null && SceneManager.Instance.CurrentScene != m_udpServer.Scene)
192 return;
193
194 if (args.Length != 7)
195 {
196 MainConsole.Instance.OutputFormat("Usage: debug lludp throttle log <level> <avatar-first-name> <avatar-last-name>");
197 return;
198 }
199
200 int level;
201 if (!ConsoleUtil.TryParseConsoleInt(MainConsole.Instance, args[4], out level))
202 return;
203
204 string firstName = args[5];
205 string lastName = args[6];
206
207 m_udpServer.Scene.ForEachScenePresence(sp =>
208 {
209 if (sp.Firstname == firstName && sp.Lastname == lastName)
210 {
211 MainConsole.Instance.OutputFormat(
212 "Throttle log level for {0} ({1}) set to {2} in {3}",
213 sp.Name, sp.IsChildAgent ? "child" : "root", level, m_udpServer.Scene.Name);
214
215 ((LLClientView)sp.ControllingClient).UDPClient.ThrottleDebugLevel = level;
216 }
217 });
218 }
219
220 private void HandleThrottleSetCommand(string module, string[] args)
221 {
222 if (SceneManager.Instance.CurrentScene != null && SceneManager.Instance.CurrentScene != m_udpServer.Scene)
223 return;
224
225 if (args.Length != 8)
226 {
227 MainConsole.Instance.OutputFormat(
228 "Usage: debug lludp throttle set <param> <value> <avatar-first-name> <avatar-last-name>");
229 return;
230 }
231
232 string param = args[4];
233 string rawValue = args[5];
234 string firstName = args[6];
235 string lastName = args[7];
236
237 if (param == "adaptive")
238 {
239 bool newValue;
240 if (!ConsoleUtil.TryParseConsoleBool(MainConsole.Instance, rawValue, out newValue))
241 return;
242
243 m_udpServer.Scene.ForEachScenePresence(sp =>
244 {
245 if (sp.Firstname == firstName && sp.Lastname == lastName)
246 {
247 MainConsole.Instance.OutputFormat(
248 "Setting param {0} to {1} for {2} ({3}) in {4}",
249 param, newValue, sp.Name, sp.IsChildAgent ? "child" : "root", m_udpServer.Scene.Name);
250
251 LLUDPClient udpClient = ((LLClientView)sp.ControllingClient).UDPClient;
252 udpClient.FlowThrottle.Enabled = newValue;
253 // udpClient.FlowThrottle.MaxDripRate = 0;
254 // udpClient.FlowThrottle.AdjustedDripRate = 0;
255 }
256 });
257 }
258 }
259
260 private void HandleThrottleGetCommand(string module, string[] args)
261 {
262 if (SceneManager.Instance.CurrentScene != null && SceneManager.Instance.CurrentScene != m_udpServer.Scene)
263 return;
264
265 if (args.Length != 6)
266 {
267 MainConsole.Instance.OutputFormat("Usage: debug lludp throttle get <avatar-first-name> <avatar-last-name>");
268 return;
269 }
270
271 string firstName = args[4];
272 string lastName = args[5];
273
274 m_udpServer.Scene.ForEachScenePresence(sp =>
275 {
276 if (sp.Firstname == firstName && sp.Lastname == lastName)
277 {
278 MainConsole.Instance.OutputFormat(
279 "Status for {0} ({1}) in {2}",
280 sp.Name, sp.IsChildAgent ? "child" : "root", m_udpServer.Scene.Name);
281
282 LLUDPClient udpClient = ((LLClientView)sp.ControllingClient).UDPClient;
283 MainConsole.Instance.OutputFormat("Adaptive throttle: {0}", udpClient.FlowThrottle.Enabled);
284 }
285 });
286 }
287
288 private void HandlePacketCommand(string module, string[] args)
289 {
290 if (SceneManager.Instance.CurrentScene != null && SceneManager.Instance.CurrentScene != m_udpServer.Scene)
291 return;
292
293 bool setAsDefaultLevel = false;
294 bool setAll = false;
295 OptionSet optionSet = new OptionSet()
296 .Add("default", o => setAsDefaultLevel = (o != null))
297 .Add("all", o => setAll = (o != null));
298 List<string> filteredArgs = optionSet.Parse(args);
299
300 string name = null;
301
302 if (filteredArgs.Count == 6)
303 {
304 if (!(setAsDefaultLevel || setAll))
305 {
306 name = string.Format("{0} {1}", filteredArgs[4], filteredArgs[5]);
307 }
308 else
309 {
310 MainConsole.Instance.OutputFormat("ERROR: Cannot specify a user name when setting default/all logging level");
311 return;
312 }
313 }
314
315 if (filteredArgs.Count > 3)
316 {
317 int newDebug;
318 if (int.TryParse(filteredArgs[3], out newDebug))
319 {
320 if (setAsDefaultLevel || setAll)
321 {
322 m_udpServer.DefaultClientPacketDebugLevel = newDebug;
323
324 MainConsole.Instance.OutputFormat(
325 "Packet debug for {0} clients set to {1} in {2}",
326 (setAll ? "all" : "future"), m_udpServer.DefaultClientPacketDebugLevel, m_udpServer.Scene.Name);
327
328 if (setAll)
329 {
330 m_udpServer.Scene.ForEachScenePresence(sp =>
331 {
332 MainConsole.Instance.OutputFormat(
333 "Packet debug for {0} ({1}) set to {2} in {3}",
334 sp.Name, sp.IsChildAgent ? "child" : "root", newDebug, m_udpServer.Scene.Name);
335
336 sp.ControllingClient.DebugPacketLevel = newDebug;
337 });
338 }
339 }
340 else
341 {
342 m_udpServer.Scene.ForEachScenePresence(sp =>
343 {
344 if (name == null || sp.Name == name)
345 {
346 MainConsole.Instance.OutputFormat(
347 "Packet debug for {0} ({1}) set to {2} in {3}",
348 sp.Name, sp.IsChildAgent ? "child" : "root", newDebug, m_udpServer.Scene.Name);
349
350 sp.ControllingClient.DebugPacketLevel = newDebug;
351 }
352 });
353 }
354 }
355 else
356 {
357 MainConsole.Instance.Output("Usage: debug lludp packet [--default | --all] 0..255 [<first-name> <last-name>]");
358 }
359 }
360 }
361
362 private void HandleDropCommand(string module, string[] args)
363 {
364 if (SceneManager.Instance.CurrentScene != null && SceneManager.Instance.CurrentScene != m_udpServer.Scene)
365 return;
366
367 if (args.Length != 6)
368 {
369 MainConsole.Instance.Output("Usage: debug lludp drop <in|out> <add|remove> <packet-name>");
370 return;
371 }
372
373 string direction = args[3];
374 string subCommand = args[4];
375 string packetName = args[5];
376
377 if (subCommand == "add")
378 {
379 MainConsole.Instance.OutputFormat(
380 "Adding packet {0} to {1} drop list for all connections in {2}",
381 direction, packetName, m_udpServer.Scene.Name);
382
383 m_udpServer.Scene.ForEachScenePresence(
384 sp =>
385 {
386 LLClientView llcv = (LLClientView)sp.ControllingClient;
387
388 if (direction == "in")
389 llcv.AddInPacketToDropSet(packetName);
390 else if (direction == "out")
391 llcv.AddOutPacketToDropSet(packetName);
392 }
393 );
394 }
395 else if (subCommand == "remove")
396 {
397 MainConsole.Instance.OutputFormat(
398 "Removing packet {0} from {1} drop list for all connections in {2}",
399 direction, packetName, m_udpServer.Scene.Name);
400
401 m_udpServer.Scene.ForEachScenePresence(
402 sp =>
403 {
404 LLClientView llcv = (LLClientView)sp.ControllingClient;
405
406 if (direction == "in")
407 llcv.RemoveInPacketFromDropSet(packetName);
408 else if (direction == "out")
409 llcv.RemoveOutPacketFromDropSet(packetName);
410 }
411 );
412 }
413 }
414
415 private void HandleStartCommand(string module, string[] args)
416 {
417 if (SceneManager.Instance.CurrentScene != null && SceneManager.Instance.CurrentScene != m_udpServer.Scene)
418 return;
419
420 if (args.Length != 4)
421 {
422 MainConsole.Instance.Output("Usage: debug lludp start <in|out|all>");
423 return;
424 }
425
426 string subCommand = args[3];
427
428 if (subCommand == "in" || subCommand == "all")
429 m_udpServer.StartInbound();
430
431 if (subCommand == "out" || subCommand == "all")
432 m_udpServer.StartOutbound();
433 }
434
435 private void HandleStopCommand(string module, string[] args)
436 {
437 if (SceneManager.Instance.CurrentScene != null && SceneManager.Instance.CurrentScene != m_udpServer.Scene)
438 return;
439
440 if (args.Length != 4)
441 {
442 MainConsole.Instance.Output("Usage: debug lludp stop <in|out|all>");
443 return;
444 }
445
446 string subCommand = args[3];
447
448 if (subCommand == "in" || subCommand == "all")
449 m_udpServer.StopInbound();
450
451 if (subCommand == "out" || subCommand == "all")
452 m_udpServer.StopOutbound();
453 }
454
455 private void HandlePoolCommand(string module, string[] args)
456 {
457 if (SceneManager.Instance.CurrentScene != null && SceneManager.Instance.CurrentScene != m_udpServer.Scene)
458 return;
459
460 if (args.Length != 4)
461 {
462 MainConsole.Instance.Output("Usage: debug lludp pool <on|off>");
463 return;
464 }
465
466 string enabled = args[3];
467
468 if (enabled == "on")
469 {
470 if (m_udpServer.EnablePools())
471 {
472 m_udpServer.EnablePoolStats();
473 MainConsole.Instance.OutputFormat("Packet pools enabled on {0}", m_udpServer.Scene.Name);
474 }
475 }
476 else if (enabled == "off")
477 {
478 if (m_udpServer.DisablePools())
479 {
480 m_udpServer.DisablePoolStats();
481 MainConsole.Instance.OutputFormat("Packet pools disabled on {0}", m_udpServer.Scene.Name);
482 }
483 }
484 else
485 {
486 MainConsole.Instance.Output("Usage: debug lludp pool <on|off>");
487 }
488 }
489
490 private void HandleAgentUpdateCommand(string module, string[] args)
491 {
492 if (SceneManager.Instance.CurrentScene != null && SceneManager.Instance.CurrentScene != m_udpServer.Scene)
493 return;
494
495 m_udpServer.DiscardInboundAgentUpdates = !m_udpServer.DiscardInboundAgentUpdates;
496
497 MainConsole.Instance.OutputFormat(
498 "Discard AgentUpdates now {0} for {1}", m_udpServer.DiscardInboundAgentUpdates, m_udpServer.Scene.Name);
499 }
500
501 private void HandleStatusCommand(string module, string[] args)
502 {
503 if (SceneManager.Instance.CurrentScene != null && SceneManager.Instance.CurrentScene != m_udpServer.Scene)
504 return;
505
506 MainConsole.Instance.OutputFormat(
507 "IN LLUDP packet processing for {0} is {1}", m_udpServer.Scene.Name, m_udpServer.IsRunningInbound ? "enabled" : "disabled");
508
509 MainConsole.Instance.OutputFormat(
510 "OUT LLUDP packet processing for {0} is {1}", m_udpServer.Scene.Name, m_udpServer.IsRunningOutbound ? "enabled" : "disabled");
511
512 MainConsole.Instance.OutputFormat("LLUDP pools in {0} are {1}", m_udpServer.Scene.Name, m_udpServer.UsePools ? "on" : "off");
513
514 MainConsole.Instance.OutputFormat(
515 "Packet debug level for new clients is {0}", m_udpServer.DefaultClientPacketDebugLevel);
516 }
517 }
518} \ No newline at end of file