aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/ogs
diff options
context:
space:
mode:
authorgareth2007-03-14 03:32:02 +0000
committergareth2007-03-14 03:32:02 +0000
commit5d2cadf6de749dab1430c016a29e09461d288693 (patch)
tree4f5698b45404b0898070419438719ff71ec3877c /ogs
parentadded movement etc from r191 (diff)
downloadopensim-SC-5d2cadf6de749dab1430c016a29e09461d288693.zip
opensim-SC-5d2cadf6de749dab1430c016a29e09461d288693.tar.gz
opensim-SC-5d2cadf6de749dab1430c016a29e09461d288693.tar.bz2
opensim-SC-5d2cadf6de749dab1430c016a29e09461d288693.tar.xz
Merged ogs-cs into trunk
Diffstat (limited to '')
-rw-r--r--ogs/ServerConsole/ServerConsole.cs98
-rw-r--r--ogs/ServerConsole/default.build48
-rw-r--r--ogs/common/src/OGS-Console.cs181
-rw-r--r--ogs/common/src/Util.cs87
-rw-r--r--ogs/common/src/VersionInfo.cs.template37
-rw-r--r--ogs/genvers.sh9
-rw-r--r--ogs/gridserver/default.build64
-rw-r--r--ogs/gridserver/gridserver_config.inc.php14
-rw-r--r--ogs/gridserver/index.php176
-rw-r--r--ogs/gridserver/src/ConsoleCmds.cs57
-rw-r--r--ogs/gridserver/src/GridHttp.cs165
-rw-r--r--ogs/gridserver/src/Main.cs94
-rw-r--r--ogs/gridserver/src/SimProfiles.cs111
-rw-r--r--ogs/login/index.php170
-rw-r--r--ogs/login/login_config.inc.php11
-rw-r--r--ogs/ogs.build38
-rw-r--r--ogs/userserver/default.build63
-rw-r--r--ogs/userserver/src/ConsoleCmds.cs57
-rw-r--r--ogs/userserver/src/Main.cs114
-rw-r--r--ogs/userserver/src/UserHttp.cs287
-rw-r--r--ogs/userserver/src/UserProfiles.cs223
-rw-r--r--ogs/userserver/src/Util.cs87
22 files changed, 1820 insertions, 371 deletions
diff --git a/ogs/ServerConsole/ServerConsole.cs b/ogs/ServerConsole/ServerConsole.cs
new file mode 100644
index 0000000..d50a7e2
--- /dev/null
+++ b/ogs/ServerConsole/ServerConsole.cs
@@ -0,0 +1,98 @@
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*/
27using System;
28
29namespace ServerConsole
30{
31 public class MainConsole {
32
33 private static ConsoleBase instance;
34
35 public static ConsoleBase Instance
36 {
37 get
38 {
39 return instance;
40 }
41 set
42 {
43 instance = value;
44 }
45 }
46
47 public MainConsole()
48 {
49
50 }
51 }
52
53 public abstract class conscmd_callback {
54 public abstract void RunCmd(string cmd, string[] cmdparams);
55 public abstract void Show(string ShowWhat);
56 }
57
58 public abstract class ConsoleBase
59 {
60
61 public enum ConsoleType {
62 Local, // Use stdio
63 TCP, // Use TCP/telnet
64 SimChat // Use in-world chat (for gods)
65 }
66
67 public abstract void Close();
68
69 // You know what ReadLine() and WriteLine() do, right? And Read() and Write()? Right, you do actually know C#, right? Are you actually a programmer? Do you know english? Do you find my sense of humour in comments irritating? Good, glad you're still here
70 public abstract void WriteLine(string Line) ;
71
72 public abstract string ReadLine();
73
74 public abstract int Read() ;
75
76 public abstract void Write(string Line) ;
77
78 public abstract string PasswdPrompt(string prompt);
79
80 // Displays a command prompt and waits for the user to enter a string, then returns that string
81 public abstract string CmdPrompt(string prompt) ;
82
83 // Displays a command prompt and returns a default value if the user simply presses enter
84 public abstract string CmdPrompt(string prompt, string defaultresponse);
85
86 // Displays a command prompt and returns a default value, user may only enter 1 of 2 options
87 public abstract string CmdPrompt(string prompt, string defaultresponse, string OptionA, string OptionB) ;
88
89 // Runs a command with a number of parameters
90 public abstract Object RunCmd(string Cmd, string[] cmdparams) ;
91
92 // Shows data about something
93 public abstract void ShowCommands(string ShowWhat) ;
94
95 // Displays a prompt to the user and then runs the command they entered
96 public abstract void MainConsolePrompt() ;
97 }
98}
diff --git a/ogs/ServerConsole/default.build b/ogs/ServerConsole/default.build
new file mode 100644
index 0000000..64a4f04
--- /dev/null
+++ b/ogs/ServerConsole/default.build
@@ -0,0 +1,48 @@
1<?xml version="1.0"?>
2 <project name="ServerConsole" default="build" basedir=".">
3 <property name="debug" value="true" overwrite="false" />
4 <target name="clean" description="remove all generated files">
5 <delete file="../common/bin/ServerConsole.dll" failonerror="false" />
6 <delete file="../common/bin/ServerConsole.dll.mdb" failonerror="false" />
7 </target>
8
9 <target name="svnupdate" description="updates to latest SVN">
10 <exec program="svn">
11 <arg value="update" />
12 </exec>
13 </target>
14
15 <target name="upgrade" description="updates from SVN and then builds" depends="clean,svnupdate,build">
16
17 </target>
18
19 <target name="build" description="compiles the source code">
20
21 <loadfile file="../VERSION" property="svnver"/>
22 <asminfo output="AssemblyInfo.cs" language="CSharp">
23 <imports>
24 <import namespace="System" />
25 <import namespace="System.Reflection" />
26 <import namespace="System.Runtime.InteropServices" />
27 </imports>
28 <attributes>
29 <attribute type="ComVisibleAttribute" value="false" />
30 <attribute type="CLSCompliantAttribute" value="false" />
31 <attribute type="AssemblyVersionAttribute" value="${svnver}" />
32 <attribute type="AssemblyTitleAttribute" value="ogs-serverconsole" />
33 <attribute type="AssemblyDescriptionAttribute" value="The default server console" />
34 <attribute type="AssemblyCopyrightAttribute" value="Copyright © OGS development team 2007"/>
35 </attributes>
36 </asminfo>
37
38 <csc target="library" output="../common/bin/ServerConsole.dll" debug="${debug}" verbose="true" warninglevel="4">
39 <references>
40 <include name="System" />
41 <include name="System.Xml" />
42 </references>
43 <sources>
44 <include name="*.cs" />
45 </sources>
46 </csc>
47 </target>
48</project>
diff --git a/ogs/common/src/OGS-Console.cs b/ogs/common/src/OGS-Console.cs
new file mode 100644
index 0000000..c35c75c
--- /dev/null
+++ b/ogs/common/src/OGS-Console.cs
@@ -0,0 +1,181 @@
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
28using System;
29using System.Collections;
30using System.Collections.Generic;
31using System.Threading;
32using System.IO;
33using System.Net;
34using ServerConsole;
35
36namespace OpenGridServices
37{
38 /// <summary>
39 /// Description of ServerConsole.
40 /// </summary>
41 public class MServerConsole : ConsoleBase
42 {
43
44 private ConsoleType ConsType;
45 StreamWriter Log;
46 public conscmd_callback cmdparser;
47 public string componentname;
48
49 // STUPID HACK ALERT!!!! STUPID HACK ALERT!!!!!
50 // constype - the type of console to use (see enum ConsoleType)
51 // sparam - depending on the console type:
52 // TCP - the IP to bind to (127.0.0.1 if blank)
53 // Local - param ignored
54 // and for the iparam:
55 // TCP - the port to bind to
56 // Local - param ignored
57 // LogFile - duh
58 // componentname - which component of the OGS system? (user, asset etc)
59 // cmdparser - a reference to a conscmd_callback object
60
61 public MServerConsole(ConsoleType constype, string sparam, int iparam, string LogFile, string componentname, conscmd_callback cmdparser) {
62 ConsType = constype;
63 this.componentname = componentname;
64 this.cmdparser = cmdparser;
65 switch(constype) {
66 case ConsoleType.Local:
67 Console.WriteLine("ServerConsole.cs - creating new local console");
68 Console.WriteLine("Logs will be saved to current directory in " + LogFile);
69 Log=File.AppendText(LogFile);
70 Log.WriteLine("========================================================================");
71 Log.WriteLine(componentname + " " + VersionInfo.Version + " Started at " + DateTime.Now.ToString());
72 break;
73
74 case ConsoleType.TCP:
75 break;
76
77 default:
78 Console.WriteLine("ServerConsole.cs - what are you smoking? that isn't a valid console type!");
79 break;
80 }
81 }
82
83 public override void Close() {
84 Log.WriteLine("Shutdown at " + DateTime.Now.ToString());
85 Log.Close();
86 }
87
88 // You know what ReadLine() and WriteLine() do, right? And Read() and Write()? Right, you do actually know C#, right? Are you actually a programmer? Do you know english? Do you find my sense of humour in comments irritating? Good, glad you're still here
89 public override void WriteLine(string Line) {
90 Log.WriteLine(Line);
91 Console.WriteLine(Line);
92 return;
93 }
94
95 public override string ReadLine() {
96 string TempStr=Console.ReadLine();
97 Log.WriteLine(TempStr);
98 return TempStr;
99 }
100
101 public override int Read() {
102 int TempInt= Console.Read();
103 Log.Write((char)TempInt);
104 return TempInt;
105 }
106
107 public override void Write(string Line) {
108 Console.Write(Line);
109 Log.Write(Line);
110 return;
111 }
112
113
114 // Displays a prompt and waits for the user to enter a string, then returns that string
115 // Done with no echo and suitable for passwords
116 public override string PasswdPrompt(string prompt) {
117 // FIXME: Needs to be better abstracted
118 Log.WriteLine(prompt);
119 this.Write(prompt);
120 ConsoleColor oldfg=Console.ForegroundColor;
121 Console.ForegroundColor=Console.BackgroundColor;
122 string temp=Console.ReadLine();
123 Console.ForegroundColor=oldfg;
124 return temp;
125 }
126
127 // Displays a command prompt and waits for the user to enter a string, then returns that string
128 public override string CmdPrompt(string prompt) {
129 this.Write(prompt);
130 return this.ReadLine();
131 }
132
133 // Displays a command prompt and returns a default value if the user simply presses enter
134 public override string CmdPrompt(string prompt, string defaultresponse) {
135 string temp=CmdPrompt(prompt);
136 if(temp=="") {
137 return defaultresponse;
138 } else {
139 return temp;
140 }
141 }
142
143 // Displays a command prompt and returns a default value, user may only enter 1 of 2 options
144 public override string CmdPrompt(string prompt, string defaultresponse, string OptionA, string OptionB) {
145 bool itisdone=false;
146 string temp=CmdPrompt(prompt,defaultresponse);
147 while(itisdone==false) {
148 if((temp==OptionA) || (temp==OptionB)) {
149 itisdone=true;
150 } else {
151 this.WriteLine("Valid options are " + OptionA + " or " + OptionB);
152 temp=CmdPrompt(prompt,defaultresponse);
153 }
154 }
155 return temp;
156 }
157
158 // Runs a command with a number of parameters
159 public override Object RunCmd(string Cmd, string[] cmdparams) {
160 cmdparser.RunCmd(Cmd, cmdparams);
161 return null;
162 }
163
164 // Shows data about something
165 public override void ShowCommands(string ShowWhat) {
166 cmdparser.Show(ShowWhat);
167 }
168
169 public override void MainConsolePrompt() {
170 string[] tempstrarray;
171 string tempstr = this.CmdPrompt(this.componentname + "# ");
172 tempstrarray = tempstr.Split(' ');
173 string cmd=tempstrarray[0];
174 Array.Reverse(tempstrarray);
175 Array.Resize<string>(ref tempstrarray,tempstrarray.Length-1);
176 Array.Reverse(tempstrarray);
177 string[] cmdparams=(string[])tempstrarray;
178 RunCmd(cmd,cmdparams);
179 }
180 }
181}
diff --git a/ogs/common/src/Util.cs b/ogs/common/src/Util.cs
new file mode 100644
index 0000000..1efa471
--- /dev/null
+++ b/ogs/common/src/Util.cs
@@ -0,0 +1,87 @@
1/*
2Copyright (c) OpenSim project, http://osgrid.org/
3
4* Copyright (c) <year>, <copyright holder>
5* All rights reserved.
6*
7* Redistribution and use in source and binary forms, with or without
8* modification, are permitted provided that the following conditions are met:
9* * Redistributions of source code must retain the above copyright
10* notice, this list of conditions and the following disclaimer.
11* * Redistributions in binary form must reproduce the above copyright
12* notice, this list of conditions and the following disclaimer in the
13* documentation and/or other materials provided with the distribution.
14* * Neither the name of the <organization> nor the
15* names of its contributors may be used to endorse or promote products
16* derived from this software without specific prior written permission.
17*
18* THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY
19* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
22* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28*/
29
30using System;
31using System.Collections.Generic;
32using System.Threading;
33using libsecondlife;
34using libsecondlife.Packets;
35
36namespace OpenGridServices
37{
38 /// <summary>
39 /// </summary>
40 ///
41 public class Util
42 {
43 public static ulong UIntsToLong(uint X, uint Y)
44 {
45 return Helpers.UIntsToLong(X,Y);
46 }
47 public Util()
48 {
49
50 }
51 }
52
53 public class QueItem {
54 public QueItem()
55 {
56 }
57
58 public Packet Packet;
59 public bool Incoming;
60 }
61
62
63 public class BlockingQueue< T > {
64 private Queue< T > _queue = new Queue< T >();
65 private object _queueSync = new object();
66
67 public void Enqueue(T value)
68 {
69 lock(_queueSync)
70 {
71 _queue.Enqueue(value);
72 Monitor.Pulse(_queueSync);
73 }
74 }
75
76 public T Dequeue()
77 {
78 lock(_queueSync)
79 {
80 if( _queue.Count < 1)
81 Monitor.Wait(_queueSync);
82
83 return _queue.Dequeue();
84 }
85 }
86 }
87}
diff --git a/ogs/common/src/VersionInfo.cs.template b/ogs/common/src/VersionInfo.cs.template
new file mode 100644
index 0000000..8f73b4b
--- /dev/null
+++ b/ogs/common/src/VersionInfo.cs.template
@@ -0,0 +1,37 @@
1/*
2Copyright (c) OpenSim project, http://osgrid.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
27using System;
28
29namespace OpenGridServices
30{
31 /// <summary>
32 /// </summary>
33 public class VersionInfo
34 {
35 public static string Version = "@@VERSION";
36 }
37}
diff --git a/ogs/genvers.sh b/ogs/genvers.sh
new file mode 100644
index 0000000..8d8007c
--- /dev/null
+++ b/ogs/genvers.sh
@@ -0,0 +1,9 @@
1#!/bin/bash
2
3MAJOR=0
4MINOR=1
5BUILD=`date +%s`
6REVISION=`svnversion . | sed s/:// | sed s/M//`
7REALREVISION=`svnversion`
8cat common/src/VersionInfo.cs.template | sed s/@@VERSION/"$MAJOR.$MINOR, Build $BUILD, Revision $REALREVISION"/g >common/src/VersionInfo.cs
9echo -n $MAJOR.$MINOR.*.$REVISION >VERSION
diff --git a/ogs/gridserver/default.build b/ogs/gridserver/default.build
new file mode 100644
index 0000000..b113b83
--- /dev/null
+++ b/ogs/gridserver/default.build
@@ -0,0 +1,64 @@
1<?xml version="1.0"?>
2 <project name="GridServer" default="build" basedir="./">
3 <property name="debug" value="true" overwrite="false" />
4 <target name="clean" description="remove all generated files">
5 <delete>
6 <fileset failonempty="false">
7 <include name="bin/*.dll" />
8 <include name="bin/*.exe" />
9 <include name="bin/*.mdb" />
10 </fileset>
11 </delete>
12 </target>
13
14 <target name="svnupdate" description="updates to latest SVN">
15 <exec program="svn">
16 <arg value="update" />
17 </exec>
18 </target>
19
20 <target name="upgrade" description="updates from SVN and then builds" depends="clean,svnupdate,build">
21
22 </target>
23
24 <target name="build" description="compiles the source code">
25
26 <loadfile file="../VERSION" property="svnver"/>
27 <asminfo output="src/AssemblyInfo.cs" language="CSharp">
28 <imports>
29 <import namespace="System" />
30 <import namespace="System.Reflection" />
31 <import namespace="System.Runtime.InteropServices" />
32 </imports>
33 <attributes>
34 <attribute type="ComVisibleAttribute" value="false" />
35 <attribute type="CLSCompliantAttribute" value="false" />
36 <attribute type="AssemblyVersionAttribute" value="${svnver}" />
37 <attribute type="AssemblyTitleAttribute" value="ogs-GridServer" />
38 <attribute type="AssemblyDescriptionAttribute" value="The core OGS Grid Server" />
39 <attribute type="AssemblyCopyrightAttribute" value="Copyright © OGS development team 2007"/>
40 </attributes>
41 </asminfo>
42
43 <csc target="exe" output="bin/GridServer.exe" debug="${debug}" verbose="true" warninglevel="4">
44 <references failonempty="true">
45 <include name="System" />
46 <include name="System.Xml" />
47 <include name="../common/bin/ServerConsole.dll" />
48 <include name="../common/bin/libsecondlife.dll" />
49 </references>
50 <sources>
51 <include name="../common/src/VersionInfo.cs" />
52 <include name="../common/src/OGS-Console.cs" />
53 <include name="../common/src/Util.cs" />
54 <include name="src/*.cs" />
55 </sources>
56 </csc>
57
58 <copy todir="bin/">
59 <fileset basedir="../common/bin">
60 <include name="*.*" />
61 </fileset>
62 </copy>
63 </target>
64</project>
diff --git a/ogs/gridserver/gridserver_config.inc.php b/ogs/gridserver/gridserver_config.inc.php
index 98ebed3..e69de29 100644
--- a/ogs/gridserver/gridserver_config.inc.php
+++ b/ogs/gridserver/gridserver_config.inc.php
@@ -1,14 +0,0 @@
1<?
2// All the grid server specific stuff lives here
3
4// What we send to authenticate to the user/login server
5$userserver_sendkey="1234";
6
7// What we expect to get back from the user/login server
8$userserver_recvkey="1234";
9
10$sim_recvkey = "1234";
11$sim_sendkey = "1234";
12
13$grid_home = "/ogs/gridserver/";
14?>
diff --git a/ogs/gridserver/index.php b/ogs/gridserver/index.php
index f7754c6..e69de29 100644
--- a/ogs/gridserver/index.php
+++ b/ogs/gridserver/index.php
@@ -1,176 +0,0 @@
1<?
2error_reporting(E_ALL); // yes, we remember this from the login server, don't we boys and girls? don't kill innocent XML-RPC!
3
4// these files are soooo common..... (to the grid)
5include("../common/xmlrpc.inc.php");
6include("../common/database.inc.php");
7include("../common/grid_config.inc.php");
8include("../common/util.inc.php");
9
10include("gridserver_config.inc.php"); // grid server specific config stuff
11
12function get_sim_info($args) {
13 global $dbhost,$dbuser,$dbpasswd,$dbname;
14 global $userserver_sendkey, $userserver_recvkey;
15
16 // First see who's talking to us, if key is invalid then send an invalid one back and nothing more
17 if($args['authkey']!=$userserver_recvkey) {
18 return Array(
19 'authkey' => 'I can play the bad key trick too you know',
20 'login' => 'false'
21 );
22 }
23
24 // if we get to here, the key is valid, give that login server what it wants!
25
26 $link = mysql_connect($dbhost,$dbuser,$dbpasswd)
27 OR die("Unable to connect to database");
28
29 mysql_select_db($dbname)
30 or die("Unable to select database");
31
32 $region_handle = $args['region_handle'];
33 $query = "SELECT * FROM region_profiles WHERE region_handle='$region_handle'";
34 $result = mysql_query($query);
35
36 return mysql_fetch_assoc($result);
37}
38
39function get_session_info($args) {
40 global $dbhost,$dbuser,$dbpasswd,$dbname;
41 global $sim_sendkey, $sim_recvkey;
42
43 // authkey, session-id, agent-id
44
45 // First see who's talking to us, if key is invalid then send an invalid one back and nothing more
46 if($args[0]!=$sim_recvkey) {
47 return Array(
48 'authkey' => "I can play the bad key trick too you know"
49 );
50 }
51
52 $link = mysql_connect($dbhost,$dbuser,$dbpasswd)
53 OR die("Unable to connect to database");
54
55 mysql_select_db($dbname)
56 or die("Unable to select database");
57
58 $session_id = $args[1];
59 $agent_id = $args[2];
60
61 $query = "SELECT * FROM sessions WHERE session_id = '$session_id' AND agent_id='$agent_id' AND session_active=1";
62 $result = mysql_query($query);
63 if(mysql_num_rows($result)>0) {
64 $info=mysql_fetch_assoc($result);
65 $circuit_code = $info['circuit_code'];
66 $secure_session_id=$info['secure_session_id'];
67
68 $query = "SELECT * FROM local_user_profiles WHERE userprofile_LLUUID='$agent_id'";
69 $result=mysql_query($query);
70 $userinfo=mysql_fetch_assoc($result);
71 $firstname=$userinfo['profile_firstname'];
72 $lastname=$userinfo['profile_lastname'];
73 $agent_id=$userinfo['userprofile_LLUUID'];
74 return Array(
75 'authkey' => $sim_sendkey,
76 'circuit_code' => $circuit_code,
77 'agent_id' => $agent_id,
78 'session_id' => $session_id,
79 'secure_session_id' => $secure_session_id,
80 'firstname' => $firstname,
81 'lastname' => $lastname
82 );
83 }
84}
85
86function check_loggedin($args) {
87 global $dbhost,$dbuser,$dbpasswd,$dbname;
88 global $userserver_sendkey, $userserver_recvkey;
89
90 // First see who's talking to us, if key is invalid then send an invalid one back and nothing more
91 if($args['authkey']!=$userserver_recvkey) {
92 return Array(
93 'authkey' => "I can play the bad key trick too you know"
94 );
95 }
96
97 // if we get to here, the key is valid, give that login server what it wants!
98
99 $link = mysql_connect($dbhost,$dbuser,$dbpasswd)
100 OR die("Unable to connect to database");
101
102 mysql_select_db($dbname)
103 or die("Unable to select database");
104
105 $userprofile_LLUUID = $args['userprofile_LLUUID'];
106 $query = "SELECT * FROM sessions WHERE agent_id='$userprofile_LLUUID' AND session_active=1";
107 $result = mysql_query($query);
108
109 if(mysql_num_rows($result)>1) {
110 return Array(
111 'authkey' => $userserver_sendkey,
112 'logged_in' => 1
113 );
114 } else {
115 return Array(
116 'authkey' => $userserver_sendkey,
117 'logged_in' => 0
118 );
119 }
120}
121
122function create_session($args) {
123 global $dbhost,$dbuser,$dbpasswd,$dbname;
124 global $userserver_sendkey, $userserver_recvkey;
125
126 // First see who's talking to us, if key is invalid then send an invalid one back and nothing more
127 if($args['authkey']!=$userserver_recvkey) {
128 return Array(
129 'authkey' => "I can play the bad key trick too you know"
130 );
131 }
132
133 // if we get to here, the key is valid, give that login server what it wants!
134
135 $link = mysql_connect($dbhost,$dbuser,$dbpasswd)
136 OR die("Unable to connect to database");
137
138 mysql_select_db($dbname)
139 or die("Unable to select database");
140
141 // yes, secure_sessionid should be different, i know...
142 $query = "SELECT value FROM Grid_settings WHERE setting='highest_LLUUID'";
143 $result = mysql_query($query);
144 $row = mysql_fetch_array($result);
145 $highest_LLUUID = $row['value'];
146 $newsession_id=inc_lluuid($highest_LLUUID);
147 $secure_session_id=inc_lluuid($newsession_id);
148
149 $query="UPDATE Grid_settings SET value='$secure_session_id' WHERE setting='highest_LLUUID' LIMIT 1";
150 $result=mysql_query($query);
151
152 $userprofile_LLUUID=$args['userprofile_LLUUID'];
153 $current_location=$args['current_location'];
154 $remote_ip=$args['remote_ip'];
155 $query="INSERT INTO sessions(session_id,secure_session_id,agent_id,session_start,session_active,current_location,remote_ip) VALUES('$newsession_id','$secure_session_id','$userprofile_LLUUID',NOW(),1,'$current_location','$remote_ip')";
156 $result=mysql_query($query);
157 if(!isset($result)) {
158 die();
159 }
160 return Array(
161 'authkey' => $userserver_sendkey,
162 'session_id' => $newsession_id,
163 'secure_session_id' => $secure_session_id
164 );
165}
166
167$server=new IXR_Server(
168 Array(
169 'check_session_loggedin' => 'check_loggedin',
170 'create_session' => 'create_session',
171 'get_sim_info' => 'get_sim_info',
172 'get_session_info' => 'get_session_info'
173 )
174);
175
176?> \ No newline at end of file
diff --git a/ogs/gridserver/src/ConsoleCmds.cs b/ogs/gridserver/src/ConsoleCmds.cs
new file mode 100644
index 0000000..82a2279
--- /dev/null
+++ b/ogs/gridserver/src/ConsoleCmds.cs
@@ -0,0 +1,57 @@
1/*
2Copyright (c) OpenSim project, http://osgrid.org/
3
4
5* All rights reserved.
6*
7* Redistribution and use in source and binary forms, with or without
8* modification, are permitted provided that the following conditions are met:
9* * Redistributions of source code must retain the above copyright
10* notice, this list of conditions and the following disclaimer.
11* * Redistributions in binary form must reproduce the above copyright
12* notice, this list of conditions and the following disclaimer in the
13* documentation and/or other materials provided with the distribution.
14* * Neither the name of the <organization> nor the
15* names of its contributors may be used to endorse or promote products
16* derived from this software without specific prior written permission.
17*
18* THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY
19* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
22* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28*/
29
30using System;
31using System.Text;
32using ServerConsole;
33
34namespace OpenGridServices
35{
36
37 public class GridConsole : conscmd_callback {
38 public GridConsole() { }
39
40 public override void RunCmd(string cmd, string[] cmdparams) {
41 switch(cmd) {
42 case "help":
43 ServerConsole.MainConsole.Instance.WriteLine("shutdown - shutdown the grid (USE CAUTION!)"
44);
45 break;
46
47 case "shutdown":
48 ServerConsole.MainConsole.Instance.Close();
49 Environment.Exit(0);
50 break;
51 }
52 }
53
54 public override void Show(string ShowWhat) {
55 }
56 }
57}
diff --git a/ogs/gridserver/src/GridHttp.cs b/ogs/gridserver/src/GridHttp.cs
new file mode 100644
index 0000000..833a8ac
--- /dev/null
+++ b/ogs/gridserver/src/GridHttp.cs
@@ -0,0 +1,165 @@
1/*
2Copyright (c) OpenGrid project, http://osgrid.org/
3
4
5* All rights reserved.
6*
7* Redistribution and use in source and binary forms, with or without
8* modification, are permitted provided that the following conditions are met:
9* * Redistributions of source code must retain the above copyright
10* notice, this list of conditions and the following disclaimer.
11* * Redistributions in binary form must reproduce the above copyright
12* notice, this list of conditions and the following disclaimer in the
13* documentation and/or other materials provided with the distribution.
14* * Neither the name of the <organization> nor the
15* names of its contributors may be used to endorse or promote products
16* derived from this software without specific prior written permission.
17*
18* THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY
19* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
22* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28*/
29
30using System;
31using System.Text;
32using Nwc.XmlRpc;
33using System.Threading;
34using System.Text.RegularExpressions;
35using System.Net;
36using System.IO;
37using System.Collections;
38using System.Collections.Generic;
39using libsecondlife;
40using ServerConsole;
41
42namespace OpenGridServices
43{
44 public class GridHTTPServer {
45 public Thread HTTPD;
46 public HttpListener Listener;
47
48 public GridHTTPServer() {
49 ServerConsole.MainConsole.Instance.WriteLine("Starting up HTTP Server");
50 HTTPD = new Thread(new ThreadStart(StartHTTP));
51 HTTPD.Start();
52 }
53
54 public void StartHTTP() {
55 ServerConsole.MainConsole.Instance.WriteLine("GridHttp.cs:StartHTTP() - Spawned main thread OK");
56 Listener = new HttpListener();
57
58 Listener.Prefixes.Add("http://+:8001/gridserver/");
59 Listener.Start();
60
61 HttpListenerContext context;
62 while(true) {
63 context = Listener.GetContext();
64 ThreadPool.QueueUserWorkItem(new WaitCallback(HandleRequest), context);
65 }
66 }
67
68 static string ParseXMLRPC(string requestBody) {
69 try{
70 XmlRpcRequest request = (XmlRpcRequest)(new XmlRpcRequestDeserializer()).Deserialize(requestBody);
71
72 Hashtable requestData = (Hashtable)request.Params[0];
73 switch(request.MethodName) {
74 case "get_sim_info":
75 ulong req_handle=(ulong)Convert.ToInt64(requestData["region_handle"]);
76 SimProfile TheSim = OpenGrid_Main.thegrid._regionmanager.GetProfileByHandle(req_handle);
77 string RecvKey="";
78 string caller=(string)requestData["caller"];
79 switch(caller) {
80 case "userserver":
81 RecvKey=OpenGrid_Main.thegrid.UserRecvKey;
82 break;
83 case "assetserver":
84 RecvKey=OpenGrid_Main.thegrid.AssetRecvKey;
85 break;
86 }
87 if((TheSim!=null) && (string)requestData["authkey"]==RecvKey) {
88 XmlRpcResponse SimInfoResp = new XmlRpcResponse();
89 Hashtable SimInfoData = new Hashtable();
90 SimInfoData["UUID"]=TheSim.UUID.ToString();
91 SimInfoData["regionhandle"]=TheSim.regionhandle.ToString();
92 SimInfoData["regionname"]=TheSim.regionname;
93 SimInfoData["sim_ip"]=TheSim.sim_ip;
94 SimInfoData["sim_port"]=TheSim.sim_port.ToString();
95 SimInfoData["caps_url"]=TheSim.caps_url;
96 SimInfoData["RegionLocX"]=TheSim.RegionLocX.ToString();
97 SimInfoData["RegionLocY"]=TheSim.RegionLocY.ToString();
98 SimInfoData["sendkey"]=TheSim.sendkey;
99 SimInfoData["recvkey"]=TheSim.recvkey;
100 SimInfoResp.Value=SimInfoData;
101 return(Regex.Replace(XmlRpcResponseSerializer.Singleton.Serialize(SimInfoResp),"utf-16","utf-8"));
102 } else {
103 XmlRpcResponse SimErrorResp = new XmlRpcResponse();
104 Hashtable SimErrorData = new Hashtable();
105 SimErrorData["error"]="sim not found";
106 SimErrorResp.Value=SimErrorData;
107 return(XmlRpcResponseSerializer.Singleton.Serialize(SimErrorResp));
108 }
109 break;
110 }
111 } catch(Exception e) {
112 Console.WriteLine(e.ToString());
113 }
114 return "";
115 }
116
117 static string ParseREST(string requestBody, string requestURL) {
118 return "";
119 }
120
121
122 static void HandleRequest(Object stateinfo) {
123 HttpListenerContext context=(HttpListenerContext)stateinfo;
124
125 HttpListenerRequest request = context.Request;
126 HttpListenerResponse response = context.Response;
127
128 response.KeepAlive=false;
129 response.SendChunked=false;
130
131 System.IO.Stream body = request.InputStream;
132 System.Text.Encoding encoding = System.Text.Encoding.UTF8;
133 System.IO.StreamReader reader = new System.IO.StreamReader(body, encoding);
134
135 string requestBody = reader.ReadToEnd();
136 body.Close();
137 reader.Close();
138
139 string responseString="";
140 switch(request.ContentType) {
141 case "text/xml":
142 // must be XML-RPC, so pass to the XML-RPC parser
143
144 responseString=ParseXMLRPC(requestBody);
145 response.AddHeader("Content-type","text/xml");
146 break;
147
148 case null:
149 // must be REST or invalid crap, so pass to the REST parser
150 responseString=ParseREST(request.Url.OriginalString,requestBody);
151 break;
152 }
153
154
155 byte[] buffer = System.Text.Encoding.UTF8.GetBytes(responseString);
156 System.IO.Stream output = response.OutputStream;
157 response.SendChunked=false;
158 response.ContentLength64=buffer.Length;
159 output.Write(buffer,0,buffer.Length);
160 output.Close();
161 }
162 }
163
164
165}
diff --git a/ogs/gridserver/src/Main.cs b/ogs/gridserver/src/Main.cs
new file mode 100644
index 0000000..d29a1ae
--- /dev/null
+++ b/ogs/gridserver/src/Main.cs
@@ -0,0 +1,94 @@
1/*
2Copyright (c) OpenSim project, http://osgrid.org/
3
4
5* All rights reserved.
6*
7* Redistribution and use in source and binary forms, with or without
8* modification, are permitted provided that the following conditions are met:
9* * Redistributions of source code must retain the above copyright
10* notice, this list of conditions and the following disclaimer.
11* * Redistributions in binary form must reproduce the above copyright
12* notice, this list of conditions and the following disclaimer in the
13* documentation and/or other materials provided with the distribution.
14* * Neither the name of the <organization> nor the
15* names of its contributors may be used to endorse or promote products
16* derived from this software without specific prior written permission.
17*
18* THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY
19* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
22* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28*/
29
30using System;
31using System.Text;
32using libsecondlife;
33using ServerConsole;
34
35namespace OpenGridServices
36{
37 /// <summary>
38 /// </summary>
39 public class OpenGrid_Main
40 {
41
42 public static OpenGrid_Main thegrid;
43 public string GridOwner;
44 public string DefaultStartupMsg;
45 public string DefaultAssetServer;
46 public string AssetSendKey;
47 public string AssetRecvKey;
48 public string DefaultUserServer;
49 public string UserSendKey;
50 public string UserRecvKey;
51
52 public GridHTTPServer _httpd;
53 public SimProfileManager _regionmanager;
54
55 [STAThread]
56 public static void Main( string[] args )
57 {
58 Console.WriteLine("OpenGrid " + VersionInfo.Version + "\n");
59 Console.WriteLine("Starting...\n");
60 ServerConsole.MainConsole.Instance = new MServerConsole(ServerConsole.ConsoleBase.ConsoleType.Local, "", 0, "opengrid-console.log", "OpenGrid", new GridConsole());
61
62 thegrid = new OpenGrid_Main();
63 thegrid.Startup();
64
65 ServerConsole.MainConsole.Instance.WriteLine("\nEnter help for a list of commands\n");
66
67 while(true) {
68 ServerConsole.MainConsole.Instance.MainConsolePrompt();
69 }
70 }
71
72 public void Startup() {
73 ServerConsole.MainConsole.Instance.WriteLine("Main.cs:Startup() - Please press enter to retain default settings");
74
75 this.GridOwner=ServerConsole.MainConsole.Instance.CmdPrompt("Grid owner [OGS development team]: ","OGS development team");
76 this.DefaultStartupMsg=ServerConsole.MainConsole.Instance.CmdPrompt("Default startup message for clients [Welcome to OGS!]: ","Welcome to OGS!");
77
78 this.DefaultAssetServer=ServerConsole.MainConsole.Instance.CmdPrompt("Default asset server [no default]: ");
79 this.AssetSendKey=ServerConsole.MainConsole.Instance.CmdPrompt("Key to send to asset server: ");
80 this.AssetRecvKey=ServerConsole.MainConsole.Instance.CmdPrompt("Key to expect from asset server: ");
81
82 this.DefaultUserServer=ServerConsole.MainConsole.Instance.CmdPrompt("Default user server [no default]: ");
83 this.UserSendKey=ServerConsole.MainConsole.Instance.CmdPrompt("Key to send to user server: ");
84 this.UserRecvKey=ServerConsole.MainConsole.Instance.CmdPrompt("Key to expect from user server: ");
85
86 ServerConsole.MainConsole.Instance.WriteLine("Main.cs:Startup() - Starting HTTP process");
87 _httpd = new GridHTTPServer();
88
89 this._regionmanager=new SimProfileManager();
90 _regionmanager.CreateNewProfile("OpenSim Test", "http://there-is-no-caps.com", "4.78.190.75", 9000, 997, 996, this.UserSendKey, this.UserRecvKey);
91
92 }
93 }
94}
diff --git a/ogs/gridserver/src/SimProfiles.cs b/ogs/gridserver/src/SimProfiles.cs
new file mode 100644
index 0000000..91a92ea
--- /dev/null
+++ b/ogs/gridserver/src/SimProfiles.cs
@@ -0,0 +1,111 @@
1/*
2Copyright (c) OpenGrid project, http://osgrid.org/
3
4
5* All rights reserved.
6*
7* Redistribution and use in source and binary forms, with or without
8* modification, are permitted provided that the following conditions are met:
9* * Redistributions of source code must retain the above copyright
10* notice, this list of conditions and the following disclaimer.
11* * Redistributions in binary form must reproduce the above copyright
12* notice, this list of conditions and the following disclaimer in the
13* documentation and/or other materials provided with the distribution.
14* * Neither the name of the <organization> nor the
15* names of its contributors may be used to endorse or promote products
16* derived from this software without specific prior written permission.
17*
18* THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY
19* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
22* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28*/
29
30using System;
31using System.Text;
32using System.Collections;
33using System.Collections.Generic;
34using libsecondlife;
35using ServerConsole;
36
37namespace OpenGridServices
38{
39 /// <summary>
40 /// </summary>
41 public class SimProfileManager {
42
43 public Dictionary<LLUUID, SimProfile> SimProfiles = new Dictionary<LLUUID, SimProfile>();
44
45 public SimProfileManager() {
46 }
47
48 public void InitSimProfiles() {
49 // TODO: need to load from database
50 }
51
52 public SimProfile GetProfileByHandle(ulong reqhandle) {
53 foreach (libsecondlife.LLUUID UUID in SimProfiles.Keys) {
54 if(SimProfiles[UUID].regionhandle==reqhandle) return SimProfiles[UUID];
55 }
56 return null;
57 }
58
59 public SimProfile GetProfileByLLUUID(LLUUID ProfileLLUUID) {
60 return SimProfiles[ProfileLLUUID];
61 }
62
63 public bool AuthenticateSim(LLUUID RegionUUID, uint regionhandle, string simrecvkey) {
64 SimProfile TheSim=GetProfileByHandle(regionhandle);
65 if(TheSim != null)
66 if(TheSim.recvkey==simrecvkey) {
67 return true;
68 } else {
69 return false;
70 } else return false;
71
72 }
73
74 public SimProfile CreateNewProfile(string regionname, string caps_url, string sim_ip, uint sim_port, uint RegionLocX, uint RegionLocY, string sendkey, string recvkey) {
75 SimProfile newprofile = new SimProfile();
76 newprofile.regionname=regionname;
77 newprofile.sim_ip=sim_ip;
78 newprofile.sim_port=sim_port;
79 newprofile.RegionLocX=RegionLocX;
80 newprofile.RegionLocY=RegionLocY;
81 newprofile.caps_url="http://" + sim_ip + ":9000/";
82 newprofile.sendkey=sendkey;
83 newprofile.recvkey=recvkey;
84 newprofile.regionhandle=Util.UIntsToLong((RegionLocX*256), (RegionLocY*256));
85 newprofile.UUID=LLUUID.Random();
86 this.SimProfiles.Add(newprofile.UUID,newprofile);
87 return newprofile;
88 }
89
90 }
91
92 public class SimProfile {
93 public LLUUID UUID;
94 public ulong regionhandle;
95 public string regionname;
96 public string sim_ip;
97 public uint sim_port;
98 public string caps_url;
99 public uint RegionLocX;
100 public uint RegionLocY;
101 public string sendkey;
102 public string recvkey;
103
104
105 public SimProfile() {
106 }
107
108
109 }
110
111}
diff --git a/ogs/login/index.php b/ogs/login/index.php
deleted file mode 100644
index 4f53c11..0000000
--- a/ogs/login/index.php
+++ /dev/null
@@ -1,170 +0,0 @@
1<?
2error_reporting(0); // Remember kids, PHP errors kill XML-RPC responses!
3
4// include all the common stuff
5include("../common/xmlrpc.inc.php");
6include("../common/database.inc.php");
7include("../common/grid_config.inc.php");
8include("../common/util.inc.php");
9
10include("login_config.inc.php"); // include login/user specific config stuff (authentication keys etc)
11
12function login($args) {
13 global $dbhost,$dbuser,$dbpasswd,$dbname;
14 global $grid_owner, $gridserver_sendkey, $gridserver_recvkey, $gridserver_url;
15
16
17 if(get_magic_quotes_gpc()) {
18 $firstname=addslashes($args['first']);
19 $lastname=addslashes($args['last']);
20 $passwd=addslashes($args['passwd']);
21 } else {
22 $firstname=$args['first'];
23 $lastname=$args['last'];
24 $passwd=$args['passwd'];
25 }
26
27 $link = mysql_connect($dbhost,$dbuser,$dbpasswd)
28 OR die("Unable to connect to database");
29
30 mysql_select_db($dbname)
31 or die("Unable to select database");
32
33 $query = "SELECT userprofile_LLUUID, profile_firstname, profile_lastname, profile_passwdmd5, homesim_ip, homesim_port, homeasset_url, look_at, region_handle, position FROM local_user_profiles WHERE profile_firstname='".$firstname."' AND profile_lastname='".$lastname."' AND profile_passwdmd5='" .$passwd."'";
34
35 $profile_lookup_result=mysql_query($query);
36
37 if(mysql_num_rows($profile_lookup_result) >0) {
38 $profiledata = mysql_fetch_assoc($profile_lookup_result);
39
40 // if we get here, the username/password is valid, but still need to check there's not an already existing session
41 $client = new IXR_Client($gridserver_url);
42 if (!$client->query('check_session_loggedin', Array('userprofile_LLUUID' => $profiledata['userprofile_LLUUID'], 'authkey' => $gridserver_sendkey, 'server_type' => 'login'))) { // if this doesn't work, grid server is down - that's bad
43 return Array (
44 'reason' => 'key',
45 'message' => "Could not connect to grid server. Please try again later or contact the grid owner ". $grid_owner,
46 'login' => "false"
47 );
48 }
49
50 $response=$client->getResponse();
51 if($response['authkey'] != $gridserver_recvkey) { // if this doesn't match up, it's a fake grid server
52 return Array (
53 'reason' => 'key',
54 'message' => "Could not connect to grid server due to possible security issues. It is possible that the grid has been compromised. Please contact the grid owner " . $grid_owner . " and report this issue",
55 'login' => "false"
56 );
57 }
58
59
60 if($response['logged_in'] == 1) { // if the user is already logged in, tell them
61 return Array (
62 'reason' => 'presence',
63 'message' => "You appear to already be logged into this grid, if your client has recently crashed then please try again later",
64 'login' => "false"
65 );
66 }
67
68 // now we start a new session on the grid
69 $remote_ip=$_SERVER['REMOTE_ADDR'];
70 $region_handle=$profiledata['region_handle'];
71 $client->query('create_session',Array('userprofile_LLUUID' => $profiledata['userprofile_LLUUID'], 'authkey' => $gridserver_sendkey, 'remote_ip' => $remote_ip, 'current_location' => $region_handle));
72 $response = $client->getResponse();
73 $session_id = $response['session_id'];
74 $secure_session_id = $response['secure_session_id'];
75
76 // ask the grid server what the IP address and port of the sim we want to connect to is
77 $client->query('get_sim_info', Array('region_handle' => $region_handle, 'authkey' => $gridserver_sendkey) );
78 $siminfo = $client->getResponse();
79
80 // send the final response!
81 $position=$profiledata['position'];
82 $look_at=$profiledata['look_at'];
83
84 $LocX=intval($siminfo['GridLocX'])*256;
85 $LocY=intval($siminfo['GridLocY'])*256;
86 $home="{'region_handle':'$region_handle', 'position':'$position', 'look_at':'$look_at'}";
87
88 $globaltextures = new LLBlock(
89 Array(
90 'sun_texture_id' => "cce0f112-878f-4586-a2e2-a8f104bba271",
91 'cloud_texture_id' => "fc4b9f0b-d008-45c6-96a4-01dd947ac621",
92 'moon_texture_id' => "d07f6eed-b96a-47cd-b51d-400ad4a1c428"
93 ));
94
95 $login_flags = new LLBlock(
96 Array(
97 'stipend_since_login' => "N",
98 'ever_logged_in' => "Y",
99 'gendered' => "Y",
100 'daylight_savings' => "N"
101 ));
102 $ui_config = new LLBlock(
103 Array(
104 'allow_first_life' => "Y"
105 ));
106 $inventory_skeleton = new LLBlock(Array(
107 Array(
108 'name' => 'My inventory',
109 'parent_id' => '00000000-0000-0000-0000-000000000000',
110 'version' => 4,
111 'type_default' => 8,
112 'folder_id' => 'f798e114-c10f-409b-a90d-a11577ff1de8'
113 ),
114 Array(
115 'name' => 'Textures',
116 'parent_id' => 'f798e114-c10f-409b-a90d-a11577ff1de8',
117 'version' => 1,
118 'type_default' => 0,
119 'folder_id' => 'fc8b4059-30bb-43a8-a042-46f5b431ad82'
120 )));
121 $inventory_root = new LLBlock(
122 Array(
123 'folder_id' => "f798e114-c10f-409b-a90d-a11577ff1de8"
124 ));
125 $initial_outfit = new LLBlock(
126 Array(
127 'folder_name' => "Nightclub Female",
128 'gender' => "female"
129 ));
130 return Array (
131 'message' => "Welcome to OGS!",
132 'session_id' => format_lluuid($session_id),
133 'sim_port' => intval($siminfo['port']),
134 'agent_access' => "M",
135 'start_location' => "last",
136 'global-textures' => $globaltextures,
137 'seconds_since_epoch' => time(),
138 'first_name' => $profiledata['profile_firstname'],
139 'circuit_code' => 50633318,
140 'login_flags' => $login_flags,
141 'seed_capability' => '',
142 'home' => $home,
143 'secure_session_id' => format_lluuid($secure_session_id),
144 'last_name' => $profiledata['profile_lastname'],
145 'ui-config' => $ui_config,
146 'region_x' => $LocX,
147 'inventory_skeleton' => $inventory_skeleton,
148 'sim_ip' => $siminfo['ip_addr'],
149 'region_y' => $LocY,
150 'inventory-root' => $inventory_root,
151 'login' => "true",
152 'look_at' => $look_at,
153 'agent_id' => format_lluuid($profiledata['userprofile_LLUUID']),
154 'initial-outfit' => $initial_outfit
155 );
156
157
158 } else {
159 // this is the default invalid username/password error
160 return Array (
161 'reason' => 'key',
162 'message' => "You have entered an invalid name/password combination or are using an incompatible client. Please check with the grid owner " .$grid_owner . " if you are sure your login details are accurate.",
163 'login' => "false",
164 );
165 }
166
167}
168
169$server=new IXR_Server(array('login_to_simulator' => 'login'));
170?>
diff --git a/ogs/login/login_config.inc.php b/ogs/login/login_config.inc.php
deleted file mode 100644
index 4cce696..0000000
--- a/ogs/login/login_config.inc.php
+++ /dev/null
@@ -1,11 +0,0 @@
1<?
2// All the user/login server specific stuff lives here
3
4// What we send to authenticate to the grid server
5$gridserver_sendkey="1234";
6
7// What we expect to get back from the grid server
8$gridserver_recvkey="1234";
9
10$gridserver_url="http://www.osgrid.org/ogs/gridserver/index.php";
11?>
diff --git a/ogs/ogs.build b/ogs/ogs.build
new file mode 100644
index 0000000..303b1bf
--- /dev/null
+++ b/ogs/ogs.build
@@ -0,0 +1,38 @@
1<?xml version="1.0"?>
2 <project name="OGS" default="build" basedir=".">
3 <description>nant buildfile for OpenSim</description>
4 <property name="debug" value="true" overwrite="false" />
5 <target name="clean" description="remove all generated files">
6 <nant target="clean">
7 <buildfiles>
8 <include name="ServerConsole/default.build" />
9 <include name="gridserver/default.build" />
10 </buildfiles>
11 </nant>
12
13 </target>
14
15 <target name="svnupdate" description="updates to latest SVN">
16 <exec program="svn">
17 <arg value="update" />
18 </exec>
19 </target>
20
21 <target name="upgrade" description="updates from SVN and then builds" depends="clean,svnupdate,build">
22
23 </target>
24
25 <target name="build" description="compiles the source code">
26
27 <exec program="genvers.sh" />
28 <loadfile file="VERSION" property="svnver"/>
29
30 <nant>
31 <buildfiles>
32 <include name="ServerConsole/default.build" />
33 <include name="gridserver/default.build" />
34 </buildfiles>
35 </nant>
36
37 </target>
38</project>
diff --git a/ogs/userserver/default.build b/ogs/userserver/default.build
new file mode 100644
index 0000000..a56f925
--- /dev/null
+++ b/ogs/userserver/default.build
@@ -0,0 +1,63 @@
1<?xml version="1.0"?>
2 <project name="UserServer" default="build" basedir="./">
3 <property name="debug" value="true" overwrite="false" />
4 <target name="clean" description="remove all generated files">
5 <delete>
6 <fileset failonempty="false">
7 <include name="bin/*.dll" />
8 <include name="bin/*.exe" />
9 <include name="bin/*.mdb" />
10 </fileset>
11 </delete>
12 </target>
13
14 <target name="svnupdate" description="updates to latest SVN">
15 <exec program="svn">
16 <arg value="update" />
17 </exec>
18 </target>
19
20 <target name="upgrade" description="updates from SVN and then builds" depends="clean,svnupdate,build">
21
22 </target>
23
24 <target name="build" description="compiles the source code">
25
26 <loadfile file="../VERSION" property="svnver"/>
27 <asminfo output="src/AssemblyInfo.cs" language="CSharp">
28 <imports>
29 <import namespace="System" />
30 <import namespace="System.Reflection" />
31 <import namespace="System.Runtime.InteropServices" />
32 </imports>
33 <attributes>
34 <attribute type="ComVisibleAttribute" value="false" />
35 <attribute type="CLSCompliantAttribute" value="false" />
36 <attribute type="AssemblyVersionAttribute" value="${svnver}" />
37 <attribute type="AssemblyTitleAttribute" value="ogs-UserServer" />
38 <attribute type="AssemblyDescriptionAttribute" value="The core OGS User Server" />
39 <attribute type="AssemblyCopyrightAttribute" value="Copyright © OGS development team 2007"/>
40 </attributes>
41 </asminfo>
42
43 <csc target="exe" output="bin/UserServer.exe" debug="${debug}" verbose="true" warninglevel="4">
44 <references failonempty="true">
45 <include name="System" />
46 <include name="System.Xml" />
47 <include name="../common/bin/ServerConsole.dll" />
48 <include name="../common/bin/libsecondlife.dll" />
49 </references>
50 <sources>
51 <include name="../common/src/VersionInfo.cs" />
52 <include name="../common/src/OGS-Console.cs" />
53 <include name="src/*.cs" />
54 </sources>
55 </csc>
56
57 <copy todir="bin/">
58 <fileset basedir="../common/bin">
59 <include name="*.*" />
60 </fileset>
61 </copy>
62 </target>
63</project>
diff --git a/ogs/userserver/src/ConsoleCmds.cs b/ogs/userserver/src/ConsoleCmds.cs
new file mode 100644
index 0000000..f2568fc
--- /dev/null
+++ b/ogs/userserver/src/ConsoleCmds.cs
@@ -0,0 +1,57 @@
1/*
2Copyright (c) OpenSim project, http://osgrid.org/
3
4
5* All rights reserved.
6*
7* Redistribution and use in source and binary forms, with or without
8* modification, are permitted provided that the following conditions are met:
9* * Redistributions of source code must retain the above copyright
10* notice, this list of conditions and the following disclaimer.
11* * Redistributions in binary form must reproduce the above copyright
12* notice, this list of conditions and the following disclaimer in the
13* documentation and/or other materials provided with the distribution.
14* * Neither the name of the <organization> nor the
15* names of its contributors may be used to endorse or promote products
16* derived from this software without specific prior written permission.
17*
18* THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY
19* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
22* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28*/
29
30using System;
31using System.Text;
32using ServerConsole;
33
34namespace OpenGridServices
35{
36
37 public class UserConsole : conscmd_callback {
38 public UserConsole() { }
39
40 public override void RunCmd(string cmd, string[] cmdparams) {
41 switch(cmd) {
42 case "help":
43 ServerConsole.MainConsole.Instance.WriteLine("shutdown - shutdown the user server (USE CAUTION!)"
44);
45 break;
46
47 case "shutdown":
48 ServerConsole.MainConsole.Instance.Close();
49 Environment.Exit(0);
50 break;
51 }
52 }
53
54 public override void Show(string ShowWhat) {
55 }
56 }
57}
diff --git a/ogs/userserver/src/Main.cs b/ogs/userserver/src/Main.cs
new file mode 100644
index 0000000..40ef916
--- /dev/null
+++ b/ogs/userserver/src/Main.cs
@@ -0,0 +1,114 @@
1/*
2Copyright (c) OpenSim project, http://osgrid.org/
3
4
5* All rights reserved.
6*
7* Redistribution and use in source and binary forms, with or without
8* modification, are permitted provided that the following conditions are met:
9* * Redistributions of source code must retain the above copyright
10* notice, this list of conditions and the following disclaimer.
11* * Redistributions in binary form must reproduce the above copyright
12* notice, this list of conditions and the following disclaimer in the
13* documentation and/or other materials provided with the distribution.
14* * Neither the name of the <organization> nor the
15* names of its contributors may be used to endorse or promote products
16* derived from this software without specific prior written permission.
17*
18* THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY
19* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
22* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28*/
29
30using System;
31using System.Collections;
32using System.Collections.Generic;
33using System.Text;
34using libsecondlife;
35using ServerConsole;
36
37namespace OpenGridServices
38{
39 /// <summary>
40 /// </summary>
41 public class OpenUser_Main
42 {
43
44 public static OpenUser_Main userserver;
45
46 public UserHTTPServer _httpd;
47 public UserProfileManager _profilemanager;
48 public UserProfile GridGod;
49 public string DefaultStartupMsg;
50 public string GridURL;
51 public string GridSendKey;
52 public string GridRecvKey;
53
54 public Dictionary<LLUUID, UserProfile> UserSessions = new Dictionary<LLUUID, UserProfile>();
55
56 [STAThread]
57 public static void Main( string[] args )
58 {
59 Console.WriteLine("OpenUser " + VersionInfo.Version + "\n");
60 Console.WriteLine("Starting...\n");
61 ServerConsole.MainConsole.Instance = new MServerConsole(ServerConsole.ConsoleBase.ConsoleType.Local, "", 0, "opengrid-console.log", "OpenUser", new UserConsole());
62
63 userserver = new OpenUser_Main();
64 userserver.Startup();
65
66 ServerConsole.MainConsole.Instance.WriteLine("\nEnter help for a list of commands\n");
67
68 while(true) {
69 ServerConsole.MainConsole.Instance.MainConsolePrompt();
70 }
71 }
72
73 public void Startup() {
74 ServerConsole.MainConsole.Instance.WriteLine("Main.cs:Startup() - Please press enter to retain default settings");
75
76 this.GridURL=ServerConsole.MainConsole.Instance.CmdPrompt("Grid URL: ");
77 this.GridSendKey=ServerConsole.MainConsole.Instance.CmdPrompt("Key to send to grid: ");
78 this.GridRecvKey=ServerConsole.MainConsole.Instance.CmdPrompt("Key to expect from grid: ");
79
80 this.DefaultStartupMsg=ServerConsole.MainConsole.Instance.CmdPrompt("Default startup message for clients [Welcome to OGS!] :","Welcome to OGS!");
81
82 ServerConsole.MainConsole.Instance.WriteLine("Main.cs:Startup() - Creating user profile manager");
83 _profilemanager = new UserProfileManager();
84 _profilemanager.InitUserProfiles();
85
86
87 string tempfirstname;
88 string templastname;
89 string tempMD5Passwd;
90 ServerConsole.MainConsole.Instance.WriteLine("Main.cs:Startup() - Please configure the grid god user:");
91 tempfirstname=ServerConsole.MainConsole.Instance.CmdPrompt("First name: ");
92 templastname=ServerConsole.MainConsole.Instance.CmdPrompt("Last name: ");
93 tempMD5Passwd=ServerConsole.MainConsole.Instance.PasswdPrompt("Password: ");
94
95 System.Security.Cryptography.MD5CryptoServiceProvider x = new System.Security.Cryptography.MD5CryptoServiceProvider();
96 byte[] bs = System.Text.Encoding.UTF8.GetBytes(tempMD5Passwd);
97 bs = x.ComputeHash(bs);
98 System.Text.StringBuilder s = new System.Text.StringBuilder();
99 foreach (byte b in bs)
100 {
101 s.Append(b.ToString("x2").ToLower());
102 }
103 tempMD5Passwd = "$1$" + s.ToString();
104
105 GridGod=_profilemanager.CreateNewProfile(tempfirstname,templastname,tempMD5Passwd);
106 _profilemanager.SetGod(GridGod.UUID);
107 GridGod.homelookat = new LLVector3(-0.57343f, -0.819255f, 0f);
108 GridGod.homepos = new LLVector3(128f,128f,23f);
109
110 ServerConsole.MainConsole.Instance.WriteLine("Main.cs:Startup() - Starting HTTP process");
111 _httpd = new UserHTTPServer();
112 }
113 }
114}
diff --git a/ogs/userserver/src/UserHttp.cs b/ogs/userserver/src/UserHttp.cs
new file mode 100644
index 0000000..bc232fb
--- /dev/null
+++ b/ogs/userserver/src/UserHttp.cs
@@ -0,0 +1,287 @@
1/*
2Copyright (c) OpenGrid project, http://osgrid.org/
3
4
5* All rights reserved.
6*
7* Redistribution and use in source and binary forms, with or without
8* modification, are permitted provided that the following conditions are met:
9* * Redistributions of source code must retain the above copyright
10* notice, this list of conditions and the following disclaimer.
11* * Redistributions in binary form must reproduce the above copyright
12* notice, this list of conditions and the following disclaimer in the
13* documentation and/or other materials provided with the distribution.
14* * Neither the name of the <organization> nor the
15* names of its contributors may be used to endorse or promote products
16* derived from this software without specific prior written permission.
17*
18* THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY
19* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
22* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28*/
29
30using System;
31using System.Text;
32using Nwc.XmlRpc;
33using System.Threading;
34using System.Text.RegularExpressions;
35using System.Net;
36using System.IO;
37using System.Collections;
38using System.Collections.Generic;
39using libsecondlife;
40using ServerConsole;
41
42namespace OpenGridServices
43{
44 public class UserHTTPServer {
45 public Thread HTTPD;
46 public HttpListener Listener;
47
48 public UserHTTPServer() {
49 ServerConsole.MainConsole.Instance.WriteLine("Starting up HTTP Server");
50 HTTPD = new Thread(new ThreadStart(StartHTTP));
51 HTTPD.Start();
52 }
53
54 public void StartHTTP() {
55 ServerConsole.MainConsole.Instance.WriteLine("UserHttp.cs:StartHTTP() - Spawned main thread OK");
56 Listener = new HttpListener();
57
58 Listener.Prefixes.Add("http://+:8002/userserver/");
59 Listener.Prefixes.Add("http://+:8002/usersessions/");
60 Listener.Start();
61
62 HttpListenerContext context;
63 while(true) {
64 context = Listener.GetContext();
65 ThreadPool.QueueUserWorkItem(new WaitCallback(HandleRequest), context);
66 }
67 }
68
69 static string ParseXMLRPC(string requestBody) {
70 XmlRpcRequest request = (XmlRpcRequest)(new XmlRpcRequestDeserializer()).Deserialize(requestBody);
71
72 Hashtable requestData = (Hashtable)request.Params[0];
73 switch(request.MethodName) {
74 case "login_to_simulator":
75 bool GoodXML= (requestData.Contains("first") && requestData.Contains("last") && requestData.Contains("passwd"));
76 bool GoodLogin=false;
77 string firstname="";
78 string lastname="";
79 string passwd="";
80
81 if(GoodXML) {
82 firstname=(string)requestData["first"];
83 lastname=(string)requestData["last"];
84 passwd=(string)requestData["passwd"];
85 GoodLogin=OpenUser_Main.userserver._profilemanager.AuthenticateUser(firstname,lastname,passwd);
86 }
87
88
89 if(!(GoodXML && GoodLogin)) {
90 XmlRpcResponse LoginErrorResp = new XmlRpcResponse();
91 Hashtable ErrorRespData = new Hashtable();
92 ErrorRespData["reason"]="key";
93 ErrorRespData["message"]="Error connecting to grid. Please double check your login details and check with the grid owner if you are sure these are correct";
94 ErrorRespData["login"]="false";
95 LoginErrorResp.Value=ErrorRespData;
96 return(Regex.Replace(XmlRpcResponseSerializer.Singleton.Serialize(LoginErrorResp)," encoding=\"utf-16\"","" ));
97 }
98
99 UserProfile TheUser=OpenUser_Main.userserver._profilemanager.GetProfileByName(firstname,lastname);
100
101 if(!((TheUser.CurrentSessionID==null) && (TheUser.CurrentSecureSessionID==null))) {
102 XmlRpcResponse PresenceErrorResp = new XmlRpcResponse();
103 Hashtable PresenceErrorRespData = new Hashtable();
104 PresenceErrorRespData["reason"]="presence";
105 PresenceErrorRespData["message"]="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";
106 PresenceErrorRespData["login"]="false";
107 PresenceErrorResp.Value=PresenceErrorRespData;
108 return(Regex.Replace(XmlRpcResponseSerializer.Singleton.Serialize(PresenceErrorResp)," encoding=\"utf-16\"","" ));
109
110 }
111
112 try {
113 LLUUID AgentID = TheUser.UUID;
114 TheUser.InitSessionData();
115 SimProfile SimInfo = new SimProfile();
116 SimInfo = SimInfo.LoadFromGrid(TheUser.homeregionhandle,OpenUser_Main.userserver.GridURL,OpenUser_Main.userserver.GridSendKey,OpenUser_Main.userserver.GridRecvKey);
117
118 XmlRpcResponse LoginGoodResp = new XmlRpcResponse();
119 Hashtable LoginGoodData = new Hashtable();
120
121 Hashtable GlobalT = new Hashtable();
122 GlobalT["sun_texture_id"] = "cce0f112-878f-4586-a2e2-a8f104bba271";
123 GlobalT["cloud_texture_id"] = "fc4b9f0b-d008-45c6-96a4-01dd947ac621";
124 GlobalT["moon_texture_id"] = "fc4b9f0b-d008-45c6-96a4-01dd947ac621";
125 ArrayList GlobalTextures = new ArrayList();
126 GlobalTextures.Add(GlobalT);
127
128 Hashtable LoginFlagsHash = new Hashtable();
129 LoginFlagsHash["daylight_savings"]="N";
130 LoginFlagsHash["stipend_since_login"]="N";
131 LoginFlagsHash["gendered"]="Y";
132 LoginFlagsHash["ever_logged_in"]="Y";
133 ArrayList LoginFlags=new ArrayList();
134 LoginFlags.Add(LoginFlagsHash);
135
136 Hashtable uiconfig = new Hashtable();
137 uiconfig["allow_first_life"]="Y";
138 ArrayList ui_config=new ArrayList();
139 ui_config.Add(uiconfig);
140
141 Hashtable ClassifiedCategoriesHash = new Hashtable();
142 ClassifiedCategoriesHash["category_name"]="bla bla";
143 ClassifiedCategoriesHash["category_id"]=(Int32)1;
144 ArrayList ClassifiedCategories = new ArrayList();
145 ClassifiedCategories.Add(ClassifiedCategoriesHash);
146
147 ArrayList AgentInventory = new ArrayList();
148 foreach(InventoryFolder InvFolder in TheUser.InventoryFolders.Values) {
149 Hashtable TempHash = new Hashtable();
150 TempHash["name"]=InvFolder.FolderName;
151 TempHash["parent_id"]=InvFolder.ParentID.ToStringHyphenated();
152 TempHash["version"]=(Int32)InvFolder.Version;
153 TempHash["type_default"]=(Int32)InvFolder.DefaultType;
154 TempHash["folder_id"]=InvFolder.FolderID.ToStringHyphenated();
155 AgentInventory.Add(TempHash);
156 }
157
158 Hashtable InventoryRootHash = new Hashtable();
159 InventoryRootHash["folder_id"]=TheUser.InventoryRoot.FolderID.ToStringHyphenated();
160 ArrayList InventoryRoot = new ArrayList();
161 InventoryRoot.Add(InventoryRootHash);
162
163 Hashtable InitialOutfitHash = new Hashtable();
164 InitialOutfitHash["folder_name"]="Nightclub Female";
165 InitialOutfitHash["gender"]="female";
166 ArrayList InitialOutfit = new ArrayList();
167 InitialOutfit.Add(InitialOutfitHash);
168
169 uint circode = (uint)(new Random()).Next();
170 TheUser.AddSimCircuit(circode, SimInfo.UUID);
171
172 LoginGoodData["last_name"]="\"" + TheUser.firstname + "\"";
173 LoginGoodData["ui-config"]=ui_config;
174 LoginGoodData["sim_ip"]=SimInfo.sim_ip.ToString();
175 LoginGoodData["login-flags"]=LoginFlags;
176 LoginGoodData["global-textures"]=GlobalTextures;
177 LoginGoodData["classified_categories"]=ClassifiedCategories;
178 LoginGoodData["event_categories"]=new ArrayList();
179 LoginGoodData["inventory-skeleton"]=AgentInventory;
180 LoginGoodData["inventory-skel-lib"]=new ArrayList();
181 LoginGoodData["inventory-root"]=InventoryRoot;
182 LoginGoodData["event_notifications"]=new ArrayList();
183 LoginGoodData["gestures"]=new ArrayList();
184 LoginGoodData["inventory-lib-owner"]=new ArrayList();
185 LoginGoodData["initial-outfit"]=InitialOutfit;
186 LoginGoodData["seconds_since_epoch"]=(Int32)(DateTime.UtcNow - new DateTime(1970,1,1)).TotalSeconds;
187 LoginGoodData["start_location"]="last";
188 LoginGoodData["home"]="{'region_handle':[r" + (SimInfo.RegionLocX*256).ToString() + ",r" + (SimInfo.RegionLocY*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() + "]}";
189 LoginGoodData["message"]=OpenUser_Main.userserver.DefaultStartupMsg;
190 LoginGoodData["first_name"]="\"" + firstname + "\"";
191 LoginGoodData["circuit_code"]=(Int32)circode;
192 LoginGoodData["sim_port"]=(Int32)SimInfo.sim_port;
193 LoginGoodData["secure_session_id"]=TheUser.CurrentSecureSessionID.ToStringHyphenated();
194 LoginGoodData["look_at"]="\n[r" + TheUser.homelookat.X.ToString() + ",r" + TheUser.homelookat.Y.ToString() + ",r" + TheUser.homelookat.Z.ToString() + "]\n";
195 LoginGoodData["agent_id"]=AgentID.ToStringHyphenated();
196 LoginGoodData["region_y"]=(Int32)SimInfo.RegionLocY*256;
197 LoginGoodData["region_x"]=(Int32)SimInfo.RegionLocX*256;
198 LoginGoodData["seed_capability"]=null;
199 LoginGoodData["agent_access"]="M";
200 LoginGoodData["session_id"]=TheUser.CurrentSessionID.ToStringHyphenated();
201 LoginGoodData["login"]="true";
202
203 LoginGoodResp.Value=LoginGoodData;
204 TheUser.SendDataToSim(SimInfo);
205 return(Regex.Replace(XmlRpcResponseSerializer.Singleton.Serialize(LoginGoodResp),"utf-16","utf-8" ));
206
207 } catch (Exception E) {
208 Console.WriteLine(E.ToString());
209 }
210
211 break;
212 }
213
214 return "";
215 }
216
217 static string ParseREST(HttpListenerRequest www_req) {
218 Console.WriteLine("INCOMING REST - " + www_req.RawUrl);
219
220 char[] splitter = {'/'};
221 string[] rest_params = www_req.RawUrl.Split(splitter);
222 string req_type = rest_params[1]; // First part of the URL is the type of request - usersessions/userprofiles/inventory/blabla
223 switch(req_type) {
224 case "usersessions":
225 LLUUID sessionid = new LLUUID(rest_params[2]); // get usersessions/sessionid
226 if(www_req.HttpMethod=="DELETE") {
227 foreach (libsecondlife.LLUUID UUID in OpenUser_Main.userserver._profilemanager.UserProfiles.Keys) {
228 if(OpenUser_Main.userserver._profilemanager.UserProfiles[UUID].CurrentSessionID==sessionid) {
229 OpenUser_Main.userserver._profilemanager.UserProfiles[UUID].CurrentSessionID=null;
230 OpenUser_Main.userserver._profilemanager.UserProfiles[UUID].CurrentSecureSessionID=null;
231 OpenUser_Main.userserver._profilemanager.UserProfiles[UUID].Circuits.Clear();
232 }
233 }
234
235 }
236 return "OK";
237 break;
238 }
239
240 return "";
241 }
242
243
244 static void HandleRequest(Object stateinfo) {
245 HttpListenerContext context=(HttpListenerContext)stateinfo;
246
247 HttpListenerRequest request = context.Request;
248 HttpListenerResponse response = context.Response;
249
250 response.KeepAlive=false;
251 response.SendChunked=false;
252
253 System.IO.Stream body = request.InputStream;
254 System.Text.Encoding encoding = System.Text.Encoding.UTF8;
255 System.IO.StreamReader reader = new System.IO.StreamReader(body, encoding);
256
257 string requestBody = reader.ReadToEnd();
258 body.Close();
259 reader.Close();
260
261 string responseString="";
262 switch(request.ContentType) {
263 case "text/xml":
264 // must be XML-RPC, so pass to the XML-RPC parser
265
266 responseString=ParseXMLRPC(requestBody);
267 response.AddHeader("Content-type","text/xml");
268 break;
269
270 case "text/plaintext":
271 responseString=ParseREST(request);
272 response.AddHeader("Content-type","text/plaintext");
273 break;
274 }
275
276
277 byte[] buffer = System.Text.Encoding.UTF8.GetBytes(responseString);
278 System.IO.Stream output = response.OutputStream;
279 response.SendChunked=false;
280 response.ContentLength64=buffer.Length;
281 output.Write(buffer,0,buffer.Length);
282 output.Close();
283 }
284 }
285
286
287}
diff --git a/ogs/userserver/src/UserProfiles.cs b/ogs/userserver/src/UserProfiles.cs
new file mode 100644
index 0000000..4586ab3
--- /dev/null
+++ b/ogs/userserver/src/UserProfiles.cs
@@ -0,0 +1,223 @@
1/*
2Copyright (c) OpenGrid project, http://osgrid.org/
3
4
5* All rights reserved.
6*
7* Redistribution and use in source and binary forms, with or without
8* modification, are permitted provided that the following conditions are met:
9* * Redistributions of source code must retain the above copyright
10* notice, this list of conditions and the following disclaimer.
11* * Redistributions in binary form must reproduce the above copyright
12* notice, this list of conditions and the following disclaimer in the
13* documentation and/or other materials provided with the distribution.
14* * Neither the name of the <organization> nor the
15* names of its contributors may be used to endorse or promote products
16* derived from this software without specific prior written permission.
17*
18* THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY
19* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
22* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28*/
29
30using System;
31using System.Text;
32using System.Collections;
33using System.Collections.Generic;
34using libsecondlife;
35using Nwc.XmlRpc;
36using ServerConsole;
37
38namespace OpenGridServices
39{
40 /// <summary>
41 /// </summary>
42 public class UserProfileManager {
43
44 public Dictionary<LLUUID, UserProfile> UserProfiles = new Dictionary<LLUUID, UserProfile>();
45
46 public UserProfileManager() {
47 }
48
49 public void InitUserProfiles() {
50 // TODO: need to load from database
51 }
52
53 public UserProfile GetProfileByName(string firstname, string lastname) {
54 foreach (libsecondlife.LLUUID UUID in UserProfiles.Keys) {
55 if((UserProfiles[UUID].firstname==firstname) && (UserProfiles[UUID].lastname==lastname)) return UserProfiles[UUID];
56 }
57 return null;
58 }
59
60 public UserProfile GetProfileByLLUUID(LLUUID ProfileLLUUID) {
61 return UserProfiles[ProfileLLUUID];
62 }
63
64 public bool AuthenticateUser(string firstname, string lastname, string passwd) {
65 UserProfile TheUser=GetProfileByName(firstname, lastname);
66 if(TheUser != null)
67 if(TheUser.MD5passwd==passwd) {
68 return true;
69 } else {
70 return false;
71 } else return false;
72
73 }
74
75 public void SetGod(LLUUID GodID) {
76 this.UserProfiles[GodID].IsGridGod=true;
77 }
78
79 public UserProfile CreateNewProfile(string firstname, string lastname, string MD5passwd) {
80 UserProfile newprofile = new UserProfile();
81 newprofile.homeregionhandle=Util.UIntsToLong((997*256), (996*256));
82 newprofile.firstname=firstname;
83 newprofile.lastname=lastname;
84 newprofile.MD5passwd=MD5passwd;
85 newprofile.UUID=LLUUID.Random();
86 this.UserProfiles.Add(newprofile.UUID,newprofile);
87 return newprofile;
88 }
89
90 }
91
92 public class UserProfile {
93
94 public string firstname;
95 public string lastname;
96 public ulong homeregionhandle;
97 public LLVector3 homepos;
98 public LLVector3 homelookat;
99
100 public bool IsGridGod=false;
101 public bool IsLocal=true; // will be used in future for visitors from foreign grids
102 public string AssetURL;
103 public string MD5passwd;
104
105 public LLUUID CurrentSessionID;
106 public LLUUID CurrentSecureSessionID;
107 public LLUUID UUID;
108 public Dictionary<LLUUID, uint> Circuits = new Dictionary<LLUUID, uint>(); // tracks circuit codes
109
110 public InventoryFolder InventoryRoot;
111 public Dictionary<LLUUID, InventoryFolder> InventoryFolders;
112 public Dictionary<LLUUID, InventoryItem> InventoryItems;
113
114 public UserProfile() {
115 Circuits = new Dictionary<LLUUID, uint>();
116 InventoryFolders = new Dictionary<LLUUID, InventoryFolder>();
117 InventoryItems = new Dictionary<LLUUID, InventoryItem>();
118 InventoryRoot=new InventoryFolder();
119 InventoryRoot.FolderID = LLUUID.Random();
120 InventoryRoot.ParentID=new LLUUID();
121 InventoryRoot.Version=1;
122 InventoryRoot.DefaultType=8;
123 InventoryRoot.FolderName="My Inventory";
124 InventoryFolders.Add(InventoryRoot.FolderID, InventoryRoot);
125 homeregionhandle=Util.UIntsToLong((997*256), (996*256));;
126 }
127
128 public void InitSessionData() {
129 CurrentSessionID=LLUUID.Random();
130 CurrentSecureSessionID=LLUUID.Random();
131 }
132
133 public void AddSimCircuit(uint circuit_code, LLUUID region_UUID) {
134 if(this.Circuits.ContainsKey(region_UUID)== false)
135 this.Circuits.Add(region_UUID, circuit_code);
136 }
137
138 public void SendDataToSim(SimProfile TheSim) {
139 Console.WriteLine(TheSim.caps_url);
140 Hashtable SimParams = new Hashtable();
141 SimParams["session_id"]=this.CurrentSessionID.ToString();
142 SimParams["secure_session_id"]=this.CurrentSecureSessionID.ToString();
143 SimParams["firstname"]=this.firstname;
144 SimParams["lastname"]=this.lastname;
145 SimParams["agent_id"]=this.UUID.ToString();
146 SimParams["circuit_code"]=(Int32)this.Circuits[TheSim.UUID];
147 ArrayList SendParams = new ArrayList();
148 SendParams.Add(SimParams);
149
150 XmlRpcRequest GridReq = new XmlRpcRequest("expect_user",SendParams);
151 XmlRpcResponse GridResp = GridReq.Send(TheSim.caps_url,3000);
152 }
153 }
154
155 public class InventoryFolder {
156 public LLUUID FolderID;
157 public LLUUID ParentID;
158 public string FolderName;
159 public ushort DefaultType;
160 public ushort Version;
161 }
162
163 public class InventoryItem { //TODO: Fixup this and add full permissions etc
164 public LLUUID FolderID;
165 public LLUUID OwnerID;
166 public LLUUID ItemID;
167 public LLUUID AssetID;
168 public LLUUID CreatorID = LLUUID.Zero;
169 public sbyte InvType;
170 public sbyte Type;
171 public string Name;
172 public string Description;
173 }
174
175 public class SimProfile {
176 public LLUUID UUID;
177 public ulong regionhandle;
178 public string regionname;
179 public string sim_ip;
180 public uint sim_port;
181 public string caps_url;
182 public uint RegionLocX;
183 public uint RegionLocY;
184 public string sendkey;
185 public string recvkey;
186
187
188 public SimProfile LoadFromGrid(ulong region_handle, string GridURL, string SendKey, string RecvKey) {
189 try {
190 Hashtable GridReqParams = new Hashtable();
191 GridReqParams["region_handle"]=region_handle.ToString();
192 GridReqParams["caller"]="userserver";
193 GridReqParams["authkey"]=SendKey;
194 ArrayList SendParams = new ArrayList();
195 SendParams.Add(GridReqParams);
196 XmlRpcRequest GridReq = new XmlRpcRequest("get_sim_info",SendParams);
197
198 XmlRpcResponse GridResp = GridReq.Send(GridURL,3000);
199
200 Hashtable RespData=(Hashtable)GridResp.Value;
201 this.UUID = new LLUUID((string)RespData["UUID"]);
202 this.regionhandle = (ulong)Convert.ToUInt64(RespData["regionhandle"]);
203 this.regionname=(string)RespData["regionname"];
204 this.sim_ip=(string)RespData["sim_ip"];
205 this.sim_port=(uint)Convert.ToUInt16(RespData["sim_port"]);
206 this.caps_url=(string)RespData["caps_url"];
207 this.RegionLocX=(uint)Convert.ToUInt32(RespData["RegionLocX"]);
208 this.RegionLocY=(uint)Convert.ToUInt32(RespData["RegionLocY"]);
209 this.sendkey=(string)RespData["sendkey"];
210 this.recvkey=(string)RespData["recvkey"];
211 } catch(Exception e) {
212 Console.WriteLine(e.ToString());
213 }
214 return this;
215 }
216
217 public SimProfile() {
218 }
219
220
221 }
222
223}
diff --git a/ogs/userserver/src/Util.cs b/ogs/userserver/src/Util.cs
new file mode 100644
index 0000000..1efa471
--- /dev/null
+++ b/ogs/userserver/src/Util.cs
@@ -0,0 +1,87 @@
1/*
2Copyright (c) OpenSim project, http://osgrid.org/
3
4* Copyright (c) <year>, <copyright holder>
5* All rights reserved.
6*
7* Redistribution and use in source and binary forms, with or without
8* modification, are permitted provided that the following conditions are met:
9* * Redistributions of source code must retain the above copyright
10* notice, this list of conditions and the following disclaimer.
11* * Redistributions in binary form must reproduce the above copyright
12* notice, this list of conditions and the following disclaimer in the
13* documentation and/or other materials provided with the distribution.
14* * Neither the name of the <organization> nor the
15* names of its contributors may be used to endorse or promote products
16* derived from this software without specific prior written permission.
17*
18* THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY
19* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
22* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28*/
29
30using System;
31using System.Collections.Generic;
32using System.Threading;
33using libsecondlife;
34using libsecondlife.Packets;
35
36namespace OpenGridServices
37{
38 /// <summary>
39 /// </summary>
40 ///
41 public class Util
42 {
43 public static ulong UIntsToLong(uint X, uint Y)
44 {
45 return Helpers.UIntsToLong(X,Y);
46 }
47 public Util()
48 {
49
50 }
51 }
52
53 public class QueItem {
54 public QueItem()
55 {
56 }
57
58 public Packet Packet;
59 public bool Incoming;
60 }
61
62
63 public class BlockingQueue< T > {
64 private Queue< T > _queue = new Queue< T >();
65 private object _queueSync = new object();
66
67 public void Enqueue(T value)
68 {
69 lock(_queueSync)
70 {
71 _queue.Enqueue(value);
72 Monitor.Pulse(_queueSync);
73 }
74 }
75
76 public T Dequeue()
77 {
78 lock(_queueSync)
79 {
80 if( _queue.Count < 1)
81 Monitor.Wait(_queueSync);
82
83 return _queue.Dequeue();
84 }
85 }
86 }
87}