Merge branch 'master' into diva-textures

prioritization
Melanie 2009-10-02 08:23:38 +01:00
commit 31d8cec0f8
356 changed files with 8423 additions and 5997 deletions

View File

@ -53,6 +53,11 @@
</exec>
<fail message="Failures reported in unit tests." unless="${int::parse(testresult.opensim.framework.servers.tests)==0}" />
<exec program="${nunitcmd}" failonerror="true" resultproperty="testresult.opensim.framework.serialization.tests">
<arg value="./bin/OpenSim.Framework.Serialization.Tests.dll" />
</exec>
<fail message="Failures reported in unit tests." unless="${int::parse(testresult.opensim.framework.serialization.tests)==0}" />
<exec program="${nunitcmd}" failonerror="true" resultproperty="testresult.opensim.region.clientstack.lindenudp.tests">
<arg value="./bin/OpenSim.Region.ClientStack.LindenUDP.Tests.dll" />
</exec>
@ -223,6 +228,11 @@
<arg value="-xml=test-results/OpenSim.Framework.Communications.Tests.dll-Results.xml" />
</exec>
<exec program="${nunitcmd}" failonerror="false" resultproperty="testresult.opensim.framework.serialization.tests">
<arg value="./bin/OpenSim.Framework.Serialization.Tests.dll" />
<arg value="-xml=test-results/OpenSim.Framework.Serialization.Tests.dll-Results.xml" />
</exec>
<exec program="${nunitcmd}" failonerror="false" resultproperty="testresult.opensim.framework.servers.tests">
<arg value="./bin/OpenSim.Framework.Servers.Tests.dll" />
<arg value="-xml=test-results/OpenSim.Framework.Servers.Tests.dll-Results.xml" />

View File

@ -69,7 +69,6 @@ namespace OpenSim.ApplicationPlugins.CreateCommsManager
protected CommunicationsManager m_commsManager;
protected GridInfoService m_gridInfoService;
protected IHyperlink HGServices = null;
protected IRegionCreator m_regionCreator;
@ -144,7 +143,6 @@ namespace OpenSim.ApplicationPlugins.CreateCommsManager
// We are in grid mode
InitialiseHGGridServices(libraryRootFolder);
}
HGCommands.HGServices = HGServices;
}
protected void InitialiseStandardServices(LibraryRootFolder libraryRootFolder)
@ -188,18 +186,11 @@ namespace OpenSim.ApplicationPlugins.CreateCommsManager
protected virtual void InitialiseHGStandaloneServices(LibraryRootFolder libraryRootFolder)
{
HGGridServicesStandalone gridService
= new HGGridServicesStandalone(
m_openSim.NetServersInfo, m_httpServer, m_openSim.SceneManager);
m_commsManager
= new HGCommunicationsStandalone(
m_openSim.ConfigurationSettings, m_openSim.NetServersInfo, m_httpServer,
gridService,
libraryRootFolder, false);
HGServices = gridService;
CreateGridInfoService();
}
@ -210,8 +201,6 @@ namespace OpenSim.ApplicationPlugins.CreateCommsManager
m_openSim.NetServersInfo,
m_openSim.SceneManager, libraryRootFolder);
HGServices = ((HGCommunicationsGridMode) m_commsManager).HGServices;
m_httpServer.AddStreamHandler(new OpenSim.SimStatusHandler());
m_httpServer.AddStreamHandler(new OpenSim.XSimStatusHandler(m_openSim));
if (m_openSim.userStatsURI != String.Empty)

View File

