From 5d2cadf6de749dab1430c016a29e09461d288693 Mon Sep 17 00:00:00 2001
From: gareth
Date: Wed, 14 Mar 2007 03:32:02 +0000
Subject: Merged ogs-cs into trunk
---
ogs/gridserver/default.build | 64 +++++++++++
ogs/gridserver/gridserver_config.inc.php | 14 ---
ogs/gridserver/index.php | 176 -------------------------------
ogs/gridserver/src/ConsoleCmds.cs | 57 ++++++++++
ogs/gridserver/src/GridHttp.cs | 165 +++++++++++++++++++++++++++++
ogs/gridserver/src/Main.cs | 94 +++++++++++++++++
ogs/gridserver/src/SimProfiles.cs | 111 +++++++++++++++++++
7 files changed, 491 insertions(+), 190 deletions(-)
create mode 100644 ogs/gridserver/default.build
create mode 100644 ogs/gridserver/src/ConsoleCmds.cs
create mode 100644 ogs/gridserver/src/GridHttp.cs
create mode 100644 ogs/gridserver/src/Main.cs
create mode 100644 ogs/gridserver/src/SimProfiles.cs
(limited to 'ogs/gridserver')
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 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
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 @@
-
-// All the grid server specific stuff lives here
-
-// What we send to authenticate to the user/login server
-$userserver_sendkey="1234";
-
-// What we expect to get back from the user/login server
-$userserver_recvkey="1234";
-
-$sim_recvkey = "1234";
-$sim_sendkey = "1234";
-
-$grid_home = "/ogs/gridserver/";
-?>
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 @@
-
-error_reporting(E_ALL); // yes, we remember this from the login server, don't we boys and girls? don't kill innocent XML-RPC!
-
-// these files are soooo common..... (to the grid)
-include("../common/xmlrpc.inc.php");
-include("../common/database.inc.php");
-include("../common/grid_config.inc.php");
-include("../common/util.inc.php");
-
-include("gridserver_config.inc.php"); // grid server specific config stuff
-
-function get_sim_info($args) {
- global $dbhost,$dbuser,$dbpasswd,$dbname;
- global $userserver_sendkey, $userserver_recvkey;
-
- // First see who's talking to us, if key is invalid then send an invalid one back and nothing more
- if($args['authkey']!=$userserver_recvkey) {
- return Array(
- 'authkey' => 'I can play the bad key trick too you know',
- 'login' => 'false'
- );
- }
-
- // if we get to here, the key is valid, give that login server what it wants!
-
- $link = mysql_connect($dbhost,$dbuser,$dbpasswd)
- OR die("Unable to connect to database");
-
- mysql_select_db($dbname)
- or die("Unable to select database");
-
- $region_handle = $args['region_handle'];
- $query = "SELECT * FROM region_profiles WHERE region_handle='$region_handle'";
- $result = mysql_query($query);
-
- return mysql_fetch_assoc($result);
-}
-
-function get_session_info($args) {
- global $dbhost,$dbuser,$dbpasswd,$dbname;
- global $sim_sendkey, $sim_recvkey;
-
- // authkey, session-id, agent-id
-
- // First see who's talking to us, if key is invalid then send an invalid one back and nothing more
- if($args[0]!=$sim_recvkey) {
- return Array(
- 'authkey' => "I can play the bad key trick too you know"
- );
- }
-
- $link = mysql_connect($dbhost,$dbuser,$dbpasswd)
- OR die("Unable to connect to database");
-
- mysql_select_db($dbname)
- or die("Unable to select database");
-
- $session_id = $args[1];
- $agent_id = $args[2];
-
- $query = "SELECT * FROM sessions WHERE session_id = '$session_id' AND agent_id='$agent_id' AND session_active=1";
- $result = mysql_query($query);
- if(mysql_num_rows($result)>0) {
- $info=mysql_fetch_assoc($result);
- $circuit_code = $info['circuit_code'];
- $secure_session_id=$info['secure_session_id'];
-
- $query = "SELECT * FROM local_user_profiles WHERE userprofile_LLUUID='$agent_id'";
- $result=mysql_query($query);
- $userinfo=mysql_fetch_assoc($result);
- $firstname=$userinfo['profile_firstname'];
- $lastname=$userinfo['profile_lastname'];
- $agent_id=$userinfo['userprofile_LLUUID'];
- return Array(
- 'authkey' => $sim_sendkey,
- 'circuit_code' => $circuit_code,
- 'agent_id' => $agent_id,
- 'session_id' => $session_id,
- 'secure_session_id' => $secure_session_id,
- 'firstname' => $firstname,
- 'lastname' => $lastname
- );
- }
-}
-
-function check_loggedin($args) {
- global $dbhost,$dbuser,$dbpasswd,$dbname;
- global $userserver_sendkey, $userserver_recvkey;
-
- // First see who's talking to us, if key is invalid then send an invalid one back and nothing more
- if($args['authkey']!=$userserver_recvkey) {
- return Array(
- 'authkey' => "I can play the bad key trick too you know"
- );
- }
-
- // if we get to here, the key is valid, give that login server what it wants!
-
- $link = mysql_connect($dbhost,$dbuser,$dbpasswd)
- OR die("Unable to connect to database");
-
- mysql_select_db($dbname)
- or die("Unable to select database");
-
- $userprofile_LLUUID = $args['userprofile_LLUUID'];
- $query = "SELECT * FROM sessions WHERE agent_id='$userprofile_LLUUID' AND session_active=1";
- $result = mysql_query($query);
-
- if(mysql_num_rows($result)>1) {
- return Array(
- 'authkey' => $userserver_sendkey,
- 'logged_in' => 1
- );
- } else {
- return Array(
- 'authkey' => $userserver_sendkey,
- 'logged_in' => 0
- );
- }
-}
-
-function create_session($args) {
- global $dbhost,$dbuser,$dbpasswd,$dbname;
- global $userserver_sendkey, $userserver_recvkey;
-
- // First see who's talking to us, if key is invalid then send an invalid one back and nothing more
- if($args['authkey']!=$userserver_recvkey) {
- return Array(
- 'authkey' => "I can play the bad key trick too you know"
- );
- }
-
- // if we get to here, the key is valid, give that login server what it wants!
-
- $link = mysql_connect($dbhost,$dbuser,$dbpasswd)
- OR die("Unable to connect to database");
-
- mysql_select_db($dbname)
- or die("Unable to select database");
-
- // yes, secure_sessionid should be different, i know...
- $query = "SELECT value FROM Grid_settings WHERE setting='highest_LLUUID'";
- $result = mysql_query($query);
- $row = mysql_fetch_array($result);
- $highest_LLUUID = $row['value'];
- $newsession_id=inc_lluuid($highest_LLUUID);
- $secure_session_id=inc_lluuid($newsession_id);
-
- $query="UPDATE Grid_settings SET value='$secure_session_id' WHERE setting='highest_LLUUID' LIMIT 1";
- $result=mysql_query($query);
-
- $userprofile_LLUUID=$args['userprofile_LLUUID'];
- $current_location=$args['current_location'];
- $remote_ip=$args['remote_ip'];
- $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')";
- $result=mysql_query($query);
- if(!isset($result)) {
- die();
- }
- return Array(
- 'authkey' => $userserver_sendkey,
- 'session_id' => $newsession_id,
- 'secure_session_id' => $secure_session_id
- );
-}
-
-$server=new IXR_Server(
- Array(
- 'check_session_loggedin' => 'check_loggedin',
- 'create_session' => 'create_session',
- 'get_sim_info' => 'get_sim_info',
- 'get_session_info' => 'get_session_info'
- )
-);
-
-?>
\ 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 @@
+/*
+Copyright (c) OpenSim project, http://osgrid.org/
+
+
+* All rights reserved.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are met:
+* * Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+* * Redistributions in binary form must reproduce the above copyright
+* notice, this list of conditions and the following disclaimer in the
+* documentation and/or other materials provided with the distribution.
+* * Neither the name of the nor the
+* names of its contributors may be used to endorse or promote products
+* derived from this software without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY
+* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
+* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+using System;
+using System.Text;
+using ServerConsole;
+
+namespace OpenGridServices
+{
+
+ public class GridConsole : conscmd_callback {
+ public GridConsole() { }
+
+ public override void RunCmd(string cmd, string[] cmdparams) {
+ switch(cmd) {
+ case "help":
+ ServerConsole.MainConsole.Instance.WriteLine("shutdown - shutdown the grid (USE CAUTION!)"
+);
+ break;
+
+ case "shutdown":
+ ServerConsole.MainConsole.Instance.Close();
+ Environment.Exit(0);
+ break;
+ }
+ }
+
+ public override void Show(string ShowWhat) {
+ }
+ }
+}
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 @@
+/*
+Copyright (c) OpenGrid project, http://osgrid.org/
+
+
+* All rights reserved.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are met:
+* * Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+* * Redistributions in binary form must reproduce the above copyright
+* notice, this list of conditions and the following disclaimer in the
+* documentation and/or other materials provided with the distribution.
+* * Neither the name of the nor the
+* names of its contributors may be used to endorse or promote products
+* derived from this software without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY
+* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
+* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+using System;
+using System.Text;
+using Nwc.XmlRpc;
+using System.Threading;
+using System.Text.RegularExpressions;
+using System.Net;
+using System.IO;
+using System.Collections;
+using System.Collections.Generic;
+using libsecondlife;
+using ServerConsole;
+
+namespace OpenGridServices
+{
+ public class GridHTTPServer {
+ public Thread HTTPD;
+ public HttpListener Listener;
+
+ public GridHTTPServer() {
+ ServerConsole.MainConsole.Instance.WriteLine("Starting up HTTP Server");
+ HTTPD = new Thread(new ThreadStart(StartHTTP));
+ HTTPD.Start();
+ }
+
+ public void StartHTTP() {
+ ServerConsole.MainConsole.Instance.WriteLine("GridHttp.cs:StartHTTP() - Spawned main thread OK");
+ Listener = new HttpListener();
+
+ Listener.Prefixes.Add("http://+:8001/gridserver/");
+ Listener.Start();
+
+ HttpListenerContext context;
+ while(true) {
+ context = Listener.GetContext();
+ ThreadPool.QueueUserWorkItem(new WaitCallback(HandleRequest), context);
+ }
+ }
+
+ static string ParseXMLRPC(string requestBody) {
+ try{
+ XmlRpcRequest request = (XmlRpcRequest)(new XmlRpcRequestDeserializer()).Deserialize(requestBody);
+
+ Hashtable requestData = (Hashtable)request.Params[0];
+ switch(request.MethodName) {
+ case "get_sim_info":
+ ulong req_handle=(ulong)Convert.ToInt64(requestData["region_handle"]);
+ SimProfile TheSim = OpenGrid_Main.thegrid._regionmanager.GetProfileByHandle(req_handle);
+ string RecvKey="";
+ string caller=(string)requestData["caller"];
+ switch(caller) {
+ case "userserver":
+ RecvKey=OpenGrid_Main.thegrid.UserRecvKey;
+ break;
+ case "assetserver":
+ RecvKey=OpenGrid_Main.thegrid.AssetRecvKey;
+ break;
+ }
+ if((TheSim!=null) && (string)requestData["authkey"]==RecvKey) {
+ XmlRpcResponse SimInfoResp = new XmlRpcResponse();
+ Hashtable SimInfoData = new Hashtable();
+ SimInfoData["UUID"]=TheSim.UUID.ToString();
+ SimInfoData["regionhandle"]=TheSim.regionhandle.ToString();
+ SimInfoData["regionname"]=TheSim.regionname;
+ SimInfoData["sim_ip"]=TheSim.sim_ip;
+ SimInfoData["sim_port"]=TheSim.sim_port.ToString();
+ SimInfoData["caps_url"]=TheSim.caps_url;
+ SimInfoData["RegionLocX"]=TheSim.RegionLocX.ToString();
+ SimInfoData["RegionLocY"]=TheSim.RegionLocY.ToString();
+ SimInfoData["sendkey"]=TheSim.sendkey;
+ SimInfoData["recvkey"]=TheSim.recvkey;
+ SimInfoResp.Value=SimInfoData;
+ return(Regex.Replace(XmlRpcResponseSerializer.Singleton.Serialize(SimInfoResp),"utf-16","utf-8"));
+ } else {
+ XmlRpcResponse SimErrorResp = new XmlRpcResponse();
+ Hashtable SimErrorData = new Hashtable();
+ SimErrorData["error"]="sim not found";
+ SimErrorResp.Value=SimErrorData;
+ return(XmlRpcResponseSerializer.Singleton.Serialize(SimErrorResp));
+ }
+ break;
+ }
+ } catch(Exception e) {
+ Console.WriteLine(e.ToString());
+ }
+ return "";
+ }
+
+ static string ParseREST(string requestBody, string requestURL) {
+ return "";
+ }
+
+
+ static void HandleRequest(Object stateinfo) {
+ HttpListenerContext context=(HttpListenerContext)stateinfo;
+
+ HttpListenerRequest request = context.Request;
+ HttpListenerResponse response = context.Response;
+
+ response.KeepAlive=false;
+ response.SendChunked=false;
+
+ System.IO.Stream body = request.InputStream;
+ System.Text.Encoding encoding = System.Text.Encoding.UTF8;
+ System.IO.StreamReader reader = new System.IO.StreamReader(body, encoding);
+
+ string requestBody = reader.ReadToEnd();
+ body.Close();
+ reader.Close();
+
+ string responseString="";
+ switch(request.ContentType) {
+ case "text/xml":
+ // must be XML-RPC, so pass to the XML-RPC parser
+
+ responseString=ParseXMLRPC(requestBody);
+ response.AddHeader("Content-type","text/xml");
+ break;
+
+ case null:
+ // must be REST or invalid crap, so pass to the REST parser
+ responseString=ParseREST(request.Url.OriginalString,requestBody);
+ break;
+ }
+
+
+ byte[] buffer = System.Text.Encoding.UTF8.GetBytes(responseString);
+ System.IO.Stream output = response.OutputStream;
+ response.SendChunked=false;
+ response.ContentLength64=buffer.Length;
+ output.Write(buffer,0,buffer.Length);
+ output.Close();
+ }
+ }
+
+
+}
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 @@
+/*
+Copyright (c) OpenSim project, http://osgrid.org/
+
+
+* All rights reserved.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are met:
+* * Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+* * Redistributions in binary form must reproduce the above copyright
+* notice, this list of conditions and the following disclaimer in the
+* documentation and/or other materials provided with the distribution.
+* * Neither the name of the nor the
+* names of its contributors may be used to endorse or promote products
+* derived from this software without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY
+* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
+* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+using System;
+using System.Text;
+using libsecondlife;
+using ServerConsole;
+
+namespace OpenGridServices
+{
+ ///
+ ///
+ public class OpenGrid_Main
+ {
+
+ public static OpenGrid_Main thegrid;
+ public string GridOwner;
+ public string DefaultStartupMsg;
+ public string DefaultAssetServer;
+ public string AssetSendKey;
+ public string AssetRecvKey;
+ public string DefaultUserServer;
+ public string UserSendKey;
+ public string UserRecvKey;
+
+ public GridHTTPServer _httpd;
+ public SimProfileManager _regionmanager;
+
+ [STAThread]
+ public static void Main( string[] args )
+ {
+ Console.WriteLine("OpenGrid " + VersionInfo.Version + "\n");
+ Console.WriteLine("Starting...\n");
+ ServerConsole.MainConsole.Instance = new MServerConsole(ServerConsole.ConsoleBase.ConsoleType.Local, "", 0, "opengrid-console.log", "OpenGrid", new GridConsole());
+
+ thegrid = new OpenGrid_Main();
+ thegrid.Startup();
+
+ ServerConsole.MainConsole.Instance.WriteLine("\nEnter help for a list of commands\n");
+
+ while(true) {
+ ServerConsole.MainConsole.Instance.MainConsolePrompt();
+ }
+ }
+
+ public void Startup() {
+ ServerConsole.MainConsole.Instance.WriteLine("Main.cs:Startup() - Please press enter to retain default settings");
+
+ this.GridOwner=ServerConsole.MainConsole.Instance.CmdPrompt("Grid owner [OGS development team]: ","OGS development team");
+ this.DefaultStartupMsg=ServerConsole.MainConsole.Instance.CmdPrompt("Default startup message for clients [Welcome to OGS!]: ","Welcome to OGS!");
+
+ this.DefaultAssetServer=ServerConsole.MainConsole.Instance.CmdPrompt("Default asset server [no default]: ");
+ this.AssetSendKey=ServerConsole.MainConsole.Instance.CmdPrompt("Key to send to asset server: ");
+ this.AssetRecvKey=ServerConsole.MainConsole.Instance.CmdPrompt("Key to expect from asset server: ");
+
+ this.DefaultUserServer=ServerConsole.MainConsole.Instance.CmdPrompt("Default user server [no default]: ");
+ this.UserSendKey=ServerConsole.MainConsole.Instance.CmdPrompt("Key to send to user server: ");
+ this.UserRecvKey=ServerConsole.MainConsole.Instance.CmdPrompt("Key to expect from user server: ");
+
+ ServerConsole.MainConsole.Instance.WriteLine("Main.cs:Startup() - Starting HTTP process");
+ _httpd = new GridHTTPServer();
+
+ this._regionmanager=new SimProfileManager();
+ _regionmanager.CreateNewProfile("OpenSim Test", "http://there-is-no-caps.com", "4.78.190.75", 9000, 997, 996, this.UserSendKey, this.UserRecvKey);
+
+ }
+ }
+}
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 @@
+/*
+Copyright (c) OpenGrid project, http://osgrid.org/
+
+
+* All rights reserved.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are met:
+* * Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+* * Redistributions in binary form must reproduce the above copyright
+* notice, this list of conditions and the following disclaimer in the
+* documentation and/or other materials provided with the distribution.
+* * Neither the name of the nor the
+* names of its contributors may be used to endorse or promote products
+* derived from this software without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY
+* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
+* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+using System;
+using System.Text;
+using System.Collections;
+using System.Collections.Generic;
+using libsecondlife;
+using ServerConsole;
+
+namespace OpenGridServices
+{
+ ///
+ ///
+ public class SimProfileManager {
+
+ public Dictionary SimProfiles = new Dictionary();
+
+ public SimProfileManager() {
+ }
+
+ public void InitSimProfiles() {
+ // TODO: need to load from database
+ }
+
+ public SimProfile GetProfileByHandle(ulong reqhandle) {
+ foreach (libsecondlife.LLUUID UUID in SimProfiles.Keys) {
+ if(SimProfiles[UUID].regionhandle==reqhandle) return SimProfiles[UUID];
+ }
+ return null;
+ }
+
+ public SimProfile GetProfileByLLUUID(LLUUID ProfileLLUUID) {
+ return SimProfiles[ProfileLLUUID];
+ }
+
+ public bool AuthenticateSim(LLUUID RegionUUID, uint regionhandle, string simrecvkey) {
+ SimProfile TheSim=GetProfileByHandle(regionhandle);
+ if(TheSim != null)
+ if(TheSim.recvkey==simrecvkey) {
+ return true;
+ } else {
+ return false;
+ } else return false;
+
+ }
+
+ public SimProfile CreateNewProfile(string regionname, string caps_url, string sim_ip, uint sim_port, uint RegionLocX, uint RegionLocY, string sendkey, string recvkey) {
+ SimProfile newprofile = new SimProfile();
+ newprofile.regionname=regionname;
+ newprofile.sim_ip=sim_ip;
+ newprofile.sim_port=sim_port;
+ newprofile.RegionLocX=RegionLocX;
+ newprofile.RegionLocY=RegionLocY;
+ newprofile.caps_url="http://" + sim_ip + ":9000/";
+ newprofile.sendkey=sendkey;
+ newprofile.recvkey=recvkey;
+ newprofile.regionhandle=Util.UIntsToLong((RegionLocX*256), (RegionLocY*256));
+ newprofile.UUID=LLUUID.Random();
+ this.SimProfiles.Add(newprofile.UUID,newprofile);
+ return newprofile;
+ }
+
+ }
+
+ public class SimProfile {
+ public LLUUID UUID;
+ public ulong regionhandle;
+ public string regionname;
+ public string sim_ip;
+ public uint sim_port;
+ public string caps_url;
+ public uint RegionLocX;
+ public uint RegionLocY;
+ public string sendkey;
+ public string recvkey;
+
+
+ public SimProfile() {
+ }
+
+
+ }
+
+}
--
cgit v1.1