aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/ogs/gridserver
diff options
context:
space:
mode:
authorgareth2007-03-14 03:32:02 +0000
committergareth2007-03-14 03:32:02 +0000
commit5d2cadf6de749dab1430c016a29e09461d288693 (patch)
tree4f5698b45404b0898070419438719ff71ec3877c /ogs/gridserver
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/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
7 files changed, 491 insertions, 190 deletions
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}