@ -69,7 +69,6 @@ namespace OpenSim.ApplicationPlugins.RemoteController
private string m_name = "RemoteAdminPlugin";
private string m_version = "0.0";
//AnakinLohner 0.6.5-post-fixes
//guard for XmlRpc-related methods
private void FailIfRemoteAdminDisabled(string requestName)
{
@ -469,7 +468,6 @@ namespace OpenSim.ApplicationPlugins.RemoteController
{
m_log.Info("[RADMIN]: CreateRegion: new request");
//AnakinLohner 0.6.5-post-fixes
FailIfRemoteAdminDisabled("CreateRegion");
XmlRpcResponse response = new XmlRpcResponse();
@ -477,7 +475,6 @@ namespace OpenSim.ApplicationPlugins.RemoteController
lock (rslock)
{
int m_regionLimit = m_config.GetInt("region_limit", 0);
bool m_enableVoiceForNewRegions = m_config.GetBoolean("create_region_enable_voice", false);
bool m_publicAccess = m_config.GetBoolean("create_region_public", true);
@ -561,7 +558,6 @@ namespace OpenSim.ApplicationPlugins.RemoteController
scene.RegionInfo.RegionName, scene.RegionInfo.RegionID,
scene.RegionInfo.RegionLocX, scene.RegionInfo.RegionLocY));
region.ExternalHostName = (string) requestData["external_address"];
string masterFirst = (string) requestData["region_master_first"];
@ -989,7 +985,6 @@ namespace OpenSim.ApplicationPlugins.RemoteController
{
m_log.Info("[RADMIN]: CreateUser: new request");
//AnakinLohner 0.6.5-post-fixes
FailIfRemoteAdminDisabled("CreateUser");
XmlRpcResponse response = new XmlRpcResponse();
@ -1101,7 +1096,6 @@ namespace OpenSim.ApplicationPlugins.RemoteController
{
m_log.Info("[RADMIN]: UserExists: new request");
//AnakinLohner 0.6.5-post-fixes
FailIfRemoteAdminDisabled("UserExists");
XmlRpcResponse response = new XmlRpcResponse();
@ -1134,7 +1128,6 @@ namespace OpenSim.ApplicationPlugins.RemoteController
responseData["lastlogin"] = userInfo.UserProfile.LastLogin;
}
response.Value = responseData;
}
catch (Exception e)
@ -1308,7 +1301,6 @@ namespace OpenSim.ApplicationPlugins.RemoteController
m_log.Info("[RADMIN]: UpdateUserAccount: request complete");
return response;
}
/// <summary>
@ -1321,7 +1313,6 @@ namespace OpenSim.ApplicationPlugins.RemoteController
private void updateUserAppearance(Hashtable responseData, Hashtable requestData, UUID userid)
{
m_log.DebugFormat("[RADMIN] updateUserAppearance");
string dmale = m_config.GetString("default_male", "Default Male");
@ -1402,7 +1393,6 @@ namespace OpenSim.ApplicationPlugins.RemoteController
private void establishAppearance(UUID dest, UUID srca)
{
m_log.DebugFormat("[RADMIN] Initializing inventory for {0} from {1}", dest, srca);
AvatarAppearance ava = m_app.CommunicationsManager.AvatarService.GetUserAppearance(srca);
@ -1423,7 +1413,6 @@ namespace OpenSim.ApplicationPlugins.RemoteController
try
{
Dictionary<UUID,UUID> imap = new Dictionary<UUID,UUID>();
iserv.GetUserInventory(dest, dic.callback);
@ -1434,7 +1423,6 @@ namespace OpenSim.ApplicationPlugins.RemoteController
if (sic.OK && dic.OK)
{
InventoryFolderImpl efolder;
InventoryFolderImpl srcf = sic.root.FindFolderForType(5);
InventoryFolderImpl dstf = dic.root.FindFolderForType(5);
@ -1494,7 +1482,6 @@ namespace OpenSim.ApplicationPlugins.RemoteController
ava.SetWearable(i, dw);
}
}
}
else
{
@ -1502,7 +1489,6 @@ namespace OpenSim.ApplicationPlugins.RemoteController
}
m_app.CommunicationsManager.AvatarService.UpdateUserAppearance(dest, ava);
}
catch (Exception e)
{
@ -1512,7 +1498,6 @@ namespace OpenSim.ApplicationPlugins.RemoteController
}
return;
}
///<summary>
@ -1527,7 +1512,6 @@ namespace OpenSim.ApplicationPlugins.RemoteController
private bool createDefaultAvatars()
{
// Only load once
if (daload)
@ -1543,10 +1527,8 @@ namespace OpenSim.ApplicationPlugins.RemoteController
try
{
string dafn = null;
//AnakinLohner 0.6.5-post-fixes
//m_config may be null if RemoteAdmin configuration secition is missing or disabled in OpenSim.ini
if (m_config != null)
{
@ -1555,7 +1537,6 @@ namespace OpenSim.ApplicationPlugins.RemoteController
if (File.Exists(dafn))
{
XmlDocument doc = new XmlDocument();
string name = "*unknown*";
string email = "anon@anon";
@ -1670,7 +1651,6 @@ namespace OpenSim.ApplicationPlugins.RemoteController
if (uic.OK)
try
{
m_log.DebugFormat("[RADMIN] {0} folders, {1} items in inventory",
uic.folders.Count, uic.items.Count);
@ -1699,7 +1679,6 @@ namespace OpenSim.ApplicationPlugins.RemoteController
foreach (XmlElement outfit in outfits)
{
m_log.DebugFormat("[RADMIN] Loading outfit {0} for {1}",
GetStringAttribute(outfit,"name","?"), GetStringAttribute(avatar,"name","?"));
@ -1820,7 +1799,6 @@ namespace OpenSim.ApplicationPlugins.RemoteController
}
return true;
}
/// <summary>
@ -1859,7 +1837,6 @@ namespace OpenSim.ApplicationPlugins.RemoteController
{
m_log.Info("[RADMIN]: Received Load OAR Administrator Request");
//AnakinLohner 0.6.5-post-fixes
FailIfRemoteAdminDisabled("Load OAR");
XmlRpcResponse response = new XmlRpcResponse();
@ -1962,7 +1939,6 @@ namespace OpenSim.ApplicationPlugins.RemoteController
{
m_log.Info("[RADMIN]: Received Save OAR Administrator Request");
//AnakinLohner 0.6.5-post-fixes
FailIfRemoteAdminDisabled("Save OAR");
XmlRpcResponse response = new XmlRpcResponse();
@ -2003,7 +1979,6 @@ namespace OpenSim.ApplicationPlugins.RemoteController
IRegionArchiverModule archiver = scene.RequestModuleInterface<IRegionArchiverModule>();
if (archiver != null)
{
scene.EventManager.OnOarFileSaved += RemoteAdminOarSaveCompleted;
@ -2014,11 +1989,9 @@ namespace OpenSim.ApplicationPlugins.RemoteController
else
throw new Exception("Archiver module not present for scene");
responseData["saved"] = true;
response.Value = responseData;
}
catch (Exception e)
{
@ -2045,7 +2018,6 @@ namespace OpenSim.ApplicationPlugins.RemoteController
{
m_log.Info("[RADMIN]: Received Load XML Administrator Request");
//AnakinLohner 0.6.5-post-fixes
FailIfRemoteAdminDisabled("Load XML");
XmlRpcResponse response = new XmlRpcResponse();
@ -2129,12 +2101,10 @@ namespace OpenSim.ApplicationPlugins.RemoteController
}
}
public XmlRpcResponse XmlRpcSaveXMLMethod(XmlRpcRequest request, IPEndPoint remoteClient)
{
m_log.Info("[RADMIN]: Received Save XML Administrator Request");
//AnakinLohner 0.6.5-post-fixes
FailIfRemoteAdminDisabled("Save XML");
XmlRpcResponse response = new XmlRpcResponse();
@ -2220,7 +2190,6 @@ namespace OpenSim.ApplicationPlugins.RemoteController
{
m_log.Info("[RADMIN]: Received Query XML Administrator Request");
//AnakinLohner 0.6.5-post-fixes
FailIfRemoteAdminDisabled("Query XML");
XmlRpcResponse response = new XmlRpcResponse();
@ -2255,9 +2224,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
else throw new Exception("neither region_name nor region_uuid given");
Scene s = m_app.SceneManager.CurrentScene;
int health = s.GetHealth();
responseData["health"] = health;
response.Value = responseData;
@ -2280,7 +2247,6 @@ namespace OpenSim.ApplicationPlugins.RemoteController
{
m_log.Info("[RADMIN]: Received Command XML Administrator Request");
//AnakinLohner 0.6.5-post-fixes
FailIfRemoteAdminDisabled("Command XML");
XmlRpcResponse response = new XmlRpcResponse();
@ -2320,10 +2286,8 @@ namespace OpenSim.ApplicationPlugins.RemoteController
public XmlRpcResponse XmlRpcAccessListClear(XmlRpcRequest request, IPEndPoint remoteClient)
{
m_log.Info("[RADMIN]: Received Access List Clear Request");
//AnakinLohner 0.6.5-post-fixes
FailIfRemoteAdminDisabled("Access List Clear");
XmlRpcResponse response = new XmlRpcResponse();
@ -2360,7 +2324,6 @@ namespace OpenSim.ApplicationPlugins.RemoteController
s.RegionInfo.EstateSettings.EstateAccess = new UUID[]{};
if (s.RegionInfo.Persistent)
s.RegionInfo.EstateSettings.Save();
}
catch (Exception e)
{
@ -2368,7 +2331,6 @@ namespace OpenSim.ApplicationPlugins.RemoteController
responseData["success"] = false;
responseData["error"] = e.Message;
}
finally
{
@ -2381,10 +2343,8 @@ namespace OpenSim.ApplicationPlugins.RemoteController
public XmlRpcResponse XmlRpcAccessListAdd(XmlRpcRequest request, IPEndPoint remoteClient)
{
m_log.Info("[RADMIN]: Received Access List Add Request");
//AnakinLohner 0.6.5-post-fixes
FailIfRemoteAdminDisabled("Access List Add");
XmlRpcResponse response = new XmlRpcResponse();
@ -2419,7 +2379,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
int addk = 0;
if (requestData.Contains("users"))
if (requestData.Contains("users"))
{
UserProfileCacheService ups = m_app.CommunicationsManager.UserProfileCacheService;
Scene s = m_app.SceneManager.CurrentScene;
@ -2450,7 +2410,6 @@ namespace OpenSim.ApplicationPlugins.RemoteController
}
responseData["added"] = addk;
}
catch (Exception e)
{
@ -2458,7 +2417,6 @@ namespace OpenSim.ApplicationPlugins.RemoteController
responseData["success"] = false;
responseData["error"] = e.Message;
}
finally
{
@ -2471,10 +2429,8 @@ namespace OpenSim.ApplicationPlugins.RemoteController
public XmlRpcResponse XmlRpcAccessListRemove(XmlRpcRequest request, IPEndPoint remoteClient)
{
m_log.Info("[RADMIN]: Received Access List Remove Request");
//AnakinLohner 0.6.5-post-fixes
FailIfRemoteAdminDisabled("Access List Remove");
XmlRpcResponse response = new XmlRpcResponse();
@ -2509,7 +2465,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
int remk = 0;
if (requestData.Contains("users"))
if (requestData.Contains("users"))
{
UserProfileCacheService ups = m_app.CommunicationsManager.UserProfileCacheService;
Scene s = m_app.SceneManager.CurrentScene;
@ -2539,7 +2495,6 @@ namespace OpenSim.ApplicationPlugins.RemoteController
}
responseData["removed"] = remk;
}
catch (Exception e)
{
@ -2547,7 +2502,6 @@ namespace OpenSim.ApplicationPlugins.RemoteController
responseData["success"] = false;
responseData["error"] = e.Message;
}
finally
{
@ -2560,10 +2514,8 @@ namespace OpenSim.ApplicationPlugins.RemoteController
public XmlRpcResponse XmlRpcAccessListList(XmlRpcRequest request, IPEndPoint remoteClient)
{
m_log.Info("[RADMIN]: Received Access List List Request");
//AnakinLohner 0.6.5-post-fixes
FailIfRemoteAdminDisabled("Access List List");
XmlRpcResponse response = new XmlRpcResponse();
@ -2610,7 +2562,6 @@ namespace OpenSim.ApplicationPlugins.RemoteController
}
responseData["users"] = users;
}
catch (Exception e)
{
@ -2618,7 +2569,6 @@ namespace OpenSim.ApplicationPlugins.RemoteController
responseData["success"] = false;
responseData["error"] = e.Message;
}
finally
{
@ -2695,12 +2645,10 @@ namespace OpenSim.ApplicationPlugins.RemoteController
public void Dispose()
{
}
}
class UICallback
{
private Object uilock = new Object();
internal InventoryFolderImpl root = null;
internal List<InventoryFolderImpl> folders;
@ -2720,7 +2668,6 @@ namespace OpenSim.ApplicationPlugins.RemoteController
public void GetInventory()
{
Dictionary<UUID, InventoryFolderImpl> fmap = new Dictionary<UUID, InventoryFolderImpl>();
if (OK == false)
@ -2774,8 +2721,6 @@ namespace OpenSim.ApplicationPlugins.RemoteController
{
fmap[item.Folder].Items.Add(item.ID, item);
}
}
}
}

View File

@ -207,7 +207,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
// This plugin will only be enabled if the broader
// REST plugin mechanism is enabled.
Rest.Log.InfoFormat("{0} Plugin is initializing", MsgId);
//Rest.Log.InfoFormat("{0} Plugin is initializing", MsgId);
base.Initialise(openSim);
@ -216,7 +216,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
if (!IsEnabled)
{
Rest.Log.WarnFormat("{0} Plugins are disabled", MsgId);
//Rest.Log.WarnFormat("{0} Plugins are disabled", MsgId);
return;
}

View File

@ -68,9 +68,10 @@ namespace OpenSim.ApplicationPlugins.Rest.Regions
base.Initialise(openSim);
if (!IsEnabled)
{
m_log.WarnFormat("{0} Rest Plugins are disabled", MsgID);
//m_log.WarnFormat("{0} Rest Plugins are disabled", MsgID);
return;
}
m_log.InfoFormat("{0} REST region plugin enabled", MsgID);
// add REST method handlers

View File

@ -216,7 +216,7 @@ namespace OpenSim.ApplicationPlugins.Rest
if (!_config.GetBoolean("enabled", false))
{
m_log.WarnFormat("{0} Rest Plugins are disabled", MsgID);
//m_log.WarnFormat("{0} Rest Plugins are disabled", MsgID);
return;
}

View File

@ -58,7 +58,7 @@ namespace OpenSim.Client.Linden
{
if (m_firstScene != null)
{
return m_firstScene.CommsManager.GridService.RegionLoginsEnabled;
return m_firstScene.SceneGridService.RegionLoginsEnabled;
}
else
{

View File

@ -62,7 +62,7 @@ namespace OpenSim.Client.Linden
{
if (m_firstScene != null)
{
return m_firstScene.CommsManager.GridService.RegionLoginsEnabled;
return m_firstScene.SceneGridService.RegionLoginsEnabled;
}
else
{

View File

@ -39,6 +39,8 @@ namespace OpenSim.Data
public string RegionName;
public int posX;
public int posY;
public int sizeX;
public int sizeY;
public Dictionary<string, object> Data;
}
@ -57,5 +59,6 @@ namespace OpenSim.Data
bool SetDataItem(UUID principalID, string item, string value);
bool Delete(UUID regionID);
}
}

View File

@ -135,7 +135,7 @@ namespace OpenSim.Data.MSSQL
insertBuilder.AppendFormat("insert into '{0}' ('UUID', '", m_Realm);
insertBuilder.Append(String.Join("', '", fields));
insertBuilder.Append("') values ( @principalID, @");
insertBuilder.Append("') values (@principalID, @");
insertBuilder.Append(String.Join(", @", fields));
insertBuilder.Append(")");

View File

@ -152,7 +152,7 @@ namespace OpenSim.Data.MSSQL
StringBuilder insertBuilder = new StringBuilder();
insertBuilder.AppendFormat("insert into '{0}' ('UUID', 'ScopeID', '", m_Realm);
insertBuilder.Append(String.Join("', '", fields));
insertBuilder.Append("') values ( @principalID, @scopeID, @");
insertBuilder.Append("') values (@principalID, @scopeID, @");
insertBuilder.Append(String.Join(", @", fields));
insertBuilder.Append(")");

View File

@ -127,7 +127,7 @@ namespace OpenSim.Data.MySQL
{
string insert = "insert into `" + m_Realm + "` (`UUID`, `" +
String.Join("`, `", fields) +
"`) values ( ?principalID, ?" + String.Join(", ?", fields) + ")";
"`) values (?principalID, ?" + String.Join(", ?", fields) + ")";
cmd.CommandText = insert;

View File

@ -773,7 +773,7 @@ namespace OpenSim.Data.MySQL
"use_estate_sun, fixed_sun, sun_position, " +
"covenant, Sandbox, sunvectorx, sunvectory, " +
"sunvectorz, loaded_creation_datetime, " +
"loaded_creation_id) values ( ?RegionUUID, ?BlockTerraform, " +
"loaded_creation_id) values (?RegionUUID, ?BlockTerraform, " +
"?BlockFly, ?AllowDamage, ?RestrictPushing, " +
"?AllowLandResell, ?AllowLandJoinDivide, " +
"?BlockShowInSearch, ?AgentLimit, ?ObjectBonus, " +

View File

@ -39,7 +39,7 @@ namespace OpenSim.Data.MySQL
{
private string m_Realm;
private List<string> m_ColumnNames = null;
private int m_LastExpire = 0;
// private int m_LastExpire = 0;
public MySqlRegionData(string connectionString, string realm)
: base(connectionString)
@ -77,7 +77,7 @@ namespace OpenSim.Data.MySQL
cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString());
List<RegionData> ret = RunCommand(cmd);
if (ret == null)
if (ret.Count == 0)
return null;
return ret[0];
@ -95,7 +95,7 @@ namespace OpenSim.Data.MySQL
cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString());
List<RegionData> ret = RunCommand(cmd);
if (ret == null)
if (ret.Count == 0)
return null;
return ret[0];
@ -138,6 +138,8 @@ namespace OpenSim.Data.MySQL
ret.RegionName = result["regionName"].ToString();
ret.posX = Convert.ToInt32(result["locX"]);
ret.posY = Convert.ToInt32(result["locY"]);
ret.sizeX = Convert.ToInt32(result["sizeX"]);
ret.sizeY = Convert.ToInt32(result["sizeY"]);
if (m_ColumnNames == null)
{
@ -170,10 +172,7 @@ namespace OpenSim.Data.MySQL
result.Close();
CloseReaderCommand(cmd);
if (retList.Count > 0)
return retList;
return null;
return retList;
}
public bool Store(RegionData data)
@ -188,21 +187,25 @@ namespace OpenSim.Data.MySQL
data.Data.Remove("posX");
if (data.Data.ContainsKey("posY"))
data.Data.Remove("posY");
if (data.Data.ContainsKey("sizeX"))
data.Data.Remove("sizeX");
if (data.Data.ContainsKey("sizeY"))
data.Data.Remove("sizeY");
if (data.Data.ContainsKey("locX"))
data.Data.Remove("locX");
if (data.Data.ContainsKey("locY"))
data.Data.Remove("locY");
string[] fields = new List<string>(data.Data.Keys).ToArray();
MySqlCommand cmd = new MySqlCommand();
string update = "update `"+m_Realm+"` set ";
bool first = true;
string update = "update `"+m_Realm+"` set locX=?posX, locY=?posY, sizeX=?sizeX, sizeY=?sizeY";
foreach (string field in fields)
{
if (!first)
update += ", ";
update += ", ";
update += "`" + field + "` = ?"+field;
first = false;
cmd.Parameters.AddWithValue("?"+field, data.Data[field]);
}
@ -213,13 +216,18 @@ namespace OpenSim.Data.MySQL
cmd.CommandText = update;
cmd.Parameters.AddWithValue("?regionID", data.RegionID.ToString());
cmd.Parameters.AddWithValue("?regionName", data.RegionName);
cmd.Parameters.AddWithValue("?scopeID", data.ScopeID.ToString());
cmd.Parameters.AddWithValue("?posX", data.posX.ToString());
cmd.Parameters.AddWithValue("?posY", data.posY.ToString());
cmd.Parameters.AddWithValue("?sizeX", data.sizeX.ToString());
cmd.Parameters.AddWithValue("?sizeY", data.sizeY.ToString());
if (ExecuteNonQuery(cmd) < 1)
{
string insert = "insert into `" + m_Realm + "` (`uuid`, `ScopeID`, `" +
string insert = "insert into `" + m_Realm + "` (`uuid`, `ScopeID`, `locX`, `locY`, `sizeX`, `sizeY`, `regionName`, `" +
String.Join("`, `", fields) +
"`) values ( ?regionID, ?scopeID, ?" + String.Join(", ?", fields) + ")";
"`) values ( ?regionID, ?scopeID, ?posX, ?posY, ?sizeX, ?sizeY, ?regionName, ?" + String.Join(", ?", fields) + ")";
cmd.CommandText = insert;

View File

@ -39,7 +39,7 @@ namespace OpenSim.Data.MySQL
{
private string m_Realm;
private List<string> m_ColumnNames = null;
private int m_LastExpire = 0;
// private int m_LastExpire = 0;
public MySqlUserAccountData(string connectionString, string realm)
: base(connectionString)
@ -146,7 +146,7 @@ namespace OpenSim.Data.MySQL
{
string insert = "insert into `" + m_Realm + "` (`UUID`, `ScopeID`, `" +
String.Join("`, `", fields) +
"`) values ( ?principalID, ?scopeID, ?" + String.Join(", ?", fields) + ")";
"`) values (?principalID, ?scopeID, ?" + String.Join(", ?", fields) + ")";
cmd.CommandText = insert;

View File

@ -0,0 +1,6 @@
BEGIN;
ALTER TABLE regions add column sizeX integer not null default 0;
ALTER TABLE regions add column sizeY integer not null default 0;
COMMIT;

View File

@ -40,13 +40,14 @@ namespace OpenSim.Data.Null
public NullRegionData(string connectionString, string realm)
{
//Console.WriteLine("[XXX] NullRegionData constructor");
}
public List<RegionData> Get(string regionName, UUID scopeID)
{
List<RegionData> ret = new List<RegionData>();
foreach(RegionData r in m_regionData.Values)
foreach (RegionData r in m_regionData.Values)
{
if (regionName.Contains("%"))
{
@ -70,7 +71,7 @@ namespace OpenSim.Data.Null
{
List<RegionData> ret = new List<RegionData>();
foreach(RegionData r in m_regionData.Values)
foreach (RegionData r in m_regionData.Values)
{
if (r.posX == posX && r.posY == posY)
ret.Add(r);
@ -94,16 +95,13 @@ namespace OpenSim.Data.Null
{
List<RegionData> ret = new List<RegionData>();
foreach(RegionData r in m_regionData.Values)
foreach (RegionData r in m_regionData.Values)
{
if (r.posX >= startX && r.posX <= endX && r.posY >= startY && r.posY <= endY)
ret.Add(r);
}
if (ret.Count > 0)
return ret;
return null;
return ret;
}
public bool Store(RegionData data)

View File

@ -124,7 +124,7 @@ namespace OpenSim.Data.SQLite
//m_log.Info("[ASSET DB]: Creating Asset " + asset.FullID.ToString());
if (ExistsAsset(asset.FullID))
{
LogAssetLoad(asset);
//LogAssetLoad(asset);
lock (this)
{
@ -173,7 +173,7 @@ namespace OpenSim.Data.SQLite
int assetLength = (asset.Data != null) ? asset.Data.Length : 0;
m_log.Info("[ASSET DB]: " +
m_log.Debug("[ASSET DB]: " +
string.Format("Loaded {5} {4} Asset: [{0}][{3}] \"{1}\":{2} ({6} bytes)",
asset.FullID, asset.Name, asset.Description, asset.Type,
temporary, local, assetLength));

View File

@ -35,6 +35,8 @@ using System.Text;
using OpenMetaverse;
using OpenMetaverse.StructuredData;
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
using log4net;
namespace OpenSim.Framework.Communications.Clients
@ -43,7 +45,7 @@ namespace OpenSim.Framework.Communications.Clients
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
public bool DoCreateChildAgentCall(RegionInfo region, AgentCircuitData aCircuit, string authKey, out string reason)
public bool DoCreateChildAgentCall(GridRegion region, AgentCircuitData aCircuit, string authKey, out string reason)
{
reason = String.Empty;
@ -166,7 +168,7 @@ namespace OpenSim.Framework.Communications.Clients
}
public bool DoChildAgentUpdateCall(RegionInfo region, IAgentData cAgentData)
public bool DoChildAgentUpdateCall(GridRegion region, IAgentData cAgentData)
{
// Eventually, we want to use a caps url instead of the agentID
string uri = string.Empty;
@ -260,7 +262,7 @@ namespace OpenSim.Framework.Communications.Clients
return true;
}
public bool DoRetrieveRootAgentCall(RegionInfo region, UUID id, out IAgentData agent)
public bool DoRetrieveRootAgentCall(GridRegion region, UUID id, out IAgentData agent)
{
agent = null;
// Eventually, we want to use a caps url instead of the agentID
@ -348,7 +350,7 @@ namespace OpenSim.Framework.Communications.Clients
}
public bool DoCloseAgentCall(RegionInfo region, UUID id)
public bool DoCloseAgentCall(GridRegion region, UUID id)
{
string uri = string.Empty;
try
@ -391,7 +393,7 @@ namespace OpenSim.Framework.Communications.Clients
return true;
}
public bool DoCreateObjectCall(RegionInfo region, ISceneObject sog, string sogXml2, bool allowScriptCrossing)
public bool DoCreateObjectCall(GridRegion region, ISceneObject sog, string sogXml2, bool allowScriptCrossing)
{
ulong regionHandle = GetRegionHandle(region.RegionHandle);
string uri
@ -474,7 +476,7 @@ namespace OpenSim.Framework.Communications.Clients
}
public bool DoCreateObjectCall(RegionInfo region, UUID userID, UUID itemID)
public bool DoCreateObjectCall(GridRegion region, UUID userID, UUID itemID)
{
ulong regionHandle = GetRegionHandle(region.RegionHandle);
string uri = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort + "/object/" + UUID.Zero + "/" + regionHandle.ToString() + "/";
@ -646,7 +648,7 @@ namespace OpenSim.Framework.Communications.Clients
return false;
}
public virtual void SendUserInformation(RegionInfo regInfo, AgentCircuitData aCircuit)
public virtual void SendUserInformation(GridRegion regInfo, AgentCircuitData aCircuit)
{
}

View File

@ -59,11 +59,6 @@ namespace OpenSim.Framework.Communications
}
protected IMessagingService m_messageService;
public IGridServices GridService
{
get { return m_gridService; }
}
protected IGridServices m_gridService;
public UserProfileCacheService UserProfileCacheService
{

View File

@ -1,92 +0,0 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* 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 OpenSimulator Project 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 THE DEVELOPERS ``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 THE CONTRIBUTORS 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.Collections.Generic;
using OpenMetaverse;
namespace OpenSim.Framework.Communications
{
public interface IGridServices
{
string gdebugRegionName { get; set; }
/// <summary>
/// If true, then regions will accept logins from the user service. If false, then they will not.
/// </summary>
bool RegionLoginsEnabled { get; set; }
/// <summary>
/// Register a region with the grid service.
/// </summary>
/// <param name="regionInfos"> </param>
/// <returns></returns>
/// <exception cref="System.Exception">Thrown if region registration failed</exception>
RegionCommsListener RegisterRegion(RegionInfo regionInfos);
/// <summary>
/// Deregister a region with the grid service.
/// </summary>
/// <param name="regionInfo"></param>
/// <returns></returns>
/// <exception cref="System.Exception">Thrown if region deregistration failed</exception>
bool DeregisterRegion(RegionInfo regionInfo);
/// <summary>
/// Get information about the regions neighbouring the given co-ordinates.
/// </summary>
/// <param name="x"></param>
/// <param name="y"></param>
/// <returns></returns>
List<SimpleRegionInfo> RequestNeighbours(uint x, uint y);
RegionInfo RequestNeighbourInfo(ulong regionHandle);
RegionInfo RequestNeighbourInfo(UUID regionID);
RegionInfo RequestNeighbourInfo(string name);
RegionInfo RequestNeighbourInfo(string host, uint port);
RegionInfo RequestClosestRegion(string regionName);
Dictionary<string, string> GetGridSettings();
List<MapBlockData> RequestNeighbourMapBlocks(int minX, int minY, int maxX, int maxY);
// not complete yet, only contains the fields needed for ParcelInfoReqeust
LandData RequestLandData(ulong regionHandle, uint x, uint y);
/// <summary>
/// Get information about regions starting with the provided name.
/// </summary>
/// <param name="name">
/// The name to match against.
/// </param>
/// <param name="maxNumber">
/// The maximum number of results to return.
/// </param>
/// <returns>
/// A list of <see cref="RegionInfo"/>s of regions with matching name. If the
/// grid-server couldn't be contacted or returned an error, return null.
/// </returns>
List<RegionInfo> RequestNamedRegions(string name, int maxNumber);
}
}

View File

@ -137,9 +137,21 @@ namespace OpenSim.Framework.Communications
// But since Scenes only have IUserService references, I'm placing it here for now.
bool VerifySession(UUID userID, UUID sessionID);
/// <summary>
/// Authenticate a user by their password.
/// </summary>
///
/// This is used by callers outside the login process that want to
/// verify a user who has given their password.
///
/// This should probably also be in IAuthentication but is here for the same reasons as VerifySession() is
///
/// <param name="userID"></param>
/// <param name="password"></param>
/// <returns></returns>
bool AuthenticateUserByPassword(UUID userID, string password);
// Temporary Hack until we move everything to the new service model
void SetInventoryService(IInventoryService invService);
}
}

View File

@ -1221,11 +1221,13 @@ namespace OpenSim.Framework.Communications.Services
{
return Util.CreateUnknownUserErrorResponse();
}
UUID.TryParse((string)requestData["session_id"], out guess_sid);
if (guess_sid == UUID.Zero)
{
return Util.CreateUnknownUserErrorResponse();
}
if (m_userManager.VerifySession(guess_aid, guess_sid))
{
authed = "TRUE";
@ -1243,6 +1245,5 @@ namespace OpenSim.Framework.Communications.Services
response.Value = responseData;
return response;
}
}
}

View File

@ -149,6 +149,11 @@ namespace OpenSim.Framework.Communications.Tests
{
throw new NotImplementedException();
}
public virtual bool AuthenticateUserByPassword(UUID userID, string password)
{
throw new NotImplementedException();
}
}
}
}

View File

@ -44,7 +44,8 @@ namespace OpenSim.Framework.Communications
/// <summary>
/// Base class for user management (create, read, etc)
/// </summary>
public abstract class UserManagerBase : IUserService, IUserAdminService, IAvatarService, IMessagingService, IAuthentication
public abstract class UserManagerBase
: IUserService, IUserAdminService, IAvatarService, IMessagingService, IAuthentication
{
private static readonly ILog m_log
= LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
@ -649,15 +650,17 @@ namespace OpenSim.Framework.Communications
public virtual UUID AddUser(
string firstName, string lastName, string password, string email, uint regX, uint regY, UUID SetUUID)
{
string md5PasswdHash = Util.Md5Hash(Util.Md5Hash(password) + ":" + String.Empty);
UserProfileData user = new UserProfileData();
user.PasswordSalt = Util.Md5Hash(UUID.Random().ToString());
string md5PasswdHash = Util.Md5Hash(Util.Md5Hash(password) + ":" + user.PasswordSalt);
user.HomeLocation = new Vector3(128, 128, 100);
user.ID = SetUUID;
user.FirstName = firstName;
user.SurName = lastName;
user.PasswordHash = md5PasswdHash;
user.PasswordSalt = String.Empty;
user.Created = Util.UnixTimeSinceEpoch();
user.HomeLookAt = new Vector3(100, 100, 100);
user.HomeRegionX = regX;
@ -891,7 +894,10 @@ namespace OpenSim.Framework.Communications
if (userProfile != null && userProfile.CurrentAgent != null)
{
m_log.DebugFormat("[USER AUTH]: Verifying session {0} for {1}; current session {2}", sessionID, userID, userProfile.CurrentAgent.SessionID);
m_log.DebugFormat(
"[USER AUTH]: Verifying session {0} for {1}; current session {2}",
sessionID, userID, userProfile.CurrentAgent.SessionID);
if (userProfile.CurrentAgent.SessionID == sessionID)
{
return true;
@ -901,6 +907,26 @@ namespace OpenSim.Framework.Communications
return false;
}
public virtual bool AuthenticateUserByPassword(UUID userID, string password)
{
// m_log.DebugFormat("[USER AUTH]: Authenticating user {0} given password {1}", userID, password);
UserProfileData userProfile = GetUserProfile(userID);
if (null == userProfile)
return false;
string md5PasswordHash = Util.Md5Hash(Util.Md5Hash(password) + ":" + userProfile.PasswordSalt);
// m_log.DebugFormat(
// "[USER AUTH]: Submitted hash {0}, stored hash {1}", md5PasswordHash, userProfile.PasswordHash);
if (md5PasswordHash == userProfile.PasswordHash)
return true;
else
return false;
}
#endregion
}
}

View File

@ -197,8 +197,8 @@ namespace OpenSim.Framework.Console
string uri = "/ReadResponses/" + sessionID.ToString() + "/";
m_Server.AddPollServiceHTTPHandler(uri, HandleHttpCloseSession,
new PollServiceEventArgs(HasEvents, GetEvents, NoEvents,
m_Server.AddPollServiceHTTPHandler(uri, HandleHttpPoll,
new PollServiceEventArgs(null, HasEvents, GetEvents, NoEvents,
sessionID));
XmlDocument xmldoc = new XmlDocument();
@ -230,6 +230,11 @@ namespace OpenSim.Framework.Console
return reply;
}
private Hashtable HandleHttpPoll(Hashtable request)
{
return new Hashtable();
}
private Hashtable HandleHttpCloseSession(Hashtable request)
{
DoExpire();
@ -365,7 +370,7 @@ namespace OpenSim.Framework.Console
}
}
private bool HasEvents(UUID sessionID)
private bool HasEvents(UUID RequestID, UUID sessionID)
{
ConsoleConnection c = null;
@ -381,19 +386,19 @@ namespace OpenSim.Framework.Console
return false;
}
private Hashtable GetEvents(UUID sessionID, string request)
private Hashtable GetEvents(UUID RequestID, UUID sessionID, string request)
{
ConsoleConnection c = null;
lock (m_Connections)
{
if (!m_Connections.ContainsKey(sessionID))
return NoEvents();
return NoEvents(RequestID, UUID.Zero);
c = m_Connections[sessionID];
}
c.last = System.Environment.TickCount;
if (c.lastLineSeen >= m_LineNumber)
return NoEvents();
return NoEvents(RequestID, UUID.Zero);
Hashtable result = new Hashtable();
@ -435,7 +440,7 @@ namespace OpenSim.Framework.Console
return result;
}
private Hashtable NoEvents()
private Hashtable NoEvents(UUID RequestID, UUID id)
{
Hashtable result = new Hashtable();

View File

@ -46,8 +46,6 @@ namespace OpenSim.Framework
public delegate bool CloseAgentConnection(UUID agentID);
public delegate bool RegionUp(RegionInfo region);
public delegate bool ChildAgentUpdate(ChildAgentDataUpdate cAgentData);
public delegate void LogOffUser(UUID agentID, UUID regionSecret, string message);
@ -65,7 +63,6 @@ namespace OpenSim.Framework
event AcknowledgePrimCross OnAcknowledgePrimCrossed;
event UpdateNeighbours OnNeighboursUpdate;
event CloseAgentConnection OnCloseAgentConnection;
event RegionUp OnRegionUp;
event ChildAgentUpdate OnChildAgentUpdate;
event LogOffUser OnLogOffUser;
event GetLandData OnGetLandData;

View File

@ -74,7 +74,7 @@ namespace OpenSim.Framework
void CloseAllAgents(uint circuitcode);
void Restart(int seconds);
bool OtherRegionUp(RegionInfo thisRegion);
//RegionInfo OtherRegionUp(RegionInfo thisRegion);
string GetSimulatorVersion();

View File

@ -102,8 +102,7 @@ namespace OpenSim.Framework
ConfigSettings.DefaultInventoryServerHttpPort.ToString());
secureInventoryServer = config.Configs["Network"].GetBoolean("secure_inventory_server", true);
MessagingURL = config.Configs["Network"].GetString("messaging_server_url",
"http://127.0.0.1:" + ConfigSettings.DefaultMessageServerHttpPort);
MessagingURL = config.Configs["Network"].GetString("messaging_server_url", string.Empty);
}
}
}

View File

@ -47,7 +47,6 @@ namespace OpenSim.Framework
private ExpectUserDelegate handlerExpectUser = null; // OnExpectUser
private UpdateNeighbours handlerNeighboursUpdate = null; // OnNeighboursUpdate;
private PrimCrossing handlerPrimCrossingIntoRegion = null; // OnPrimCrossingIntoRegion;
private RegionUp handlerRegionUp = null; // OnRegionUp;
private LogOffUser handlerLogOffUser = null;
private GetLandData handlerGetLandData = null;
@ -62,7 +61,6 @@ namespace OpenSim.Framework
public event AcknowledgeAgentCross OnAcknowledgeAgentCrossed;
public event AcknowledgePrimCross OnAcknowledgePrimCrossed;
public event CloseAgentConnection OnCloseAgentConnection;
public event RegionUp OnRegionUp;
public event ChildAgentUpdate OnChildAgentUpdate;
public event LogOffUser OnLogOffUser;
public event GetLandData OnGetLandData;
@ -108,17 +106,6 @@ namespace OpenSim.Framework
return false;
}
public virtual bool TriggerRegionUp(RegionInfo region)
{
handlerRegionUp = OnRegionUp;
if (handlerRegionUp != null)
{
handlerRegionUp(region);
return true;
}
return false;
}
public virtual bool TriggerChildAgentUpdate(ChildAgentDataUpdate cAgentData)
{
handlerChildAgentUpdate = OnChildAgentUpdate;

View File

@ -26,6 +26,7 @@
*/
using System;
using System.Collections.Generic;
using System.Net;
using System.Net.Sockets;
using System.Xml;
@ -63,6 +64,13 @@ namespace OpenSim.Framework
}
protected string m_serverURI;
public string RegionName
{
get { return m_regionName; }
set { m_regionName = value; }
}
protected string m_regionName = String.Empty;
protected bool Allow_Alternate_Ports;
public bool m_allow_alternate_ports;
protected string m_externalHostName;
@ -100,6 +108,7 @@ namespace OpenSim.Framework
public SimpleRegionInfo(RegionInfo ConvertFrom)
{
m_regionName = ConvertFrom.RegionName;
m_regionLocX = ConvertFrom.RegionLocX;
m_regionLocY = ConvertFrom.RegionLocY;
m_internalEndPoint = ConvertFrom.InternalEndPoint;
@ -197,6 +206,67 @@ namespace OpenSim.Framework
{
return m_internalEndPoint.Port;
}
public Dictionary<string, object> ToKeyValuePairs()
{
Dictionary<string, object> kvp = new Dictionary<string, object>();
kvp["uuid"] = RegionID.ToString();
kvp["locX"] = RegionLocX.ToString();
kvp["locY"] = RegionLocY.ToString();
kvp["external_ip_address"] = ExternalEndPoint.Address.ToString();
kvp["external_port"] = ExternalEndPoint.Port.ToString();
kvp["external_host_name"] = ExternalHostName;
kvp["http_port"] = HttpPort.ToString();
kvp["internal_ip_address"] = InternalEndPoint.Address.ToString();
kvp["internal_port"] = InternalEndPoint.Port.ToString();
kvp["alternate_ports"] = m_allow_alternate_ports.ToString();
kvp["server_uri"] = ServerURI;
return kvp;
}
public SimpleRegionInfo(Dictionary<string, object> kvp)
{
if ((kvp["external_ip_address"] != null) && (kvp["external_port"] != null))
{
int port = 0;
Int32.TryParse((string)kvp["external_port"], out port);
IPEndPoint ep = new IPEndPoint(IPAddress.Parse((string)kvp["external_ip_address"]), port);
ExternalEndPoint = ep;
}
else
ExternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), 0);
if (kvp["external_host_name"] != null)
ExternalHostName = (string)kvp["external_host_name"];
if (kvp["http_port"] != null)
{
UInt32 port = 0;
UInt32.TryParse((string)kvp["http_port"], out port);
HttpPort = port;
}
if ((kvp["internal_ip_address"] != null) && (kvp["internal_port"] != null))
{
int port = 0;
Int32.TryParse((string)kvp["internal_port"], out port);
IPEndPoint ep = new IPEndPoint(IPAddress.Parse((string)kvp["internal_ip_address"]), port);
InternalEndPoint = ep;
}
else
InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), 0);
if (kvp["alternate_ports"] != null)
{
bool alts = false;
Boolean.TryParse((string)kvp["alternate_ports"], out alts);
m_allow_alternate_ports = alts;
}
if (kvp["server_uri"] != null)
ServerURI = (string)kvp["server_uri"];
}
}
public class RegionInfo : SimpleRegionInfo
@ -222,7 +292,6 @@ namespace OpenSim.Framework
public UUID originRegionID = UUID.Zero;
public string proxyUrl = "";
public int ProxyOffset = 0;
public string RegionName = String.Empty;
public string regionSecret = UUID.Random().ToString();
public string osSecret;

View File

@ -0,0 +1,191 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* 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 OpenSimulator Project 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 THE DEVELOPERS ``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 THE CONTRIBUTORS 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.IO;
using System.Text;
using System.Xml;
using OpenMetaverse;
using OpenSim.Framework;
namespace OpenSim.Framework.Serialization.External
{
/// <summary>
/// Serialize and deserialize LandData as an external format.
/// </summary>
public class LandDataSerializer
{
protected static UTF8Encoding m_utf8Encoding = new UTF8Encoding();
/// <summary>
/// Reify/deserialize landData
/// </summary>
/// <param name="serializedLandData"></param>
/// <returns></returns>
/// <exception cref="System.Xml.XmlException"></exception>
public static LandData Deserialize(byte[] serializedLandData)
{
return Deserialize(m_utf8Encoding.GetString(serializedLandData, 0, serializedLandData.Length));
}
/// <summary>
/// Reify/deserialize landData
/// </summary>
/// <param name="serializedLandData"></param>
/// <returns></returns>
/// <exception cref="System.Xml.XmlException"></exception>
public static LandData Deserialize(string serializedLandData)
{
LandData landData = new LandData();
StringReader sr = new StringReader(serializedLandData);
XmlTextReader xtr = new XmlTextReader(sr);
xtr.ReadStartElement("LandData");
landData.Area = Convert.ToInt32( xtr.ReadElementString("Area"));
landData.AuctionID = Convert.ToUInt32( xtr.ReadElementString("AuctionID"));
landData.AuthBuyerID = UUID.Parse( xtr.ReadElementString("AuthBuyerID"));
landData.Category = (ParcelCategory)Convert.ToSByte( xtr.ReadElementString("Category"));
landData.ClaimDate = Convert.ToInt32( xtr.ReadElementString("ClaimDate"));
landData.ClaimPrice = Convert.ToInt32( xtr.ReadElementString("ClaimPrice"));
landData.GlobalID = UUID.Parse( xtr.ReadElementString("GlobalID"));
landData.GroupID = UUID.Parse( xtr.ReadElementString("GroupID"));
landData.IsGroupOwned = Convert.ToBoolean( xtr.ReadElementString("IsGroupOwned"));
landData.Bitmap = Convert.FromBase64String( xtr.ReadElementString("Bitmap"));
landData.Description = xtr.ReadElementString("Description");
landData.Flags = Convert.ToUInt32( xtr.ReadElementString("Flags"));
landData.LandingType = Convert.ToByte( xtr.ReadElementString("LandingType"));
landData.Name = xtr.ReadElementString("Name");
landData.Status = (ParcelStatus)Convert.ToSByte( xtr.ReadElementString("Status"));
landData.LocalID = Convert.ToInt32( xtr.ReadElementString("LocalID"));
landData.MediaAutoScale = Convert.ToByte( xtr.ReadElementString("MediaAutoScale"));
landData.MediaID = UUID.Parse( xtr.ReadElementString("MediaID"));
landData.MediaURL = xtr.ReadElementString("MediaURL");
landData.MusicURL = xtr.ReadElementString("MusicURL");
landData.OwnerID = UUID.Parse( xtr.ReadElementString("OwnerID"));
landData.ParcelAccessList = new List<ParcelManager.ParcelAccessEntry>();
xtr.Read();
if (xtr.Name != "ParcelAccessList")
throw new XmlException(String.Format("Expected \"ParcelAccessList\" element but got \"{0}\"", xtr.Name));
if (!xtr.IsEmptyElement)
{
while (xtr.Read() && xtr.NodeType != XmlNodeType.EndElement)
{
ParcelManager.ParcelAccessEntry pae = new ParcelManager.ParcelAccessEntry();
xtr.ReadStartElement("ParcelAccessEntry");
pae.AgentID = UUID.Parse( xtr.ReadElementString("AgentID"));
pae.Time = Convert.ToDateTime( xtr.ReadElementString("Time"));
pae.Flags = (AccessList)Convert.ToUInt32( xtr.ReadElementString("AccessList"));
xtr.ReadEndElement();
landData.ParcelAccessList.Add(pae);
}
}
xtr.Read();
landData.PassHours = Convert.ToSingle( xtr.ReadElementString("PassHours"));
landData.PassPrice = Convert.ToInt32( xtr.ReadElementString("PassPrice"));
landData.SalePrice = Convert.ToInt32( xtr.ReadElementString("SalePrice"));
landData.SnapshotID = UUID.Parse( xtr.ReadElementString("SnapshotID"));
landData.UserLocation = Vector3.Parse( xtr.ReadElementString("UserLocation"));
landData.UserLookAt = Vector3.Parse( xtr.ReadElementString("UserLookAt"));
landData.Dwell = Convert.ToInt32( xtr.ReadElementString("Dwell"));
landData.OtherCleanTime = Convert.ToInt32( xtr.ReadElementString("OtherCleanTime"));
xtr.ReadEndElement();
xtr.Close();
sr.Close();
return landData;
}
public static string Serialize(LandData landData)
{
StringWriter sw = new StringWriter();
XmlTextWriter xtw = new XmlTextWriter(sw);
xtw.Formatting = Formatting.Indented;
xtw.WriteStartDocument();
xtw.WriteStartElement("LandData");
xtw.WriteElementString("Area", Convert.ToString(landData.Area));
xtw.WriteElementString("AuctionID", Convert.ToString(landData.AuctionID));
xtw.WriteElementString("AuthBuyerID", landData.AuthBuyerID.ToString());
xtw.WriteElementString("Category", Convert.ToString((sbyte)landData.Category));
xtw.WriteElementString("ClaimDate", Convert.ToString(landData.ClaimDate));
xtw.WriteElementString("ClaimPrice", Convert.ToString(landData.ClaimPrice));
xtw.WriteElementString("GlobalID", landData.GlobalID.ToString());
xtw.WriteElementString("GroupID", landData.GroupID.ToString());
xtw.WriteElementString("IsGroupOwned", Convert.ToString(landData.IsGroupOwned));
xtw.WriteElementString("Bitmap", Convert.ToBase64String(landData.Bitmap));
xtw.WriteElementString("Description", landData.Description);
xtw.WriteElementString("Flags", Convert.ToString((uint)landData.Flags));
xtw.WriteElementString("LandingType", Convert.ToString((byte)landData.LandingType));
xtw.WriteElementString("Name", landData.Name);
xtw.WriteElementString("Status", Convert.ToString((sbyte)landData.Status));
xtw.WriteElementString("LocalID", landData.LocalID.ToString());
xtw.WriteElementString("MediaAutoScale", Convert.ToString(landData.MediaAutoScale));
xtw.WriteElementString("MediaID", landData.MediaID.ToString());
xtw.WriteElementString("MediaURL", landData.MediaURL);
xtw.WriteElementString("MusicURL", landData.MusicURL);
xtw.WriteElementString("OwnerID", landData.OwnerID.ToString());
xtw.WriteStartElement("ParcelAccessList");
foreach (ParcelManager.ParcelAccessEntry pal in landData.ParcelAccessList)
{
xtw.WriteStartElement("ParcelAccessEntry");
xtw.WriteElementString("AgentID", pal.AgentID.ToString());
xtw.WriteElementString("Time", pal.Time.ToString("s"));
xtw.WriteElementString("AccessList", Convert.ToString((uint)pal.Flags));
xtw.WriteEndElement();
}
xtw.WriteEndElement();
xtw.WriteElementString("PassHours", Convert.ToString(landData.PassHours));
xtw.WriteElementString("PassPrice", Convert.ToString(landData.PassPrice));
xtw.WriteElementString("SalePrice", Convert.ToString(landData.SalePrice));
xtw.WriteElementString("SnapshotID", landData.SnapshotID.ToString());
xtw.WriteElementString("UserLocation", landData.UserLocation.ToString());
xtw.WriteElementString("UserLookAt", landData.UserLookAt.ToString());
xtw.WriteElementString("Dwell", Convert.ToString(landData.Dwell));
xtw.WriteElementString("OtherCleanTime", Convert.ToString(landData.OtherCleanTime));
xtw.WriteEndElement();
xtw.Close();
sw.Close();
return sw.ToString();
}
}
}

View File

@ -0,0 +1,131 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* 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 OpenSimulator Project 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 THE DEVELOPERS ``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 THE CONTRIBUTORS 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 OpenSim.Framework;
using OpenSim.Framework.Serialization.External;
using OpenMetaverse;
using OpenMetaverse.StructuredData;
using NUnit.Framework;
namespace OpenSim.Framework.Serialization.Tests
{
[TestFixture]
public class LandDataSerializerTest
{
private LandData land;
private LandData landWithParcelAccessList;
private static string preSerialized = "<?xml version=\"1.0\" encoding=\"utf-16\"?>\n<LandData>\n <Area>128</Area>\n <AuctionID>0</AuctionID>\n <AuthBuyerID>00000000-0000-0000-0000-000000000000</AuthBuyerID>\n <Category>10</Category>\n <ClaimDate>0</ClaimDate>\n <ClaimPrice>0</ClaimPrice>\n <GlobalID>54ff9641-dd40-4a2c-b1f1-47dd3af24e50</GlobalID>\n <GroupID>d740204e-bbbf-44aa-949d-02c7d739f6a5</GroupID>\n <IsGroupOwned>False</IsGroupOwned>\n <Bitmap>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</Bitmap>\n <Description>land data to test LandDataSerializer</Description>\n <Flags>536870944</Flags>\n <LandingType>2</LandingType>\n <Name>LandDataSerializerTest Land</Name>\n <Status>0</Status>\n <LocalID>0</LocalID>\n <MediaAutoScale>1</MediaAutoScale>\n <MediaID>d4452578-2f25-4b97-a81b-819af559cfd7</MediaID>\n <MediaURL>http://videos.opensimulator.org/bumblebee.mp4</MediaURL>\n <MusicURL />\n <OwnerID>1b8eedf9-6d15-448b-8015-24286f1756bf</OwnerID>\n <ParcelAccessList />\n <PassHours>0</PassHours>\n <PassPrice>0</PassPrice>\n <SalePrice>0</SalePrice>\n <SnapshotID>00000000-0000-0000-0000-000000000000</SnapshotID>\n <UserLocation>&lt;0, 0, 0&gt;</UserLocation>\n <UserLookAt>&lt;0, 0, 0&gt;</UserLookAt>\n <Dwell>0</Dwell>\n <OtherCleanTime>0</OtherCleanTime>\n</LandData>";
private static string preSerializedWithParcelAccessList = "<?xml version=\"1.0\" encoding=\"utf-16\"?>\n<LandData>\n <Area>128</Area>\n <AuctionID>0</AuctionID>\n <AuthBuyerID>00000000-0000-0000-0000-000000000000</AuthBuyerID>\n <Category>10</Category>\n <ClaimDate>0</ClaimDate>\n <ClaimPrice>0</ClaimPrice>\n <GlobalID>54ff9641-dd40-4a2c-b1f1-47dd3af24e50</GlobalID>\n <GroupID>d740204e-bbbf-44aa-949d-02c7d739f6a5</GroupID>\n <IsGroupOwned>False</IsGroupOwned>\n <Bitmap>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</Bitmap>\n <Description>land data to test LandDataSerializer</Description>\n <Flags>536870944</Flags>\n <LandingType>2</LandingType>\n <Name>LandDataSerializerTest Land</Name>\n <Status>0</Status>\n <LocalID>0</LocalID>\n <MediaAutoScale>1</MediaAutoScale>\n <MediaID>d4452578-2f25-4b97-a81b-819af559cfd7</MediaID>\n <MediaURL>http://videos.opensimulator.org/bumblebee.mp4</MediaURL>\n <MusicURL />\n <OwnerID>1b8eedf9-6d15-448b-8015-24286f1756bf</OwnerID>\n <ParcelAccessList>\n <ParcelAccessEntry>\n <AgentID>62d65d45-c91a-4f77-862c-46557d978b6c</AgentID>\n <Time>2009-10-01T00:00:00</Time>\n <AccessList>2</AccessList>\n </ParcelAccessEntry>\n <ParcelAccessEntry>\n <AgentID>ec2a8d18-2378-4fe0-8b68-2a31b57c481e</AgentID>\n <Time>2010-10-20T00:00:00</Time>\n <AccessList>1</AccessList>\n </ParcelAccessEntry>\n </ParcelAccessList>\n <PassHours>0</PassHours>\n <PassPrice>0</PassPrice>\n <SalePrice>0</SalePrice>\n <SnapshotID>00000000-0000-0000-0000-000000000000</SnapshotID>\n <UserLocation>&lt;0, 0, 0&gt;</UserLocation>\n <UserLookAt>&lt;0, 0, 0&gt;</UserLookAt>\n <Dwell>0</Dwell>\n <OtherCleanTime>0</OtherCleanTime>\n</LandData>";
[SetUp]
public void setup()
{
// setup LandData object
this.land = new LandData();
this.land.AABBMax = new Vector3(0, 0, 0);
this.land.AABBMin = new Vector3(128, 128, 128);
this.land.Area = 128;
this.land.AuctionID = 0;
this.land.AuthBuyerID = new UUID();
this.land.Category = ParcelCategory.Residential;
this.land.ClaimDate = 0;
this.land.ClaimPrice = 0;
this.land.GlobalID = new UUID("54ff9641-dd40-4a2c-b1f1-47dd3af24e50");
this.land.GroupID = new UUID("d740204e-bbbf-44aa-949d-02c7d739f6a5");
this.land.GroupPrims = 0;
this.land.Description = "land data to test LandDataSerializer";
this.land.Flags = (uint)(ParcelFlags.AllowDamage | ParcelFlags.AllowVoiceChat);
this.land.LandingType = (byte)LandingType.Direct;
this.land.Name = "LandDataSerializerTest Land";
this.land.Status = ParcelStatus.Leased;
this.land.LocalID = 0;
this.land.MediaAutoScale = (byte)0x01;
this.land.MediaID = new UUID("d4452578-2f25-4b97-a81b-819af559cfd7");
this.land.MediaURL = "http://videos.opensimulator.org/bumblebee.mp4";
this.land.OwnerID = new UUID("1b8eedf9-6d15-448b-8015-24286f1756bf");
this.landWithParcelAccessList = this.land.Copy();
this.landWithParcelAccessList.ParcelAccessList.Clear();
ParcelManager.ParcelAccessEntry pae0 = new ParcelManager.ParcelAccessEntry();
pae0.AgentID = new UUID("62d65d45-c91a-4f77-862c-46557d978b6c");
pae0.Flags = AccessList.Ban;
pae0.Time = new DateTime(2009, 10, 01);
this.landWithParcelAccessList.ParcelAccessList.Add(pae0);
ParcelManager.ParcelAccessEntry pae1 = new ParcelManager.ParcelAccessEntry();
pae1.AgentID = new UUID("ec2a8d18-2378-4fe0-8b68-2a31b57c481e");
pae1.Flags = AccessList.Access;
pae1.Time = new DateTime(2010, 10, 20);
this.landWithParcelAccessList.ParcelAccessList.Add(pae1);
}
/// <summary>
/// Test the LandDataSerializer.Serialize() method
/// </summary>
[Test]
public void LandDataSerializerSerializeTest()
{
string serialized = LandDataSerializer.Serialize(this.land);
Assert.That(serialized.Length > 0, "Serialize(LandData) returned empty string");
Assert.That(serialized == LandDataSerializerTest.preSerialized,
"result of Serialize(LandData) does not match expected result");
string serializedWithParcelAccessList = LandDataSerializer.Serialize(this.landWithParcelAccessList);
Assert.That(serializedWithParcelAccessList.Length > 0,
"Serialize(LandData) returned empty string for LandData object with ParcelAccessList");
Assert.That(serializedWithParcelAccessList == LandDataSerializerTest.preSerializedWithParcelAccessList,
"result of Serialize(LandData) does not match expected result (pre-serialized with parcel access list");
}
/// <summary>
/// Test the LandDataSerializer.Deserialize() method
/// </summary>
[Test]
public void TestLandDataSerializerDeserializeFromStringTest()
{
LandData reifiedLandData = LandDataSerializer.Deserialize(LandDataSerializerTest.preSerialized);
Assert.That(reifiedLandData != null, "Deserialize(string) returned null");
Assert.That(reifiedLandData.GlobalID == this.land.GlobalID, "Reified LandData.GlobalID != original LandData.GlobalID");
Assert.That(reifiedLandData.Name == this.land.Name, "Reified LandData.Name != original LandData.Name");
LandData reifiedLandDataWithParcelAccessList = LandDataSerializer.Deserialize(LandDataSerializerTest.preSerializedWithParcelAccessList);
Assert.That(reifiedLandDataWithParcelAccessList != null,
"Deserialize(string) returned null (pre-serialized with parcel access list)");
Assert.That(reifiedLandDataWithParcelAccessList.GlobalID == this.landWithParcelAccessList.GlobalID,
"Reified LandData.GlobalID != original LandData.GlobalID (pre-serialized with parcel access list)");
Assert.That(reifiedLandDataWithParcelAccessList.Name == this.landWithParcelAccessList.Name,
"Reified LandData.Name != original LandData.Name (pre-serialized with parcel access list)");
}
}
}

View File

@ -256,13 +256,51 @@ namespace OpenSim.Framework.Servers.HttpServer
IHttpClientContext context = (IHttpClientContext)source;
IHttpRequest request = args.Request;
PollServiceEventArgs psEvArgs;
if (TryGetPollServiceHTTPHandler(request.UriPath.ToString(), out psEvArgs))
{
PollServiceHttpRequest psreq = new PollServiceHttpRequest(psEvArgs, context, request);
m_PollServiceManager.Enqueue(new PollServiceHttpRequest(psEvArgs, context, request));
//DoHTTPGruntWork(psEvArgs.NoEvents(),new OSHttpResponse(new HttpResponse(context, request)));
if (psEvArgs.Request != null)
{
OSHttpRequest req = new OSHttpRequest(context, request);
Stream requestStream = req.InputStream;
Encoding encoding = Encoding.UTF8;
StreamReader reader = new StreamReader(requestStream, encoding);
string requestBody = reader.ReadToEnd();
Hashtable keysvals = new Hashtable();
Hashtable headervals = new Hashtable();
string[] querystringkeys = req.QueryString.AllKeys;
string[] rHeaders = req.Headers.AllKeys;
keysvals.Add("body", requestBody);
keysvals.Add("uri", req.RawUrl);
keysvals.Add("content-type", req.ContentType);
keysvals.Add("http-method", req.HttpMethod);
foreach (string queryname in querystringkeys)
{
keysvals.Add(queryname, req.QueryString[queryname]);
}
foreach (string headername in rHeaders)
{
headervals[headername] = req.Headers[headername];
}
keysvals.Add("headers",headervals);
keysvals.Add("querystringkeys", querystringkeys);
psEvArgs.Request(psreq.RequestID, keysvals);
}
m_PollServiceManager.Enqueue(psreq);
}
else
{
@ -275,48 +313,16 @@ namespace OpenSim.Framework.Servers.HttpServer
{
OSHttpRequest req = new OSHttpRequest(context, request);
OSHttpResponse resp = new OSHttpResponse(new HttpResponse(context, request),context);
//resp.KeepAlive = req.KeepAlive;
//m_log.Info("[Debug BASE HTTP SERVER]: Got Request");
//HttpServerContextObj objstate= new HttpServerContextObj(req,resp);
//ThreadPool.QueueUserWorkItem(new WaitCallback(ConvertIHttpClientContextToOSHttp), (object)objstate);
HandleRequest(req, resp);
}
public void ConvertIHttpClientContextToOSHttp(object stateinfo)
{
HttpServerContextObj objstate = (HttpServerContextObj)stateinfo;
//OSHttpRequest request = new OSHttpRequest(objstate.context,objstate.req);
//OSHttpResponse resp = new OSHttpResponse(new HttpServer.HttpResponse(objstate.context, objstate.req));
OSHttpRequest request = objstate.oreq;
OSHttpResponse resp = objstate.oresp;
//OSHttpResponse resp = new OSHttpResponse(new HttpServer.HttpResponse(objstate.context, objstate.req));
/*
request.AcceptTypes = objstate.req.AcceptTypes;
request.ContentLength = (long)objstate.req.ContentLength;
request.Headers = objstate.req.Headers;
request.HttpMethod = objstate.req.Method;
request.InputStream = objstate.req.Body;
foreach (string str in request.Headers)
{
if (str.ToLower().Contains("content-type: "))
{
request.ContentType = str.Substring(13, str.Length - 13);
break;
}
}
//request.KeepAlive = objstate.req.
foreach (HttpServer.HttpInput httpinput in objstate.req.QueryString)
{
request.QueryString.Add(httpinput.Name, httpinput[httpinput.Name]);
}
//request.Query = objstate.req.//objstate.req.QueryString;
//foreach (
//request.QueryString = objstate.req.QueryString;
*/
HandleRequest(request,resp);
}
@ -332,6 +338,7 @@ namespace OpenSim.Framework.Servers.HttpServer
// probability event; if a request is matched it is normally expected to be
// handled
//m_log.Debug("[BASE HTTP SERVER]: Handling Request" + request.RawUrl);
IHttpAgentHandler agentHandler;
if (TryGetAgentHandler(request, response, out agentHandler))
@ -342,10 +349,11 @@ namespace OpenSim.Framework.Servers.HttpServer
}
}
IRequestHandler requestHandler;
//response.KeepAlive = true;
response.SendChunked = false;
IRequestHandler requestHandler;
string path = request.RawUrl;
string handlerKey = GetHandlerKey(request.HttpMethod, path);
@ -359,6 +367,7 @@ namespace OpenSim.Framework.Servers.HttpServer
response.ContentType = requestHandler.ContentType; // Lets do this defaulting before in case handler has varying content type.
if (requestHandler is IStreamedRequestHandler)
{
IStreamedRequestHandler streamedRequestHandler = requestHandler as IStreamedRequestHandler;
@ -404,6 +413,7 @@ namespace OpenSim.Framework.Servers.HttpServer
// }
keysvals.Add("requestbody", requestBody);
keysvals.Add("headers",headervals);
if (keysvals.Contains("method"))
{
//m_log.Warn("[HTTP]: Contains Method");
@ -726,8 +736,11 @@ namespace OpenSim.Framework.Servers.HttpServer
else
{
xmlRpcResponse = new XmlRpcResponse();
// Code set in accordance with http://xmlrpc-epi.sourceforge.net/specs/rfc.fault_codes.php
xmlRpcResponse.SetFault(-32601, String.Format("Requested method [{0}] not found", methodName));
xmlRpcResponse.SetFault(
XmlRpcErrorCodes.SERVER_ERROR_METHOD,
String.Format("Requested method [{0}] not found", methodName));
}
responseString = XmlRpcResponseSerializer.Singleton.Serialize(xmlRpcResponse);
@ -747,6 +760,7 @@ namespace OpenSim.Framework.Servers.HttpServer
response.SendChunked = false;
response.ContentLength64 = buf.Length;
response.ContentEncoding = Encoding.UTF8;
try
{
response.OutputStream.Write(buf, 0, buf.Length);

View File

@ -30,20 +30,23 @@ using System.Collections;
using OpenMetaverse;
namespace OpenSim.Framework.Servers.HttpServer
{
public delegate bool HasEventsMethod(UUID pId);
public delegate void RequestMethod(UUID requestID, Hashtable request);
public delegate bool HasEventsMethod(UUID requestID, UUID pId);
public delegate Hashtable GetEventsMethod(UUID pId, string request);
public delegate Hashtable GetEventsMethod(UUID requestID, UUID pId, string request);
public delegate Hashtable NoEventsMethod();
public delegate Hashtable NoEventsMethod(UUID requestID, UUID pId);
public class PollServiceEventArgs : EventArgs
{
public HasEventsMethod HasEvents;
public GetEventsMethod GetEvents;
public NoEventsMethod NoEvents;
public RequestMethod Request;
public UUID Id;
public PollServiceEventArgs(HasEventsMethod pHasEvents, GetEventsMethod pGetEvents, NoEventsMethod pNoEvents,UUID pId)
public PollServiceEventArgs(RequestMethod pRequest, HasEventsMethod pHasEvents, GetEventsMethod pGetEvents, NoEventsMethod pNoEvents,UUID pId)
{
Request = pRequest;
HasEvents = pHasEvents;
GetEvents = pGetEvents;
NoEvents = pNoEvents;

View File

@ -27,6 +27,7 @@
using System;
using HttpServer;
using OpenMetaverse;
namespace OpenSim.Framework.Servers.HttpServer
{
@ -37,12 +38,14 @@ namespace OpenSim.Framework.Servers.HttpServer
public readonly IHttpClientContext HttpContext;
public readonly IHttpRequest Request;
public readonly int RequestTime;
public readonly UUID RequestID;
public PollServiceHttpRequest(PollServiceEventArgs pPollServiceArgs, IHttpClientContext pHttpContext, IHttpRequest pRequest)
{
PollServiceArgs = pPollServiceArgs;
HttpContext = pHttpContext;
Request = pRequest;
RequestTime = System.Environment.TickCount;
RequestID = UUID.Random();
}
}
}

View File

@ -130,7 +130,7 @@ namespace OpenSim.Framework.Servers.HttpServer
foreach (object o in m_requests)
{
PollServiceHttpRequest req = (PollServiceHttpRequest) o;
m_server.DoHTTPGruntWork(req.PollServiceArgs.NoEvents(), new OSHttpResponse(new HttpResponse(req.HttpContext, req.Request), req.HttpContext));
m_server.DoHTTPGruntWork(req.PollServiceArgs.NoEvents(req.RequestID, req.PollServiceArgs.Id), new OSHttpResponse(new HttpResponse(req.HttpContext, req.Request), req.HttpContext));
}
m_requests.Clear();

View File

@ -100,11 +100,11 @@ namespace OpenSim.Framework.Servers.HttpServer
PollServiceHttpRequest req = m_request.Dequeue();
try
{
if (req.PollServiceArgs.HasEvents(req.PollServiceArgs.Id))
if (req.PollServiceArgs.HasEvents(req.RequestID, req.PollServiceArgs.Id))
{
StreamReader str = new StreamReader(req.Request.Body);
Hashtable responsedata = req.PollServiceArgs.GetEvents(req.PollServiceArgs.Id, str.ReadToEnd());
Hashtable responsedata = req.PollServiceArgs.GetEvents(req.RequestID, req.PollServiceArgs.Id, str.ReadToEnd());
m_server.DoHTTPGruntWork(responsedata,
new OSHttpResponse(new HttpResponse(req.HttpContext, req.Request),req.HttpContext));
}
@ -112,7 +112,7 @@ namespace OpenSim.Framework.Servers.HttpServer
{
if ((Environment.TickCount - req.RequestTime) > m_timeout)
{
m_server.DoHTTPGruntWork(req.PollServiceArgs.NoEvents(),
m_server.DoHTTPGruntWork(req.PollServiceArgs.NoEvents(req.RequestID, req.PollServiceArgs.Id),
new OSHttpResponse(new HttpResponse(req.HttpContext, req.Request),req.HttpContext));
}
else

View File

@ -0,0 +1,95 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* 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 OpenSimulator Project 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 THE DEVELOPERS ``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 THE CONTRIBUTORS 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.IO;
using System.Net;
using System.Text;
using System.Xml;
using System.Xml.Serialization;
namespace OpenSim.Framework.Servers.HttpServer
{
public class SynchronousRestFormsRequester
{
/// <summary>
/// Perform a synchronous REST request.
/// </summary>
/// <param name="verb"></param>
/// <param name="requestUrl"></param>
/// <param name="obj"> </param>
/// <returns></returns>
///
/// <exception cref="System.Net.WebException">Thrown if we encounter a network issue while posting
/// the request. You'll want to make sure you deal with this as they're not uncommon</exception>
public static string MakeRequest(string verb, string requestUrl, string obj)
{
WebRequest request = WebRequest.Create(requestUrl);
request.Method = verb;
if ((verb == "POST") || (verb == "PUT"))
{
request.ContentType = "text/www-form-urlencoded";
MemoryStream buffer = new MemoryStream();
int length = 0;
using (StreamWriter writer = new StreamWriter(buffer))
{
writer.Write(obj);
writer.Flush();
}
length = (int)obj.Length;
request.ContentLength = length;
Stream requestStream = request.GetRequestStream();
requestStream.Write(buffer.ToArray(), 0, length);
}
string respstring = String.Empty;
try
{
using (WebResponse resp = request.GetResponse())
{
if (resp.ContentLength > 0)
{
using (StreamReader reader = new StreamReader(resp.GetResponseStream()))
{
respstring = reader.ReadToEnd();
}
}
}
}
catch (System.InvalidOperationException)
{
// This is what happens when there is invalid XML
}
return respstring;
}
}
}

View File

@ -29,7 +29,7 @@ namespace OpenSim
{
public class VersionInfo
{
private const string VERSION_NUMBER = "0.6.6";
private const string VERSION_NUMBER = "0.6.8";
private const Flavour VERSION_FLAVOUR = Flavour.Dev;
public enum Flavour

View File

@ -76,7 +76,7 @@ namespace OpenSim.Framework
public UUID RegionUUID
{
get { return regionUUID;}
get { return regionUUID; }
}
private UUID regionUUID;

View File

@ -70,6 +70,39 @@ namespace OpenSim.Framework
public static readonly Regex UUIDPattern
= new Regex("^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$");
/// <summary>
/// Linear interpolates B<->C using percent A
/// </summary>
/// <param name="a"></param>
/// <param name="b"></param>
/// <param name="c"></param>
/// <returns></returns>
public static double lerp(double a, double b, double c)
{
return (b*a) + (c*(1 - a));
}
/// <summary>
/// Bilinear Interpolate, see Lerp but for 2D using 'percents' X & Y.
/// Layout:
/// A B
/// C D
/// A<->C = Y
/// C<->D = X
/// </summary>
/// <param name="x"></param>
/// <param name="y"></param>
/// <param name="a"></param>
/// <param name="b"></param>
/// <param name="c"></param>
/// <param name="d"></param>
/// <returns></returns>
public static double lerp2D(double x, double y, double a, double b, double c, double d)
{
return lerp(y, lerp(x, a, b), lerp(x, c, d));
}
/// <value>
/// Well known UUID for the blank texture used in the Linden SL viewer version 1.20 (and hopefully onwards)
/// </value>
@ -1170,6 +1203,32 @@ namespace OpenSim.Framework
return found.ToArray();
}
public static string ServerURI(string uri)
{
if (uri == string.Empty)
return string.Empty;
// Get rid of eventual slashes at the end
uri = uri.TrimEnd('/');
IPAddress ipaddr1 = null;
string port1 = "";
try
{
ipaddr1 = Util.GetHostFromURL(uri);
}
catch { }
try
{
port1 = uri.Split(new char[] { ':' })[2];
}
catch { }
// We tried our best to convert the domain names to IP addresses
return (ipaddr1 != null) ? "http://" + ipaddr1.ToString() + ":" + port1 : uri;
}
#region FireAndForget Threading Pattern
public static void FireAndForget(System.Threading.WaitCallback callback)

View File

@ -324,44 +324,53 @@ namespace OpenSim.Grid.MessagingServer.Modules
/// <returns></returns>
public XmlRpcResponse UserLoggedOn(XmlRpcRequest request, IPEndPoint remoteClient)
{
Hashtable requestData = (Hashtable)request.Params[0];
AgentCircuitData agentData = new AgentCircuitData();
agentData.SessionID = new UUID((string)requestData["sessionid"]);
agentData.SecureSessionID = new UUID((string)requestData["secure_session_id"]);
agentData.firstname = (string)requestData["firstname"];
agentData.lastname = (string)requestData["lastname"];
agentData.AgentID = new UUID((string)requestData["agentid"]);
agentData.circuitcode = Convert.ToUInt32(requestData["circuit_code"]);
agentData.CapsPath = (string)requestData["caps_path"];
if (requestData.ContainsKey("child_agent") && requestData["child_agent"].Equals("1"))
try
{
agentData.child = true;
Hashtable requestData = (Hashtable)request.Params[0];
AgentCircuitData agentData = new AgentCircuitData();
agentData.SessionID = new UUID((string)requestData["sessionid"]);
agentData.SecureSessionID = new UUID((string)requestData["secure_session_id"]);
agentData.firstname = (string)requestData["firstname"];
agentData.lastname = (string)requestData["lastname"];
agentData.AgentID = new UUID((string)requestData["agentid"]);
agentData.circuitcode = Convert.ToUInt32(requestData["circuit_code"]);
agentData.CapsPath = (string)requestData["caps_path"];
if (requestData.ContainsKey("child_agent") && requestData["child_agent"].Equals("1"))
{
agentData.child = true;
}
else
{
agentData.startpos =
new Vector3(Convert.ToSingle(requestData["positionx"]),
Convert.ToSingle(requestData["positiony"]),
Convert.ToSingle(requestData["positionz"]));
agentData.child = false;
}
ulong regionHandle = Convert.ToUInt64((string)requestData["regionhandle"]);
m_log.InfoFormat("[LOGON]: User {0} {1} logged into region {2} as {3} agent, building indexes for user",
agentData.firstname, agentData.lastname, regionHandle, agentData.child ? "child" : "root");
UserPresenceData up = new UserPresenceData();
up.agentData = agentData;
up.friendData = GetUserFriendList(agentData.AgentID);
up.regionData = m_regionModule.GetRegionInfo(regionHandle);
up.OnlineYN = true;
up.lookupUserRegionYN = false;
ProcessFriendListSubscriptions(up);
}
else
catch (Exception e)
{
agentData.startpos =
new Vector3(Convert.ToSingle(requestData["positionx"]),
Convert.ToSingle(requestData["positiony"]),
Convert.ToSingle(requestData["positionz"]));
agentData.child = false;
m_log.WarnFormat("[LOGIN]: Exception on UserLoggedOn: {0}", e);
}
ulong regionHandle = Convert.ToUInt64((string)requestData["regionhandle"]);
m_log.InfoFormat("[LOGON]: User {0} {1} logged into region {2} as {3} agent, building indexes for user",
agentData.firstname, agentData.lastname, regionHandle, agentData.child ? "child" : "root");
UserPresenceData up = new UserPresenceData();
up.agentData = agentData;
up.friendData = GetUserFriendList(agentData.AgentID);
up.regionData = m_regionModule.GetRegionInfo(regionHandle);
up.OnlineYN = true;
up.lookupUserRegionYN = false;
ProcessFriendListSubscriptions(up);
return new XmlRpcResponse();
}
/// <summary>
@ -372,11 +381,18 @@ namespace OpenSim.Grid.MessagingServer.Modules
/// <returns></returns>
public XmlRpcResponse UserLoggedOff(XmlRpcRequest request, IPEndPoint remoteClient)
{
m_log.Info("[USERLOGOFF]: User logged off called");
Hashtable requestData = (Hashtable)request.Params[0];
try
{
m_log.Info("[USERLOGOFF]: User logged off called");
Hashtable requestData = (Hashtable)request.Params[0];
UUID AgentID = new UUID((string)requestData["agentid"]);
ProcessLogOff(AgentID);
UUID AgentID = new UUID((string)requestData["agentid"]);
ProcessLogOff(AgentID);
}
catch (Exception e)
{
m_log.WarnFormat("[USERLOGOFF]: Exception on UserLoggedOff: {0}", e);
}
return new XmlRpcResponse();
}

View File

@ -34,6 +34,7 @@ using System.Text.RegularExpressions;
using log4net;
using Nwc.XmlRpc;
using OpenMetaverse;
using Nini.Config;
using OpenSim.Data;
using OpenSim.Framework;
using OpenSim.Framework.Communications;
@ -42,6 +43,9 @@ using OpenSim.Framework.Communications.Cache;
using OpenSim.Framework.Capabilities;
using OpenSim.Framework.Servers;
using OpenSim.Framework.Servers.HttpServer;
using OpenSim.Services.Interfaces;
using OpenSim.Services.Connectors;
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
namespace OpenSim.Grid.UserServer.Modules
{
@ -63,6 +67,8 @@ namespace OpenSim.Grid.UserServer.Modules
public UserConfig m_config;
private readonly IRegionProfileRouter m_regionProfileService;
private IGridService m_GridService;
protected BaseHttpServer m_httpServer;
public UserLoginService(
@ -76,6 +82,8 @@ namespace OpenSim.Grid.UserServer.Modules
m_defaultHomeY = m_config.DefaultY;
m_interInventoryService = inventoryService;
m_regionProfileService = regionProfileService;
m_GridService = new GridServicesConnector(config.GridServerURL.ToString());
}
public void RegisterHandlers(BaseHttpServer httpServer, bool registerLLSDHandler, bool registerOpenIDHandlers)
@ -203,47 +211,38 @@ namespace OpenSim.Grid.UserServer.Modules
protected override RegionInfo RequestClosestRegion(string region)
{
RegionProfileData profileData = m_regionProfileService.RequestSimProfileData(region,
m_config.GridServerURL, m_config.GridSendKey, m_config.GridRecvKey);
if (profileData != null)
{
return profileData.ToRegionInfo();
}
else
{
return null;
}
return GridRegionToRegionInfo(m_GridService.GetRegionByName(UUID.Zero, region));
}
protected override RegionInfo GetRegionInfo(ulong homeRegionHandle)
{
RegionProfileData profileData = m_regionProfileService.RequestSimProfileData(homeRegionHandle,
m_config.GridServerURL, m_config.GridSendKey,
m_config.GridRecvKey);
if (profileData != null)
{
return profileData.ToRegionInfo();
}
else
{
return null;
}
uint x = 0, y = 0;
Utils.LongToUInts(homeRegionHandle, out x, out y);
return GridRegionToRegionInfo(m_GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y));
}
protected override RegionInfo GetRegionInfo(UUID homeRegionId)
{
RegionProfileData profileData = m_regionProfileService.RequestSimProfileData(homeRegionId,
m_config.GridServerURL, m_config.GridSendKey,
m_config.GridRecvKey);
if (profileData != null)
{
return profileData.ToRegionInfo();
}
else
{
return GridRegionToRegionInfo(m_GridService.GetRegionByUUID(UUID.Zero, homeRegionId));
}
private RegionInfo GridRegionToRegionInfo(GridRegion gregion)
{
if (gregion == null)
return null;
}
RegionInfo rinfo = new RegionInfo();
rinfo.ExternalHostName = gregion.ExternalHostName;
rinfo.HttpPort = gregion.HttpPort;
rinfo.InternalEndPoint = gregion.InternalEndPoint;
rinfo.RegionID = gregion.RegionID;
rinfo.RegionLocX = (uint)(gregion.RegionLocX / Constants.RegionSize);
rinfo.RegionLocY = (uint)(gregion.RegionLocY / Constants.RegionSize);
rinfo.RegionName = gregion.RegionName;
rinfo.ScopeID = gregion.ScopeID;
rinfo.ServerURI = gregion.ServerURI;
return rinfo;
}
protected override bool PrepareLoginToRegion(RegionInfo regionInfo, UserProfileData user, LoginResponse response, IPEndPoint remoteClient)
@ -280,9 +279,8 @@ namespace OpenSim.Grid.UserServer.Modules
//response.SeedCapability = serverURI + CapsUtil.GetCapsSeedPath(capsPath);
// Take off trailing / so that the caps path isn't //CAPS/someUUID
if (regionInfo.httpServerURI.EndsWith("/"))
regionInfo.httpServerURI = regionInfo.httpServerURI.Substring(0, regionInfo.httpServerURI.Length - 1);
response.SeedCapability = regionInfo.httpServerURI + CapsUtil.GetCapsSeedPath(capsPath);
string uri = regionInfo.httpServerURI.Trim(new char[] { '/' });
response.SeedCapability = uri + CapsUtil.GetCapsSeedPath(capsPath);
// Notify the target of an incoming user

View File

@ -108,6 +108,9 @@ namespace OpenSim.Grid.UserServer.Modules
m_httpServer.AddXmlRPCHandler("get_user_by_uuid", XmlRPCGetUserMethodUUID);
m_httpServer.AddXmlRPCHandler("get_avatar_picker_avatar", XmlRPCGetAvatarPickerAvatar);
// Used by IAR module to do password checks
m_httpServer.AddXmlRPCHandler("authenticate_user_by_password", XmlRPCAuthenticateUserMethodPassword);
m_httpServer.AddXmlRPCHandler("update_user_current_region", XmlRPCAtRegion);
m_httpServer.AddXmlRPCHandler("logout_of_simulator", XmlRPCLogOffUserMethodUUID);
m_httpServer.AddXmlRPCHandler("get_agent_by_uuid", XmlRPCGetAgentMethodUUID);
@ -203,6 +206,57 @@ namespace OpenSim.Grid.UserServer.Modules
#region XMLRPC User Methods
/// <summary>
/// Authenticate a user using their password
/// </summary>
/// <param name="request">Must contain values for "user_uuid" and "password" keys</param>
/// <param name="remoteClient"></param>
/// <returns></returns>
public XmlRpcResponse XmlRPCAuthenticateUserMethodPassword(XmlRpcRequest request, IPEndPoint remoteClient)
{
// m_log.DebugFormat("[USER MANAGER]: Received authenticated user by password request from {0}", remoteClient);
Hashtable requestData = (Hashtable)request.Params[0];
string userUuidRaw = (string)requestData["user_uuid"];
string password = (string)requestData["password"];
if (null == userUuidRaw)
return Util.CreateUnknownUserErrorResponse();
UUID userUuid;
if (!UUID.TryParse(userUuidRaw, out userUuid))
return Util.CreateUnknownUserErrorResponse();
UserProfileData userProfile = m_userDataBaseService.GetUserProfile(userUuid);
if (null == userProfile)
return Util.CreateUnknownUserErrorResponse();
string authed;
if (null == password)
{
authed = "FALSE";
}
else
{
if (m_userDataBaseService.AuthenticateUserByPassword(userUuid, password))
authed = "TRUE";
else
authed = "FALSE";
}
// m_log.DebugFormat(
// "[USER MANAGER]: Authentication by password result from {0} for {1} is {2}",
// remoteClient, userUuid, authed);
XmlRpcResponse response = new XmlRpcResponse();
Hashtable responseData = new Hashtable();
responseData["auth_user"] = authed;
response.Value = responseData;
return response;
}
public XmlRpcResponse XmlRPCGetAvatarPickerAvatar(XmlRpcRequest request, IPEndPoint remoteClient)
{
// XmlRpcResponse response = new XmlRpcResponse();
@ -246,10 +300,10 @@ namespace OpenSim.Grid.UserServer.Modules
m_userDataBaseService.CommitAgent(ref userProfile);
//setUserProfile(userProfile);
returnstring = "TRUE";
}
}
responseData.Add("returnString", returnstring);
response.Value = responseData;
return response;

View File

@ -260,8 +260,6 @@ namespace OpenSim.Grid.UserServer
m_userManager.PostInitialise();
m_avatarAppearanceModule.PostInitialise();
m_friendsModule.PostInitialise();
m_avatarAppearanceModule.PostInitialise();
}
protected virtual void RegisterHttpHandlers()
@ -276,8 +274,6 @@ namespace OpenSim.Grid.UserServer
m_avatarAppearanceModule.RegisterHandlers(m_httpServer);
m_messagesService.RegisterHandlers(m_httpServer);
m_gridInfoService.RegisterHandlers(m_httpServer);
m_avatarAppearanceModule.RegisterHandlers(m_httpServer);
}
public override void ShutdownSpecific()

View File

@ -43,16 +43,11 @@ namespace OpenSim
public class HGCommands
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
public static IHyperlink HGServices = null;
private static uint m_autoMappingX = 0;
private static uint m_autoMappingY = 0;
private static bool m_enableAutoMapping = false;
public static Scene CreateScene(RegionInfo regionInfo, AgentCircuitManager circuitManager, CommunicationsManager m_commsManager,
StorageManager storageManager, ModuleLoader m_moduleLoader, ConfigSettings m_configSettings, OpenSimConfigSource m_config, string m_version)
{
HGSceneCommunicationService sceneGridService = new HGSceneCommunicationService(m_commsManager, HGServices);
HGSceneCommunicationService sceneGridService = new HGSceneCommunicationService(m_commsManager);
return
new HGScene(
@ -61,213 +56,5 @@ namespace OpenSim
m_configSettings.See_into_region_from_neighbor, m_config.Source, m_version);
}
public static void RunHGCommand(string command, string[] cmdparams, Scene scene)
{
if (command.Equals("link-mapping"))
{
if (cmdparams.Length == 2)
{
try
{
m_autoMappingX = Convert.ToUInt32(cmdparams[0]);
m_autoMappingY = Convert.ToUInt32(cmdparams[1]);
m_enableAutoMapping = true;
}
catch (Exception)
{
m_autoMappingX = 0;
m_autoMappingY = 0;
m_enableAutoMapping = false;
}
}
}
else if (command.Equals("link-region"))
{
if (cmdparams.Length < 3)
{
if ((cmdparams.Length == 1) || (cmdparams.Length == 2))
{
LoadXmlLinkFile(cmdparams, scene);
}
else
{
LinkRegionCmdUsage();
}
return;
}
if (cmdparams[2].Contains(":"))
{
// New format
uint xloc, yloc;
string mapName;
try
{
xloc = Convert.ToUInt32(cmdparams[0]);
yloc = Convert.ToUInt32(cmdparams[1]);
mapName = cmdparams[2];
if (cmdparams.Length > 3)
for (int i = 3; i < cmdparams.Length; i++)
mapName += " " + cmdparams[i];
m_log.Info(">> MapName: " + mapName);
//internalPort = Convert.ToUInt32(cmdparams[4]);
//remotingPort = Convert.ToUInt32(cmdparams[5]);
}
catch (Exception e)
{
m_log.Warn("[HGrid] Wrong format for link-region command: " + e.Message);
LinkRegionCmdUsage();
return;
}
HGHyperlink.TryLinkRegionToCoords(scene, null, mapName, xloc, yloc);
}
else
{
// old format
RegionInfo regInfo;
uint xloc, yloc;
uint externalPort;
string externalHostName;
try
{
xloc = Convert.ToUInt32(cmdparams[0]);
yloc = Convert.ToUInt32(cmdparams[1]);
externalPort = Convert.ToUInt32(cmdparams[3]);
externalHostName = cmdparams[2];
//internalPort = Convert.ToUInt32(cmdparams[4]);
//remotingPort = Convert.ToUInt32(cmdparams[5]);
}
catch (Exception e)
{
m_log.Warn("[HGrid] Wrong format for link-region command: " + e.Message);
LinkRegionCmdUsage();
return;
}
//if (TryCreateLink(xloc, yloc, externalPort, externalHostName, out regInfo))
if (HGHyperlink.TryCreateLink(scene, null, xloc, yloc, "", externalPort, externalHostName, out regInfo))
{
if (cmdparams.Length >= 5)
{
regInfo.RegionName = "";
for (int i = 4; i < cmdparams.Length; i++)
regInfo.RegionName += cmdparams[i] + " ";
}
}
}
return;
}
else if (command.Equals("unlink-region"))
{
if (cmdparams.Length < 1)
{
UnlinkRegionCmdUsage();
return;
}
if (HGHyperlink.TryUnlinkRegion(scene, cmdparams[0]))
m_log.InfoFormat("[HGrid]: Successfully unlinked {0}", cmdparams[0]);
else
m_log.InfoFormat("[HGrid]: Unable to unlink {0}, region not found", cmdparams[0]);
}
}
private static void LoadXmlLinkFile(string[] cmdparams, Scene scene)
{
//use http://www.hgurl.com/hypergrid.xml for test
try
{
XmlReader r = XmlReader.Create(cmdparams[0]);
XmlConfigSource cs = new XmlConfigSource(r);
string[] excludeSections = null;
if (cmdparams.Length == 2)
{
if (cmdparams[1].ToLower().StartsWith("excludelist:"))
{
string excludeString = cmdparams[1].ToLower();
excludeString = excludeString.Remove(0, 12);
char[] splitter = {';'};
excludeSections = excludeString.Split(splitter);
}
}
for (int i = 0; i < cs.Configs.Count; i++)
{
bool skip = false;
if ((excludeSections != null) && (excludeSections.Length > 0))
{
for (int n = 0; n < excludeSections.Length; n++)
{
if (excludeSections[n] == cs.Configs[i].Name.ToLower())
{
skip = true;
break;
}
}
}
if (!skip)
{
ReadLinkFromConfig(cs.Configs[i], scene);
}
}
}
catch (Exception e)
{
m_log.Error(e.ToString());
}
}
private static void ReadLinkFromConfig(IConfig config, Scene scene)
{
RegionInfo regInfo;
uint xloc, yloc;
uint externalPort;
string externalHostName;
uint realXLoc, realYLoc;
xloc = Convert.ToUInt32(config.GetString("xloc", "0"));
yloc = Convert.ToUInt32(config.GetString("yloc", "0"));
externalPort = Convert.ToUInt32(config.GetString("externalPort", "0"));
externalHostName = config.GetString("externalHostName", "");
realXLoc = Convert.ToUInt32(config.GetString("real-xloc", "0"));
realYLoc = Convert.ToUInt32(config.GetString("real-yloc", "0"));
if (m_enableAutoMapping)
{
xloc = (uint) ((xloc%100) + m_autoMappingX);
yloc = (uint) ((yloc%100) + m_autoMappingY);
}
if (((realXLoc == 0) && (realYLoc == 0)) ||
(((realXLoc - xloc < 3896) || (xloc - realXLoc < 3896)) &&
((realYLoc - yloc < 3896) || (yloc - realYLoc < 3896))))
{
if (
HGHyperlink.TryCreateLink(scene, null, xloc, yloc, "", externalPort,
externalHostName, out regInfo))
{
regInfo.RegionName = config.GetString("localName", "");
}
}
}
private static void LinkRegionCmdUsage()
{
m_log.Info("Usage: link-region <Xloc> <Yloc> <HostName>:<HttpPort>[:<RemoteRegionName>]");
m_log.Info("Usage: link-region <Xloc> <Yloc> <HostName> <HttpPort> [<LocalName>]");
m_log.Info("Usage: link-region <URI_of_xml> [<exclude>]");
}
private static void UnlinkRegionCmdUsage()
{
m_log.Info("Usage: unlink-region <HostName>:<HttpPort>");
m_log.Info("Usage: unlink-region <LocalName>");
}
}
}

View File

@ -493,7 +493,7 @@ namespace OpenSim
{
if (cmd.Length < 4)
{
m_log.Error("Usage: create region <region name> <region_file.xml>");
m_log.Error("Usage: create region <region name> <region_file.ini>");
return;
}
if (cmd[3].EndsWith(".xml"))
@ -520,7 +520,7 @@ namespace OpenSim
}
else
{
m_log.Error("Usage: create region <region name> <region_file.xml>");
m_log.Error("Usage: create region <region name> <region_file.ini>");
return;
}
}
@ -553,7 +553,7 @@ namespace OpenSim
/// <param name="cmd"></param>
private void HandleLoginStatus(string module, string[] cmd)
{
if (m_commsManager.GridService.RegionLoginsEnabled == false)
if (m_sceneManager.CurrentOrFirstScene.SceneGridService.RegionLoginsEnabled == false)
m_log.Info("[ Login ] Login are disabled ");
else

View File

@ -209,9 +209,9 @@ namespace OpenSim
}
// Only enable logins to the regions once we have completely finished starting up (apart from scripts)
if ((m_commsManager != null) && (m_commsManager.GridService != null))
if ((SceneManager.CurrentOrFirstScene != null) && (SceneManager.CurrentOrFirstScene.SceneGridService != null))
{
m_commsManager.GridService.RegionLoginsEnabled = true;
SceneManager.CurrentOrFirstScene.SceneGridService.RegionLoginsEnabled = true;
}
AddPluginCommands();
@ -299,12 +299,12 @@ namespace OpenSim
if (LoginEnabled)
{
m_log.Info("[LOGIN]: Login is now enabled.");
m_commsManager.GridService.RegionLoginsEnabled = true;
SceneManager.CurrentOrFirstScene.SceneGridService.RegionLoginsEnabled = true;
}
else
{
m_log.Info("[LOGIN]: Login is now disabled.");
m_commsManager.GridService.RegionLoginsEnabled = false;
SceneManager.CurrentOrFirstScene.SceneGridService.RegionLoginsEnabled = false;
}
}
@ -399,7 +399,7 @@ namespace OpenSim
}
catch (Exception e)
{
m_log.ErrorFormat("[STARTUP]: Registration of region with grid failed, aborting startup - {0}", e);
m_log.ErrorFormat("[STARTUP]: Registration of region with grid failed, aborting startup - {0}", e.StackTrace);
// Carrying on now causes a lot of confusion down the
// line - we need to get the user's attention

View File

@ -1637,6 +1637,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
enablesimpacket.SimulatorInfo.IP += (uint)byteIP[1] << 8;
enablesimpacket.SimulatorInfo.IP += (uint)byteIP[0];
enablesimpacket.SimulatorInfo.Port = neighbourPort;
enablesimpacket.Header.Reliable = true; // ESP's should be reliable.
OutPacket(enablesimpacket, ThrottleOutPacketType.Task);
}

View File

@ -28,6 +28,7 @@
using OpenMetaverse;
using OpenSim.Framework;
using OpenSim.Region.Framework.Scenes;
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
namespace OpenSim.Region.ClientStack.LindenUDP.Tests
{
@ -58,7 +59,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests
public override void RemoveClient(UUID agentID) {}
public override void CloseAllAgents(uint circuitcode) {}
public override bool OtherRegionUp(RegionInfo thisRegion) { return false; }
public override void OtherRegionUp(GridRegion otherRegion) { }
/// <summary>
/// Doesn't really matter what the call is - we're using this to test that a packet has actually been received

View File

@ -40,21 +40,12 @@ namespace OpenSim.Region.Communications.Hypergrid
{
public class HGCommunicationsGridMode : CommunicationsManager // CommunicationsOGS1
{
IHyperlink m_osw = null;
public IHyperlink HGServices
{
get { return m_osw; }
}
public HGCommunicationsGridMode(
NetworkServersInfo serversInfo,
SceneManager sman, LibraryRootFolder libraryRootFolder)
: base(serversInfo, libraryRootFolder)
{
// From constructor at CommunicationsOGS1
HGGridServices gridInterComms = new HGGridServicesGridMode(serversInfo, sman, m_userProfileCacheService);
m_gridService = gridInterComms;
m_osw = gridInterComms;
HGUserServices userServices = new HGUserServices(this);
// This plugin arrangement could eventually be configurable rather than hardcoded here.

View File

@ -44,7 +44,6 @@ namespace OpenSim.Region.Communications.Hypergrid
ConfigSettings configSettings,
NetworkServersInfo serversInfo,
BaseHttpServer httpServer,
HGGridServices gridService,
LibraryRootFolder libraryRootFolder,
bool dumpAssetsToFile)
: base(serversInfo, libraryRootFolder)
@ -64,8 +63,6 @@ namespace OpenSim.Region.Communications.Hypergrid
m_avatarService = hgUserService;
m_messageService = hgUserService;
gridService.UserProfileCache = m_userProfileCacheService;
m_gridService = gridService;
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,159 +0,0 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* 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 OpenSimulator Project 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 THE DEVELOPERS ``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 THE CONTRIBUTORS 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.Reflection;
using log4net;
using OpenMetaverse;
using OpenSim.Framework;
using OpenSim.Framework.Communications.Cache;
using OpenSim.Framework.Servers.HttpServer;
using OpenSim.Region.Communications.OGS1;
using OpenSim.Region.Framework.Scenes;
namespace OpenSim.Region.Communications.Hypergrid
{
public class HGGridServicesGridMode : HGGridServices
{
//private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
/// <summary>
/// Encapsulate remote backend services for manipulation of grid regions
/// </summary>
private OGS1GridServices m_remoteBackend = null;
public OGS1GridServices RemoteBackend
{
get { return m_remoteBackend; }
}
public override string gdebugRegionName
{
get { return m_remoteBackend.gdebugRegionName; }
set { m_remoteBackend.gdebugRegionName = value; }
}
public override bool RegionLoginsEnabled
{
get { return m_remoteBackend.RegionLoginsEnabled; }
set { m_remoteBackend.RegionLoginsEnabled = value; }
}
public HGGridServicesGridMode(NetworkServersInfo servers_info,
SceneManager sman, UserProfileCacheService userv)
: base(servers_info, sman)
{
m_remoteBackend = new OGS1GridServices(servers_info);
m_userProfileCache = userv;
}
#region IGridServices interface
public override RegionCommsListener RegisterRegion(RegionInfo regionInfo)
{
if (!regionInfo.RegionID.Equals(UUID.Zero))
{
m_regionsOnInstance.Add(regionInfo);
return m_remoteBackend.RegisterRegion(regionInfo);
}
else
return base.RegisterRegion(regionInfo);
}
public override bool DeregisterRegion(RegionInfo regionInfo)
{
bool success = base.DeregisterRegion(regionInfo);
if (!success)
success = m_remoteBackend.DeregisterRegion(regionInfo);
return success;
}
public override List<SimpleRegionInfo> RequestNeighbours(uint x, uint y)
{
List<SimpleRegionInfo> neighbours = m_remoteBackend.RequestNeighbours(x, y);
//List<SimpleRegionInfo> remotes = base.RequestNeighbours(x, y);
//neighbours.AddRange(remotes);
return neighbours;
}
public override RegionInfo RequestNeighbourInfo(UUID Region_UUID)
{
RegionInfo info = m_remoteBackend.RequestNeighbourInfo(Region_UUID);
if (info == null)
info = base.RequestNeighbourInfo(Region_UUID);
return info;
}
public override RegionInfo RequestNeighbourInfo(ulong regionHandle)
{
RegionInfo info = base.RequestNeighbourInfo(regionHandle);
if (info == null)
info = m_remoteBackend.RequestNeighbourInfo(regionHandle);
return info;
}
public override RegionInfo RequestClosestRegion(string regionName)
{
RegionInfo info = m_remoteBackend.RequestClosestRegion(regionName);
if (info == null)
info = base.RequestClosestRegion(regionName);
return info;
}
public override List<MapBlockData> RequestNeighbourMapBlocks(int minX, int minY, int maxX, int maxY)
{
List<MapBlockData> neighbours = m_remoteBackend.RequestNeighbourMapBlocks(minX, minY, maxX, maxY);
List<MapBlockData> remotes = base.RequestNeighbourMapBlocks(minX, minY, maxX, maxY);
neighbours.AddRange(remotes);
return neighbours;
}
public override LandData RequestLandData(ulong regionHandle, uint x, uint y)
{
LandData land = m_remoteBackend.RequestLandData(regionHandle, x, y);
if (land == null)
land = base.RequestLandData(regionHandle, x, y);
return land;
}
public override List<RegionInfo> RequestNamedRegions(string name, int maxNumber)
{
List<RegionInfo> infos = m_remoteBackend.RequestNamedRegions(name, maxNumber);
List<RegionInfo> remotes = base.RequestNamedRegions(name, maxNumber);
infos.AddRange(remotes);
return infos;
}
#endregion
}
}

View File

@ -1,259 +0,0 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* 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 OpenSimulator Project 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 THE DEVELOPERS ``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 THE CONTRIBUTORS 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.Net;
using System.Net.Sockets;
using System.Reflection;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Tcp;
using System.Security.Authentication;
using log4net;
using Nwc.XmlRpc;
using OpenMetaverse;
using OpenSim.Framework;
using OpenSim.Framework.Servers;
using OpenSim.Framework.Servers.HttpServer;
using OpenSim.Region.Communications.Local;
using OpenSim.Region.Communications.OGS1;
using OpenSim.Region.Framework.Scenes;
namespace OpenSim.Region.Communications.Hypergrid
{
public class HGGridServicesStandalone : HGGridServices
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
/// <summary>
/// Encapsulate local backend services for manipulation of local regions
/// </summary>
protected LocalBackEndServices m_localBackend = new LocalBackEndServices();
//private Dictionary<ulong, int> m_deadRegionCache = new Dictionary<ulong, int>();
public LocalBackEndServices LocalBackend
{
get { return m_localBackend; }
}
public override string gdebugRegionName
{
get { return m_localBackend.gdebugRegionName; }
set { m_localBackend.gdebugRegionName = value; }
}
public override bool RegionLoginsEnabled
{
get { return m_localBackend.RegionLoginsEnabled; }
set { m_localBackend.RegionLoginsEnabled = value; }
}
public HGGridServicesStandalone(NetworkServersInfo servers_info, BaseHttpServer httpServe, SceneManager sman)
: base(servers_info, sman)
{
//Respond to Grid Services requests
MainServer.Instance.AddXmlRPCHandler("logoff_user", LogOffUser);
MainServer.Instance.AddXmlRPCHandler("check", PingCheckReply);
MainServer.Instance.AddXmlRPCHandler("land_data", LandData);
}
#region IGridServices interface
public override RegionCommsListener RegisterRegion(RegionInfo regionInfo)
{
if (!regionInfo.RegionID.Equals(UUID.Zero))
{
m_regionsOnInstance.Add(regionInfo);
return m_localBackend.RegisterRegion(regionInfo);
}
else
return base.RegisterRegion(regionInfo);
}
public override bool DeregisterRegion(RegionInfo regionInfo)
{
bool success = m_localBackend.DeregisterRegion(regionInfo);
if (!success)
success = base.DeregisterRegion(regionInfo);
return success;
}
public override List<SimpleRegionInfo> RequestNeighbours(uint x, uint y)
{
List<SimpleRegionInfo> neighbours = m_localBackend.RequestNeighbours(x, y);
//List<SimpleRegionInfo> remotes = base.RequestNeighbours(x, y);
//neighbours.AddRange(remotes);
return neighbours;
}
public override RegionInfo RequestNeighbourInfo(UUID Region_UUID)
{
RegionInfo info = m_localBackend.RequestNeighbourInfo(Region_UUID);
if (info == null)
info = base.RequestNeighbourInfo(Region_UUID);
return info;
}
public override RegionInfo RequestNeighbourInfo(ulong regionHandle)
{
RegionInfo info = m_localBackend.RequestNeighbourInfo(regionHandle);
//m_log.Info("[HGrid] Request neighbor info, local backend returned " + info);
if (info == null)
info = base.RequestNeighbourInfo(regionHandle);
return info;
}
public override RegionInfo RequestClosestRegion(string regionName)
{
RegionInfo info = m_localBackend.RequestClosestRegion(regionName);
if (info == null)
info = base.RequestClosestRegion(regionName);
return info;
}
public override List<MapBlockData> RequestNeighbourMapBlocks(int minX, int minY, int maxX, int maxY)
{
//m_log.Info("[HGrid] Request map blocks " + minX + "-" + minY + "-" + maxX + "-" + maxY);
List<MapBlockData> neighbours = m_localBackend.RequestNeighbourMapBlocks(minX, minY, maxX, maxY);
List<MapBlockData> remotes = base.RequestNeighbourMapBlocks(minX, minY, maxX, maxY);
neighbours.AddRange(remotes);
return neighbours;
}
public override LandData RequestLandData(ulong regionHandle, uint x, uint y)
{
LandData land = m_localBackend.RequestLandData(regionHandle, x, y);
if (land == null)
land = base.RequestLandData(regionHandle, x, y);
return land;
}
public override List<RegionInfo> RequestNamedRegions(string name, int maxNumber)
{
List<RegionInfo> infos = m_localBackend.RequestNamedRegions(name, maxNumber);
List<RegionInfo> remotes = base.RequestNamedRegions(name, maxNumber);
infos.AddRange(remotes);
return infos;
}
#endregion
#region XML Request Handlers
/// <summary>
/// A ping / version check
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public virtual XmlRpcResponse PingCheckReply(XmlRpcRequest request, IPEndPoint remoteClient)
{
XmlRpcResponse response = new XmlRpcResponse();
Hashtable respData = new Hashtable();
respData["online"] = "true";
m_localBackend.PingCheckReply(respData);
response.Value = respData;
return response;
}
// Grid Request Processing
/// <summary>
/// Ooops, our Agent must be dead if we're getting this request!
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public XmlRpcResponse LogOffUser(XmlRpcRequest request, IPEndPoint remoteClient)
{
m_log.Debug("[HGrid]: LogOff User Called");
Hashtable requestData = (Hashtable)request.Params[0];
string message = (string)requestData["message"];
UUID agentID = UUID.Zero;
UUID RegionSecret = UUID.Zero;
UUID.TryParse((string)requestData["agent_id"], out agentID);
UUID.TryParse((string)requestData["region_secret"], out RegionSecret);
ulong regionHandle = Convert.ToUInt64((string)requestData["regionhandle"]);
m_localBackend.TriggerLogOffUser(regionHandle, agentID, RegionSecret, message);
return new XmlRpcResponse();
}
/// <summary>
/// Someone asked us about parcel-information
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public XmlRpcResponse LandData(XmlRpcRequest request, IPEndPoint remoteClient)
{
Hashtable requestData = (Hashtable)request.Params[0];
ulong regionHandle = Convert.ToUInt64(requestData["region_handle"]);
uint x = Convert.ToUInt32(requestData["x"]);
uint y = Convert.ToUInt32(requestData["y"]);
m_log.DebugFormat("[HGrid]: Got XML reqeuest for land data at {0}, {1} in region {2}", x, y, regionHandle);
LandData landData = m_localBackend.RequestLandData(regionHandle, x, y);
Hashtable hash = new Hashtable();
if (landData != null)
{
// for now, only push out the data we need for answering a ParcelInfoReqeust
hash["AABBMax"] = landData.AABBMax.ToString();
hash["AABBMin"] = landData.AABBMin.ToString();
hash["Area"] = landData.Area.ToString();
hash["AuctionID"] = landData.AuctionID.ToString();
hash["Description"] = landData.Description;
hash["Flags"] = landData.Flags.ToString();
hash["GlobalID"] = landData.GlobalID.ToString();
hash["Name"] = landData.Name;
hash["OwnerID"] = landData.OwnerID.ToString();
hash["SalePrice"] = landData.SalePrice.ToString();
hash["SnapshotID"] = landData.SnapshotID.ToString();
hash["UserLocation"] = landData.UserLocation.ToString();
}
XmlRpcResponse response = new XmlRpcResponse();
response.Value = hash;
return response;
}
#endregion
}
}

View File

@ -53,8 +53,6 @@ namespace OpenSim.Region.Communications.Local
m_avatarService = lus;
m_messageService = lus;
m_gridService = new LocalBackEndServices();
//LocalLoginService loginService = CreateLoginService(libraryRootFolder, inventoryService, userService, backendService);
}
}

View File

@ -1,410 +0,0 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* 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 OpenSimulator Project 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 THE DEVELOPERS ``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 THE CONTRIBUTORS 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.Reflection;
using log4net;
using OpenMetaverse;
using OpenSim.Framework;
using OpenSim.Framework.Communications;
namespace OpenSim.Region.Communications.Local
{
public class LocalBackEndServices : IGridServices
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
protected Dictionary<ulong, RegionInfo> m_regions = new Dictionary<ulong, RegionInfo>();
protected Dictionary<ulong, RegionCommsListener> m_regionListeners =
new Dictionary<ulong, RegionCommsListener>();
// private Dictionary<ulong, RegionInfo> m_remoteRegionInfoCache = new Dictionary<ulong, RegionInfo>();
private Dictionary<string, string> m_queuedGridSettings = new Dictionary<string, string>();
public string _gdebugRegionName = String.Empty;
public bool RegionLoginsEnabled
{
get { return m_regionLoginsEnabled; }
set { m_regionLoginsEnabled = value; }
}
private bool m_regionLoginsEnabled;
public bool CheckRegion(string address, uint port)
{
return true;
}
public string gdebugRegionName
{
get { return _gdebugRegionName; }
set { _gdebugRegionName = value; }
}
public string _rdebugRegionName = String.Empty;
public string rdebugRegionName
{
get { return _rdebugRegionName; }
set { _rdebugRegionName = value; }
}
/// <summary>
/// Register a region method with the BackEnd Services.
/// </summary>
/// <param name="regionInfo"></param>
/// <returns></returns>
public RegionCommsListener RegisterRegion(RegionInfo regionInfo)
{
//m_log.Debug("CommsManager - Region " + regionInfo.RegionHandle + " , " + regionInfo.RegionLocX + " , "+ regionInfo.RegionLocY +" is registering");
if (!m_regions.ContainsKey(regionInfo.RegionHandle))
{
//m_log.Debug("CommsManager - Adding Region " + regionInfo.RegionHandle);
m_regions.Add(regionInfo.RegionHandle, regionInfo);
RegionCommsListener regionHost = new RegionCommsListener();
if (m_regionListeners.ContainsKey(regionInfo.RegionHandle))
{
m_log.Error("[INTERREGION STANDALONE]: " +
"Error:Region registered twice as an Events listener for Interregion Communications but not as a listed region. " +
"In Standalone mode this will cause BIG issues. In grid mode, it means a region went down and came back up.");
m_regionListeners.Remove(regionInfo.RegionHandle);
}
m_regionListeners.Add(regionInfo.RegionHandle, regionHost);
return regionHost;
}
else
{
// Already in our list, so the region went dead and restarted.
// don't replace the old regioninfo.. this might be a locking issue.. however we need to
// remove it and let it add normally below or we get extremely strange and intermittant
// connectivity errors.
// Don't change this line below to 'm_regions[regionInfo.RegionHandle] = regionInfo' unless you
// *REALLY* know what you are doing here.
m_regions[regionInfo.RegionHandle] = regionInfo;
m_log.Warn("[INTERREGION STANDALONE]: Region registered twice. Region went down and came back up.");
RegionCommsListener regionHost = new RegionCommsListener();
if (m_regionListeners.ContainsKey(regionInfo.RegionHandle))
{
m_regionListeners.Remove(regionInfo.RegionHandle);
}
m_regionListeners.Add(regionInfo.RegionHandle, regionHost);
return regionHost;
}
}
public bool DeregisterRegion(RegionInfo regionInfo)
{
if (m_regions.ContainsKey(regionInfo.RegionHandle))
{
m_regions.Remove(regionInfo.RegionHandle);
if (m_regionListeners.ContainsKey(regionInfo.RegionHandle))
{
m_regionListeners.Remove(regionInfo.RegionHandle);
}
return true;
}
return false;
}
/// <summary>
/// </summary>
/// <param name="regionInfo"></param>
/// <returns></returns>
public List<SimpleRegionInfo> RequestNeighbours(uint x, uint y)
{
// m_log.Debug("Finding Neighbours to " + regionInfo.RegionHandle);
List<SimpleRegionInfo> neighbours = new List<SimpleRegionInfo>();
foreach (RegionInfo reg in m_regions.Values)
{
// m_log.Debug("CommsManager- RequestNeighbours() checking region " + reg.RegionLocX + " , "+ reg.RegionLocY);
if (reg.RegionLocX != x || reg.RegionLocY != y)
{
//m_log.Debug("CommsManager- RequestNeighbours() - found a different region in list, checking location");
if ((reg.RegionLocX > (x - 2)) && (reg.RegionLocX < (x + 2)))
{
if ((reg.RegionLocY > (y - 2)) && (reg.RegionLocY < (y + 2)))
{
neighbours.Add(reg);
}
}
}
}
return neighbours;
}
/// <summary>
/// Get information about a neighbouring region
/// </summary>
/// <param name="regionHandle"></param>
/// <returns></returns>
public RegionInfo RequestNeighbourInfo(ulong regionHandle)
{
if (m_regions.ContainsKey(regionHandle))
{
return m_regions[regionHandle];
}
return null;
}
/// <summary>
/// Get information about a neighbouring region
/// </summary>
/// <param name="regionHandle"></param>
/// <returns></returns>
public RegionInfo RequestNeighbourInfo(UUID regionID)
{
// TODO add a dictionary for faster lookup
foreach (RegionInfo info in m_regions.Values)
{
if (info.RegionID == regionID)
return info;
}
return null;
}
/// <summary>
/// Get information about a neighbouring region
/// </summary>
/// <param name="regionHandle"></param>
/// <returns></returns>
public RegionInfo RequestNeighbourInfo(string name)
{
foreach (RegionInfo info in m_regions.Values)
{
if (info.RegionName == name)
return info;
}
return null;
}
/// <summary>
/// Get information about a neighbouring region
/// </summary>
/// <param name="regionHandle"></param>
/// <returns></returns>
public RegionInfo RequestNeighbourInfo(string host, uint port)
{
foreach (RegionInfo info in m_regions.Values)
{
if ((info.ExternalHostName == host) && (info.HttpPort == port))
return info;
}
return null;
}
/// <summary>
/// Get information about the closet region given a region name.
/// </summary>
/// <param name="regionName"></param>
/// <returns></returns>
public RegionInfo RequestClosestRegion(string regionName)
{
foreach (RegionInfo regInfo in m_regions.Values)
{
if (regInfo.RegionName == regionName)
return regInfo;
}
return null;
}
/// <summary>
///
/// </summary>
/// <param name="minX"></param>
/// <param name="minY"></param>
/// <param name="maxX"></param>
/// <param name="maxY"></param>
/// <returns></returns>
public List<MapBlockData> RequestNeighbourMapBlocks(int minX, int minY, int maxX, int maxY)
{
List<MapBlockData> mapBlocks = new List<MapBlockData>();
foreach (RegionInfo regInfo in m_regions.Values)
{
if (((regInfo.RegionLocX >= minX) && (regInfo.RegionLocX <= maxX)) &&
((regInfo.RegionLocY >= minY) && (regInfo.RegionLocY <= maxY)))
{
MapBlockData map = new MapBlockData();
map.Name = regInfo.RegionName;
map.X = (ushort) regInfo.RegionLocX;
map.Y = (ushort) regInfo.RegionLocY;
map.WaterHeight = (byte) regInfo.RegionSettings.WaterHeight;
map.MapImageId = regInfo.RegionSettings.TerrainImageID;
map.Agents = 1;
map.RegionFlags = 72458694;
map.Access = regInfo.AccessLevel;
mapBlocks.Add(map);
}
}
return mapBlocks;
}
// This function is only here to keep this class in line with the Grid Interface.
// It never gets called.
public virtual Dictionary<string, string> GetGridSettings()
{
Dictionary<string, string> returnGridSettings = new Dictionary<string, string>();
lock (m_queuedGridSettings)
{
returnGridSettings = m_queuedGridSettings;
m_queuedGridSettings.Clear();
}
return returnGridSettings;
}
public virtual void SetForcefulBanlistsDisallowed()
{
m_queuedGridSettings.Add("allow_forceful_banlines", "FALSE");
}
/// <summary>
/// Is a Sandbox mode method, used by the local Login server to inform a region of a connection user/session
/// </summary>
/// <param name="regionHandle"></param>
/// <param name="loginData"></param>
/// <returns></returns>
public void AddNewSession(ulong regionHandle, Login loginData)
{
AgentCircuitData agent = new AgentCircuitData();
agent.AgentID = loginData.Agent;
agent.firstname = loginData.First;
agent.lastname = loginData.Last;
agent.SessionID = loginData.Session;
agent.SecureSessionID = loginData.SecureSession;
agent.circuitcode = loginData.CircuitCode;
agent.BaseFolder = loginData.BaseFolder;
agent.InventoryFolder = loginData.InventoryFolder;
agent.startpos = loginData.StartPos;
agent.CapsPath = loginData.CapsPath;
if (loginData.Appearance != null)
agent.Appearance = loginData.Appearance;
else
{
m_log.WarnFormat("[INTER]: Appearance not found for {0} {1}. Creating default.", agent.firstname, agent.lastname);
agent.Appearance = new AvatarAppearance(agent.AgentID);
}
TriggerExpectUser(regionHandle, agent);
}
public void TriggerExpectUser(ulong regionHandle, AgentCircuitData agent)
{
//m_log.Info("[INTER]: " + rdebugRegionName + ":Local BackEnd: Other region is sending child agent our way: " + agent.firstname + " " + agent.lastname);
if (m_regionListeners.ContainsKey(regionHandle))
{
//m_log.Info("[INTER]: " + rdebugRegionName + ":Local BackEnd: FoundLocalRegion To send it to: " + agent.firstname + " " + agent.lastname);
m_regionListeners[regionHandle].TriggerExpectUser(agent);
}
}
public void TriggerLogOffUser(ulong regionHandle, UUID agentID, UUID RegionSecret, string message)
{
if (m_regionListeners.ContainsKey(regionHandle))
{
//m_log.Info("[INTER]: " + rdebugRegionName + ":Local BackEnd: FoundLocalRegion To send it to: " + agent.firstname + " " + agent.lastname);
m_regionListeners[regionHandle].TriggerLogOffUser(agentID, RegionSecret, message);
}
}
public void PingCheckReply(Hashtable respData)
{
foreach (ulong region in m_regions.Keys)
{
Hashtable regData = new Hashtable();
RegionInfo reg = m_regions[region];
regData["status"] = "active";
regData["handle"] = region.ToString();
respData[reg.RegionID.ToString()] = regData;
}
}
public LandData RequestLandData (ulong regionHandle, uint x, uint y)
{
m_log.DebugFormat("[INTERREGION STANDALONE] requests land data in {0}, at {1}, {2}",
regionHandle, x, y);
if (m_regionListeners.ContainsKey(regionHandle))
{
LandData land = m_regionListeners[regionHandle].TriggerGetLandData(x, y);
return land;
}
m_log.Debug("[INTERREGION STANDALONE] didn't find land data locally.");
return null;
}
public List<RegionInfo> RequestNamedRegions (string name, int maxNumber)
{
List<RegionInfo> lowercase_regions = new List<RegionInfo>();
List<RegionInfo> regions = new List<RegionInfo>();
foreach (RegionInfo info in m_regions.Values)
{
// Prioritizes exact match
if (info.RegionName.StartsWith(name))
{
regions.Add(info);
if (regions.Count >= maxNumber) break;
}
// But still saves lower case matches
else if (info.RegionName.ToLower().StartsWith(name))
{
if (lowercase_regions.Count < maxNumber)
{
lowercase_regions.Add(info);
}
}
}
// If no exact matches found, return lowercase matches (libOMV compatiblity)
if (regions.Count == 0 && lowercase_regions.Count != 0)
{
return lowercase_regions;
}
return regions;
}
}
}

View File

@ -81,5 +81,20 @@ namespace OpenSim.Region.Communications.Local
}
return data;
}
public override bool AuthenticateUserByPassword(UUID userID, string password)
{
UserProfileData userProfile = GetUserProfile(userID);
if (null == userProfile)
return false;
string md5PasswordHash = Util.Md5Hash(Util.Md5Hash(password) + ":" + userProfile.PasswordSalt);
if (md5PasswordHash == userProfile.PasswordHash)
return true;
else
return false;
}
}
}

View File

@ -39,8 +39,6 @@ namespace OpenSim.Region.Communications.OGS1
LibraryRootFolder libraryRootFolder)
: base(serversInfo, libraryRootFolder)
{
OGS1GridServices gridInterComms = new OGS1GridServices(serversInfo);
m_gridService = gridInterComms;
// This plugin arrangement could eventually be configurable rather than hardcoded here.
OGS1UserServices userServices = new OGS1UserServices(this);

View File

@ -1,937 +0,0 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* 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 OpenSimulator Project 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 THE DEVELOPERS ``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 THE CONTRIBUTORS 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.Net;
using System.Net.Sockets;
using System.Reflection;
using log4net;
using Nwc.XmlRpc;
using OpenMetaverse;
using OpenSim.Framework;
using OpenSim.Framework.Communications;
using OpenSim.Framework.Servers.HttpServer;
using OpenSim.Region.Communications.Local;
namespace OpenSim.Region.Communications.OGS1
{
public class OGS1GridServices : IGridServices
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private bool m_useRemoteRegionCache = true;
/// <summary>
/// Encapsulate local backend services for manipulation of local regions
/// </summary>
private LocalBackEndServices m_localBackend = new LocalBackEndServices();
private Dictionary<ulong, RegionInfo> m_remoteRegionInfoCache = new Dictionary<ulong, RegionInfo>();
// private List<SimpleRegionInfo> m_knownRegions = new List<SimpleRegionInfo>();
private Dictionary<ulong, int> m_deadRegionCache = new Dictionary<ulong, int>();
private Dictionary<string, string> m_queuedGridSettings = new Dictionary<string, string>();
private List<RegionInfo> m_regionsOnInstance = new List<RegionInfo>();
public BaseHttpServer httpListener;
public NetworkServersInfo serversInfo;
public string gdebugRegionName
{
get { return m_localBackend.gdebugRegionName; }
set { m_localBackend.gdebugRegionName = value; }
}
public string rdebugRegionName
{
get { return _rdebugRegionName; }
set { _rdebugRegionName = value; }
}
private string _rdebugRegionName = String.Empty;
public bool RegionLoginsEnabled
{
get { return m_localBackend.RegionLoginsEnabled; }
set { m_localBackend.RegionLoginsEnabled = value; }
}
/// <summary>
/// Contructor. Adds "expect_user" and "check" xmlrpc method handlers
/// </summary>
/// <param name="servers_info"></param>
/// <param name="httpServe"></param>
public OGS1GridServices(NetworkServersInfo servers_info)
{
serversInfo = servers_info;
//Respond to Grid Services requests
MainServer.Instance.AddXmlRPCHandler("check", PingCheckReply);
}
// see IGridServices
public RegionCommsListener RegisterRegion(RegionInfo regionInfo)
{
if (m_regionsOnInstance.Contains(regionInfo))
{
m_log.Error("[OGS1 GRID SERVICES]: Foobar! Caller is confused, region already registered " + regionInfo.RegionName);
Exception e = new Exception(String.Format("Unable to register region"));
throw e;
}
m_log.InfoFormat(
"[OGS1 GRID SERVICES]: Registering region {0} with grid at {1}",
regionInfo.RegionName, serversInfo.GridURL);
m_regionsOnInstance.Add(regionInfo);
Hashtable GridParams = new Hashtable();
// Login / Authentication
GridParams["authkey"] = serversInfo.GridSendKey;
GridParams["recvkey"] = serversInfo.GridRecvKey;
GridParams["UUID"] = regionInfo.RegionID.ToString();
GridParams["sim_ip"] = regionInfo.ExternalHostName;
GridParams["sim_port"] = regionInfo.InternalEndPoint.Port.ToString();
GridParams["region_locx"] = regionInfo.RegionLocX.ToString();
GridParams["region_locy"] = regionInfo.RegionLocY.ToString();
GridParams["sim_name"] = regionInfo.RegionName;
GridParams["http_port"] = serversInfo.HttpListenerPort.ToString();
GridParams["remoting_port"] = ConfigSettings.DefaultRegionRemotingPort.ToString();
GridParams["map-image-id"] = regionInfo.RegionSettings.TerrainImageID.ToString();
GridParams["originUUID"] = regionInfo.originRegionID.ToString();
GridParams["server_uri"] = regionInfo.ServerURI;
GridParams["region_secret"] = regionInfo.regionSecret;
GridParams["major_interface_version"] = VersionInfo.MajorInterfaceVersion.ToString();
if (regionInfo.MasterAvatarAssignedUUID != UUID.Zero)
GridParams["master_avatar_uuid"] = regionInfo.MasterAvatarAssignedUUID.ToString();
else
GridParams["master_avatar_uuid"] = regionInfo.EstateSettings.EstateOwner.ToString();
GridParams["maturity"] = regionInfo.RegionSettings.Maturity.ToString();
// Package into an XMLRPC Request
ArrayList SendParams = new ArrayList();
SendParams.Add(GridParams);
// Send Request
XmlRpcRequest GridReq = new XmlRpcRequest("simulator_login", SendParams);
XmlRpcResponse GridResp;
try
{
// The timeout should always be significantly larger than the timeout for the grid server to request
// the initial status of the region before confirming registration.
GridResp = GridReq.Send(serversInfo.GridURL, 9999999);
}
catch (Exception e)
{
Exception e2
= new Exception(
String.Format(
"Unable to register region with grid at {0}. Grid service not running?",
serversInfo.GridURL),
e);
throw e2;
}
Hashtable GridRespData = (Hashtable)GridResp.Value;
// Hashtable griddatahash = GridRespData;
// Process Response
if (GridRespData.ContainsKey("error"))
{
string errorstring = (string) GridRespData["error"];
Exception e = new Exception(
String.Format("Unable to connect to grid at {0}: {1}", serversInfo.GridURL, errorstring));
throw e;
}
else
{
// m_knownRegions = RequestNeighbours(regionInfo.RegionLocX, regionInfo.RegionLocY);
if (GridRespData.ContainsKey("allow_forceful_banlines"))
{
if ((string) GridRespData["allow_forceful_banlines"] != "TRUE")
{
//m_localBackend.SetForcefulBanlistsDisallowed(regionInfo.RegionHandle);
if (!m_queuedGridSettings.ContainsKey("allow_forceful_banlines"))
m_queuedGridSettings.Add("allow_forceful_banlines", "FALSE");
}
}
m_log.InfoFormat(
"[OGS1 GRID SERVICES]: Region {0} successfully registered with grid at {1}",
regionInfo.RegionName, serversInfo.GridURL);
}
return m_localBackend.RegisterRegion(regionInfo);
}
// see IGridServices
public bool DeregisterRegion(RegionInfo regionInfo)
{
Hashtable GridParams = new Hashtable();
GridParams["UUID"] = regionInfo.RegionID.ToString();
// Package into an XMLRPC Request
ArrayList SendParams = new ArrayList();
SendParams.Add(GridParams);
// Send Request
XmlRpcRequest GridReq = new XmlRpcRequest("simulator_after_region_moved", SendParams);
XmlRpcResponse GridResp = null;
try
{
GridResp = GridReq.Send(serversInfo.GridURL, 10000);
}
catch (Exception e)
{
Exception e2
= new Exception(
String.Format(
"Unable to deregister region with grid at {0}. Grid service not running?",
serversInfo.GridURL),
e);
throw e2;
}
Hashtable GridRespData = (Hashtable) GridResp.Value;
// Hashtable griddatahash = GridRespData;
// Process Response
if (GridRespData != null && GridRespData.ContainsKey("error"))
{
string errorstring = (string)GridRespData["error"];
m_log.Error("Unable to connect to grid: " + errorstring);
return false;
}
return m_localBackend.DeregisterRegion(regionInfo);
}
public virtual Dictionary<string, string> GetGridSettings()
{
Dictionary<string, string> returnGridSettings = new Dictionary<string, string>();
lock (m_queuedGridSettings)
{
foreach (string Dictkey in m_queuedGridSettings.Keys)
{
returnGridSettings.Add(Dictkey, m_queuedGridSettings[Dictkey]);
}
m_queuedGridSettings.Clear();
}
return returnGridSettings;
}
// see IGridServices
public List<SimpleRegionInfo> RequestNeighbours(uint x, uint y)
{
Hashtable respData = MapBlockQuery((int) x - 1, (int) y - 1, (int) x + 1, (int) y + 1);
List<SimpleRegionInfo> neighbours = new List<SimpleRegionInfo>();
foreach (ArrayList neighboursList in respData.Values)
{
foreach (Hashtable neighbourData in neighboursList)
{
uint regX = Convert.ToUInt32(neighbourData["x"]);
uint regY = Convert.ToUInt32(neighbourData["y"]);
if ((x != regX) || (y != regY))
{
string simIp = (string) neighbourData["sim_ip"];
uint port = Convert.ToUInt32(neighbourData["sim_port"]);
// string externalUri = (string) neighbourData["sim_uri"];
// string externalIpStr = String.Empty;
try
{
// externalIpStr = Util.GetHostFromDNS(simIp).ToString();
Util.GetHostFromDNS(simIp).ToString();
}
catch (SocketException e)
{
m_log.WarnFormat(
"[OGS1 GRID SERVICES]: RequestNeighbours(): Lookup of neighbour {0} failed! Not including in neighbours list. {1}",
simIp, e);
continue;
}
SimpleRegionInfo sri = new SimpleRegionInfo(regX, regY, simIp, port);
sri.RemotingPort = Convert.ToUInt32(neighbourData["remoting_port"]);
if (neighbourData.ContainsKey("http_port"))
{
sri.HttpPort = Convert.ToUInt32(neighbourData["http_port"]);
}
else
{
m_log.Error("[OGS1 GRID SERVICES]: Couldn't find httpPort, using default 9000; please upgrade your grid-server to r7621 or later");
sri.HttpPort = 9000; // that's the default and will probably be wrong
}
sri.RegionID = new UUID((string) neighbourData["uuid"]);
neighbours.Add(sri);
}
}
}
return neighbours;
}
/// <summary>
/// Request information about a region.
/// </summary>
/// <param name="regionHandle"></param>
/// <returns>
/// null on a failure to contact or get a response from the grid server
/// FIXME: Might be nicer to return a proper exception here since we could inform the client more about the
/// nature of the faiulre.
/// </returns>
public RegionInfo RequestNeighbourInfo(UUID Region_UUID)
{
// don't ask the gridserver about regions on this instance...
foreach (RegionInfo info in m_regionsOnInstance)
{
if (info.RegionID == Region_UUID) return info;
}
// didn't find it so far, we have to go the long way
RegionInfo regionInfo;
Hashtable requestData = new Hashtable();
requestData["region_UUID"] = Region_UUID.ToString();
requestData["authkey"] = serversInfo.GridSendKey;
ArrayList SendParams = new ArrayList();
SendParams.Add(requestData);
XmlRpcRequest gridReq = new XmlRpcRequest("simulator_data_request", SendParams);
XmlRpcResponse gridResp = null;
try
{
gridResp = gridReq.Send(serversInfo.GridURL, 3000);
}
catch (Exception e)
{
m_log.ErrorFormat(
"[OGS1 GRID SERVICES]: Communication with the grid server at {0} failed, {1}",
serversInfo.GridURL, e);
return null;
}
Hashtable responseData = (Hashtable)gridResp.Value;
if (responseData.ContainsKey("error"))
{
m_log.WarnFormat("[OGS1 GRID SERVICES]: Error received from grid server: {0}", responseData["error"]);
return null;
}
regionInfo = buildRegionInfo(responseData, String.Empty);
if ((m_useRemoteRegionCache) && (requestData.ContainsKey("regionHandle")))
{
m_remoteRegionInfoCache.Add(Convert.ToUInt64((string) requestData["regionHandle"]), regionInfo);
}
return regionInfo;
}
/// <summary>
/// Request information about a region.
/// </summary>
/// <param name="regionHandle"></param>
/// <returns></returns>
public RegionInfo RequestNeighbourInfo(ulong regionHandle)
{
RegionInfo regionInfo = m_localBackend.RequestNeighbourInfo(regionHandle);
if (regionInfo != null)
{
return regionInfo;
}
if ((!m_useRemoteRegionCache) || (!m_remoteRegionInfoCache.TryGetValue(regionHandle, out regionInfo)))
{
try
{
Hashtable requestData = new Hashtable();
requestData["region_handle"] = regionHandle.ToString();
requestData["authkey"] = serversInfo.GridSendKey;
ArrayList SendParams = new ArrayList();
SendParams.Add(requestData);
XmlRpcRequest GridReq = new XmlRpcRequest("simulator_data_request", SendParams);
XmlRpcResponse GridResp = GridReq.Send(serversInfo.GridURL, 3000);
Hashtable responseData = (Hashtable) GridResp.Value;
if (responseData.ContainsKey("error"))
{
m_log.Error("[OGS1 GRID SERVICES]: Error received from grid server: " + responseData["error"]);
return null;
}
uint regX = Convert.ToUInt32((string) responseData["region_locx"]);
uint regY = Convert.ToUInt32((string) responseData["region_locy"]);
string externalHostName = (string) responseData["sim_ip"];
uint simPort = Convert.ToUInt32(responseData["sim_port"]);
string regionName = (string)responseData["region_name"];
UUID regionID = new UUID((string)responseData["region_UUID"]);
uint remotingPort = Convert.ToUInt32((string)responseData["remoting_port"]);
uint httpPort = 9000;
if (responseData.ContainsKey("http_port"))
{
httpPort = Convert.ToUInt32((string)responseData["http_port"]);
}
// Ok, so this is definitively the wrong place to do this, way too hard coded, but it doesn't seem we GET this info?
string simURI = "http://" + externalHostName + ":" + simPort;
// string externalUri = (string) responseData["sim_uri"];
//IPEndPoint neighbourInternalEndPoint = new IPEndPoint(IPAddress.Parse(internalIpStr), (int) port);
regionInfo = RegionInfo.Create(regionID, regionName, regX, regY, externalHostName, httpPort, simPort, remotingPort, simURI);
if (m_useRemoteRegionCache)
{
lock (m_remoteRegionInfoCache)
{
if (!m_remoteRegionInfoCache.ContainsKey(regionHandle))
{
m_remoteRegionInfoCache.Add(regionHandle, regionInfo);
}
}
}
}
catch (Exception e)
{
m_log.Error("[OGS1 GRID SERVICES]: " +
"Region lookup failed for: " + regionHandle.ToString() +
" - Is the GridServer down?" + e.ToString());
return null;
}
}
return regionInfo;
}
/// <summary>
/// Get information about a neighbouring region
/// </summary>
/// <param name="regionHandle"></param>
/// <returns></returns>
public RegionInfo RequestNeighbourInfo(string name)
{
// Not implemented yet
return null;
}
/// <summary>
/// Get information about a neighbouring region
/// </summary>
/// <param name="regionHandle"></param>
/// <returns></returns>
public RegionInfo RequestNeighbourInfo(string host, uint port)
{
// Not implemented yet
return null;
}
public RegionInfo RequestClosestRegion(string regionName)
{
if (m_useRemoteRegionCache)
{
foreach (RegionInfo ri in m_remoteRegionInfoCache.Values)
{
if (ri.RegionName == regionName)
return ri;
}
}
RegionInfo regionInfo = null;
try
{
Hashtable requestData = new Hashtable();
requestData["region_name_search"] = regionName;
requestData["authkey"] = serversInfo.GridSendKey;
ArrayList SendParams = new ArrayList();
SendParams.Add(requestData);
XmlRpcRequest GridReq = new XmlRpcRequest("simulator_data_request", SendParams);
XmlRpcResponse GridResp = GridReq.Send(serversInfo.GridURL, 3000);
Hashtable responseData = (Hashtable) GridResp.Value;
if (responseData.ContainsKey("error"))
{
m_log.ErrorFormat("[OGS1 GRID SERVICES]: Error received from grid server: ", responseData["error"]);
return null;
}
regionInfo = buildRegionInfo(responseData, "");
if ((m_useRemoteRegionCache) && (!m_remoteRegionInfoCache.ContainsKey(regionInfo.RegionHandle)))
m_remoteRegionInfoCache.Add(regionInfo.RegionHandle, regionInfo);
}
catch
{
m_log.Error("[OGS1 GRID SERVICES]: " +
"Region lookup failed for: " + regionName +
" - Is the GridServer down?");
}
return regionInfo;
}
/// <summary>
///
/// </summary>
/// <param name="minX"></param>
/// <param name="minY"></param>
/// <param name="maxX"></param>
/// <param name="maxY"></param>
/// <returns></returns>
public List<MapBlockData> RequestNeighbourMapBlocks(int minX, int minY, int maxX, int maxY)
{
int temp = 0;
if (minX > maxX)
{
temp = minX;
minX = maxX;
maxX = temp;
}
if (minY > maxY)
{
temp = minY;
minY = maxY;
maxY = temp;
}
Hashtable respData = MapBlockQuery(minX, minY, maxX, maxY);
List<MapBlockData> neighbours = new List<MapBlockData>();
foreach (ArrayList a in respData.Values)
{
foreach (Hashtable n in a)
{
MapBlockData neighbour = new MapBlockData();
neighbour.X = Convert.ToUInt16(n["x"]);
neighbour.Y = Convert.ToUInt16(n["y"]);
neighbour.Name = (string) n["name"];
neighbour.Access = Convert.ToByte(n["access"]);
neighbour.RegionFlags = Convert.ToUInt32(n["region-flags"]);
neighbour.WaterHeight = Convert.ToByte(n["water-height"]);
neighbour.MapImageId = new UUID((string) n["map-image-id"]);
neighbours.Add(neighbour);
}
}
return neighbours;
}
/// <summary>
/// Performs a XML-RPC query against the grid server returning mapblock information in the specified coordinates
/// </summary>
/// <remarks>REDUNDANT - OGS1 is to be phased out in favour of OGS2</remarks>
/// <param name="minX">Minimum X value</param>
/// <param name="minY">Minimum Y value</param>
/// <param name="maxX">Maximum X value</param>
/// <param name="maxY">Maximum Y value</param>
/// <returns>Hashtable of hashtables containing map data elements</returns>
private Hashtable MapBlockQuery(int minX, int minY, int maxX, int maxY)
{
Hashtable param = new Hashtable();
param["xmin"] = minX;
param["ymin"] = minY;
param["xmax"] = maxX;
param["ymax"] = maxY;
IList parameters = new ArrayList();
parameters.Add(param);
try
{
XmlRpcRequest req = new XmlRpcRequest("map_block", parameters);
XmlRpcResponse resp = req.Send(serversInfo.GridURL, 10000);
Hashtable respData = (Hashtable) resp.Value;
return respData;
}
catch (Exception e)
{
m_log.Error("MapBlockQuery XMLRPC failure: " + e);
return new Hashtable();
}
}
/// <summary>
/// A ping / version check
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public XmlRpcResponse PingCheckReply(XmlRpcRequest request, IPEndPoint remoteClient)
{
XmlRpcResponse response = new XmlRpcResponse();
Hashtable respData = new Hashtable();
respData["online"] = "true";
m_localBackend.PingCheckReply(respData);
response.Value = respData;
return response;
}
/// <summary>
/// Received from the user server when a user starts logging in. This call allows
/// the region to prepare for direct communication from the client. Sends back an empty
/// xmlrpc response on completion.
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public XmlRpcResponse ExpectUser(XmlRpcRequest request)
{
Hashtable requestData = (Hashtable) request.Params[0];
AgentCircuitData agentData = new AgentCircuitData();
agentData.SessionID = new UUID((string) requestData["session_id"]);
agentData.SecureSessionID = new UUID((string) requestData["secure_session_id"]);
agentData.firstname = (string) requestData["firstname"];
agentData.lastname = (string) requestData["lastname"];
agentData.AgentID = new UUID((string) requestData["agent_id"]);
agentData.circuitcode = Convert.ToUInt32(requestData["circuit_code"]);
agentData.CapsPath = (string)requestData["caps_path"];
ulong regionHandle = Convert.ToUInt64((string) requestData["regionhandle"]);
// Appearance
if (requestData["appearance"] != null)
agentData.Appearance = new AvatarAppearance((Hashtable)requestData["appearance"]);
m_log.DebugFormat(
"[CLIENT]: Told by user service to prepare for a connection from {0} {1} {2}, circuit {3}",
agentData.firstname, agentData.lastname, agentData.AgentID, agentData.circuitcode);
if (requestData.ContainsKey("child_agent") && requestData["child_agent"].Equals("1"))
{
//m_log.Debug("[CLIENT]: Child agent detected");
agentData.child = true;
}
else
{
//m_log.Debug("[CLIENT]: Main agent detected");
agentData.startpos =
new Vector3((float)Convert.ToDecimal((string)requestData["startpos_x"]),
(float)Convert.ToDecimal((string)requestData["startpos_y"]),
(float)Convert.ToDecimal((string)requestData["startpos_z"]));
agentData.child = false;
}
XmlRpcResponse resp = new XmlRpcResponse();
if (!RegionLoginsEnabled)
{
m_log.InfoFormat(
"[CLIENT]: Denying access for user {0} {1} because region login is currently disabled",
agentData.firstname, agentData.lastname);
Hashtable respdata = new Hashtable();
respdata["success"] = "FALSE";
respdata["reason"] = "region login currently disabled";
resp.Value = respdata;
}
else
{
RegionInfo[] regions = m_regionsOnInstance.ToArray();
bool banned = false;
for (int i = 0; i < regions.Length; i++)
{
if (regions[i] != null)
{
if (regions[i].RegionHandle == regionHandle)
{
if (regions[i].EstateSettings.IsBanned(agentData.AgentID))
{
banned = true;
break;
}
}
}
}
if (banned)
{
m_log.InfoFormat(
"[CLIENT]: Denying access for user {0} {1} because user is banned",
agentData.firstname, agentData.lastname);
Hashtable respdata = new Hashtable();
respdata["success"] = "FALSE";
respdata["reason"] = "banned";
resp.Value = respdata;
}
else
{
m_localBackend.TriggerExpectUser(regionHandle, agentData);
Hashtable respdata = new Hashtable();
respdata["success"] = "TRUE";
resp.Value = respdata;
}
}
return resp;
}
// Grid Request Processing
/// <summary>
/// Ooops, our Agent must be dead if we're getting this request!
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public XmlRpcResponse LogOffUser(XmlRpcRequest request)
{
m_log.Debug("[CONNECTION DEBUGGING]: LogOff User Called");
Hashtable requestData = (Hashtable)request.Params[0];
string message = (string)requestData["message"];
UUID agentID = UUID.Zero;
UUID RegionSecret = UUID.Zero;
UUID.TryParse((string)requestData["agent_id"], out agentID);
UUID.TryParse((string)requestData["region_secret"], out RegionSecret);
ulong regionHandle = Convert.ToUInt64((string)requestData["regionhandle"]);
m_localBackend.TriggerLogOffUser(regionHandle, agentID, RegionSecret,message);
return new XmlRpcResponse();
}
public void NoteDeadRegion(ulong regionhandle)
{
lock (m_deadRegionCache)
{
if (m_deadRegionCache.ContainsKey(regionhandle))
{
m_deadRegionCache[regionhandle] = m_deadRegionCache[regionhandle] + 1;
}
else
{
m_deadRegionCache.Add(regionhandle, 1);
}
}
}
public LandData RequestLandData (ulong regionHandle, uint x, uint y)
{
m_log.DebugFormat("[OGS1 GRID SERVICES] requests land data in {0}, at {1}, {2}",
regionHandle, x, y);
LandData landData = m_localBackend.RequestLandData(regionHandle, x, y);
if (landData == null)
{
Hashtable hash = new Hashtable();
hash["region_handle"] = regionHandle.ToString();
hash["x"] = x.ToString();
hash["y"] = y.ToString();
IList paramList = new ArrayList();
paramList.Add(hash);
try
{
// this might be cached, as we probably requested it just a moment ago...
RegionInfo info = RequestNeighbourInfo(regionHandle);
if (info != null) // just to be sure
{
XmlRpcRequest request = new XmlRpcRequest("land_data", paramList);
string uri = "http://" + info.ExternalEndPoint.Address + ":" + info.HttpPort + "/";
XmlRpcResponse response = request.Send(uri, 10000);
if (response.IsFault)
{
m_log.ErrorFormat("[OGS1 GRID SERVICES] remote call returned an error: {0}", response.FaultString);
}
else
{
hash = (Hashtable)response.Value;
try
{
landData = new LandData();
landData.AABBMax = Vector3.Parse((string)hash["AABBMax"]);
landData.AABBMin = Vector3.Parse((string)hash["AABBMin"]);
landData.Area = Convert.ToInt32(hash["Area"]);
landData.AuctionID = Convert.ToUInt32(hash["AuctionID"]);
landData.Description = (string)hash["Description"];
landData.Flags = Convert.ToUInt32(hash["Flags"]);
landData.GlobalID = new UUID((string)hash["GlobalID"]);
landData.Name = (string)hash["Name"];
landData.OwnerID = new UUID((string)hash["OwnerID"]);
landData.SalePrice = Convert.ToInt32(hash["SalePrice"]);
landData.SnapshotID = new UUID((string)hash["SnapshotID"]);
landData.UserLocation = Vector3.Parse((string)hash["UserLocation"]);
m_log.DebugFormat("[OGS1 GRID SERVICES] Got land data for parcel {0}", landData.Name);
}
catch (Exception e)
{
m_log.Error("[OGS1 GRID SERVICES] Got exception while parsing land-data:", e);
}
}
}
else m_log.WarnFormat("[OGS1 GRID SERVICES] Couldn't find region with handle {0}", regionHandle);
}
catch (Exception e)
{
m_log.ErrorFormat("[OGS1 GRID SERVICES] Couldn't contact region {0}: {1}", regionHandle, e);
}
}
return landData;
}
// Grid Request Processing
/// <summary>
/// Someone asked us about parcel-information
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public XmlRpcResponse LandData(XmlRpcRequest request, IPEndPoint remoteClient)
{
Hashtable requestData = (Hashtable)request.Params[0];
ulong regionHandle = Convert.ToUInt64(requestData["region_handle"]);
uint x = Convert.ToUInt32(requestData["x"]);
uint y = Convert.ToUInt32(requestData["y"]);
m_log.DebugFormat("[OGS1 GRID SERVICES]: Got XML reqeuest for land data at {0}, {1} in region {2}", x, y, regionHandle);
LandData landData = m_localBackend.RequestLandData(regionHandle, x, y);
Hashtable hash = new Hashtable();
if (landData != null)
{
// for now, only push out the data we need for answering a ParcelInfoReqeust
hash["AABBMax"] = landData.AABBMax.ToString();
hash["AABBMin"] = landData.AABBMin.ToString();
hash["Area"] = landData.Area.ToString();
hash["AuctionID"] = landData.AuctionID.ToString();
hash["Description"] = landData.Description;
hash["Flags"] = landData.Flags.ToString();
hash["GlobalID"] = landData.GlobalID.ToString();
hash["Name"] = landData.Name;
hash["OwnerID"] = landData.OwnerID.ToString();
hash["SalePrice"] = landData.SalePrice.ToString();
hash["SnapshotID"] = landData.SnapshotID.ToString();
hash["UserLocation"] = landData.UserLocation.ToString();
}
XmlRpcResponse response = new XmlRpcResponse();
response.Value = hash;
return response;
}
public List<RegionInfo> RequestNamedRegions (string name, int maxNumber)
{
// no asking of the local backend first, here, as we have to ask the gridserver anyway.
Hashtable hash = new Hashtable();
hash["name"] = name;
hash["maxNumber"] = maxNumber.ToString();
IList paramList = new ArrayList();
paramList.Add(hash);
Hashtable result = XmlRpcSearchForRegionByName(paramList);
if (result == null) return null;
uint numberFound = Convert.ToUInt32(result["numFound"]);
List<RegionInfo> infos = new List<RegionInfo>();
for (int i = 0; i < numberFound; ++i)
{
string prefix = "region" + i + ".";
RegionInfo info = buildRegionInfo(result, prefix);
infos.Add(info);
}
return infos;
}
private RegionInfo buildRegionInfo(Hashtable responseData, string prefix)
{
uint regX = Convert.ToUInt32((string) responseData[prefix + "region_locx"]);
uint regY = Convert.ToUInt32((string) responseData[prefix + "region_locy"]);
string internalIpStr = (string) responseData[prefix + "sim_ip"];
uint port = Convert.ToUInt32(responseData[prefix + "sim_port"]);
IPEndPoint neighbourInternalEndPoint = new IPEndPoint(Util.GetHostFromDNS(internalIpStr), (int) port);
RegionInfo regionInfo = new RegionInfo(regX, regY, neighbourInternalEndPoint, internalIpStr);
regionInfo.RemotingPort = Convert.ToUInt32((string) responseData[prefix + "remoting_port"]);
regionInfo.RemotingAddress = internalIpStr;
if (responseData.ContainsKey(prefix + "http_port"))
{
regionInfo.HttpPort = Convert.ToUInt32((string) responseData[prefix + "http_port"]);
}
regionInfo.RegionID = new UUID((string) responseData[prefix + "region_UUID"]);
regionInfo.RegionName = (string) responseData[prefix + "region_name"];
regionInfo.RegionSettings.TerrainImageID = new UUID((string) responseData[prefix + "map_UUID"]);
return regionInfo;
}
private Hashtable XmlRpcSearchForRegionByName(IList parameters)
{
try
{
XmlRpcRequest request = new XmlRpcRequest("search_for_region_by_name", parameters);
XmlRpcResponse resp = request.Send(serversInfo.GridURL, 10000);
Hashtable respData = (Hashtable) resp.Value;
if (respData != null && respData.Contains("faultCode"))
{
m_log.WarnFormat("[OGS1 GRID SERVICES]: Got an error while contacting GridServer: {0}", respData["faultString"]);
return null;
}
return respData;
}
catch (Exception e)
{
m_log.Error("[OGS1 GRID SERVICES]: MapBlockQuery XMLRPC failure: ", e);
return null;
}
}
}
}

View File

@ -141,5 +141,36 @@ namespace OpenSim.Region.Communications.OGS1
m_log.DebugFormat("[OGS1 USER SERVICES]: Verifying user session for " + userID);
return AuthClient.VerifySession(GetUserServerURL(userID), userID, sessionID);
}
public override bool AuthenticateUserByPassword(UUID userID, string password)
{
Hashtable param = new Hashtable();
param["user_uuid"] = userID.ToString();
param["password"] = password;
IList parameters = new ArrayList();
parameters.Add(param);
XmlRpcRequest req = new XmlRpcRequest("authenticate_user_by_password", parameters);
XmlRpcResponse resp = req.Send(m_commsManager.NetworkServersInfo.UserURL, 30000);
// Temporary measure to deal with older services
if (resp.IsFault && resp.FaultCode == XmlRpcErrorCodes.SERVER_ERROR_METHOD)
{
throw new Exception(
String.Format(
"XMLRPC method 'authenticate_user_by_password' not yet implemented by user service at {0}",
m_commsManager.NetworkServersInfo.UserURL));
}
Hashtable respData = (Hashtable)resp.Value;
if ((string)respData["auth_user"] == "TRUE")
{
return true;
}
else
{
return false;
}
}
}
}

View File

@ -142,7 +142,7 @@ namespace Flotsam.RegionModules.AssetCache
m_CacheDirectory = assetConfig.GetString("CacheDirectory", m_DefaultCacheDirectory);
m_log.InfoFormat("[FLOTSAM ASSET CACHE]: Cache Directory", m_DefaultCacheDirectory);
m_MemoryCacheEnabled = assetConfig.GetBoolean("MemoryCacheEnabled", true);
m_MemoryCacheEnabled = assetConfig.GetBoolean("MemoryCacheEnabled", false);
m_MemoryExpiration = TimeSpan.FromHours(assetConfig.GetDouble("MemoryCacheTimeout", m_DefaultMemoryExpiration));
#if WAIT_ON_INPROGRESS_REQUESTS
@ -150,7 +150,7 @@ namespace Flotsam.RegionModules.AssetCache
#endif
m_LogLevel = assetConfig.GetInt("LogLevel", 1);
m_HitRateDisplay = (ulong)assetConfig.GetInt("HitRateDisplay", 1);
m_HitRateDisplay = (ulong)assetConfig.GetInt("HitRateDisplay", 1000);
m_FileExpiration = TimeSpan.FromHours(assetConfig.GetDouble("FileCacheTimeout", m_DefaultFileExpiration));
m_FileExpirationCleanupTimer = TimeSpan.FromHours(assetConfig.GetDouble("FileCleanupTimer", m_DefaultFileExpiration));

View File

@ -40,6 +40,7 @@ using OpenSim.Framework.Communications.Cache;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Services.Interfaces;
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
namespace OpenSim.Region.CoreModules.Avatar.Friends
{
@ -108,7 +109,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
private Dictionary<ulong, Scene> m_scenes = new Dictionary<ulong,Scene>();
private IMessageTransferModule m_TransferModule = null;
private IGridServices m_gridServices = null;
private IGridService m_gridServices = null;
#region IRegionModule Members
@ -142,7 +143,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
if (m_scenes.Count > 0)
{
m_TransferModule = m_initialScene.RequestModuleInterface<IMessageTransferModule>();
m_gridServices = m_initialScene.CommsManager.GridService;
m_gridServices = m_initialScene.GridService;
}
if (m_TransferModule == null)
m_log.Error("[FRIENDS]: Unable to find a message transfer module, friendship offers will not work");
@ -171,7 +172,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
List<UUID> tpdAway = new List<UUID>();
// destRegionHandle is a region on another server
RegionInfo info = m_gridServices.RequestNeighbourInfo(destRegionHandle);
uint x = 0, y = 0;
Utils.LongToUInts(destRegionHandle, out x, out y);
GridRegion info = m_gridServices.GetRegionByPosition(m_initialScene.RegionInfo.ScopeID, (int)x, (int)y);
if (info != null)
{
string httpServer = "http://" + info.ExternalEndPoint.Address + ":" + info.HttpPort + "/presence_update_bulk";
@ -223,7 +226,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
public bool TriggerTerminateFriend(ulong destRegionHandle, UUID agentID, UUID exFriendID)
{
// destRegionHandle is a region on another server
RegionInfo info = m_gridServices.RequestNeighbourInfo(destRegionHandle);
uint x = 0, y = 0;
Utils.LongToUInts(destRegionHandle, out x, out y);
GridRegion info = m_gridServices.GetRegionByPosition(m_initialScene.RegionInfo.ScopeID, (int)x, (int)y);
if (info == null)
{
m_log.WarnFormat("[OGS1 GRID SERVICES]: Couldn't find region {0}", destRegionHandle);

View File

@ -36,6 +36,7 @@ using OpenMetaverse;
using OpenSim.Framework;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
{
@ -497,7 +498,10 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
{
if (upd.AgentOnline)
{
RegionInfo reginfo = m_Scenes[0].SceneGridService.RequestNeighbouringRegionInfo(upd.Handle);
uint x = 0, y = 0;
Utils.LongToUInts(upd.Handle, out x, out y);
GridRegion reginfo = m_Scenes[0].GridService.GetRegionByPosition(m_Scenes[0].RegionInfo.ScopeID,
(int)x, (int)y);
if (reginfo != null)
{
Hashtable msgdata = ConvertGridInstantMessageToXMLRPC(im);
@ -559,7 +563,7 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
/// <param name="reginfo">RegionInfo we pull the data out of to send the request to</param>
/// <param name="xmlrpcdata">The Instant Message data Hashtable</param>
/// <returns>Bool if the message was successfully delivered at the other side.</returns>
protected virtual bool doIMSending(RegionInfo reginfo, Hashtable xmlrpcdata)
protected virtual bool doIMSending(GridRegion reginfo, Hashtable xmlrpcdata)
{
ArrayList SendParams = new ArrayList();

View File

@ -35,6 +35,7 @@ using OpenMetaverse;
using OpenSim.Framework;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
{
@ -171,7 +172,10 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
{
// TODO this is the old messaging-server protocol; only the regionHandle is available.
// Fetch region-info to get the id
RegionInfo regionInfo = m_initialScene.RequestNeighbouringRegionInfo(info.regionHandle);
uint x = 0, y = 0;
Utils.LongToUInts(info.regionHandle, out x, out y);
GridRegion regionInfo = m_initialScene.GridService.GetRegionByPosition(m_initialScene.RegionInfo.ScopeID,
(int)x, (int)y);
regionID = regionInfo.RegionID;
}
result[indices[i]] = new PresenceInfo(uuids[i], regionID);
@ -349,6 +353,9 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
private void NotifyMessageServerOfShutdown(Scene scene)
{
if (m_Scenes[0].CommsManager.NetworkServersInfo.MessagingURL == string.Empty)
return;
Hashtable xmlrpcdata = new Hashtable();
xmlrpcdata["RegionUUID"] = scene.RegionInfo.RegionID.ToString();
ArrayList SendParams = new ArrayList();
@ -372,6 +379,9 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
private void NotifyMessageServerOfAgentLocation(UUID agentID, UUID region, ulong regionHandle)
{
if (m_Scenes[0].CommsManager.NetworkServersInfo.MessagingURL == string.Empty)
return;
Hashtable xmlrpcdata = new Hashtable();
xmlrpcdata["AgentID"] = agentID.ToString();
xmlrpcdata["RegionUUID"] = region.ToString();
@ -397,6 +407,9 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
private void NotifyMessageServerOfAgentLeaving(UUID agentID, UUID region, ulong regionHandle)
{
if (m_Scenes[0].CommsManager.NetworkServersInfo.MessagingURL == string.Empty)
return;
Hashtable xmlrpcdata = new Hashtable();
xmlrpcdata["AgentID"] = agentID.ToString();
xmlrpcdata["RegionUUID"] = region.ToString();

View File

@ -118,6 +118,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
protected void ReceivedAllAssets(ICollection<UUID> assetsFoundUuids, ICollection<UUID> assetsNotFoundUuids)
{
// We're almost done. Just need to write out the control file now
m_archiveWriter.WriteFile(ArchiveConstants.CONTROL_FILE_PATH, Create0p1ControlFile());
m_log.InfoFormat("[ARCHIVER]: Added control file to archive.");
Exception reportedException = null;
bool succeeded = true;
@ -320,7 +324,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
SaveInvFolder(inventoryFolder, ArchiveConstants.INVENTORY_PATH, !foundStar);
}
SaveUsers();
// Don't put all this profile information into the archive right now.
//SaveUsers();
new AssetsRequest(
new AssetsArchiver(m_archiveWriter), m_assetUuids.Keys,
m_scene.AssetService, ReceivedAllAssets).Execute();
@ -409,5 +415,29 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
ArchiveConstants.INVENTORY_NODE_NAME_COMPONENT_SEPARATOR,
id);
}
/// <summary>
/// Create the control file for a 0.1 version archive
/// </summary>
/// <returns></returns>
public static string Create0p1ControlFile()
{
StringWriter sw = new StringWriter();
XmlTextWriter xtw = new XmlTextWriter(sw);
xtw.Formatting = Formatting.Indented;
xtw.WriteStartDocument();
xtw.WriteStartElement("archive");
xtw.WriteAttributeString("major_version", "0");
xtw.WriteAttributeString("minor_version", "1");
xtw.WriteEndElement();
xtw.Flush();
xtw.Close();
String s = sw.ToString();
sw.Close();
return s;
}
}
}

View File

@ -264,7 +264,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
/// <param name="cmdparams"></param>
protected void HandleSaveInvConsoleCommand(string module, string[] cmdparams)
{
if (cmdparams.Length < 5)
if (cmdparams.Length < 6)
{
m_log.Error(
"[INVENTORY ARCHIVER]: usage is save iar <first name> <last name> <inventory path> <user password> [<save file path>]");
@ -324,6 +324,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
protected CachedUserInfo GetUserInfo(string firstName, string lastName, string pass)
{
CachedUserInfo userInfo = m_aScene.CommsManager.UserProfileCacheService.GetUserDetails(firstName, lastName);
//m_aScene.CommsManager.UserService.GetUserProfile(firstName, lastName);
if (null == userInfo)
{
m_log.ErrorFormat(
@ -332,16 +333,25 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
return null;
}
string md5PasswdHash = Util.Md5Hash(Util.Md5Hash(pass) + ":" + userInfo.UserProfile.PasswordSalt);
if (userInfo.UserProfile.PasswordHash != md5PasswdHash)
try
{
m_log.ErrorFormat(
"[INVENTORY ARCHIVER]: Password for user {0} {1} incorrect. Please try again.",
firstName, lastName);
if (m_aScene.CommsManager.UserService.AuthenticateUserByPassword(userInfo.UserProfile.ID, pass))
{
return userInfo;
}
else
{
m_log.ErrorFormat(
"[INVENTORY ARCHIVER]: Password for user {0} {1} incorrect. Please try again.",
firstName, lastName);
return null;
}
}
catch (Exception e)
{
m_log.ErrorFormat("[INVENTORY ARCHIVER]: Could not authenticate password, {0}", e.Message);
return null;
}
return userInfo;
}
/// <summary>
@ -361,9 +371,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
{
foreach (InventoryNodeBase node in loadedNodes)
{
m_log.DebugFormat(
"[INVENTORY ARCHIVER]: Notifying {0} of loaded inventory node {1}",
user.Name, node.Name);
// m_log.DebugFormat(
// "[INVENTORY ARCHIVER]: Notifying {0} of loaded inventory node {1}",
// user.Name, node.Name);
user.ControllingClient.SendBulkUpdateInventory(node);
}

View File

@ -316,7 +316,7 @@ namespace OpenSim.Region.CoreModules.Framework.EventQueue
// This will persist this beyond the expiry of the caps handlers
MainServer.Instance.AddPollServiceHTTPHandler(
capsBase + EventQueueGetUUID.ToString() + "/", EventQueuePath2, new PollServiceEventArgs(HasEvents, GetEvents, NoEvents, agentID));
capsBase + EventQueueGetUUID.ToString() + "/", EventQueuePoll, new PollServiceEventArgs(null, HasEvents, GetEvents, NoEvents, agentID));
Random rnd = new Random(Environment.TickCount);
lock (m_ids)
@ -326,7 +326,7 @@ namespace OpenSim.Region.CoreModules.Framework.EventQueue
}
}
public bool HasEvents(UUID agentID)
public bool HasEvents(UUID requestID, UUID agentID)
{
// Don't use this, because of race conditions at agent closing time
//Queue<OSD> queue = TryGetQueue(agentID);
@ -343,14 +343,14 @@ namespace OpenSim.Region.CoreModules.Framework.EventQueue
return false;
}
public Hashtable GetEvents(UUID pAgentId, string request)
public Hashtable GetEvents(UUID requestID, UUID pAgentId, string request)
{
Queue<OSD> queue = TryGetQueue(pAgentId);
OSD element;
lock (queue)
{
if (queue.Count == 0)
return NoEvents();
return NoEvents(requestID, pAgentId);
element = queue.Dequeue(); // 15s timeout
}
@ -398,7 +398,7 @@ namespace OpenSim.Region.CoreModules.Framework.EventQueue
//m_log.DebugFormat("[EVENTQUEUE]: sending response for {0} in region {1}: {2}", agentID, m_scene.RegionInfo.RegionName, responsedata["str_response_string"]);
}
public Hashtable NoEvents()
public Hashtable NoEvents(UUID requestID, UUID agentID)
{
Hashtable responsedata = new Hashtable();
responsedata["int_response_code"] = 502;
@ -491,6 +491,11 @@ namespace OpenSim.Region.CoreModules.Framework.EventQueue
return responsedata;
}
public Hashtable EventQueuePoll(Hashtable request)
{
return new Hashtable();
}
public Hashtable EventQueuePath2(Hashtable request)
{
string capuuid = (string)request["uri"]; //path.Replace("/CAPS/EQG/","");

View File

@ -1,208 +0,0 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* 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 OpenSimulator Project 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 THE DEVELOPERS ``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 THE CONTRIBUTORS 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.Net;
using System.Reflection;
using log4net;
using Nini.Config;
using OpenMetaverse;
using OpenSim.Data;
using OpenSim.Framework;
using OpenSim.Framework.Communications;
using OpenSim.Framework.Communications.Cache;
using OpenSim.Framework.Servers.HttpServer;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;
using Nwc.XmlRpc;
namespace OpenSim.Region.CoreModules.Framework.Services
{
public class RegionMapService : IRegionModule
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private static bool initialized = false;
private static bool enabled = false;
Scene m_scene;
//AssetService m_assetService;
#region IRegionModule interface
public void Initialise(Scene scene, IConfigSource config)
{
if (!initialized)
{
initialized = true;
m_scene = scene;
// This module is only on for hypergrid mode
enabled = config.Configs["Startup"].GetBoolean("hypergrid", false);
}
}
public void PostInitialise()
{
if (enabled)
{
m_log.Info("[RegionMapService]: Starting...");
//m_assetService = new AssetService(m_scene);
new GridService(m_scene);
}
}
public void Close()
{
}
public string Name
{
get { return "RegionMapService"; }
}
public bool IsSharedModule
{
get { return true; }
}
#endregion
}
public class GridService
{
// private IUserService m_userService;
private IGridServices m_gridService;
private bool m_doLookup = false;
public bool DoLookup
{
get { return m_doLookup; }
set { m_doLookup = value; }
}
private static readonly ILog m_log
= LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
public GridService(Scene m_scene)
{
AddHandlers(m_scene);
// m_userService = m_scene.CommsManager.UserService;
m_gridService = m_scene.CommsManager.GridService;
}
protected void AddHandlers(Scene m_scene)
{
// IAssetDataPlugin m_assetProvider
// = ((AssetServerBase)m_scene.CommsManager.AssetCache.AssetServer).AssetProviderPlugin;
IHttpServer httpServer = MainServer.Instance;
httpServer.AddXmlRPCHandler("simulator_data_request", XmlRpcSimulatorDataRequestMethod);
//m_httpServer.AddXmlRPCHandler("map_block", XmlRpcMapBlockMethod);
//m_httpServer.AddXmlRPCHandler("search_for_region_by_name", XmlRpcSearchForRegionMethod);
}
/// <summary>
/// Returns an XML RPC response to a simulator profile request
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public XmlRpcResponse XmlRpcSimulatorDataRequestMethod(XmlRpcRequest request, IPEndPoint remoteClient)
{
Hashtable requestData = (Hashtable)request.Params[0];
Hashtable responseData = new Hashtable();
RegionInfo simData = null;
if (requestData.ContainsKey("region_UUID"))
{
UUID regionID = new UUID((string)requestData["region_UUID"]);
simData = m_gridService.RequestNeighbourInfo(regionID); //.GetRegion(regionID);
if (simData == null)
{
m_log.WarnFormat("[HGGridService] didn't find region for regionID {0} from {1}",
regionID, request.Params.Count > 1 ? request.Params[1] : "unknwon source");
}
}
else if (requestData.ContainsKey("region_handle"))
{
//CFK: The if/else below this makes this message redundant.
//CFK: m_log.Info("requesting data for region " + (string) requestData["region_handle"]);
ulong regionHandle = Convert.ToUInt64((string)requestData["region_handle"]);
simData = m_gridService.RequestNeighbourInfo(regionHandle); //m_gridDBService.GetRegion(regionHandle);
if (simData == null)
{
m_log.WarnFormat("[HGGridService] didn't find region for regionHandle {0} from {1}",
regionHandle, request.Params.Count > 1 ? request.Params[1] : "unknwon source");
}
}
else if (requestData.ContainsKey("region_name_search"))
{
string regionName = (string)requestData["region_name_search"];
List<RegionInfo> regInfos = m_gridService.RequestNamedRegions(regionName, 1);//m_gridDBService.GetRegion(regionName);
if (regInfos != null)
simData = regInfos[0];
if (simData == null)
{
m_log.WarnFormat("[HGGridService] didn't find region for regionName {0} from {1}",
regionName, request.Params.Count > 1 ? request.Params[1] : "unknwon source");
}
}
else m_log.Warn("[HGGridService] regionlookup without regionID, regionHandle or regionHame");
if (simData == null)
{
//Sim does not exist
responseData["error"] = "Sim does not exist";
}
else
{
m_log.Debug("[HGGridService]: found " + (string)simData.RegionName + " regionHandle = " +
(string)requestData["region_handle"]);
responseData["sim_ip"] = simData.ExternalEndPoint.Address.ToString();
responseData["sim_port"] = simData.ExternalEndPoint.Port.ToString();
//responseData["server_uri"] = simData.serverURI;
responseData["http_port"] = simData.HttpPort.ToString();
//responseData["remoting_port"] = simData.remotingPort.ToString();
responseData["region_locx"] = simData.RegionLocX.ToString();
responseData["region_locy"] = simData.RegionLocY.ToString();
responseData["region_UUID"] = simData.RegionID.ToString();
responseData["region_name"] = simData.RegionName;
responseData["region_secret"] = simData.regionSecret;
}
XmlRpcResponse response = new XmlRpcResponse();
response.Value = responseData;
return response;
}
}
}

View File

@ -61,7 +61,7 @@ namespace OpenSim.Region.CoreModules.Hypergrid
{
if (m_firstScene != null)
{
return m_firstScene.CommsManager.GridService.RegionLoginsEnabled;
return m_firstScene.SceneGridService.RegionLoginsEnabled;
}
else
{

View File

@ -34,6 +34,7 @@ using OpenSim.Framework;
using OpenSim.Region.CoreModules.World.WorldMap;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
namespace OpenSim.Region.CoreModules.Hypergrid
{
@ -59,7 +60,17 @@ namespace OpenSim.Region.CoreModules.Hypergrid
protected override void GetAndSendBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY, uint flag)
{
List<MapBlockData> mapBlocks = m_scene.SceneGridService.RequestNeighbourMapBlocks(minX - 4, minY - 4, maxX + 4, maxY + 4);
List<MapBlockData> mapBlocks = new List<MapBlockData>();
List<GridRegion> regions = m_scene.GridService.GetRegionRange(m_scene.RegionInfo.ScopeID,
(minX - 4) * (int)Constants.RegionSize, (maxX + 4) * (int)Constants.RegionSize,
(minY - 4) * (int)Constants.RegionSize, (maxY + 4) * (int)Constants.RegionSize);
foreach (GridRegion r in regions)
{
MapBlockData block = new MapBlockData();
MapBlockFromGridRegion(block, r);
mapBlocks.Add(block);
}
// Different from super
FillInMap(mapBlocks, minX, minY, maxX, maxY);

View File

@ -38,11 +38,15 @@
<RegionModule id="RemoteLandServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Land.RemoteLandServicesConnector" />
<RegionModule id="LocalInterregionComms" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion.LocalInterregionComms" />
<RegionModule id="RESTInterregionComms" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion.RESTInterregionComms" />
<RegionModule id="LocalGridServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid.LocalGridServicesConnector" />
<RegionModule id="RemoteGridServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid.RemoteGridServicesConnector" />
<RegionModule id="HGGridConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid.HGGridConnector" />
<!-- Service connectors IN modules -->
<RegionModule id="AssetServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Asset.AssetServiceInConnectorModule" />
<RegionModule id="InventoryServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Inventory.InventoryServiceInConnectorModule" />
<RegionModule id="LandServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Land.LandServiceInConnectorModule" />
<RegionModule id="NeighbourServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Neighbour.NeighbourServiceInConnectorModule" /> \
<RegionModule id="HypergridServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Grid.HypergridServiceInConnectorModule" /> \
</Extension>

View File

@ -55,14 +55,19 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
public UUID requestID;
public Dictionary<string, string> headers;
public string body;
public int responseCode;
public string responseBody;
public ManualResetEvent ev;
public bool requestDone;
public int startTime;
public string uri;
}
public class UrlModule : ISharedRegionModule, IUrlModule
{
// private static readonly ILog m_log =
// LogManager.GetLogger(
// MethodBase.GetCurrentMethod().DeclaringType);
private static readonly ILog m_log =
LogManager.GetLogger(
MethodBase.GetCurrentMethod().DeclaringType);
private Dictionary<UUID, UrlData> m_RequestMap =
new Dictionary<UUID, UrlData>();
@ -70,15 +75,23 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
private Dictionary<string, UrlData> m_UrlMap =
new Dictionary<string, UrlData>();
private int m_TotalUrls = 100;
private IHttpServer m_HttpServer = null;
private string m_ExternalHostNameForLSL = "";
public Type ReplaceableInterface
{
get { return null; }
}
private Hashtable HandleHttpPoll(Hashtable request)
{
return new Hashtable();
}
public string Name
{
get { return "UrlModule"; }
@ -86,6 +99,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
public void Initialise(IConfigSource config)
{
m_ExternalHostNameForLSL = config.Configs["Network"].GetString("ExternalHostNameForLSL", System.Environment.MachineName);
}
public void PostInitialise()
@ -117,7 +131,6 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
public void Close()
{
}
public UUID RequestURL(IScriptModule engine, SceneObjectPart host, UUID itemID)
{
UUID urlcode = UUID.Random();
@ -129,7 +142,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_DENIED", "" });
return urlcode;
}
string url = "http://"+System.Environment.MachineName+":"+m_HttpServer.Port.ToString()+"/lslhttp/"+urlcode.ToString()+"/";
string url = "http://" + m_ExternalHostNameForLSL + ":" + m_HttpServer.Port.ToString() + "/lslhttp/" + urlcode.ToString() + "/";
UrlData urlData = new UrlData();
urlData.hostID = host.UUID;
@ -139,9 +152,14 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
urlData.urlcode = urlcode;
urlData.requests = new Dictionary<UUID, RequestData>();
m_UrlMap[url] = urlData;
m_HttpServer.AddHTTPHandler("/lslhttp/"+urlcode.ToString()+"/", HttpRequestHandler);
string uri = "/lslhttp/" + urlcode.ToString() + "/";
m_HttpServer.AddPollServiceHTTPHandler(uri,HandleHttpPoll,
new PollServiceEventArgs(HttpRequestHandler,HasEvents, GetEvents, NoEvents,
urlcode));
engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_GRANTED", url });
}
@ -165,7 +183,9 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
UrlData data;
if (!m_UrlMap.TryGetValue(url, out data))
{
return;
}
foreach (UUID req in data.requests.Keys)
m_RequestMap.Remove(req);
@ -177,10 +197,33 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
public void HttpResponse(UUID request, int status, string body)
{
if (m_RequestMap.ContainsKey(request))
{
UrlData urlData = m_RequestMap[request];
urlData.requests[request].responseCode = status;
urlData.requests[request].responseBody = body;
//urlData.requests[request].ev.Set();
urlData.requests[request].requestDone =true;
}
else
{
m_log.Info("[HttpRequestHandler] There is no http-in request with id " + request.ToString());
}
}
public string GetHttpHeader(UUID request, string header)
public string GetHttpHeader(UUID requestId, string header)
{
if (m_RequestMap.ContainsKey(requestId))
{
UrlData urlData=m_RequestMap[requestId];
string value;
if (urlData.requests[requestId].headers.TryGetValue(header,out value))
return value;
}
else
{
m_log.Warn("[HttpRequestHandler] There was no http-in request with id " + requestId);
}
return String.Empty;
}
@ -233,27 +276,215 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
}
}
private void RemoveUrl(UrlData data)
{
m_HttpServer.RemoveHTTPHandler("", "/lslhttp/"+data.urlcode.ToString()+"/");
}
private Hashtable HttpRequestHandler(Hashtable request)
private Hashtable NoEvents(UUID requestID, UUID sessionID)
{
string uri = request["uri"].ToString();
//A solution to this ugly mess would be to use only the /lslhttp/<UUID>/ part of the URI as the key.
UrlData url = m_UrlMap["http://"+System.Environment.MachineName+":"+m_HttpServer.Port.ToString()+uri];
//UUID.Random() below is a hack! Eventually we will do HTTP requests and responses properly.
url.engine.PostScriptEvent(url.itemID, "http_request", new Object[] { UUID.Random().ToString(), request["http-method"].ToString(), request["body"].ToString() });
Hashtable response = new Hashtable();
response["int_response_code"] = 200;
response["str_response_string"] = "This is a generic response as OpenSim does not yet support proper responses. Your request has been passed to the object.";
UrlData url;
lock (m_RequestMap)
{
if (!m_RequestMap.ContainsKey(requestID))
return response;
url = m_RequestMap[requestID];
}
if (System.Environment.TickCount - url.requests[requestID].startTime > 25000)
{
response["int_response_code"] = 500;
response["str_response_string"] = "Script timeout";
response["content_type"] = "text/plain";
response["keepalive"] = false;
response["reusecontext"] = false;
//remove from map
lock (url)
{
url.requests.Remove(requestID);
m_RequestMap.Remove(requestID);
}
return response;
}
return response;
}
private bool HasEvents(UUID requestID, UUID sessionID)
{
UrlData url=null;
lock (m_RequestMap)
{
if (!m_RequestMap.ContainsKey(requestID))
{
return false;
}
url = m_RequestMap[requestID];
if (!url.requests.ContainsKey(requestID))
{
return false;
}
}
if (System.Environment.TickCount-url.requests[requestID].startTime>25000)
{
return true;
}
if (url.requests[requestID].requestDone)
return true;
else
return false;
}
private Hashtable GetEvents(UUID requestID, UUID sessionID, string request)
{
UrlData url = null;
RequestData requestData = null;
lock (m_RequestMap)
{
if (!m_RequestMap.ContainsKey(requestID))
return NoEvents(requestID,sessionID);
url = m_RequestMap[requestID];
requestData = url.requests[requestID];
}
if (!requestData.requestDone)
return NoEvents(requestID,sessionID);
Hashtable response = new Hashtable();
if (System.Environment.TickCount - requestData.startTime > 25000)
{
response["int_response_code"] = 500;
response["str_response_string"] = "Script timeout";
response["content_type"] = "text/plain";
response["keepalive"] = false;
response["reusecontext"] = false;
return response;
}
//put response
response["int_response_code"] = requestData.responseCode;
response["str_response_string"] = requestData.responseBody;
response["content_type"] = "text/plain";
response["keepalive"] = false;
response["reusecontext"] = false;
//remove from map
lock (url)
{
url.requests.Remove(requestID);
m_RequestMap.Remove(requestID);
}
return response;
}
public void HttpRequestHandler(UUID requestID, Hashtable request)
{
lock (request)
{
string uri = request["uri"].ToString();
try
{
Hashtable headers = (Hashtable)request["headers"];
// string uri_full = "http://" + m_ExternalHostNameForLSL + ":" + m_HttpServer.Port.ToString() + uri;// "/lslhttp/" + urlcode.ToString() + "/";
int pos1 = uri.IndexOf("/");// /lslhttp
int pos2 = uri.IndexOf("/", pos1 + 1);// /lslhttp/
int pos3 = uri.IndexOf("/", pos2 + 1);// /lslhttp/<UUID>/
string uri_tmp = uri.Substring(0, pos3 + 1);
//HTTP server code doesn't provide us with QueryStrings
string pathInfo;
string queryString;
queryString = "";
pathInfo = uri.Substring(pos3);
UrlData url = m_UrlMap["http://" + m_ExternalHostNameForLSL + ":" + m_HttpServer.Port.ToString() + uri_tmp];
//for llGetHttpHeader support we need to store original URI here
//to make x-path-info / x-query-string / x-script-url / x-remote-ip headers
//as per http://wiki.secondlife.com/wiki/LlGetHTTPHeader
RequestData requestData = new RequestData();
requestData.requestID = requestID;
requestData.requestDone = false;
requestData.startTime = System.Environment.TickCount;
requestData.uri = uri;
if (requestData.headers == null)
requestData.headers = new Dictionary<string, string>();
foreach (DictionaryEntry header in headers)
{
string key = (string)header.Key;
string value = (string)header.Value;
requestData.headers.Add(key, value);
}
foreach (DictionaryEntry de in request)
{
if (de.Key.ToString() == "querystringkeys")
{
System.String[] keys = (System.String[])de.Value;
foreach (String key in keys)
{
if (request.ContainsKey(key))
{
string val = (String)request[key];
queryString = queryString + key + "=" + val + "&";
}
}
if (queryString.Length > 1)
queryString = queryString.Substring(0, queryString.Length - 1);
}
}
//if this machine is behind DNAT/port forwarding, currently this is being
//set to address of port forwarding router
requestData.headers["x-remote-ip"] = requestData.headers["remote_addr"];
requestData.headers["x-path-info"] = pathInfo;
requestData.headers["x-query-string"] = queryString;
requestData.headers["x-script-url"] = url.url;
requestData.ev = new ManualResetEvent(false);
lock (url.requests)
{
url.requests.Add(requestID, requestData);
}
lock (m_RequestMap)
{
//add to request map
m_RequestMap.Add(requestID, url);
}
url.engine.PostScriptEvent(url.itemID, "http_request", new Object[] { requestID.ToString(), request["http-method"].ToString(), request["body"].ToString() });
//send initial response?
// Hashtable response = new Hashtable();
return;
}
catch (Exception we)
{
//Hashtable response = new Hashtable();
m_log.Warn("[HttpRequestHandler]: http-in request failed");
m_log.Warn(we.Message);
m_log.Warn(we.StackTrace);
}
}
}
private void OnScriptReset(uint localID, UUID itemID)
{
ScriptRemoved(itemID);

View File

@ -0,0 +1,134 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* 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 OpenSimulator Project 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 THE DEVELOPERS ``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 THE CONTRIBUTORS 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.Reflection;
using System.Collections.Generic;
using log4net;
using Nini.Config;
using OpenSim.Framework;
using OpenSim.Framework.Servers.HttpServer;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Server.Base;
using OpenSim.Server.Handlers.Base;
using OpenSim.Server.Handlers.Grid;
using OpenSim.Services.Interfaces;
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Grid
{
public class HypergridServiceInConnectorModule : ISharedRegionModule
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private static bool m_Enabled = false;
private IConfigSource m_Config;
bool m_Registered = false;
HypergridServiceInConnector m_HypergridHandler;
#region IRegionModule interface
public void Initialise(IConfigSource config)
{
//// This module is only on for standalones in hypergrid mode
//enabled = (!config.Configs["Startup"].GetBoolean("gridmode", true)) &&
// config.Configs["Startup"].GetBoolean("hypergrid", true);
//m_log.DebugFormat("[RegionInventoryService]: enabled? {0}", enabled);
m_Config = config;
IConfig moduleConfig = config.Configs["Modules"];
if (moduleConfig != null)
{
m_Enabled = moduleConfig.GetBoolean("HypergridServiceInConnector", false);
if (m_Enabled)
{
m_log.Info("[HGGRID IN CONNECTOR]: Hypergrid Service In Connector enabled");
}
}
}
public void PostInitialise()
{
}
public void Close()
{
}
public Type ReplaceableInterface
{
get { return null; }
}
public string Name
{
get { return "HypergridService"; }
}
public void AddRegion(Scene scene)
{
if (!m_Enabled)
return;
}
public void RemoveRegion(Scene scene)
{
if (!m_Enabled)
return;
GridRegion rinfo = new GridRegion(scene.RegionInfo);
m_HypergridHandler.RemoveRegion(rinfo);
}
public void RegionLoaded(Scene scene)
{
if (!m_Enabled)
return;
if (!m_Registered)
{
m_Registered = true;
m_log.Info("[HypergridService]: Starting...");
Object[] args = new Object[] { m_Config, MainServer.Instance };
m_HypergridHandler = new HypergridServiceInConnector(m_Config, MainServer.Instance, scene.RequestModuleInterface<IHyperlinkService>());
//ServerUtils.LoadPlugin<HypergridServiceInConnector>("OpenSim.Server.Handlers.dll:HypergridServiceInConnector", args);
}
GridRegion rinfo = new GridRegion(scene.RegionInfo);
m_HypergridHandler.AddRegion(rinfo);
}
#endregion
}
}

View File

@ -121,7 +121,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Neighbour
#region INeighbourService
public bool HelloNeighbour(ulong regionHandle, RegionInfo thisRegion)
public GridRegion HelloNeighbour(ulong regionHandle, RegionInfo thisRegion)
{
m_log.DebugFormat("[NEIGHBOUR IN CONNECTOR]: HelloNeighbour from {0}, to {1}. Count = {2}",
thisRegion.RegionName, regionHandle, m_Scenes.Count);
@ -134,7 +134,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Neighbour
}
}
m_log.DebugFormat("[NEIGHBOUR IN CONNECTOR]: region handle {0} not found", regionHandle);
return false;
return null;
}
#endregion INeighbourService

View File

@ -0,0 +1,303 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* 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 OpenSimulator Project 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 THE DEVELOPERS ``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 THE CONTRIBUTORS 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.Reflection;
using System.Xml;
using log4net;
using Nini.Config;
using OpenSim.Framework;
//using OpenSim.Framework.Communications;
using OpenSim.Framework.Console;
using OpenSim.Region.Framework;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Region.Framework.Scenes.Hypergrid;
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
{
public class HGCommands
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private HGGridConnector m_HGGridConnector;
private Scene m_scene;
private static uint m_autoMappingX = 0;
private static uint m_autoMappingY = 0;
private static bool m_enableAutoMapping = false;
public HGCommands(HGGridConnector hgConnector, Scene scene)
{
m_HGGridConnector = hgConnector;
m_scene = scene;
}
//public static Scene CreateScene(RegionInfo regionInfo, AgentCircuitManager circuitManager, CommunicationsManager m_commsManager,
// StorageManager storageManager, ModuleLoader m_moduleLoader, ConfigSettings m_configSettings, OpenSimConfigSource m_config, string m_version)
//{
// HGSceneCommunicationService sceneGridService = new HGSceneCommunicationService(m_commsManager, HGServices);
// return
// new HGScene(
// regionInfo, circuitManager, m_commsManager, sceneGridService, storageManager,
// m_moduleLoader, false, m_configSettings.PhysicalPrim,
// m_configSettings.See_into_region_from_neighbor, m_config.Source, m_version);
//}
public void RunCommand(string module, string[] cmdparams)
{
List<string> args = new List<string>(cmdparams);
if (args.Count < 1)
return;
string command = args[0];
args.RemoveAt(0);
cmdparams = args.ToArray();
RunHGCommand(command, cmdparams);
}
private void RunHGCommand(string command, string[] cmdparams)
{
if (command.Equals("link-mapping"))
{
if (cmdparams.Length == 2)
{
try
{
m_autoMappingX = Convert.ToUInt32(cmdparams[0]);
m_autoMappingY = Convert.ToUInt32(cmdparams[1]);
m_enableAutoMapping = true;
}
catch (Exception)
{
m_autoMappingX = 0;
m_autoMappingY = 0;
m_enableAutoMapping = false;
}
}
}
else if (command.Equals("link-region"))
{
if (cmdparams.Length < 3)
{
if ((cmdparams.Length == 1) || (cmdparams.Length == 2))
{
LoadXmlLinkFile(cmdparams);
}
else
{
LinkRegionCmdUsage();
}
return;
}
if (cmdparams[2].Contains(":"))
{
// New format
int xloc, yloc;
string mapName;
try
{
xloc = Convert.ToInt32(cmdparams[0]);
yloc = Convert.ToInt32(cmdparams[1]);
mapName = cmdparams[2];
if (cmdparams.Length > 3)
for (int i = 3; i < cmdparams.Length; i++)
mapName += " " + cmdparams[i];
m_log.Info(">> MapName: " + mapName);
//internalPort = Convert.ToUInt32(cmdparams[4]);
//remotingPort = Convert.ToUInt32(cmdparams[5]);
}
catch (Exception e)
{
m_log.Warn("[HGrid] Wrong format for link-region command: " + e.Message);
LinkRegionCmdUsage();
return;
}
// Convert cell coordinates given by the user to meters
xloc = xloc * (int)Constants.RegionSize;
yloc = yloc * (int)Constants.RegionSize;
m_HGGridConnector.TryLinkRegionToCoords(m_scene, null, mapName, xloc, yloc);
}
else
{
// old format
GridRegion regInfo;
int xloc, yloc;
uint externalPort;
string externalHostName;
try
{
xloc = Convert.ToInt32(cmdparams[0]);
yloc = Convert.ToInt32(cmdparams[1]);
externalPort = Convert.ToUInt32(cmdparams[3]);
externalHostName = cmdparams[2];
//internalPort = Convert.ToUInt32(cmdparams[4]);
//remotingPort = Convert.ToUInt32(cmdparams[5]);
}
catch (Exception e)
{
m_log.Warn("[HGrid] Wrong format for link-region command: " + e.Message);
LinkRegionCmdUsage();
return;
}
// Convert cell coordinates given by the user to meters
xloc = xloc * (int)Constants.RegionSize;
yloc = yloc * (int)Constants.RegionSize;
if (m_HGGridConnector.TryCreateLink(m_scene, null, xloc, yloc, "", externalPort, externalHostName, out regInfo))
{
if (cmdparams.Length >= 5)
{
regInfo.RegionName = "";
for (int i = 4; i < cmdparams.Length; i++)
regInfo.RegionName += cmdparams[i] + " ";
}
}
}
return;
}
else if (command.Equals("unlink-region"))
{
if (cmdparams.Length < 1)
{
UnlinkRegionCmdUsage();
return;
}
if (m_HGGridConnector.TryUnlinkRegion(m_scene, cmdparams[0]))
m_log.InfoFormat("[HGrid]: Successfully unlinked {0}", cmdparams[0]);
else
m_log.InfoFormat("[HGrid]: Unable to unlink {0}, region not found", cmdparams[0]);
}
}
private void LoadXmlLinkFile(string[] cmdparams)
{
//use http://www.hgurl.com/hypergrid.xml for test
try
{
XmlReader r = XmlReader.Create(cmdparams[0]);
XmlConfigSource cs = new XmlConfigSource(r);
string[] excludeSections = null;
if (cmdparams.Length == 2)
{
if (cmdparams[1].ToLower().StartsWith("excludelist:"))
{
string excludeString = cmdparams[1].ToLower();
excludeString = excludeString.Remove(0, 12);
char[] splitter = { ';' };
excludeSections = excludeString.Split(splitter);
}
}
for (int i = 0; i < cs.Configs.Count; i++)
{
bool skip = false;
if ((excludeSections != null) && (excludeSections.Length > 0))
{
for (int n = 0; n < excludeSections.Length; n++)
{
if (excludeSections[n] == cs.Configs[i].Name.ToLower())
{
skip = true;
break;
}
}
}
if (!skip)
{
ReadLinkFromConfig(cs.Configs[i]);
}
}
}
catch (Exception e)
{
m_log.Error(e.ToString());
}
}
private void ReadLinkFromConfig(IConfig config)
{
GridRegion regInfo;
int xloc, yloc;
uint externalPort;
string externalHostName;
uint realXLoc, realYLoc;
xloc = Convert.ToInt32(config.GetString("xloc", "0"));
yloc = Convert.ToInt32(config.GetString("yloc", "0"));
externalPort = Convert.ToUInt32(config.GetString("externalPort", "0"));
externalHostName = config.GetString("externalHostName", "");
realXLoc = Convert.ToUInt32(config.GetString("real-xloc", "0"));
realYLoc = Convert.ToUInt32(config.GetString("real-yloc", "0"));
if (m_enableAutoMapping)
{
xloc = (int)((xloc % 100) + m_autoMappingX);
yloc = (int)((yloc % 100) + m_autoMappingY);
}
if (((realXLoc == 0) && (realYLoc == 0)) ||
(((realXLoc - xloc < 3896) || (xloc - realXLoc < 3896)) &&
((realYLoc - yloc < 3896) || (yloc - realYLoc < 3896))))
{
xloc = xloc * (int)Constants.RegionSize;
yloc = yloc * (int)Constants.RegionSize;
if (
m_HGGridConnector.TryCreateLink(m_scene, null, xloc, yloc, "", externalPort,
externalHostName, out regInfo))
{
regInfo.RegionName = config.GetString("localName", "");
}
}
}
private void LinkRegionCmdUsage()
{
m_log.Info("Usage: link-region <Xloc> <Yloc> <HostName>:<HttpPort>[:<RemoteRegionName>]");
m_log.Info("Usage: link-region <Xloc> <Yloc> <HostName> <HttpPort> [<LocalName>]");
m_log.Info("Usage: link-region <URI_of_xml> [<exclude>]");
}
private void UnlinkRegionCmdUsage()
{
m_log.Info("Usage: unlink-region <HostName>:<HttpPort>");
m_log.Info("Usage: unlink-region <LocalName>");
}
}
}

View File

@ -0,0 +1,795 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* 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 OpenSimulator Project 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 THE DEVELOPERS ``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 THE CONTRIBUTORS 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.Net;
using System.Reflection;
using System.Xml;
using OpenSim.Framework.Communications.Cache;
using OpenSim.Framework;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Region.Framework.Scenes.Hypergrid;
using OpenSim.Services.Interfaces;
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
using OpenSim.Server.Base;
using OpenSim.Services.Connectors.Grid;
using OpenSim.Framework.Console;
using OpenMetaverse;
using log4net;
using Nini.Config;
namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
{
public class HGGridConnector : ISharedRegionModule, IGridService, IHyperlinkService
{
private static readonly ILog m_log =
LogManager.GetLogger(
MethodBase.GetCurrentMethod().DeclaringType);
private static string LocalAssetServerURI, LocalInventoryServerURI, LocalUserServerURI;
private bool m_Enabled = false;
private bool m_Initialized = false;
private Scene m_aScene;
private Dictionary<ulong, Scene> m_LocalScenes = new Dictionary<ulong, Scene>();
private IGridService m_GridServiceConnector;
private HypergridServiceConnector m_HypergridServiceConnector;
// Hyperlink regions are hyperlinks on the map
protected Dictionary<UUID, GridRegion> m_HyperlinkRegions = new Dictionary<UUID, GridRegion>();
// Known regions are home regions of visiting foreign users.
// They are not on the map as static hyperlinks. They are dynamic hyperlinks, they go away when
// the visitor goes away. They are mapped to X=0 on the map.
// This is key-ed on agent ID
protected Dictionary<UUID, GridRegion> m_knownRegions = new Dictionary<UUID, GridRegion>();
protected Dictionary<UUID, ulong> m_HyperlinkHandles = new Dictionary<UUID, ulong>();
#region ISharedRegionModule
public Type ReplaceableInterface
{
get { return null; }
}
public string Name
{
get { return "HGGridServicesConnector"; }
}
public void Initialise(IConfigSource source)
{
IConfig moduleConfig = source.Configs["Modules"];
if (moduleConfig != null)
{
string name = moduleConfig.GetString("GridServices", "");
if (name == Name)
{
IConfig gridConfig = source.Configs["GridService"];
if (gridConfig == null)
{
m_log.Error("[HGGRID CONNECTOR]: GridService missing from OpenSim.ini");
return;
}
InitialiseConnectorModule(source);
m_Enabled = true;
m_log.Info("[HGGRID CONNECTOR]: HG grid enabled");
}
}
}
private void InitialiseConnectorModule(IConfigSource source)
{
IConfig gridConfig = source.Configs["GridService"];
if (gridConfig == null)
{
m_log.Error("[HGGRID CONNECTOR]: GridService missing from OpenSim.ini");
throw new Exception("Grid connector init error");
}
string module = gridConfig.GetString("GridServiceConnectorModule", String.Empty);
if (module == String.Empty)
{
m_log.Error("[HGGRID CONNECTOR]: No GridServiceConnectorModule named in section GridService");
//return;
throw new Exception("Unable to proceed. Please make sure your ini files in config-include are updated according to .example's");
}
Object[] args = new Object[] { source };
m_GridServiceConnector = ServerUtils.LoadPlugin<IGridService>(module, args);
}
public void PostInitialise()
{
if (m_Enabled)
((ISharedRegionModule)m_GridServiceConnector).PostInitialise();
}
public void Close()
{
}
public void AddRegion(Scene scene)
{
if (!m_Enabled)
return;
m_LocalScenes[scene.RegionInfo.RegionHandle] = scene;
scene.RegisterModuleInterface<IGridService>(this);
scene.RegisterModuleInterface<IHyperlinkService>(this);
((ISharedRegionModule)m_GridServiceConnector).AddRegion(scene);
}
public void RemoveRegion(Scene scene)
{
if (m_Enabled)
{
m_LocalScenes.Remove(scene.RegionInfo.RegionHandle);
((ISharedRegionModule)m_GridServiceConnector).RemoveRegion(scene);
}
}
public void RegionLoaded(Scene scene)
{
if (!m_Enabled)
return;
if (!m_Initialized)
{
m_aScene = scene;
LocalAssetServerURI = m_aScene.CommsManager.NetworkServersInfo.UserURL;
LocalInventoryServerURI = m_aScene.CommsManager.NetworkServersInfo.InventoryURL;
LocalUserServerURI = m_aScene.CommsManager.NetworkServersInfo.UserURL;
m_HypergridServiceConnector = new HypergridServiceConnector(scene.AssetService);
HGCommands hgCommands = new HGCommands(this, scene);
MainConsole.Instance.Commands.AddCommand("HGGridServicesConnector", false, "link-region",
"link-region <Xloc> <Yloc> <HostName>:<HttpPort>[:<RemoteRegionName>] <cr>",
"Link a hypergrid region", hgCommands.RunCommand);
MainConsole.Instance.Commands.AddCommand("HGGridServicesConnector", false, "unlink-region",
"unlink-region <local name> or <HostName>:<HttpPort> <cr>",
"Unlink a hypergrid region", hgCommands.RunCommand);
MainConsole.Instance.Commands.AddCommand("HGGridServicesConnector", false, "link-mapping", "link-mapping [<x> <y>] <cr>",
"Set local coordinate to map HG regions to", hgCommands.RunCommand);
// Yikes!! Remove this as soon as user services get refactored
HGNetworkServersInfo.Init(LocalAssetServerURI, LocalInventoryServerURI, LocalUserServerURI);
m_Initialized = true;
}
}
#endregion
#region IGridService
public bool RegisterRegion(UUID scopeID, GridRegion regionInfo)
{
// Region doesn't exist here. Trying to link remote region
if (regionInfo.RegionID.Equals(UUID.Zero))
{
m_log.Info("[HGrid]: Linking remote region " + regionInfo.ExternalHostName + ":" + regionInfo.HttpPort);
ulong regionHandle = 0;
regionInfo.RegionID = m_HypergridServiceConnector.LinkRegion(regionInfo, out regionHandle);
if (!regionInfo.RegionID.Equals(UUID.Zero))
{
AddHyperlinkRegion(regionInfo, regionHandle);
m_log.Info("[HGrid]: Successfully linked to region_uuid " + regionInfo.RegionID);
// Try get the map image
m_HypergridServiceConnector.GetMapImage(regionInfo);
return true;
}
else
{
m_log.Info("[HGrid]: No such region " + regionInfo.ExternalHostName + ":" + regionInfo.HttpPort + "(" + regionInfo.InternalEndPoint.Port + ")");
return false;
}
// Note that these remote regions aren't registered in localBackend, so return null, no local listeners
}
else // normal grid
return m_GridServiceConnector.RegisterRegion(scopeID, regionInfo);
}
public bool DeregisterRegion(UUID regionID)
{
// Try the hyperlink collection
if (m_HyperlinkRegions.ContainsKey(regionID))
{
RemoveHyperlinkRegion(regionID);
return true;
}
// Try the foreign users home collection
foreach (GridRegion r in m_knownRegions.Values)
if (r.RegionID == regionID)
{
RemoveHyperlinkHomeRegion(regionID);
return true;
}
// Finally, try the normal route
return m_GridServiceConnector.DeregisterRegion(regionID);
}
public List<GridRegion> GetNeighbours(UUID scopeID, UUID regionID)
{
// No serving neighbours on hyperliked regions.
// Just the regular regions.
return m_GridServiceConnector.GetNeighbours(scopeID, regionID);
}
public GridRegion GetRegionByUUID(UUID scopeID, UUID regionID)
{
// Try the hyperlink collection
if (m_HyperlinkRegions.ContainsKey(regionID))
return m_HyperlinkRegions[regionID];
// Try the foreign users home collection
foreach (GridRegion r in m_knownRegions.Values)
if (r.RegionID == regionID)
return r;
// Finally, try the normal route
return m_GridServiceConnector.GetRegionByUUID(scopeID, regionID);
}
public GridRegion GetRegionByPosition(UUID scopeID, int x, int y)
{
int snapX = (int) (x / Constants.RegionSize) * (int)Constants.RegionSize;
int snapY = (int) (y / Constants.RegionSize) * (int)Constants.RegionSize;
// Try the hyperlink collection
foreach (GridRegion r in m_HyperlinkRegions.Values)
{
if ((r.RegionLocX == snapX) && (r.RegionLocY == snapY))
return r;
}
// Try the foreign users home collection
foreach (GridRegion r in m_knownRegions.Values)
{
if ((r.RegionLocX == snapX) && (r.RegionLocY == snapY))
{
return r;
}
}
// Finally, try the normal route
return m_GridServiceConnector.GetRegionByPosition(scopeID, x, y);
}
public GridRegion GetRegionByName(UUID scopeID, string regionName)
{
// Try normal grid first
GridRegion region = m_GridServiceConnector.GetRegionByName(scopeID, regionName);
if (region != null)
return region;
// Try the hyperlink collection
foreach (GridRegion r in m_HyperlinkRegions.Values)
{
if (r.RegionName == regionName)
return r;
}
// Try the foreign users home collection
foreach (GridRegion r in m_knownRegions.Values)
{
if (r.RegionName == regionName)
return r;
}
return null;
}
public List<GridRegion> GetRegionsByName(UUID scopeID, string name, int maxNumber)
{
List<GridRegion> rinfos = new List<GridRegion>();
// Commenting until regionname exists
//foreach (SimpleRegionInfo r in m_HyperlinkRegions.Values)
// if ((r.RegionName != null) && r.RegionName.StartsWith(name))
// rinfos.Add(r);
rinfos.AddRange(m_GridServiceConnector.GetRegionsByName(scopeID, name, maxNumber));
return rinfos;
}
public List<GridRegion> GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax)
{
int snapXmin = (int)(xmin / Constants.RegionSize) * (int)Constants.RegionSize;
int snapXmax = (int)(xmax / Constants.RegionSize) * (int)Constants.RegionSize;
int snapYmin = (int)(ymin / Constants.RegionSize) * (int)Constants.RegionSize;
int snapYmax = (int)(ymax / Constants.RegionSize) * (int)Constants.RegionSize;
List<GridRegion> rinfos = new List<GridRegion>();
foreach (GridRegion r in m_HyperlinkRegions.Values)
if ((r.RegionLocX > snapXmin) && (r.RegionLocX < snapYmax) &&
(r.RegionLocY > snapYmin) && (r.RegionLocY < snapYmax))
rinfos.Add(r);
rinfos.AddRange(m_GridServiceConnector.GetRegionRange(scopeID, xmin, xmax, ymin, ymax));
return rinfos;
}
#endregion
#region Auxiliary
private void AddHyperlinkRegion(GridRegion regionInfo, ulong regionHandle)
{
m_HyperlinkRegions[regionInfo.RegionID] = regionInfo;
m_HyperlinkHandles[regionInfo.RegionID] = regionHandle;
}
private void RemoveHyperlinkRegion(UUID regionID)
{
m_HyperlinkRegions.Remove(regionID);
m_HyperlinkHandles.Remove(regionID);
}
private void AddHyperlinkHomeRegion(UUID userID, GridRegion regionInfo, ulong regionHandle)
{
m_knownRegions[userID] = regionInfo;
m_HyperlinkHandles[regionInfo.RegionID] = regionHandle;
}
private void RemoveHyperlinkHomeRegion(UUID regionID)
{
foreach (KeyValuePair<UUID, GridRegion> kvp in m_knownRegions)
{
if (kvp.Value.RegionID == regionID)
{
m_knownRegions.Remove(kvp.Key);
}
}
m_HyperlinkHandles.Remove(regionID);
}
#endregion
#region IHyperlinkService
private static Random random = new Random();
public GridRegion TryLinkRegionToCoords(Scene m_scene, IClientAPI client, string mapName, int xloc, int yloc)
{
string host = "127.0.0.1";
string portstr;
string regionName = "";
uint port = 9000;
string[] parts = mapName.Split(new char[] { ':' });
if (parts.Length >= 1)
{
host = parts[0];
}
if (parts.Length >= 2)
{
portstr = parts[1];
if (!UInt32.TryParse(portstr, out port))
regionName = parts[1];
}
// always take the last one
if (parts.Length >= 3)
{
regionName = parts[2];
}
// Sanity check. Don't ever link to this sim.
IPAddress ipaddr = null;
try
{
ipaddr = Util.GetHostFromDNS(host);
}
catch { }
if ((ipaddr != null) &&
!((m_scene.RegionInfo.ExternalEndPoint.Address.Equals(ipaddr)) && (m_scene.RegionInfo.HttpPort == port)))
{
GridRegion regInfo;
bool success = TryCreateLink(m_scene, client, xloc, yloc, regionName, port, host, out regInfo);
if (success)
{
regInfo.RegionName = mapName;
return regInfo;
}
}
return null;
}
// From the map search and secondlife://blah
public GridRegion TryLinkRegion(Scene m_scene, IClientAPI client, string mapName)
{
int xloc = random.Next(0, Int16.MaxValue) * (int) Constants.RegionSize;
return TryLinkRegionToCoords(m_scene, client, mapName, xloc, 0);
}
public bool TryCreateLink(Scene m_scene, IClientAPI client, int xloc, int yloc,
string externalRegionName, uint externalPort, string externalHostName, out GridRegion regInfo)
{
m_log.DebugFormat("[HGrid]: Link to {0}:{1}, in {2}-{3}", externalHostName, externalPort, xloc, yloc);
regInfo = new GridRegion();
regInfo.RegionName = externalRegionName;
regInfo.HttpPort = externalPort;
regInfo.ExternalHostName = externalHostName;
regInfo.RegionLocX = xloc;
regInfo.RegionLocY = yloc;
try
{
regInfo.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), (int)0);
}
catch (Exception e)
{
m_log.Warn("[HGrid]: Wrong format for link-region: " + e.Message);
return false;
}
// Finally, link it
if (!RegisterRegion(UUID.Zero, regInfo))
{
m_log.Warn("[HGrid]: Unable to link region");
return false;
}
int x, y;
if (!Check4096(m_scene, regInfo, out x, out y))
{
DeregisterRegion(regInfo.RegionID);
if (client != null)
client.SendAlertMessage("Region is too far (" + x + ", " + y + ")");
m_log.Info("[HGrid]: Unable to link, region is too far (" + x + ", " + y + ")");
return false;
}
if (!CheckCoords(m_scene.RegionInfo.RegionLocX, m_scene.RegionInfo.RegionLocY, x, y))
{
DeregisterRegion(regInfo.RegionID);
if (client != null)
client.SendAlertMessage("Region has incompatible coordinates (" + x + ", " + y + ")");
m_log.Info("[HGrid]: Unable to link, region has incompatible coordinates (" + x + ", " + y + ")");
return false;
}
m_log.Debug("[HGrid]: link region succeeded");
return true;
}
public bool TryUnlinkRegion(Scene m_scene, string mapName)
{
GridRegion regInfo = null;
if (mapName.Contains(":"))
{
string host = "127.0.0.1";
//string portstr;
//string regionName = "";
uint port = 9000;
string[] parts = mapName.Split(new char[] { ':' });
if (parts.Length >= 1)
{
host = parts[0];
}
// if (parts.Length >= 2)
// {
// portstr = parts[1];
// if (!UInt32.TryParse(portstr, out port))
// regionName = parts[1];
// }
// always take the last one
// if (parts.Length >= 3)
// {
// regionName = parts[2];
// }
foreach (GridRegion r in m_HyperlinkRegions.Values)
if (host.Equals(r.ExternalHostName) && (port == r.HttpPort))
regInfo = r;
}
else
{
foreach (GridRegion r in m_HyperlinkRegions.Values)
if (r.RegionName.Equals(mapName))
regInfo = r;
}
if (regInfo != null)
{
return DeregisterRegion(regInfo.RegionID);
}
else
{
m_log.InfoFormat("[HGrid]: Region {0} not found", mapName);
return false;
}
}
/// <summary>
/// Cope with this viewer limitation.
/// </summary>
/// <param name="regInfo"></param>
/// <returns></returns>
public bool Check4096(Scene m_scene, GridRegion regInfo, out int x, out int y)
{
ulong realHandle = m_HyperlinkHandles[regInfo.RegionID];
uint ux = 0, uy = 0;
Utils.LongToUInts(realHandle, out ux, out uy);
x = (int)(ux / Constants.RegionSize);
y = (int)(uy / Constants.RegionSize);
if ((Math.Abs((int)m_scene.RegionInfo.RegionLocX - x) >= 4096) ||
(Math.Abs((int)m_scene.RegionInfo.RegionLocY - y) >= 4096))
{
return false;
}
return true;
}
public bool CheckCoords(uint thisx, uint thisy, int x, int y)
{
if ((thisx == x) && (thisy == y))
return false;
return true;
}
public GridRegion TryLinkRegion(IClientAPI client, string regionDescriptor)
{
return TryLinkRegion((Scene)client.Scene, client, regionDescriptor);
}
public GridRegion GetHyperlinkRegion(ulong handle)
{
foreach (GridRegion r in m_HyperlinkRegions.Values)
if (r.RegionHandle == handle)
return r;
foreach (GridRegion r in m_knownRegions.Values)
if (r.RegionHandle == handle)
return r;
return null;
}
public ulong FindRegionHandle(ulong handle)
{
foreach (GridRegion r in m_HyperlinkRegions.Values)
if ((r.RegionHandle == handle) && (m_HyperlinkHandles.ContainsKey(r.RegionID)))
return m_HyperlinkHandles[r.RegionID];
foreach (GridRegion r in m_knownRegions.Values)
if ((r.RegionHandle == handle) && (m_HyperlinkHandles.ContainsKey(r.RegionID)))
return m_HyperlinkHandles[r.RegionID];
return handle;
}
public bool SendUserInformation(GridRegion regInfo, AgentCircuitData agentData)
{
CachedUserInfo uinfo = m_aScene.CommsManager.UserProfileCacheService.GetUserDetails(agentData.AgentID);
if ((IsLocalUser(uinfo) && (GetHyperlinkRegion(regInfo.RegionHandle) != null)) ||
(!IsLocalUser(uinfo) && !IsGoingHome(uinfo, regInfo)))
{
m_log.Info("[HGrid]: Local user is going to foreign region or foreign user is going elsewhere");
// Set the position of the region on the remote grid
ulong realHandle = FindRegionHandle(regInfo.RegionHandle);
uint x = 0, y = 0;
Utils.LongToUInts(regInfo.RegionHandle, out x, out y);
GridRegion clonedRegion = new GridRegion(regInfo);
clonedRegion.RegionLocX = (int)x;
clonedRegion.RegionLocY = (int)y;
// Get the user's home region information
GridRegion home = m_aScene.GridService.GetRegionByUUID(m_aScene.RegionInfo.ScopeID, uinfo.UserProfile.HomeRegionID);
// Get the user's service URLs
string serverURI = "";
if (uinfo.UserProfile is ForeignUserProfileData)
serverURI = Util.ServerURI(((ForeignUserProfileData)uinfo.UserProfile).UserServerURI);
string userServer = (serverURI == "") || (serverURI == null) ? LocalUserServerURI : serverURI;
string assetServer = Util.ServerURI(uinfo.UserProfile.UserAssetURI);
if ((assetServer == null) || (assetServer == ""))
assetServer = LocalAssetServerURI;
string inventoryServer = Util.ServerURI(uinfo.UserProfile.UserInventoryURI);
if ((inventoryServer == null) || (inventoryServer == ""))
inventoryServer = LocalInventoryServerURI;
if (!m_HypergridServiceConnector.InformRegionOfUser(clonedRegion, agentData, home, userServer, assetServer, inventoryServer))
{
m_log.Warn("[HGrid]: Could not inform remote region of transferring user.");
return false;
}
}
//if ((uinfo == null) || !IsGoingHome(uinfo, regInfo))
//{
// m_log.Info("[HGrid]: User seems to be going to foreign region.");
// if (!InformRegionOfUser(regInfo, agentData))
// {
// m_log.Warn("[HGrid]: Could not inform remote region of transferring user.");
// return false;
// }
//}
//else
// m_log.Info("[HGrid]: User seems to be going home " + uinfo.UserProfile.FirstName + " " + uinfo.UserProfile.SurName);
// May need to change agent's name
if (IsLocalUser(uinfo) && (GetHyperlinkRegion(regInfo.RegionHandle) != null))
{
agentData.firstname = agentData.firstname + "." + agentData.lastname;
agentData.lastname = "@" + LocalUserServerURI.Replace("http://", ""); ; //HGNetworkServersInfo.Singleton.LocalUserServerURI;
}
return true;
}
public void AdjustUserInformation(AgentCircuitData agentData)
{
CachedUserInfo uinfo = m_aScene.CommsManager.UserProfileCacheService.GetUserDetails(agentData.AgentID);
if ((uinfo != null) && (uinfo.UserProfile != null) &&
(IsLocalUser(uinfo) || !(uinfo.UserProfile is ForeignUserProfileData)))
{
//m_log.Debug("---------------> Local User!");
string[] parts = agentData.firstname.Split(new char[] { '.' });
if (parts.Length == 2)
{
agentData.firstname = parts[0];
agentData.lastname = parts[1];
}
}
//else
// m_log.Debug("---------------> Foreign User!");
}
// Check if a local user exists with the same UUID as the incoming foreign user
public bool CheckUserAtEntry(UUID userID, UUID sessionID, out bool comingHome)
{
comingHome = false;
if (!m_aScene.SceneGridService.RegionLoginsEnabled)
return false;
CachedUserInfo uinfo = m_aScene.CommsManager.UserProfileCacheService.GetUserDetails(userID);
if (uinfo != null)
{
// uh-oh we have a potential intruder
if (uinfo.SessionID != sessionID)
// can't have a foreigner with a local UUID
return false;
else
// oh, so it's you! welcome back
comingHome = true;
}
// OK, user can come in
return true;
}
public void AcceptUser(ForeignUserProfileData user, GridRegion home)
{
m_aScene.CommsManager.UserProfileCacheService.PreloadUserCache(user);
ulong realHandle = home.RegionHandle;
// Change the local coordinates
// X=0 on the map
home.RegionLocX = 0;
home.RegionLocY = random.Next(0, 10000) * (int)Constants.RegionSize;
AddHyperlinkHomeRegion(user.ID, home, realHandle);
DumpUserData(user);
DumpRegionData(home);
}
public bool IsLocalUser(UUID userID)
{
CachedUserInfo uinfo = m_aScene.CommsManager.UserProfileCacheService.GetUserDetails(userID);
return IsLocalUser(uinfo);
}
#endregion
#region IHyperlink Misc
protected bool IsComingHome(ForeignUserProfileData userData)
{
return (userData.UserServerURI == LocalUserServerURI);
}
// Is the user going back to the home region or the home grid?
protected bool IsGoingHome(CachedUserInfo uinfo, GridRegion rinfo)
{
if (uinfo.UserProfile == null)
return false;
if (!(uinfo.UserProfile is ForeignUserProfileData))
// it's a home user, can't be outside to return home
return false;
// OK, it's a foreign user with a ForeignUserProfileData
// and is going back to exactly the home region.
// We can't check if it's going back to a non-home region
// of the home grid. That will be dealt with in the
// receiving end
return (uinfo.UserProfile.HomeRegionID == rinfo.RegionID);
}
protected bool IsLocalUser(CachedUserInfo uinfo)
{
if (uinfo == null)
return false;
return !(uinfo.UserProfile is ForeignUserProfileData);
}
protected bool IsLocalRegion(ulong handle)
{
return m_LocalScenes.ContainsKey(handle);
}
private void DumpUserData(ForeignUserProfileData userData)
{
m_log.Info(" ------------ User Data Dump ----------");
m_log.Info(" >> Name: " + userData.FirstName + " " + userData.SurName);
m_log.Info(" >> HomeID: " + userData.HomeRegionID);
m_log.Info(" >> UserServer: " + userData.UserServerURI);
m_log.Info(" >> InvServer: " + userData.UserInventoryURI);
m_log.Info(" >> AssetServer: " + userData.UserAssetURI);
m_log.Info(" ------------ -------------- ----------");
}
private void DumpRegionData(GridRegion rinfo)
{
m_log.Info(" ------------ Region Data Dump ----------");
m_log.Info(" >> handle: " + rinfo.RegionHandle);
m_log.Info(" >> coords: " + rinfo.RegionLocX + ", " + rinfo.RegionLocY);
m_log.Info(" >> external host name: " + rinfo.ExternalHostName);
m_log.Info(" >> http port: " + rinfo.HttpPort);
m_log.Info(" >> external EP address: " + rinfo.ExternalEndPoint.Address);
m_log.Info(" >> external EP port: " + rinfo.ExternalEndPoint.Port);
m_log.Info(" ------------ -------------- ----------");
}
#endregion
}
}

View File

@ -0,0 +1,240 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* 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 OpenSimulator Project 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 THE DEVELOPERS ``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 THE CONTRIBUTORS 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 log4net;
using Nini.Config;
using System;
using System.Collections.Generic;
using System.Reflection;
using OpenSim.Framework;
using OpenSim.Framework.Console;
using OpenSim.Server.Base;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Services.Interfaces;
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
using OpenMetaverse;
namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
{
public class LocalGridServicesConnector :
ISharedRegionModule, IGridService
{
private static readonly ILog m_log =
LogManager.GetLogger(
MethodBase.GetCurrentMethod().DeclaringType);
private static LocalGridServicesConnector m_MainInstance;
private IGridService m_GridService;
private Dictionary<UUID, RegionCache> m_LocalCache = new Dictionary<UUID, RegionCache>();
private bool m_Enabled = false;
public LocalGridServicesConnector()
{
}
public LocalGridServicesConnector(IConfigSource source)
{
m_log.Debug("[LOCAL GRID CONNECTOR]: LocalGridServicesConnector instantiated");
m_MainInstance = this;
InitialiseService(source);
}
#region ISharedRegionModule
public Type ReplaceableInterface
{
get { return null; }
}
public string Name
{
get { return "LocalGridServicesConnector"; }
}
public void Initialise(IConfigSource source)
{
IConfig moduleConfig = source.Configs["Modules"];
if (moduleConfig != null)
{
string name = moduleConfig.GetString("GridServices", "");
if (name == Name)
{
InitialiseService(source);
m_MainInstance = this;
m_Enabled = true;
m_log.Info("[LOCAL GRID CONNECTOR]: Local grid connector enabled");
}
}
}
private void InitialiseService(IConfigSource source)
{
IConfig assetConfig = source.Configs["GridService"];
if (assetConfig == null)
{
m_log.Error("[LOCAL GRID CONNECTOR]: GridService missing from OpenSim.ini");
return;
}
string serviceDll = assetConfig.GetString("LocalServiceModule",
String.Empty);
if (serviceDll == String.Empty)
{
m_log.Error("[LOCAL GRID CONNECTOR]: No LocalServiceModule named in section GridService");
return;
}
Object[] args = new Object[] { source };
m_GridService =
ServerUtils.LoadPlugin<IGridService>(serviceDll,
args);
if (m_GridService == null)
{
m_log.Error("[LOCAL GRID CONNECTOR]: Can't load grid service");
return;
}
}
public void PostInitialise()
{
if (m_MainInstance == this)
{
MainConsole.Instance.Commands.AddCommand("LocalGridConnector", false, "show neighbours",
"show neighbours",
"Shows the local regions' neighbours", NeighboursCommand);
}
}
public void Close()
{
}
public void AddRegion(Scene scene)
{
if (m_Enabled)
scene.RegisterModuleInterface<IGridService>(this);
if (m_MainInstance == this)
{
if (m_LocalCache.ContainsKey(scene.RegionInfo.RegionID))
m_log.ErrorFormat("[LOCAL GRID CONNECTOR]: simulator seems to have more than one region with the same UUID. Please correct this!");
else
m_LocalCache.Add(scene.RegionInfo.RegionID, new RegionCache(scene));
}
}
public void RemoveRegion(Scene scene)
{
if (m_MainInstance == this)
{
m_LocalCache[scene.RegionInfo.RegionID].Clear();
m_LocalCache.Remove(scene.RegionInfo.RegionID);
}
}
public void RegionLoaded(Scene scene)
{
}
#endregion
#region IGridService
public bool RegisterRegion(UUID scopeID, GridRegion regionInfo)
{
return m_GridService.RegisterRegion(scopeID, regionInfo);
}
public bool DeregisterRegion(UUID regionID)
{
return m_GridService.DeregisterRegion(regionID);
}
public List<GridRegion> GetNeighbours(UUID scopeID, UUID regionID)
{
if (m_LocalCache.ContainsKey(regionID))
{
List<GridRegion> neighbours = m_LocalCache[regionID].GetNeighbours();
if (neighbours.Count == 0)
// try the DB
neighbours = m_GridService.GetNeighbours(scopeID, regionID);
return neighbours;
}
else
{
m_log.WarnFormat("[LOCAL GRID CONNECTOR]: GetNeighbours: Requested region {0} is not on this sim", regionID);
return new List<GridRegion>();
}
// Don't go to the DB
//return m_GridService.GetNeighbours(scopeID, regionID);
}
public GridRegion GetRegionByUUID(UUID scopeID, UUID regionID)
{
return m_GridService.GetRegionByUUID(scopeID, regionID);
}
public GridRegion GetRegionByPosition(UUID scopeID, int x, int y)
{
return m_GridService.GetRegionByPosition(scopeID, x, y);
}
public GridRegion GetRegionByName(UUID scopeID, string regionName)
{
return m_GridService.GetRegionByName(scopeID, regionName);
}
public List<GridRegion> GetRegionsByName(UUID scopeID, string name, int maxNumber)
{
return m_GridService.GetRegionsByName(scopeID, name, maxNumber);
}
public List<GridRegion> GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax)
{
return m_GridService.GetRegionRange(scopeID, xmin, xmax, ymin, ymax);
}
#endregion
public void NeighboursCommand(string module, string[] cmdparams)
{
foreach (KeyValuePair<UUID, RegionCache> kvp in m_LocalCache)
{
m_log.InfoFormat("*** Neighbours of {0} {1} ***", kvp.Key, kvp.Value.RegionName);
List<GridRegion> regions = kvp.Value.GetNeighbours();
foreach (GridRegion r in regions)
m_log.InfoFormat(" {0} @ {1}={2}", r.RegionName, r.RegionLocX / Constants.RegionSize, r.RegionLocY / Constants.RegionSize);
}
}
}
}

View File

@ -0,0 +1,79 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* 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 OpenSimulator Project 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 THE DEVELOPERS ``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 THE CONTRIBUTORS 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.Reflection;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Services.Interfaces;
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
using log4net;
namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
{
public class RegionCache
{
private static readonly ILog m_log =
LogManager.GetLogger(
MethodBase.GetCurrentMethod().DeclaringType);
private Scene m_scene;
private Dictionary<ulong, GridRegion> m_neighbours = new Dictionary<ulong, GridRegion>();
public string RegionName
{
get { return m_scene.RegionInfo.RegionName; }
}
public RegionCache(Scene s)
{
m_scene = s;
m_scene.EventManager.OnRegionUp += OnRegionUp;
}
private void OnRegionUp(GridRegion otherRegion)
{
m_log.DebugFormat("[REGION CACHE]: (on region {0}) Region {1} is up @ {2}-{3}",
m_scene.RegionInfo.RegionName, otherRegion.RegionName, otherRegion.RegionLocX, otherRegion.RegionLocY);
m_neighbours[otherRegion.RegionHandle] = otherRegion;
}
public void Clear()
{
m_scene.EventManager.OnRegionUp -= OnRegionUp;
m_neighbours.Clear();
}
public List<GridRegion> GetNeighbours()
{
return new List<GridRegion>(m_neighbours.Values);
}
}
}

View File

@ -0,0 +1,194 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* 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 OpenSimulator Project 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 THE DEVELOPERS ``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 THE CONTRIBUTORS 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 log4net;
using System;
using System.Collections.Generic;
using System.Reflection;
using Nini.Config;
using OpenMetaverse;
using OpenSim.Framework;
using OpenSim.Services.Connectors;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Services.Interfaces;
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
{
public class RemoteGridServicesConnector :
GridServicesConnector, ISharedRegionModule, IGridService
{
private static readonly ILog m_log =
LogManager.GetLogger(
MethodBase.GetCurrentMethod().DeclaringType);
private bool m_Enabled = false;
private IGridService m_LocalGridService;
public RemoteGridServicesConnector()
{
}
public RemoteGridServicesConnector(IConfigSource source)
{
InitialiseServices(source);
}
#region ISharedRegionmodule
public Type ReplaceableInterface
{
get { return null; }
}
public string Name
{
get { return "RemoteGridServicesConnector"; }
}
public override void Initialise(IConfigSource source)
{
IConfig moduleConfig = source.Configs["Modules"];
if (moduleConfig != null)
{
string name = moduleConfig.GetString("GridServices", "");
if (name == Name)
{
InitialiseServices(source);
m_Enabled = true;
m_log.Info("[REMOTE GRID CONNECTOR]: Remote grid enabled");
}
}
}
private void InitialiseServices(IConfigSource source)
{
IConfig gridConfig = source.Configs["GridService"];
if (gridConfig == null)
{
m_log.Error("[REMOTE GRID CONNECTOR]: GridService missing from OpenSim.ini");
return;
}
base.Initialise(source);
m_LocalGridService = new LocalGridServicesConnector(source);
}
public void PostInitialise()
{
if (m_LocalGridService != null)
((ISharedRegionModule)m_LocalGridService).PostInitialise();
}
public void Close()
{
}
public void AddRegion(Scene scene)
{
if (m_Enabled)
scene.RegisterModuleInterface<IGridService>(this);
if (m_LocalGridService != null)
((ISharedRegionModule)m_LocalGridService).AddRegion(scene);
}
public void RemoveRegion(Scene scene)
{
if (m_LocalGridService != null)
((ISharedRegionModule)m_LocalGridService).RemoveRegion(scene);
}
public void RegionLoaded(Scene scene)
{
}
#endregion
#region IGridService
public override bool RegisterRegion(UUID scopeID, GridRegion regionInfo)
{
if (m_LocalGridService.RegisterRegion(scopeID, regionInfo))
return base.RegisterRegion(scopeID, regionInfo);
return false;
}
public override bool DeregisterRegion(UUID regionID)
{
if (m_LocalGridService.DeregisterRegion(regionID))
return base.DeregisterRegion(regionID);
return false;
}
// Let's override GetNeighbours completely -- never go to the grid server
// Neighbours are/should be cached locally
// For retrieval from the DB, caller should call GetRegionByPosition
public override List<GridRegion> GetNeighbours(UUID scopeID, UUID regionID)
{
return m_LocalGridService.GetNeighbours(scopeID, regionID);
}
public override GridRegion GetRegionByUUID(UUID scopeID, UUID regionID)
{
GridRegion rinfo = m_LocalGridService.GetRegionByUUID(scopeID, regionID);
if (rinfo == null)
rinfo = base.GetRegionByUUID(scopeID, regionID);
return rinfo;
}
public override GridRegion GetRegionByPosition(UUID scopeID, int x, int y)
{
GridRegion rinfo = m_LocalGridService.GetRegionByPosition(scopeID, x, y);
if (rinfo == null)
rinfo = base.GetRegionByPosition(scopeID, x, y);
return rinfo;
}
public override GridRegion GetRegionByName(UUID scopeID, string regionName)
{
GridRegion rinfo = m_LocalGridService.GetRegionByName(scopeID, regionName);
if (rinfo == null)
rinfo = base.GetRegionByName(scopeID, regionName);
return rinfo;
}
// Let's not override GetRegionsByName -- let's get them all from the grid server
// Let's not override GetRegionRange -- let's get them all from the grid server
#endregion
}
}

View File

@ -0,0 +1,141 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* 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 OpenSimulator Project 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 THE DEVELOPERS ``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 THE CONTRIBUTORS 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.IO;
using System.Reflection;
using System.Threading;
using log4net.Config;
using NUnit.Framework;
using NUnit.Framework.SyntaxHelpers;
using OpenMetaverse;
using OpenSim.Framework;
using Nini.Config;
using OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid;
using OpenSim.Region.Framework.Scenes;
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
using OpenSim.Tests.Common;
using OpenSim.Tests.Common.Setup;
namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid.Tests
{
[TestFixture]
public class GridConnectorsTests
{
LocalGridServicesConnector m_LocalConnector;
private void SetUp()
{
IConfigSource config = new IniConfigSource();
config.AddConfig("Modules");
config.AddConfig("GridService");
config.Configs["Modules"].Set("GridServices", "LocalGridServicesConnector");
config.Configs["GridService"].Set("LocalServiceModule", "OpenSim.Services.GridService.dll:GridService");
config.Configs["GridService"].Set("StorageProvider", "OpenSim.Data.Null.dll:NullRegionData");
m_LocalConnector = new LocalGridServicesConnector(config);
}
/// <summary>
/// Test saving a V0.2 OpenSim Region Archive.
/// </summary>
[Test]
public void TestRegisterRegionV0_2()
{
SetUp();
// Create 3 regions
GridRegion r1 = new GridRegion();
r1.RegionName = "Test Region 1";
r1.RegionID = new UUID(1);
r1.RegionLocX = 1000 * (int)Constants.RegionSize;
r1.RegionLocY = 1000 * (int)Constants.RegionSize;
r1.ExternalHostName = "127.0.0.1";
r1.HttpPort = 9001;
r1.InternalEndPoint = new System.Net.IPEndPoint(System.Net.IPAddress.Parse("0.0.0.0"), 0);
Scene s = new Scene(new RegionInfo());
s.RegionInfo.RegionID = r1.RegionID;
m_LocalConnector.AddRegion(s);
GridRegion r2 = new GridRegion();
r2.RegionName = "Test Region 2";
r2.RegionID = new UUID(2);
r2.RegionLocX = 1001 * (int)Constants.RegionSize;
r2.RegionLocY = 1000 * (int)Constants.RegionSize;
r2.ExternalHostName = "127.0.0.1";
r2.HttpPort = 9002;
r2.InternalEndPoint = new System.Net.IPEndPoint(System.Net.IPAddress.Parse("0.0.0.0"), 0);
s = new Scene(new RegionInfo());
s.RegionInfo.RegionID = r1.RegionID;
m_LocalConnector.AddRegion(s);
GridRegion r3 = new GridRegion();
r3.RegionName = "Test Region 3";
r3.RegionID = new UUID(3);
r3.RegionLocX = 1005 * (int)Constants.RegionSize;
r3.RegionLocY = 1000 * (int)Constants.RegionSize;
r3.ExternalHostName = "127.0.0.1";
r3.HttpPort = 9003;
r3.InternalEndPoint = new System.Net.IPEndPoint(System.Net.IPAddress.Parse("0.0.0.0"), 0);
s = new Scene(new RegionInfo());
s.RegionInfo.RegionID = r1.RegionID;
m_LocalConnector.AddRegion(s);
m_LocalConnector.RegisterRegion(UUID.Zero, r1);
GridRegion result = m_LocalConnector.GetRegionByName(UUID.Zero, "Test");
Assert.IsNotNull(result, "Retrieved GetRegionByName is null");
Assert.That(result.RegionName, Is.EqualTo("Test Region 1"), "Retrieved region's name does not match");
result = m_LocalConnector.GetRegionByUUID(UUID.Zero, new UUID(1));
Assert.IsNotNull(result, "Retrieved GetRegionByUUID is null");
Assert.That(result.RegionID, Is.EqualTo(new UUID(1)), "Retrieved region's UUID does not match");
result = m_LocalConnector.GetRegionByPosition(UUID.Zero, 1000 * (int)Constants.RegionSize, 1000 * (int)Constants.RegionSize);
Assert.IsNotNull(result, "Retrieved GetRegionByPosition is null");
Assert.That(result.RegionLocX, Is.EqualTo(1000 * (int)Constants.RegionSize), "Retrieved region's position does not match");
m_LocalConnector.RegisterRegion(UUID.Zero, r2);
m_LocalConnector.RegisterRegion(UUID.Zero, r3);
List<GridRegion> results = m_LocalConnector.GetNeighbours(UUID.Zero, new UUID(1));
Assert.IsNotNull(results, "Retrieved neighbours list is null");
Assert.That(results.Count, Is.EqualTo(1), "Retrieved neighbour collection is greater than expected");
Assert.That(results[0].RegionID, Is.EqualTo(new UUID(2)), "Retrieved region's UUID does not match");
results = m_LocalConnector.GetRegionsByName(UUID.Zero, "Test", 10);
Assert.IsNotNull(results, "Retrieved GetRegionsByName list is null");
Assert.That(results.Count, Is.EqualTo(3), "Retrieved neighbour collection is less than expected");
results = m_LocalConnector.GetRegionRange(UUID.Zero, 900 * (int)Constants.RegionSize, 1002 * (int)Constants.RegionSize,
900 * (int)Constants.RegionSize, 1100 * (int)Constants.RegionSize);
Assert.IsNotNull(results, "Retrieved GetRegionRange list is null");
Assert.That(results.Count, Is.EqualTo(2), "Retrieved neighbour collection is not the number expected");
}
}
}

View File

@ -42,6 +42,8 @@ using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Region.Framework.Scenes.Hypergrid;
using OpenSim.Region.Framework.Scenes.Serialization;
using OpenSim.Services.Interfaces;
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion
{
@ -59,6 +61,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion
protected RegionToRegionClient m_regionClient;
protected IHyperlinkService m_hyperlinkService;
protected bool m_safemode;
protected IPAddress m_thisIP;
@ -134,7 +138,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion
m_localBackend = new LocalInterregionComms();
m_commsManager = scene.CommsManager;
m_aScene = scene;
m_regionClient = new RegionToRegionClient(m_aScene);
m_hyperlinkService = m_aScene.RequestModuleInterface<IHyperlinkService>();
m_regionClient = new RegionToRegionClient(m_aScene, m_hyperlinkService);
m_thisIP = Util.GetHostFromDNS(scene.RegionInfo.ExternalHostName);
}
@ -161,7 +166,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion
// else do the remote thing
if (!m_localBackend.IsLocalRegion(regionHandle))
{
RegionInfo regInfo = m_commsManager.GridService.RequestNeighbourInfo(regionHandle);
uint x = 0, y = 0;
Utils.LongToUInts(regionHandle, out x, out y);
GridRegion regInfo = m_aScene.GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y);
if (regInfo != null)
{
m_regionClient.SendUserInformation(regInfo, aCircuit);
@ -183,7 +190,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion
// else do the remote thing
if (!m_localBackend.IsLocalRegion(regionHandle))
{
RegionInfo regInfo = m_commsManager.GridService.RequestNeighbourInfo(regionHandle);
uint x = 0, y = 0;
Utils.LongToUInts(regionHandle, out x, out y);
GridRegion regInfo = m_aScene.GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y);
if (regInfo != null)
{
return m_regionClient.DoChildAgentUpdateCall(regInfo, cAgentData);
@ -204,7 +213,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion
// else do the remote thing
if (!m_localBackend.IsLocalRegion(regionHandle))
{
RegionInfo regInfo = m_commsManager.GridService.RequestNeighbourInfo(regionHandle);
uint x = 0, y = 0;
Utils.LongToUInts(regionHandle, out x, out y);
GridRegion regInfo = m_aScene.GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y);
if (regInfo != null)
{
return m_regionClient.DoChildAgentUpdateCall(regInfo, cAgentData);
@ -225,7 +236,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion
// else do the remote thing
if (!m_localBackend.IsLocalRegion(regionHandle))
{
RegionInfo regInfo = m_commsManager.GridService.RequestNeighbourInfo(regionHandle);
uint x = 0, y = 0;
Utils.LongToUInts(regionHandle, out x, out y);
GridRegion regInfo = m_aScene.GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y);
if (regInfo != null)
{
return m_regionClient.DoRetrieveRootAgentCall(regInfo, id, out agent);
@ -257,7 +270,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion
// else do the remote thing
if (!m_localBackend.IsLocalRegion(regionHandle))
{
RegionInfo regInfo = m_commsManager.GridService.RequestNeighbourInfo(regionHandle);
uint x = 0, y = 0;
Utils.LongToUInts(regionHandle, out x, out y);
GridRegion regInfo = m_aScene.GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y);
if (regInfo != null)
{
return m_regionClient.DoCloseAgentCall(regInfo, id);
@ -284,7 +299,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion
// else do the remote thing
if (!m_localBackend.IsLocalRegion(regionHandle))
{
RegionInfo regInfo = m_commsManager.GridService.RequestNeighbourInfo(regionHandle);
uint x = 0, y = 0;
Utils.LongToUInts(regionHandle, out x, out y);
GridRegion regInfo = m_aScene.GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y);
if (regInfo != null)
{
return m_regionClient.DoCreateObjectCall(
@ -776,16 +793,21 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion
protected class RegionToRegionClient : RegionClient
{
Scene m_aScene = null;
IHyperlinkService m_hyperlinkService;
public RegionToRegionClient(Scene s)
public RegionToRegionClient(Scene s, IHyperlinkService hyperService)
{
m_aScene = s;
m_hyperlinkService = hyperService;
}
public override ulong GetRegionHandle(ulong handle)
{
if (m_aScene.SceneGridService is HGSceneCommunicationService)
return ((HGSceneCommunicationService)(m_aScene.SceneGridService)).m_hg.FindRegionHandle(handle);
{
if (m_hyperlinkService != null)
return m_hyperlinkService.FindRegionHandle(handle);
}
return handle;
}
@ -793,29 +815,24 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion
public override bool IsHyperlink(ulong handle)
{
if (m_aScene.SceneGridService is HGSceneCommunicationService)
return ((HGSceneCommunicationService)(m_aScene.SceneGridService)).m_hg.IsHyperlinkRegion(handle);
{
if ((m_hyperlinkService != null) && (m_hyperlinkService.GetHyperlinkRegion(handle) != null))
return true;
}
return false;
}
public override void SendUserInformation(RegionInfo regInfo, AgentCircuitData aCircuit)
public override void SendUserInformation(GridRegion regInfo, AgentCircuitData aCircuit)
{
try
{
if (m_aScene.SceneGridService is HGSceneCommunicationService)
{
((HGSceneCommunicationService)(m_aScene.SceneGridService)).m_hg.SendUserInformation(regInfo, aCircuit);
}
}
catch // Bad cast
{ }
if (m_hyperlinkService != null)
m_hyperlinkService.SendUserInformation(regInfo, aCircuit);
}
public override void AdjustUserInformation(AgentCircuitData aCircuit)
{
if (m_aScene.SceneGridService is HGSceneCommunicationService)
((HGSceneCommunicationService)(m_aScene.SceneGridService)).m_hg.AdjustUserInformation(aCircuit);
if (m_hyperlinkService != null)
m_hyperlinkService.AdjustUserInformation(aCircuit);
}
}

View File

@ -525,7 +525,12 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
return true;
}
string userInventoryServerURI = HGNetworkServersInfo.ServerURI(uinfo.UserProfile.UserInventoryURI);
if ((uinfo.UserProfile.UserInventoryURI == null) || (uinfo.UserProfile.UserInventoryURI == ""))
// this happens in standalone profiles, apparently
return true;
string userInventoryServerURI = Util.ServerURI(uinfo.UserProfile.UserInventoryURI);
string uri = m_LocalGridInventoryURI.TrimEnd('/');
if ((userInventoryServerURI == uri) || (userInventoryServerURI == ""))
@ -544,7 +549,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
if ((uinfo == null) || (uinfo.UserProfile == null))
return invURI;
string userInventoryServerURI = HGNetworkServersInfo.ServerURI(uinfo.UserProfile.UserInventoryURI);
string userInventoryServerURI = Util.ServerURI(uinfo.UserProfile.UserInventoryURI);
if ((userInventoryServerURI != null) &&
(userInventoryServerURI != ""))

View File

@ -107,7 +107,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
public void AddRegion(Scene scene)
{
m_Scene = scene;
m_log.Debug("[XXXX] Adding scene " + m_Scene.RegionInfo.RegionName);
//m_log.Debug("[XXXX] Adding scene " + m_Scene.RegionInfo.RegionName);
if (!m_Enabled)
return;

View File

@ -37,6 +37,7 @@ using OpenSim.Region.Framework.Scenes;
using OpenSim.Services.Interfaces;
using OpenSim.Server.Base;
namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Land
{
public class RemoteLandServicesConnector :
@ -89,7 +90,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Land
if (!m_Enabled)
return;
m_MapService = scene.CommsManager.GridService;
m_GridService = scene.GridService;
m_LocalService.AddRegion(scene);
scene.RegisterModuleInterface<ILandService>(this);
}

View File

@ -119,7 +119,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Neighbour
#region INeighbourService
public bool HelloNeighbour(ulong regionHandle, RegionInfo thisRegion)
public GridRegion HelloNeighbour(ulong regionHandle, RegionInfo thisRegion)
{
m_log.DebugFormat("[NEIGHBOUR CONNECTOR]: HelloNeighbour from {0}, to {1}. Count = {2}",
thisRegion.RegionName, regionHandle, m_Scenes.Count);
@ -132,7 +132,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Neighbour
}
}
m_log.DebugFormat("[NEIGHBOUR CONNECTOR]: region handle {0} not found", regionHandle);
return false;
return null;
}
#endregion INeighbourService

View File

@ -118,7 +118,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Neighbour
if (!m_Enabled)
return;
m_MapService = scene.CommsManager.GridService;
m_LocalService.AddRegion(scene);
scene.RegisterModuleInterface<INeighbourService>(this);
}
@ -134,16 +133,19 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Neighbour
if (!m_Enabled)
return;
m_GridService = scene.GridService;
m_log.InfoFormat("[NEIGHBOUR CONNECTOR]: Enabled remote neighbours for region {0}", scene.RegionInfo.RegionName);
}
#region INeighbourService
public override bool HelloNeighbour(ulong regionHandle, RegionInfo thisRegion)
public override GridRegion HelloNeighbour(ulong regionHandle, RegionInfo thisRegion)
{
if (m_LocalService.HelloNeighbour(regionHandle, thisRegion))
return true;
GridRegion region = m_LocalService.HelloNeighbour(regionHandle, thisRegion);
if (region != null)
return region;
return base.HelloNeighbour(regionHandle, thisRegion);
}

View File

@ -33,7 +33,6 @@ using log4net;
using Nini.Config;
using OpenMetaverse;
using OpenSim.Framework;
using OpenSim.Region.CoreModules.World.Terrain;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;
@ -47,7 +46,7 @@ namespace OpenSim.Region.CoreModules.World.Estate
private Scene m_scene;
private EstateTerrainXferHandler TerrainUploader = null;
private EstateTerrainXferHandler TerrainUploader;
#region Packet Data Responders
@ -155,6 +154,7 @@ namespace OpenSim.Region.CoreModules.World.Estate
break;
}
m_scene.RegionInfo.RegionSettings.Save();
sendRegionInfoPacketToAll();
}
public void setEstateTerrainTextureHeights(IClientAPI client, int corner, float lowValue, float highValue)
@ -179,6 +179,7 @@ namespace OpenSim.Region.CoreModules.World.Estate
break;
}
m_scene.RegionInfo.RegionSettings.Save();
sendRegionInfoPacketToAll();
}
private void handleCommitEstateTerrainTextureRequest(IClientAPI remoteClient)
@ -668,7 +669,7 @@ namespace OpenSim.Region.CoreModules.World.Estate
LookupUUID(uuidNameLookupList);
}
private void LookupUUIDSCompleted(IAsyncResult iar)
private static void LookupUUIDSCompleted(IAsyncResult iar)
{
LookupUUIDS icon = (LookupUUIDS)iar.AsyncState;
icon.EndInvoke(iar);
@ -683,7 +684,7 @@ namespace OpenSim.Region.CoreModules.World.Estate
}
private void LookupUUIDsAsync(List<UUID> uuidLst)
{
UUID[] uuidarr = new UUID[0];
UUID[] uuidarr;
lock (uuidLst)
{
@ -707,7 +708,7 @@ namespace OpenSim.Region.CoreModules.World.Estate
for (int i = 0; i < avatars.Count; i++)
{
HandleRegionInfoRequest(avatars[i].ControllingClient); ;
HandleRegionInfoRequest(avatars[i].ControllingClient);
}
}
@ -768,7 +769,7 @@ namespace OpenSim.Region.CoreModules.World.Estate
else
{
m_scene.RegionInfo.EstateSettings.UseGlobalTime = false;
m_scene.RegionInfo.EstateSettings.SunPosition = (double)(parms2 - 0x1800)/1024.0;
m_scene.RegionInfo.EstateSettings.SunPosition = (parms2 - 0x1800)/1024.0;
}
if ((parms1 & 0x00000010) != 0)
@ -828,8 +829,108 @@ namespace OpenSim.Region.CoreModules.World.Estate
m_scene.RegisterModuleInterface<IEstateModule>(this);
m_scene.EventManager.OnNewClient += EventManager_OnNewClient;
m_scene.EventManager.OnRequestChangeWaterHeight += changeWaterHeight;
m_scene.AddCommand(this, "set terrain texture",
"set terrain texture <number> <uuid> [<x>] [<y>]",
"Sets the terrain <number> to <uuid>, if <x> or <y> are specified, it will only " +
"set it on regions with a matching coordinate. Specify -1 in <x> or <y> to wildcard" +
" that coordinate.",
consoleSetTerrainTexture);
m_scene.AddCommand(this, "set terrain heights",
"set terrain heights <corner> <min> <max> [<x>] [<y>]",
"Sets the terrain texture heights on corner #<corner> to <min>/<max>, if <x> or <y> are specified, it will only " +
"set it on regions with a matching coordinate. Specify -1 in <x> or <y> to wildcard" +
" that coordinate. Corner # SW = 0, NW = 1, SE = 2, NE = 3.",
consoleSetTerrainHeights);
}
#region Console Commands
public void consoleSetTerrainTexture(string module, string[] args)
{
string num = args[3];
string uuid = args[4];
int x = (args.Length > 5 ? int.Parse(args[5]) : -1);
int y = (args.Length > 6 ? int.Parse(args[6]) : -1);
if (x == -1 || m_scene.RegionInfo.RegionLocX == x)
{
if (y == -1 || m_scene.RegionInfo.RegionLocY == y)
{
int corner = int.Parse(num);
UUID texture = UUID.Parse(uuid);
m_log.Debug("[ESTATEMODULE] Setting terrain textures for " + m_scene.RegionInfo.RegionName +
string.Format(" (C#{0} = {1})", corner, texture));
switch (corner)
{
case 0:
m_scene.RegionInfo.RegionSettings.TerrainTexture1 = texture;
break;
case 1:
m_scene.RegionInfo.RegionSettings.TerrainTexture2 = texture;
break;
case 2:
m_scene.RegionInfo.RegionSettings.TerrainTexture3 = texture;
break;
case 3:
m_scene.RegionInfo.RegionSettings.TerrainTexture4 = texture;
break;
}
m_scene.RegionInfo.RegionSettings.Save();
sendRegionInfoPacketToAll();
}
}
}
public void consoleSetTerrainHeights(string module, string[] args)
{
string num = args[3];
string min = args[4];
string max = args[5];
int x = (args.Length > 6 ? int.Parse(args[6]) : -1);
int y = (args.Length > 7 ? int.Parse(args[7]) : -1);
if (x == -1 || m_scene.RegionInfo.RegionLocX == x)
{
if (y == -1 || m_scene.RegionInfo.RegionLocY == y)
{
int corner = int.Parse(num);
float lowValue = float.Parse(min);
float highValue = float.Parse(max);
m_log.Debug("[ESTATEMODULE] Setting terrain heights " + m_scene.RegionInfo.RegionName +
string.Format(" (C{0}, {1}-{2}", corner, lowValue, highValue));
switch (corner)
{
case 0:
m_scene.RegionInfo.RegionSettings.Elevation1SW = lowValue;
m_scene.RegionInfo.RegionSettings.Elevation2SW = highValue;
break;
case 1:
m_scene.RegionInfo.RegionSettings.Elevation1NW = lowValue;
m_scene.RegionInfo.RegionSettings.Elevation2NW = highValue;
break;
case 2:
m_scene.RegionInfo.RegionSettings.Elevation1SE = lowValue;
m_scene.RegionInfo.RegionSettings.Elevation2SE = highValue;
break;
case 3:
m_scene.RegionInfo.RegionSettings.Elevation1NE = lowValue;
m_scene.RegionInfo.RegionSettings.Elevation2NE = highValue;
break;
}
m_scene.RegionInfo.RegionSettings.Save();
sendRegionHandshakeToAll();
}
}
}
#endregion
public void PostInitialise()
{

View File

@ -36,10 +36,12 @@ using OpenSim.Framework;
using OpenSim.Framework.Capabilities;
using OpenSim.Framework.Servers;
using OpenSim.Framework.Servers.HttpServer;
using OpenSim.Services.Interfaces;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Region.Physics.Manager;
using Caps=OpenSim.Framework.Capabilities.Caps;
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
namespace OpenSim.Region.CoreModules.World.Land
{
@ -1301,7 +1303,7 @@ namespace OpenSim.Region.CoreModules.World.Land
else
{
// a parcel request for a parcel in another region. Ask the grid about the region
RegionInfo info = m_scene.CommsManager.GridService.RequestNeighbourInfo(regionID);
GridRegion info = m_scene.GridService.GetRegionByUUID(UUID.Zero, regionID);
if (info != null)
parcelID = Util.BuildFakeParcelID(info.RegionHandle, x, y);
}
@ -1359,9 +1361,10 @@ namespace OpenSim.Region.CoreModules.World.Land
}
else
{
extLandData.landData = m_scene.CommsManager.GridService.RequestLandData(extLandData.regionHandle,
extLandData.x,
extLandData.y);
ILandService landService = m_scene.RequestModuleInterface<ILandService>();
extLandData.landData = landService.GetLandData(extLandData.regionHandle,
extLandData.x,
extLandData.y);
if (extLandData.landData == null)
{
// we didn't find the region/land => don't cache
@ -1373,20 +1376,27 @@ namespace OpenSim.Region.CoreModules.World.Land
if (data != null) // if we found some data, send it
{
RegionInfo info;
GridRegion info;
if (data.regionHandle == m_scene.RegionInfo.RegionHandle)
{
info = m_scene.RegionInfo;
info = new GridRegion(m_scene.RegionInfo);
}
else
{
// most likely still cached from building the extLandData entry
info = m_scene.CommsManager.GridService.RequestNeighbourInfo(data.regionHandle);
uint x = 0, y = 0;
Utils.LongToUInts(data.regionHandle, out x, out y);
info = m_scene.GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y);
}
// we need to transfer the fake parcelID, not the one in landData, so the viewer can match it to the landmark.
m_log.DebugFormat("[LAND] got parcelinfo for parcel {0} in region {1}; sending...",
data.landData.Name, data.regionHandle);
remoteClient.SendParcelInfo(info, data.landData, parcelID, data.x, data.y);
// HACK for now
RegionInfo r = new RegionInfo();
r.RegionName = info.RegionName;
r.RegionLocX = (uint)info.RegionLocX;
r.RegionLocY = (uint)info.RegionLocY;
remoteClient.SendParcelInfo(r, data.landData, parcelID, data.x, data.y);
}
else
m_log.Debug("[LAND] got no parcelinfo; not sending");

View File

@ -35,6 +35,7 @@ using OpenSim.Framework;
using OpenSim.Framework.Client;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Framework.Console;
namespace OpenSim.Region.CoreModules.World.Land
{
@ -61,7 +62,10 @@ namespace OpenSim.Region.CoreModules.World.Land
IConfig myConfig = source.Configs["Startup"];
enabledYN = myConfig.GetBoolean("CombineContiguousRegions", false);
//enabledYN = true;
}
if (enabledYN)
MainConsole.Instance.Commands.AddCommand("RegionCombinerModule", false, "fix-phantoms",
"Fix phantom objects", "Fixes phantom objects after an import to megaregions", FixPhantoms);
}
public void Close()
{
@ -79,12 +83,12 @@ namespace OpenSim.Region.CoreModules.World.Land
{
if (!enabledYN)
return;
/*
// For testing on a single instance
if (scene.RegionInfo.RegionLocX == 1004 && scene.RegionInfo.RegionLocY == 1000)
return;
//
*/
lock (m_startingScenes)
m_startingScenes.Add(scene.RegionInfo.originRegionID, scene);
@ -910,5 +914,20 @@ namespace OpenSim.Region.CoreModules.World.Land
VirtualRegion.Permissions.OnTeleport += BigRegion.PermissionModule.CanTeleport; //NOT YET IMPLEMENTED
VirtualRegion.Permissions.OnUseObjectReturn += BigRegion.PermissionModule.CanUseObjectReturn; //NOT YET IMPLEMENTED
}
#region console commands
public void FixPhantoms(string module, string[] cmdparams)
{
List<Scene> scenes = new List<Scene>(m_startingScenes.Values);
foreach (Scene s in scenes)
{
s.ForEachSOG(delegate(SceneObjectGroup e)
{
e.AbsolutePosition = e.AbsolutePosition;
}
);
}
}
#endregion
}
}

View File

@ -33,6 +33,8 @@ using OpenSim.Framework;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Region.Framework.Scenes.Hypergrid;
using OpenSim.Services.Interfaces;
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
namespace OpenSim.Region.CoreModules.World.WorldMap
{
@ -92,13 +94,13 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
}
// try to fetch from GridServer
List<RegionInfo> regionInfos = m_scene.SceneGridService.RequestNamedRegions(mapName, 20);
List<GridRegion> regionInfos = m_scene.GridService.GetRegionsByName(UUID.Zero, mapName, 20);
if (regionInfos == null)
{
m_log.Warn("[MAPSEARCHMODULE]: RequestNamedRegions returned null. Old gridserver?");
// service wasn't available; maybe still an old GridServer. Try the old API, though it will return only one region
regionInfos = new List<RegionInfo>();
RegionInfo info = m_scene.SceneGridService.RequestClosestRegion(mapName);
regionInfos = new List<GridRegion>();
GridRegion info = m_scene.GridService.GetRegionByName(UUID.Zero, mapName);
if (info != null) regionInfos.Add(info);
}
@ -109,11 +111,15 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
if (mapName.Contains(".") && mapName.Contains(":"))
{
// It probably is a domain name. Try to link to it.
RegionInfo regInfo;
GridRegion regInfo;
Scene cScene = GetClientScene(remoteClient);
regInfo = HGHyperlink.TryLinkRegion(cScene, remoteClient, mapName);
if (regInfo != null)
regionInfos.Add(regInfo);
IHyperlinkService hyperService = cScene.RequestModuleInterface<IHyperlinkService>();
if (hyperService != null)
{
regInfo = hyperService.TryLinkRegion(remoteClient, mapName);
if (regInfo != null)
regionInfos.Add(regInfo);
}
}
}
@ -122,17 +128,17 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
MapBlockData data;
if (regionInfos.Count > 0)
{
foreach (RegionInfo info in regionInfos)
foreach (GridRegion info in regionInfos)
{
data = new MapBlockData();
data.Agents = 0;
data.Access = info.AccessLevel;
data.MapImageId = info.RegionSettings.TerrainImageID;
data.Access = info.Access;
data.MapImageId = info.TerrainImage;
data.Name = info.RegionName;
data.RegionFlags = 0; // TODO not used?
data.WaterHeight = 0; // not used
data.X = (ushort)info.RegionLocX;
data.Y = (ushort)info.RegionLocY;
data.X = (ushort)(info.RegionLocX / Constants.RegionSize);
data.Y = (ushort)(info.RegionLocY / Constants.RegionSize);
blocks.Add(data);
}
}

View File

@ -48,6 +48,7 @@ using OpenSim.Region.Framework.Scenes;
using Caps=OpenSim.Framework.Capabilities.Caps;
using OSDArray=OpenMetaverse.StructuredData.OSDArray;
using OSDMap=OpenMetaverse.StructuredData.OSDMap;
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
namespace OpenSim.Region.CoreModules.World.WorldMap
{
@ -232,10 +233,20 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
}
if (lookup)
{
List<MapBlockData> mapBlocks;
List<MapBlockData> mapBlocks = new List<MapBlockData>(); ;
mapBlocks = m_scene.SceneGridService.RequestNeighbourMapBlocks((int)m_scene.RegionInfo.RegionLocX - 8, (int)m_scene.RegionInfo.RegionLocY - 8, (int)m_scene.RegionInfo.RegionLocX + 8, (int)m_scene.RegionInfo.RegionLocY + 8);
avatarPresence.ControllingClient.SendMapBlock(mapBlocks,0);
List<GridRegion> regions = m_scene.GridService.GetRegionRange(m_scene.RegionInfo.ScopeID,
(int)(m_scene.RegionInfo.RegionLocX - 8) * (int)Constants.RegionSize,
(int)(m_scene.RegionInfo.RegionLocX + 8) * (int)Constants.RegionSize,
(int)(m_scene.RegionInfo.RegionLocY - 8) * (int)Constants.RegionSize,
(int)(m_scene.RegionInfo.RegionLocY + 8) * (int)Constants.RegionSize);
foreach (GridRegion r in regions)
{
MapBlockData block = new MapBlockData();
MapBlockFromGridRegion(block, r);
mapBlocks.Add(block);
}
avatarPresence.ControllingClient.SendMapBlock(mapBlocks, 0);
lock (cachedMapBlocks)
cachedMapBlocks = mapBlocks;
@ -579,7 +590,9 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
}
if (httpserver.Length == 0)
{
RegionInfo mreg = m_scene.SceneGridService.RequestNeighbouringRegionInfo(regionhandle);
uint x = 0, y = 0;
Utils.LongToUInts(regionhandle, out x, out y);
GridRegion mreg = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, (int)x, (int)y);
if (mreg != null)
{
@ -719,15 +732,25 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
{
List<MapBlockData> response = new List<MapBlockData>();
// this should return one mapblock at most. But make sure: Look whether the one we requested is in there
List<MapBlockData> mapBlocks = m_scene.SceneGridService.RequestNeighbourMapBlocks(minX, minY, maxX, maxY);
if (mapBlocks != null)
// this should return one mapblock at most.
// (diva note: why?? in that case we should GetRegionByPosition)
// But make sure: Look whether the one we requested is in there
List<GridRegion> regions = m_scene.GridService.GetRegionRange(m_scene.RegionInfo.ScopeID,
minX * (int)Constants.RegionSize,
maxX * (int)Constants.RegionSize,
minY * (int)Constants.RegionSize,
maxY * (int)Constants.RegionSize);
if (regions != null)
{
foreach (MapBlockData block in mapBlocks)
foreach (GridRegion r in regions)
{
if (block.X == minX && block.Y == minY)
if ((r.RegionLocX == minX * (int)Constants.RegionSize) &&
(r.RegionLocY == minY * (int)Constants.RegionSize))
{
// found it => add it to response
MapBlockData block = new MapBlockData();
MapBlockFromGridRegion(block, r);
response.Add(block);
break;
}
@ -754,10 +777,30 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
protected virtual void GetAndSendBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY, uint flag)
{
List<MapBlockData> mapBlocks = m_scene.SceneGridService.RequestNeighbourMapBlocks(minX - 4, minY - 4, maxX + 4, maxY + 4);
List<MapBlockData> mapBlocks = new List<MapBlockData>();
List<GridRegion> regions = m_scene.GridService.GetRegionRange(m_scene.RegionInfo.ScopeID,
(minX - 4) * (int)Constants.RegionSize,
(maxX + 4) * (int)Constants.RegionSize,
(minY - 4) * (int)Constants.RegionSize,
(maxY + 4) * (int)Constants.RegionSize);
foreach (GridRegion r in regions)
{
MapBlockData block = new MapBlockData();
MapBlockFromGridRegion(block, r);
mapBlocks.Add(block);
}
remoteClient.SendMapBlock(mapBlocks, flag);
}
protected void MapBlockFromGridRegion(MapBlockData block, GridRegion r)
{
block.Access = r.Access;
block.MapImageId = r.TerrainImage;
block.Name = r.RegionName;
block.X = (ushort)(r.RegionLocX / Constants.RegionSize);
block.Y = (ushort)(r.RegionLocY / Constants.RegionSize);
}
public Hashtable OnHTTPGetMapImage(Hashtable keysvals)
{
m_log.Debug("[WORLD MAP]: Sending map image jpeg");
@ -874,31 +917,34 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
m_log.InfoFormat(
"[WORLD MAP]: Exporting world map for {0} to {1}", m_scene.RegionInfo.RegionName, exportPath);
List<MapBlockData> mapBlocks =
m_scene.CommsManager.GridService.RequestNeighbourMapBlocks(
(int)(m_scene.RegionInfo.RegionLocX - 9),
(int)(m_scene.RegionInfo.RegionLocY - 9),
(int)(m_scene.RegionInfo.RegionLocX + 9),
(int)(m_scene.RegionInfo.RegionLocY + 9));
List<MapBlockData> mapBlocks = new List<MapBlockData>();
List<GridRegion> regions = m_scene.GridService.GetRegionRange(m_scene.RegionInfo.ScopeID,
(int)(m_scene.RegionInfo.RegionLocX - 9) * (int)Constants.RegionSize,
(int)(m_scene.RegionInfo.RegionLocX + 9) * (int)Constants.RegionSize,
(int)(m_scene.RegionInfo.RegionLocY - 9) * (int)Constants.RegionSize,
(int)(m_scene.RegionInfo.RegionLocY + 9) * (int)Constants.RegionSize);
List<AssetBase> textures = new List<AssetBase>();
List<Image> bitImages = new List<Image>();
foreach (MapBlockData mapBlock in mapBlocks)
foreach (GridRegion r in regions)
{
MapBlockData mapBlock = new MapBlockData();
MapBlockFromGridRegion(mapBlock, r);
AssetBase texAsset = m_scene.AssetService.Get(mapBlock.MapImageId.ToString());
if (texAsset != null)
{
textures.Add(texAsset);
}
else
{
texAsset = m_scene.AssetService.Get(mapBlock.MapImageId.ToString());
if (texAsset != null)
{
textures.Add(texAsset);
}
}
//else
//{
// // WHAT?!? This doesn't seem right. Commenting (diva)
// texAsset = m_scene.AssetService.Get(mapBlock.MapImageId.ToString());
// if (texAsset != null)
// {
// textures.Add(texAsset);
// }
//}
}
foreach (AssetBase asset in textures)

View File

@ -24,3 +24,22 @@
* (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.IO;
using OpenMetaverse;
namespace OpenSim.Region.Framework.Interfaces
{
public interface IVoiceModule
{
/// <summary>
/// Set the SIP url to be used by a parcel, this will allow manual setting of a SIP address
/// for a particular piece of land, allowing region owners to use preconfigured SIP conference channels.
/// This is used by osSetParcelSIPAddress
/// </summary>
void setLandSIPAddress(string SIPAddress,UUID GlobalID);
}
}

View File

@ -32,6 +32,7 @@ using OpenSim.Framework;
using OpenSim.Framework.Client;
using OpenSim.Region.Framework.Interfaces;
using Caps=OpenSim.Framework.Capabilities.Caps;
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
namespace OpenSim.Region.Framework.Scenes
{
@ -305,6 +306,9 @@ namespace OpenSim.Region.Framework.Scenes
public delegate void Attach(uint localID, UUID itemID, UUID avatarID);
public event Attach OnAttach;
public delegate void RegionUp(GridRegion region);
public event RegionUp OnRegionUp;
public class MoneyTransferArgs : EventArgs
{
public UUID sender;
@ -446,6 +450,7 @@ namespace OpenSim.Region.Framework.Scenes
private EmptyScriptCompileQueue handlerEmptyScriptCompileQueue = null;
private Attach handlerOnAttach = null;
private RegionUp handlerOnRegionUp = null;
public void TriggerOnAttach(uint localID, UUID itemID, UUID avatarID)
{
@ -1035,5 +1040,13 @@ namespace OpenSim.Region.Framework.Scenes
if (handlerSetRootAgentScene != null)
handlerSetRootAgentScene(agentID, scene);
}
public void TriggerOnRegionUp(GridRegion otherRegion)
{
handlerOnRegionUp = OnRegionUp;
if (handlerOnRegionUp != null)
handlerOnRegionUp(otherRegion);
}
}
}

View File

@ -35,6 +35,7 @@ using OpenSim.Framework;
using OpenSim.Framework.Communications.Cache;
using OpenSim.Framework.Communications.Clients;
using OpenSim.Region.Framework.Scenes.Serialization;
using OpenSim.Services.Interfaces;
//using HyperGrid.Framework;
//using OpenSim.Region.Communications.Hypergrid;
@ -47,10 +48,21 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
// This maps between inventory server urls and inventory server clients
private Dictionary<string, InventoryClient> m_inventoryServers = new Dictionary<string, InventoryClient>();
// private Dictionary<string, InventoryClient> m_inventoryServers = new Dictionary<string, InventoryClient>();
private Scene m_scene;
private IHyperlinkService m_hyper;
IHyperlinkService HyperlinkService
{
get
{
if (m_hyper == null)
m_hyper = m_scene.RequestModuleInterface<IHyperlinkService>();
return m_hyper;
}
}
#endregion
#region Constructor
@ -72,30 +84,14 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
return null;
}
private string UserInventoryURL(UUID userID)
{
CachedUserInfo uinfo = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(userID);
if (uinfo != null)
return (uinfo.UserProfile.UserInventoryURI == "") ? null : uinfo.UserProfile.UserInventoryURI;
return null;
}
// private string UserInventoryURL(UUID userID)
// {
// CachedUserInfo uinfo = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(userID);
// if (uinfo != null)
// return (uinfo.UserProfile.UserInventoryURI == "") ? null : uinfo.UserProfile.UserInventoryURI;
// return null;
// }
private bool IsLocalUser(UUID userID)
{
CachedUserInfo uinfo = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(userID);
if (uinfo != null)
{
if (HGNetworkServersInfo.Singleton.IsLocalUser(uinfo.UserProfile))
{
m_log.Debug("[HGScene]: Home user " + uinfo.UserProfile.FirstName + " " + uinfo.UserProfile.SurName);
return true;
}
}
m_log.Debug("[HGScene]: Foreign user " + uinfo.UserProfile.FirstName + " " + uinfo.UserProfile.SurName);
return false;
}
public AssetBase FetchAsset(string url, UUID assetID)
{
@ -171,7 +167,7 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
public void Get(UUID assetID, UUID ownerID)
{
if (!IsLocalUser(ownerID))
if (!HyperlinkService.IsLocalUser(ownerID))
{
// Get the item from the remote asset server onto the local AssetCache
// and place an entry in m_assetMap
@ -229,7 +225,7 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
public void Post(UUID assetID, UUID ownerID)
{
if (!IsLocalUser(ownerID))
if (!HyperlinkService.IsLocalUser(ownerID))
{
// Post the item from the local AssetCache onto the remote asset server
// and place an entry in m_assetMap

View File

@ -1,232 +0,0 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* 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 OpenSimulator Project 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 THE DEVELOPERS ``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 THE CONTRIBUTORS 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.Net;
using System.Reflection;
using log4net;
using OpenMetaverse;
using OpenSim.Framework;
namespace OpenSim.Region.Framework.Scenes.Hypergrid
{
public class HGHyperlink
{
private static readonly ILog m_log =
LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private static Random random = new Random();
public static RegionInfo TryLinkRegionToCoords(Scene m_scene, IClientAPI client, string mapName, uint xloc, uint yloc)
{
string host = "127.0.0.1";
string portstr;
string regionName = "";
uint port = 9000;
string[] parts = mapName.Split(new char[] { ':' });
if (parts.Length >= 1)
{
host = parts[0];
}
if (parts.Length >= 2)
{
portstr = parts[1];
if (!UInt32.TryParse(portstr, out port))
regionName = parts[1];
}
// always take the last one
if (parts.Length >= 3)
{
regionName = parts[2];
}
// Sanity check. Don't ever link to this sim.
IPAddress ipaddr = null;
try
{
ipaddr = Util.GetHostFromDNS(host);
}
catch { }
if ((ipaddr != null) &&
!((m_scene.RegionInfo.ExternalEndPoint.Address.Equals(ipaddr)) && (m_scene.RegionInfo.HttpPort == port)))
{
RegionInfo regInfo;
bool success = TryCreateLink(m_scene, client, xloc, yloc, regionName, port, host, out regInfo);
if (success)
{
regInfo.RegionName = mapName;
return regInfo;
}
}
return null;
}
public static RegionInfo TryLinkRegion(Scene m_scene, IClientAPI client, string mapName)
{
uint xloc = (uint)(random.Next(0, Int16.MaxValue));
return TryLinkRegionToCoords(m_scene, client, mapName, xloc, 0);
}
public static bool TryCreateLink(Scene m_scene, IClientAPI client, uint xloc, uint yloc,
string externalRegionName, uint externalPort, string externalHostName, out RegionInfo regInfo)
{
m_log.DebugFormat("[HGrid]: Link to {0}:{1}, in {2}-{3}", externalHostName, externalPort, xloc, yloc);
regInfo = new RegionInfo();
regInfo.RegionName = externalRegionName;
regInfo.HttpPort = externalPort;
regInfo.ExternalHostName = externalHostName;
regInfo.RegionLocX = xloc;
regInfo.RegionLocY = yloc;
try
{
regInfo.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), (int)0);
}
catch (Exception e)
{
m_log.Warn("[HGrid]: Wrong format for link-region: " + e.Message);
return false;
}
regInfo.RemotingAddress = regInfo.ExternalEndPoint.Address.ToString();
// Finally, link it
try
{
m_scene.CommsManager.GridService.RegisterRegion(regInfo);
}
catch (Exception e)
{
m_log.Warn("[HGrid]: Unable to link region: " + e.Message);
return false;
}
uint x, y;
if (!Check4096(m_scene, regInfo, out x, out y))
{
m_scene.CommsManager.GridService.DeregisterRegion(regInfo);
if (client != null)
client.SendAlertMessage("Region is too far (" + x + ", " + y + ")");
m_log.Info("[HGrid]: Unable to link, region is too far (" + x + ", " + y + ")");
return false;
}
if (!CheckCoords(m_scene.RegionInfo.RegionLocX, m_scene.RegionInfo.RegionLocY, x, y))
{
m_scene.CommsManager.GridService.DeregisterRegion(regInfo);
if (client != null)
client.SendAlertMessage("Region has incompatible coordinates (" + x + ", " + y + ")");
m_log.Info("[HGrid]: Unable to link, region has incompatible coordinates (" + x + ", " + y + ")");
return false;
}
m_log.Debug("[HGrid]: link region succeeded");
return true;
}
public static bool TryUnlinkRegion(Scene m_scene, string mapName)
{
RegionInfo regInfo = null;
if (mapName.Contains(":"))
{
string host = "127.0.0.1";
//string portstr;
//string regionName = "";
uint port = 9000;
string[] parts = mapName.Split(new char[] { ':' });
if (parts.Length >= 1)
{
host = parts[0];
}
// if (parts.Length >= 2)
// {
// portstr = parts[1];
// if (!UInt32.TryParse(portstr, out port))
// regionName = parts[1];
// }
// always take the last one
// if (parts.Length >= 3)
// {
// regionName = parts[2];
// }
regInfo = m_scene.CommsManager.GridService.RequestNeighbourInfo(host, port);
}
else
{
regInfo = m_scene.CommsManager.GridService.RequestNeighbourInfo(mapName);
}
if (regInfo != null)
{
return m_scene.CommsManager.GridService.DeregisterRegion(regInfo);
}
else
{
m_log.InfoFormat("[HGrid]: Region {0} not found", mapName);
return false;
}
}
/// <summary>
/// Cope with this viewer limitation.
/// </summary>
/// <param name="regInfo"></param>
/// <returns></returns>
public static bool Check4096(Scene m_scene, RegionInfo regInfo, out uint x, out uint y)
{
ulong realHandle;
if (UInt64.TryParse(regInfo.regionSecret, out realHandle))
{
Utils.LongToUInts(realHandle, out x, out y);
x = x / Constants.RegionSize;
y = y / Constants.RegionSize;
if ((Math.Abs((int)m_scene.RegionInfo.RegionLocX - (int)x) >= 4096) ||
(Math.Abs((int)m_scene.RegionInfo.RegionLocY - (int)y) >= 4096))
{
return false;
}
return true;
}
else
{
m_scene.CommsManager.GridService.RegisterRegion(regInfo);
m_log.Debug("[HGrid]: Gnomes. Region deregistered.");
x = y = 0;
return false;
}
}
public static bool CheckCoords(uint thisx, uint thisy, uint x, uint y)
{
if ((thisx == x) && (thisy == y))
return false;
return true;
}
}
}

View File

@ -29,6 +29,7 @@ using OpenMetaverse;
using OpenSim.Framework;
using OpenSim.Framework.Communications.Cache;
using TPFlags = OpenSim.Framework.Constants.TeleportFlags;
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
namespace OpenSim.Region.Framework.Scenes.Hypergrid
{
@ -50,7 +51,7 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
if (UserProfile != null)
{
RegionInfo regionInfo = CommsManager.GridService.RequestNeighbourInfo(UserProfile.HomeRegion);
GridRegion regionInfo = GridService.GetRegionByUUID(UUID.Zero, UserProfile.HomeRegionID);
//if (regionInfo != null)
//{
// UserProfile.HomeRegionID = regionInfo.RegionID;

View File

@ -38,6 +38,8 @@ using OpenSim.Framework.Communications;
using OpenSim.Framework.Communications.Cache;
using OpenSim.Framework.Capabilities;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Services.Interfaces;
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
namespace OpenSim.Region.Framework.Scenes.Hypergrid
{
@ -45,11 +47,19 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
public readonly IHyperlink m_hg;
public HGSceneCommunicationService(CommunicationsManager commsMan, IHyperlink hg) : base(commsMan)
private IHyperlinkService m_hg;
IHyperlinkService HyperlinkService
{
get
{
if (m_hg == null)
m_hg = m_scene.RequestModuleInterface<IHyperlinkService>();
return m_hg;
}
}
public HGSceneCommunicationService(CommunicationsManager commsMan) : base(commsMan)
{
m_hg = hg;
}
@ -77,7 +87,7 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
if (regionHandle == m_regionInfo.RegionHandle)
{
// Teleport within the same region
if (position.X < 0 || position.X > Constants.RegionSize || position.Y < 0 || position.Y > Constants.RegionSize || position.Z < 0)
if (IsOutsideRegion(avatar.Scene, position) || position.Z < 0)
{
Vector3 emergencyPos = new Vector3(128, 128, 128);
@ -89,7 +99,13 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
// TODO: Get proper AVG Height
float localAVHeight = 1.56f;
float posZLimit = (float)avatar.Scene.Heightmap[(int)position.X, (int)position.Y];
float posZLimit = 22;
if (position.X > 0 && position.X <= (int)Constants.RegionSize && position.Y > 0 && position.Y <= (int)Constants.RegionSize)
{
posZLimit = (float) avatar.Scene.Heightmap[(int) position.X, (int) position.Y];
}
float newPosZ = posZLimit + localAVHeight;
if (posZLimit >= (position.Z - (localAVHeight / 2)) && !(Single.IsInfinity(newPosZ) || Single.IsNaN(newPosZ)))
{
@ -106,7 +122,10 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
}
else
{
RegionInfo reg = RequestNeighbouringRegionInfo(regionHandle);
uint x = 0, y = 0;
Utils.LongToUInts(regionHandle, out x, out y);
GridRegion reg = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, (int)x, (int)y);
if (reg != null)
{
@ -119,13 +138,13 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
/// Hypergrid mod start
///
///
bool isHyperLink = m_hg.IsHyperlinkRegion(reg.RegionHandle);
bool isHyperLink = (HyperlinkService.GetHyperlinkRegion(reg.RegionHandle) != null);
bool isHomeUser = true;
ulong realHandle = regionHandle;
CachedUserInfo uinfo = m_commsProvider.UserProfileCacheService.GetUserDetails(avatar.UUID);
if (uinfo != null)
{
isHomeUser = HGNetworkServersInfo.Singleton.IsLocalUser(uinfo.UserProfile);
isHomeUser = HyperlinkService.IsLocalUser(uinfo.UserProfile.ID);
realHandle = m_hg.FindRegionHandle(regionHandle);
m_log.Debug("XXX ---- home user? " + isHomeUser + " --- hyperlink? " + isHyperLink + " --- real handle: " + realHandle.ToString());
}

View File

@ -49,6 +49,7 @@ using OpenSim.Region.Framework.Scenes.Serialization;
using OpenSim.Region.Physics.Manager;
using Timer=System.Timers.Timer;
using TPFlags = OpenSim.Framework.Constants.TeleportFlags;
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
namespace OpenSim.Region.Framework.Scenes
{
@ -193,6 +194,26 @@ namespace OpenSim.Region.Framework.Scenes
}
}
protected IGridService m_GridService = null;
public IGridService GridService
{
get
{
if (m_GridService == null)
{
m_GridService = RequestModuleInterface<IGridService>();
if (m_GridService == null)
{
throw new Exception("No IGridService available. This could happen if the config_include folder doesn't exist or if the OpenSim.ini [Architecture] section isn't set. Please also check that you have the correct version of your inventory service dll. Sometimes old versions of this dll will still exist. Do a clean checkout and re-create the opensim.ini from the opensim.ini.example.");
}
}
return m_GridService;
}
}
protected IXMLRPC m_xmlrpcModule;
protected IWorldComm m_worldCommModule;
protected IAvatarFactory m_AvatarFactory;
@ -566,10 +587,7 @@ namespace OpenSim.Region.Framework.Scenes
}
/// <summary>
/// Another region is up. Gets called from Grid Comms:
/// (OGS1 -> LocalBackEnd -> RegionListened -> SceneCommunicationService)
/// We have to tell all our ScenePresences about it, and add it to the
/// neighbor list.
/// Another region is up.
///
/// We only add it to the neighbor list if it's within 1 region from here.
/// Agents may have draw distance values that cross two regions though, so
@ -578,47 +596,30 @@ namespace OpenSim.Region.Framework.Scenes
/// </summary>
/// <param name="otherRegion">RegionInfo handle for the new region.</param>
/// <returns>True after all operations complete, throws exceptions otherwise.</returns>
public override bool OtherRegionUp(RegionInfo otherRegion)
public override void OtherRegionUp(GridRegion otherRegion)
{
m_log.InfoFormat("[SCENE]: Region {0} up in coords {1}-{2}", otherRegion.RegionName, otherRegion.RegionLocX, otherRegion.RegionLocY);
uint xcell = (uint)((int)otherRegion.RegionLocX / (int)Constants.RegionSize);
uint ycell = (uint)((int)otherRegion.RegionLocY / (int)Constants.RegionSize);
m_log.InfoFormat("[SCENE]: (on region {0}): Region {1} up in coords {2}-{3}",
RegionInfo.RegionName, otherRegion.RegionName, xcell, ycell);
if (RegionInfo.RegionHandle != otherRegion.RegionHandle)
{
for (int i = 0; i < m_neighbours.Count; i++)
{
// The purpose of this loop is to re-update the known neighbors
// when another region comes up on top of another one.
// The latest region in that location ends up in the
// 'known neighbors list'
// Additionally, the commFailTF property gets reset to false.
if (m_neighbours[i].RegionHandle == otherRegion.RegionHandle)
{
lock (m_neighbours)
{
m_neighbours[i] = otherRegion;
}
}
}
// If the value isn't in the neighbours, add it.
// If the RegionInfo isn't exact but is for the same XY World location,
// then the above loop will fix that.
if (!(CheckNeighborRegion(otherRegion)))
{
lock (m_neighbours)
{
m_neighbours.Add(otherRegion);
//m_log.Info("[UP]: " + otherRegion.RegionHandle.ToString());
}
}
// If these are cast to INT because long + negative values + abs returns invalid data
int resultX = Math.Abs((int)otherRegion.RegionLocX - (int)RegionInfo.RegionLocX);
int resultY = Math.Abs((int)otherRegion.RegionLocY - (int)RegionInfo.RegionLocY);
int resultX = Math.Abs((int)xcell - (int)RegionInfo.RegionLocX);
int resultY = Math.Abs((int)ycell - (int)RegionInfo.RegionLocY);
if (resultX <= 1 && resultY <= 1)
{
// Let the grid service module know, so this can be cached
m_eventManager.TriggerOnRegionUp(otherRegion);
RegionInfo regInfo = new RegionInfo(xcell, ycell, otherRegion.InternalEndPoint, otherRegion.ExternalHostName);
regInfo.RegionID = otherRegion.RegionID;
regInfo.RegionName = otherRegion.RegionName;
regInfo.ScopeID = otherRegion.ScopeID;
regInfo.ExternalHostName = otherRegion.ExternalHostName;
try
{
ForEachScenePresence(delegate(ScenePresence agent)
@ -632,7 +633,7 @@ namespace OpenSim.Region.Framework.Scenes
List<ulong> old = new List<ulong>();
old.Add(otherRegion.RegionHandle);
agent.DropOldNeighbours(old);
InformClientOfNeighbor(agent, otherRegion);
InformClientOfNeighbor(agent, regInfo);
}
}
);
@ -643,6 +644,7 @@ namespace OpenSim.Region.Framework.Scenes
// This shouldn't happen too often anymore.
m_log.Error("[SCENE]: Couldn't inform client of regionup because we got a null reference exception");
}
}
else
{
@ -651,7 +653,6 @@ namespace OpenSim.Region.Framework.Scenes
otherRegion.RegionLocY.ToString() + ")");
}
}
return true;
}
public void AddNeighborRegion(RegionInfo region)
@ -683,9 +684,10 @@ namespace OpenSim.Region.Framework.Scenes
}
// Alias IncomingHelloNeighbour OtherRegionUp, for now
public bool IncomingHelloNeighbour(RegionInfo neighbour)
public GridRegion IncomingHelloNeighbour(RegionInfo neighbour)
{
return OtherRegionUp(neighbour);
OtherRegionUp(new GridRegion(neighbour));
return new GridRegion(RegionInfo);
}
/// <summary>
@ -1336,24 +1338,31 @@ namespace OpenSim.Region.Framework.Scenes
RegisterCommsEvents();
// These two 'commands' *must be* next to each other or sim rebooting fails.
m_sceneGridService.RegisterRegion(m_interregionCommsOut, RegionInfo);
//m_sceneGridService.RegisterRegion(m_interregionCommsOut, RegionInfo);
GridRegion region = new GridRegion(RegionInfo);
bool success = GridService.RegisterRegion(RegionInfo.ScopeID, region);
if (!success)
throw new Exception("Can't register with grid");
m_sceneGridService.SetScene(this);
m_sceneGridService.InformNeighborsThatRegionisUp(RequestModuleInterface<INeighbourService>(), RegionInfo);
Dictionary<string, string> dGridSettings = m_sceneGridService.GetGridSettings();
//Dictionary<string, string> dGridSettings = m_sceneGridService.GetGridSettings();
if (dGridSettings.ContainsKey("allow_forceful_banlines"))
{
if (dGridSettings["allow_forceful_banlines"] != "TRUE")
{
m_log.Info("[GRID]: Grid is disabling forceful parcel banlists");
EventManager.TriggerSetAllowForcefulBan(false);
}
else
{
m_log.Info("[GRID]: Grid is allowing forceful parcel banlists");
EventManager.TriggerSetAllowForcefulBan(true);
}
}
//if (dGridSettings.ContainsKey("allow_forceful_banlines"))
//{
// if (dGridSettings["allow_forceful_banlines"] != "TRUE")
// {
// m_log.Info("[GRID]: Grid is disabling forceful parcel banlists");
// EventManager.TriggerSetAllowForcefulBan(false);
// }
// else
// {
// m_log.Info("[GRID]: Grid is allowing forceful parcel banlists");
// EventManager.TriggerSetAllowForcefulBan(true);
// }
//}
}
/// <summary>
@ -2717,10 +2726,12 @@ namespace OpenSim.Region.Framework.Scenes
UserProfileData UserProfile = CommsManager.UserService.GetUserProfile(agentId);
if (UserProfile != null)
{
RegionInfo regionInfo = CommsManager.GridService.RequestNeighbourInfo(UserProfile.HomeRegionID);
GridRegion regionInfo = GridService.GetRegionByUUID(UUID.Zero, UserProfile.HomeRegionID);
if (regionInfo == null)
{
regionInfo = CommsManager.GridService.RequestNeighbourInfo(UserProfile.HomeRegion);
uint x = 0, y = 0;
Utils.LongToUInts(UserProfile.HomeRegion, out x, out y);
regionInfo = GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y);
if (regionInfo != null) // home region can be away temporarily, too
{
UserProfile.HomeRegionID = regionInfo.RegionID;
@ -3074,7 +3085,7 @@ namespace OpenSim.Region.Framework.Scenes
m_sceneGridService.OnExpectUser += HandleNewUserConnection;
m_sceneGridService.OnAvatarCrossingIntoRegion += AgentCrossing;
m_sceneGridService.OnCloseAgentConnection += IncomingCloseAgent;
m_sceneGridService.OnRegionUp += OtherRegionUp;
//m_eventManager.OnRegionUp += OtherRegionUp;
//m_sceneGridService.OnChildAgentUpdate += IncomingChildAgentDataUpdate;
m_sceneGridService.OnExpectPrim += IncomingInterRegionPrimGroup;
//m_sceneGridService.OnRemoveKnownRegionFromAvatar += HandleRemoveKnownRegionsFromAvatar;
@ -3102,7 +3113,7 @@ namespace OpenSim.Region.Framework.Scenes
//m_sceneGridService.OnRemoveKnownRegionFromAvatar -= HandleRemoveKnownRegionsFromAvatar;
m_sceneGridService.OnExpectPrim -= IncomingInterRegionPrimGroup;
//m_sceneGridService.OnChildAgentUpdate -= IncomingChildAgentDataUpdate;
m_sceneGridService.OnRegionUp -= OtherRegionUp;
//m_eventManager.OnRegionUp -= OtherRegionUp;
m_sceneGridService.OnExpectUser -= HandleNewUserConnection;
m_sceneGridService.OnAvatarCrossingIntoRegion -= AgentCrossing;
m_sceneGridService.OnCloseAgentConnection -= IncomingCloseAgent;
@ -3111,7 +3122,11 @@ namespace OpenSim.Region.Framework.Scenes
if (m_interregionCommsIn != null)
m_interregionCommsIn.OnChildAgentUpdate -= IncomingChildAgentDataUpdate;
// this does nothing; should be removed
m_sceneGridService.Close();
if (!GridService.DeregisterRegion(m_regInfo.RegionID))
m_log.WarnFormat("[SCENE]: Deregister from grid failed for region {0}", m_regInfo.RegionName);
}
/// <summary>
@ -3556,30 +3571,6 @@ namespace OpenSim.Region.Framework.Scenes
m_sceneGridService.EnableNeighbourChildAgents(presence, m_neighbours);
}
/// <summary>
/// Requests information about this region from gridcomms
/// </summary>
/// <param name="regionHandle"></param>
/// <returns></returns>
public RegionInfo RequestNeighbouringRegionInfo(ulong regionHandle)
{
return m_sceneGridService.RequestNeighbouringRegionInfo(regionHandle);
}
/// <summary>
/// Requests textures for map from minimum region to maximum region in world cordinates
/// </summary>
/// <param name="remoteClient"></param>
/// <param name="minX"></param>
/// <param name="minY"></param>
/// <param name="maxX"></param>
/// <param name="maxY"></param>
public void RequestMapBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY)
{
m_log.DebugFormat("[MAPBLOCK]: {0}-{1}, {2}-{3}", minX, minY, maxX, maxY);
m_sceneGridService.RequestMapBlocks(remoteClient, minX, minY, maxX, maxY);
}
/// <summary>
/// Tries to teleport agent to other region.
/// </summary>
@ -3591,7 +3582,7 @@ namespace OpenSim.Region.Framework.Scenes
public void RequestTeleportLocation(IClientAPI remoteClient, string regionName, Vector3 position,
Vector3 lookat, uint teleportFlags)
{
RegionInfo regionInfo = m_sceneGridService.RequestClosestRegion(regionName);
GridRegion regionInfo = GridService.GetRegionByName(UUID.Zero, regionName);
if (regionInfo == null)
{
// can't find the region: Tell viewer and abort
@ -3680,7 +3671,7 @@ namespace OpenSim.Region.Framework.Scenes
/// <param name="position"></param>
public void RequestTeleportLandmark(IClientAPI remoteClient, UUID regionID, Vector3 position)
{
RegionInfo info = CommsManager.GridService.RequestNeighbourInfo(regionID);
GridRegion info = GridService.GetRegionByUUID(UUID.Zero, regionID);
if (info == null)
{
@ -3864,10 +3855,6 @@ namespace OpenSim.Region.Framework.Scenes
return LandChannel.GetLandObject((int)x, (int)y).landData;
}
public RegionInfo RequestClosestRegion(string name)
{
return m_sceneGridService.RequestClosestRegion(name);
}
#endregion
@ -4154,6 +4141,11 @@ namespace OpenSim.Region.Framework.Scenes
m_sceneGraph.ForEachClient(action);
}
public void ForEachSOG(Action<SceneObjectGroup> action)
{
m_sceneGraph.ForEachSOG(action);
}
/// <summary>
/// Returns a list of the entities in the scene. This is a new list so operations perform on the list itself
/// will not affect the original list of objects in the scene.
@ -4178,14 +4170,18 @@ namespace OpenSim.Region.Framework.Scenes
public void RegionHandleRequest(IClientAPI client, UUID regionID)
{
RegionInfo info;
ulong handle = 0;
if (regionID == RegionInfo.RegionID)
info = RegionInfo;
handle = RegionInfo.RegionHandle;
else
info = CommsManager.GridService.RequestNeighbourInfo(regionID);
{
GridRegion r = GridService.GetRegionByUUID(UUID.Zero, regionID);
if (r != null)
handle = r.RegionHandle;
}
if (info != null)
client.SendRegionHandle(regionID, info.RegionHandle);
if (handle != 0)
client.SendRegionHandle(regionID, handle);
}
public void TerrainUnAcked(IClientAPI client, int patchX, int patchY)

Some files were not shown because too many files have changed in this diff Show More