Finally moved HG agent transfers to use agent fatpacks.

cpu-performance
Diva Canto 2013-06-21 20:52:46 -07:00
parent a5de4f692b
commit 4778d67005
11 changed files with 175 additions and 369 deletions

View File

@ -273,7 +273,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
{
string userAgentDriver = agentCircuit.ServiceURLs["HomeURI"].ToString();
IUserAgentService connector = new UserAgentServiceConnector(userAgentDriver);
bool success = connector.LoginAgentToGrid(agentCircuit, reg, finalDestination, out reason);
bool success = connector.LoginAgentToGrid(agentCircuit, reg, finalDestination, false, out reason);
logout = success; // flag for later logout from this grid; this is an HG TP
if (success)

View File

@ -61,7 +61,7 @@ namespace OpenSim.Server.Handlers.Hypergrid
m_Proxy = proxy;
}
protected override bool CreateAgent(GridRegion destination, AgentCircuitData aCircuit, uint teleportFlags, out string reason)
protected override bool CreateAgent(GridRegion gatekeeper, GridRegion destination, AgentCircuitData aCircuit, uint teleportFlags, bool fromLogin, out string reason)
{
return m_GatekeeperService.LoginAgent(aCircuit, destination, out reason);
}

View File

@ -49,191 +49,87 @@ using log4net;
namespace OpenSim.Server.Handlers.Hypergrid
{
public class HomeAgentHandler
public class HomeAgentHandler : AgentPostHandler
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private IUserAgentService m_UserAgentService;
private string m_LoginServerIP;
private bool m_Proxy = false;
public HomeAgentHandler(IUserAgentService userAgentService, string loginServerIP, bool proxy)
public HomeAgentHandler(IUserAgentService userAgentService, string loginServerIP, bool proxy) :
base("/homeagent")
{
m_UserAgentService = userAgentService;
m_LoginServerIP = loginServerIP;
m_Proxy = proxy;
}
public Hashtable Handler(Hashtable request)
protected override AgentDestinationData CreateAgentDestinationData()
{
// m_log.Debug("[CONNECTION DEBUGGING]: HomeAgentHandler Called");
//
// m_log.Debug("---------------------------");
// m_log.Debug(" >> uri=" + request["uri"]);
// m_log.Debug(" >> content-type=" + request["content-type"]);
// m_log.Debug(" >> http-method=" + request["http-method"]);
// m_log.Debug("---------------------------\n");
Hashtable responsedata = new Hashtable();
responsedata["content_type"] = "text/html";
responsedata["keepalive"] = false;
UUID agentID;
UUID regionID;
string action;
if (!Utils.GetParams((string)request["uri"], out agentID, out regionID, out action))
{
m_log.InfoFormat("[HOME AGENT HANDLER]: Invalid parameters for agent message {0}", request["uri"]);
responsedata["int_response_code"] = 404;
responsedata["str_response_string"] = "false";
return responsedata;
}
// Next, let's parse the verb
string method = (string)request["http-method"];
if (method.Equals("POST"))
{
DoAgentPost(request, responsedata, agentID);
return responsedata;
}
else
{
m_log.InfoFormat("[HOME AGENT HANDLER]: method {0} not supported in agent message", method);
responsedata["int_response_code"] = HttpStatusCode.MethodNotAllowed;
responsedata["str_response_string"] = "Method not allowed";
return responsedata;
}
return new ExtendedAgentDestinationData();
}
protected void DoAgentPost(Hashtable request, Hashtable responsedata, UUID id)
protected override void UnpackData(OSDMap args, AgentDestinationData d, Hashtable request)
{
OSDMap args = Utils.GetOSDMap((string)request["body"]);
if (args == null)
{
responsedata["int_response_code"] = HttpStatusCode.BadRequest;
responsedata["str_response_string"] = "Bad request";
return;
}
// retrieve the input arguments
int x = 0, y = 0;
UUID uuid = UUID.Zero;
string regionname = string.Empty;
string gatekeeper_host = string.Empty;
string gatekeeper_serveruri = string.Empty;
string destination_serveruri = string.Empty;
int gatekeeper_port = 0;
IPEndPoint client_ipaddress = null;
if (args.ContainsKey("gatekeeper_host") && args["gatekeeper_host"] != null)
gatekeeper_host = args["gatekeeper_host"].AsString();
if (args.ContainsKey("gatekeeper_port") && args["gatekeeper_port"] != null)
Int32.TryParse(args["gatekeeper_port"].AsString(), out gatekeeper_port);
if (args.ContainsKey("gatekeeper_serveruri") && args["gatekeeper_serveruri"] !=null)
gatekeeper_serveruri = args["gatekeeper_serveruri"];
if (args.ContainsKey("destination_serveruri") && args["destination_serveruri"] !=null)
destination_serveruri = args["destination_serveruri"];
GridRegion gatekeeper = new GridRegion();
gatekeeper.ServerURI = gatekeeper_serveruri;
gatekeeper.ExternalHostName = gatekeeper_host;
gatekeeper.HttpPort = (uint)gatekeeper_port;
gatekeeper.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), 0);
if (args.ContainsKey("destination_x") && args["destination_x"] != null)
Int32.TryParse(args["destination_x"].AsString(), out x);
else
m_log.WarnFormat(" -- request didn't have destination_x");
if (args.ContainsKey("destination_y") && args["destination_y"] != null)
Int32.TryParse(args["destination_y"].AsString(), out y);
else
m_log.WarnFormat(" -- request didn't have destination_y");
if (args.ContainsKey("destination_uuid") && args["destination_uuid"] != null)
UUID.TryParse(args["destination_uuid"].AsString(), out uuid);
if (args.ContainsKey("destination_name") && args["destination_name"] != null)
regionname = args["destination_name"].ToString();
if (args.ContainsKey("client_ip") && args["client_ip"] != null)
{
string ip_str = args["client_ip"].ToString();
try
{
string callerIP = GetCallerIP(request);
// Verify if this caller has authority to send the client IP
if (callerIP == m_LoginServerIP)
client_ipaddress = new IPEndPoint(IPAddress.Parse(ip_str), 0);
else // leaving this for now, but this warning should be removed
m_log.WarnFormat("[HOME AGENT HANDLER]: Unauthorized machine {0} tried to set client ip to {1}", callerIP, ip_str);
}
catch
{
m_log.DebugFormat("[HOME AGENT HANDLER]: Exception parsing client ip address from {0}", ip_str);
}
}
GridRegion destination = new GridRegion();
destination.RegionID = uuid;
destination.RegionLocX = x;
destination.RegionLocY = y;
destination.RegionName = regionname;
destination.ServerURI = destination_serveruri;
AgentCircuitData aCircuit = new AgentCircuitData();
base.UnpackData(args, d, request);
ExtendedAgentDestinationData data = (ExtendedAgentDestinationData)d;
try
{
aCircuit.UnpackAgentCircuitData(args);
if (args.ContainsKey("gatekeeper_host") && args["gatekeeper_host"] != null)
data.host = args["gatekeeper_host"].AsString();
if (args.ContainsKey("gatekeeper_port") && args["gatekeeper_port"] != null)
Int32.TryParse(args["gatekeeper_port"].AsString(), out data.port);
if (args.ContainsKey("gatekeeper_serveruri") && args["gatekeeper_serveruri"] != null)
data.gatekeeperServerURI = args["gatekeeper_serveruri"];
if (args.ContainsKey("destination_serveruri") && args["destination_serveruri"] != null)
data.destinationServerURI = args["destination_serveruri"];
}
catch (Exception ex)
catch (InvalidCastException e)
{
m_log.InfoFormat("[HOME AGENT HANDLER]: exception on unpacking ChildCreate message {0}", ex.Message);
responsedata["int_response_code"] = HttpStatusCode.BadRequest;
responsedata["str_response_string"] = "Bad request";
return;
m_log.ErrorFormat("[HOME AGENT HANDLER]: Bad cast in UnpackData");
}
OSDMap resp = new OSDMap(2);
string reason = String.Empty;
string callerIP = GetCallerIP(request);
// Verify if this call came from the login server
if (callerIP == m_LoginServerIP)
data.fromLogin = true;
bool result = m_UserAgentService.LoginAgentToGrid(aCircuit, gatekeeper, destination, client_ipaddress, out reason);
resp["reason"] = OSD.FromString(reason);
resp["success"] = OSD.FromBoolean(result);
// TODO: add reason if not String.Empty?
responsedata["int_response_code"] = HttpStatusCode.OK;
responsedata["str_response_string"] = OSDParser.SerializeJsonString(resp);
}
private string GetCallerIP(Hashtable request)
protected override GridRegion ExtractGatekeeper(AgentDestinationData d)
{
if (!m_Proxy)
return Util.GetCallerIP(request);
// We're behind a proxy
Hashtable headers = (Hashtable)request["headers"];
string xff = "X-Forwarded-For";
if (headers.ContainsKey(xff.ToLower()))
xff = xff.ToLower();
if (!headers.ContainsKey(xff) || headers[xff] == null)
if (d is ExtendedAgentDestinationData)
{
m_log.WarnFormat("[AGENT HANDLER]: No XFF header");
return Util.GetCallerIP(request);
ExtendedAgentDestinationData data = (ExtendedAgentDestinationData)d;
GridRegion gatekeeper = new GridRegion();
gatekeeper.ServerURI = data.gatekeeperServerURI;
gatekeeper.ExternalHostName = data.host;
gatekeeper.HttpPort = (uint)data.port;
gatekeeper.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), 0);
return gatekeeper;
}
else
m_log.WarnFormat("[HOME AGENT HANDLER]: Wrong data type");
m_log.DebugFormat("[AGENT HANDLER]: XFF is {0}", headers[xff]);
IPEndPoint ep = Util.GetClientIPFromXFF((string)headers[xff]);
if (ep != null)
return ep.Address.ToString();
// Oops
return Util.GetCallerIP(request);
return null;
}
protected override bool CreateAgent(GridRegion gatekeeper, GridRegion destination, AgentCircuitData aCircuit, uint teleportFlags, bool fromLogin, out string reason)
{
return m_UserAgentService.LoginAgentToGrid(aCircuit, gatekeeper, destination, fromLogin, out reason);
}
}
public class ExtendedAgentDestinationData : AgentDestinationData
{
public string host;
public int port;
public string gatekeeperServerURI;
public string destinationServerURI;
}
}

