cleaning up commented lines in IRCConnector; changing access_password
logic to use a regexp.0.6.0-stable
parent
f919b86156
commit
dbd8e1edb5
|
@ -54,6 +54,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
|
||||||
private string m_last_leaving_user = null;
|
private string m_last_leaving_user = null;
|
||||||
private string m_last_new_user = null;
|
private string m_last_new_user = null;
|
||||||
private List<Scene> m_scenes = new List<Scene>();
|
private List<Scene> m_scenes = new List<Scene>();
|
||||||
|
private List<int> m_validInWorldChannels = new List<int>();
|
||||||
|
|
||||||
internal object m_syncInit = new object();
|
internal object m_syncInit = new object();
|
||||||
internal object m_syncLogout = new object();
|
internal object m_syncLogout = new object();
|
||||||
|
@ -65,6 +66,8 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
|
||||||
private bool m_relayPrivateChannels = false;
|
private bool m_relayPrivateChannels = false;
|
||||||
private int m_relayChannelOut = -1;
|
private int m_relayChannelOut = -1;
|
||||||
private bool m_clientReporting = true;
|
private bool m_clientReporting = true;
|
||||||
|
private bool m_relayChat = true;
|
||||||
|
private Regex m_accessPasswordRe = null;
|
||||||
|
|
||||||
#region IRegionModule Members
|
#region IRegionModule Members
|
||||||
|
|
||||||
|
@ -96,9 +99,27 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
|
||||||
|
|
||||||
m_relayPrivateChannels = m_config.GetBoolean("relay_private_channels", m_relayPrivateChannels);
|
m_relayPrivateChannels = m_config.GetBoolean("relay_private_channels", m_relayPrivateChannels);
|
||||||
m_relayChannelOut = m_config.GetInt("relay_private_channel_out", m_relayChannelOut);
|
m_relayChannelOut = m_config.GetInt("relay_private_channel_out", m_relayChannelOut);
|
||||||
|
m_relayChat = m_config.GetBoolean("relay_chat", m_relayChat);
|
||||||
|
|
||||||
m_clientReporting = m_config.GetBoolean("report_clients", m_clientReporting);
|
m_clientReporting = m_config.GetBoolean("report_clients", m_clientReporting);
|
||||||
|
|
||||||
|
if (m_accessPasswordRe == null)
|
||||||
|
{
|
||||||
|
string pass = config.Configs["IRC"].GetString("access_password", String.Empty);
|
||||||
|
m_accessPasswordRe = new Regex(String.Format(@"^{0},(?<avatar>[^,]+),(?<message>.+)$", pass),
|
||||||
|
RegexOptions.Compiled);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_relayChat)
|
||||||
|
{
|
||||||
|
m_validInWorldChannels.Add(0);
|
||||||
|
m_validInWorldChannels.Add(DEBUG_CHANNEL);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_relayPrivateChannels)
|
||||||
|
m_validInWorldChannels.Add(m_relayChannelOut);
|
||||||
|
|
||||||
|
|
||||||
lock (m_syncInit)
|
lock (m_syncInit)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -227,19 +248,9 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// drop all messages coming in on a private channel,
|
// drop messages if their channel is not on the valid
|
||||||
// except if we are relaying private channels, in which
|
// in-world channel list
|
||||||
// case we drop if the private channel is not the
|
if (!m_validInWorldChannels.Contains(c.Channel))
|
||||||
// configured m_relayChannelOut
|
|
||||||
if (m_relayPrivateChannels)
|
|
||||||
{
|
|
||||||
if (c.Channel != 0 && c.Channel != DEBUG_CHANNEL && c.Channel != m_relayChannelOut)
|
|
||||||
{
|
|
||||||
m_log.DebugFormat("[IRC] dropping message {0} on channel {1}", c, c.Channel);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (c.Channel != 0 && c.Channel != DEBUG_CHANNEL)
|
|
||||||
{
|
{
|
||||||
m_log.DebugFormat("[IRC] dropping message {0} on channel {1}", c, c.Channel);
|
m_log.DebugFormat("[IRC] dropping message {0} on channel {1}", c, c.Channel);
|
||||||
return;
|
return;
|
||||||
|
@ -265,31 +276,28 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (null != avatar)
|
if (null != avatar && m_relayChat)
|
||||||
{
|
{
|
||||||
string msg = c.Message;
|
string msg = c.Message;
|
||||||
if (msg.StartsWith("/me "))
|
if (msg.StartsWith("/me "))
|
||||||
msg = String.Format("{0} {1}", fromName, c.Message.Substring(4));
|
msg = String.Format("{0} {1}", fromName, c.Message.Substring(4));
|
||||||
|
|
||||||
m_irc.PrivMsg(fromName, scene.RegionInfo.RegionName, msg);
|
m_irc.PrivMsg(fromName, scene.RegionInfo.RegionName, msg);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
if (null == avatar && m_relayPrivateChannels)
|
||||||
{
|
{
|
||||||
//Message came from an object
|
Match m;
|
||||||
char[] splits = { ',' };
|
if (m_accessPasswordRe != null &&
|
||||||
string[] tokens = c.Message.Split(splits,3); // This is certainly wrong
|
(m = m_accessPasswordRe.Match(c.Message)) != null)
|
||||||
if (tokens.Length == 3)
|
|
||||||
{
|
{
|
||||||
if (tokens[0] == m_irc.m_accessPassword) // This is my really simple check
|
m_log.DebugFormat("[IRC] relaying message from {0}: {1}", m.Groups["avatar"].ToString(),
|
||||||
{
|
m.Groups["message"].ToString());
|
||||||
m_log.DebugFormat("[IRC] message from object {0}, {1}", tokens[0], tokens[1]);
|
m_irc.PrivMsg(m.Groups["avatar"].ToString(), scene.RegionInfo.RegionName,
|
||||||
m_irc.PrivMsg(tokens[1], scene.RegionInfo.RegionName, tokens[2]);
|
m.Groups["message"].ToString());
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_log.WarnFormat("[IRC] prim security key mismatch <{0}> not <{1}>", tokens[0], m_irc.m_accessPassword);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
|
@ -135,8 +135,6 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
|
||||||
set { m_server = value; }
|
set { m_server = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public string m_accessPassword = "badkitty";
|
|
||||||
|
|
||||||
private string m_privmsgformat = "PRIVMSG {0} :<{1} in {2}>: {3}";
|
private string m_privmsgformat = "PRIVMSG {0} :<{1} in {2}>: {3}";
|
||||||
private StreamReader m_reader;
|
private StreamReader m_reader;
|
||||||
private List<Scene> m_scenes = new List<Scene>();
|
private List<Scene> m_scenes = new List<Scene>();
|
||||||
|
@ -188,20 +186,14 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
|
||||||
m_port = (uint)config.Configs["IRC"].GetInt("port", (int)m_port);
|
m_port = (uint)config.Configs["IRC"].GetInt("port", (int)m_port);
|
||||||
m_user = config.Configs["IRC"].GetString("username", m_user);
|
m_user = config.Configs["IRC"].GetString("username", m_user);
|
||||||
m_privmsgformat = config.Configs["IRC"].GetString("msgformat", m_privmsgformat);
|
m_privmsgformat = config.Configs["IRC"].GetString("msgformat", m_privmsgformat);
|
||||||
// m_commandChannel = config.Configs["IRC"].GetInt("commandchannel", m_commandChannel);
|
|
||||||
|
|
||||||
// m_verbosity = config.Configs["IRC"].GetInt("verbosity", m_verbosity);
|
|
||||||
m_clientReporting = config.Configs["IRC"].GetInt("verbosity", 2) > 0;
|
m_clientReporting = config.Configs["IRC"].GetInt("verbosity", 2) > 0;
|
||||||
m_clientReporting = config.Configs["IRC"].GetBoolean("report_clients", m_clientReporting);
|
m_clientReporting = config.Configs["IRC"].GetBoolean("report_clients", m_clientReporting);
|
||||||
|
|
||||||
// m_messageOutChannel = config.Configs["IRC"].GetInt("outchannel", m_messageOutChannel);
|
|
||||||
// m_messageInChannel = config.Configs["IRC"].GetInt("inchannel", m_messageInChannel);
|
|
||||||
m_relayPrivateChannels = config.Configs["IRC"].GetBoolean("relay_private_channels", m_relayPrivateChannels);
|
m_relayPrivateChannels = config.Configs["IRC"].GetBoolean("relay_private_channels", m_relayPrivateChannels);
|
||||||
m_relayPrivateChannels = config.Configs["IRC"].GetBoolean("useworldcomm", m_relayPrivateChannels); //compat
|
m_relayPrivateChannels = config.Configs["IRC"].GetBoolean("useworldcomm", m_relayPrivateChannels); //compat
|
||||||
m_relayChannel = config.Configs["IRC"].GetInt("relay_private_channel_in", m_relayChannel);
|
m_relayChannel = config.Configs["IRC"].GetInt("relay_private_channel_in", m_relayChannel);
|
||||||
m_relayChannel = config.Configs["IRC"].GetInt("inchannel", m_relayChannel);
|
m_relayChannel = config.Configs["IRC"].GetInt("inchannel", m_relayChannel);
|
||||||
m_accessPassword = config.Configs["IRC"].GetString("access_password",m_accessPassword);
|
|
||||||
// m_useWorldComm = config.Configs["IRC"].GetBoolean("useworldcomm", m_useWorldComm);
|
|
||||||
|
|
||||||
if (m_server != null && m_baseNick != null && m_ircChannel != null)
|
if (m_server != null && m_baseNick != null && m_ircChannel != null)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue