diff options
Diffstat (limited to 'Common/OpenSim.Servers')
-rw-r--r-- | Common/OpenSim.Servers/BaseHttpServer.cs | 256 | ||||
-rw-r--r-- | Common/OpenSim.Servers/BaseServer.cs | 10 | ||||
-rw-r--r-- | Common/OpenSim.Servers/CheckSumServer.cs | 113 | ||||
-rw-r--r-- | Common/OpenSim.Servers/IRestHandler.cs | 8 | ||||
-rw-r--r-- | Common/OpenSim.Servers/LocalUserProfileManager.cs | 123 | ||||
-rw-r--r-- | Common/OpenSim.Servers/LoginResponse.cs | 670 | ||||
-rw-r--r-- | Common/OpenSim.Servers/LoginServer.cs | 284 | ||||
-rw-r--r-- | Common/OpenSim.Servers/OpenSim.Servers.csproj | 130 | ||||
-rw-r--r-- | Common/OpenSim.Servers/OpenSim.Servers.csproj.user | 12 | ||||
-rw-r--r-- | Common/OpenSim.Servers/OpenSim.Servers.dll.build | 52 | ||||
-rw-r--r-- | Common/OpenSim.Servers/UDPServerBase.cs | 68 | ||||
-rw-r--r-- | Common/OpenSim.Servers/XmlRpcMethod.cs | 7 |
12 files changed, 1733 insertions, 0 deletions
diff --git a/Common/OpenSim.Servers/BaseHttpServer.cs b/Common/OpenSim.Servers/BaseHttpServer.cs new file mode 100644 index 0000000..38f4370 --- /dev/null +++ b/Common/OpenSim.Servers/BaseHttpServer.cs | |||
@@ -0,0 +1,256 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.Net; | ||
4 | using System.Text; | ||
5 | using System.Text.RegularExpressions; | ||
6 | using System.Threading; | ||
7 | //using OpenSim.CAPS; | ||
8 | using Nwc.XmlRpc; | ||
9 | using System.Collections; | ||
10 | using OpenSim.Framework.Console; | ||
11 | |||
12 | namespace OpenSim.Servers | ||
13 | { | ||
14 | public class BaseHttpServer | ||
15 | { | ||
16 | protected class RestMethodEntry | ||
17 | { | ||
18 | private string m_path; | ||
19 | public string Path | ||
20 | { | ||
21 | get { return m_path; } | ||
22 | } | ||
23 | |||
24 | private RestMethod m_restMethod; | ||
25 | public RestMethod RestMethod | ||
26 | { | ||
27 | get { return m_restMethod; } | ||
28 | } | ||
29 | |||
30 | public RestMethodEntry(string path, RestMethod restMethod) | ||
31 | { | ||
32 | m_path = path; | ||
33 | m_restMethod = restMethod; | ||
34 | } | ||
35 | } | ||
36 | |||
37 | protected Thread m_workerThread; | ||
38 | protected HttpListener m_httpListener; | ||
39 | protected Dictionary<string, RestMethodEntry> m_restHandlers = new Dictionary<string, RestMethodEntry>(); | ||
40 | protected Dictionary<string, XmlRpcMethod> m_rpcHandlers = new Dictionary<string, XmlRpcMethod>(); | ||
41 | protected int m_port; | ||
42 | |||
43 | public BaseHttpServer(int port) | ||
44 | { | ||
45 | m_port = port; | ||
46 | } | ||
47 | |||
48 | public bool AddRestHandler(string method, string path, RestMethod handler) | ||
49 | { | ||
50 | string methodKey = String.Format("{0}: {1}", method, path); | ||
51 | |||
52 | if (!this.m_restHandlers.ContainsKey(methodKey)) | ||
53 | { | ||
54 | this.m_restHandlers.Add(methodKey, new RestMethodEntry(path, handler)); | ||
55 | return true; | ||
56 | } | ||
57 | |||
58 | //must already have a handler for that path so return false | ||
59 | return false; | ||
60 | } | ||
61 | |||
62 | public bool AddXmlRPCHandler(string method, XmlRpcMethod handler) | ||
63 | { | ||
64 | if (!this.m_rpcHandlers.ContainsKey(method)) | ||
65 | { | ||
66 | this.m_rpcHandlers.Add(method, handler); | ||
67 | return true; | ||
68 | } | ||
69 | |||
70 | //must already have a handler for that path so return false | ||
71 | return false; | ||
72 | } | ||
73 | |||
74 | protected virtual string ProcessXMLRPCMethod(string methodName, XmlRpcRequest request) | ||
75 | { | ||
76 | XmlRpcResponse response; | ||
77 | |||
78 | XmlRpcMethod method; | ||
79 | if (this.m_rpcHandlers.TryGetValue(methodName, out method)) | ||
80 | { | ||
81 | response = method(request); | ||
82 | } | ||
83 | else | ||
84 | { | ||
85 | response = new XmlRpcResponse(); | ||
86 | Hashtable unknownMethodError = new Hashtable(); | ||
87 | unknownMethodError["reason"] = "XmlRequest"; ; | ||
88 | unknownMethodError["message"] = "Unknown Rpc request"; | ||
89 | unknownMethodError["login"] = "false"; | ||
90 | response.Value = unknownMethodError; | ||
91 | } | ||
92 | |||
93 | return XmlRpcResponseSerializer.Singleton.Serialize(response); | ||
94 | } | ||
95 | |||
96 | protected virtual string ParseREST(string request, string path, string method) | ||
97 | { | ||
98 | string response; | ||
99 | |||
100 | string requestKey = String.Format("{0}: {1}", method, path); | ||
101 | |||
102 | string bestMatch = String.Empty; | ||
103 | foreach (string currentKey in m_restHandlers.Keys) | ||
104 | { | ||
105 | if (requestKey.StartsWith(currentKey)) | ||
106 | { | ||
107 | if (currentKey.Length > bestMatch.Length) | ||
108 | { | ||
109 | bestMatch = currentKey; | ||
110 | } | ||
111 | } | ||
112 | } | ||
113 | |||
114 | RestMethodEntry restMethodEntry; | ||
115 | if (m_restHandlers.TryGetValue(bestMatch, out restMethodEntry)) | ||
116 | { | ||
117 | RestMethod restMethod = restMethodEntry.RestMethod; | ||
118 | |||
119 | string param = path.Substring(restMethodEntry.Path.Length); | ||
120 | response = restMethod(request, path, param); | ||
121 | |||
122 | } | ||
123 | else | ||
124 | { | ||
125 | response = String.Empty; | ||
126 | } | ||
127 | |||
128 | return response; | ||
129 | } | ||
130 | |||
131 | protected virtual string ParseLLSDXML(string requestBody) | ||
132 | { | ||
133 | // dummy function for now - IMPLEMENT ME! | ||
134 | return ""; | ||
135 | } | ||
136 | |||
137 | protected virtual string ParseXMLRPC(string requestBody) | ||
138 | { | ||
139 | string responseString = String.Empty; | ||
140 | |||
141 | try | ||
142 | { | ||
143 | XmlRpcRequest request = (XmlRpcRequest)(new XmlRpcRequestDeserializer()).Deserialize(requestBody); | ||
144 | |||
145 | string methodName = request.MethodName; | ||
146 | |||
147 | responseString = ProcessXMLRPCMethod(methodName, request); | ||
148 | } | ||
149 | catch (Exception e) | ||
150 | { | ||
151 | Console.WriteLine(e.ToString()); | ||
152 | } | ||
153 | return responseString; | ||
154 | } | ||
155 | |||
156 | public virtual void HandleRequest(Object stateinfo) | ||
157 | { | ||
158 | try | ||
159 | { | ||
160 | HttpListenerContext context = (HttpListenerContext)stateinfo; | ||
161 | |||
162 | HttpListenerRequest request = context.Request; | ||
163 | HttpListenerResponse response = context.Response; | ||
164 | |||
165 | response.KeepAlive = false; | ||
166 | response.SendChunked = false; | ||
167 | |||
168 | System.IO.Stream body = request.InputStream; | ||
169 | System.Text.Encoding encoding = System.Text.Encoding.UTF8; | ||
170 | System.IO.StreamReader reader = new System.IO.StreamReader(body, encoding); | ||
171 | |||
172 | string requestBody = reader.ReadToEnd(); | ||
173 | body.Close(); | ||
174 | reader.Close(); | ||
175 | |||
176 | //Console.WriteLine(request.HttpMethod + " " + request.RawUrl + " Http/" + request.ProtocolVersion.ToString() + " content type: " + request.ContentType); | ||
177 | //Console.WriteLine(requestBody); | ||
178 | |||
179 | string responseString = ""; | ||
180 | switch (request.ContentType) | ||
181 | { | ||
182 | case "text/xml": | ||
183 | // must be XML-RPC, so pass to the XML-RPC parser | ||
184 | |||
185 | responseString = ParseXMLRPC(requestBody); | ||
186 | responseString = Regex.Replace(responseString, "utf-16", "utf-8"); | ||
187 | |||
188 | response.AddHeader("Content-type", "text/xml"); | ||
189 | break; | ||
190 | |||
191 | case "application/xml": | ||
192 | // probably LLSD we hope, otherwise it should be ignored by the parser | ||
193 | responseString = ParseLLSDXML(requestBody); | ||
194 | response.AddHeader("Content-type", "application/xml"); | ||
195 | break; | ||
196 | |||
197 | case "application/x-www-form-urlencoded": | ||
198 | // a form data POST so send to the REST parser | ||
199 | responseString = ParseREST(requestBody, request.RawUrl, request.HttpMethod); | ||
200 | response.AddHeader("Content-type", "text/html"); | ||
201 | break; | ||
202 | |||
203 | case null: | ||
204 | // must be REST or invalid crap, so pass to the REST parser | ||
205 | responseString = ParseREST(requestBody, request.RawUrl, request.HttpMethod); | ||
206 | response.AddHeader("Content-type", "text/html"); | ||
207 | break; | ||
208 | |||
209 | } | ||
210 | |||
211 | byte[] buffer = System.Text.Encoding.UTF8.GetBytes(responseString); | ||
212 | System.IO.Stream output = response.OutputStream; | ||
213 | response.SendChunked = false; | ||
214 | response.ContentLength64 = buffer.Length; | ||
215 | output.Write(buffer, 0, buffer.Length); | ||
216 | output.Close(); | ||
217 | } | ||
218 | catch (Exception e) | ||
219 | { | ||
220 | Console.WriteLine(e.ToString()); | ||
221 | } | ||
222 | } | ||
223 | |||
224 | public void Start() | ||
225 | { | ||
226 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine(LogPriority.LOW, "BaseHttpServer.cs: Starting up HTTP Server"); | ||
227 | |||
228 | m_workerThread = new Thread(new ThreadStart(StartHTTP)); | ||
229 | m_workerThread.IsBackground = true; | ||
230 | m_workerThread.Start(); | ||
231 | } | ||
232 | |||
233 | private void StartHTTP() | ||
234 | { | ||
235 | try | ||
236 | { | ||
237 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine(LogPriority.LOW, "BaseHttpServer.cs: StartHTTP() - Spawned main thread OK"); | ||
238 | m_httpListener = new HttpListener(); | ||
239 | |||
240 | m_httpListener.Prefixes.Add("http://+:" + m_port + "/"); | ||
241 | m_httpListener.Start(); | ||
242 | |||
243 | HttpListenerContext context; | ||
244 | while (true) | ||
245 | { | ||
246 | context = m_httpListener.GetContext(); | ||
247 | ThreadPool.QueueUserWorkItem(new WaitCallback(HandleRequest), context); | ||
248 | } | ||
249 | } | ||
250 | catch (Exception e) | ||
251 | { | ||
252 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine(LogPriority.MEDIUM, e.Message); | ||
253 | } | ||
254 | } | ||
255 | } | ||
256 | } | ||
diff --git a/Common/OpenSim.Servers/BaseServer.cs b/Common/OpenSim.Servers/BaseServer.cs new file mode 100644 index 0000000..0a4c498 --- /dev/null +++ b/Common/OpenSim.Servers/BaseServer.cs | |||
@@ -0,0 +1,10 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.Text; | ||
4 | |||
5 | namespace OpenSim.Servers | ||
6 | { | ||
7 | public class BaseServer | ||
8 | { | ||
9 | } | ||
10 | } | ||
diff --git a/Common/OpenSim.Servers/CheckSumServer.cs b/Common/OpenSim.Servers/CheckSumServer.cs new file mode 100644 index 0000000..1125baf --- /dev/null +++ b/Common/OpenSim.Servers/CheckSumServer.cs | |||
@@ -0,0 +1,113 @@ | |||
1 | using System; | ||
2 | using System.Text; | ||
3 | using System.IO; | ||
4 | using System.Threading; | ||
5 | using System.Net; | ||
6 | using System.Net.Sockets; | ||
7 | using System.Timers; | ||
8 | using System.Reflection; | ||
9 | using System.Collections; | ||
10 | using System.Collections.Generic; | ||
11 | using libsecondlife; | ||
12 | using libsecondlife.Packets; | ||
13 | using OpenSim.Framework.Console; | ||
14 | |||
15 | |||
16 | namespace OpenSim.Servers | ||
17 | { | ||
18 | public class CheckSumServer : UDPServerBase | ||
19 | { | ||
20 | //protected ConsoleBase m_console; | ||
21 | |||
22 | public CheckSumServer(int port) | ||
23 | : base(port) | ||
24 | { | ||
25 | } | ||
26 | |||
27 | protected override void OnReceivedData(IAsyncResult result) | ||
28 | { | ||
29 | ipeSender = new IPEndPoint(IPAddress.Any, 0); | ||
30 | epSender = (EndPoint)ipeSender; | ||
31 | Packet packet = null; | ||
32 | int numBytes = Server.EndReceiveFrom(result, ref epSender); | ||
33 | int packetEnd = numBytes - 1; | ||
34 | |||
35 | packet = Packet.BuildPacket(RecvBuffer, ref packetEnd, ZeroBuffer); | ||
36 | |||
37 | if (packet.Type == PacketType.SecuredTemplateChecksumRequest) | ||
38 | { | ||
39 | SecuredTemplateChecksumRequestPacket checksum = (SecuredTemplateChecksumRequestPacket)packet; | ||
40 | TemplateChecksumReplyPacket checkreply = new TemplateChecksumReplyPacket(); | ||
41 | checkreply.DataBlock.Checksum = 3220703154;//180572585; | ||
42 | checkreply.DataBlock.Flags = 0; | ||
43 | checkreply.DataBlock.MajorVersion = 1; | ||
44 | checkreply.DataBlock.MinorVersion = 15; | ||
45 | checkreply.DataBlock.PatchVersion = 0; | ||
46 | checkreply.DataBlock.ServerVersion = 0; | ||
47 | checkreply.TokenBlock.Token = checksum.TokenBlock.Token; | ||
48 | this.SendPacket(checkreply, epSender); | ||
49 | |||
50 | /* | ||
51 | //if we wanted to echo the the checksum/ version from the client (so that any client worked) | ||
52 | SecuredTemplateChecksumRequestPacket checkrequest = new SecuredTemplateChecksumRequestPacket(); | ||
53 | checkrequest.TokenBlock.Token = checksum.TokenBlock.Token; | ||
54 | this.SendPacket(checkrequest, epSender); | ||
55 | */ | ||
56 | } | ||
57 | else if (packet.Type == PacketType.TemplateChecksumReply) | ||
58 | { | ||
59 | //echo back the client checksum reply (Hegemon's method) | ||
60 | TemplateChecksumReplyPacket checksum2 = (TemplateChecksumReplyPacket)packet; | ||
61 | TemplateChecksumReplyPacket checkreply2 = new TemplateChecksumReplyPacket(); | ||
62 | checkreply2.DataBlock.Checksum = checksum2.DataBlock.Checksum; | ||
63 | checkreply2.DataBlock.Flags = checksum2.DataBlock.Flags; | ||
64 | checkreply2.DataBlock.MajorVersion = checksum2.DataBlock.MajorVersion; | ||
65 | checkreply2.DataBlock.MinorVersion = checksum2.DataBlock.MinorVersion; | ||
66 | checkreply2.DataBlock.PatchVersion = checksum2.DataBlock.PatchVersion; | ||
67 | checkreply2.DataBlock.ServerVersion = checksum2.DataBlock.ServerVersion; | ||
68 | checkreply2.TokenBlock.Token = checksum2.TokenBlock.Token; | ||
69 | this.SendPacket(checkreply2, epSender); | ||
70 | } | ||
71 | else | ||
72 | { | ||
73 | } | ||
74 | |||
75 | Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null); | ||
76 | } | ||
77 | |||
78 | private void SendPacket(Packet Pack, EndPoint endp) | ||
79 | { | ||
80 | if (!Pack.Header.Resent) | ||
81 | { | ||
82 | Pack.Header.Sequence = 1; | ||
83 | } | ||
84 | |||
85 | byte[] ZeroOutBuffer = new byte[4096]; | ||
86 | byte[] sendbuffer; | ||
87 | sendbuffer = Pack.ToBytes(); | ||
88 | |||
89 | try | ||
90 | { | ||
91 | if (Pack.Header.Zerocoded) | ||
92 | { | ||
93 | int packetsize = Helpers.ZeroEncode(sendbuffer, sendbuffer.Length, ZeroOutBuffer); | ||
94 | this.SendPackTo(ZeroOutBuffer, packetsize, SocketFlags.None, endp); | ||
95 | } | ||
96 | else | ||
97 | { | ||
98 | this.SendPackTo(sendbuffer, sendbuffer.Length, SocketFlags.None, endp); | ||
99 | } | ||
100 | } | ||
101 | catch (Exception) | ||
102 | { | ||
103 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.MEDIUM, "OpenSimClient.cs:ProcessOutPacket() - WARNING: Socket exception occurred on connection "); | ||
104 | |||
105 | } | ||
106 | } | ||
107 | |||
108 | private void SendPackTo(byte[] buffer, int size, SocketFlags flags, EndPoint endp) | ||
109 | { | ||
110 | this.Server.SendTo(buffer, size, flags, endp); | ||
111 | } | ||
112 | } | ||
113 | } \ No newline at end of file | ||
diff --git a/Common/OpenSim.Servers/IRestHandler.cs b/Common/OpenSim.Servers/IRestHandler.cs new file mode 100644 index 0000000..c322505 --- /dev/null +++ b/Common/OpenSim.Servers/IRestHandler.cs | |||
@@ -0,0 +1,8 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.Text; | ||
4 | |||
5 | namespace OpenSim.Servers | ||
6 | { | ||
7 | public delegate string RestMethod( string request, string path, string param ); | ||
8 | } | ||
diff --git a/Common/OpenSim.Servers/LocalUserProfileManager.cs b/Common/OpenSim.Servers/LocalUserProfileManager.cs new file mode 100644 index 0000000..a8b5f1f --- /dev/null +++ b/Common/OpenSim.Servers/LocalUserProfileManager.cs | |||
@@ -0,0 +1,123 @@ | |||
1 | /* | ||
2 | * Copyright (c) OpenSim project, http://sim.opensecondlife.org/ | ||
3 | * | ||
4 | * Redistribution and use in source and binary forms, with or without | ||
5 | * modification, are permitted provided that the following conditions are met: | ||
6 | * * Redistributions of source code must retain the above copyright | ||
7 | * notice, this list of conditions and the following disclaimer. | ||
8 | * * Redistributions in binary form must reproduce the above copyright | ||
9 | * notice, this list of conditions and the following disclaimer in the | ||
10 | * documentation and/or other materials provided with the distribution. | ||
11 | * * Neither the name of the <organization> nor the | ||
12 | * names of its contributors may be used to endorse or promote products | ||
13 | * derived from this software without specific prior written permission. | ||
14 | * | ||
15 | * THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY | ||
16 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
17 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
18 | * DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY | ||
19 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
20 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
21 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
22 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
24 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
25 | * | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Collections; | ||
31 | using System.Text; | ||
32 | using OpenSim.Framework.User; | ||
33 | using OpenSim.Framework.Grid; | ||
34 | using OpenSim.Framework.Inventory; | ||
35 | using OpenSim.Framework.Interfaces; | ||
36 | using OpenSim.Framework.Types; | ||
37 | using libsecondlife; | ||
38 | |||
39 | namespace OpenSim.UserServer | ||
40 | { | ||
41 | public class LocalUserProfileManager : UserProfileManager | ||
42 | { | ||
43 | private IGridServer m_gridServer; | ||
44 | private int m_port; | ||
45 | private string m_ipAddr; | ||
46 | private uint regionX; | ||
47 | private uint regionY; | ||
48 | private AddNewSessionHandler AddSession; | ||
49 | |||
50 | public LocalUserProfileManager(IGridServer gridServer, int simPort, string ipAddr , uint regX, uint regY) | ||
51 | { | ||
52 | m_gridServer = gridServer; | ||
53 | m_port = simPort; | ||
54 | m_ipAddr = ipAddr; | ||
55 | regionX = regX; | ||
56 | regionY = regY; | ||
57 | } | ||
58 | |||
59 | public void SetSessionHandler(AddNewSessionHandler sessionHandler) | ||
60 | { | ||
61 | this.AddSession = sessionHandler; | ||
62 | } | ||
63 | |||
64 | public override void InitUserProfiles() | ||
65 | { | ||
66 | // TODO: need to load from database | ||
67 | } | ||
68 | |||
69 | public override void CustomiseResponse(ref System.Collections.Hashtable response, UserProfile theUser) | ||
70 | { | ||
71 | Int32 circode = (Int32)response["circuit_code"]; | ||
72 | theUser.AddSimCircuit((uint)circode, LLUUID.Random()); | ||
73 | 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() + "]}"; | ||
74 | response["sim_port"] = m_port; | ||
75 | response["sim_ip"] = m_ipAddr; | ||
76 | response["region_y"] = (Int32)regionY* 256; | ||
77 | response["region_x"] = (Int32)regionX* 256; | ||
78 | |||
79 | string first; | ||
80 | string last; | ||
81 | if (response.Contains("first_name")) | ||
82 | { | ||
83 | first = (string)response["first_name"]; | ||
84 | } | ||
85 | else | ||
86 | { | ||
87 | first = "test"; | ||
88 | } | ||
89 | |||
90 | if (response.Contains("last_name")) | ||
91 | { | ||
92 | last = (string)response["last_name"]; | ||
93 | } | ||
94 | else | ||
95 | { | ||
96 | last = "User"; | ||
97 | } | ||
98 | |||
99 | ArrayList InventoryList = (ArrayList)response["inventory-skeleton"]; | ||
100 | Hashtable Inventory1 = (Hashtable)InventoryList[0]; | ||
101 | |||
102 | Login _login = new Login(); | ||
103 | //copy data to login object | ||
104 | _login.First = first; | ||
105 | _login.Last = last; | ||
106 | _login.Agent = new LLUUID((string)response["agent_id"]) ; | ||
107 | _login.Session = new LLUUID((string)response["session_id"]); | ||
108 | _login.SecureSession = new LLUUID((string)response["secure_session_id"]); | ||
109 | _login.CircuitCode =(uint) circode; | ||
110 | _login.BaseFolder = null; | ||
111 | _login.InventoryFolder = new LLUUID((string)Inventory1["folder_id"]); | ||
112 | |||
113 | //working on local computer if so lets add to the gridserver's list of sessions? | ||
114 | /*if (m_gridServer.GetName() == "Local") | ||
115 | { | ||
116 | Console.WriteLine("adding login data to gridserver"); | ||
117 | ((LocalGridBase)this.m_gridServer).AddNewSession(_login); | ||
118 | }*/ | ||
119 | |||
120 | this.AddSession(_login); | ||
121 | } | ||
122 | } | ||
123 | } | ||
diff --git a/Common/OpenSim.Servers/LoginResponse.cs b/Common/OpenSim.Servers/LoginResponse.cs new file mode 100644 index 0000000..7333d1f --- /dev/null +++ b/Common/OpenSim.Servers/LoginResponse.cs | |||
@@ -0,0 +1,670 @@ | |||
1 | /* | ||
2 | * Copyright (c) OpenSim project, http://sim.opensecondlife.org/ | ||
3 | * | ||
4 | * Redistribution and use in source and binary forms, with or without | ||
5 | * modification, are permitted provided that the following conditions are met: | ||
6 | * * Redistributions of source code must retain the above copyright | ||
7 | * notice, this list of conditions and the following disclaimer. | ||
8 | * * Redistributions in binary form must reproduce the above copyright | ||
9 | * notice, this list of conditions and the following disclaimer in the | ||
10 | * documentation and/or other materials provided with the distribution. | ||
11 | * * Neither the name of the <organization> nor the | ||
12 | * names of its contributors may be used to endorse or promote products | ||
13 | * derived from this software without specific prior written permission. | ||
14 | * | ||
15 | * THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY | ||
16 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
17 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
18 | * DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY | ||
19 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
20 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
21 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
22 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
24 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
25 | * | ||
26 | */ | ||
27 | |||
28 | using Nwc.XmlRpc; | ||
29 | using System; | ||
30 | using System.IO; | ||
31 | using System.Net; | ||
32 | using System.Net.Sockets; | ||
33 | using System.Text; | ||
34 | using System.Text.RegularExpressions; | ||
35 | using System.Threading; | ||
36 | using System.Collections; | ||
37 | using System.Security.Cryptography; | ||
38 | using System.Xml; | ||
39 | using libsecondlife; | ||
40 | using OpenSim; | ||
41 | using OpenSim.Framework.User; | ||
42 | using OpenSim.Framework.Inventory; | ||
43 | using OpenSim.Framework.Utilities; | ||
44 | using OpenSim.Framework.Interfaces; | ||
45 | |||
46 | // ? | ||
47 | using OpenSim.Framework.Grid; | ||
48 | |||
49 | namespace OpenSim.UserServer | ||
50 | { | ||
51 | /// <summary> | ||
52 | /// A temp class to handle login response. | ||
53 | /// Should make use of UserProfileManager where possible. | ||
54 | /// </summary> | ||
55 | |||
56 | public class LoginResponse | ||
57 | { | ||
58 | private Hashtable loginFlagsHash; | ||
59 | private Hashtable globalTexturesHash; | ||
60 | private Hashtable loginError; | ||
61 | private Hashtable eventCategoriesHash; | ||
62 | private Hashtable uiConfigHash; | ||
63 | private Hashtable classifiedCategoriesHash; | ||
64 | |||
65 | private ArrayList loginFlags; | ||
66 | private ArrayList globalTextures; | ||
67 | private ArrayList eventCategories; | ||
68 | private ArrayList uiConfig; | ||
69 | private ArrayList classifiedCategories; | ||
70 | private ArrayList inventoryRoot; | ||
71 | private ArrayList initialOutfit; | ||
72 | private ArrayList agentInventory; | ||
73 | |||
74 | private UserProfile userProfile; | ||
75 | |||
76 | private LLUUID agentID; | ||
77 | private LLUUID sessionID; | ||
78 | private LLUUID secureSessionID; | ||
79 | private LLUUID baseFolderID; | ||
80 | private LLUUID inventoryFolderID; | ||
81 | |||
82 | // Login Flags | ||
83 | private string dst; | ||
84 | private string stipendSinceLogin; | ||
85 | private string gendered; | ||
86 | private string everLoggedIn; | ||
87 | private string login; | ||
88 | private string simPort; | ||
89 | private string simAddress; | ||
90 | private string agentAccess; | ||
91 | private Int32 circuitCode; | ||
92 | private uint regionX; | ||
93 | private uint regionY; | ||
94 | |||
95 | // Login | ||
96 | private string firstname; | ||
97 | private string lastname; | ||
98 | |||
99 | // Global Textures | ||
100 | private string sunTexture; | ||
101 | private string cloudTexture; | ||
102 | private string moonTexture; | ||
103 | |||
104 | // Error Flags | ||
105 | private string errorReason; | ||
106 | private string errorMessage; | ||
107 | |||
108 | // Response | ||
109 | private XmlRpcResponse xmlRpcResponse; | ||
110 | private XmlRpcResponse defaultXmlRpcResponse; | ||
111 | |||
112 | private string welcomeMessage; | ||
113 | private string startLocation; | ||
114 | private string allowFirstLife; | ||
115 | private string home; | ||
116 | private string seedCapability; | ||
117 | private string lookAt; | ||
118 | |||
119 | public LoginResponse() | ||
120 | { | ||
121 | this.loginFlags = new ArrayList(); | ||
122 | this.globalTextures = new ArrayList(); | ||
123 | this.eventCategories = new ArrayList(); | ||
124 | this.uiConfig = new ArrayList(); | ||
125 | this.classifiedCategories = new ArrayList(); | ||
126 | |||
127 | this.loginError = new Hashtable(); | ||
128 | this.eventCategoriesHash = new Hashtable(); | ||
129 | this.classifiedCategoriesHash = new Hashtable(); | ||
130 | this.uiConfigHash = new Hashtable(); | ||
131 | |||
132 | this.defaultXmlRpcResponse = new XmlRpcResponse(); | ||
133 | this.userProfile = new UserProfile(); | ||
134 | this.inventoryRoot = new ArrayList(); | ||
135 | this.initialOutfit = new ArrayList(); | ||
136 | this.agentInventory = new ArrayList(); | ||
137 | |||
138 | this.xmlRpcResponse = new XmlRpcResponse(); | ||
139 | this.defaultXmlRpcResponse = new XmlRpcResponse(); | ||
140 | |||
141 | this.SetDefaultValues(); | ||
142 | } // LoginServer | ||
143 | |||
144 | public void SetDefaultValues() | ||
145 | { | ||
146 | try | ||
147 | { | ||
148 | this.DST = "N"; | ||
149 | this.StipendSinceLogin = "N"; | ||
150 | this.Gendered = "Y"; | ||
151 | this.EverLoggedIn = "Y"; | ||
152 | this.login = "false"; | ||
153 | this.firstname = "Test"; | ||
154 | this.lastname = "User"; | ||
155 | this.agentAccess = "M"; | ||
156 | this.startLocation = "last"; | ||
157 | this.allowFirstLife = "Y"; | ||
158 | |||
159 | this.SunTexture = "cce0f112-878f-4586-a2e2-a8f104bba271"; | ||
160 | this.CloudTexture = "fc4b9f0b-d008-45c6-96a4-01dd947ac621"; | ||
161 | this.MoonTexture = "fc4b9f0b-d008-45c6-96a4-01dd947ac621"; | ||
162 | |||
163 | this.ErrorMessage = "You have entered an invalid name/password combination. Check Caps/lock."; | ||
164 | this.ErrorReason = "key"; | ||
165 | this.welcomeMessage = "Welcome to OpenSim!"; | ||
166 | this.seedCapability = ""; | ||
167 | 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() + "]}"; | ||
168 | this.lookAt = "[r0.99949799999999999756,r0.03166859999999999814,r0]"; | ||
169 | this.RegionX = (uint)255232; | ||
170 | this.RegionY = (uint)254976; | ||
171 | |||
172 | // Classifieds; | ||
173 | this.AddClassifiedCategory((Int32)1, "Shopping"); | ||
174 | this.AddClassifiedCategory((Int32)2, "Land Rental"); | ||
175 | this.AddClassifiedCategory((Int32)3, "Property Rental"); | ||
176 | this.AddClassifiedCategory((Int32)4, "Special Attraction"); | ||
177 | this.AddClassifiedCategory((Int32)5, "New Products"); | ||
178 | this.AddClassifiedCategory((Int32)6, "Employment"); | ||
179 | this.AddClassifiedCategory((Int32)7, "Wanted"); | ||
180 | this.AddClassifiedCategory((Int32)8, "Service"); | ||
181 | this.AddClassifiedCategory((Int32)9, "Personal"); | ||
182 | |||
183 | int SessionRand = Util.RandomClass.Next(1, 999); | ||
184 | this.SessionID = new LLUUID("aaaabbbb-0200-" + SessionRand.ToString("0000") + "-8664-58f53e442797"); | ||
185 | this.SecureSessionID = LLUUID.Random(); | ||
186 | |||
187 | this.userProfile.Inventory.CreateRootFolder(this.userProfile.UUID, true); | ||
188 | this.baseFolderID = this.userProfile.Inventory.GetFolderID("Textures"); | ||
189 | this.inventoryFolderID = this.userProfile.Inventory.GetFolderID("My Inventory-"); | ||
190 | Hashtable InventoryRootHash = new Hashtable(); | ||
191 | InventoryRootHash["folder_id"] = this.userProfile.Inventory.InventoryRoot.FolderID.ToStringHyphenated(); | ||
192 | this.inventoryRoot.Add(InventoryRootHash); | ||
193 | |||
194 | Hashtable TempHash; | ||
195 | foreach (InventoryFolder InvFolder in this.userProfile.Inventory.InventoryFolders.Values) | ||
196 | { | ||
197 | TempHash = new Hashtable(); | ||
198 | TempHash["name"] = InvFolder.FolderName; | ||
199 | TempHash["parent_id"] = InvFolder.ParentID.ToStringHyphenated(); | ||
200 | TempHash["version"] = (Int32)InvFolder.Version; | ||
201 | TempHash["type_default"] = (Int32)InvFolder.DefaultType; | ||
202 | TempHash["folder_id"] = InvFolder.FolderID.ToStringHyphenated(); | ||
203 | this.agentInventory.Add(TempHash); | ||
204 | } | ||
205 | |||
206 | Hashtable InitialOutfitHash = new Hashtable(); | ||
207 | InitialOutfitHash["folder_name"] = "Nightclub Female"; | ||
208 | InitialOutfitHash["gender"] = "female"; | ||
209 | this.initialOutfit.Add(InitialOutfitHash); | ||
210 | } | ||
211 | catch (Exception e) | ||
212 | { | ||
213 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine( | ||
214 | OpenSim.Framework.Console.LogPriority.LOW, | ||
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.WriteLine( | ||
330 | OpenSim.Framework.Console.LogPriority.LOW, | ||
331 | "LoginResponse: Error creating XML-RPC Response: " + e.Message | ||
332 | ); | ||
333 | return (this.GenerateFailureResponse("Internal Error", "Error generating Login Response", "false")); | ||
334 | |||
335 | } | ||
336 | |||
337 | } // ToXmlRpcResponse | ||
338 | |||
339 | public void SetEventCategories(string category, string value) | ||
340 | { | ||
341 | this.eventCategoriesHash[category] = value; | ||
342 | } // SetEventCategories | ||
343 | |||
344 | public void AddToUIConfig(string itemName, string item) | ||
345 | { | ||
346 | this.uiConfigHash[itemName] = item; | ||
347 | } // SetUIConfig | ||
348 | |||
349 | public void AddClassifiedCategory(Int32 ID, string categoryName) | ||
350 | { | ||
351 | this.classifiedCategoriesHash["category_name"] = categoryName; | ||
352 | this.classifiedCategoriesHash["category_id"] = ID; | ||
353 | this.classifiedCategories.Add(this.classifiedCategoriesHash); | ||
354 | // this.classifiedCategoriesHash.Clear(); | ||
355 | } // SetClassifiedCategory | ||
356 | |||
357 | public string Login | ||
358 | { | ||
359 | get | ||
360 | { | ||
361 | return this.login; | ||
362 | } | ||
363 | set | ||
364 | { | ||
365 | this.login = value; | ||
366 | } | ||
367 | } // Login | ||
368 | |||
369 | public string DST | ||
370 | { | ||
371 | get | ||
372 | { | ||
373 | return this.dst; | ||
374 | } | ||
375 | set | ||
376 | { | ||
377 | this.dst = value; | ||
378 | } | ||
379 | } // DST | ||
380 | |||
381 | public string StipendSinceLogin | ||
382 | { | ||
383 | get | ||
384 | { | ||
385 | return this.stipendSinceLogin; | ||
386 | } | ||
387 | set | ||
388 | { | ||
389 | this.stipendSinceLogin = value; | ||
390 | } | ||
391 | } // StipendSinceLogin | ||
392 | |||
393 | public string Gendered | ||
394 | { | ||
395 | get | ||
396 | { | ||
397 | return this.gendered; | ||
398 | } | ||
399 | set | ||
400 | { | ||
401 | this.gendered = value; | ||
402 | } | ||
403 | } // Gendered | ||
404 | |||
405 | public string EverLoggedIn | ||
406 | { | ||
407 | get | ||
408 | { | ||
409 | return this.everLoggedIn; | ||
410 | } | ||
411 | set | ||
412 | { | ||
413 | this.everLoggedIn = value; | ||
414 | } | ||
415 | } // EverLoggedIn | ||
416 | |||
417 | public string SimPort | ||
418 | { | ||
419 | get | ||
420 | { | ||
421 | return this.simPort; | ||
422 | } | ||
423 | set | ||
424 | { | ||
425 | this.simPort = value; | ||
426 | } | ||
427 | } // SimPort | ||
428 | |||
429 | public string SimAddress | ||
430 | { | ||
431 | get | ||
432 | { | ||
433 | return this.simAddress; | ||
434 | } | ||
435 | set | ||
436 | { | ||
437 | this.simAddress = value; | ||
438 | } | ||
439 | } // SimAddress | ||
440 | |||
441 | public LLUUID AgentID | ||
442 | { | ||
443 | get | ||
444 | { | ||
445 | return this.agentID; | ||
446 | } | ||
447 | set | ||
448 | { | ||
449 | this.agentID = value; | ||
450 | } | ||
451 | } // AgentID | ||
452 | |||
453 | public LLUUID SessionID | ||
454 | { | ||
455 | get | ||
456 | { | ||
457 | return this.sessionID; | ||
458 | } | ||
459 | set | ||
460 | { | ||
461 | this.sessionID = value; | ||
462 | } | ||
463 | } // SessionID | ||
464 | |||
465 | public LLUUID SecureSessionID | ||
466 | { | ||
467 | get | ||
468 | { | ||
469 | return this.secureSessionID; | ||
470 | } | ||
471 | set | ||
472 | { | ||
473 | this.secureSessionID = value; | ||
474 | } | ||
475 | } // SecureSessionID | ||
476 | |||
477 | public LLUUID BaseFolderID | ||
478 | { | ||
479 | get | ||
480 | { | ||
481 | return this.baseFolderID; | ||
482 | } | ||
483 | set | ||
484 | { | ||
485 | this.baseFolderID = value; | ||
486 | } | ||
487 | } // BaseFolderID | ||
488 | |||
489 | public LLUUID InventoryFolderID | ||
490 | { | ||
491 | get | ||
492 | { | ||
493 | return this.inventoryFolderID; | ||
494 | } | ||
495 | set | ||
496 | { | ||
497 | this.inventoryFolderID = value; | ||
498 | } | ||
499 | } // InventoryFolderID | ||
500 | |||
501 | public Int32 CircuitCode | ||
502 | { | ||
503 | get | ||
504 | { | ||
505 | return this.circuitCode; | ||
506 | } | ||
507 | set | ||
508 | { | ||
509 | this.circuitCode = value; | ||
510 | } | ||
511 | } // CircuitCode | ||
512 | |||
513 | public uint RegionX | ||
514 | { | ||
515 | get | ||
516 | { | ||
517 | return this.regionX; | ||
518 | } | ||
519 | set | ||
520 | { | ||
521 | this.regionX = value; | ||
522 | } | ||
523 | } // RegionX | ||
524 | |||
525 | public uint RegionY | ||
526 | { | ||
527 | get | ||
528 | { | ||
529 | return this.regionY; | ||
530 | } | ||
531 | set | ||
532 | { | ||
533 | this.regionY = value; | ||
534 | } | ||
535 | } // RegionY | ||
536 | |||
537 | public string SunTexture | ||
538 | { | ||
539 | get | ||
540 | { | ||
541 | return this.sunTexture; | ||
542 | } | ||
543 | set | ||
544 | { | ||
545 | this.sunTexture = value; | ||
546 | } | ||
547 | } // SunTexture | ||
548 | |||
549 | public string CloudTexture | ||
550 | { | ||
551 | get | ||
552 | { | ||
553 | return this.cloudTexture; | ||
554 | } | ||
555 | set | ||
556 | { | ||
557 | this.cloudTexture = value; | ||
558 | } | ||
559 | } // CloudTexture | ||
560 | |||
561 | public string MoonTexture | ||
562 | { | ||
563 | get | ||
564 | { | ||
565 | return this.moonTexture; | ||
566 | } | ||
567 | set | ||
568 | { | ||
569 | this.moonTexture = value; | ||
570 | } | ||
571 | } // MoonTexture | ||
572 | |||
573 | public string Firstname | ||
574 | { | ||
575 | get | ||
576 | { | ||
577 | return this.firstname; | ||
578 | } | ||
579 | set | ||
580 | { | ||
581 | this.firstname = value; | ||
582 | } | ||
583 | } // Firstname | ||
584 | |||
585 | public string Lastname | ||
586 | { | ||
587 | get | ||
588 | { | ||
589 | return this.lastname; | ||
590 | } | ||
591 | set | ||
592 | { | ||
593 | this.lastname = value; | ||
594 | } | ||
595 | } // Lastname | ||
596 | |||
597 | public string AgentAccess | ||
598 | { | ||
599 | get | ||
600 | { | ||
601 | return this.agentAccess; | ||
602 | } | ||
603 | set | ||
604 | { | ||
605 | this.agentAccess = value; | ||
606 | } | ||
607 | } | ||
608 | |||
609 | public string StartLocation | ||
610 | { | ||
611 | get | ||
612 | { | ||
613 | return this.startLocation; | ||
614 | } | ||
615 | set | ||
616 | { | ||
617 | this.startLocation = value; | ||
618 | } | ||
619 | } // StartLocation | ||
620 | |||
621 | public string LookAt | ||
622 | { | ||
623 | get | ||
624 | { | ||
625 | return this.lookAt; | ||
626 | } | ||
627 | set | ||
628 | { | ||
629 | this.lookAt = value; | ||
630 | } | ||
631 | } | ||
632 | |||
633 | public string SeedCapability | ||
634 | { | ||
635 | get | ||
636 | { | ||
637 | return this.seedCapability; | ||
638 | } | ||
639 | set | ||
640 | { | ||
641 | this.seedCapability = value; | ||
642 | } | ||
643 | } // SeedCapability | ||
644 | |||
645 | public string ErrorReason | ||
646 | { | ||
647 | get | ||
648 | { | ||
649 | return this.errorReason; | ||
650 | } | ||
651 | set | ||
652 | { | ||
653 | this.errorReason = value; | ||
654 | } | ||
655 | } // ErrorReason | ||
656 | |||
657 | public string ErrorMessage | ||
658 | { | ||
659 | get | ||
660 | { | ||
661 | return this.errorMessage; | ||
662 | } | ||
663 | set | ||
664 | { | ||
665 | this.errorMessage = value; | ||
666 | } | ||
667 | } // ErrorMessage | ||
668 | |||
669 | } // LoginResponse | ||
670 | } // namespace OpenSim.UserServer \ No newline at end of file | ||
diff --git a/Common/OpenSim.Servers/LoginServer.cs b/Common/OpenSim.Servers/LoginServer.cs new file mode 100644 index 0000000..6fd174b --- /dev/null +++ b/Common/OpenSim.Servers/LoginServer.cs | |||
@@ -0,0 +1,284 @@ | |||
1 | /* | ||
2 | * Copyright (c) OpenSim project, http://sim.opensecondlife.org/ | ||
3 | * | ||
4 | * Redistribution and use in source and binary forms, with or without | ||
5 | * modification, are permitted provided that the following conditions are met: | ||
6 | * * Redistributions of source code must retain the above copyright | ||
7 | * notice, this list of conditions and the following disclaimer. | ||
8 | * * Redistributions in binary form must reproduce the above copyright | ||
9 | * notice, this list of conditions and the following disclaimer in the | ||
10 | * documentation and/or other materials provided with the distribution. | ||
11 | * * Neither the name of the <organization> nor the | ||
12 | * names of its contributors may be used to endorse or promote products | ||
13 | * derived from this software without specific prior written permission. | ||
14 | * | ||
15 | * THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY | ||
16 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
17 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
18 | * DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY | ||
19 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
20 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
21 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
22 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
24 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
25 | * | ||
26 | */ | ||
27 | |||
28 | using Nwc.XmlRpc; | ||
29 | using System; | ||
30 | using System.IO; | ||
31 | using System.Net; | ||
32 | using System.Net.Sockets; | ||
33 | using System.Text; | ||
34 | using System.Text.RegularExpressions; | ||
35 | using System.Threading; | ||
36 | using System.Collections; | ||
37 | using System.Security.Cryptography; | ||
38 | using System.Xml; | ||
39 | using libsecondlife; | ||
40 | using OpenSim; | ||
41 | using OpenSim.Framework.Interfaces; | ||
42 | using OpenSim.Framework.Grid; | ||
43 | using OpenSim.Framework.Inventory; | ||
44 | using OpenSim.Framework.User; | ||
45 | using OpenSim.Framework.Utilities; | ||
46 | using OpenSim.Framework.Types; | ||
47 | |||
48 | namespace OpenSim.UserServer | ||
49 | { | ||
50 | public delegate void AddNewSessionHandler(Login loginData); | ||
51 | /// <summary> | ||
52 | /// When running in local (default) mode , handles client logins. | ||
53 | /// </summary> | ||
54 | public class LoginServer : LoginService, IUserServer | ||
55 | { | ||
56 | private IGridServer m_gridServer; | ||
57 | public IPAddress clientAddress = IPAddress.Loopback; | ||
58 | public IPAddress remoteAddress = IPAddress.Any; | ||
59 | private int NumClients; | ||
60 | private bool userAccounts = false; | ||
61 | private string _mpasswd; | ||
62 | private bool _needPasswd = false; | ||
63 | private LocalUserProfileManager userManager; | ||
64 | private int m_simPort; | ||
65 | private string m_simAddr; | ||
66 | private uint regionX; | ||
67 | private uint regionY; | ||
68 | private AddNewSessionHandler AddSession; | ||
69 | |||
70 | public LocalUserProfileManager LocalUserManager | ||
71 | { | ||
72 | get | ||
73 | { | ||
74 | return userManager; | ||
75 | } | ||
76 | } | ||
77 | |||
78 | public LoginServer( string simAddr, int simPort, uint regX, uint regY, bool useAccounts) | ||
79 | { | ||
80 | m_simPort = simPort; | ||
81 | m_simAddr = simAddr; | ||
82 | regionX = regX; | ||
83 | regionY = regY; | ||
84 | this.userAccounts = useAccounts; | ||
85 | } | ||
86 | |||
87 | public void SetSessionHandler(AddNewSessionHandler sessionHandler) | ||
88 | { | ||
89 | this.AddSession = sessionHandler; | ||
90 | this.userManager.SetSessionHandler(sessionHandler); | ||
91 | } | ||
92 | |||
93 | public void Startup() | ||
94 | { | ||
95 | this._needPasswd = false; | ||
96 | |||
97 | this._mpasswd = EncodePassword("testpass"); | ||
98 | |||
99 | userManager = new LocalUserProfileManager(this.m_gridServer, m_simPort, m_simAddr, regionX, regionY); | ||
100 | //userManager.InitUserProfiles(); | ||
101 | userManager.SetKeys("", "", "", "Welcome to OpenSim"); | ||
102 | } | ||
103 | |||
104 | public XmlRpcResponse XmlRpcLoginMethod(XmlRpcRequest request) | ||
105 | { | ||
106 | Console.WriteLine("login attempt"); | ||
107 | Hashtable requestData = (Hashtable)request.Params[0]; | ||
108 | string first; | ||
109 | string last; | ||
110 | string passwd; | ||
111 | |||
112 | LoginResponse loginResponse = new LoginResponse(); | ||
113 | loginResponse.RegionX = regionX; | ||
114 | loginResponse.RegionY = regionY; | ||
115 | |||
116 | //get login name | ||
117 | if (requestData.Contains("first")) | ||
118 | { | ||
119 | first = (string)requestData["first"]; | ||
120 | } | ||
121 | else | ||
122 | { | ||
123 | first = "test"; | ||
124 | } | ||
125 | |||
126 | if (requestData.Contains("last")) | ||
127 | { | ||
128 | last = (string)requestData["last"]; | ||
129 | } | ||
130 | else | ||
131 | { | ||
132 | last = "User" + NumClients.ToString(); | ||
133 | } | ||
134 | |||
135 | if (requestData.Contains("passwd")) | ||
136 | { | ||
137 | passwd = (string)requestData["passwd"]; | ||
138 | } | ||
139 | else | ||
140 | { | ||
141 | passwd = "notfound"; | ||
142 | } | ||
143 | |||
144 | if (!Authenticate(first, last, passwd)) | ||
145 | { | ||
146 | return loginResponse.LoginFailedResponse(); | ||
147 | } | ||
148 | |||
149 | NumClients++; | ||
150 | |||
151 | // Create a agent and session LLUUID | ||
152 | // Agent = GetAgentId(first, last); | ||
153 | // int SessionRand = Util.RandomClass.Next(1, 999); | ||
154 | // Session = new LLUUID("aaaabbbb-0200-" + SessionRand.ToString("0000") + "-8664-58f53e442797"); | ||
155 | // LLUUID secureSess = LLUUID.Random(); | ||
156 | |||
157 | loginResponse.SimPort = m_simPort.ToString(); | ||
158 | loginResponse.SimAddress = m_simAddr.ToString(); | ||
159 | // loginResponse.AgentID = Agent.ToStringHyphenated(); | ||
160 | // loginResponse.SessionID = Session.ToStringHyphenated(); | ||
161 | // loginResponse.SecureSessionID = secureSess.ToStringHyphenated(); | ||
162 | loginResponse.CircuitCode = (Int32)(Util.RandomClass.Next()); | ||
163 | XmlRpcResponse response = loginResponse.ToXmlRpcResponse(); | ||
164 | Hashtable responseData = (Hashtable)response.Value; | ||
165 | |||
166 | //inventory | ||
167 | /* ArrayList InventoryList = (ArrayList)responseData["inventory-skeleton"]; | ||
168 | Hashtable Inventory1 = (Hashtable)InventoryList[0]; | ||
169 | Hashtable Inventory2 = (Hashtable)InventoryList[1]; | ||
170 | LLUUID BaseFolderID = LLUUID.Random(); | ||
171 | LLUUID InventoryFolderID = LLUUID.Random(); | ||
172 | Inventory2["name"] = "Textures"; | ||
173 | Inventory2["folder_id"] = BaseFolderID.ToStringHyphenated(); | ||
174 | Inventory2["type_default"] = 0; | ||
175 | Inventory1["folder_id"] = InventoryFolderID.ToStringHyphenated(); | ||
176 | |||
177 | ArrayList InventoryRoot = (ArrayList)responseData["inventory-root"]; | ||
178 | Hashtable Inventoryroot = (Hashtable)InventoryRoot[0]; | ||
179 | Inventoryroot["folder_id"] = InventoryFolderID.ToStringHyphenated(); | ||
180 | */ | ||
181 | CustomiseLoginResponse(responseData, first, last); | ||
182 | |||
183 | Login _login = new Login(); | ||
184 | //copy data to login object | ||
185 | _login.First = first; | ||
186 | _login.Last = last; | ||
187 | _login.Agent = loginResponse.AgentID; | ||
188 | _login.Session = loginResponse.SessionID; | ||
189 | _login.SecureSession = loginResponse.SecureSessionID; | ||
190 | _login.CircuitCode = (uint) loginResponse.CircuitCode; | ||
191 | _login.BaseFolder = loginResponse.BaseFolderID; | ||
192 | _login.InventoryFolder = loginResponse.InventoryFolderID; | ||
193 | |||
194 | //working on local computer if so lets add to the gridserver's list of sessions? | ||
195 | /* if (m_gridServer.GetName() == "Local") | ||
196 | { | ||
197 | ((LocalGridBase)m_gridServer).AddNewSession(_login); | ||
198 | }*/ | ||
199 | AddSession(_login); | ||
200 | |||
201 | return response; | ||
202 | } | ||
203 | |||
204 | protected virtual void CustomiseLoginResponse(Hashtable responseData, string first, string last) | ||
205 | { | ||
206 | } | ||
207 | |||
208 | protected virtual LLUUID GetAgentId(string firstName, string lastName) | ||
209 | { | ||
210 | LLUUID Agent; | ||
211 | int AgentRand = Util.RandomClass.Next(1, 9999); | ||
212 | Agent = new LLUUID("99998888-0100-" + AgentRand.ToString("0000") + "-8ec1-0b1d5cd6aead"); | ||
213 | return Agent; | ||
214 | } | ||
215 | |||
216 | protected virtual bool Authenticate(string first, string last, string passwd) | ||
217 | { | ||
218 | if (this._needPasswd) | ||
219 | { | ||
220 | //every user needs the password to login | ||
221 | string encodedPass = passwd.Remove(0, 3); //remove $1$ | ||
222 | if (encodedPass == this._mpasswd) | ||
223 | { | ||
224 | return true; | ||
225 | } | ||
226 | else | ||
227 | { | ||
228 | return false; | ||
229 | } | ||
230 | } | ||
231 | else | ||
232 | { | ||
233 | //do not need password to login | ||
234 | return true; | ||
235 | } | ||
236 | } | ||
237 | |||
238 | private static string EncodePassword(string passwd) | ||
239 | { | ||
240 | Byte[] originalBytes; | ||
241 | Byte[] encodedBytes; | ||
242 | MD5 md5; | ||
243 | |||
244 | md5 = new MD5CryptoServiceProvider(); | ||
245 | originalBytes = ASCIIEncoding.Default.GetBytes(passwd); | ||
246 | encodedBytes = md5.ComputeHash(originalBytes); | ||
247 | |||
248 | return Regex.Replace(BitConverter.ToString(encodedBytes), "-", "").ToLower(); | ||
249 | } | ||
250 | |||
251 | public bool CreateUserAccount(string firstName, string lastName, string password) | ||
252 | { | ||
253 | Console.WriteLine("creating new user account"); | ||
254 | string mdPassword = EncodePassword(password); | ||
255 | Console.WriteLine("with password: " + mdPassword); | ||
256 | this.userManager.CreateNewProfile(firstName, lastName, mdPassword); | ||
257 | return true; | ||
258 | } | ||
259 | |||
260 | //IUserServer implementation | ||
261 | public AgentInventory RequestAgentsInventory(LLUUID agentID) | ||
262 | { | ||
263 | AgentInventory aInventory = null; | ||
264 | if (this.userAccounts) | ||
265 | { | ||
266 | aInventory = this.userManager.GetUsersInventory(agentID); | ||
267 | } | ||
268 | |||
269 | return aInventory; | ||
270 | } | ||
271 | |||
272 | public bool UpdateAgentsInventory(LLUUID agentID, AgentInventory inventory) | ||
273 | { | ||
274 | return true; | ||
275 | } | ||
276 | |||
277 | public void SetServerInfo(string ServerUrl, string SendKey, string RecvKey) | ||
278 | { | ||
279 | |||
280 | } | ||
281 | } | ||
282 | |||
283 | |||
284 | } | ||
diff --git a/Common/OpenSim.Servers/OpenSim.Servers.csproj b/Common/OpenSim.Servers/OpenSim.Servers.csproj new file mode 100644 index 0000000..e89a62c --- /dev/null +++ b/Common/OpenSim.Servers/OpenSim.Servers.csproj | |||
@@ -0,0 +1,130 @@ | |||
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="System" > | ||
62 | <HintPath>System.dll</HintPath> | ||
63 | <Private>False</Private> | ||
64 | </Reference> | ||
65 | <Reference Include="System.Xml" > | ||
66 | <HintPath>System.Xml.dll</HintPath> | ||
67 | <Private>False</Private> | ||
68 | </Reference> | ||
69 | <Reference Include="libsecondlife.dll" > | ||
70 | <HintPath>..\..\bin\libsecondlife.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="UDPServerBase.cs"> | ||
117 | <SubType>Code</SubType> | ||
118 | </Compile> | ||
119 | <Compile Include="XmlRpcMethod.cs"> | ||
120 | <SubType>Code</SubType> | ||
121 | </Compile> | ||
122 | </ItemGroup> | ||
123 | <Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" /> | ||
124 | <PropertyGroup> | ||
125 | <PreBuildEvent> | ||
126 | </PreBuildEvent> | ||
127 | <PostBuildEvent> | ||
128 | </PostBuildEvent> | ||
129 | </PropertyGroup> | ||
130 | </Project> | ||
diff --git a/Common/OpenSim.Servers/OpenSim.Servers.csproj.user b/Common/OpenSim.Servers/OpenSim.Servers.csproj.user new file mode 100644 index 0000000..d47d65d --- /dev/null +++ b/Common/OpenSim.Servers/OpenSim.Servers.csproj.user | |||
@@ -0,0 +1,12 @@ | |||
1 | <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
2 | <PropertyGroup> | ||
3 | <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
4 | <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
5 | <ReferencePath>C:\New Folder\second-life-viewer\opensim-dailys2\opensim15-07\bin\</ReferencePath> | ||
6 | <LastOpenVersion>8.0.50727</LastOpenVersion> | ||
7 | <ProjectView>ProjectFiles</ProjectView> | ||
8 | <ProjectTrust>0</ProjectTrust> | ||
9 | </PropertyGroup> | ||
10 | <PropertyGroup Condition = " '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' " /> | ||
11 | <PropertyGroup Condition = " '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " /> | ||
12 | </Project> | ||
diff --git a/Common/OpenSim.Servers/OpenSim.Servers.dll.build b/Common/OpenSim.Servers/OpenSim.Servers.dll.build new file mode 100644 index 0000000..41c1350 --- /dev/null +++ b/Common/OpenSim.Servers/OpenSim.Servers.dll.build | |||
@@ -0,0 +1,52 @@ | |||
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="UDPServerBase.cs" /> | ||
22 | <include name="XmlRpcMethod.cs" /> | ||
23 | </sources> | ||
24 | <references basedir="${project::get-base-directory()}"> | ||
25 | <lib> | ||
26 | <include name="${project::get-base-directory()}" /> | ||
27 | <include name="${project::get-base-directory()}/${build.dir}" /> | ||
28 | </lib> | ||
29 | <include name="System.dll" /> | ||
30 | <include name="System.Xml.dll" /> | ||
31 | <include name="../../bin/OpenSim.Framework.dll" /> | ||
32 | <include name="../../bin/OpenSim.Framework.Console.dll" /> | ||
33 | <include name="../../bin/libsecondlife.dll" /> | ||
34 | <include name="../../bin/XMLRPC.dll" /> | ||
35 | </references> | ||
36 | </csc> | ||
37 | <echo message="Copying from [${project::get-base-directory()}/${build.dir}/] to [${project::get-base-directory()}/../../bin/" /> | ||
38 | <mkdir dir="${project::get-base-directory()}/../../bin/"/> | ||
39 | <copy todir="${project::get-base-directory()}/../../bin/"> | ||
40 | <fileset basedir="${project::get-base-directory()}/${build.dir}/" > | ||
41 | <include name="*.dll"/> | ||
42 | <include name="*.exe"/> | ||
43 | </fileset> | ||
44 | </copy> | ||
45 | </target> | ||
46 | <target name="clean"> | ||
47 | <delete dir="${bin.dir}" failonerror="false" /> | ||
48 | <delete dir="${obj.dir}" failonerror="false" /> | ||
49 | </target> | ||
50 | <target name="doc" description="Creates documentation."> | ||
51 | </target> | ||
52 | </project> | ||
diff --git a/Common/OpenSim.Servers/UDPServerBase.cs b/Common/OpenSim.Servers/UDPServerBase.cs new file mode 100644 index 0000000..a308052 --- /dev/null +++ b/Common/OpenSim.Servers/UDPServerBase.cs | |||
@@ -0,0 +1,68 @@ | |||
1 | using System; | ||
2 | using System.Text; | ||
3 | using System.IO; | ||
4 | using System.Threading; | ||
5 | using System.Net; | ||
6 | using System.Net.Sockets; | ||
7 | using System.Timers; | ||
8 | using System.Reflection; | ||
9 | using System.Collections; | ||
10 | using System.Collections.Generic; | ||
11 | using libsecondlife; | ||
12 | using libsecondlife.Packets; | ||
13 | |||
14 | namespace OpenSim.Servers | ||
15 | { | ||
16 | public class UDPServerBase | ||
17 | { | ||
18 | public Socket Server; | ||
19 | protected IPEndPoint ServerIncoming; | ||
20 | protected byte[] RecvBuffer = new byte[4096]; | ||
21 | protected byte[] ZeroBuffer = new byte[8192]; | ||
22 | protected IPEndPoint ipeSender; | ||
23 | protected EndPoint epSender; | ||
24 | protected AsyncCallback ReceivedData; | ||
25 | protected int listenPort; | ||
26 | |||
27 | public UDPServerBase(int port) | ||
28 | { | ||
29 | listenPort = port; | ||
30 | } | ||
31 | |||
32 | protected virtual void OnReceivedData(IAsyncResult result) | ||
33 | { | ||
34 | ipeSender = new IPEndPoint(IPAddress.Any, 0); | ||
35 | epSender = (EndPoint)ipeSender; | ||
36 | Packet packet = null; | ||
37 | int numBytes = Server.EndReceiveFrom(result, ref epSender); | ||
38 | int packetEnd = numBytes - 1; | ||
39 | |||
40 | packet = Packet.BuildPacket(RecvBuffer, ref packetEnd, ZeroBuffer); | ||
41 | |||
42 | Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null); | ||
43 | } | ||
44 | |||
45 | protected virtual void AddNewClient(Packet packet) | ||
46 | { | ||
47 | } | ||
48 | |||
49 | public virtual void ServerListener() | ||
50 | { | ||
51 | |||
52 | ServerIncoming = new IPEndPoint(IPAddress.Any, listenPort); | ||
53 | Server = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); | ||
54 | Server.Bind(ServerIncoming); | ||
55 | |||
56 | ipeSender = new IPEndPoint(IPAddress.Any, 0); | ||
57 | epSender = (EndPoint)ipeSender; | ||
58 | ReceivedData = new AsyncCallback(this.OnReceivedData); | ||
59 | Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null); | ||
60 | } | ||
61 | |||
62 | public virtual void SendPacketTo(byte[] buffer, int size, SocketFlags flags, uint circuitcode) | ||
63 | { | ||
64 | |||
65 | } | ||
66 | } | ||
67 | } | ||
68 | |||
diff --git a/Common/OpenSim.Servers/XmlRpcMethod.cs b/Common/OpenSim.Servers/XmlRpcMethod.cs new file mode 100644 index 0000000..2295405 --- /dev/null +++ b/Common/OpenSim.Servers/XmlRpcMethod.cs | |||
@@ -0,0 +1,7 @@ | |||
1 | using System; | ||
2 | using Nwc.XmlRpc; | ||
3 | |||
4 | namespace OpenSim.Servers | ||
5 | { | ||
6 | public delegate XmlRpcResponse XmlRpcMethod( XmlRpcRequest request ); | ||
7 | } | ||