diff options
author | Dr Scofield | 2008-10-23 09:58:12 +0000 |
---|---|---|
committer | Dr Scofield | 2008-10-23 09:58:12 +0000 |
commit | dbd8e1edb5b2ce0e686b23200ff297fc3d004b5b (patch) | |
tree | fcc577b215a02ed5e0b3833227e657df509a4da2 /OpenSim | |
parent | Thank you kindly, Idb for a patch that: (diff) | |
download | opensim-SC-dbd8e1edb5b2ce0e686b23200ff297fc3d004b5b.zip opensim-SC-dbd8e1edb5b2ce0e686b23200ff297fc3d004b5b.tar.gz opensim-SC-dbd8e1edb5b2ce0e686b23200ff297fc3d004b5b.tar.bz2 opensim-SC-dbd8e1edb5b2ce0e686b23200ff297fc3d004b5b.tar.xz |
cleaning up commented lines in IRCConnector; changing access_password
logic to use a regexp.
Diffstat (limited to 'OpenSim')
-rw-r--r-- | OpenSim/Region/Environment/Modules/Avatar/Chat/IRCBridgeModule.cs | 64 | ||||
-rw-r--r-- | OpenSim/Region/Environment/Modules/Avatar/Chat/IRCConnector.cs | 8 |
2 files changed, 36 insertions, 36 deletions
diff --git a/OpenSim/Region/Environment/Modules/Avatar/Chat/IRCBridgeModule.cs b/OpenSim/Region/Environment/Modules/Avatar/Chat/IRCBridgeModule.cs index 05718d8..ba993a0 100644 --- a/OpenSim/Region/Environment/Modules/Avatar/Chat/IRCBridgeModule.cs +++ b/OpenSim/Region/Environment/Modules/Avatar/Chat/IRCBridgeModule.cs | |||
@@ -54,6 +54,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat | |||
54 | private string m_last_leaving_user = null; | 54 | private string m_last_leaving_user = null; |
55 | private string m_last_new_user = null; | 55 | private string m_last_new_user = null; |
56 | private List<Scene> m_scenes = new List<Scene>(); | 56 | private List<Scene> m_scenes = new List<Scene>(); |
57 | private List<int> m_validInWorldChannels = new List<int>(); | ||
57 | 58 | ||
58 | internal object m_syncInit = new object(); | 59 | internal object m_syncInit = new object(); |
59 | internal object m_syncLogout = new object(); | 60 | internal object m_syncLogout = new object(); |
@@ -65,6 +66,8 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat | |||
65 | private bool m_relayPrivateChannels = false; | 66 | private bool m_relayPrivateChannels = false; |
66 | private int m_relayChannelOut = -1; | 67 | private int m_relayChannelOut = -1; |
67 | private bool m_clientReporting = true; | 68 | private bool m_clientReporting = true; |
69 | private bool m_relayChat = true; | ||
70 | private Regex m_accessPasswordRe = null; | ||
68 | 71 | ||
69 | #region IRegionModule Members | 72 | #region IRegionModule Members |
70 | 73 | ||
@@ -96,9 +99,27 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat | |||
96 | 99 | ||
97 | m_relayPrivateChannels = m_config.GetBoolean("relay_private_channels", m_relayPrivateChannels); | 100 | m_relayPrivateChannels = m_config.GetBoolean("relay_private_channels", m_relayPrivateChannels); |
98 | m_relayChannelOut = m_config.GetInt("relay_private_channel_out", m_relayChannelOut); | 101 | m_relayChannelOut = m_config.GetInt("relay_private_channel_out", m_relayChannelOut); |
102 | m_relayChat = m_config.GetBoolean("relay_chat", m_relayChat); | ||
99 | 103 | ||
100 | m_clientReporting = m_config.GetBoolean("report_clients", m_clientReporting); | 104 | m_clientReporting = m_config.GetBoolean("report_clients", m_clientReporting); |
101 | 105 | ||
106 | if (m_accessPasswordRe == null) | ||
107 | { | ||
108 | string pass = config.Configs["IRC"].GetString("access_password", String.Empty); | ||
109 | m_accessPasswordRe = new Regex(String.Format(@"^{0},(?<avatar>[^,]+),(?<message>.+)$", pass), | ||
110 | RegexOptions.Compiled); | ||
111 | } | ||
112 | |||
113 | if (m_relayChat) | ||
114 | { | ||
115 | m_validInWorldChannels.Add(0); | ||
116 | m_validInWorldChannels.Add(DEBUG_CHANNEL); | ||
117 | } | ||
118 | |||
119 | if (m_relayPrivateChannels) | ||
120 | m_validInWorldChannels.Add(m_relayChannelOut); | ||
121 | |||
122 | |||
102 | lock (m_syncInit) | 123 | lock (m_syncInit) |
103 | { | 124 | { |
104 | 125 | ||
@@ -227,19 +248,9 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat | |||
227 | } | 248 | } |
228 | } | 249 | } |
229 | 250 | ||
230 | // drop all messages coming in on a private channel, | 251 | // drop messages if their channel is not on the valid |
231 | // except if we are relaying private channels, in which | 252 | // in-world channel list |
232 | // case we drop if the private channel is not the | 253 | if (!m_validInWorldChannels.Contains(c.Channel)) |
233 | // configured m_relayChannelOut | ||
234 | if (m_relayPrivateChannels) | ||
235 | { | ||
236 | if (c.Channel != 0 && c.Channel != DEBUG_CHANNEL && c.Channel != m_relayChannelOut) | ||
237 | { | ||
238 | m_log.DebugFormat("[IRC] dropping message {0} on channel {1}", c, c.Channel); | ||
239 | return; | ||
240 | } | ||
241 | } | ||
242 | else if (c.Channel != 0 && c.Channel != DEBUG_CHANNEL) | ||
243 | { | 254 | { |
244 | m_log.DebugFormat("[IRC] dropping message {0} on channel {1}", c, c.Channel); | 255 | m_log.DebugFormat("[IRC] dropping message {0} on channel {1}", c, c.Channel); |
245 | return; | 256 | return; |
@@ -265,31 +276,28 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat | |||
265 | return; | 276 | return; |
266 | } | 277 | } |
267 | 278 | ||
268 | if (null != avatar) | 279 | if (null != avatar && m_relayChat) |
269 | { | 280 | { |
270 | string msg = c.Message; | 281 | string msg = c.Message; |
271 | if (msg.StartsWith("/me ")) | 282 | if (msg.StartsWith("/me ")) |
272 | msg = String.Format("{0} {1}", fromName, c.Message.Substring(4)); | 283 | msg = String.Format("{0} {1}", fromName, c.Message.Substring(4)); |
273 | 284 | ||
274 | m_irc.PrivMsg(fromName, scene.RegionInfo.RegionName, msg); | 285 | m_irc.PrivMsg(fromName, scene.RegionInfo.RegionName, msg); |
286 | return; | ||
275 | } | 287 | } |
276 | else | 288 | |
289 | if (null == avatar && m_relayPrivateChannels) | ||
277 | { | 290 | { |
278 | //Message came from an object | 291 | Match m; |
279 | char[] splits = { ',' }; | 292 | if (m_accessPasswordRe != null && |
280 | string[] tokens = c.Message.Split(splits,3); // This is certainly wrong | 293 | (m = m_accessPasswordRe.Match(c.Message)) != null) |
281 | if (tokens.Length == 3) | ||
282 | { | 294 | { |
283 | if (tokens[0] == m_irc.m_accessPassword) // This is my really simple check | 295 | m_log.DebugFormat("[IRC] relaying message from {0}: {1}", m.Groups["avatar"].ToString(), |
284 | { | 296 | m.Groups["message"].ToString()); |
285 | m_log.DebugFormat("[IRC] message from object {0}, {1}", tokens[0], tokens[1]); | 297 | m_irc.PrivMsg(m.Groups["avatar"].ToString(), scene.RegionInfo.RegionName, |
286 | m_irc.PrivMsg(tokens[1], scene.RegionInfo.RegionName, tokens[2]); | 298 | m.Groups["message"].ToString()); |
287 | } | ||
288 | else | ||
289 | { | ||
290 | m_log.WarnFormat("[IRC] prim security key mismatch <{0}> not <{1}>", tokens[0], m_irc.m_accessPassword); | ||
291 | } | ||
292 | } | 299 | } |
300 | return; | ||
293 | } | 301 | } |
294 | } | 302 | } |
295 | #endregion | 303 | #endregion |
diff --git a/OpenSim/Region/Environment/Modules/Avatar/Chat/IRCConnector.cs b/OpenSim/Region/Environment/Modules/Avatar/Chat/IRCConnector.cs index 9ad467e..ddf6601 100644 --- a/OpenSim/Region/Environment/Modules/Avatar/Chat/IRCConnector.cs +++ b/OpenSim/Region/Environment/Modules/Avatar/Chat/IRCConnector.cs | |||
@@ -135,8 +135,6 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat | |||
135 | set { m_server = value; } | 135 | set { m_server = value; } |
136 | } | 136 | } |
137 | 137 | ||
138 | public string m_accessPassword = "badkitty"; | ||
139 | |||
140 | private string m_privmsgformat = "PRIVMSG {0} :<{1} in {2}>: {3}"; | 138 | private string m_privmsgformat = "PRIVMSG {0} :<{1} in {2}>: {3}"; |
141 | private StreamReader m_reader; | 139 | private StreamReader m_reader; |
142 | private List<Scene> m_scenes = new List<Scene>(); | 140 | private List<Scene> m_scenes = new List<Scene>(); |
@@ -188,20 +186,14 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat | |||
188 | m_port = (uint)config.Configs["IRC"].GetInt("port", (int)m_port); | 186 | m_port = (uint)config.Configs["IRC"].GetInt("port", (int)m_port); |
189 | m_user = config.Configs["IRC"].GetString("username", m_user); | 187 | m_user = config.Configs["IRC"].GetString("username", m_user); |
190 | m_privmsgformat = config.Configs["IRC"].GetString("msgformat", m_privmsgformat); | 188 | m_privmsgformat = config.Configs["IRC"].GetString("msgformat", m_privmsgformat); |
191 | // m_commandChannel = config.Configs["IRC"].GetInt("commandchannel", m_commandChannel); | ||
192 | 189 | ||
193 | // m_verbosity = config.Configs["IRC"].GetInt("verbosity", m_verbosity); | ||
194 | m_clientReporting = config.Configs["IRC"].GetInt("verbosity", 2) > 0; | 190 | m_clientReporting = config.Configs["IRC"].GetInt("verbosity", 2) > 0; |
195 | m_clientReporting = config.Configs["IRC"].GetBoolean("report_clients", m_clientReporting); | 191 | m_clientReporting = config.Configs["IRC"].GetBoolean("report_clients", m_clientReporting); |
196 | 192 | ||
197 | // m_messageOutChannel = config.Configs["IRC"].GetInt("outchannel", m_messageOutChannel); | ||
198 | // m_messageInChannel = config.Configs["IRC"].GetInt("inchannel", m_messageInChannel); | ||
199 | m_relayPrivateChannels = config.Configs["IRC"].GetBoolean("relay_private_channels", m_relayPrivateChannels); | 193 | m_relayPrivateChannels = config.Configs["IRC"].GetBoolean("relay_private_channels", m_relayPrivateChannels); |
200 | m_relayPrivateChannels = config.Configs["IRC"].GetBoolean("useworldcomm", m_relayPrivateChannels); //compat | 194 | m_relayPrivateChannels = config.Configs["IRC"].GetBoolean("useworldcomm", m_relayPrivateChannels); //compat |
201 | m_relayChannel = config.Configs["IRC"].GetInt("relay_private_channel_in", m_relayChannel); | 195 | m_relayChannel = config.Configs["IRC"].GetInt("relay_private_channel_in", m_relayChannel); |
202 | m_relayChannel = config.Configs["IRC"].GetInt("inchannel", m_relayChannel); | 196 | m_relayChannel = config.Configs["IRC"].GetInt("inchannel", m_relayChannel); |
203 | m_accessPassword = config.Configs["IRC"].GetString("access_password",m_accessPassword); | ||
204 | // m_useWorldComm = config.Configs["IRC"].GetBoolean("useworldcomm", m_useWorldComm); | ||
205 | 197 | ||
206 | if (m_server != null && m_baseNick != null && m_ircChannel != null) | 198 | if (m_server != null && m_baseNick != null && m_ircChannel != null) |
207 | { | 199 | { |