public bool CreateAgent(GridRegion destination, AgentCircuitData aCircuit, uint teleportFlags, AgentData data, out string reason) { reason = String.Empty; // Try local first if (m_localBackend.CreateAgent(destination, aCircuit, teleportFlags, data, out reason)) return true; reason = String.Empty; string uri = MakeUri(destination, true) + 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(teleportFlags.ToString()); if(data != null) args["agent_data"] = data.Pack(); OSDMap result = WebUtils.PostToService (uri, args, true, false); OSDMap results = WebUtils.GetOSDMap(result["_RawResult"].AsString()); //Pull out the result and set it as the reason if (results == null) return false; reason = results["reason"] != null ? results["reason"].AsString() : ""; if (result["Success"].AsBoolean()) { try { OSDMap responseMap = (OSDMap)OSDParser.DeserializeJson(reason); if (responseMap.ContainsKey("Reason")) reason = responseMap["Reason"].AsString(); return responseMap["Success"].AsBoolean(); } catch { //Not right... don't return true except for opensim combatibility :/ return true; } } 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; }
public static OSDMap ArrivedAtDestination(UUID AgentID, int DrawDistance, AgentCircuitData circuit, ulong requestingRegion) { OSDMap llsdBody = new OSDMap(); llsdBody.Add("AgentID", AgentID); llsdBody.Add("DrawDistance", DrawDistance); llsdBody.Add("Circuit", circuit.PackAgentCircuitData()); return(buildEvent("ArrivedAtDestination", llsdBody, AgentID, requestingRegion)); }
public static OSDMap ArrivedAtDestination(UUID AgentID, int DrawDistance, AgentCircuitData circuit, ulong requestingRegion) { OSDMap llsdBody = new OSDMap(); llsdBody.Add("AgentID", AgentID); llsdBody.Add("DrawDistance", DrawDistance); llsdBody.Add("Circuit", circuit.PackAgentCircuitData()); return buildEvent("ArrivedAtDestination", llsdBody, AgentID, requestingRegion); }
public static OSDMap CrossAgent(GridRegion crossingRegion, Vector3 pos, Vector3 velocity, AgentCircuitData circuit, AgentData cAgent, ulong RequestingRegion) { OSDMap llsdBody = new OSDMap(); llsdBody.Add("Pos", pos); llsdBody.Add("Vel", velocity); llsdBody.Add("Region", crossingRegion.ToOSD()); llsdBody.Add("Circuit", circuit.PackAgentCircuitData()); llsdBody.Add("AgentData", cAgent.Pack()); return(buildEvent("CrossAgent", llsdBody, circuit.AgentID, RequestingRegion)); }
public static OSDMap TeleportAgent(int DrawDistance, AgentCircuitData circuit, AgentData data, uint TeleportFlags, GridRegion destination, ulong requestingRegion) { OSDMap llsdBody = new OSDMap(); llsdBody.Add("DrawDistance", DrawDistance); llsdBody.Add("Circuit", circuit.PackAgentCircuitData()); llsdBody.Add("TeleportFlags", TeleportFlags); llsdBody.Add("AgentData", data.Pack()); llsdBody.Add("Region", destination.ToOSD()); return(buildEvent("TeleportAgent", llsdBody, circuit.AgentID, requestingRegion)); }
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, 20000); 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; }
protected virtual OSDMap PackCreateAgentArguments(AgentCircuitData aCircuit, GridRegion destination, uint flags) { OSDMap args = null; try { args = aCircuit.PackAgentCircuitData(); } catch (Exception e) { m_log.Debug("[REMOTE SIMULATION CONNECTOR]: PackAgentCircuitData failed with exception: " + e.Message); return null; } // Add the input arguments 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()); return args; }
protected OSDMap PackCreateAgentArguments(AgentCircuitData aCircuit, GridRegion gatekeeper, GridRegion destination) { OSDMap args = null; try { args = aCircuit.PackAgentCircuitData(); } catch (Exception e) { m_log.Debug("[USER AGENT CONNECTOR]: PackAgentCircuitData failed with exception: " + e.Message); } // Add the input arguments args["gatekeeper_host"] = OSD.FromString(gatekeeper.ExternalHostName); args["gatekeeper_port"] = OSD.FromString(gatekeeper.HttpPort.ToString()); 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()); return args; }
protected OSDMap PackCreateAgentArguments(AgentCircuitData aCircuit, GridRegion gatekeeper, GridRegion destination, IPEndPoint ipaddress) { OSDMap args = null; try { args = aCircuit.PackAgentCircuitData(); } catch (Exception e) { m_log.Debug("[USER AGENT CONNECTOR]: PackAgentCircuitData failed with exception: " + e.Message); } // Add the input arguments args["gatekeeper_serveruri"] = OSD.FromString(gatekeeper.ServerURI); args["gatekeeper_host"] = OSD.FromString(gatekeeper.ExternalHostName); args["gatekeeper_port"] = OSD.FromString(gatekeeper.HttpPort.ToString()); 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["destination_serveruri"] = OSD.FromString(destination.ServerURI); // 10/3/2010 // I added the client_ip up to the regular AgentCircuitData, so this doesn't need to be here. // This need cleaning elsewhere... //if (ipaddress != null) // args["client_ip"] = OSD.FromString(ipaddress.Address.ToString()); return args; }
/// <summary> /// Do the work necessary to initiate a new user connection for a particular scene. /// At the moment, this consists of setting up the caps infrastructure /// The return bool should allow for connections to be refused, but as not all calling paths /// take proper notice of it let, we allowed banned users in still. /// </summary> /// <param name="agent">CircuitData of the agent who is connecting</param> /// <param name="reason">Outputs the reason for the false response on this string, /// If the agent was accepted, this will be the Caps SEED for the region</param> /// <param name="requirePresenceLookup">True for normal presence. False for NPC /// or other applications where a full grid/Hypergrid presence may not be required.</param> /// <returns>True if the region accepts this agent. False if it does not. False will /// also return a reason.</returns> public bool NewUserConnection (IScene scene, AgentCircuitData agent, uint teleportFlags, out int UDPPort, out string reason) { reason = String.Empty; UDPPort = GetUDPPort (scene); // Don't disable this log message - it's too helpful m_log.TraceFormat ( "[ConnectionBegin]: Region {0} told of incoming {1} agent {2} (circuit code {3}, teleportflags {4})", scene.RegionInfo.RegionName, (agent.child ? "child" : "root"), agent.AgentID, agent.circuitcode, teleportFlags); if (!AuthorizeUser (scene, agent, out reason)) { OSDMap map = new OSDMap (); map["Reason"] = reason; map["Success"] = false; reason = OSDParser.SerializeJsonString (map); return false; } IScenePresence sp = scene.GetScenePresence (agent.AgentID); if (sp != null && !sp.IsChildAgent) { // We have a zombie from a crashed session. // Or the same user is trying to be root twice here, won't work. // Kill it. m_log.InfoFormat ("[Scene]: Zombie scene presence detected for {0} in {1}", agent.AgentID, scene.RegionInfo.RegionName); //Tell everyone about it scene.AuroraEventManager.FireGenericEventHandler ("AgentIsAZombie", sp.UUID); //Send the killing message (DisableSimulator) scene.RemoveAgent (sp, true); sp = null; } OSDMap responseMap = new OSDMap (); responseMap["CapsUrls"] = scene.EventManager.TriggerOnRegisterCaps (agent.AgentID); responseMap["OurIPForClient"] = NetworkUtils.ResolveAddressForClient(NetworkUtils.GetHostFromDNS(scene.RegionInfo.ExternalHostName), new IPEndPoint(IPAddress.Parse(agent.IPAddress), 0)).ToString(); // In all cases, add or update the circuit data with the new agent circuit data and teleport flags agent.teleportFlags = teleportFlags; responseMap["Agent"] = agent.PackAgentCircuitData (); object[] obj = new object[2]; obj[0] = responseMap; obj[1] = agent; scene.AuroraEventManager.FireGenericEventHandler ("NewUserConnection", obj); //Add the circuit at the end scene.AuthenticateHandler.AddNewCircuit (agent.circuitcode, agent); m_log.InfoFormat ( "[ConnectionBegin]: Region {0} authenticated and authorized incoming {1} agent {2} (circuit code {3})", scene.RegionInfo.RegionName, (agent.child ? "child" : "root"), agent.AgentID, agent.circuitcode); responseMap["Success"] = true; reason = OSDParser.SerializeJsonString (responseMap); return true; }
public bool CreateAgent(GridRegion destination, AgentCircuitData aCircuit, uint flags, out string reason) { // m_log.DebugFormat("[REMOTE SIMULATION CONNECTOR]: CreateAgent start"); reason = String.Empty; if (destination == null) { m_log.Debug("[REMOTE SIMULATION 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, 20000); if (result["Success"].AsBoolean()) return true; m_log.WarnFormat( "[REMOTE SIMULATION CONNECTOR]: Failed to create agent {0} {1} at remote simulator {1}", aCircuit.firstname, aCircuit.lastname, destination.RegionName); 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; }
/// <summary> /// Do the work necessary to initiate a new user connection for a particular scene. /// At the moment, this consists of setting up the caps infrastructure /// The return bool should allow for connections to be refused, but as not all calling paths /// take proper notice of it let, we allowed banned users in still. /// </summary> /// <param name="agent">CircuitData of the agent who is connecting</param> /// <param name="reason">Outputs the reason for the false response on this string, /// If the agent was accepted, this will be the Caps SEED for the region</param> /// <param name="requirePresenceLookup">True for normal presence. False for NPC /// or other applications where a full grid/Hypergrid presence may not be required.</param> /// <returns>True if the region accepts this agent. False if it does not. False will /// also return a reason.</returns> public bool NewUserConnection (IScene scene, AgentCircuitData agent, uint teleportFlags, out string reason) { reason = String.Empty; // Don't disable this log message - it's too helpful m_log.DebugFormat ( "[ConnectionBegin]: Region {0} told of incoming {1} agent {2} (circuit code {3}, teleportflags {4})", scene.RegionInfo.RegionName, (agent.child ? "child" : "root"), agent.AgentID, agent.circuitcode, teleportFlags); if (!AuthorizeUser (scene, agent, out reason)) { OSDMap map = new OSDMap (); map["Reason"] = reason; map["Success"] = false; reason = OSDParser.SerializeJsonString (map); return false; } IScenePresence sp = scene.GetScenePresence (agent.AgentID); if (sp != null && !sp.IsChildAgent) { // We have a zombie from a crashed session. // Or the same user is trying to be root twice here, won't work. // Kill it. m_log.InfoFormat ("[Scene]: Zombie scene presence detected for {0} in {1}", agent.AgentID, scene.RegionInfo.RegionName); scene.RemoveAgent (sp); sp = null; } //Add possible Urls for the given agent IConfigurationService configService = scene.RequestModuleInterface<IConfigurationService> (); if (configService != null && agent.OtherInformation.ContainsKey ("UserUrls")) { configService.AddNewUser (agent.AgentID.ToString (), (OSDMap)agent.OtherInformation["UserUrls"]); } OSDMap responseMap = new OSDMap (); responseMap["CapsUrls"] = scene.EventManager.TriggerOnRegisterCaps (agent.AgentID); // In all cases, add or update the circuit data with the new agent circuit data and teleport flags agent.teleportFlags = teleportFlags; //Add the circuit at the end scene.AuthenticateHandler.AddNewCircuit (agent.circuitcode, agent); responseMap["Agent"] = agent.PackAgentCircuitData (); scene.AuroraEventManager.FireGenericEventHandler ("NewUserConnection", responseMap); m_log.InfoFormat ( "[ConnectionBegin]: Region {0} authenticated and authorized incoming {1} agent {2} (circuit code {3})", scene.RegionInfo.RegionName, (agent.child ? "child" : "root"), agent.AgentID, agent.circuitcode); responseMap["Success"] = true; reason = OSDParser.SerializeJsonString (responseMap); return true; }
public virtual bool CreateAgent(GridRegion destination, ref AgentCircuitData aCircuit, uint teleportFlags, AgentData data, out int requestedUDPPort, out string reason) { reason = String.Empty; // Try local first if (m_localBackend.CreateAgent(destination, ref aCircuit, teleportFlags, data, out requestedUDPPort, out reason)) return true; requestedUDPPort = destination.ExternalEndPoint.Port; //Just make sure.. reason = String.Empty; string uri = MakeUri(destination, true) + 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(teleportFlags.ToString()); if (data != null) args["agent_data"] = data.Pack(); OSDMap result = WebUtils.PostToService(uri, args, true, false); OSDMap results = WebUtils.GetOSDMap(result["_RawResult"].AsString()); //Pull out the result and set it as the reason if (results == null) return false; reason = results["reason"] != null ? results["reason"].AsString() : ""; if (result["Success"].AsBoolean()) { //Not right... don't return true except for opensim combatibility :/ if (reason == "") return true; //We were able to contact the region try { //We send the CapsURLs through, so we need these OSDMap responseMap = (OSDMap) OSDParser.DeserializeJson(reason); if (responseMap.ContainsKey("Reason")) reason = responseMap["Reason"].AsString(); if (responseMap.ContainsKey("requestedUDPPort")) requestedUDPPort = responseMap["requestedUDPPort"]; return results["success"].AsBoolean(); } catch { //Something went wrong return false; } } reason = result.ContainsKey("Message") ? result["Message"].AsString() : "Could not contact the region"; return false; } catch (Exception e) { MainConsole.Instance.Warn("[REMOTE SIMULATION CONNECTOR]: CreateAgent failed with exception: " + e); reason = e.Message; } return false; }
public static OSDMap CrossAgent(GridRegion crossingRegion, Vector3 pos, Vector3 velocity, AgentCircuitData circuit, AgentData cAgent, ulong RequestingRegion) { OSDMap llsdBody = new OSDMap(); llsdBody.Add("Pos", pos); llsdBody.Add("Vel", velocity); llsdBody.Add("Region", crossingRegion.ToOSD()); llsdBody.Add("Circuit", circuit.PackAgentCircuitData()); llsdBody.Add("AgentData", cAgent.Pack()); return buildEvent("CrossAgent", llsdBody, circuit.AgentID, RequestingRegion); }
public static OSD EnableChildAgents(int DrawDistance, GridRegion[] neighbors, AgentCircuitData circuit, uint TeleportFlags, AgentData data, byte[] IPAddress, int Port) { OSDMap llsdBody = new OSDMap(); llsdBody.Add("DrawDistance", DrawDistance); OSDArray regionsArray = new OSDArray(); foreach (GridRegion r in neighbors) { regionsArray.Add(r.ToOSD()); } llsdBody.Add("Regions", regionsArray); if(IPAddress != null) llsdBody.Add("IPAddress", IPAddress); if(Port != 0) //0 is the eqivilent of null llsdBody.Add("Port", Port); llsdBody.Add("Circuit", circuit.PackAgentCircuitData()); llsdBody.Add("TeleportFlags", TeleportFlags); if(data != null) llsdBody.Add("AgentData", data.Pack()); return buildEvent("EnableChildAgents", llsdBody); }
public static OSDMap TeleportAgent(int DrawDistance, AgentCircuitData circuit, AgentData data, uint TeleportFlags, GridRegion destination, ulong requestingRegion) { OSDMap llsdBody = new OSDMap(); llsdBody.Add("DrawDistance", DrawDistance); llsdBody.Add("Circuit", circuit.PackAgentCircuitData()); llsdBody.Add("TeleportFlags", TeleportFlags); llsdBody.Add("AgentData", data.Pack()); llsdBody.Add("Region", destination.ToOSD()); return buildEvent("TeleportAgent", llsdBody, circuit.AgentID, requestingRegion); }
public bool CreateAgent(GridRegion destination, AgentCircuitData aCircuit, uint flags, out string reason) { // m_log.DebugFormat("[REMOTE SIMULATION CONNECTOR]: CreateAgent start"); reason = String.Empty; if (destination == null) { m_log.Debug("[REMOTE SIMULATION 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.PostToServiceCompressed(uri, args, 30000); bool success = result["success"].AsBoolean(); if (success && result.ContainsKey("_Result")) { OSDMap data = (OSDMap)result["_Result"]; reason = data["reason"].AsString(); success = data["success"].AsBoolean(); return success; } // Try the old version, uncompressed result = WebUtil.PostToService(uri, args, 30000); if (result["Success"].AsBoolean()) { if (result.ContainsKey("_Result")) { OSDMap data = (OSDMap)result["_Result"]; reason = data["reason"].AsString(); success = data["success"].AsBoolean(); m_log.WarnFormat( "[REMOTE SIMULATION CONNECTOR]: Remote simulator {0} did not accept compressed transfer, suggest updating it.", destination.RegionName); return success; } } m_log.WarnFormat( "[REMOTE SIMULATION CONNECTOR]: Failed to create agent {0} {1} at remote simulator {2}", aCircuit.firstname, aCircuit.lastname, destination.RegionName); 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; }
public static OSD EnableChildAgents(int DrawDistance, AgentCircuitData circuit) { OSDMap llsdBody = new OSDMap(); llsdBody.Add("DrawDistance", DrawDistance); llsdBody.Add("Circuit", circuit.PackAgentCircuitData()); return buildEvent("EnableChildAgents", llsdBody); }