aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/OptionalModules/Avatar/Chat
diff options
context:
space:
mode:
authoronefang2019-05-19 21:24:15 +1000
committeronefang2019-05-19 21:24:15 +1000
commit5e4d6cab00cb29cd088ab7b62ab13aff103b64cb (patch)
treea9fbc62df9eb2d1d9ba2698d8552eae71eca20d8 /OpenSim/Region/OptionalModules/Avatar/Chat
parentAdd a build script. (diff)
downloadopensim-SC_OLD-5e4d6cab00cb29cd088ab7b62ab13aff103b64cb.zip
opensim-SC_OLD-5e4d6cab00cb29cd088ab7b62ab13aff103b64cb.tar.gz
opensim-SC_OLD-5e4d6cab00cb29cd088ab7b62ab13aff103b64cb.tar.bz2
opensim-SC_OLD-5e4d6cab00cb29cd088ab7b62ab13aff103b64cb.tar.xz
Dump OpenSim 0.9.0.1 into it's own branch.
Diffstat (limited to 'OpenSim/Region/OptionalModules/Avatar/Chat')
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/Chat/ChannelState.cs27
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/Chat/IRCBridgeModule.cs4
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/Chat/IRCConnector.cs58
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/Chat/RegionState.cs43
4 files changed, 61 insertions, 71 deletions
diff --git a/OpenSim/Region/OptionalModules/Avatar/Chat/ChannelState.cs b/OpenSim/Region/OptionalModules/Avatar/Chat/ChannelState.cs
index b5d9fda..27ab32f 100644
--- a/OpenSim/Region/OptionalModules/Avatar/Chat/ChannelState.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/Chat/ChannelState.cs
@@ -38,7 +38,7 @@ using OpenSim.Region.Framework.Scenes;
38namespace OpenSim.Region.OptionalModules.Avatar.Chat 38namespace OpenSim.Region.OptionalModules.Avatar.Chat
39{ 39{
40 40
41 // An instance of this class exists for each unique combination of 41 // An instance of this class exists for each unique combination of
42 // IRC chat interface characteristics, as determined by the supplied 42 // IRC chat interface characteristics, as determined by the supplied
43 // configuration file. 43 // configuration file.
44 44
@@ -48,7 +48,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
48 private static readonly ILog m_log = 48 private static readonly ILog m_log =
49 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 49 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
50 50
51 private static Regex arg = new Regex(@"\[[^\[\]]*\]"); 51 private static Regex arg = new Regex(@"(?<!\\)\[[^\[\]]*(?<!\\)\]");
52 private static int _idk_ = 0; 52 private static int _idk_ = 0;
53 private static int DEBUG_CHANNEL = 2147483647; 53 private static int DEBUG_CHANNEL = 2147483647;
54 54
@@ -266,11 +266,11 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
266 ChannelState cs = p_cs; 266 ChannelState cs = p_cs;
267 267
268 // Check to see if we have an existing server/channel setup that can be used 268 // Check to see if we have an existing server/channel setup that can be used
269 // In the absence of variable substitution this will always resolve to the 269 // In the absence of variable substitution this will always resolve to the
270 // same ChannelState instance, and the table will only contains a single 270 // same ChannelState instance, and the table will only contains a single
271 // entry, so the performance considerations for the existing behavior are 271 // entry, so the performance considerations for the existing behavior are
272 // zero. Only the IRC connector is shared, the ChannelState still contains 272 // zero. Only the IRC connector is shared, the ChannelState still contains
273 // values that, while independent of the IRC connetion, do still distinguish 273 // values that, while independent of the IRC connetion, do still distinguish
274 // this region's behavior. 274 // this region's behavior.
275 275
276 lock (IRCBridgeModule.m_channels) 276 lock (IRCBridgeModule.m_channels)
@@ -335,7 +335,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
335 335
336 } 336 }
337 337
338 // These routines allow differentiating changes to 338 // These routines allow differentiating changes to
339 // the underlying channel state. If necessary, a 339 // the underlying channel state. If necessary, a
340 // new channel state will be created. 340 // new channel state will be created.
341 341
@@ -426,7 +426,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
426 } 426 }
427 427
428 // This level of obsessive matching allows us to produce 428 // This level of obsessive matching allows us to produce
429 // a minimal overhead int he case of a server which does 429 // a minimal overhead int he case of a server which does
430 // need to differentiate IRC at a region level. 430 // need to differentiate IRC at a region level.
431 431
432 private bool IsAPerfectMatchFor(ChannelState cs) 432 private bool IsAPerfectMatchFor(ChannelState cs)
@@ -447,8 +447,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
447 ); 447 );
448 } 448 }
449 449
450 // This function implements the variable substitution mechanism 450 // This function implements the variable substitution mechanism
451 // for the configuration values. Each string read from the 451 // for the configuration values. Each string read from the
452 // configuration file is scanned for '[...]' enclosures. Each 452 // configuration file is scanned for '[...]' enclosures. Each
453 // one that is found is replaced by either a runtime variable 453 // one that is found is replaced by either a runtime variable
454 // (%xxx) or an existing configuration key. When no further 454 // (%xxx) or an existing configuration key. When no further
@@ -499,6 +499,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
499 // m_log.DebugFormat("[IRC-Channel] Parse[2]: {0}", result); 499 // m_log.DebugFormat("[IRC-Channel] Parse[2]: {0}", result);
500 } 500 }
501 501
502 // Now we unescape the literal brackets
503 result = result.Replace(@"\[","[").Replace(@"\]","]");
504
502 // m_log.DebugFormat("[IRC-Channel] Parse[3]: {0}", result); 505 // m_log.DebugFormat("[IRC-Channel] Parse[3]: {0}", result);
503 return result; 506 return result;
504 507
@@ -582,7 +585,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
582 585
583 } 586 }
584 587
585 // This function is lifted from the IRCConnector because it 588 // This function is lifted from the IRCConnector because it
586 // contains information that is not differentiating from an 589 // contains information that is not differentiating from an
587 // IRC point-of-view. 590 // IRC point-of-view.
588 591
@@ -595,7 +598,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
595 { 598 {
596 599
597 // Scan through the set of unique channel configuration for those 600 // Scan through the set of unique channel configuration for those
598 // that belong to this connector. And then forward the message to 601 // that belong to this connector. And then forward the message to
599 // all regions known to those channels. 602 // all regions known to those channels.
600 // Note that this code is responsible for completing some of the 603 // Note that this code is responsible for completing some of the
601 // settings for the inbound OSChatMessage 604 // settings for the inbound OSChatMessage
diff --git a/OpenSim/Region/OptionalModules/Avatar/Chat/IRCBridgeModule.cs b/OpenSim/Region/OptionalModules/Avatar/Chat/IRCBridgeModule.cs
index 351dbfe..d6b6642 100644
--- a/OpenSim/Region/OptionalModules/Avatar/Chat/IRCBridgeModule.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/Chat/IRCBridgeModule.cs
@@ -79,6 +79,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
79 if (!m_config.GetBoolean("enabled", false)) 79 if (!m_config.GetBoolean("enabled", false))
80 { 80 {
81 // m_log.InfoFormat("[IRC-Bridge] module disabled in configuration"); 81 // m_log.InfoFormat("[IRC-Bridge] module disabled in configuration");
82 m_config = null;
82 return; 83 return;
83 } 84 }
84 85
@@ -104,7 +105,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
104 MainServer.Instance.AddXmlRPCHandler("irc_admin", XmlRpcAdminMethod, false); 105 MainServer.Instance.AddXmlRPCHandler("irc_admin", XmlRpcAdminMethod, false);
105 106
106 m_region = new RegionState(scene, m_config); 107 m_region = new RegionState(scene, m_config);
107 lock (m_regions) m_regions.Add(m_region); 108 lock (m_regions)
109 m_regions.Add(m_region);
108 m_region.Open(); 110 m_region.Open();
109 } 111 }
110 catch (Exception e) 112 catch (Exception e)
diff --git a/OpenSim/Region/OptionalModules/Avatar/Chat/IRCConnector.cs b/OpenSim/Region/OptionalModules/Avatar/Chat/IRCConnector.cs
index 6985371..ffbebe7 100644
--- a/OpenSim/Region/OptionalModules/Avatar/Chat/IRCConnector.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/Chat/IRCConnector.cs
@@ -97,14 +97,14 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
97 97
98 // How many regions depend upon this connection 98 // How many regions depend upon this connection
99 // This count is updated by the ChannelState object and reflects the sum 99 // This count is updated by the ChannelState object and reflects the sum
100 // of the region clients associated with the set of associated channel 100 // of the region clients associated with the set of associated channel
101 // state instances. That's why it cannot be managed here. 101 // state instances. That's why it cannot be managed here.
102 102
103 internal int depends = 0; 103 internal int depends = 0;
104 104
105 // This variable counts the number of resets that have been performed 105 // This variable counts the number of resets that have been performed
106 // on the connector. When a listener thread terminates, it checks to 106 // on the connector. When a listener thread terminates, it checks to
107 // see of the reset count has changed before it schedules another 107 // see of the reset count has changed before it schedules another
108 // reset. 108 // reset.
109 109
110 internal int m_resetk = 0; 110 internal int m_resetk = 0;
@@ -270,7 +270,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
270 270
271 public void Close() 271 public void Close()
272 { 272 {
273
274 m_log.InfoFormat("[IRC-Connector-{0}] Closing", idn); 273 m_log.InfoFormat("[IRC-Connector-{0}] Closing", idn);
275 274
276 lock (msyncConnect) 275 lock (msyncConnect)
@@ -295,7 +294,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
295 } 294 }
296 catch (Exception) { } 295 catch (Exception) { }
297 296
298
299 m_connected = false; 297 m_connected = false;
300 298
301 try { m_writer.Close(); } 299 try { m_writer.Close(); }
@@ -308,10 +306,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
308 catch (Exception) { } 306 catch (Exception) { }
309 307
310 } 308 }
311
312 lock (m_connectors) 309 lock (m_connectors)
313 m_connectors.Remove(this); 310 m_connectors.Remove(this);
314
315 } 311 }
316 } 312 }
317 313
@@ -327,25 +323,21 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
327 323
328 public void Connect() 324 public void Connect()
329 { 325 {
330
331 if (!m_enabled) 326 if (!m_enabled)
332 return; 327 return;
333 328
334 // Delay until next WD cycle if this is too close to the last start attempt 329 // Delay until next WD cycle if this is too close to the last start attempt
335 330 if(_icc_ < ICCD_PERIOD)
336 while (_icc_ < ICCD_PERIOD)
337 return; 331 return;
338 332
339 m_log.DebugFormat("[IRC-Connector-{0}]: Connection request for {1} on {2}:{3}", idn, m_nick, m_server, m_ircChannel); 333 m_log.DebugFormat("[IRC-Connector-{0}]: Connection request for {1} on {2}:{3}", idn, m_nick, m_server, m_ircChannel);
340 334
335 _icc_ = 0;
336
341 lock (msyncConnect) 337 lock (msyncConnect)
342 { 338 {
343
344 _icc_ = 0;
345
346 try 339 try
347 { 340 {
348
349 if (m_connected) return; 341 if (m_connected) return;
350 342
351 m_connected = true; 343 m_connected = true;
@@ -368,11 +360,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
368 m_writer.Flush(); 360 m_writer.Flush();
369 m_writer.WriteLine(m_user); 361 m_writer.WriteLine(m_user);
370 m_writer.Flush(); 362 m_writer.Flush();
371 m_writer.WriteLine(String.Format("JOIN {0}", m_ircChannel));
372 m_writer.Flush();
373
374 m_log.InfoFormat("[IRC-Connector-{0}]: {1} has asked to join {2}", idn, m_nick, m_ircChannel);
375
376 } 363 }
377 catch (Exception e) 364 catch (Exception e)
378 { 365 {
@@ -384,11 +371,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
384 // expires. By leaving them as they are, the connection will be retried 371 // expires. By leaving them as they are, the connection will be retried
385 // when the login timeout expires. Which is preferred. 372 // when the login timeout expires. Which is preferred.
386 } 373 }
387
388 } 374 }
389 375
390 return; 376 return;
391
392 } 377 }
393 378
394 // Reconnect is used to force a re-cycle of the IRC connection. Should generally 379 // Reconnect is used to force a re-cycle of the IRC connection. Should generally
@@ -443,7 +428,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
443 public void PrivMsg(string pattern, string from, string region, string msg) 428 public void PrivMsg(string pattern, string from, string region, string msg)
444 { 429 {
445 430
446 // m_log.DebugFormat("[IRC-Connector-{0}] PrivMsg to IRC from {1}: <{2}>", idn, from, 431 // m_log.DebugFormat("[IRC-Connector-{0}] PrivMsg to IRC from {1}: <{2}>", idn, from,
447 // String.Format(pattern, m_ircChannel, from, region, msg)); 432 // String.Format(pattern, m_ircChannel, from, region, msg));
448 433
449 // One message to the IRC server 434 // One message to the IRC server
@@ -521,11 +506,11 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
521 c.Message = data["msg"]; 506 c.Message = data["msg"];
522 c.Type = ChatTypeEnum.Region; 507 c.Type = ChatTypeEnum.Region;
523 c.Position = CenterOfRegion; 508 c.Position = CenterOfRegion;
524 c.From = data["nick"]; 509 c.From = data["nick"] + "@IRC";
525 c.Sender = null; 510 c.Sender = null;
526 c.SenderUUID = UUID.Zero; 511 c.SenderUUID = UUID.Zero;
527 512
528 // Is message "\001ACTION foo bar\001"? 513 // Is message "\001ACTION foo bar\001"?
529 // Then change to: "/me foo bar" 514 // Then change to: "/me foo bar"
530 515
531 if ((1 == c.Message[0]) && c.Message.Substring(1).StartsWith("ACTION")) 516 if ((1 == c.Message[0]) && c.Message.Substring(1).StartsWith("ACTION"))
@@ -623,8 +608,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
623 string parms = String.Empty; 608 string parms = String.Empty;
624 609
625 // ":" indicates that a prefix is present 610 // ":" indicates that a prefix is present
626 // There are NEVER more than 17 real 611 // There are NEVER more than 17 real
627 // fields. A parameter that starts with 612 // fields. A parameter that starts with
628 // ":" indicates that the remainder of the 613 // ":" indicates that the remainder of the
629 // line is a single parameter value. 614 // line is a single parameter value.
630 615
@@ -659,6 +644,11 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
659 version = commArgs[2]; 644 version = commArgs[2];
660 usermod = commArgs[3]; 645 usermod = commArgs[3];
661 chanmod = commArgs[4]; 646 chanmod = commArgs[4];
647
648 m_writer.WriteLine(String.Format("JOIN {0}", m_ircChannel));
649 m_writer.Flush();
650 m_log.InfoFormat("[IRC-Connector-{0}]: sent request to join {1} ", idn, m_ircChannel);
651
662 break; 652 break;
663 case "005": // Server information 653 case "005": // Server information
664 break; 654 break;
@@ -721,11 +711,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
721 case "PONG": 711 case "PONG":
722 break; 712 break;
723 case "JOIN": 713 case "JOIN":
724 if (m_pending) 714
725 {
726 m_log.InfoFormat("[IRC-Connector-{0}] [{1}] Connected", idn, cmd);
727 m_pending = false;
728 }
729 m_log.DebugFormat("[IRC-Connector-{0}] [{1}] parms = <{2}>", idn, cmd, parms); 715 m_log.DebugFormat("[IRC-Connector-{0}] [{1}] parms = <{2}>", idn, cmd, parms);
730 eventIrcJoin(pfx, cmd, parms); 716 eventIrcJoin(pfx, cmd, parms);
731 break; 717 break;
@@ -767,7 +753,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
767 if (IrcChannel.StartsWith(":")) 753 if (IrcChannel.StartsWith(":"))
768 IrcChannel = IrcChannel.Substring(1); 754 IrcChannel = IrcChannel.Substring(1);
769 755
770 m_log.DebugFormat("[IRC-Connector-{0}] Event: IRCJoin {1}:{2}", idn, m_server, m_ircChannel); 756 if(IrcChannel == m_ircChannel)
757 {
758 m_log.InfoFormat("[IRC-Connector-{0}] Joined requested channel {1} at {2}", idn, IrcChannel,m_server);
759 m_pending = false;
760 }
761 else
762 m_log.InfoFormat("[IRC-Connector-{0}] Joined unknown channel {1} at {2}", idn, IrcChannel,m_server);
771 BroadcastSim(IrcUser, "/me joins {0}", IrcChannel); 763 BroadcastSim(IrcUser, "/me joins {0}", IrcChannel);
772 } 764 }
773 765
@@ -881,7 +873,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
881 } 873 }
882 874
883 // Being marked connected is not enough to ping. Socket establishment can sometimes take a long 875 // Being marked connected is not enough to ping. Socket establishment can sometimes take a long
884 // time, in which case the watch dog might try to ping the server before the socket has been 876 // time, in which case the watch dog might try to ping the server before the socket has been
885 // set up, with nasty side-effects. 877 // set up, with nasty side-effects.
886 878
887 else if (_pdk_ == 0) 879 else if (_pdk_ == 0)
diff --git a/OpenSim/Region/OptionalModules/Avatar/Chat/RegionState.cs b/OpenSim/Region/OptionalModules/Avatar/Chat/RegionState.cs
index 6ea542c..a3ef83b 100644
--- a/OpenSim/Region/OptionalModules/Avatar/Chat/RegionState.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/Chat/RegionState.cs
@@ -389,39 +389,32 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
389 } 389 }
390 390
391 m_log.DebugFormat("[IRC-Region {0}] heard on channel {1} : {2}", Region, msg.Channel, msg.Message); 391 m_log.DebugFormat("[IRC-Region {0}] heard on channel {1} : {2}", Region, msg.Channel, msg.Message);
392 string txt = msg.Message;
393 392
394 if (null != avatar) 393 if (null != avatar && cs.RelayChat && (msg.Channel == 0 || msg.Channel == DEBUG_CHANNEL))
395 { 394 {
396 if ((!cs.RelayChat) || (msg.Channel != 0 && msg.Channel != DEBUG_CHANNEL)) 395 string txt = msg.Message;
397 return; 396 if (txt.StartsWith("/me "))
397 txt = String.Format("{0} {1}", fromName, msg.Message.Substring(4));
398
399 cs.irc.PrivMsg(cs.PrivateMessageFormat, fromName, Region, txt);
400 return;
398 } 401 }
399 else 402
403 if (null == avatar && cs.RelayPrivateChannels && null != cs.AccessPassword &&
404 msg.Channel == cs.RelayChannelOut)
400 { 405 {
401 if (cs.RelayPrivateChannels && msg.Channel == cs.RelayChannelOut) 406 Match m = cs.AccessPasswordRegex.Match(msg.Message);
407 if (null != m)
402 { 408 {
403 if (null != cs.AccessPassword) 409 m_log.DebugFormat("[IRC] relaying message from {0}: {1}", m.Groups["avatar"].ToString(),
404 { 410 m.Groups["message"].ToString());
405 Match m = cs.AccessPasswordRegex.Match(msg.Message); 411 cs.irc.PrivMsg(cs.PrivateMessageFormat, m.Groups["avatar"].ToString(),
406 if (null != m) 412 scene.RegionInfo.RegionName, m.Groups["message"].ToString());
407 {
408 if (m.Groups["avatar"].ToString() != "")
409 fromName = m.Groups["avatar"].ToString();
410 if (m.Groups["message"].ToString() != "")
411 txt = m.Groups["message"].ToString();
412 }
413 }
414 } 413 }
415 fromName = "OBJECT: " + fromName;
416 } 414 }
417
418 if (txt.StartsWith("/me "))
419 txt = String.Format("{0} {1}", fromName, msg.Message.Substring(4));
420 m_log.DebugFormat("[IRC] relaying message from {0}: {1}", fromName, txt);
421 cs.irc.PrivMsg(cs.PrivateMessageFormat, fromName, Region, txt);
422 } 415 }
423 416
424 // This method gives the region an opportunity to interfere with 417 // This method gives the region an opportunity to interfere with
425 // message delivery. For now we just enforce the enable/disable 418 // message delivery. For now we just enforce the enable/disable
426 // flag. 419 // flag.
427 420
@@ -435,7 +428,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
435 } 428 }
436 } 429 }
437 430
438 // This supports any local message traffic that might be needed in 431 // This supports any local message traffic that might be needed in
439 // support of command processing. At present there is none. 432 // support of command processing. At present there is none.
440 433
441 internal void LocalChat(string msg) 434 internal void LocalChat(string msg)