aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Common/OpenSim.Servers
diff options
context:
space:
mode:
authorAdam Frisby2007-07-11 08:02:47 +0000
committerAdam Frisby2007-07-11 08:02:47 +0000
commit5c7ffdde0b9642a42e8f5987e06eb01220ff7776 (patch)
tree4b825dc642cb6eb9a060e54bf8d69288fbee4904 /Common/OpenSim.Servers
parentWho would have known that the only way of specifying utf-8 without preamble, ... (diff)
downloadopensim-SC-5c7ffdde0b9642a42e8f5987e06eb01220ff7776.zip
opensim-SC-5c7ffdde0b9642a42e8f5987e06eb01220ff7776.tar.gz
opensim-SC-5c7ffdde0b9642a42e8f5987e06eb01220ff7776.tar.bz2
opensim-SC-5c7ffdde0b9642a42e8f5987e06eb01220ff7776.tar.xz
* Wiping trunk in prep for Sugilite
Diffstat (limited to 'Common/OpenSim.Servers')
-rw-r--r--Common/OpenSim.Servers/BaseHttpServer.cs283
-rw-r--r--Common/OpenSim.Servers/BaseServer.cs37
-rw-r--r--Common/OpenSim.Servers/CheckSumServer.cs139
-rw-r--r--Common/OpenSim.Servers/IRestHandler.cs35
-rw-r--r--Common/OpenSim.Servers/LocalUserProfileManager.cs124
-rw-r--r--Common/OpenSim.Servers/LoginResponse.cs669
-rw-r--r--Common/OpenSim.Servers/LoginServer.cs296
-rw-r--r--Common/OpenSim.Servers/OpenSim.Servers.csproj133
-rw-r--r--Common/OpenSim.Servers/OpenSim.Servers.dll.build53
-rw-r--r--Common/OpenSim.Servers/SocketRegistry.cs63
-rw-r--r--Common/OpenSim.Servers/UDPServerBase.cs103
-rw-r--r--Common/OpenSim.Servers/XmlRpcMethod.cs34
12 files changed, 0 insertions, 1969 deletions
diff --git a/Common/OpenSim.Servers/BaseHttpServer.cs b/Common/OpenSim.Servers/BaseHttpServer.cs
deleted file mode 100644
index ec5a6d7..0000000
--- a/Common/OpenSim.Servers/BaseHttpServer.cs
+++ /dev/null
@@ -1,283 +0,0 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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 System.Net;
31using System.Text;
32using System.Text.RegularExpressions;
33using System.Threading;
34//using OpenSim.CAPS;
35using Nwc.XmlRpc;
36using System.Collections;
37using OpenSim.Framework.Console;
38
39namespace OpenSim.Servers
40{
41 public class BaseHttpServer
42 {
43 protected class RestMethodEntry
44 {
45 private string m_path;
46 public string Path
47 {
48 get { return m_path; }
49 }
50
51 private RestMethod m_restMethod;
52 public RestMethod RestMethod
53 {
54 get { return m_restMethod; }
55 }
56
57 public RestMethodEntry(string path, RestMethod restMethod)
58 {
59 m_path = path;
60 m_restMethod = restMethod;
61 }
62 }
63
64 protected Thread m_workerThread;
65 protected HttpListener m_httpListener;
66 protected Dictionary<string, RestMethodEntry> m_restHandlers = new Dictionary<string, RestMethodEntry>();
67 protected Dictionary<string, XmlRpcMethod> m_rpcHandlers = new Dictionary<string, XmlRpcMethod>();
68 protected int m_port;
69
70 public BaseHttpServer(int port)
71 {
72 m_port = port;
73 }
74
75 public bool AddRestHandler(string method, string path, RestMethod handler)
76 {
77 string methodKey = String.Format("{0}: {1}", method, path);
78
79 if (!this.m_restHandlers.ContainsKey(methodKey))
80 {
81 this.m_restHandlers.Add(methodKey, new RestMethodEntry(path, handler));
82 return true;
83 }
84
85 //must already have a handler for that path so return false
86 return false;
87 }
88
89 public bool AddXmlRPCHandler(string method, XmlRpcMethod handler)
90 {
91 if (!this.m_rpcHandlers.ContainsKey(method))
92 {
93 this.m_rpcHandlers.Add(method, handler);
94 return true;
95 }
96
97 //must already have a handler for that path so return false
98 return false;
99 }
100
101 protected virtual string ProcessXMLRPCMethod(string methodName, XmlRpcRequest request)
102 {
103 XmlRpcResponse response;
104
105 XmlRpcMethod method;
106 if (this.m_rpcHandlers.TryGetValue(methodName, out method))
107 {
108 response = method(request);
109 }
110 else
111 {
112 response = new XmlRpcResponse();
113 Hashtable unknownMethodError = new Hashtable();
114 unknownMethodError["reason"] = "XmlRequest"; ;
115 unknownMethodError["message"] = "Unknown Rpc request";
116 unknownMethodError["login"] = "false";
117 response.Value = unknownMethodError;
118 }
119
120 return XmlRpcResponseSerializer.Singleton.Serialize(response);
121 }
122
123 protected virtual string ParseREST(string request, string path, string method)
124 {
125 string response;
126
127 string requestKey = String.Format("{0}: {1}", method, path);
128
129 string bestMatch = String.Empty;
130 foreach (string currentKey in m_restHandlers.Keys)
131 {
132 if (requestKey.StartsWith(currentKey))
133 {
134 if (currentKey.Length > bestMatch.Length)
135 {
136 bestMatch = currentKey;
137 }
138 }
139 }
140
141 RestMethodEntry restMethodEntry;
142 if (m_restHandlers.TryGetValue(bestMatch, out restMethodEntry))
143 {
144 RestMethod restMethod = restMethodEntry.RestMethod;
145
146 string param = path.Substring(restMethodEntry.Path.Length);
147 response = restMethod(request, path, param);
148
149 }
150 else
151 {
152 response = String.Empty;
153 }
154
155 return response;
156 }
157
158 protected virtual string ParseLLSDXML(string requestBody)
159 {
160 // dummy function for now - IMPLEMENT ME!
161 return "";
162 }
163
164 protected virtual string ParseXMLRPC(string requestBody)
165 {
166 string responseString = String.Empty;
167
168 try
169 {
170 XmlRpcRequest request = (XmlRpcRequest)(new XmlRpcRequestDeserializer()).Deserialize(requestBody);
171
172 string methodName = request.MethodName;
173
174 responseString = ProcessXMLRPCMethod(methodName, request);
175 }
176 catch (Exception e)
177 {
178 Console.WriteLine(e.ToString());
179 }
180 return responseString;
181 }
182
183 public virtual void HandleRequest(Object stateinfo)
184 {
185 try
186 {
187 HttpListenerContext context = (HttpListenerContext)stateinfo;
188
189 HttpListenerRequest request = context.Request;
190 HttpListenerResponse response = context.Response;
191
192 response.KeepAlive = false;
193 response.SendChunked = false;
194
195 System.IO.Stream body = request.InputStream;
196 System.Text.Encoding encoding = System.Text.Encoding.UTF8;
197 System.IO.StreamReader reader = new System.IO.StreamReader(body, encoding);
198
199 string requestBody = reader.ReadToEnd();
200 body.Close();
201 reader.Close();
202
203 //Console.WriteLine(request.HttpMethod + " " + request.RawUrl + " Http/" + request.ProtocolVersion.ToString() + " content type: " + request.ContentType);
204 //Console.WriteLine(requestBody);
205
206 string responseString = "";
207 switch (request.ContentType)
208 {
209 case "text/xml":
210 // must be XML-RPC, so pass to the XML-RPC parser
211
212 responseString = ParseXMLRPC(requestBody);
213 responseString = Regex.Replace(responseString, "utf-16", "utf-8");
214
215 response.AddHeader("Content-type", "text/xml");
216 break;
217
218 case "application/xml":
219 // probably LLSD we hope, otherwise it should be ignored by the parser
220 responseString = ParseLLSDXML(requestBody);
221 response.AddHeader("Content-type", "application/xml");
222 break;
223
224 case "application/x-www-form-urlencoded":
225 // a form data POST so send to the REST parser
226 responseString = ParseREST(requestBody, request.RawUrl, request.HttpMethod);
227 response.AddHeader("Content-type", "text/html");
228 break;
229
230 case null:
231 // must be REST or invalid crap, so pass to the REST parser
232 responseString = ParseREST(requestBody, request.RawUrl, request.HttpMethod);
233 response.AddHeader("Content-type", "text/html");
234 break;
235
236 }
237
238 byte[] buffer = System.Text.Encoding.UTF8.GetBytes(responseString);
239 System.IO.Stream output = response.OutputStream;
240 response.SendChunked = false;
241 response.ContentLength64 = buffer.Length;
242 output.Write(buffer, 0, buffer.Length);
243 output.Close();
244 }
245 catch (Exception e)
246 {
247 Console.WriteLine(e.ToString());
248 }
249 }
250
251 public void Start()
252 {
253 MainConsole.Instance.Verbose("BaseHttpServer.cs: Starting up HTTP Server");
254
255 m_workerThread = new Thread(new ThreadStart(StartHTTP));
256 m_workerThread.IsBackground = true;
257 m_workerThread.Start();
258 }
259
260 private void StartHTTP()
261 {
262 try
263 {
264 MainConsole.Instance.Verbose("BaseHttpServer.cs: StartHTTP() - Spawned main thread OK");
265 m_httpListener = new HttpListener();
266
267 m_httpListener.Prefixes.Add("http://+:" + m_port + "/");
268 m_httpListener.Start();
269
270 HttpListenerContext context;
271 while (true)
272 {
273 context = m_httpListener.GetContext();
274 ThreadPool.QueueUserWorkItem(new WaitCallback(HandleRequest), context);
275 }
276 }
277 catch (Exception e)
278 {
279 MainConsole.Instance.Warn(e.Message);
280 }
281 }
282 }
283}
diff --git a/Common/OpenSim.Servers/BaseServer.cs b/Common/OpenSim.Servers/BaseServer.cs
deleted file mode 100644
index f248186..0000000
--- a/Common/OpenSim.Servers/BaseServer.cs
+++ /dev/null
@@ -1,37 +0,0 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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 System.Text;
31
32namespace OpenSim.Servers
33{
34 public class BaseServer
35 {
36 }
37}
diff --git a/Common/OpenSim.Servers/CheckSumServer.cs b/Common/OpenSim.Servers/CheckSumServer.cs
deleted file mode 100644
index b6bfe3a..0000000
--- a/Common/OpenSim.Servers/CheckSumServer.cs
+++ /dev/null
@@ -1,139 +0,0 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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.Text;
30using System.IO;
31using System.Threading;
32using System.Net;
33using System.Net.Sockets;
34using System.Timers;
35using System.Reflection;
36using System.Collections;
37using System.Collections.Generic;
38using libsecondlife;
39using libsecondlife.Packets;
40using OpenSim.Framework.Console;
41
42
43namespace OpenSim.Servers
44{
45 public class CheckSumServer : UDPServerBase
46 {
47 //protected ConsoleBase m_console;
48
49 public CheckSumServer(int port)
50 : base(port)
51 {
52 }
53
54 protected override void OnReceivedData(IAsyncResult result)
55 {
56 ipeSender = new IPEndPoint(IPAddress.Any, 0);
57 epSender = (EndPoint)ipeSender;
58 Packet packet = null;
59 int numBytes = Server.EndReceiveFrom(result, ref epSender);
60 int packetEnd = numBytes - 1;
61
62 packet = Packet.BuildPacket(RecvBuffer, ref packetEnd, ZeroBuffer);
63
64 if (packet.Type == PacketType.SecuredTemplateChecksumRequest)
65 {
66 SecuredTemplateChecksumRequestPacket checksum = (SecuredTemplateChecksumRequestPacket)packet;
67 TemplateChecksumReplyPacket checkreply = new TemplateChecksumReplyPacket();
68 checkreply.DataBlock.Checksum = 3220703154;//180572585;
69 checkreply.DataBlock.Flags = 0;
70 checkreply.DataBlock.MajorVersion = 1;
71 checkreply.DataBlock.MinorVersion = 15;
72 checkreply.DataBlock.PatchVersion = 0;
73 checkreply.DataBlock.ServerVersion = 0;
74 checkreply.TokenBlock.Token = checksum.TokenBlock.Token;
75 this.SendPacket(checkreply, epSender);
76
77 /*
78 //if we wanted to echo the the checksum/ version from the client (so that any client worked)
79 SecuredTemplateChecksumRequestPacket checkrequest = new SecuredTemplateChecksumRequestPacket();
80 checkrequest.TokenBlock.Token = checksum.TokenBlock.Token;
81 this.SendPacket(checkrequest, epSender);
82 */
83 }
84 else if (packet.Type == PacketType.TemplateChecksumReply)
85 {
86 //echo back the client checksum reply (Hegemon's method)
87 TemplateChecksumReplyPacket checksum2 = (TemplateChecksumReplyPacket)packet;
88 TemplateChecksumReplyPacket checkreply2 = new TemplateChecksumReplyPacket();
89 checkreply2.DataBlock.Checksum = checksum2.DataBlock.Checksum;
90 checkreply2.DataBlock.Flags = checksum2.DataBlock.Flags;
91 checkreply2.DataBlock.MajorVersion = checksum2.DataBlock.MajorVersion;
92 checkreply2.DataBlock.MinorVersion = checksum2.DataBlock.MinorVersion;
93 checkreply2.DataBlock.PatchVersion = checksum2.DataBlock.PatchVersion;
94 checkreply2.DataBlock.ServerVersion = checksum2.DataBlock.ServerVersion;
95 checkreply2.TokenBlock.Token = checksum2.TokenBlock.Token;
96 this.SendPacket(checkreply2, epSender);
97 }
98 else
99 {
100 }
101
102 Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null);
103 }
104
105 private void SendPacket(Packet Pack, EndPoint endp)
106 {
107 if (!Pack.Header.Resent)
108 {
109 Pack.Header.Sequence = 1;
110 }
111
112 byte[] ZeroOutBuffer = new byte[4096];
113 byte[] sendbuffer;
114 sendbuffer = Pack.ToBytes();
115
116 try
117 {
118 if (Pack.Header.Zerocoded)
119 {
120 int packetsize = Helpers.ZeroEncode(sendbuffer, sendbuffer.Length, ZeroOutBuffer);
121 this.SendPackTo(ZeroOutBuffer, packetsize, SocketFlags.None, endp);
122 }
123 else
124 {
125 this.SendPackTo(sendbuffer, sendbuffer.Length, SocketFlags.None, endp);
126 }
127 }
128 catch (Exception)
129 {
130 MainConsole.Instance.Warn("OpenSimClient.cs:ProcessOutPacket() - WARNING: Socket exception occurred on connection ");
131 }
132 }
133
134 private void SendPackTo(byte[] buffer, int size, SocketFlags flags, EndPoint endp)
135 {
136 this.Server.SendTo(buffer, size, flags, endp);
137 }
138 }
139} \ No newline at end of file
diff --git a/Common/OpenSim.Servers/IRestHandler.cs b/Common/OpenSim.Servers/IRestHandler.cs
deleted file mode 100644
index 3aa508c..0000000
--- a/Common/OpenSim.Servers/IRestHandler.cs
+++ /dev/null
@@ -1,35 +0,0 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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 System.Text;
31
32namespace OpenSim.Servers
33{
34 public delegate string RestMethod( string request, string path, string param );
35}
diff --git a/Common/OpenSim.Servers/LocalUserProfileManager.cs b/Common/OpenSim.Servers/LocalUserProfileManager.cs
deleted file mode 100644
index 6f65176..0000000
--- a/Common/OpenSim.Servers/LocalUserProfileManager.cs
+++ /dev/null
@@ -1,124 +0,0 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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*/
28
29using System;
30using System.Collections.Generic;
31using System.Collections;
32using System.Text;
33using OpenSim.Framework.User;
34using OpenSim.Framework.Grid;
35using OpenSim.Framework.Inventory;
36using OpenSim.Framework.Interfaces;
37using OpenSim.Framework.Types;
38using libsecondlife;
39
40namespace OpenSim.UserServer
41{
42 public class LocalUserProfileManager : UserProfileManager
43 {
44 private IGridServer m_gridServer;
45 private int m_port;
46 private string m_ipAddr;
47 private uint regionX;
48 private uint regionY;
49 private AddNewSessionHandler AddSession;
50
51 public LocalUserProfileManager(IGridServer gridServer, int simPort, string ipAddr , uint regX, uint regY)
52 {
53 m_gridServer = gridServer;
54 m_port = simPort;
55 m_ipAddr = ipAddr;
56 regionX = regX;
57 regionY = regY;
58 }
59
60 public void SetSessionHandler(AddNewSessionHandler sessionHandler)
61 {
62 this.AddSession = sessionHandler;
63 }
64
65 public override void InitUserProfiles()
66 {
67 base.InitUserProfiles();
68 }
69
70 public override void CustomiseResponse(ref System.Collections.Hashtable response, UserProfile theUser)
71 {
72 Int32 circode = (Int32)response["circuit_code"];
73 theUser.AddSimCircuit((uint)circode, LLUUID.Random());
74 response["home"] = "{'region_handle':[r" + (997 * 256).ToString() + ",r" + (996 * 256).ToString() + "], 'position':[r" + theUser.homepos.X.ToString() + ",r" + theUser.homepos.Y.ToString() + ",r" + theUser.homepos.Z.ToString() + "], 'look_at':[r" + theUser.homelookat.X.ToString() + ",r" + theUser.homelookat.Y.ToString() + ",r" + theUser.homelookat.Z.ToString() + "]}";
75 response["sim_port"] = m_port;
76 response["sim_ip"] = m_ipAddr;
77 response["region_y"] = (Int32)regionY* 256;
78 response["region_x"] = (Int32)regionX* 256;
79
80 string first;
81 string last;
82 if (response.Contains("first_name"))
83 {
84 first = (string)response["first_name"];
85 }
86 else
87 {
88 first = "test";
89 }
90
91 if (response.Contains("last_name"))
92 {
93 last = (string)response["last_name"];
94 }
95 else
96 {
97 last = "User";
98 }
99
100 ArrayList InventoryList = (ArrayList)response["inventory-skeleton"];
101 Hashtable Inventory1 = (Hashtable)InventoryList[0];
102
103 Login _login = new Login();
104 //copy data to login object
105 _login.First = first;
106 _login.Last = last;
107 _login.Agent = new LLUUID((string)response["agent_id"]) ;
108 _login.Session = new LLUUID((string)response["session_id"]);
109 _login.SecureSession = new LLUUID((string)response["secure_session_id"]);
110 _login.CircuitCode =(uint) circode;
111 _login.BaseFolder = null;
112 _login.InventoryFolder = new LLUUID((string)Inventory1["folder_id"]);
113
114 //working on local computer if so lets add to the gridserver's list of sessions?
115 /*if (m_gridServer.GetName() == "Local")
116 {
117 Console.WriteLine("adding login data to gridserver");
118 ((LocalGridBase)this.m_gridServer).AddNewSession(_login);
119 }*/
120
121 this.AddSession(_login);
122 }
123 }
124}
diff --git a/Common/OpenSim.Servers/LoginResponse.cs b/Common/OpenSim.Servers/LoginResponse.cs
deleted file mode 100644
index 9e37409..0000000
--- a/Common/OpenSim.Servers/LoginResponse.cs
+++ /dev/null
@@ -1,669 +0,0 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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*/
28
29using Nwc.XmlRpc;
30using System;
31using System.IO;
32using System.Net;
33using System.Net.Sockets;
34using System.Text;
35using System.Text.RegularExpressions;
36using System.Threading;
37using System.Collections;
38using System.Security.Cryptography;
39using System.Xml;
40using libsecondlife;
41using OpenSim;
42using OpenSim.Framework.User;
43using OpenSim.Framework.Inventory;
44using OpenSim.Framework.Utilities;
45using OpenSim.Framework.Interfaces;
46
47// ?
48using OpenSim.Framework.Grid;
49
50namespace OpenSim.UserServer
51{
52 /// <summary>
53 /// A temp class to handle login response.
54 /// Should make use of UserProfileManager where possible.
55 /// </summary>
56
57 public class LoginResponse
58 {
59 private Hashtable loginFlagsHash;
60 private Hashtable globalTexturesHash;
61 private Hashtable loginError;
62 private Hashtable eventCategoriesHash;
63 private Hashtable uiConfigHash;
64 private Hashtable classifiedCategoriesHash;
65
66 private ArrayList loginFlags;
67 private ArrayList globalTextures;
68 private ArrayList eventCategories;
69 private ArrayList uiConfig;
70 private ArrayList classifiedCategories;
71 private ArrayList inventoryRoot;
72 private ArrayList initialOutfit;
73 private ArrayList agentInventory;
74
75 private UserProfile userProfile;
76
77 private LLUUID agentID;
78 private LLUUID sessionID;
79 private LLUUID secureSessionID;
80 private LLUUID baseFolderID;
81 private LLUUID inventoryFolderID;
82
83 // Login Flags
84 private string dst;
85 private string stipendSinceLogin;
86 private string gendered;
87 private string everLoggedIn;
88 private string login;
89 private string simPort;
90 private string simAddress;
91 private string agentAccess;
92 private Int32 circuitCode;
93 private uint regionX;
94 private uint regionY;
95
96 // Login
97 private string firstname;
98 private string lastname;
99
100 // Global Textures
101 private string sunTexture;
102 private string cloudTexture;
103 private string moonTexture;
104
105 // Error Flags
106 private string errorReason;
107 private string errorMessage;
108
109 // Response
110 private XmlRpcResponse xmlRpcResponse;
111 private XmlRpcResponse defaultXmlRpcResponse;
112
113 private string welcomeMessage;
114 private string startLocation;
115 private string allowFirstLife;
116 private string home;
117 private string seedCapability;
118 private string lookAt;
119
120 public LoginResponse()
121 {
122 this.loginFlags = new ArrayList();
123 this.globalTextures = new ArrayList();
124 this.eventCategories = new ArrayList();
125 this.uiConfig = new ArrayList();
126 this.classifiedCategories = new ArrayList();
127
128 this.loginError = new Hashtable();
129 this.eventCategoriesHash = new Hashtable();
130 this.classifiedCategoriesHash = new Hashtable();
131 this.uiConfigHash = new Hashtable();
132
133 this.defaultXmlRpcResponse = new XmlRpcResponse();
134 this.userProfile = new UserProfile();
135 this.inventoryRoot = new ArrayList();
136 this.initialOutfit = new ArrayList();
137 this.agentInventory = new ArrayList();
138
139 this.xmlRpcResponse = new XmlRpcResponse();
140 this.defaultXmlRpcResponse = new XmlRpcResponse();
141
142 this.SetDefaultValues();
143 } // LoginServer
144
145 public void SetDefaultValues()
146 {
147 try
148 {
149 this.DST = "N";
150 this.StipendSinceLogin = "N";
151 this.Gendered = "Y";
152 this.EverLoggedIn = "Y";
153 this.login = "false";
154 this.firstname = "Test";
155 this.lastname = "User";
156 this.agentAccess = "M";
157 this.startLocation = "last";
158 this.allowFirstLife = "Y";
159
160 this.SunTexture = "cce0f112-878f-4586-a2e2-a8f104bba271";
161 this.CloudTexture = "fc4b9f0b-d008-45c6-96a4-01dd947ac621";
162 this.MoonTexture = "fc4b9f0b-d008-45c6-96a4-01dd947ac621";
163
164 this.ErrorMessage = "You have entered an invalid name/password combination. Check Caps/lock.";
165 this.ErrorReason = "key";
166 this.welcomeMessage = "Welcome to OpenSim!";
167 this.seedCapability = "";
168 this.home = "{'region_handle':[r" + (997 * 256).ToString() + ",r" + (996 * 256).ToString() + "], 'position':[r" + this.userProfile.homepos.X.ToString() + ",r" + this.userProfile.homepos.Y.ToString() + ",r" + this.userProfile.homepos.Z.ToString() + "], 'look_at':[r" + this.userProfile.homelookat.X.ToString() + ",r" + this.userProfile.homelookat.Y.ToString() + ",r" + this.userProfile.homelookat.Z.ToString() + "]}";
169 this.lookAt = "[r0.99949799999999999756,r0.03166859999999999814,r0]";
170 this.RegionX = (uint)255232;
171 this.RegionY = (uint)254976;
172
173 // Classifieds;
174 this.AddClassifiedCategory((Int32)1, "Shopping");
175 this.AddClassifiedCategory((Int32)2, "Land Rental");
176 this.AddClassifiedCategory((Int32)3, "Property Rental");
177 this.AddClassifiedCategory((Int32)4, "Special Attraction");
178 this.AddClassifiedCategory((Int32)5, "New Products");
179 this.AddClassifiedCategory((Int32)6, "Employment");
180 this.AddClassifiedCategory((Int32)7, "Wanted");
181 this.AddClassifiedCategory((Int32)8, "Service");
182 this.AddClassifiedCategory((Int32)9, "Personal");
183
184 int SessionRand = Util.RandomClass.Next(1, 999);
185 this.SessionID = new LLUUID("aaaabbbb-0200-" + SessionRand.ToString("0000") + "-8664-58f53e442797");
186 this.SecureSessionID = LLUUID.Random();
187
188 this.userProfile.Inventory.CreateRootFolder(this.userProfile.UUID, true);
189 this.baseFolderID = this.userProfile.Inventory.GetFolderID("Textures");
190 this.inventoryFolderID = this.userProfile.Inventory.GetFolderID("My Inventory-");
191 Hashtable InventoryRootHash = new Hashtable();
192 InventoryRootHash["folder_id"] = this.userProfile.Inventory.InventoryRoot.FolderID.ToStringHyphenated();
193 this.inventoryRoot.Add(InventoryRootHash);
194
195 Hashtable TempHash;
196 foreach (InventoryFolder InvFolder in this.userProfile.Inventory.InventoryFolders.Values)
197 {
198 TempHash = new Hashtable();
199 TempHash["name"] = InvFolder.FolderName;
200 TempHash["parent_id"] = InvFolder.ParentID.ToStringHyphenated();
201 TempHash["version"] = (Int32)InvFolder.Version;
202 TempHash["type_default"] = (Int32)InvFolder.DefaultType;
203 TempHash["folder_id"] = InvFolder.FolderID.ToStringHyphenated();
204 this.agentInventory.Add(TempHash);
205 }
206
207 Hashtable InitialOutfitHash = new Hashtable();
208 InitialOutfitHash["folder_name"] = "Nightclub Female";
209 InitialOutfitHash["gender"] = "female";
210 this.initialOutfit.Add(InitialOutfitHash);
211 }
212 catch (Exception e)
213 {
214 OpenSim.Framework.Console.MainConsole.Instance.Warn(
215 "LoginResponse: Unable to set default values: " + e.Message
216 );
217 }
218
219 } // SetDefaultValues
220
221 protected virtual LLUUID GetAgentId()
222 {
223 // todo
224 LLUUID Agent;
225 int AgentRand = Util.RandomClass.Next(1, 9999);
226 Agent = new LLUUID("99998888-0100-" + AgentRand.ToString("0000") + "-8ec1-0b1d5cd6aead");
227 return Agent;
228 } // GetAgentId
229
230 private XmlRpcResponse GenerateFailureResponse(string reason, string message, string login)
231 {
232 // Overwrite any default values;
233 this.xmlRpcResponse = new XmlRpcResponse();
234
235 // Ensure Login Failed message/reason;
236 this.ErrorMessage = message;
237 this.ErrorReason = reason;
238
239 this.loginError["reason"] = this.ErrorReason;
240 this.loginError["message"] = this.ErrorMessage;
241 this.loginError["login"] = login;
242 this.xmlRpcResponse.Value = this.loginError;
243 return (this.xmlRpcResponse);
244 } // GenerateResponse
245
246 public XmlRpcResponse LoginFailedResponse()
247 {
248 return (this.GenerateFailureResponse("key", "You have entered an invalid name/password combination. Check Caps/lock.", "false"));
249 } // LoginFailedResponse
250
251 public XmlRpcResponse ConnectionFailedResponse()
252 {
253 return (this.LoginFailedResponse());
254 } // CreateErrorConnectingToGridResponse()
255
256 public XmlRpcResponse CreateAlreadyLoggedInResponse()
257 {
258 return (this.GenerateFailureResponse("presence", "You appear to be already logged in, if this is not the case please wait for your session to timeout, if this takes longer than a few minutes please contact the grid owner", "false"));
259 } // CreateAlreadyLoggedInResponse()
260
261 public XmlRpcResponse ToXmlRpcResponse()
262 {
263 try
264 {
265
266 Hashtable responseData = new Hashtable();
267
268 this.loginFlagsHash = new Hashtable();
269 this.loginFlagsHash["daylight_savings"] = this.DST;
270 this.loginFlagsHash["stipend_since_login"] = this.StipendSinceLogin;
271 this.loginFlagsHash["gendered"] = this.Gendered;
272 this.loginFlagsHash["ever_logged_in"] = this.EverLoggedIn;
273 this.loginFlags.Add(this.loginFlagsHash);
274
275 responseData["first_name"] = this.Firstname;
276 responseData["last_name"] = this.Lastname;
277 responseData["agent_access"] = this.agentAccess;
278
279 this.globalTexturesHash = new Hashtable();
280 this.globalTexturesHash["sun_texture_id"] = this.SunTexture;
281 this.globalTexturesHash["cloud_texture_id"] = this.CloudTexture;
282 this.globalTexturesHash["moon_texture_id"] = this.MoonTexture;
283 this.globalTextures.Add(this.globalTexturesHash);
284 this.eventCategories.Add(this.eventCategoriesHash);
285
286 this.AddToUIConfig("allow_first_life", this.allowFirstLife);
287 this.uiConfig.Add(this.uiConfigHash);
288
289 // Create a agent and session LLUUID
290 this.agentID = this.GetAgentId();
291
292 responseData["sim_port"] = this.SimPort;
293 responseData["sim_ip"] = this.SimAddress;
294 responseData["agent_id"] = this.AgentID.ToStringHyphenated();
295 responseData["session_id"] = this.SessionID.ToStringHyphenated();
296 responseData["secure_session_id"] = this.SecureSessionID.ToStringHyphenated();
297 responseData["circuit_code"] = this.CircuitCode;
298 responseData["seconds_since_epoch"] = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;
299 responseData["login-flags"] = this.loginFlags;
300 responseData["global-textures"] = this.globalTextures;
301 responseData["seed_capability"] = this.seedCapability;
302
303 responseData["event_categories"] = this.eventCategories;
304 responseData["event_notifications"] = new ArrayList(); // todo
305 responseData["classified_categories"] = this.classifiedCategories;
306 responseData["ui-config"] = this.uiConfig;
307
308 responseData["inventory-skeleton"] = this.agentInventory;
309 responseData["inventory-skel-lib"] = new ArrayList(); // todo
310 responseData["inventory-root"] = this.inventoryRoot;
311 responseData["gestures"] = new ArrayList(); // todo
312 responseData["inventory-lib-owner"] = new ArrayList(); // todo
313 responseData["initial-outfit"] = this.initialOutfit;
314 responseData["start_location"] = this.startLocation;
315 responseData["seed_capability"] = this.seedCapability;
316 responseData["home"] = this.home;
317 responseData["look_at"] = this.lookAt;
318 responseData["message"] = this.welcomeMessage;
319 responseData["region_x"] = (Int32)this.RegionX * 256;
320 responseData["region_y"] = (Int32)this.RegionY * 256;
321
322 responseData["login"] = "true";
323 this.xmlRpcResponse.Value = responseData;
324
325 return (this.xmlRpcResponse);
326 }
327 catch (Exception e)
328 {
329 OpenSim.Framework.Console.MainConsole.Instance.Error(
330 "LoginResponse: Error creating XML-RPC Response: " + e.Message
331 );
332 return (this.GenerateFailureResponse("Internal Error", "Error generating Login Response", "false"));
333
334 }
335
336 } // ToXmlRpcResponse
337
338 public void SetEventCategories(string category, string value)
339 {
340 this.eventCategoriesHash[category] = value;
341 } // SetEventCategories
342
343 public void AddToUIConfig(string itemName, string item)
344 {
345 this.uiConfigHash[itemName] = item;
346 } // SetUIConfig
347
348 public void AddClassifiedCategory(Int32 ID, string categoryName)
349 {
350 this.classifiedCategoriesHash["category_name"] = categoryName;
351 this.classifiedCategoriesHash["category_id"] = ID;
352 this.classifiedCategories.Add(this.classifiedCategoriesHash);
353 // this.classifiedCategoriesHash.Clear();
354 } // SetClassifiedCategory
355
356 public string Login
357 {
358 get
359 {
360 return this.login;
361 }
362 set
363 {
364 this.login = value;
365 }
366 } // Login
367
368 public string DST
369 {
370 get
371 {
372 return this.dst;
373 }
374 set
375 {
376 this.dst = value;
377 }
378 } // DST
379
380 public string StipendSinceLogin
381 {
382 get
383 {
384 return this.stipendSinceLogin;
385 }
386 set
387 {
388 this.stipendSinceLogin = value;
389 }
390 } // StipendSinceLogin
391
392 public string Gendered
393 {
394 get
395 {
396 return this.gendered;
397 }
398 set
399 {
400 this.gendered = value;
401 }
402 } // Gendered
403
404 public string EverLoggedIn
405 {
406 get
407 {
408 return this.everLoggedIn;
409 }
410 set
411 {
412 this.everLoggedIn = value;
413 }
414 } // EverLoggedIn
415
416 public string SimPort
417 {
418 get
419 {
420 return this.simPort;
421 }
422 set
423 {
424 this.simPort = value;
425 }
426 } // SimPort
427
428 public string SimAddress
429 {
430 get
431 {
432 return this.simAddress;
433 }
434 set
435 {
436 this.simAddress = value;
437 }
438 } // SimAddress
439
440 public LLUUID AgentID
441 {
442 get
443 {
444 return this.agentID;
445 }
446 set
447 {
448 this.agentID = value;
449 }
450 } // AgentID
451
452 public LLUUID SessionID
453 {
454 get
455 {
456 return this.sessionID;
457 }
458 set
459 {
460 this.sessionID = value;
461 }
462 } // SessionID
463
464 public LLUUID SecureSessionID
465 {
466 get
467 {
468 return this.secureSessionID;
469 }
470 set
471 {
472 this.secureSessionID = value;
473 }
474 } // SecureSessionID
475
476 public LLUUID BaseFolderID
477 {
478 get
479 {
480 return this.baseFolderID;
481 }
482 set
483 {
484 this.baseFolderID = value;
485 }
486 } // BaseFolderID
487
488 public LLUUID InventoryFolderID
489 {
490 get
491 {
492 return this.inventoryFolderID;
493 }
494 set
495 {
496 this.inventoryFolderID = value;
497 }
498 } // InventoryFolderID
499
500 public Int32 CircuitCode
501 {
502 get
503 {
504 return this.circuitCode;
505 }
506 set
507 {
508 this.circuitCode = value;
509 }
510 } // CircuitCode
511
512 public uint RegionX
513 {
514 get
515 {
516 return this.regionX;
517 }
518 set
519 {
520 this.regionX = value;
521 }
522 } // RegionX
523
524 public uint RegionY
525 {
526 get
527 {
528 return this.regionY;
529 }
530 set
531 {
532 this.regionY = value;
533 }
534 } // RegionY
535
536 public string SunTexture
537 {
538 get
539 {
540 return this.sunTexture;
541 }
542 set
543 {
544 this.sunTexture = value;
545 }
546 } // SunTexture
547
548 public string CloudTexture
549 {
550 get
551 {
552 return this.cloudTexture;
553 }
554 set
555 {
556 this.cloudTexture = value;
557 }
558 } // CloudTexture
559
560 public string MoonTexture
561 {
562 get
563 {
564 return this.moonTexture;
565 }
566 set
567 {
568 this.moonTexture = value;
569 }
570 } // MoonTexture
571
572 public string Firstname
573 {
574 get
575 {
576 return this.firstname;
577 }
578 set
579 {
580 this.firstname = value;
581 }
582 } // Firstname
583
584 public string Lastname
585 {
586 get
587 {
588 return this.lastname;
589 }
590 set
591 {
592 this.lastname = value;
593 }
594 } // Lastname
595
596 public string AgentAccess
597 {
598 get
599 {
600 return this.agentAccess;
601 }
602 set
603 {
604 this.agentAccess = value;
605 }
606 }
607
608 public string StartLocation
609 {
610 get
611 {
612 return this.startLocation;
613 }
614 set
615 {
616 this.startLocation = value;
617 }
618 } // StartLocation
619
620 public string LookAt
621 {
622 get
623 {
624 return this.lookAt;
625 }
626 set
627 {
628 this.lookAt = value;
629 }
630 }
631
632 public string SeedCapability
633 {
634 get
635 {
636 return this.seedCapability;
637 }
638 set
639 {
640 this.seedCapability = value;
641 }
642 } // SeedCapability
643
644 public string ErrorReason
645 {
646 get
647 {
648 return this.errorReason;
649 }
650 set
651 {
652 this.errorReason = value;
653 }
654 } // ErrorReason
655
656 public string ErrorMessage
657 {
658 get
659 {
660 return this.errorMessage;
661 }
662 set
663 {
664 this.errorMessage = value;
665 }
666 } // ErrorMessage
667
668 } // LoginResponse
669} // namespace OpenSim.UserServer \ No newline at end of file
diff --git a/Common/OpenSim.Servers/LoginServer.cs b/Common/OpenSim.Servers/LoginServer.cs
deleted file mode 100644
index 4f4d76f..0000000
--- a/Common/OpenSim.Servers/LoginServer.cs
+++ /dev/null
@@ -1,296 +0,0 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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*/
28
29using Nwc.XmlRpc;
30using System;
31using System.IO;
32using System.Net;
33using System.Net.Sockets;
34using System.Text;
35using System.Text.RegularExpressions;
36using System.Threading;
37using System.Collections;
38using System.Security.Cryptography;
39using System.Xml;
40using libsecondlife;
41using OpenSim;
42using OpenSim.Framework.Interfaces;
43using OpenSim.Framework.Grid;
44using OpenSim.Framework.Inventory;
45using OpenSim.Framework.User;
46using OpenSim.Framework.Utilities;
47using OpenSim.Framework.Types;
48
49namespace OpenSim.UserServer
50{
51 public delegate void AddNewSessionHandler(Login loginData);
52 /// <summary>
53 /// When running in local (default) mode , handles client logins.
54 /// </summary>
55 public class LoginServer : LoginService, IUserServer
56 {
57 private IGridServer m_gridServer;
58 public IPAddress clientAddress = IPAddress.Loopback;
59 public IPAddress remoteAddress = IPAddress.Any;
60 private int NumClients;
61 private bool userAccounts = false;
62 private string _mpasswd;
63 private bool _needPasswd = false;
64 private LocalUserProfileManager userManager;
65 private int m_simPort;
66 private string m_simAddr;
67 private uint regionX;
68 private uint regionY;
69 private AddNewSessionHandler AddSession;
70
71 public LocalUserProfileManager LocalUserManager
72 {
73 get
74 {
75 return userManager;
76 }
77 }
78
79 public LoginServer( string simAddr, int simPort, uint regX, uint regY, bool useAccounts)
80 {
81 m_simPort = simPort;
82 m_simAddr = simAddr;
83 regionX = regX;
84 regionY = regY;
85 this.userAccounts = useAccounts;
86 }
87
88 public void SetSessionHandler(AddNewSessionHandler sessionHandler)
89 {
90 this.AddSession = sessionHandler;
91 this.userManager.SetSessionHandler(sessionHandler);
92 }
93
94 public void Startup()
95 {
96 this._needPasswd = false;
97
98 this._mpasswd = EncodePassword("testpass");
99
100 userManager = new LocalUserProfileManager(this.m_gridServer, m_simPort, m_simAddr, regionX, regionY);
101 userManager.InitUserProfiles();
102 userManager.SetKeys("", "", "", "Welcome to OpenSim");
103 }
104
105 public XmlRpcResponse XmlRpcLoginMethod(XmlRpcRequest request)
106 {
107 Console.WriteLine("login attempt");
108 Hashtable requestData = (Hashtable)request.Params[0];
109 string first;
110 string last;
111 string passwd;
112
113 LoginResponse loginResponse = new LoginResponse();
114 loginResponse.RegionX = regionX;
115 loginResponse.RegionY = regionY;
116
117 //get login name
118 if (requestData.Contains("first"))
119 {
120 first = (string)requestData["first"];
121 }
122 else
123 {
124 first = "test";
125 }
126
127 if (requestData.Contains("last"))
128 {
129 last = (string)requestData["last"];
130 }
131 else
132 {
133 last = "User" + NumClients.ToString();
134 }
135
136 if (requestData.Contains("passwd"))
137 {
138 passwd = (string)requestData["passwd"];
139 }
140 else
141 {
142 passwd = "notfound";
143 }
144
145 if (!Authenticate(first, last, passwd))
146 {
147 return loginResponse.LoginFailedResponse();
148 }
149
150 NumClients++;
151
152 // Create a agent and session LLUUID
153 // Agent = GetAgentId(first, last);
154 // int SessionRand = Util.RandomClass.Next(1, 999);
155 // Session = new LLUUID("aaaabbbb-0200-" + SessionRand.ToString("0000") + "-8664-58f53e442797");
156 // LLUUID secureSess = LLUUID.Random();
157
158 loginResponse.SimPort = m_simPort.ToString();
159 // 7 June 2007, AJD:
160 // [10:03:05] (@AdamZaius) Sandbox should work listening on 0.0.0.0 if you can fix the login XML reply
161 // OLD: loginResponse.SimAddress = m_simAddr.ToString();
162 loginResponse.SimAddress = "0.0.0.0";
163
164 // loginResponse.AgentID = Agent.ToStringHyphenated();
165 // loginResponse.SessionID = Session.ToStringHyphenated();
166 // loginResponse.SecureSessionID = secureSess.ToStringHyphenated();
167 loginResponse.CircuitCode = (Int32)(Util.RandomClass.Next());
168 XmlRpcResponse response = loginResponse.ToXmlRpcResponse();
169 Hashtable responseData = (Hashtable)response.Value;
170
171 //inventory
172 /* ArrayList InventoryList = (ArrayList)responseData["inventory-skeleton"];
173 Hashtable Inventory1 = (Hashtable)InventoryList[0];
174 Hashtable Inventory2 = (Hashtable)InventoryList[1];
175 LLUUID BaseFolderID = LLUUID.Random();
176 LLUUID InventoryFolderID = LLUUID.Random();
177 Inventory2["name"] = "Textures";
178 Inventory2["folder_id"] = BaseFolderID.ToStringHyphenated();
179 Inventory2["type_default"] = 0;
180 Inventory1["folder_id"] = InventoryFolderID.ToStringHyphenated();
181
182 ArrayList InventoryRoot = (ArrayList)responseData["inventory-root"];
183 Hashtable Inventoryroot = (Hashtable)InventoryRoot[0];
184 Inventoryroot["folder_id"] = InventoryFolderID.ToStringHyphenated();
185 */
186 CustomiseLoginResponse(responseData, first, last);
187
188 Login _login = new Login();
189 //copy data to login object
190 _login.First = first;
191 _login.Last = last;
192 _login.Agent = loginResponse.AgentID;
193 _login.Session = loginResponse.SessionID;
194 _login.SecureSession = loginResponse.SecureSessionID;
195 _login.CircuitCode = (uint) loginResponse.CircuitCode;
196 _login.BaseFolder = loginResponse.BaseFolderID;
197 _login.InventoryFolder = loginResponse.InventoryFolderID;
198
199 //working on local computer if so lets add to the gridserver's list of sessions?
200 /* if (m_gridServer.GetName() == "Local")
201 {
202 ((LocalGridBase)m_gridServer).AddNewSession(_login);
203 }*/
204 AddSession(_login);
205
206 return response;
207 }
208
209 protected virtual void CustomiseLoginResponse(Hashtable responseData, string first, string last)
210 {
211 }
212
213 protected virtual LLUUID GetAgentId(string firstName, string lastName)
214 {
215 LLUUID Agent;
216 int AgentRand = Util.RandomClass.Next(1, 9999);
217 Agent = new LLUUID("99998888-0100-" + AgentRand.ToString("0000") + "-8ec1-0b1d5cd6aead");
218 return Agent;
219 }
220
221 protected virtual bool Authenticate(string first, string last, string passwd)
222 {
223 if (this._needPasswd)
224 {
225 //every user needs the password to login
226 string encodedPass = passwd.Remove(0, 3); //remove $1$
227 if (encodedPass == this._mpasswd)
228 {
229 return true;
230 }
231 else
232 {
233 return false;
234 }
235 }
236 else
237 {
238 //do not need password to login
239 return true;
240 }
241 }
242
243 private static string EncodePassword(string passwd)
244 {
245 Byte[] originalBytes;
246 Byte[] encodedBytes;
247 MD5 md5;
248
249 md5 = new MD5CryptoServiceProvider();
250 originalBytes = ASCIIEncoding.Default.GetBytes(passwd);
251 encodedBytes = md5.ComputeHash(originalBytes);
252
253 return Regex.Replace(BitConverter.ToString(encodedBytes), "-", "").ToLower();
254 }
255
256 public bool CreateUserAccount(string firstName, string lastName, string password)
257 {
258 Console.WriteLine("creating new user account");
259 string mdPassword = EncodePassword(password);
260 Console.WriteLine("with password: " + mdPassword);
261 this.userManager.CreateNewProfile(firstName, lastName, mdPassword);
262
263 return true;
264 }
265
266 public UserProfile GetProfileByName(string firstName, string lastName)
267 {
268 return this.userManager.GetProfileByName(firstName, lastName);
269 }
270
271
272 //IUserServer implementation
273 public AgentInventory RequestAgentsInventory(LLUUID agentID)
274 {
275 AgentInventory aInventory = null;
276 if (this.userAccounts)
277 {
278 aInventory = this.userManager.GetUsersInventory(agentID);
279 }
280
281 return aInventory;
282 }
283
284 public bool UpdateAgentsInventory(LLUUID agentID, AgentInventory inventory)
285 {
286 return true;
287 }
288
289 public void SetServerInfo(string ServerUrl, string SendKey, string RecvKey)
290 {
291
292 }
293 }
294
295
296}
diff --git a/Common/OpenSim.Servers/OpenSim.Servers.csproj b/Common/OpenSim.Servers/OpenSim.Servers.csproj
deleted file mode 100644
index 7a99206..0000000
--- a/Common/OpenSim.Servers/OpenSim.Servers.csproj
+++ /dev/null
@@ -1,133 +0,0 @@
1<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2 <PropertyGroup>
3 <ProjectType>Local</ProjectType>
4 <ProductVersion>8.0.50727</ProductVersion>
5 <SchemaVersion>2.0</SchemaVersion>
6 <ProjectGuid>{8BB20F0A-0000-0000-0000-000000000000}</ProjectGuid>
7 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
8 <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
9 <ApplicationIcon></ApplicationIcon>
10 <AssemblyKeyContainerName>
11 </AssemblyKeyContainerName>
12 <AssemblyName>OpenSim.Servers</AssemblyName>
13 <DefaultClientScript>JScript</DefaultClientScript>
14 <DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>
15 <DefaultTargetSchema>IE50</DefaultTargetSchema>
16 <DelaySign>false</DelaySign>
17 <OutputType>Library</OutputType>
18 <AppDesignerFolder></AppDesignerFolder>
19 <RootNamespace>OpenSim.Servers</RootNamespace>
20 <StartupObject></StartupObject>
21 <FileUpgradeFlags>
22 </FileUpgradeFlags>
23 </PropertyGroup>
24 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
25 <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
26 <BaseAddress>285212672</BaseAddress>
27 <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
28 <ConfigurationOverrideFile>
29 </ConfigurationOverrideFile>
30 <DefineConstants>TRACE;DEBUG</DefineConstants>
31 <DocumentationFile></DocumentationFile>
32 <DebugSymbols>True</DebugSymbols>
33 <FileAlignment>4096</FileAlignment>
34 <Optimize>False</Optimize>
35 <OutputPath>..\..\bin\</OutputPath>
36 <RegisterForComInterop>False</RegisterForComInterop>
37 <RemoveIntegerChecks>False</RemoveIntegerChecks>
38 <TreatWarningsAsErrors>False</TreatWarningsAsErrors>
39 <WarningLevel>4</WarningLevel>
40 <NoWarn></NoWarn>
41 </PropertyGroup>
42 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
43 <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
44 <BaseAddress>285212672</BaseAddress>
45 <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
46 <ConfigurationOverrideFile>
47 </ConfigurationOverrideFile>
48 <DefineConstants>TRACE</DefineConstants>
49 <DocumentationFile></DocumentationFile>
50 <DebugSymbols>False</DebugSymbols>
51 <FileAlignment>4096</FileAlignment>
52 <Optimize>True</Optimize>
53 <OutputPath>..\..\bin\</OutputPath>
54 <RegisterForComInterop>False</RegisterForComInterop>
55 <RemoveIntegerChecks>False</RemoveIntegerChecks>
56 <TreatWarningsAsErrors>False</TreatWarningsAsErrors>
57 <WarningLevel>4</WarningLevel>
58 <NoWarn></NoWarn>
59 </PropertyGroup>
60 <ItemGroup>
61 <Reference Include="libsecondlife.dll" >
62 <HintPath>..\..\bin\libsecondlife.dll</HintPath>
63 <Private>False</Private>
64 </Reference>
65 <Reference Include="System" >
66 <HintPath>System.dll</HintPath>
67 <Private>False</Private>
68 </Reference>
69 <Reference Include="System.Xml" >
70 <HintPath>System.Xml.dll</HintPath>
71 <Private>False</Private>
72 </Reference>
73 </ItemGroup>
74 <ItemGroup>
75 <ProjectReference Include="..\OpenSim.Framework\OpenSim.Framework.csproj">
76 <Name>OpenSim.Framework</Name>
77 <Project>{8ACA2445-0000-0000-0000-000000000000}</Project>
78 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
79 <Private>False</Private>
80 </ProjectReference>
81 <ProjectReference Include="..\OpenSim.Framework.Console\OpenSim.Framework.Console.csproj">
82 <Name>OpenSim.Framework.Console</Name>
83 <Project>{A7CD0630-0000-0000-0000-000000000000}</Project>
84 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
85 <Private>False</Private>
86 </ProjectReference>
87 <ProjectReference Include="..\XmlRpcCS\XMLRPC.csproj">
88 <Name>XMLRPC</Name>
89 <Project>{8E81D43C-0000-0000-0000-000000000000}</Project>
90 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
91 <Private>False</Private>
92 </ProjectReference>
93 </ItemGroup>
94 <ItemGroup>
95 <Compile Include="BaseHttpServer.cs">
96 <SubType>Code</SubType>
97 </Compile>
98 <Compile Include="BaseServer.cs">
99 <SubType>Code</SubType>
100 </Compile>
101 <Compile Include="CheckSumServer.cs">
102 <SubType>Code</SubType>
103 </Compile>
104 <Compile Include="IRestHandler.cs">
105 <SubType>Code</SubType>
106 </Compile>
107 <Compile Include="LocalUserProfileManager.cs">
108 <SubType>Code</SubType>
109 </Compile>
110 <Compile Include="LoginResponse.cs">
111 <SubType>Code</SubType>
112 </Compile>
113 <Compile Include="LoginServer.cs">
114 <SubType>Code</SubType>
115 </Compile>
116 <Compile Include="SocketRegistry.cs">
117 <SubType>Code</SubType>
118 </Compile>
119 <Compile Include="UDPServerBase.cs">
120 <SubType>Code</SubType>
121 </Compile>
122 <Compile Include="XmlRpcMethod.cs">
123 <SubType>Code</SubType>
124 </Compile>
125 </ItemGroup>
126 <Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />
127 <PropertyGroup>
128 <PreBuildEvent>
129 </PreBuildEvent>
130 <PostBuildEvent>
131 </PostBuildEvent>
132 </PropertyGroup>
133</Project>
diff --git a/Common/OpenSim.Servers/OpenSim.Servers.dll.build b/Common/OpenSim.Servers/OpenSim.Servers.dll.build
deleted file mode 100644
index 6147ea7..0000000
--- a/Common/OpenSim.Servers/OpenSim.Servers.dll.build
+++ /dev/null
@@ -1,53 +0,0 @@
1<?xml version="1.0" ?>
2<project name="OpenSim.Servers" default="build">
3 <target name="build">
4 <echo message="Build Directory is ${project::get-base-directory()}/${build.dir}" />
5 <mkdir dir="${project::get-base-directory()}/${build.dir}" />
6 <copy todir="${project::get-base-directory()}/${build.dir}">
7 <fileset basedir="${project::get-base-directory()}">
8 </fileset>
9 </copy>
10 <csc target="library" debug="${build.debug}" unsafe="False" define="TRACE;DEBUG" output="${project::get-base-directory()}/${build.dir}/${project::get-name()}.dll">
11 <resources prefix="OpenSim.Servers" dynamicprefix="true" >
12 </resources>
13 <sources failonempty="true">
14 <include name="BaseHttpServer.cs" />
15 <include name="BaseServer.cs" />
16 <include name="CheckSumServer.cs" />
17 <include name="IRestHandler.cs" />
18 <include name="LocalUserProfileManager.cs" />
19 <include name="LoginResponse.cs" />
20 <include name="LoginServer.cs" />
21 <include name="SocketRegistry.cs" />
22 <include name="UDPServerBase.cs" />
23 <include name="XmlRpcMethod.cs" />
24 </sources>
25 <references basedir="${project::get-base-directory()}">
26 <lib>
27 <include name="${project::get-base-directory()}" />
28 <include name="${project::get-base-directory()}/${build.dir}" />
29 </lib>
30 <include name="../../bin/libsecondlife.dll" />
31 <include name="../../bin/OpenSim.Framework.dll" />
32 <include name="../../bin/OpenSim.Framework.Console.dll" />
33 <include name="System.dll" />
34 <include name="System.Xml.dll" />
35 <include name="../../bin/XMLRPC.dll" />
36 </references>
37 </csc>
38 <echo message="Copying from [${project::get-base-directory()}/${build.dir}/] to [${project::get-base-directory()}/../../bin/" />
39 <mkdir dir="${project::get-base-directory()}/../../bin/"/>
40 <copy todir="${project::get-base-directory()}/../../bin/">
41 <fileset basedir="${project::get-base-directory()}/${build.dir}/" >
42 <include name="*.dll"/>
43 <include name="*.exe"/>
44 </fileset>
45 </copy>
46 </target>
47 <target name="clean">
48 <delete dir="${bin.dir}" failonerror="false" />
49 <delete dir="${obj.dir}" failonerror="false" />
50 </target>
51 <target name="doc" description="Creates documentation.">
52 </target>
53</project>
diff --git a/Common/OpenSim.Servers/SocketRegistry.cs b/Common/OpenSim.Servers/SocketRegistry.cs
deleted file mode 100644
index 2ebf80c..0000000
--- a/Common/OpenSim.Servers/SocketRegistry.cs
+++ /dev/null
@@ -1,63 +0,0 @@
1/*
2 * Created by SharpDevelop.
3 * User: Adam Stevenson
4 * Date: 6/13/2007
5 * Time: 12:55 AM
6 *
7 * To change this template use Tools | Options | Coding | Edit Standard Headers.
8 */
9
10using System;
11using System.Collections.Generic;
12using System.Net;
13using System.Net.Sockets;
14
15namespace OpenSim.Servers
16{
17 /// <summary>
18 ///
19 /// </summary>
20 public class SocketRegistry
21 {
22 static List<Socket> _Sockets;
23
24 static SocketRegistry()
25 {
26 _Sockets = new List<Socket>();
27 }
28
29 private SocketRegistry()
30 {
31
32 }
33
34 public static void Register(Socket pSocket)
35 {
36 _Sockets.Add(pSocket);
37 }
38
39 public static void Unregister(Socket pSocket)
40 {
41 _Sockets.Remove(pSocket);
42 }
43
44 public static void UnregisterAllAndClose()
45 {
46 int iSockets = _Sockets.Count;
47
48 for (int i = 0; i < iSockets; i++)
49 {
50 try
51 {
52 _Sockets[i].Close();
53 }
54 catch
55 {
56
57 }
58 }
59
60 _Sockets.Clear();
61 }
62 }
63}
diff --git a/Common/OpenSim.Servers/UDPServerBase.cs b/Common/OpenSim.Servers/UDPServerBase.cs
deleted file mode 100644
index b763315..0000000
--- a/Common/OpenSim.Servers/UDPServerBase.cs
+++ /dev/null
@@ -1,103 +0,0 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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.Text;
30using System.IO;
31using System.Threading;
32using System.Net;
33using System.Net.Sockets;
34using System.Timers;
35using System.Reflection;
36using System.Collections;
37using System.Collections.Generic;
38using libsecondlife;
39using libsecondlife.Packets;
40
41namespace OpenSim.Servers
42{
43 public class UDPServerBase
44 {
45 public Socket Server;
46 protected IPEndPoint ServerIncoming;
47 protected byte[] RecvBuffer = new byte[4096];
48 protected byte[] ZeroBuffer = new byte[8192];
49 protected IPEndPoint ipeSender;
50 protected EndPoint epSender;
51 protected AsyncCallback ReceivedData;
52 protected int listenPort;
53
54 public UDPServerBase(int port)
55 {
56 listenPort = port;
57 }
58
59 protected virtual void OnReceivedData(IAsyncResult result)
60 {
61 ipeSender = new IPEndPoint(IPAddress.Any, 0);
62 epSender = (EndPoint)ipeSender;
63 Packet packet = null;
64 int numBytes = Server.EndReceiveFrom(result, ref epSender);
65 int packetEnd = numBytes - 1;
66
67 packet = Packet.BuildPacket(RecvBuffer, ref packetEnd, ZeroBuffer);
68
69 Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null);
70 }
71
72 protected virtual void AddNewClient(Packet packet)
73 {
74 }
75
76 public virtual void ServerListener()
77 {
78
79 ServerIncoming = new IPEndPoint(IPAddress.Any, listenPort);
80 Server = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
81
82 /// Add this new socket to the list of sockets that was opened by the application. When the application
83 /// closes, either gracefully or not, all sockets can be cleaned up. Right now I am not aware of any method
84 /// to get all of the sockets for a process within .NET, but if so, this process can be refactored, as
85 /// socket registration would not be neccessary.
86 SocketRegistry.Register(Server);
87
88 Server.Bind(ServerIncoming);
89
90 ipeSender = new IPEndPoint(IPAddress.Any, 0);
91 epSender = (EndPoint)ipeSender;
92 ReceivedData = new AsyncCallback(this.OnReceivedData);
93 Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null);
94 }
95
96 public virtual void SendPacketTo(byte[] buffer, int size, SocketFlags flags, uint circuitcode)
97 {
98
99 }
100 }
101}
102
103
diff --git a/Common/OpenSim.Servers/XmlRpcMethod.cs b/Common/OpenSim.Servers/XmlRpcMethod.cs
deleted file mode 100644
index 05cbf2e..0000000
--- a/Common/OpenSim.Servers/XmlRpcMethod.cs
+++ /dev/null
@@ -1,34 +0,0 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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 Nwc.XmlRpc;
30
31namespace OpenSim.Servers
32{
33 public delegate XmlRpcResponse XmlRpcMethod( XmlRpcRequest request );
34}