aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Addons
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Addons')
-rw-r--r--OpenSim/Addons/Groups/GroupsMessagingModule.cs38
-rw-r--r--OpenSim/Addons/Groups/Remote/GroupsServiceRemoteConnector.cs33
-rw-r--r--OpenSim/Addons/Groups/Remote/GroupsServiceRemoteConnectorModule.cs8
-rw-r--r--OpenSim/Addons/Groups/Remote/GroupsServiceRobustConnector.cs29
-rw-r--r--OpenSim/Addons/OfflineIM/OfflineIMRegionModule.cs6
-rw-r--r--OpenSim/Addons/OfflineIM/Remote/OfflineIMServiceRemoteConnector.cs17
-rw-r--r--OpenSim/Addons/OfflineIM/Remote/OfflineIMServiceRobustConnector.cs9
-rw-r--r--OpenSim/Addons/OfflineIM/Service/OfflineIMService.cs4
8 files changed, 92 insertions, 52 deletions
diff --git a/OpenSim/Addons/Groups/GroupsMessagingModule.cs b/OpenSim/Addons/Groups/GroupsMessagingModule.cs
index bbb5e05..e6a4765 100644
--- a/OpenSim/Addons/Groups/GroupsMessagingModule.cs
+++ b/OpenSim/Addons/Groups/GroupsMessagingModule.cs
@@ -56,8 +56,8 @@ namespace OpenSim.Groups
56 private IGroupsServicesConnector m_groupData = null; 56 private IGroupsServicesConnector m_groupData = null;
57 57
58 // Config Options 58 // Config Options
59 private bool m_groupMessagingEnabled = false; 59 private bool m_groupMessagingEnabled;
60 private bool m_debugEnabled = true; 60 private bool m_debugEnabled;
61 61
62 /// <summary> 62 /// <summary>
63 /// If enabled, module only tries to send group IMs to online users by querying cached presence information. 63 /// If enabled, module only tries to send group IMs to online users by querying cached presence information.
@@ -120,7 +120,7 @@ namespace OpenSim.Groups
120 return; 120 return;
121 } 121 }
122 122
123 m_debugEnabled = groupsConfig.GetBoolean("DebugEnabled", true); 123 m_debugEnabled = groupsConfig.GetBoolean("MessagingDebugEnabled", m_debugEnabled);
124 124
125 m_log.InfoFormat( 125 m_log.InfoFormat(
126 "[Groups.Messaging]: GroupsMessagingModule enabled with MessageOnlineOnly = {0}, DebugEnabled = {1}", 126 "[Groups.Messaging]: GroupsMessagingModule enabled with MessageOnlineOnly = {0}, DebugEnabled = {1}",
@@ -140,6 +140,14 @@ namespace OpenSim.Groups
140 scene.EventManager.OnMakeChildAgent += OnMakeChildAgent; 140 scene.EventManager.OnMakeChildAgent += OnMakeChildAgent;
141 scene.EventManager.OnIncomingInstantMessage += OnGridInstantMessage; 141 scene.EventManager.OnIncomingInstantMessage += OnGridInstantMessage;
142 scene.EventManager.OnClientLogin += OnClientLogin; 142 scene.EventManager.OnClientLogin += OnClientLogin;
143
144 scene.AddCommand(
145 "Debug",
146 this,
147 "debug groups messaging verbose",
148 "debug groups messaging verbose <true|false>",
149 "This setting turns on very verbose groups messaging debugging",
150 HandleDebugGroupsMessagingVerbose);
143 } 151 }
144 152
145 public void RegionLoaded(Scene scene) 153 public void RegionLoaded(Scene scene)
@@ -227,6 +235,26 @@ namespace OpenSim.Groups
227 235
228 #endregion 236 #endregion
229 237
238 private void HandleDebugGroupsMessagingVerbose(object modules, string[] args)
239 {
240 if (args.Length < 5)
241 {
242 MainConsole.Instance.Output("Usage: debug groups messaging verbose <true|false>");
243 return;
244 }
245
246 bool verbose = false;
247 if (!bool.TryParse(args[4], out verbose))
248 {
249 MainConsole.Instance.Output("Usage: debug groups messaging verbose <true|false>");
250 return;
251 }
252
253 m_debugEnabled = verbose;
254
255 MainConsole.Instance.OutputFormat("{0} verbose logging set to {1}", Name, m_debugEnabled);
256 }
257
230 /// <summary> 258 /// <summary>
231 /// Not really needed, but does confirm that the group exists. 259 /// Not really needed, but does confirm that the group exists.
232 /// </summary> 260 /// </summary>
@@ -255,6 +283,8 @@ namespace OpenSim.Groups
255 public void SendMessageToGroup( 283 public void SendMessageToGroup(
256 GridInstantMessage im, UUID groupID, UUID sendingAgentForGroupCalls, Func<GroupMembersData, bool> sendCondition) 284 GridInstantMessage im, UUID groupID, UUID sendingAgentForGroupCalls, Func<GroupMembersData, bool> sendCondition)
257 { 285 {
286 int requestStartTick = Environment.TickCount;
287
258 UUID fromAgentID = new UUID(im.fromAgentID); 288 UUID fromAgentID = new UUID(im.fromAgentID);
259 289
260 // Unlike current XmlRpcGroups, Groups V2 can accept UUID.Zero when a perms check for the requesting agent 290 // Unlike current XmlRpcGroups, Groups V2 can accept UUID.Zero when a perms check for the requesting agent
@@ -287,8 +317,6 @@ namespace OpenSim.Groups
287// "[Groups.Messaging]: SendMessageToGroup called for group {0} with {1} visible members, {2} online", 317// "[Groups.Messaging]: SendMessageToGroup called for group {0} with {1} visible members, {2} online",
288// groupID, groupMembersCount, groupMembers.Count()); 318// groupID, groupMembersCount, groupMembers.Count());
289 319
290 int requestStartTick = Environment.TickCount;
291
292 im.imSessionID = groupID.Guid; 320 im.imSessionID = groupID.Guid;
293 im.fromGroup = true; 321 im.fromGroup = true;
294 IClientAPI thisClient = GetActiveClient(fromAgentID); 322 IClientAPI thisClient = GetActiveClient(fromAgentID);
diff --git a/OpenSim/Addons/Groups/Remote/GroupsServiceRemoteConnector.cs b/OpenSim/Addons/Groups/Remote/GroupsServiceRemoteConnector.cs
index 1425a23..7450c14 100644
--- a/OpenSim/Addons/Groups/Remote/GroupsServiceRemoteConnector.cs
+++ b/OpenSim/Addons/Groups/Remote/GroupsServiceRemoteConnector.cs
@@ -32,29 +32,47 @@ using System.Reflection;
32using System.Text; 32using System.Text;
33 33
34using OpenSim.Framework; 34using OpenSim.Framework;
35using OpenSim.Framework.ServiceAuth;
35using OpenSim.Server.Base; 36using OpenSim.Server.Base;
36 37
37using OpenMetaverse; 38using OpenMetaverse;
38using log4net; 39using log4net;
40using Nini.Config;
39 41
40namespace OpenSim.Groups 42namespace OpenSim.Groups
41{ 43{
42 public class GroupsServiceRemoteConnector 44 public class GroupsServiceRemoteConnector
43 { 45 {
44 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 46 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
45 47
46 private string m_ServerURI; 48 private string m_ServerURI;
47 private string m_SecretKey; 49 private IServiceAuth m_Auth;
48 private object m_Lock = new object(); 50 private object m_Lock = new object();
49 51
50 public GroupsServiceRemoteConnector(string url, string secret) 52 public GroupsServiceRemoteConnector(IConfigSource config)
51 { 53 {
54 IConfig groupsConfig = config.Configs["Groups"];
55 string url = groupsConfig.GetString("GroupsServerURI", string.Empty);
56 if (!Uri.IsWellFormedUriString(url, UriKind.Absolute))
57 throw new Exception(string.Format("[Groups.RemoteConnector]: Malformed groups server URL {0}. Fix it or disable the Groups feature.", url));
58
52 m_ServerURI = url; 59 m_ServerURI = url;
53 if (!m_ServerURI.EndsWith("/")) 60 if (!m_ServerURI.EndsWith("/"))
54 m_ServerURI += "/"; 61 m_ServerURI += "/";
55 62
56 m_SecretKey = secret; 63 /// This is from BaseServiceConnector
57 m_log.DebugFormat("[Groups.RemoteConnector]: Groups server at {0}, secret key {1}", m_ServerURI, m_SecretKey); 64 string authType = Util.GetConfigVarFromSections<string>(config, "AuthType", new string[] { "Network", "Groups" }, "None");
65
66 switch (authType)
67 {
68 case "BasicHttpAuthentication":
69 m_Auth = new BasicHttpAuthentication(config, "Groups");
70 break;
71 }
72 ///
73
74 m_log.DebugFormat("[Groups.RemoteConnector]: Groups server at {0}, authentication {1}",
75 m_ServerURI, (m_Auth == null ? "None" : m_Auth.GetType().ToString()));
58 } 76 }
59 77
60 public ExtendedGroupRecord CreateGroup(string RequestingAgentID, string name, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment, 78 public ExtendedGroupRecord CreateGroup(string RequestingAgentID, string name, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment,
@@ -656,14 +674,13 @@ namespace OpenSim.Groups
656 private Dictionary<string, object> MakeRequest(string method, Dictionary<string, object> sendData) 674 private Dictionary<string, object> MakeRequest(string method, Dictionary<string, object> sendData)
657 { 675 {
658 sendData["METHOD"] = method; 676 sendData["METHOD"] = method;
659 if (m_SecretKey != string.Empty)
660 sendData["KEY"] = m_SecretKey;
661 677
662 string reply = string.Empty; 678 string reply = string.Empty;
663 lock (m_Lock) 679 lock (m_Lock)
664 reply = SynchronousRestFormsRequester.MakeRequest("POST", 680 reply = SynchronousRestFormsRequester.MakeRequest("POST",
665 m_ServerURI + "groups", 681 m_ServerURI + "groups",
666 ServerUtils.BuildQueryString(sendData)); 682 ServerUtils.BuildQueryString(sendData),
683 m_Auth);
667 684
668 if (reply == string.Empty) 685 if (reply == string.Empty)
669 return null; 686 return null;
diff --git a/OpenSim/Addons/Groups/Remote/GroupsServiceRemoteConnectorModule.cs b/OpenSim/Addons/Groups/Remote/GroupsServiceRemoteConnectorModule.cs
index 5fb3c19..fddda22 100644
--- a/OpenSim/Addons/Groups/Remote/GroupsServiceRemoteConnectorModule.cs
+++ b/OpenSim/Addons/Groups/Remote/GroupsServiceRemoteConnectorModule.cs
@@ -72,13 +72,7 @@ namespace OpenSim.Groups
72 72
73 private void Init(IConfigSource config) 73 private void Init(IConfigSource config)
74 { 74 {
75 IConfig groupsConfig = config.Configs["Groups"]; 75 m_GroupsService = new GroupsServiceRemoteConnector(config);
76 string url = groupsConfig.GetString("GroupsServerURI", string.Empty);
77 if (!Uri.IsWellFormedUriString(url, UriKind.Absolute))
78 throw new Exception(string.Format("[Groups.RemoteConnector]: Malformed groups server URL {0}. Fix it or disable the Groups feature.", url));
79
80 string secret = groupsConfig.GetString("SecretKey", string.Empty);
81 m_GroupsService = new GroupsServiceRemoteConnector(url, secret);
82 m_Scenes = new List<Scene>(); 76 m_Scenes = new List<Scene>();
83 77
84 } 78 }
diff --git a/OpenSim/Addons/Groups/Remote/GroupsServiceRobustConnector.cs b/OpenSim/Addons/Groups/Remote/GroupsServiceRobustConnector.cs
index 828965f..55ae6db 100644
--- a/OpenSim/Addons/Groups/Remote/GroupsServiceRobustConnector.cs
+++ b/OpenSim/Addons/Groups/Remote/GroupsServiceRobustConnector.cs
@@ -36,6 +36,7 @@ using OpenSim.Framework;
36using OpenSim.Server.Base; 36using OpenSim.Server.Base;
37using OpenSim.Services.Interfaces; 37using OpenSim.Services.Interfaces;
38using OpenSim.Framework.Servers.HttpServer; 38using OpenSim.Framework.Servers.HttpServer;
39using OpenSim.Framework.ServiceAuth;
39using OpenSim.Server.Handlers.Base; 40using OpenSim.Server.Handlers.Base;
40using log4net; 41using log4net;
41using OpenMetaverse; 42using OpenMetaverse;
@@ -64,12 +65,14 @@ namespace OpenSim.Groups
64 key = groupsConfig.GetString("SecretKey", string.Empty); 65 key = groupsConfig.GetString("SecretKey", string.Empty);
65 m_log.DebugFormat("[Groups.RobustConnector]: Starting with secret key {0}", key); 66 m_log.DebugFormat("[Groups.RobustConnector]: Starting with secret key {0}", key);
66 } 67 }
67 else 68// else
68 m_log.WarnFormat("[Groups.RobustConnector]: Unable to find {0} section in configuration", m_ConfigName); 69// m_log.DebugFormat("[Groups.RobustConnector]: Unable to find {0} section in configuration", m_ConfigName);
69 70
70 m_GroupsService = new GroupsService(config); 71 m_GroupsService = new GroupsService(config);
71 72
72 server.AddStreamHandler(new GroupsServicePostHandler(m_GroupsService, key)); 73 IServiceAuth auth = ServiceAuth.Create(config, m_ConfigName);
74
75 server.AddStreamHandler(new GroupsServicePostHandler(m_GroupsService, auth));
73 } 76 }
74 } 77 }
75 78
@@ -78,13 +81,11 @@ namespace OpenSim.Groups
78 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 81 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
79 82
80 private GroupsService m_GroupsService; 83 private GroupsService m_GroupsService;
81 private string m_SecretKey = String.Empty;
82 84
83 public GroupsServicePostHandler(GroupsService service, string key) : 85 public GroupsServicePostHandler(GroupsService service, IServiceAuth auth) :
84 base("POST", "/groups") 86 base("POST", "/groups", auth)
85 { 87 {
86 m_GroupsService = service; 88 m_GroupsService = service;
87 m_SecretKey = key;
88 } 89 }
89 90
90 protected override byte[] ProcessRequest(string path, Stream requestData, 91 protected override byte[] ProcessRequest(string path, Stream requestData,
@@ -108,20 +109,6 @@ namespace OpenSim.Groups
108 string method = request["METHOD"].ToString(); 109 string method = request["METHOD"].ToString();
109 request.Remove("METHOD"); 110 request.Remove("METHOD");
110 111
111 if (!String.IsNullOrEmpty(m_SecretKey)) // Verification required
112 {
113 // Sender didn't send key
114 if (!request.ContainsKey("KEY") || (request["KEY"] == null))
115 return FailureResult("This service requires a secret key");
116
117 // Sender sent wrong key
118 if (!m_SecretKey.Equals(request["KEY"]))
119 return FailureResult("Provided key does not match existing one");
120
121 // OK, key matches. Remove it.
122 request.Remove("KEY");
123 }
124
125 m_log.DebugFormat("[Groups.Handler]: {0}", method); 112 m_log.DebugFormat("[Groups.Handler]: {0}", method);
126 switch (method) 113 switch (method)
127 { 114 {
diff --git a/OpenSim/Addons/OfflineIM/OfflineIMRegionModule.cs b/OpenSim/Addons/OfflineIM/OfflineIMRegionModule.cs
index 5ef068a..5340bcd 100644
--- a/OpenSim/Addons/OfflineIM/OfflineIMRegionModule.cs
+++ b/OpenSim/Addons/OfflineIM/OfflineIMRegionModule.cs
@@ -66,7 +66,7 @@ namespace OpenSim.OfflineIM
66 if (serviceLocation == string.Empty) 66 if (serviceLocation == string.Empty)
67 m_OfflineIMService = new OfflineIMService(config); 67 m_OfflineIMService = new OfflineIMService(config);
68 else 68 else
69 m_OfflineIMService = new OfflineIMServiceRemoteConnector(serviceLocation); 69 m_OfflineIMService = new OfflineIMServiceRemoteConnector(config);
70 70
71 m_ForwardOfflineGroupMessages = cnf.GetBoolean("ForwardOfflineGroupMessages", m_ForwardOfflineGroupMessages); 71 m_ForwardOfflineGroupMessages = cnf.GetBoolean("ForwardOfflineGroupMessages", m_ForwardOfflineGroupMessages);
72 m_log.DebugFormat("[OfflineIM.V2]: Offline messages enabled by {0}", Name); 72 m_log.DebugFormat("[OfflineIM.V2]: Offline messages enabled by {0}", Name);
@@ -226,10 +226,6 @@ namespace OpenSim.OfflineIM
226 return; 226 return;
227 } 227 }
228 228
229 Scene scene = FindScene(new UUID(im.fromAgentID));
230 if (scene == null)
231 scene = m_SceneList[0];
232
233 string reason = string.Empty; 229 string reason = string.Empty;
234 bool success = m_OfflineIMService.StoreMessage(im, out reason); 230 bool success = m_OfflineIMService.StoreMessage(im, out reason);
235 231
diff --git a/OpenSim/Addons/OfflineIM/Remote/OfflineIMServiceRemoteConnector.cs b/OpenSim/Addons/OfflineIM/Remote/OfflineIMServiceRemoteConnector.cs
index eb287a4..047b8be 100644
--- a/OpenSim/Addons/OfflineIM/Remote/OfflineIMServiceRemoteConnector.cs
+++ b/OpenSim/Addons/OfflineIM/Remote/OfflineIMServiceRemoteConnector.cs
@@ -32,6 +32,7 @@ using System.Reflection;
32using System.Text; 32using System.Text;
33 33
34using OpenSim.Framework; 34using OpenSim.Framework;
35using OpenSim.Framework.ServiceAuth;
35using OpenSim.Server.Base; 36using OpenSim.Server.Base;
36using OpenSim.Services.Interfaces; 37using OpenSim.Services.Interfaces;
37 38
@@ -46,6 +47,7 @@ namespace OpenSim.OfflineIM
46 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 47 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
47 48
48 private string m_ServerURI = string.Empty; 49 private string m_ServerURI = string.Empty;
50 private IServiceAuth m_Auth;
49 private object m_Lock = new object(); 51 private object m_Lock = new object();
50 52
51 public OfflineIMServiceRemoteConnector(string url) 53 public OfflineIMServiceRemoteConnector(string url)
@@ -65,6 +67,18 @@ namespace OpenSim.OfflineIM
65 67
66 m_ServerURI = cnf.GetString("OfflineMessageURL", string.Empty); 68 m_ServerURI = cnf.GetString("OfflineMessageURL", string.Empty);
67 69
70 /// This is from BaseServiceConnector
71 string authType = Util.GetConfigVarFromSections<string>(config, "AuthType", new string[] { "Network", "Messaging" }, "None");
72
73 switch (authType)
74 {
75 case "BasicHttpAuthentication":
76 m_Auth = new BasicHttpAuthentication(config, "Messaging");
77 break;
78 }
79 ///
80 m_log.DebugFormat("[OfflineIM.V2.RemoteConnector]: Offline IM server at {0} with auth {1}",
81 m_ServerURI, (m_Auth == null ? "None" : m_Auth.GetType().ToString()));
68 } 82 }
69 83
70 #region IOfflineIMService 84 #region IOfflineIMService
@@ -143,7 +157,8 @@ namespace OpenSim.OfflineIM
143 lock (m_Lock) 157 lock (m_Lock)
144 reply = SynchronousRestFormsRequester.MakeRequest("POST", 158 reply = SynchronousRestFormsRequester.MakeRequest("POST",
145 m_ServerURI + "/offlineim", 159 m_ServerURI + "/offlineim",
146 ServerUtils.BuildQueryString(sendData)); 160 ServerUtils.BuildQueryString(sendData),
161 m_Auth);
147 162
148 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse( 163 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(
149 reply); 164 reply);
diff --git a/OpenSim/Addons/OfflineIM/Remote/OfflineIMServiceRobustConnector.cs b/OpenSim/Addons/OfflineIM/Remote/OfflineIMServiceRobustConnector.cs
index ed5c742..c44b6cc 100644
--- a/OpenSim/Addons/OfflineIM/Remote/OfflineIMServiceRobustConnector.cs
+++ b/OpenSim/Addons/OfflineIM/Remote/OfflineIMServiceRobustConnector.cs
@@ -36,6 +36,7 @@ using OpenSim.Framework;
36using OpenSim.Server.Base; 36using OpenSim.Server.Base;
37using OpenSim.Services.Interfaces; 37using OpenSim.Services.Interfaces;
38using OpenSim.Framework.Servers.HttpServer; 38using OpenSim.Framework.Servers.HttpServer;
39using OpenSim.Framework.ServiceAuth;
39using OpenSim.Server.Handlers.Base; 40using OpenSim.Server.Handlers.Base;
40using log4net; 41using log4net;
41using OpenMetaverse; 42using OpenMetaverse;
@@ -59,7 +60,9 @@ namespace OpenSim.OfflineIM
59 60
60 m_OfflineIMService = new OfflineIMService(config); 61 m_OfflineIMService = new OfflineIMService(config);
61 62
62 server.AddStreamHandler(new OfflineIMServicePostHandler(m_OfflineIMService)); 63 IServiceAuth auth = ServiceAuth.Create(config, m_ConfigName);
64
65 server.AddStreamHandler(new OfflineIMServicePostHandler(m_OfflineIMService, auth));
63 } 66 }
64 } 67 }
65 68
@@ -69,8 +72,8 @@ namespace OpenSim.OfflineIM
69 72
70 private IOfflineIMService m_OfflineIMService; 73 private IOfflineIMService m_OfflineIMService;
71 74
72 public OfflineIMServicePostHandler(IOfflineIMService service) : 75 public OfflineIMServicePostHandler(IOfflineIMService service, IServiceAuth auth) :
73 base("POST", "/offlineim") 76 base("POST", "/offlineim", auth)
74 { 77 {
75 m_OfflineIMService = service; 78 m_OfflineIMService = service;
76 } 79 }
diff --git a/OpenSim/Addons/OfflineIM/Service/OfflineIMService.cs b/OpenSim/Addons/OfflineIM/Service/OfflineIMService.cs
index 690c955..02084ff 100644
--- a/OpenSim/Addons/OfflineIM/Service/OfflineIMService.cs
+++ b/OpenSim/Addons/OfflineIM/Service/OfflineIMService.cs
@@ -104,7 +104,7 @@ namespace OpenSim.OfflineIM
104 using (MemoryStream mstream = new MemoryStream()) 104 using (MemoryStream mstream = new MemoryStream())
105 { 105 {
106 XmlWriterSettings settings = new XmlWriterSettings(); 106 XmlWriterSettings settings = new XmlWriterSettings();
107 settings.Encoding = Encoding.UTF8; 107 settings.Encoding = Util.UTF8NoBomEncoding;
108 108
109 using (XmlWriter writer = XmlWriter.Create(mstream, settings)) 109 using (XmlWriter writer = XmlWriter.Create(mstream, settings))
110 { 110 {
@@ -112,7 +112,7 @@ namespace OpenSim.OfflineIM
112 writer.Flush(); 112 writer.Flush();
113 } 113 }
114 114
115 imXml = Util.UTF8.GetString(mstream.ToArray()); 115 imXml = Util.UTF8NoBomEncoding.GetString(mstream.ToArray());
116 } 116 }
117 117
118 OfflineIMData data = new OfflineIMData(); 118 OfflineIMData data = new OfflineIMData();