View File

@ -108,7 +108,7 @@ namespace OpenSim.Server.Handlers.Hypergrid
server.AddXmlRPCHandler("get_uui", GetUUI, false);
server.AddXmlRPCHandler("get_uuid", GetUUID, false);
server.AddHTTPHandler("/homeagent/", new HomeAgentHandler(m_HomeUsersService, loginServerIP, proxy).Handler);
server.AddStreamHandler(new HomeAgentHandler(m_HomeUsersService, loginServerIP, proxy));
}
public XmlRpcResponse GetHomeRegion(XmlRpcRequest request, IPEndPoint remoteClient)

View File

@ -328,31 +328,16 @@ namespace OpenSim.Server.Handlers.Simulation
return;
}
// retrieve the input arguments
int x = 0, y = 0;
UUID uuid = UUID.Zero;
string regionname = string.Empty;
uint teleportFlags = 0;
if (args.ContainsKey("destination_x") && args["destination_x"] != null)
Int32.TryParse(args["destination_x"].AsString(), out x);
else
m_log.WarnFormat(" -- request didn't have destination_x");
if (args.ContainsKey("destination_y") && args["destination_y"] != null)
Int32.TryParse(args["destination_y"].AsString(), out y);
else
m_log.WarnFormat(" -- request didn't have destination_y");
if (args.ContainsKey("destination_uuid") && args["destination_uuid"] != null)
UUID.TryParse(args["destination_uuid"].AsString(), out uuid);
if (args.ContainsKey("destination_name") && args["destination_name"] != null)
regionname = args["destination_name"].ToString();
if (args.ContainsKey("teleport_flags") && args["teleport_flags"] != null)
teleportFlags = args["teleport_flags"].AsUInteger();
AgentDestinationData data = CreateAgentDestinationData();
UnpackData(args, data, request);
GridRegion destination = new GridRegion();
destination.RegionID = uuid;
destination.RegionLocX = x;
destination.RegionLocY = y;
destination.RegionName = regionname;
destination.RegionID = data.uuid;
destination.RegionLocX = data.x;
destination.RegionLocY = data.y;
destination.RegionName = data.name;
GridRegion gatekeeper = ExtractGatekeeper(data);
AgentCircuitData aCircuit = new AgentCircuitData();
try
@ -373,7 +358,7 @@ namespace OpenSim.Server.Handlers.Simulation
// This is the meaning of POST agent
//m_regionClient.AdjustUserInformation(aCircuit);
//bool result = m_SimulationService.CreateAgent(destination, aCircuit, teleportFlags, out reason);
bool result = CreateAgent(destination, aCircuit, teleportFlags, out reason);
bool result = CreateAgent(gatekeeper, destination, aCircuit, data.flags, data.fromLogin, out reason);
resp["reason"] = OSD.FromString(reason);
resp["success"] = OSD.FromBoolean(result);
@ -385,7 +370,36 @@ namespace OpenSim.Server.Handlers.Simulation
responsedata["str_response_string"] = OSDParser.SerializeJsonString(resp);
}
private string GetCallerIP(Hashtable request)
protected virtual AgentDestinationData CreateAgentDestinationData()
{
return new AgentDestinationData();
}
protected virtual void UnpackData(OSDMap args, AgentDestinationData data, Hashtable request)
{
// retrieve the input arguments
if (args.ContainsKey("destination_x") && args["destination_x"] != null)
Int32.TryParse(args["destination_x"].AsString(), out data.x);
else
m_log.WarnFormat(" -- request didn't have destination_x");
if (args.ContainsKey("destination_y") && args["destination_y"] != null)
Int32.TryParse(args["destination_y"].AsString(), out data.y);
else
m_log.WarnFormat(" -- request didn't have destination_y");
if (args.ContainsKey("destination_uuid") && args["destination_uuid"] != null)
UUID.TryParse(args["destination_uuid"].AsString(), out data.uuid);
if (args.ContainsKey("destination_name") && args["destination_name"] != null)
data.name = args["destination_name"].ToString();
if (args.ContainsKey("teleport_flags") && args["teleport_flags"] != null)
data.flags = args["teleport_flags"].AsUInteger();
}
protected virtual GridRegion ExtractGatekeeper(AgentDestinationData data)
{
return null;
}
protected string GetCallerIP(Hashtable request)
{
if (!m_Proxy)
return Util.GetCallerIP(request);
@ -418,7 +432,7 @@ namespace OpenSim.Server.Handlers.Simulation
}
// subclasses can override this
protected virtual bool CreateAgent(GridRegion destination, AgentCircuitData aCircuit, uint teleportFlags, out string reason)
protected virtual bool CreateAgent(GridRegion gatekeeper, GridRegion destination, AgentCircuitData aCircuit, uint teleportFlags, bool fromLogin, out string reason)
{
return m_SimulationService.CreateAgent(destination, aCircuit, teleportFlags, out reason);
}
@ -593,4 +607,14 @@ namespace OpenSim.Server.Handlers.Simulation
return m_SimulationService.UpdateAgent(destination, agent);
}
}
public class AgentDestinationData
{
public int x;
public int y;
public string name;
public UUID uuid;
public uint flags;
public bool fromLogin;
}
}

View File

@ -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;
}
}
}

View File

@ -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)

View File

@ -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;

View File

@ -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)

View File

@ -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);

View File

@ -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;
}