Moved gridserver into main trunk (but no prebuild yet)

tourmaline
gareth 2007-03-24 18:29:35 +00:00
parent d1fbe870af
commit d9dcc6fa8b
13 changed files with 0 additions and 425 deletions

View File

@ -1,57 +0,0 @@
/*
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) {
}
}
}

View File

@ -1,118 +0,0 @@
/*
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;
using OpenSim.Framework.User;
using OpenSim.Framework.Sims;
using OpenSim.Framework.Inventory;
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();
_profilemanager.SetKeys(GridSendKey, GridRecvKey, GridURL, DefaultStartupMsg);
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();
}
}
}

View File

@ -1,63 +0,0 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.50727</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{D45B6E48-5668-478D-B9CB-6D46E665FACF}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>OGS_UserServer</RootNamespace>
<AssemblyName>OGS-UserServer</AssemblyName>
<StartupObject>OpenGridServices.OpenUser_Main</StartupObject>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="libsecondlife, Version=0.9.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\common\bin\libsecondlife.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\..\common\src\OGS-Console.cs">
<Link>OGS-Console.cs</Link>
</Compile>
<Compile Include="..\..\common\VersionInfo\VersionInfo.cs">
<Link>VersionInfo.cs</Link>
</Compile>
<Compile Include="ConsoleCmds.cs" />
<Compile Include="Main.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="UserHttp.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\OpenSim.FrameWork\OpenSim.Framework.csproj">
<Project>{2E46A825-3168-492F-93BC-637126B5B72B}</Project>
<Name>OpenSim.Framework</Name>
</ProjectReference>
<ProjectReference Include="..\..\ServerConsole\ServerConsole.csproj">
<Project>{7667E6E2-F227-41A2-B1B2-315613E1BAFC}</Project>
<Name>ServerConsole</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
</Project>

View File

@ -1,8 +0,0 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<PublishUrlHistory>publish\</PublishUrlHistory>
<ApplicationRevision>0</ApplicationRevision>
<FallbackCulture>en-US</FallbackCulture>
<VerifyUploadedFiles>false</VerifyUploadedFiles>
</PropertyGroup>
</Project>

View File

@ -1,33 +0,0 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("OGS-UserServer")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("OGS-UserServer")]
[assembly: AssemblyCopyright("Copyright © 2007")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("e266513a-090b-4d38-80f6-8599eef68c8c")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@ -1,146 +0,0 @@
/*
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;
using OpenSim.Framework.User;
using OpenSim.Framework.Sims;
using OpenSim.Framework.Inventory;
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) {
return OpenGridServices.OpenUser_Main.userserver._profilemanager.ParseXMLRPC(requestBody);
}
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();
}
}
}