* Refactored out creation of LoginResponse
* Refactored out ErrorResponse0.6.0-stable
parent
47ed69c933
commit
d873a043dd
|
@ -239,6 +239,15 @@ namespace OpenSim.Grid.GridServer
|
||||||
return validated;
|
return validated;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private XmlRpcResponse ErrorResponse(string error)
|
||||||
|
{
|
||||||
|
XmlRpcResponse errorResponse = new XmlRpcResponse();
|
||||||
|
Hashtable errorResponseData = new Hashtable();
|
||||||
|
errorResponse.Value = errorResponseData;
|
||||||
|
errorResponseData["error"] = error;
|
||||||
|
return errorResponse;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Performed when a region connects to the grid server initially.
|
/// Performed when a region connects to the grid server initially.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -246,9 +255,6 @@ namespace OpenSim.Grid.GridServer
|
||||||
/// <returns>Startup parameters</returns>
|
/// <returns>Startup parameters</returns>
|
||||||
public XmlRpcResponse XmlRpcSimulatorLoginMethod(XmlRpcRequest request)
|
public XmlRpcResponse XmlRpcSimulatorLoginMethod(XmlRpcRequest request)
|
||||||
{
|
{
|
||||||
XmlRpcResponse response = new XmlRpcResponse();
|
|
||||||
Hashtable responseData = new Hashtable();
|
|
||||||
response.Value = responseData;
|
|
||||||
|
|
||||||
RegionProfileData sim;
|
RegionProfileData sim;
|
||||||
RegionProfileData existingSim;
|
RegionProfileData existingSim;
|
||||||
|
@ -258,13 +264,11 @@ namespace OpenSim.Grid.GridServer
|
||||||
|
|
||||||
if (requestData.ContainsKey("UUID") && LLUUID.TryParse((string)requestData["UUID"], out uuid))
|
if (requestData.ContainsKey("UUID") && LLUUID.TryParse((string)requestData["UUID"], out uuid))
|
||||||
{
|
{
|
||||||
existingSim = getRegion(uuid);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_log.Info("[GRID]: Region connected without a UUID, ignoring.");
|
m_log.Info("[GRID]: Region connected without a UUID, ignoring.");
|
||||||
responseData["error"] = "No UUID passed to grid server - unable to connect you";
|
return ErrorResponse("No UUID passed to grid server - unable to connect you");
|
||||||
return response;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
|
@ -274,8 +278,7 @@ namespace OpenSim.Grid.GridServer
|
||||||
catch (FormatException e)
|
catch (FormatException e)
|
||||||
{
|
{
|
||||||
m_log.Info("[GRID]: Invalid login parameters, ignoring.");
|
m_log.Info("[GRID]: Invalid login parameters, ignoring.");
|
||||||
responseData["error"] = "Wrong format in login parameters. Please verify parameters.";
|
return ErrorResponse("Wrong format in login parameters. Please verify parameters.");
|
||||||
return response;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
existingSim = getRegion(sim.regionHandle);
|
existingSim = getRegion(sim.regionHandle);
|
||||||
|
@ -325,17 +328,86 @@ namespace OpenSim.Grid.GridServer
|
||||||
"Unable to add region " + sim.UUID.ToString() + " via " + kvp.Key);
|
"Unable to add region " + sim.UUID.ToString() + " via " + kvp.Key);
|
||||||
m_log.Warn("[storage]: " + e.ToString());
|
m_log.Warn("[storage]: " + e.ToString());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
XmlRpcResponse response = CreateLoginResponse(sim);
|
||||||
|
|
||||||
if (getRegion(sim.regionHandle) == null)
|
|
||||||
{
|
|
||||||
responseData["error"] = "Unable to add new region";
|
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (existingSim == null)
|
||||||
|
{
|
||||||
|
m_log.Warn("[grid]: Authentication failed when trying to add new region " + sim.regionName +
|
||||||
|
" at location " + sim.regionLocX +
|
||||||
|
" " + sim.regionLocY + " with TheSim.regionRecvKey " + sim.regionRecvKey + "(" + Config.SimSendKey + ") and TheSim.regionRecvKey " + sim.regionSendKey + "(" + Config.SimRecvKey + ") ");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_log.Warn("[grid]: Authentication failed when trying to add new region " + sim.regionName +
|
||||||
|
" at location " + sim.regionLocX +
|
||||||
|
" " + sim.regionLocY + " currently occupied by " + existingSim.regionName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return ErrorResponse("The key required to connect to your region did not match. Please check your send and recieve keys.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_log.Warn("[grid]: Failed to add new region " + sim.regionName + " at location " + sim.regionLocX + " " + sim.regionLocY + " currently occupied by " + existingSim.regionName);
|
||||||
|
return ErrorResponse("Another region already exists at that location. Try another");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private XmlRpcResponse CreateLoginResponse(RegionProfileData sim)
|
||||||
|
{
|
||||||
|
XmlRpcResponse response = new XmlRpcResponse();
|
||||||
|
Hashtable responseData = new Hashtable();
|
||||||
|
response.Value = responseData;
|
||||||
|
|
||||||
|
ArrayList SimNeighboursData = GetSimNeighboursData(sim);
|
||||||
|
|
||||||
|
responseData["UUID"] = sim.UUID.ToString();
|
||||||
|
responseData["region_locx"] = sim.regionLocX.ToString();
|
||||||
|
responseData["region_locy"] = sim.regionLocY.ToString();
|
||||||
|
responseData["regionname"] = sim.regionName;
|
||||||
|
responseData["estate_id"] = "1";
|
||||||
|
responseData["neighbours"] = SimNeighboursData;
|
||||||
|
|
||||||
|
responseData["sim_ip"] = sim.serverIP;
|
||||||
|
responseData["sim_port"] = sim.serverPort.ToString();
|
||||||
|
responseData["asset_url"] = sim.regionAssetURI;
|
||||||
|
responseData["asset_sendkey"] = sim.regionAssetSendKey;
|
||||||
|
responseData["asset_recvkey"] = sim.regionAssetRecvKey;
|
||||||
|
responseData["user_url"] = sim.regionUserURI;
|
||||||
|
responseData["user_sendkey"] = sim.regionUserSendKey;
|
||||||
|
responseData["user_recvkey"] = sim.regionUserRecvKey;
|
||||||
|
responseData["authkey"] = sim.regionSecret;
|
||||||
|
|
||||||
|
// New! If set, use as URL to local sim storage (ie http://remotehost/region.yap)
|
||||||
|
responseData["data_uri"] = sim.regionDataURI;
|
||||||
|
|
||||||
|
responseData["allow_forceful_banlines"] = Config.AllowForcefulBanlines;
|
||||||
|
|
||||||
|
// Instead of sending a multitude of message servers to the registering sim
|
||||||
|
// we should probably be sending a single one and parhaps it's backup
|
||||||
|
// that has responsibility over routing it's messages.
|
||||||
|
|
||||||
|
// The Sim won't be contacting us again about any of the message server stuff during it's time up.
|
||||||
|
|
||||||
|
responseData["messageserver_count"] = _MessageServers.Count;
|
||||||
|
|
||||||
|
for (int i = 0; i < _MessageServers.Count; i++)
|
||||||
|
{
|
||||||
|
responseData["messageserver_uri" + i] = _MessageServers[i].URI;
|
||||||
|
responseData["messageserver_sendkey" + i] = _MessageServers[i].sendkey;
|
||||||
|
responseData["messageserver_recvkey" + i] = _MessageServers[i].recvkey;
|
||||||
|
}
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
private ArrayList GetSimNeighboursData(RegionProfileData sim)
|
||||||
|
{
|
||||||
ArrayList SimNeighboursData = new ArrayList();
|
ArrayList SimNeighboursData = new ArrayList();
|
||||||
|
|
||||||
RegionProfileData neighbour;
|
RegionProfileData neighbour;
|
||||||
|
@ -392,72 +464,7 @@ namespace OpenSim.Grid.GridServer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return SimNeighboursData;
|
||||||
responseData["UUID"] = sim.UUID.ToString();
|
|
||||||
responseData["region_locx"] = sim.regionLocX.ToString();
|
|
||||||
responseData["region_locy"] = sim.regionLocY.ToString();
|
|
||||||
responseData["regionname"] = sim.regionName;
|
|
||||||
responseData["estate_id"] = "1";
|
|
||||||
responseData["neighbours"] = SimNeighboursData;
|
|
||||||
|
|
||||||
responseData["sim_ip"] = sim.serverIP;
|
|
||||||
responseData["sim_port"] = sim.serverPort.ToString();
|
|
||||||
responseData["asset_url"] = sim.regionAssetURI;
|
|
||||||
responseData["asset_sendkey"] = sim.regionAssetSendKey;
|
|
||||||
responseData["asset_recvkey"] = sim.regionAssetRecvKey;
|
|
||||||
responseData["user_url"] = sim.regionUserURI;
|
|
||||||
responseData["user_sendkey"] = sim.regionUserSendKey;
|
|
||||||
responseData["user_recvkey"] = sim.regionUserRecvKey;
|
|
||||||
responseData["authkey"] = sim.regionSecret;
|
|
||||||
|
|
||||||
// New! If set, use as URL to local sim storage (ie http://remotehost/region.yap)
|
|
||||||
responseData["data_uri"] = sim.regionDataURI;
|
|
||||||
|
|
||||||
responseData["allow_forceful_banlines"] = Config.AllowForcefulBanlines;
|
|
||||||
|
|
||||||
// Instead of sending a multitude of message servers to the registering sim
|
|
||||||
// we should probably be sending a single one and parhaps it's backup
|
|
||||||
// that has responsibility over routing it's messages.
|
|
||||||
|
|
||||||
// The Sim won't be contacting us again about any of the message server stuff during it's time up.
|
|
||||||
|
|
||||||
responseData["messageserver_count"] = _MessageServers.Count;
|
|
||||||
|
|
||||||
for (int i = 0; i < _MessageServers.Count; i++)
|
|
||||||
{
|
|
||||||
responseData["messageserver_uri" + i] = _MessageServers[i].URI;
|
|
||||||
responseData["messageserver_sendkey" + i] = _MessageServers[i].sendkey;
|
|
||||||
responseData["messageserver_recvkey" + i] = _MessageServers[i].recvkey;
|
|
||||||
}
|
|
||||||
return response;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (existingSim == null)
|
|
||||||
{
|
|
||||||
m_log.Warn("[grid]: Authentication failed when trying to add new region " + sim.regionName +
|
|
||||||
" at location " + sim.regionLocX +
|
|
||||||
" " + sim.regionLocY + " with TheSim.regionRecvKey " + sim.regionRecvKey + "(" + Config.SimSendKey + ") and TheSim.regionRecvKey " + sim.regionSendKey + "(" + Config.SimRecvKey + ") ");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_log.Warn("[grid]: Authentication failed when trying to add new region " + sim.regionName +
|
|
||||||
" at location " + sim.regionLocX +
|
|
||||||
" " + sim.regionLocY + " currently occupied by " + existingSim.regionName);
|
|
||||||
}
|
|
||||||
|
|
||||||
responseData["error"] =
|
|
||||||
"The key required to connect to your region did not match. Please check your send and recieve keys.";
|
|
||||||
return response;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_log.Warn("[grid]: Failed to add new region " + sim.regionName + " at location " + sim.regionLocX + " " + sim.regionLocY + " currently occupied by " + existingSim.regionName);
|
|
||||||
responseData["error"] = "Another region already exists at that location. Try another";
|
|
||||||
return response;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private RegionProfileData RegionFromRequest(Hashtable requestData)
|
private RegionProfileData RegionFromRequest(Hashtable requestData)
|
||||||
|
|
Loading…
Reference in New Issue