aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Login_manager.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Login_manager.cs')
-rw-r--r--Login_manager.cs74
1 files changed, 59 insertions, 15 deletions
diff --git a/Login_manager.cs b/Login_manager.cs
index 84f475d..a41bde3 100644
--- a/Login_manager.cs
+++ b/Login_manager.cs
@@ -25,7 +25,7 @@
25* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27*/ 27*/
28 28using Nwc.XmlRpc;
29using System; 29using System;
30using System.IO; 30using System.IO;
31using System.Net; 31using System.Net;
@@ -33,24 +33,27 @@ using System.Net.Sockets;
33using System.Text; 33using System.Text;
34using System.Text.RegularExpressions; 34using System.Text.RegularExpressions;
35using System.Threading; 35using System.Threading;
36using System.Collections;
37using libsecondlife;
36 38
37namespace Second_server 39namespace OpenSim
38{ 40{
39 /// <summary> 41 /// <summary>
40 /// Description of Login_manager. 42 /// Description of Login_manager.
41 /// </summary> 43 /// </summary>
42 public class Login_manager 44 public class LoginManager
43 { 45 {
44 public Login_manager() 46 public LoginManager(Logon login)
45 { 47 {
46 48 Login=login;
47 } 49 }
48 50 public Logon Login;
49 public ushort loginPort = 8080; 51 public ushort loginPort = 8080;
50 public IPAddress clientAddress = IPAddress.Loopback; 52 public IPAddress clientAddress = IPAddress.Loopback;
51 public IPAddress remoteAddress = IPAddress.Any; 53 public IPAddress remoteAddress = IPAddress.Any;
52 private Socket loginServer; 54 private Socket loginServer;
53 private Random RandomClass = new Random(); 55 private Random RandomClass = new Random();
56 private int NumClients;
54 57
55 // InitializeLoginProxy: initialize the login proxy 58 // InitializeLoginProxy: initialize the login proxy
56 private void InitializeLoginProxy() { 59 private void InitializeLoginProxy() {
@@ -59,7 +62,7 @@ namespace Second_server
59 loginServer.Listen(1); 62 loginServer.Listen(1);
60 } 63 }
61 64
62 public void startup() 65 public void Startup()
63 { 66 {
64 this.InitializeLoginProxy(); 67 this.InitializeLoginProxy();
65 Thread runLoginProxy = new Thread(new ThreadStart(RunLoginProxy)); 68 Thread runLoginProxy = new Thread(new ThreadStart(RunLoginProxy));
@@ -67,7 +70,7 @@ namespace Second_server
67 runLoginProxy.Start(); 70 runLoginProxy.Start();
68 } 71 }
69 72
70 private void RunLoginProxy() { 73 private void RunLoginProxy() {
71 try { 74 try {
72 for (;;) { 75 for (;;) {
73 Socket client = loginServer.Accept(); 76 Socket client = loginServer.Accept();
@@ -121,11 +124,52 @@ namespace Second_server
121 if (match.Success) 124 if (match.Success)
122 contentLength = Convert.ToInt32(match.Groups[1].Captures[0].ToString()); 125 contentLength = Convert.ToInt32(match.Groups[1].Captures[0].ToString());
123 } while (line != ""); 126 } while (line != "");
124 System.Console.WriteLine(line); 127
125 // read the HTTP body into a buffer 128 // read the HTTP body into a buffer
126 char[] content = new char[contentLength]; 129 char[] content = new char[contentLength];
127 reader.Read(content, 0, contentLength); 130 reader.Read(content, 0, contentLength);
128 131 // System.Text.Encoding enc = System.Text.Encoding.ASCII;
132 XmlRpcRequest request = (XmlRpcRequest)(new XmlRpcRequestDeserializer()).Deserialize(new String(content));
133 Hashtable requestData = (Hashtable)request.Params[0];
134
135 string first;
136 string last;
137 LLUUID Agent;
138 LLUUID Session;
139
140 //get login name
141 if(requestData.Contains("first"))
142 {
143 first=(string)requestData["first"];
144 }
145 else
146 {
147 first="test";
148 }
149 if(requestData.Contains("last"))
150 {
151 last=(string)requestData["last"];
152 }
153 else
154 {
155 last="User"+NumClients.ToString();
156 }
157 NumClients++;
158
159 //create a agent and session LLUUID
160 int AgentRand=this.RandomClass.Next(1,9999);
161 Agent=new LLUUID("99998888-"+AgentRand.ToString("0000")+"-4f52-8ec1-0b1d5cd6aead");
162 int SessionRand=this.RandomClass.Next(1,999);
163 Session=new LLUUID("aaaabbbb-8932-"+SessionRand.ToString("0000")+"-8664-58f53e442797");
164
165 //copy data to login object
166 lock(Login)
167 {
168 Login.first=first;
169 Login.last=last;
170 Login.Agent=Agent;
171 Login.Session=Session;
172 }
129 173
130 // forward the XML-RPC response to the client 174 // forward the XML-RPC response to the client
131 writer.WriteLine("HTTP/1.0 200 OK"); 175 writer.WriteLine("HTTP/1.0 200 OK");
@@ -138,16 +182,16 @@ namespace Second_server
138 SR=File.OpenText("login.dat"); 182 SR=File.OpenText("login.dat");
139 lines=SR.ReadLine(); 183 lines=SR.ReadLine();
140 writer.WriteLine(lines); 184 writer.WriteLine(lines);
141 lines=SR.ReadLine();
142 int ran=this.RandomClass.Next(1,9999);
143 185
144 lines="<member><name>session_id</name><value><string>99998888-"+ran.ToString("0000")+"-4f52-8ec1-0b1d5cd6aead</string></value></member>"; 186 lines=SR.ReadLine();
187 //lines="<member><name>session_id</name><value><string>"+Agent.ToString()+"</string></value></member>";
188 lines="<member><name>session_id</name><value><string>99998888-"+AgentRand.ToString("0000")+"-4f52-8ec1-0b1d5cd6aead</string></value></member>";
145 writer.WriteLine(lines); 189 writer.WriteLine(lines);
146 lines=SR.ReadLine(); 190 lines=SR.ReadLine();
147 writer.WriteLine(lines); 191 writer.WriteLine(lines);
148 lines=SR.ReadLine(); 192 lines=SR.ReadLine();
149 ran=this.RandomClass.Next(1,9999); 193 //lines="<member><name>agent_id</name><value><string>"+Session.ToString()+"</string></value></member>";
150 lines="<member><name>agent_id</name><value><string>aaaabbbb-8932-"+ran.ToString("0000")+"-8664-58f53e442797</string></value></member>"; 194 lines="<member><name>agent_id</name><value><string>aaaabbbb-8932-"+SessionRand.ToString("0000")+"-8664-58f53e442797</string></value></member>";
151 writer.WriteLine(lines); 195 writer.WriteLine(lines);
152 lines=SR.ReadLine(); 196 lines=SR.ReadLine();
153 197