Merged ogs-cs into trunk
parent
82e18112f2
commit
5d2cadf6de
|
@ -0,0 +1,98 @@
|
|||
/*
|
||||
* Copyright (c) OpenSim project, http://sim.opensecondlife.org/
|
||||
*
|
||||
* 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 <organization> 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 <copyright holder> ``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 <copyright holder> 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;
|
||||
|
||||
namespace ServerConsole
|
||||
{
|
||||
public class MainConsole {
|
||||
|
||||
private static ConsoleBase instance;
|
||||
|
||||
public static ConsoleBase Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
return instance;
|
||||
}
|
||||
set
|
||||
{
|
||||
instance = value;
|
||||
}
|
||||
}
|
||||
|
||||
public MainConsole()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public abstract class conscmd_callback {
|
||||
public abstract void RunCmd(string cmd, string[] cmdparams);
|
||||
public abstract void Show(string ShowWhat);
|
||||
}
|
||||
|
||||
public abstract class ConsoleBase
|
||||
{
|
||||
|
||||
public enum ConsoleType {
|
||||
Local, // Use stdio
|
||||
TCP, // Use TCP/telnet
|
||||
SimChat // Use in-world chat (for gods)
|
||||
}
|
||||
|
||||
public abstract void Close();
|
||||
|
||||
// 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
|
||||
public abstract void WriteLine(string Line) ;
|
||||
|
||||
public abstract string ReadLine();
|
||||
|
||||
public abstract int Read() ;
|
||||
|
||||
public abstract void Write(string Line) ;
|
||||
|
||||
public abstract string PasswdPrompt(string prompt);
|
||||
|
||||
// Displays a command prompt and waits for the user to enter a string, then returns that string
|
||||
public abstract string CmdPrompt(string prompt) ;
|
||||
|
||||
// Displays a command prompt and returns a default value if the user simply presses enter
|
||||
public abstract string CmdPrompt(string prompt, string defaultresponse);
|
||||
|
||||
// Displays a command prompt and returns a default value, user may only enter 1 of 2 options
|
||||
public abstract string CmdPrompt(string prompt, string defaultresponse, string OptionA, string OptionB) ;
|
||||
|
||||
// Runs a command with a number of parameters
|
||||
public abstract Object RunCmd(string Cmd, string[] cmdparams) ;
|
||||
|
||||
// Shows data about something
|
||||
public abstract void ShowCommands(string ShowWhat) ;
|
||||
|
||||
// Displays a prompt to the user and then runs the command they entered
|
||||
public abstract void MainConsolePrompt() ;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
<?xml version="1.0"?>
|
||||
<project name="ServerConsole" default="build" basedir=".">
|
||||
<property name="debug" value="true" overwrite="false" />
|
||||
<target name="clean" description="remove all generated files">
|
||||
<delete file="../common/bin/ServerConsole.dll" failonerror="false" />
|
||||
<delete file="../common/bin/ServerConsole.dll.mdb" failonerror="false" />
|
||||
</target>
|
||||
|
||||
<target name="svnupdate" description="updates to latest SVN">
|
||||
<exec program="svn">
|
||||
<arg value="update" />
|
||||
</exec>
|
||||
</target>
|
||||
|
||||
<target name="upgrade" description="updates from SVN and then builds" depends="clean,svnupdate,build">
|
||||
|
||||
</target>
|
||||
|
||||
<target name="build" description="compiles the source code">
|
||||
|
||||
<loadfile file="../VERSION" property="svnver"/>
|
||||
<asminfo output="AssemblyInfo.cs" language="CSharp">
|
||||
<imports>
|
||||
<import namespace="System" />
|
||||
<import namespace="System.Reflection" />
|
||||
<import namespace="System.Runtime.InteropServices" />
|
||||
</imports>
|
||||
<attributes>
|
||||
<attribute type="ComVisibleAttribute" value="false" />
|
||||
<attribute type="CLSCompliantAttribute" value="false" />
|
||||
<attribute type="AssemblyVersionAttribute" value="${svnver}" />
|
||||
<attribute type="AssemblyTitleAttribute" value="ogs-serverconsole" />
|
||||
<attribute type="AssemblyDescriptionAttribute" value="The default server console" />
|
||||
<attribute type="AssemblyCopyrightAttribute" value="Copyright © OGS development team 2007"/>
|
||||
</attributes>
|
||||
</asminfo>
|
||||
|
||||
<csc target="library" output="../common/bin/ServerConsole.dll" debug="${debug}" verbose="true" warninglevel="4">
|
||||
<references>
|
||||
<include name="System" />
|
||||
<include name="System.Xml" />
|
||||
</references>
|
||||
<sources>
|
||||
<include name="*.cs" />
|
||||
</sources>
|
||||
</csc>
|
||||
</target>
|
||||
</project>
|
|
@ -0,0 +1,181 @@
|
|||
/*
|
||||
* Copyright (c) OpenSim project, http://sim.opensecondlife.org/
|
||||
*
|
||||
* 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 <organization> 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 <copyright holder> ``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 <copyright holder> 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.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using ServerConsole;
|
||||
|
||||
namespace OpenGridServices
|
||||
{
|
||||
/// <summary>
|
||||
/// Description of ServerConsole.
|
||||
/// </summary>
|
||||
public class MServerConsole : ConsoleBase
|
||||
{
|
||||
|
||||
private ConsoleType ConsType;
|
||||
StreamWriter Log;
|
||||
public conscmd_callback cmdparser;
|
||||
public string componentname;
|
||||
|
||||
// STUPID HACK ALERT!!!! STUPID HACK ALERT!!!!!
|
||||
// constype - the type of console to use (see enum ConsoleType)
|
||||
// sparam - depending on the console type:
|
||||
// TCP - the IP to bind to (127.0.0.1 if blank)
|
||||
// Local - param ignored
|
||||
// and for the iparam:
|
||||
// TCP - the port to bind to
|
||||
// Local - param ignored
|
||||
// LogFile - duh
|
||||
// componentname - which component of the OGS system? (user, asset etc)
|
||||
// cmdparser - a reference to a conscmd_callback object
|
||||
|
||||
public MServerConsole(ConsoleType constype, string sparam, int iparam, string LogFile, string componentname, conscmd_callback cmdparser) {
|
||||
ConsType = constype;
|
||||
this.componentname = componentname;
|
||||
this.cmdparser = cmdparser;
|
||||
switch(constype) {
|
||||
case ConsoleType.Local:
|
||||
Console.WriteLine("ServerConsole.cs - creating new local console");
|
||||
Console.WriteLine("Logs will be saved to current directory in " + LogFile);
|
||||
Log=File.AppendText(LogFile);
|
||||
Log.WriteLine("========================================================================");
|
||||
Log.WriteLine(componentname + " " + VersionInfo.Version + " Started at " + DateTime.Now.ToString());
|
||||
break;
|
||||
|
||||
case ConsoleType.TCP:
|
||||
break;
|
||||
|
||||
default:
|
||||
Console.WriteLine("ServerConsole.cs - what are you smoking? that isn't a valid console type!");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public override void Close() {
|
||||
Log.WriteLine("Shutdown at " + DateTime.Now.ToString());
|
||||
Log.Close();
|
||||
}
|
||||
|
||||
// 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
|
||||
public override void WriteLine(string Line) {
|
||||
Log.WriteLine(Line);
|
||||
Console.WriteLine(Line);
|
||||
return;
|
||||
}
|
||||
|
||||
public override string ReadLine() {
|
||||
string TempStr=Console.ReadLine();
|
||||
Log.WriteLine(TempStr);
|
||||
return TempStr;
|
||||
}
|
||||
|
||||
public override int Read() {
|
||||
int TempInt= Console.Read();
|
||||
Log.Write((char)TempInt);
|
||||
return TempInt;
|
||||
}
|
||||
|
||||
public override void Write(string Line) {
|
||||
Console.Write(Line);
|
||||
Log.Write(Line);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Displays a prompt and waits for the user to enter a string, then returns that string
|
||||
// Done with no echo and suitable for passwords
|
||||
public override string PasswdPrompt(string prompt) {
|
||||
// FIXME: Needs to be better abstracted
|
||||
Log.WriteLine(prompt);
|
||||
this.Write(prompt);
|
||||
ConsoleColor oldfg=Console.ForegroundColor;
|
||||
Console.ForegroundColor=Console.BackgroundColor;
|
||||
string temp=Console.ReadLine();
|
||||
Console.ForegroundColor=oldfg;
|
||||
return temp;
|
||||
}
|
||||
|
||||
// Displays a command prompt and waits for the user to enter a string, then returns that string
|
||||
public override string CmdPrompt(string prompt) {
|
||||
this.Write(prompt);
|
||||
return this.ReadLine();
|
||||
}
|
||||
|
||||
// Displays a command prompt and returns a default value if the user simply presses enter
|
||||
public override string CmdPrompt(string prompt, string defaultresponse) {
|
||||
string temp=CmdPrompt(prompt);
|
||||
if(temp=="") {
|
||||
return defaultresponse;
|
||||
} else {
|
||||
return temp;
|
||||
}
|
||||
}
|
||||
|
||||
// Displays a command prompt and returns a default value, user may only enter 1 of 2 options
|
||||
public override string CmdPrompt(string prompt, string defaultresponse, string OptionA, string OptionB) {
|
||||
bool itisdone=false;
|
||||
string temp=CmdPrompt(prompt,defaultresponse);
|
||||
while(itisdone==false) {
|
||||
if((temp==OptionA) || (temp==OptionB)) {
|
||||
itisdone=true;
|
||||
} else {
|
||||
this.WriteLine("Valid options are " + OptionA + " or " + OptionB);
|
||||
temp=CmdPrompt(prompt,defaultresponse);
|
||||
}
|
||||
}
|
||||
return temp;
|
||||
}
|
||||
|
||||
// Runs a command with a number of parameters
|
||||
public override Object RunCmd(string Cmd, string[] cmdparams) {
|
||||
cmdparser.RunCmd(Cmd, cmdparams);
|
||||
return null;
|
||||
}
|
||||
|
||||
// Shows data about something
|
||||
public override void ShowCommands(string ShowWhat) {
|
||||
cmdparser.Show(ShowWhat);
|
||||
}
|
||||
|
||||
public override void MainConsolePrompt() {
|
||||
string[] tempstrarray;
|
||||
string tempstr = this.CmdPrompt(this.componentname + "# ");
|
||||
tempstrarray = tempstr.Split(' ');
|
||||
string cmd=tempstrarray[0];
|
||||
Array.Reverse(tempstrarray);
|
||||
Array.Resize<string>(ref tempstrarray,tempstrarray.Length-1);
|
||||
Array.Reverse(tempstrarray);
|
||||
string[] cmdparams=(string[])tempstrarray;
|
||||
RunCmd(cmd,cmdparams);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,87 @@
|
|||
/*
|
||||
Copyright (c) OpenSim project, http://osgrid.org/
|
||||
|
||||
* Copyright (c) <year>, <copyright holder>
|
||||
* 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 <organization> 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 <copyright holder> ``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 <copyright holder> 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.Collections.Generic;
|
||||
using System.Threading;
|
||||
using libsecondlife;
|
||||
using libsecondlife.Packets;
|
||||
|
||||
namespace OpenGridServices
|
||||
{
|
||||
/// <summary>
|
||||
/// </summary>
|
||||
///
|
||||
public class Util
|
||||
{
|
||||
public static ulong UIntsToLong(uint X, uint Y)
|
||||
{
|
||||
return Helpers.UIntsToLong(X,Y);
|
||||
}
|
||||
public Util()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public class QueItem {
|
||||
public QueItem()
|
||||
{
|
||||
}
|
||||
|
||||
public Packet Packet;
|
||||
public bool Incoming;
|
||||
}
|
||||
|
||||
|
||||
public class BlockingQueue< T > {
|
||||
private Queue< T > _queue = new Queue< T >();
|
||||
private object _queueSync = new object();
|
||||
|
||||
public void Enqueue(T value)
|
||||
{
|
||||
lock(_queueSync)
|
||||
{
|
||||
_queue.Enqueue(value);
|
||||
Monitor.Pulse(_queueSync);
|
||||
}
|
||||
}
|
||||
|
||||
public T Dequeue()
|
||||
{
|
||||
lock(_queueSync)
|
||||
{
|
||||
if( _queue.Count < 1)
|
||||
Monitor.Wait(_queueSync);
|
||||
|
||||
return _queue.Dequeue();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
Copyright (c) OpenSim project, http://osgrid.org/
|
||||
*
|
||||
* 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 <organization> 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 <copyright holder> ``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 <copyright holder> 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;
|
||||
|
||||
namespace OpenGridServices
|
||||
{
|
||||
/// <summary>
|
||||
/// </summary>
|
||||
public class VersionInfo
|
||||
{
|
||||
public static string Version = "@@VERSION";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
#!/bin/bash
|
||||
|
||||
MAJOR=0
|
||||
MINOR=1
|
||||
BUILD=`date +%s`
|
||||
REVISION=`svnversion . | sed s/:// | sed s/M//`
|
||||
REALREVISION=`svnversion`
|
||||
cat common/src/VersionInfo.cs.template | sed s/@@VERSION/"$MAJOR.$MINOR, Build $BUILD, Revision $REALREVISION"/g >common/src/VersionInfo.cs
|
||||
echo -n $MAJOR.$MINOR.*.$REVISION >VERSION
|
|
@ -0,0 +1,64 @@
|
|||
<?xml version="1.0"?>
|
||||
<project name="GridServer" default="build" basedir="./">
|
||||
<property name="debug" value="true" overwrite="false" />
|
||||
<target name="clean" description="remove all generated files">
|
||||
<delete>
|
||||
<fileset failonempty="false">
|
||||
<include name="bin/*.dll" />
|
||||
<include name="bin/*.exe" />
|
||||
<include name="bin/*.mdb" />
|
||||
</fileset>
|
||||
</delete>
|
||||
</target>
|
||||
|
||||
<target name="svnupdate" description="updates to latest SVN">
|
||||
<exec program="svn">
|
||||
<arg value="update" />
|
||||
</exec>
|
||||
</target>
|
||||
|
||||
<target name="upgrade" description="updates from SVN and then builds" depends="clean,svnupdate,build">
|
||||
|
||||
</target>
|
||||
|
||||
<target name="build" description="compiles the source code">
|
||||
|
||||
<loadfile file="../VERSION" property="svnver"/>
|
||||
<asminfo output="src/AssemblyInfo.cs" language="CSharp">
|
||||
<imports>
|
||||
<import namespace="System" />
|
||||
<import namespace="System.Reflection" />
|
||||
<import namespace="System.Runtime.InteropServices" />
|
||||
</imports>
|
||||
<attributes>
|
||||
<attribute type="ComVisibleAttribute" value="false" />
|
||||
<attribute type="CLSCompliantAttribute" value="false" />
|
||||
<attribute type="AssemblyVersionAttribute" value="${svnver}" />
|
||||
<attribute type="AssemblyTitleAttribute" value="ogs-GridServer" />
|
||||
<attribute type="AssemblyDescriptionAttribute" value="The core OGS Grid Server" />
|
||||
<attribute type="AssemblyCopyrightAttribute" value="Copyright © OGS development team 2007"/>
|
||||
</attributes>
|
||||
</asminfo>
|
||||
|
||||
<csc target="exe" output="bin/GridServer.exe" debug="${debug}" verbose="true" warninglevel="4">
|
||||
<references failonempty="true">
|
||||
<include name="System" />
|
||||
<include name="System.Xml" />
|
||||
<include name="../common/bin/ServerConsole.dll" />
|
||||
<include name="../common/bin/libsecondlife.dll" />
|
||||
</references>
|
||||
<sources>
|
||||
<include name="../common/src/VersionInfo.cs" />
|
||||
<include name="../common/src/OGS-Console.cs" />
|
||||
<include name="../common/src/Util.cs" />
|
||||
<include name="src/*.cs" />
|
||||
</sources>
|
||||
</csc>
|
||||
|
||||
<copy todir="bin/">
|
||||
<fileset basedir="../common/bin">
|
||||
<include name="*.*" />
|
||||
</fileset>
|
||||
</copy>
|
||||
</target>
|
||||
</project>
|
|
@ -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/";
|
||||
?>
|
|
@ -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'
|
||||
)
|
||||
);
|
||||
|
||||
?>
|
|
@ -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 <organization> 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 <copyright holder> ``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 <copyright holder> 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) {
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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 <organization> 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 <copyright holder> ``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 <copyright holder> 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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -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 <organization> 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 <copyright holder> ``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 <copyright holder> 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
|
||||
{
|
||||
/// <summary>
|
||||
/// </summary>
|
||||
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);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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 <organization> 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 <copyright holder> ``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 <copyright holder> 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
|
||||
{
|
||||
/// <summary>
|
||||
/// </summary>
|
||||
public class SimProfileManager {
|
||||
|
||||
public Dictionary<LLUUID, SimProfile> SimProfiles = new Dictionary<LLUUID, SimProfile>();
|
||||
|
||||
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() {
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -1,170 +0,0 @@
|
|||
<?
|
||||
error_reporting(0); // Remember kids, PHP errors kill XML-RPC responses!
|
||||
|
||||
// include all the common stuff
|
||||
include("../common/xmlrpc.inc.php");
|
||||
include("../common/database.inc.php");
|
||||
include("../common/grid_config.inc.php");
|
||||
include("../common/util.inc.php");
|
||||
|
||||
include("login_config.inc.php"); // include login/user specific config stuff (authentication keys etc)
|
||||
|
||||
function login($args) {
|
||||
global $dbhost,$dbuser,$dbpasswd,$dbname;
|
||||
global $grid_owner, $gridserver_sendkey, $gridserver_recvkey, $gridserver_url;
|
||||
|
||||
|
||||
if(get_magic_quotes_gpc()) {
|
||||
$firstname=addslashes($args['first']);
|
||||
$lastname=addslashes($args['last']);
|
||||
$passwd=addslashes($args['passwd']);
|
||||
} else {
|
||||
$firstname=$args['first'];
|
||||
$lastname=$args['last'];
|
||||
$passwd=$args['passwd'];
|
||||
}
|
||||
|
||||
$link = mysql_connect($dbhost,$dbuser,$dbpasswd)
|
||||
OR die("Unable to connect to database");
|
||||
|
||||
mysql_select_db($dbname)
|
||||
or die("Unable to select database");
|
||||
|
||||
$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."'";
|
||||
|
||||
$profile_lookup_result=mysql_query($query);
|
||||
|
||||
if(mysql_num_rows($profile_lookup_result) >0) {
|
||||
$profiledata = mysql_fetch_assoc($profile_lookup_result);
|
||||
|
||||
// if we get here, the username/password is valid, but still need to check there's not an already existing session
|
||||
$client = new IXR_Client($gridserver_url);
|
||||
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
|
||||
return Array (
|
||||
'reason' => 'key',
|
||||
'message' => "Could not connect to grid server. Please try again later or contact the grid owner ". $grid_owner,
|
||||
'login' => "false"
|
||||
);
|
||||
}
|
||||
|
||||
$response=$client->getResponse();
|
||||
if($response['authkey'] != $gridserver_recvkey) { // if this doesn't match up, it's a fake grid server
|
||||
return Array (
|
||||
'reason' => 'key',
|
||||
'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",
|
||||
'login' => "false"
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
if($response['logged_in'] == 1) { // if the user is already logged in, tell them
|
||||
return Array (
|
||||
'reason' => 'presence',
|
||||
'message' => "You appear to already be logged into this grid, if your client has recently crashed then please try again later",
|
||||
'login' => "false"
|
||||
);
|
||||
}
|
||||
|
||||
// now we start a new session on the grid
|
||||
$remote_ip=$_SERVER['REMOTE_ADDR'];
|
||||
$region_handle=$profiledata['region_handle'];
|
||||
$client->query('create_session',Array('userprofile_LLUUID' => $profiledata['userprofile_LLUUID'], 'authkey' => $gridserver_sendkey, 'remote_ip' => $remote_ip, 'current_location' => $region_handle));
|
||||
$response = $client->getResponse();
|
||||
$session_id = $response['session_id'];
|
||||
$secure_session_id = $response['secure_session_id'];
|
||||
|
||||
// ask the grid server what the IP address and port of the sim we want to connect to is
|
||||
$client->query('get_sim_info', Array('region_handle' => $region_handle, 'authkey' => $gridserver_sendkey) );
|
||||
$siminfo = $client->getResponse();
|
||||
|
||||
// send the final response!
|
||||
$position=$profiledata['position'];
|
||||
$look_at=$profiledata['look_at'];
|
||||
|
||||
$LocX=intval($siminfo['GridLocX'])*256;
|
||||
$LocY=intval($siminfo['GridLocY'])*256;
|
||||
$home="{'region_handle':'$region_handle', 'position':'$position', 'look_at':'$look_at'}";
|
||||
|
||||
$globaltextures = new LLBlock(
|
||||
Array(
|
||||
'sun_texture_id' => "cce0f112-878f-4586-a2e2-a8f104bba271",
|
||||
'cloud_texture_id' => "fc4b9f0b-d008-45c6-96a4-01dd947ac621",
|
||||
'moon_texture_id' => "d07f6eed-b96a-47cd-b51d-400ad4a1c428"
|
||||
));
|
||||
|
||||
$login_flags = new LLBlock(
|
||||
Array(
|
||||
'stipend_since_login' => "N",
|
||||
'ever_logged_in' => "Y",
|
||||
'gendered' => "Y",
|
||||
'daylight_savings' => "N"
|
||||
));
|
||||
$ui_config = new LLBlock(
|
||||
Array(
|
||||
'allow_first_life' => "Y"
|
||||
));
|
||||
$inventory_skeleton = new LLBlock(Array(
|
||||
Array(
|
||||
'name' => 'My inventory',
|
||||
'parent_id' => '00000000-0000-0000-0000-000000000000',
|
||||
'version' => 4,
|
||||
'type_default' => 8,
|
||||
'folder_id' => 'f798e114-c10f-409b-a90d-a11577ff1de8'
|
||||
),
|
||||
Array(
|
||||
'name' => 'Textures',
|
||||
'parent_id' => 'f798e114-c10f-409b-a90d-a11577ff1de8',
|
||||
'version' => 1,
|
||||
'type_default' => 0,
|
||||
'folder_id' => 'fc8b4059-30bb-43a8-a042-46f5b431ad82'
|
||||
)));
|
||||
$inventory_root = new LLBlock(
|
||||
Array(
|
||||
'folder_id' => "f798e114-c10f-409b-a90d-a11577ff1de8"
|
||||
));
|
||||
$initial_outfit = new LLBlock(
|
||||
Array(
|
||||
'folder_name' => "Nightclub Female",
|
||||
'gender' => "female"
|
||||
));
|
||||
return Array (
|
||||
'message' => "Welcome to OGS!",
|
||||
'session_id' => format_lluuid($session_id),
|
||||
'sim_port' => intval($siminfo['port']),
|
||||
'agent_access' => "M",
|
||||
'start_location' => "last",
|
||||
'global-textures' => $globaltextures,
|
||||
'seconds_since_epoch' => time(),
|
||||
'first_name' => $profiledata['profile_firstname'],
|
||||
'circuit_code' => 50633318,
|
||||
'login_flags' => $login_flags,
|
||||
'seed_capability' => '',
|
||||
'home' => $home,
|
||||
'secure_session_id' => format_lluuid($secure_session_id),
|
||||
'last_name' => $profiledata['profile_lastname'],
|
||||
'ui-config' => $ui_config,
|
||||
'region_x' => $LocX,
|
||||
'inventory_skeleton' => $inventory_skeleton,
|
||||
'sim_ip' => $siminfo['ip_addr'],
|
||||
'region_y' => $LocY,
|
||||
'inventory-root' => $inventory_root,
|
||||
'login' => "true",
|
||||
'look_at' => $look_at,
|
||||
'agent_id' => format_lluuid($profiledata['userprofile_LLUUID']),
|
||||
'initial-outfit' => $initial_outfit
|
||||
);
|
||||
|
||||
|
||||
} else {
|
||||
// this is the default invalid username/password error
|
||||
return Array (
|
||||
'reason' => 'key',
|
||||
'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.",
|
||||
'login' => "false",
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$server=new IXR_Server(array('login_to_simulator' => 'login'));
|
||||
?>
|
|
@ -1,11 +0,0 @@
|
|||
<?
|
||||
// All the user/login server specific stuff lives here
|
||||
|
||||
// What we send to authenticate to the grid server
|
||||
$gridserver_sendkey="1234";
|
||||
|
||||
// What we expect to get back from the grid server
|
||||
$gridserver_recvkey="1234";
|
||||
|
||||
$gridserver_url="http://www.osgrid.org/ogs/gridserver/index.php";
|
||||
?>
|
|
@ -0,0 +1,38 @@
|
|||
<?xml version="1.0"?>
|
||||
<project name="OGS" default="build" basedir=".">
|
||||
<description>nant buildfile for OpenSim</description>
|
||||
<property name="debug" value="true" overwrite="false" />
|
||||
<target name="clean" description="remove all generated files">
|
||||
<nant target="clean">
|
||||
<buildfiles>
|
||||
<include name="ServerConsole/default.build" />
|
||||
<include name="gridserver/default.build" />
|
||||
</buildfiles>
|
||||
</nant>
|
||||
|
||||
</target>
|
||||
|
||||
<target name="svnupdate" description="updates to latest SVN">
|
||||
<exec program="svn">
|
||||
<arg value="update" />
|
||||
</exec>
|
||||
</target>
|
||||
|
||||
<target name="upgrade" description="updates from SVN and then builds" depends="clean,svnupdate,build">
|
||||
|
||||
</target>
|
||||
|
||||
<target name="build" description="compiles the source code">
|
||||
|
||||
<exec program="genvers.sh" />
|
||||
<loadfile file="VERSION" property="svnver"/>
|
||||
|
||||
<nant>
|
||||
<buildfiles>
|
||||
<include name="ServerConsole/default.build" />
|
||||
<include name="gridserver/default.build" />
|
||||
</buildfiles>
|
||||
</nant>
|
||||
|
||||
</target>
|
||||
</project>
|
|
@ -0,0 +1,63 @@
|
|||
<?xml version="1.0"?>
|
||||
<project name="UserServer" default="build" basedir="./">
|
||||
<property name="debug" value="true" overwrite="false" />
|
||||
<target name="clean" description="remove all generated files">
|
||||
<delete>
|
||||
<fileset failonempty="false">
|
||||
<include name="bin/*.dll" />
|
||||
<include name="bin/*.exe" />
|
||||
<include name="bin/*.mdb" />
|
||||
</fileset>
|
||||
</delete>
|
||||
</target>
|
||||
|
||||
<target name="svnupdate" description="updates to latest SVN">
|
||||
<exec program="svn">
|
||||
<arg value="update" />
|
||||
</exec>
|
||||
</target>
|
||||
|
||||
<target name="upgrade" description="updates from SVN and then builds" depends="clean,svnupdate,build">
|
||||
|
||||
</target>
|
||||
|
||||
<target name="build" description="compiles the source code">
|
||||
|
||||
<loadfile file="../VERSION" property="svnver"/>
|
||||
<asminfo output="src/AssemblyInfo.cs" language="CSharp">
|
||||
<imports>
|
||||
<import namespace="System" />
|
||||
<import namespace="System.Reflection" />
|
||||
<import namespace="System.Runtime.InteropServices" />
|
||||
</imports>
|
||||
<attributes>
|
||||
<attribute type="ComVisibleAttribute" value="false" />
|
||||
<attribute type="CLSCompliantAttribute" value="false" />
|
||||
<attribute type="AssemblyVersionAttribute" value="${svnver}" />
|
||||
<attribute type="AssemblyTitleAttribute" value="ogs-UserServer" />
|
||||
<attribute type="AssemblyDescriptionAttribute" value="The core OGS User Server" />
|
||||
<attribute type="AssemblyCopyrightAttribute" value="Copyright © OGS development team 2007"/>
|
||||
</attributes>
|
||||
</asminfo>
|
||||
|
||||
<csc target="exe" output="bin/UserServer.exe" debug="${debug}" verbose="true" warninglevel="4">
|
||||
<references failonempty="true">
|
||||
<include name="System" />
|
||||
<include name="System.Xml" />
|
||||
<include name="../common/bin/ServerConsole.dll" />
|
||||
<include name="../common/bin/libsecondlife.dll" />
|
||||
</references>
|
||||
<sources>
|
||||
<include name="../common/src/VersionInfo.cs" />
|
||||
<include name="../common/src/OGS-Console.cs" />
|
||||
<include name="src/*.cs" />
|
||||
</sources>
|
||||
</csc>
|
||||
|
||||
<copy todir="bin/">
|
||||
<fileset basedir="../common/bin">
|
||||
<include name="*.*" />
|
||||
</fileset>
|
||||
</copy>
|
||||
</target>
|
||||
</project>
|
|
@ -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 <organization> 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 <copyright holder> ``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 <copyright holder> 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 UserConsole : conscmd_callback {
|
||||
public UserConsole() { }
|
||||
|
||||
public override void RunCmd(string cmd, string[] cmdparams) {
|
||||
switch(cmd) {
|
||||
case "help":
|
||||
ServerConsole.MainConsole.Instance.WriteLine("shutdown - shutdown the user server (USE CAUTION!)"
|
||||
);
|
||||
break;
|
||||
|
||||
case "shutdown":
|
||||
ServerConsole.MainConsole.Instance.Close();
|
||||
Environment.Exit(0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public override void Show(string ShowWhat) {
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,114 @@
|
|||
/*
|
||||
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 <organization> 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 <copyright holder> ``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 <copyright holder> 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.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using libsecondlife;
|
||||
using ServerConsole;
|
||||
|
||||
namespace OpenGridServices
|
||||
{
|
||||
/// <summary>
|
||||
/// </summary>
|
||||
public class OpenUser_Main
|
||||
{
|
||||
|
||||
public static OpenUser_Main userserver;
|
||||
|
||||
public UserHTTPServer _httpd;
|
||||
public UserProfileManager _profilemanager;
|
||||
public UserProfile GridGod;
|
||||
public string DefaultStartupMsg;
|
||||
public string GridURL;
|
||||
public string GridSendKey;
|
||||
public string GridRecvKey;
|
||||
|
||||
public Dictionary<LLUUID, UserProfile> UserSessions = new Dictionary<LLUUID, UserProfile>();
|
||||
|
||||
[STAThread]
|
||||
public static void Main( string[] args )
|
||||
{
|
||||
Console.WriteLine("OpenUser " + VersionInfo.Version + "\n");
|
||||
Console.WriteLine("Starting...\n");
|
||||
ServerConsole.MainConsole.Instance = new MServerConsole(ServerConsole.ConsoleBase.ConsoleType.Local, "", 0, "opengrid-console.log", "OpenUser", new UserConsole());
|
||||
|
||||
userserver = new OpenUser_Main();
|
||||
userserver.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.GridURL=ServerConsole.MainConsole.Instance.CmdPrompt("Grid URL: ");
|
||||
this.GridSendKey=ServerConsole.MainConsole.Instance.CmdPrompt("Key to send to grid: ");
|
||||
this.GridRecvKey=ServerConsole.MainConsole.Instance.CmdPrompt("Key to expect from grid: ");
|
||||
|
||||
this.DefaultStartupMsg=ServerConsole.MainConsole.Instance.CmdPrompt("Default startup message for clients [Welcome to OGS!] :","Welcome to OGS!");
|
||||
|
||||
ServerConsole.MainConsole.Instance.WriteLine("Main.cs:Startup() - Creating user profile manager");
|
||||
_profilemanager = new UserProfileManager();
|
||||
_profilemanager.InitUserProfiles();
|
||||
|
||||
|
||||
string tempfirstname;
|
||||
string templastname;
|
||||
string tempMD5Passwd;
|
||||
ServerConsole.MainConsole.Instance.WriteLine("Main.cs:Startup() - Please configure the grid god user:");
|
||||
tempfirstname=ServerConsole.MainConsole.Instance.CmdPrompt("First name: ");
|
||||
templastname=ServerConsole.MainConsole.Instance.CmdPrompt("Last name: ");
|
||||
tempMD5Passwd=ServerConsole.MainConsole.Instance.PasswdPrompt("Password: ");
|
||||
|
||||
System.Security.Cryptography.MD5CryptoServiceProvider x = new System.Security.Cryptography.MD5CryptoServiceProvider();
|
||||
byte[] bs = System.Text.Encoding.UTF8.GetBytes(tempMD5Passwd);
|
||||
bs = x.ComputeHash(bs);
|
||||
System.Text.StringBuilder s = new System.Text.StringBuilder();
|
||||
foreach (byte b in bs)
|
||||
{
|
||||
s.Append(b.ToString("x2").ToLower());
|
||||
}
|
||||
tempMD5Passwd = "$1$" + s.ToString();
|
||||
|
||||
GridGod=_profilemanager.CreateNewProfile(tempfirstname,templastname,tempMD5Passwd);
|
||||
_profilemanager.SetGod(GridGod.UUID);
|
||||
GridGod.homelookat = new LLVector3(-0.57343f, -0.819255f, 0f);
|
||||
GridGod.homepos = new LLVector3(128f,128f,23f);
|
||||
|
||||
ServerConsole.MainConsole.Instance.WriteLine("Main.cs:Startup() - Starting HTTP process");
|
||||
_httpd = new UserHTTPServer();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,287 @@
|
|||
/*
|
||||
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 <organization> 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 <copyright holder> ``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 <copyright holder> 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 UserHTTPServer {
|
||||
public Thread HTTPD;
|
||||
public HttpListener Listener;
|
||||
|
||||
public UserHTTPServer() {
|
||||
ServerConsole.MainConsole.Instance.WriteLine("Starting up HTTP Server");
|
||||
HTTPD = new Thread(new ThreadStart(StartHTTP));
|
||||
HTTPD.Start();
|
||||
}
|
||||
|
||||
public void StartHTTP() {
|
||||
ServerConsole.MainConsole.Instance.WriteLine("UserHttp.cs:StartHTTP() - Spawned main thread OK");
|
||||
Listener = new HttpListener();
|
||||
|
||||
Listener.Prefixes.Add("http://+:8002/userserver/");
|
||||
Listener.Prefixes.Add("http://+:8002/usersessions/");
|
||||
Listener.Start();
|
||||
|
||||
HttpListenerContext context;
|
||||
while(true) {
|
||||
context = Listener.GetContext();
|
||||
ThreadPool.QueueUserWorkItem(new WaitCallback(HandleRequest), context);
|
||||
}
|
||||
}
|
||||
|
||||
static string ParseXMLRPC(string requestBody) {
|
||||
XmlRpcRequest request = (XmlRpcRequest)(new XmlRpcRequestDeserializer()).Deserialize(requestBody);
|
||||
|
||||
Hashtable requestData = (Hashtable)request.Params[0];
|
||||
switch(request.MethodName) {
|
||||
case "login_to_simulator":
|
||||
bool GoodXML= (requestData.Contains("first") && requestData.Contains("last") && requestData.Contains("passwd"));
|
||||
bool GoodLogin=false;
|
||||
string firstname="";
|
||||
string lastname="";
|
||||
string passwd="";
|
||||
|
||||
if(GoodXML) {
|
||||
firstname=(string)requestData["first"];
|
||||
lastname=(string)requestData["last"];
|
||||
passwd=(string)requestData["passwd"];
|
||||
GoodLogin=OpenUser_Main.userserver._profilemanager.AuthenticateUser(firstname,lastname,passwd);
|
||||
}
|
||||
|
||||
|
||||
if(!(GoodXML && GoodLogin)) {
|
||||
XmlRpcResponse LoginErrorResp = new XmlRpcResponse();
|
||||
Hashtable ErrorRespData = new Hashtable();
|
||||
ErrorRespData["reason"]="key";
|
||||
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";
|
||||
ErrorRespData["login"]="false";
|
||||
LoginErrorResp.Value=ErrorRespData;
|
||||
return(Regex.Replace(XmlRpcResponseSerializer.Singleton.Serialize(LoginErrorResp)," encoding=\"utf-16\"","" ));
|
||||
}
|
||||
|
||||
UserProfile TheUser=OpenUser_Main.userserver._profilemanager.GetProfileByName(firstname,lastname);
|
||||
|
||||
if(!((TheUser.CurrentSessionID==null) && (TheUser.CurrentSecureSessionID==null))) {
|
||||
XmlRpcResponse PresenceErrorResp = new XmlRpcResponse();
|
||||
Hashtable PresenceErrorRespData = new Hashtable();
|
||||
PresenceErrorRespData["reason"]="presence";
|
||||
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";
|
||||
PresenceErrorRespData["login"]="false";
|
||||
PresenceErrorResp.Value=PresenceErrorRespData;
|
||||
return(Regex.Replace(XmlRpcResponseSerializer.Singleton.Serialize(PresenceErrorResp)," encoding=\"utf-16\"","" ));
|
||||
|
||||
}
|
||||
|
||||
try {
|
||||
LLUUID AgentID = TheUser.UUID;
|
||||
TheUser.InitSessionData();
|
||||
SimProfile SimInfo = new SimProfile();
|
||||
SimInfo = SimInfo.LoadFromGrid(TheUser.homeregionhandle,OpenUser_Main.userserver.GridURL,OpenUser_Main.userserver.GridSendKey,OpenUser_Main.userserver.GridRecvKey);
|
||||
|
||||
XmlRpcResponse LoginGoodResp = new XmlRpcResponse();
|
||||
Hashtable LoginGoodData = new Hashtable();
|
||||
|
||||
Hashtable GlobalT = new Hashtable();
|
||||
GlobalT["sun_texture_id"] = "cce0f112-878f-4586-a2e2-a8f104bba271";
|
||||
GlobalT["cloud_texture_id"] = "fc4b9f0b-d008-45c6-96a4-01dd947ac621";
|
||||
GlobalT["moon_texture_id"] = "fc4b9f0b-d008-45c6-96a4-01dd947ac621";
|
||||
ArrayList GlobalTextures = new ArrayList();
|
||||
GlobalTextures.Add(GlobalT);
|
||||
|
||||
Hashtable LoginFlagsHash = new Hashtable();
|
||||
LoginFlagsHash["daylight_savings"]="N";
|
||||
LoginFlagsHash["stipend_since_login"]="N";
|
||||
LoginFlagsHash["gendered"]="Y";
|
||||
LoginFlagsHash["ever_logged_in"]="Y";
|
||||
ArrayList LoginFlags=new ArrayList();
|
||||
LoginFlags.Add(LoginFlagsHash);
|
||||
|
||||
Hashtable uiconfig = new Hashtable();
|
||||
uiconfig["allow_first_life"]="Y";
|
||||
ArrayList ui_config=new ArrayList();
|
||||
ui_config.Add(uiconfig);
|
||||
|
||||
Hashtable ClassifiedCategoriesHash = new Hashtable();
|
||||
ClassifiedCategoriesHash["category_name"]="bla bla";
|
||||
ClassifiedCategoriesHash["category_id"]=(Int32)1;
|
||||
ArrayList ClassifiedCategories = new ArrayList();
|
||||
ClassifiedCategories.Add(ClassifiedCategoriesHash);
|
||||
|
||||
ArrayList AgentInventory = new ArrayList();
|
||||
foreach(InventoryFolder InvFolder in TheUser.InventoryFolders.Values) {
|
||||
Hashtable TempHash = new Hashtable();
|
||||
TempHash["name"]=InvFolder.FolderName;
|
||||
TempHash["parent_id"]=InvFolder.ParentID.ToStringHyphenated();
|
||||
TempHash["version"]=(Int32)InvFolder.Version;
|
||||
TempHash["type_default"]=(Int32)InvFolder.DefaultType;
|
||||
TempHash["folder_id"]=InvFolder.FolderID.ToStringHyphenated();
|
||||
AgentInventory.Add(TempHash);
|
||||
}
|
||||
|
||||
Hashtable InventoryRootHash = new Hashtable();
|
||||
InventoryRootHash["folder_id"]=TheUser.InventoryRoot.FolderID.ToStringHyphenated();
|
||||
ArrayList InventoryRoot = new ArrayList();
|
||||
InventoryRoot.Add(InventoryRootHash);
|
||||
|
||||
Hashtable InitialOutfitHash = new Hashtable();
|
||||
InitialOutfitHash["folder_name"]="Nightclub Female";
|
||||
InitialOutfitHash["gender"]="female";
|
||||
ArrayList InitialOutfit = new ArrayList();
|
||||
InitialOutfit.Add(InitialOutfitHash);
|
||||
|
||||
uint circode = (uint)(new Random()).Next();
|
||||
TheUser.AddSimCircuit(circode, SimInfo.UUID);
|
||||
|
||||
LoginGoodData["last_name"]="\"" + TheUser.firstname + "\"";
|
||||
LoginGoodData["ui-config"]=ui_config;
|
||||
LoginGoodData["sim_ip"]=SimInfo.sim_ip.ToString();
|
||||
LoginGoodData["login-flags"]=LoginFlags;
|
||||
LoginGoodData["global-textures"]=GlobalTextures;
|
||||
LoginGoodData["classified_categories"]=ClassifiedCategories;
|
||||
LoginGoodData["event_categories"]=new ArrayList();
|
||||
LoginGoodData["inventory-skeleton"]=AgentInventory;
|
||||
LoginGoodData["inventory-skel-lib"]=new ArrayList();
|
||||
LoginGoodData["inventory-root"]=InventoryRoot;
|
||||
LoginGoodData["event_notifications"]=new ArrayList();
|
||||
LoginGoodData["gestures"]=new ArrayList();
|
||||
LoginGoodData["inventory-lib-owner"]=new ArrayList();
|
||||
LoginGoodData["initial-outfit"]=InitialOutfit;
|
||||
LoginGoodData["seconds_since_epoch"]=(Int32)(DateTime.UtcNow - new DateTime(1970,1,1)).TotalSeconds;
|
||||
LoginGoodData["start_location"]="last";
|
||||
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() + "]}";
|
||||
LoginGoodData["message"]=OpenUser_Main.userserver.DefaultStartupMsg;
|
||||
LoginGoodData["first_name"]="\"" + firstname + "\"";
|
||||
LoginGoodData["circuit_code"]=(Int32)circode;
|
||||
LoginGoodData["sim_port"]=(Int32)SimInfo.sim_port;
|
||||
LoginGoodData["secure_session_id"]=TheUser.CurrentSecureSessionID.ToStringHyphenated();
|
||||
LoginGoodData["look_at"]="\n[r" + TheUser.homelookat.X.ToString() + ",r" + TheUser.homelookat.Y.ToString() + ",r" + TheUser.homelookat.Z.ToString() + "]\n";
|
||||
LoginGoodData["agent_id"]=AgentID.ToStringHyphenated();
|
||||
LoginGoodData["region_y"]=(Int32)SimInfo.RegionLocY*256;
|
||||
LoginGoodData["region_x"]=(Int32)SimInfo.RegionLocX*256;
|
||||
LoginGoodData["seed_capability"]=null;
|
||||
LoginGoodData["agent_access"]="M";
|
||||
LoginGoodData["session_id"]=TheUser.CurrentSessionID.ToStringHyphenated();
|
||||
LoginGoodData["login"]="true";
|
||||
|
||||
LoginGoodResp.Value=LoginGoodData;
|
||||
TheUser.SendDataToSim(SimInfo);
|
||||
return(Regex.Replace(XmlRpcResponseSerializer.Singleton.Serialize(LoginGoodResp),"utf-16","utf-8" ));
|
||||
|
||||
} catch (Exception E) {
|
||||
Console.WriteLine(E.ToString());
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
static string ParseREST(HttpListenerRequest www_req) {
|
||||
Console.WriteLine("INCOMING REST - " + www_req.RawUrl);
|
||||
|
||||
char[] splitter = {'/'};
|
||||
string[] rest_params = www_req.RawUrl.Split(splitter);
|
||||
string req_type = rest_params[1]; // First part of the URL is the type of request - usersessions/userprofiles/inventory/blabla
|
||||
switch(req_type) {
|
||||
case "usersessions":
|
||||
LLUUID sessionid = new LLUUID(rest_params[2]); // get usersessions/sessionid
|
||||
if(www_req.HttpMethod=="DELETE") {
|
||||
foreach (libsecondlife.LLUUID UUID in OpenUser_Main.userserver._profilemanager.UserProfiles.Keys) {
|
||||
if(OpenUser_Main.userserver._profilemanager.UserProfiles[UUID].CurrentSessionID==sessionid) {
|
||||
OpenUser_Main.userserver._profilemanager.UserProfiles[UUID].CurrentSessionID=null;
|
||||
OpenUser_Main.userserver._profilemanager.UserProfiles[UUID].CurrentSecureSessionID=null;
|
||||
OpenUser_Main.userserver._profilemanager.UserProfiles[UUID].Circuits.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return "OK";
|
||||
break;
|
||||
}
|
||||
|
||||
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 "text/plaintext":
|
||||
responseString=ParseREST(request);
|
||||
response.AddHeader("Content-type","text/plaintext");
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,223 @@
|
|||
/*
|
||||
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 <organization> 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 <copyright holder> ``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 <copyright holder> 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 Nwc.XmlRpc;
|
||||
using ServerConsole;
|
||||
|
||||
namespace OpenGridServices
|
||||
{
|
||||
/// <summary>
|
||||
/// </summary>
|
||||
public class UserProfileManager {
|
||||
|
||||
public Dictionary<LLUUID, UserProfile> UserProfiles = new Dictionary<LLUUID, UserProfile>();
|
||||
|
||||
public UserProfileManager() {
|
||||
}
|
||||
|
||||
public void InitUserProfiles() {
|
||||
// TODO: need to load from database
|
||||
}
|
||||
|
||||
public UserProfile GetProfileByName(string firstname, string lastname) {
|
||||
foreach (libsecondlife.LLUUID UUID in UserProfiles.Keys) {
|
||||
if((UserProfiles[UUID].firstname==firstname) && (UserProfiles[UUID].lastname==lastname)) return UserProfiles[UUID];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public UserProfile GetProfileByLLUUID(LLUUID ProfileLLUUID) {
|
||||
return UserProfiles[ProfileLLUUID];
|
||||
}
|
||||
|
||||
public bool AuthenticateUser(string firstname, string lastname, string passwd) {
|
||||
UserProfile TheUser=GetProfileByName(firstname, lastname);
|
||||
if(TheUser != null)
|
||||
if(TheUser.MD5passwd==passwd) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
} else return false;
|
||||
|
||||
}
|
||||
|
||||
public void SetGod(LLUUID GodID) {
|
||||
this.UserProfiles[GodID].IsGridGod=true;
|
||||
}
|
||||
|
||||
public UserProfile CreateNewProfile(string firstname, string lastname, string MD5passwd) {
|
||||
UserProfile newprofile = new UserProfile();
|
||||
newprofile.homeregionhandle=Util.UIntsToLong((997*256), (996*256));
|
||||
newprofile.firstname=firstname;
|
||||
newprofile.lastname=lastname;
|
||||
newprofile.MD5passwd=MD5passwd;
|
||||
newprofile.UUID=LLUUID.Random();
|
||||
this.UserProfiles.Add(newprofile.UUID,newprofile);
|
||||
return newprofile;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class UserProfile {
|
||||
|
||||
public string firstname;
|
||||
public string lastname;
|
||||
public ulong homeregionhandle;
|
||||
public LLVector3 homepos;
|
||||
public LLVector3 homelookat;
|
||||
|
||||
public bool IsGridGod=false;
|
||||
public bool IsLocal=true; // will be used in future for visitors from foreign grids
|
||||
public string AssetURL;
|
||||
public string MD5passwd;
|
||||
|
||||
public LLUUID CurrentSessionID;
|
||||
public LLUUID CurrentSecureSessionID;
|
||||
public LLUUID UUID;
|
||||
public Dictionary<LLUUID, uint> Circuits = new Dictionary<LLUUID, uint>(); // tracks circuit codes
|
||||
|
||||
public InventoryFolder InventoryRoot;
|
||||
public Dictionary<LLUUID, InventoryFolder> InventoryFolders;
|
||||
public Dictionary<LLUUID, InventoryItem> InventoryItems;
|
||||
|
||||
public UserProfile() {
|
||||
Circuits = new Dictionary<LLUUID, uint>();
|
||||
InventoryFolders = new Dictionary<LLUUID, InventoryFolder>();
|
||||
InventoryItems = new Dictionary<LLUUID, InventoryItem>();
|
||||
InventoryRoot=new InventoryFolder();
|
||||
InventoryRoot.FolderID = LLUUID.Random();
|
||||
InventoryRoot.ParentID=new LLUUID();
|
||||
InventoryRoot.Version=1;
|
||||
InventoryRoot.DefaultType=8;
|
||||
InventoryRoot.FolderName="My Inventory";
|
||||
InventoryFolders.Add(InventoryRoot.FolderID, InventoryRoot);
|
||||
homeregionhandle=Util.UIntsToLong((997*256), (996*256));;
|
||||
}
|
||||
|
||||
public void InitSessionData() {
|
||||
CurrentSessionID=LLUUID.Random();
|
||||
CurrentSecureSessionID=LLUUID.Random();
|
||||
}
|
||||
|
||||
public void AddSimCircuit(uint circuit_code, LLUUID region_UUID) {
|
||||
if(this.Circuits.ContainsKey(region_UUID)== false)
|
||||
this.Circuits.Add(region_UUID, circuit_code);
|
||||
}
|
||||
|
||||
public void SendDataToSim(SimProfile TheSim) {
|
||||
Console.WriteLine(TheSim.caps_url);
|
||||
Hashtable SimParams = new Hashtable();
|
||||
SimParams["session_id"]=this.CurrentSessionID.ToString();
|
||||
SimParams["secure_session_id"]=this.CurrentSecureSessionID.ToString();
|
||||
SimParams["firstname"]=this.firstname;
|
||||
SimParams["lastname"]=this.lastname;
|
||||
SimParams["agent_id"]=this.UUID.ToString();
|
||||
SimParams["circuit_code"]=(Int32)this.Circuits[TheSim.UUID];
|
||||
ArrayList SendParams = new ArrayList();
|
||||
SendParams.Add(SimParams);
|
||||
|
||||
XmlRpcRequest GridReq = new XmlRpcRequest("expect_user",SendParams);
|
||||
XmlRpcResponse GridResp = GridReq.Send(TheSim.caps_url,3000);
|
||||
}
|
||||
}
|
||||
|
||||
public class InventoryFolder {
|
||||
public LLUUID FolderID;
|
||||
public LLUUID ParentID;
|
||||
public string FolderName;
|
||||
public ushort DefaultType;
|
||||
public ushort Version;
|
||||
}
|
||||
|
||||
public class InventoryItem { //TODO: Fixup this and add full permissions etc
|
||||
public LLUUID FolderID;
|
||||
public LLUUID OwnerID;
|
||||
public LLUUID ItemID;
|
||||
public LLUUID AssetID;
|
||||
public LLUUID CreatorID = LLUUID.Zero;
|
||||
public sbyte InvType;
|
||||
public sbyte Type;
|
||||
public string Name;
|
||||
public string Description;
|
||||
}
|
||||
|
||||
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 LoadFromGrid(ulong region_handle, string GridURL, string SendKey, string RecvKey) {
|
||||
try {
|
||||
Hashtable GridReqParams = new Hashtable();
|
||||
GridReqParams["region_handle"]=region_handle.ToString();
|
||||
GridReqParams["caller"]="userserver";
|
||||
GridReqParams["authkey"]=SendKey;
|
||||
ArrayList SendParams = new ArrayList();
|
||||
SendParams.Add(GridReqParams);
|
||||
XmlRpcRequest GridReq = new XmlRpcRequest("get_sim_info",SendParams);
|
||||
|
||||
XmlRpcResponse GridResp = GridReq.Send(GridURL,3000);
|
||||
|
||||
Hashtable RespData=(Hashtable)GridResp.Value;
|
||||
this.UUID = new LLUUID((string)RespData["UUID"]);
|
||||
this.regionhandle = (ulong)Convert.ToUInt64(RespData["regionhandle"]);
|
||||
this.regionname=(string)RespData["regionname"];
|
||||
this.sim_ip=(string)RespData["sim_ip"];
|
||||
this.sim_port=(uint)Convert.ToUInt16(RespData["sim_port"]);
|
||||
this.caps_url=(string)RespData["caps_url"];
|
||||
this.RegionLocX=(uint)Convert.ToUInt32(RespData["RegionLocX"]);
|
||||
this.RegionLocY=(uint)Convert.ToUInt32(RespData["RegionLocY"]);
|
||||
this.sendkey=(string)RespData["sendkey"];
|
||||
this.recvkey=(string)RespData["recvkey"];
|
||||
} catch(Exception e) {
|
||||
Console.WriteLine(e.ToString());
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public SimProfile() {
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,87 @@
|
|||
/*
|
||||
Copyright (c) OpenSim project, http://osgrid.org/
|
||||
|
||||
* Copyright (c) <year>, <copyright holder>
|
||||
* 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 <organization> 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 <copyright holder> ``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 <copyright holder> 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.Collections.Generic;
|
||||
using System.Threading;
|
||||
using libsecondlife;
|
||||
using libsecondlife.Packets;
|
||||
|
||||
namespace OpenGridServices
|
||||
{
|
||||
/// <summary>
|
||||
/// </summary>
|
||||
///
|
||||
public class Util
|
||||
{
|
||||
public static ulong UIntsToLong(uint X, uint Y)
|
||||
{
|
||||
return Helpers.UIntsToLong(X,Y);
|
||||
}
|
||||
public Util()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public class QueItem {
|
||||
public QueItem()
|
||||
{
|
||||
}
|
||||
|
||||
public Packet Packet;
|
||||
public bool Incoming;
|
||||
}
|
||||
|
||||
|
||||
public class BlockingQueue< T > {
|
||||
private Queue< T > _queue = new Queue< T >();
|
||||
private object _queueSync = new object();
|
||||
|
||||
public void Enqueue(T value)
|
||||
{
|
||||
lock(_queueSync)
|
||||
{
|
||||
_queue.Enqueue(value);
|
||||
Monitor.Pulse(_queueSync);
|
||||
}
|
||||
}
|
||||
|
||||
public T Dequeue()
|
||||
{
|
||||
lock(_queueSync)
|
||||
{
|
||||
if( _queue.Count < 1)
|
||||
Monitor.Wait(_queueSync);
|
||||
|
||||
return _queue.Dequeue();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue