mirror of
https://github.com/opensim/opensim.git
synced 2026-08-11 20:05:33 +08:00
Finally moved HG agent transfers to use agent fatpacks.
This commit is contained in:
@@ -53,7 +53,8 @@ namespace OpenSim.Services.Connectors.Hypergrid
|
||||
|
||||
private IAssetService m_AssetService;
|
||||
|
||||
public GatekeeperServiceConnector() : base()
|
||||
public GatekeeperServiceConnector()
|
||||
: base()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -123,11 +124,13 @@ namespace OpenSim.Services.Connectors.Hypergrid
|
||||
realHandle = Convert.ToUInt64((string)hash["handle"]);
|
||||
//m_log.Debug(">> HERE, realHandle: " + realHandle);
|
||||
}
|
||||
if (hash["region_image"] != null) {
|
||||
if (hash["region_image"] != null)
|
||||
{
|
||||
imageURL = (string)hash["region_image"];
|
||||
//m_log.Debug(">> HERE, imageURL: " + imageURL);
|
||||
}
|
||||
if (hash["external_name"] != null) {
|
||||
if (hash["external_name"] != null)
|
||||
{
|
||||
externalName = (string)hash["external_name"];
|
||||
//m_log.Debug(">> HERE, externalName: " + externalName);
|
||||
}
|
||||
@@ -178,7 +181,7 @@ namespace OpenSim.Services.Connectors.Hypergrid
|
||||
//m_log.Debug("Size: " + m.PhysicalDimension.Height + "-" + m.PhysicalDimension.Width);
|
||||
imageData = OpenJPEG.EncodeFromImage(bitmap, true);
|
||||
}
|
||||
|
||||
|
||||
AssetBase ass = new AssetBase(UUID.Random(), "region " + name, (sbyte)AssetType.Texture, regionID.ToString());
|
||||
|
||||
// !!! for now
|
||||
@@ -257,7 +260,8 @@ namespace OpenSim.Services.Connectors.Hypergrid
|
||||
region.RegionName = (string)hash["region_name"];
|
||||
//m_log.Debug(">> HERE, region_name: " + region.RegionName);
|
||||
}
|
||||
if (hash["hostname"] != null) {
|
||||
if (hash["hostname"] != null)
|
||||
{
|
||||
region.ExternalHostName = (string)hash["hostname"];
|
||||
//m_log.Debug(">> HERE, hostname: " + region.ExternalHostName);
|
||||
}
|
||||
@@ -275,10 +279,10 @@ namespace OpenSim.Services.Connectors.Hypergrid
|
||||
region.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), p);
|
||||
//m_log.Debug(">> HERE, internal_port: " + region.InternalEndPoint);
|
||||
}
|
||||
|
||||
|
||||
if (hash["server_uri"] != null)
|
||||
{
|
||||
region.ServerURI = (string) hash["server_uri"];
|
||||
region.ServerURI = (string)hash["server_uri"];
|
||||
//m_log.Debug(">> HERE, server_uri: " + region.ServerURI);
|
||||
}
|
||||
|
||||
@@ -295,55 +299,5 @@ namespace OpenSim.Services.Connectors.Hypergrid
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public bool CreateAgent(GridRegion destination, AgentCircuitData aCircuit, uint flags, out string myipaddress, out string reason)
|
||||
{
|
||||
// m_log.DebugFormat("[GATEKEEPER SERVICE CONNECTOR]: CreateAgent start");
|
||||
|
||||
myipaddress = String.Empty;
|
||||
reason = String.Empty;
|
||||
|
||||
if (destination == null)
|
||||
{
|
||||
m_log.Debug("[GATEKEEPER SERVICE CONNECTOR]: Given destination is null");
|
||||
return false;
|
||||
}
|
||||
|
||||
string uri = destination.ServerURI + AgentPath() + aCircuit.AgentID + "/";
|
||||
|
||||
try
|
||||
{
|
||||
OSDMap args = aCircuit.PackAgentCircuitData();
|
||||
|
||||
args["destination_x"] = OSD.FromString(destination.RegionLocX.ToString());
|
||||
args["destination_y"] = OSD.FromString(destination.RegionLocY.ToString());
|
||||
args["destination_name"] = OSD.FromString(destination.RegionName);
|
||||
args["destination_uuid"] = OSD.FromString(destination.RegionID.ToString());
|
||||
args["teleport_flags"] = OSD.FromString(flags.ToString());
|
||||
|
||||
OSDMap result = WebUtil.PostToService(uri, args, 80000);
|
||||
if (result["Success"].AsBoolean())
|
||||
{
|
||||
OSDMap unpacked = (OSDMap)result["_Result"];
|
||||
|
||||
if (unpacked != null)
|
||||
{
|
||||
reason = unpacked["reason"].AsString();
|
||||
myipaddress = unpacked["your_ip"].AsString();
|
||||
return unpacked["success"].AsBoolean();
|
||||
}
|
||||
}
|
||||
|
||||
reason = result["Message"] != null ? result["Message"].AsString() : "error";
|
||||
return false;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.Warn("[REMOTE SIMULATION CONNECTOR]: CreateAgent failed with exception: " + e.ToString());
|
||||
reason = e.Message;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,13 +44,14 @@ using Nini.Config;
|
||||
|
||||
namespace OpenSim.Services.Connectors.Hypergrid
|
||||
{
|
||||
public class UserAgentServiceConnector : IUserAgentService
|
||||
public class UserAgentServiceConnector : SimulationServiceConnector, IUserAgentService
|
||||
{
|
||||
private static readonly ILog m_log =
|
||||
LogManager.GetLogger(
|
||||
MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
string m_ServerURL;
|
||||
private string m_ServerURL;
|
||||
private GridRegion m_Gatekeeper;
|
||||
|
||||
public UserAgentServiceConnector(string url) : this(url, true)
|
||||
{
|
||||
@@ -104,9 +105,15 @@ namespace OpenSim.Services.Connectors.Hypergrid
|
||||
m_log.DebugFormat("[USER AGENT CONNECTOR]: UserAgentServiceConnector started for {0}", m_ServerURL);
|
||||
}
|
||||
|
||||
protected override string AgentPath()
|
||||
{
|
||||
return "homeagent/";
|
||||
}
|
||||
|
||||
// The Login service calls this interface with a non-null [client] ipaddress
|
||||
public bool LoginAgentToGrid(AgentCircuitData aCircuit, GridRegion gatekeeper, GridRegion destination, IPEndPoint ipaddress, out string reason)
|
||||
// The Login service calls this interface with fromLogin=true
|
||||
// Sims call it with fromLogin=false
|
||||
// Either way, this is verified by the handler
|
||||
public bool LoginAgentToGrid(AgentCircuitData aCircuit, GridRegion gatekeeper, GridRegion destination, bool fromLogin, out string reason)
|
||||
{
|
||||
reason = String.Empty;
|
||||
|
||||
@@ -117,119 +124,34 @@ namespace OpenSim.Services.Connectors.Hypergrid
|
||||
return false;
|
||||
}
|
||||
|
||||
string uri = m_ServerURL + "homeagent/" + aCircuit.AgentID + "/";
|
||||
GridRegion home = new GridRegion();
|
||||
home.ServerURI = m_ServerURL;
|
||||
home.RegionID = destination.RegionID;
|
||||
home.RegionLocX = destination.RegionLocX;
|
||||
home.RegionLocY = destination.RegionLocY;
|
||||
|
||||
Console.WriteLine(" >>> LoginAgentToGrid <<< " + uri);
|
||||
m_Gatekeeper = gatekeeper;
|
||||
|
||||
HttpWebRequest AgentCreateRequest = (HttpWebRequest)WebRequest.Create(uri);
|
||||
AgentCreateRequest.Method = "POST";
|
||||
AgentCreateRequest.ContentType = "application/json";
|
||||
AgentCreateRequest.Timeout = 10000;
|
||||
//AgentCreateRequest.KeepAlive = false;
|
||||
//AgentCreateRequest.Headers.Add("Authorization", authKey);
|
||||
|
||||
// Fill it in
|
||||
OSDMap args = PackCreateAgentArguments(aCircuit, gatekeeper, destination, ipaddress);
|
||||
|
||||
string strBuffer = "";
|
||||
byte[] buffer = new byte[1];
|
||||
try
|
||||
{
|
||||
strBuffer = OSDParser.SerializeJsonString(args);
|
||||
Encoding str = Util.UTF8;
|
||||
buffer = str.GetBytes(strBuffer);
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.WarnFormat("[USER AGENT CONNECTOR]: Exception thrown on serialization of ChildCreate: {0}", e.Message);
|
||||
// ignore. buffer will be empty, caller should check.
|
||||
}
|
||||
|
||||
Stream os = null;
|
||||
try
|
||||
{ // send the Post
|
||||
AgentCreateRequest.ContentLength = buffer.Length; //Count bytes to send
|
||||
os = AgentCreateRequest.GetRequestStream();
|
||||
os.Write(buffer, 0, strBuffer.Length); //Send it
|
||||
m_log.InfoFormat("[USER AGENT CONNECTOR]: Posted CreateAgent request to remote sim {0}, region {1}, x={2} y={3}",
|
||||
uri, destination.RegionName, destination.RegionLocX, destination.RegionLocY);
|
||||
}
|
||||
//catch (WebException ex)
|
||||
catch
|
||||
{
|
||||
//m_log.InfoFormat("[USER AGENT CONNECTOR]: Bad send on ChildAgentUpdate {0}", ex.Message);
|
||||
reason = "cannot contact remote region";
|
||||
return false;
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (os != null)
|
||||
os.Close();
|
||||
}
|
||||
|
||||
// Let's wait for the response
|
||||
//m_log.Info("[USER AGENT CONNECTOR]: Waiting for a reply after DoCreateChildAgentCall");
|
||||
|
||||
try
|
||||
{
|
||||
using (WebResponse webResponse = AgentCreateRequest.GetResponse())
|
||||
{
|
||||
if (webResponse == null)
|
||||
{
|
||||
m_log.Info("[USER AGENT CONNECTOR]: Null reply on DoCreateChildAgentCall post");
|
||||
}
|
||||
else
|
||||
{
|
||||
using (Stream s = webResponse.GetResponseStream())
|
||||
{
|
||||
using (StreamReader sr = new StreamReader(s))
|
||||
{
|
||||
string response = sr.ReadToEnd().Trim();
|
||||
m_log.InfoFormat("[USER AGENT CONNECTOR]: DoCreateChildAgentCall reply was {0} ", response);
|
||||
|
||||
if (!String.IsNullOrEmpty(response))
|
||||
{
|
||||
try
|
||||
{
|
||||
// we assume we got an OSDMap back
|
||||
OSDMap r = Util.GetOSDMap(response);
|
||||
bool success = r["success"].AsBoolean();
|
||||
reason = r["reason"].AsString();
|
||||
return success;
|
||||
}
|
||||
catch (NullReferenceException e)
|
||||
{
|
||||
m_log.InfoFormat("[USER AGENT CONNECTOR]: exception on reply of DoCreateChildAgentCall {0}", e.Message);
|
||||
|
||||
// check for old style response
|
||||
if (response.ToLower().StartsWith("true"))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (WebException ex)
|
||||
{
|
||||
m_log.InfoFormat("[USER AGENT CONNECTOR]: exception on reply of DoCreateChildAgentCall {0}", ex.Message);
|
||||
reason = "Destination did not reply";
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
Console.WriteLine(" >>> LoginAgentToGrid <<< " + home.ServerURI);
|
||||
|
||||
uint flags = fromLogin ? (uint)TeleportFlags.ViaLogin : (uint)TeleportFlags.ViaHome;
|
||||
return CreateAgent(home, aCircuit, flags, out reason);
|
||||
}
|
||||
|
||||
|
||||
// The simulators call this interface
|
||||
public bool LoginAgentToGrid(AgentCircuitData aCircuit, GridRegion gatekeeper, GridRegion destination, out string reason)
|
||||
{
|
||||
return LoginAgentToGrid(aCircuit, gatekeeper, destination, null, out reason);
|
||||
return LoginAgentToGrid(aCircuit, gatekeeper, destination, false, out reason);
|
||||
}
|
||||
|
||||
protected override void PackData(OSDMap args, AgentCircuitData aCircuit, GridRegion destination, uint flags)
|
||||
{
|
||||
base.PackData(args, aCircuit, destination, flags);
|
||||
args["gatekeeper_serveruri"] = OSD.FromString(m_Gatekeeper.ServerURI);
|
||||
args["gatekeeper_host"] = OSD.FromString(m_Gatekeeper.ExternalHostName);
|
||||
args["gatekeeper_port"] = OSD.FromString(m_Gatekeeper.HttpPort.ToString());
|
||||
args["destination_serveruri"] = OSD.FromString(destination.ServerURI);
|
||||
}
|
||||
|
||||
protected OSDMap PackCreateAgentArguments(AgentCircuitData aCircuit, GridRegion gatekeeper, GridRegion destination, IPEndPoint ipaddress)
|
||||
|
||||
@@ -79,11 +79,27 @@ namespace OpenSim.Services.Connectors.Simulation
|
||||
return "agent/";
|
||||
}
|
||||
|
||||
protected virtual void PackData(OSDMap args, AgentCircuitData aCircuit, GridRegion destination, uint flags)
|
||||
{
|
||||
args["destination_x"] = OSD.FromString(destination.RegionLocX.ToString());
|
||||
args["destination_y"] = OSD.FromString(destination.RegionLocY.ToString());
|
||||
args["destination_name"] = OSD.FromString(destination.RegionName);
|
||||
args["destination_uuid"] = OSD.FromString(destination.RegionID.ToString());
|
||||
args["teleport_flags"] = OSD.FromString(flags.ToString());
|
||||
}
|
||||
|
||||
public bool CreateAgent(GridRegion destination, AgentCircuitData aCircuit, uint flags, out string reason)
|
||||
{
|
||||
// m_log.DebugFormat("[REMOTE SIMULATION CONNECTOR]: CreateAgent start");
|
||||
|
||||
string tmp = String.Empty;
|
||||
return CreateAgent(destination, aCircuit, flags, out tmp, out reason);
|
||||
}
|
||||
|
||||
public bool CreateAgent(GridRegion destination, AgentCircuitData aCircuit, uint flags, out string myipaddress, out string reason)
|
||||
{
|
||||
m_log.DebugFormat("[REMOTE SIMULATION CONNECTOR]: Creating agent at {0}", destination.ServerURI);
|
||||
reason = String.Empty;
|
||||
myipaddress = String.Empty;
|
||||
|
||||
if (destination == null)
|
||||
{
|
||||
m_log.Debug("[REMOTE SIMULATION CONNECTOR]: Given destination is null");
|
||||
@@ -95,12 +111,7 @@ namespace OpenSim.Services.Connectors.Simulation
|
||||
try
|
||||
{
|
||||
OSDMap args = aCircuit.PackAgentCircuitData();
|
||||
|
||||
args["destination_x"] = OSD.FromString(destination.RegionLocX.ToString());
|
||||
args["destination_y"] = OSD.FromString(destination.RegionLocY.ToString());
|
||||
args["destination_name"] = OSD.FromString(destination.RegionName);
|
||||
args["destination_uuid"] = OSD.FromString(destination.RegionID.ToString());
|
||||
args["teleport_flags"] = OSD.FromString(flags.ToString());
|
||||
PackData(args, aCircuit, destination, flags);
|
||||
|
||||
OSDMap result = WebUtil.PostToServiceCompressed(uri, args, 30000);
|
||||
bool success = result["success"].AsBoolean();
|
||||
@@ -110,6 +121,7 @@ namespace OpenSim.Services.Connectors.Simulation
|
||||
|
||||
reason = data["reason"].AsString();
|
||||
success = data["success"].AsBoolean();
|
||||
myipaddress = data["your_ip"].AsString();
|
||||
return success;
|
||||
}
|
||||
|
||||
@@ -124,6 +136,7 @@ namespace OpenSim.Services.Connectors.Simulation
|
||||
|
||||
reason = data["reason"].AsString();
|
||||
success = data["success"].AsBoolean();
|
||||
myipaddress = data["your_ip"].AsString();
|
||||
m_log.WarnFormat(
|
||||
"[REMOTE SIMULATION CONNECTOR]: Remote simulator {0} did not accept compressed transfer, suggest updating it.", destination.RegionName);
|
||||
return success;
|
||||
|
||||
@@ -210,10 +210,10 @@ namespace OpenSim.Services.HypergridService
|
||||
return home;
|
||||
}
|
||||
|
||||
public bool LoginAgentToGrid(AgentCircuitData agentCircuit, GridRegion gatekeeper, GridRegion finalDestination, IPEndPoint clientIP, out string reason)
|
||||
public bool LoginAgentToGrid(AgentCircuitData agentCircuit, GridRegion gatekeeper, GridRegion finalDestination, bool fromLogin, out string reason)
|
||||
{
|
||||
m_log.DebugFormat("[USER AGENT SERVICE]: Request to login user {0} {1} (@{2}) to grid {3}",
|
||||
agentCircuit.firstname, agentCircuit.lastname, ((clientIP == null) ? "stored IP" : clientIP.Address.ToString()), gatekeeper.ServerURI);
|
||||
agentCircuit.firstname, agentCircuit.lastname, (fromLogin ? agentCircuit.IPAddress : "stored IP"), gatekeeper.ServerURI);
|
||||
|
||||
string gridName = gatekeeper.ServerURI;
|
||||
|
||||
@@ -265,7 +265,7 @@ namespace OpenSim.Services.HypergridService
|
||||
bool success = false;
|
||||
string myExternalIP = string.Empty;
|
||||
|
||||
m_log.DebugFormat("[USER AGENT SERVICE]: this grid: {0}, desired grid: {1}", m_GridName, gridName);
|
||||
m_log.DebugFormat("[USER AGENT SERVICE]: this grid: {0}, desired grid: {1}, desired region: {2}", m_GridName, gridName, region.RegionID);
|
||||
|
||||
if (m_GridName == gridName)
|
||||
success = m_GatekeeperService.LoginAgent(agentCircuit, finalDestination, out reason);
|
||||
@@ -296,8 +296,8 @@ namespace OpenSim.Services.HypergridService
|
||||
|
||||
m_log.DebugFormat("[USER AGENT SERVICE]: Gatekeeper sees me as {0}", myExternalIP);
|
||||
// else set the IP addresses associated with this client
|
||||
if (clientIP != null)
|
||||
m_TravelingAgents[agentCircuit.SessionID].ClientIPAddress = clientIP.Address.ToString();
|
||||
if (fromLogin)
|
||||
m_TravelingAgents[agentCircuit.SessionID].ClientIPAddress = agentCircuit.IPAddress;
|
||||
m_TravelingAgents[agentCircuit.SessionID].MyIpAddress = myExternalIP;
|
||||
|
||||
return true;
|
||||
@@ -306,7 +306,7 @@ namespace OpenSim.Services.HypergridService
|
||||
public bool LoginAgentToGrid(AgentCircuitData agentCircuit, GridRegion gatekeeper, GridRegion finalDestination, out string reason)
|
||||
{
|
||||
reason = string.Empty;
|
||||
return LoginAgentToGrid(agentCircuit, gatekeeper, finalDestination, null, out reason);
|
||||
return LoginAgentToGrid(agentCircuit, gatekeeper, finalDestination, false, out reason);
|
||||
}
|
||||
|
||||
private void SetClientIP(UUID sessionID, string ip)
|
||||
|
||||
@@ -48,10 +48,7 @@ namespace OpenSim.Services.Interfaces
|
||||
/// </summary>
|
||||
public interface IUserAgentService
|
||||
{
|
||||
// called by login service only
|
||||
bool LoginAgentToGrid(AgentCircuitData agent, GridRegion gatekeeper, GridRegion finalDestination, IPEndPoint clientIP, out string reason);
|
||||
// called by simulators
|
||||
bool LoginAgentToGrid(AgentCircuitData agent, GridRegion gatekeeper, GridRegion finalDestination, out string reason);
|
||||
bool LoginAgentToGrid(AgentCircuitData agent, GridRegion gatekeeper, GridRegion finalDestination, bool fromLogin, out string reason);
|
||||
void LogoutAgent(UUID userID, UUID sessionID);
|
||||
GridRegion GetHomeRegion(UUID userID, out Vector3 position, out Vector3 lookAt);
|
||||
Dictionary<string, object> GetServerURLs(UUID userID);
|
||||
|
||||
@@ -933,7 +933,7 @@ namespace OpenSim.Services.LLLoginService
|
||||
private bool LaunchAgentIndirectly(GridRegion gatekeeper, GridRegion destination, AgentCircuitData aCircuit, IPEndPoint clientIP, out string reason)
|
||||
{
|
||||
m_log.Debug("[LLOGIN SERVICE] Launching agent at " + destination.RegionName);
|
||||
if (m_UserAgentService.LoginAgentToGrid(aCircuit, gatekeeper, destination, clientIP, out reason))
|
||||
if (m_UserAgentService.LoginAgentToGrid(aCircuit, gatekeeper, destination, true, out reason))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user