Merge branch 'master' of melanie@opensimulator.org:/var/git/opensim

prebuild-update
Melanie 2010-08-20 08:36:54 +01:00
commit 82abaadd55
11 changed files with 213 additions and 164 deletions

View File

@ -83,7 +83,9 @@ namespace OpenSim.Framework
/// <summary>Finished, Sim Changed</summary> /// <summary>Finished, Sim Changed</summary>
FinishedViaNewSim = 1 << 28, FinishedViaNewSim = 1 << 28,
/// <summary>Finished, Same Sim</summary> /// <summary>Finished, Same Sim</summary>
FinishedViaSameSim = 1 << 29 FinishedViaSameSim = 1 << 29,
/// <summary>Agent coming into the grid from another grid</summary>
ViaHGLogin = 1 << 30
} }
} }

View File

@ -181,16 +181,8 @@ namespace OpenSim.Framework
throw new ArgumentException("[NetworkUtil] Unable to resolve defaultHostname to an IPv4 address for an IPv4 client"); throw new ArgumentException("[NetworkUtil] Unable to resolve defaultHostname to an IPv4 address for an IPv4 client");
} }
static IPAddress externalIPAddress;
static NetworkUtil() static NetworkUtil()
{ {
try
{
externalIPAddress = GetExternalIP();
}
catch { /* ignore */ }
try try
{ {
foreach (NetworkInterface ni in NetworkInterface.GetAllNetworkInterfaces()) foreach (NetworkInterface ni in NetworkInterface.GetAllNetworkInterfaces())
@ -254,79 +246,5 @@ namespace OpenSim.Framework
return defaultHostname; return defaultHostname;
} }
public static IPAddress GetExternalIPOf(IPAddress user)
{
if (externalIPAddress == null)
return user;
if (user.ToString() == "127.0.0.1")
{
m_log.Info("[NetworkUtil] 127.0.0.1 user detected, sending '" + externalIPAddress + "' instead of '" + user + "'");
return externalIPAddress;
}
// Check if we're accessing localhost.
foreach (IPAddress host in Dns.GetHostAddresses(Dns.GetHostName()))
{
if (host.Equals(user) && host.AddressFamily == AddressFamily.InterNetwork)
{
m_log.Info("[NetworkUtil] Localhost user detected, sending '" + externalIPAddress + "' instead of '" + user + "'");
return externalIPAddress;
}
}
// Check for same LAN segment
foreach (KeyValuePair<IPAddress, IPAddress> subnet in m_subnets)
{
byte[] subnetBytes = subnet.Value.GetAddressBytes();
byte[] localBytes = subnet.Key.GetAddressBytes();
byte[] destBytes = user.GetAddressBytes();
if (subnetBytes.Length != destBytes.Length || subnetBytes.Length != localBytes.Length)
return user;
bool valid = true;
for (int i = 0; i < subnetBytes.Length; i++)
{
if ((localBytes[i] & subnetBytes[i]) != (destBytes[i] & subnetBytes[i]))
{
valid = false;
break;
}
}
if (subnet.Key.AddressFamily != AddressFamily.InterNetwork)
valid = false;
if (valid)
{
m_log.Info("[NetworkUtil] Local LAN user detected, sending '" + externalIPAddress + "' instead of '" + user + "'");
return externalIPAddress;
}
}
// Otherwise, return user address
return user;
}
private static IPAddress GetExternalIP()
{
string whatIsMyIp = "http://www.whatismyip.com/automation/n09230945.asp";
WebClient wc = new WebClient();
UTF8Encoding utf8 = new UTF8Encoding();
string requestHtml = "";
try
{
requestHtml = utf8.GetString(wc.DownloadData(whatIsMyIp));
}
catch (WebException we)
{
m_log.Info("[NetworkUtil]: Exception in GetExternalIP: " + we.ToString());
return null;
}
IPAddress externalIp = IPAddress.Parse(requestHtml);
return externalIp;
}
} }
} }

View File

@ -2538,26 +2538,26 @@ namespace OpenSim.Region.Framework.Scenes
{ {
AgentCircuitData aCircuit = m_authenticateHandler.GetAgentCircuitData(client.CircuitCode); AgentCircuitData aCircuit = m_authenticateHandler.GetAgentCircuitData(client.CircuitCode);
// Do the verification here //// Do the verification here -- No, really don't do this here. This is UDP address, let it go.
System.Net.IPEndPoint ep = (System.Net.IPEndPoint)client.GetClientEP(); //System.Net.IPEndPoint ep = (System.Net.IPEndPoint)client.GetClientEP();
if (aCircuit != null) //if (aCircuit != null)
{ //{
if (!VerifyClient(aCircuit, ep, out vialogin)) // if (!VerifyClient(aCircuit, ep, out vialogin))
{ // {
// uh-oh, this is fishy // // uh-oh, this is fishy
m_log.WarnFormat("[SCENE]: Agent {0} with session {1} connecting with unidentified end point {2}. Refusing service.", // m_log.WarnFormat("[SCENE]: Agent {0} with session {1} connecting with unidentified end point {2}. Refusing service.",
client.AgentId, client.SessionId, ep.ToString()); // client.AgentId, client.SessionId, ep.ToString());
try // try
{ // {
client.Close(); // client.Close();
} // }
catch (Exception e) // catch (Exception e)
{ // {
m_log.DebugFormat("[SCENE]: Exception while closing aborted client: {0}", e.StackTrace); // m_log.DebugFormat("[SCENE]: Exception while closing aborted client: {0}", e.StackTrace);
} // }
return; // return;
} // }
} //}
m_log.Debug("[SCENE]: Adding new agent " + client.Name + " to scene " + RegionInfo.RegionName); m_log.Debug("[SCENE]: Adding new agent " + client.Name + " to scene " + RegionInfo.RegionName);
@ -2586,16 +2586,14 @@ namespace OpenSim.Region.Framework.Scenes
vialogin = false; vialogin = false;
// Do the verification here // Do the verification here
if ((aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0) if ((aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0)
{ {
m_log.DebugFormat("[SCENE]: Incoming client {0} {1} in region {2} via Login", aCircuit.firstname, aCircuit.lastname, RegionInfo.RegionName); m_log.DebugFormat("[SCENE]: Incoming client {0} {1} in region {2} via HG login", aCircuit.firstname, aCircuit.lastname, RegionInfo.RegionName);
vialogin = true; vialogin = true;
IUserAgentVerificationModule userVerification = RequestModuleInterface<IUserAgentVerificationModule>(); IUserAgentVerificationModule userVerification = RequestModuleInterface<IUserAgentVerificationModule>();
if (userVerification != null && ep != null) if (userVerification != null && ep != null)
{ {
System.Net.IPAddress addr = NetworkUtil.GetExternalIPOf(ep.Address); if (!userVerification.VerifyClient(aCircuit, ep.Address.ToString()))
if (!userVerification.VerifyClient(aCircuit, /*ep.Address.ToString() */ addr.ToString()))
{ {
// uh-oh, this is fishy // uh-oh, this is fishy
m_log.DebugFormat("[SCENE]: User Client Verification for {0} {1} in {2} returned false", aCircuit.firstname, aCircuit.lastname, RegionInfo.RegionName); m_log.DebugFormat("[SCENE]: User Client Verification for {0} {1} in {2} returned false", aCircuit.firstname, aCircuit.lastname, RegionInfo.RegionName);
@ -2606,6 +2604,10 @@ namespace OpenSim.Region.Framework.Scenes
} }
} }
else if ((aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0)
m_log.DebugFormat("[SCENE]: Incoming client {0} {1} in region {2} via regular login. Client IP verification not performed.",
aCircuit.firstname, aCircuit.lastname, RegionInfo.RegionName);
return true; return true;
} }

View File

@ -178,6 +178,8 @@ namespace OpenSim.Server.Handlers.Simulation
resp["reason"] = OSD.FromString(reason); resp["reason"] = OSD.FromString(reason);
resp["success"] = OSD.FromBoolean(result); resp["success"] = OSD.FromBoolean(result);
// Let's also send out the IP address of the caller back to the caller (HG 1.5)
resp["your_ip"] = OSD.FromString(GetCallerIP(request));
// TODO: add reason if not String.Empty? // TODO: add reason if not String.Empty?
responsedata["int_response_code"] = HttpStatusCode.OK; responsedata["int_response_code"] = HttpStatusCode.OK;
@ -352,6 +354,24 @@ namespace OpenSim.Server.Handlers.Simulation
{ {
m_SimulationService.ReleaseAgent(regionID, id, ""); m_SimulationService.ReleaseAgent(regionID, id, "");
} }
private string GetCallerIP(Hashtable req)
{
if (req.ContainsKey("headers"))
{
try
{
Hashtable headers = (Hashtable)req["headers"];
if (headers.ContainsKey("remote_addr") && headers["remote_addr"] != null)
return headers["remote_addr"].ToString();
}
catch (Exception e)
{
m_log.WarnFormat("[AGENT HANDLER]: exception in GetCallerIP: {0}", e.Message);
}
}
return string.Empty;
}
} }
} }

View File

@ -38,6 +38,7 @@ using GridRegion = OpenSim.Services.Interfaces.GridRegion;
using OpenMetaverse; using OpenMetaverse;
using OpenMetaverse.Imaging; using OpenMetaverse.Imaging;
using OpenMetaverse.StructuredData;
using Nwc.XmlRpc; using Nwc.XmlRpc;
using log4net; using log4net;
@ -268,5 +269,48 @@ namespace OpenSim.Services.Connectors.Hypergrid
return null; return null;
} }
public bool CreateAgent(GridRegion destination, AgentCircuitData aCircuit, uint flags, out string myipaddress, out string reason)
{
HttpWebRequest AgentCreateRequest = null;
myipaddress = String.Empty;
reason = String.Empty;
if (SendRequest(destination, aCircuit, flags, out reason, out AgentCreateRequest))
{
string response = GetResponse(AgentCreateRequest, out reason);
bool success = true;
UnpackResponse(response, out success, out reason, out myipaddress);
return success;
}
return false;
}
protected void UnpackResponse(string response, out bool result, out string reason, out string ipaddress)
{
result = true;
reason = string.Empty;
ipaddress = string.Empty;
if (!String.IsNullOrEmpty(response))
{
try
{
// we assume we got an OSDMap back
OSDMap r = Util.GetOSDMap(response);
result = r["success"].AsBoolean();
reason = r["reason"].AsString();
ipaddress = r["your_ip"].AsString();
}
catch (NullReferenceException e)
{
m_log.InfoFormat("[GATEKEEPER SERVICE CONNECTOR]: exception on UnpackResponse of DoCreateChildAgentCall {0}", e.Message);
reason = "Internal error";
result = false;
}
}
}
} }
} }

View File

@ -73,6 +73,13 @@ namespace OpenSim.Services.Connectors.Hypergrid
{ {
} }
public bool LoginAgentToGrid(AgentCircuitData agent, GridRegion gatekeeper, GridRegion finalDestination, IPEndPoint ipaddress, out string reason)
{
// not available over remote calls
reason = "Method not available over remote calls";
return false;
}
public bool LoginAgentToGrid(AgentCircuitData aCircuit, GridRegion gatekeeper, GridRegion destination, out string reason) public bool LoginAgentToGrid(AgentCircuitData aCircuit, GridRegion gatekeeper, GridRegion destination, out string reason)
{ {
reason = String.Empty; reason = String.Empty;

View File

@ -77,8 +77,26 @@ namespace OpenSim.Services.Connectors.Simulation
public bool CreateAgent(GridRegion destination, AgentCircuitData aCircuit, uint flags, out string reason) public bool CreateAgent(GridRegion destination, AgentCircuitData aCircuit, uint flags, out string reason)
{ {
HttpWebRequest AgentCreateRequest = null;
reason = String.Empty; reason = String.Empty;
if (SendRequest(destination, aCircuit, flags, out reason, out AgentCreateRequest))
{
string response = GetResponse(AgentCreateRequest, out reason);
bool success = true;
UnpackResponse(response, out success, out reason);
return success;
}
return false;
}
protected bool SendRequest(GridRegion destination, AgentCircuitData aCircuit, uint flags, out string reason, out HttpWebRequest AgentCreateRequest)
{
reason = String.Empty;
AgentCreateRequest = null;
if (destination == null) if (destination == null)
{ {
reason = "Destination is null"; reason = "Destination is null";
@ -101,7 +119,7 @@ namespace OpenSim.Services.Connectors.Simulation
//Console.WriteLine(" >>> DoCreateChildAgentCall <<< " + uri); //Console.WriteLine(" >>> DoCreateChildAgentCall <<< " + uri);
HttpWebRequest AgentCreateRequest = (HttpWebRequest)WebRequest.Create(uri); AgentCreateRequest = (HttpWebRequest)WebRequest.Create(uri);
AgentCreateRequest.Method = "POST"; AgentCreateRequest.Method = "POST";
AgentCreateRequest.ContentType = "application/json"; AgentCreateRequest.ContentType = "application/json";
AgentCreateRequest.Timeout = 10000; AgentCreateRequest.Timeout = 10000;
@ -134,7 +152,7 @@ namespace OpenSim.Services.Connectors.Simulation
AgentCreateRequest.ContentLength = buffer.Length; //Count bytes to send AgentCreateRequest.ContentLength = buffer.Length; //Count bytes to send
os = AgentCreateRequest.GetRequestStream(); os = AgentCreateRequest.GetRequestStream();
os.Write(buffer, 0, strBuffer.Length); //Send it os.Write(buffer, 0, strBuffer.Length); //Send it
m_log.InfoFormat("[REMOTE SIMULATION CONNECTOR]: Posted CreateAgent request to remote sim {0}, region {1}, x={2} y={3}", m_log.InfoFormat("[REMOTE SIMULATION CONNECTOR]: Posted CreateAgent request to remote sim {0}, region {1}, x={2} y={3}",
uri, destination.RegionName, destination.RegionLocX, destination.RegionLocY); uri, destination.RegionName, destination.RegionLocX, destination.RegionLocY);
} }
//catch (WebException ex) //catch (WebException ex)
@ -150,11 +168,18 @@ namespace OpenSim.Services.Connectors.Simulation
os.Close(); os.Close();
} }
return true;
}
protected string GetResponse(HttpWebRequest AgentCreateRequest, out string reason)
{
// Let's wait for the response // Let's wait for the response
//m_log.Info("[REMOTE SIMULATION CONNECTOR]: Waiting for a reply after DoCreateChildAgentCall"); //m_log.Info("[REMOTE SIMULATION CONNECTOR]: Waiting for a reply after DoCreateChildAgentCall");
reason = string.Empty;
WebResponse webResponse = null; WebResponse webResponse = null;
StreamReader sr = null; StreamReader sr = null;
string response = string.Empty;
try try
{ {
webResponse = AgentCreateRequest.GetResponse(); webResponse = AgentCreateRequest.GetResponse();
@ -166,37 +191,15 @@ namespace OpenSim.Services.Connectors.Simulation
{ {
sr = new StreamReader(webResponse.GetResponseStream()); sr = new StreamReader(webResponse.GetResponseStream());
string response = sr.ReadToEnd().Trim(); response = sr.ReadToEnd().Trim();
m_log.InfoFormat("[REMOTE SIMULATION CONNECTOR]: DoCreateChildAgentCall reply was {0} ", response); m_log.InfoFormat("[REMOTE SIMULATION 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("[REMOTE SIMULATION 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) catch (WebException ex)
{ {
m_log.InfoFormat("[REMOTE SIMULATION CONNECTOR]: exception on reply of DoCreateChildAgentCall {0}", ex.Message); m_log.InfoFormat("[REMOTE SIMULATION CONNECTOR]: exception on reply of DoCreateChildAgentCall {0}", ex.Message);
reason = "Destination did not reply"; reason = "Destination did not reply";
return false; return string.Empty;
} }
finally finally
{ {
@ -204,7 +207,33 @@ namespace OpenSim.Services.Connectors.Simulation
sr.Close(); sr.Close();
} }
return true; return response;
}
protected void UnpackResponse(string response, out bool result, out string reason)
{
result = true;
reason = string.Empty;
if (!String.IsNullOrEmpty(response))
{
try
{
// we assume we got an OSDMap back
OSDMap r = Util.GetOSDMap(response);
result = r["success"].AsBoolean();
reason = r["reason"].AsString();
}
catch (NullReferenceException e)
{
m_log.InfoFormat("[REMOTE SIMULATION CONNECTOR]: exception on reply of DoCreateChildAgentCall {0}", e.Message);
// check for old style response
if (response.ToLower().StartsWith("true"))
result = true;
result = false;
}
}
} }
protected virtual OSDMap PackCreateAgentArguments(AgentCircuitData aCircuit, GridRegion destination, uint flags) protected virtual OSDMap PackCreateAgentArguments(AgentCircuitData aCircuit, GridRegion destination, uint flags)

View File

@ -225,17 +225,23 @@ namespace OpenSim.Services.HypergridService
// May want to authorize // May want to authorize
bool isFirstLogin = false;
// //
// Login the presence // Login the presence, if it's not there yet (by the login service)
// //
if (!m_PresenceService.LoginAgent(aCircuit.AgentID.ToString(), aCircuit.SessionID, aCircuit.SecureSessionID)) PresenceInfo presence = m_PresenceService.GetAgent(aCircuit.SessionID);
{ if (presence != null) // it has been placed there by the login service
reason = "Unable to login presence"; isFirstLogin = true;
m_log.InfoFormat("[GATEKEEPER SERVICE]: Presence login failed for foreign agent {0} {1}. Refusing service.",
aCircuit.firstname, aCircuit.lastname); else
return false; if (!m_PresenceService.LoginAgent(aCircuit.AgentID.ToString(), aCircuit.SessionID, aCircuit.SecureSessionID))
} {
m_log.DebugFormat("[GATEKEEPER SERVICE]: Login presence ok"); reason = "Unable to login presence";
m_log.InfoFormat("[GATEKEEPER SERVICE]: Presence login failed for foreign agent {0} {1}. Refusing service.",
aCircuit.firstname, aCircuit.lastname);
return false;
}
m_log.DebugFormat("[GATEKEEPER SERVICE]: Login presence ok");
// //
// Get the region // Get the region
@ -274,7 +280,9 @@ namespace OpenSim.Services.HypergridService
// //
// Finally launch the agent at the destination // Finally launch the agent at the destination
// //
return m_SimulationService.CreateAgent(destination, aCircuit, (uint)Constants.TeleportFlags.ViaLogin, out reason); Constants.TeleportFlags loginFlag = isFirstLogin ? Constants.TeleportFlags.ViaLogin : Constants.TeleportFlags.ViaHGLogin;
m_log.DebugFormat("[GATEKEEPER SERVICE]: launching agent {0}", loginFlag);
return m_SimulationService.CreateAgent(destination, aCircuit, (uint)loginFlag, out reason);
} }
protected bool Authenticate(AgentCircuitData aCircuit) protected bool Authenticate(AgentCircuitData aCircuit)

View File

@ -131,10 +131,11 @@ namespace OpenSim.Services.HypergridService
return home; return home;
} }
public bool LoginAgentToGrid(AgentCircuitData agentCircuit, GridRegion gatekeeper, GridRegion finalDestination, out string reason) public bool LoginAgentToGrid(AgentCircuitData agentCircuit, GridRegion gatekeeper, GridRegion finalDestination, IPEndPoint clientIP, out string reason)
{ {
m_log.DebugFormat("[USER AGENT SERVICE]: Request to login user {0} {1} to grid {2}", m_log.DebugFormat("[USER AGENT SERVICE]: Request to login user {0} {1} (@{2}) to grid {3}",
agentCircuit.firstname, agentCircuit.lastname, gatekeeper.ExternalHostName +":"+ gatekeeper.HttpPort); agentCircuit.firstname, agentCircuit.lastname, ((clientIP == null) ? "stored IP" : clientIP.Address.ToString()),
gatekeeper.ExternalHostName +":"+ gatekeeper.HttpPort);
// Take the IP address + port of the gatekeeper (reg) plus the info of finalDestination // Take the IP address + port of the gatekeeper (reg) plus the info of finalDestination
GridRegion region = new GridRegion(gatekeeper); GridRegion region = new GridRegion(gatekeeper);
@ -149,11 +150,12 @@ namespace OpenSim.Services.HypergridService
//bool success = m_GatekeeperConnector.CreateAgent(region, agentCircuit, (uint)Constants.TeleportFlags.ViaLogin, out reason); //bool success = m_GatekeeperConnector.CreateAgent(region, agentCircuit, (uint)Constants.TeleportFlags.ViaLogin, out reason);
bool success = false; bool success = false;
string myExternalIP = string.Empty;
string gridName = "http://" + gatekeeper.ExternalHostName + ":" + gatekeeper.HttpPort; string gridName = "http://" + gatekeeper.ExternalHostName + ":" + gatekeeper.HttpPort;
if (m_GridName == gridName) if (m_GridName == gridName)
success = m_GatekeeperService.LoginAgent(agentCircuit, finalDestination, out reason); success = m_GatekeeperService.LoginAgent(agentCircuit, finalDestination, out reason);
else else
success = m_GatekeeperConnector.CreateAgent(region, agentCircuit, (uint)Constants.TeleportFlags.ViaLogin, out reason); success = m_GatekeeperConnector.CreateAgent(region, agentCircuit, (uint)Constants.TeleportFlags.ViaLogin, out myExternalIP, out reason);
if (!success) if (!success)
{ {
@ -167,15 +169,26 @@ namespace OpenSim.Services.HypergridService
return false; return false;
} }
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();
m_TravelingAgents[agentCircuit.SessionID].MyIpAddress = myExternalIP;
return true; return true;
} }
public void SetClientToken(UUID sessionID, string token) public bool LoginAgentToGrid(AgentCircuitData agentCircuit, GridRegion gatekeeper, GridRegion finalDestination, out string reason)
{
reason = string.Empty;
return LoginAgentToGrid(agentCircuit, gatekeeper, finalDestination, null, out reason);
}
private void SetClientIP(UUID sessionID, string ip)
{ {
if (m_TravelingAgents.ContainsKey(sessionID)) if (m_TravelingAgents.ContainsKey(sessionID))
{ {
m_log.DebugFormat("[USER AGENT SERVICE]: Setting token {0} for session {1}", token, sessionID); m_log.DebugFormat("[USER AGENT SERVICE]: Setting IP {0} for session {1}", ip, sessionID);
m_TravelingAgents[sessionID].ClientToken = token; m_TravelingAgents[sessionID].ClientIPAddress = ip;
} }
} }
@ -196,7 +209,7 @@ namespace OpenSim.Services.HypergridService
travel.GridExternalName = "http://" + region.ExternalHostName + ":" + region.HttpPort; travel.GridExternalName = "http://" + region.ExternalHostName + ":" + region.HttpPort;
travel.ServiceToken = agentCircuit.ServiceSessionID; travel.ServiceToken = agentCircuit.ServiceSessionID;
if (old != null) if (old != null)
travel.ClientToken = old.ClientToken; travel.ClientIPAddress = old.ClientIPAddress;
return old; return old;
} }
@ -233,15 +246,22 @@ namespace OpenSim.Services.HypergridService
return travel.GridExternalName == thisGridExternalName; return travel.GridExternalName == thisGridExternalName;
} }
public bool VerifyClient(UUID sessionID, string token) public bool VerifyClient(UUID sessionID, string reportedIP)
{ {
if (m_BypassClientVerification) if (m_BypassClientVerification)
return true; return true;
m_log.DebugFormat("[USER AGENT SERVICE]: Verifying Client session {0} with token {1}", sessionID, token); m_log.DebugFormat("[USER AGENT SERVICE]: Verifying Client session {0} with reported IP {1}.",
sessionID, reportedIP);
if (m_TravelingAgents.ContainsKey(sessionID)) if (m_TravelingAgents.ContainsKey(sessionID))
return m_TravelingAgents[sessionID].ClientToken == token; {
m_log.DebugFormat("[USER AGENT SERVICE]: Comparing with login IP {0} and MyIP {1}",
m_TravelingAgents[sessionID].ClientIPAddress, m_TravelingAgents[sessionID].MyIpAddress);
return m_TravelingAgents[sessionID].ClientIPAddress == reportedIP ||
m_TravelingAgents[sessionID].MyIpAddress == reportedIP; // NATed
}
return false; return false;
} }
@ -266,7 +286,8 @@ namespace OpenSim.Services.HypergridService
public UUID UserID; public UUID UserID;
public string GridExternalName = string.Empty; public string GridExternalName = string.Empty;
public string ServiceToken = string.Empty; public string ServiceToken = string.Empty;
public string ClientToken = string.Empty; public string ClientIPAddress = string.Empty; // as seen from this user agent service
public string MyIpAddress = string.Empty; // the user agent service's external IP, as seen from the next gatekeeper
} }
} }

View File

@ -48,13 +48,15 @@ namespace OpenSim.Services.Interfaces
/// </summary> /// </summary>
public interface IUserAgentService 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, out string reason);
void SetClientToken(UUID sessionID, string token);
void LogoutAgent(UUID userID, UUID sessionID); void LogoutAgent(UUID userID, UUID sessionID);
GridRegion GetHomeRegion(UUID userID, out Vector3 position, out Vector3 lookAt); GridRegion GetHomeRegion(UUID userID, out Vector3 position, out Vector3 lookAt);
bool AgentIsComingHome(UUID sessionID, string thisGridExternalName); bool AgentIsComingHome(UUID sessionID, string thisGridExternalName);
bool VerifyAgent(UUID sessionID, string token); bool VerifyAgent(UUID sessionID, string token);
bool VerifyClient(UUID sessionID, string token); bool VerifyClient(UUID sessionID, string reportedIP);
} }
} }

View File

@ -755,12 +755,8 @@ namespace OpenSim.Services.LLLoginService
private bool LaunchAgentIndirectly(GridRegion gatekeeper, GridRegion destination, AgentCircuitData aCircuit, IPEndPoint clientIP, out string reason) private bool LaunchAgentIndirectly(GridRegion gatekeeper, GridRegion destination, AgentCircuitData aCircuit, IPEndPoint clientIP, out string reason)
{ {
m_log.Debug("[LLOGIN SERVICE] Launching agent at " + destination.RegionName); m_log.Debug("[LLOGIN SERVICE] Launching agent at " + destination.RegionName);
if (m_UserAgentService.LoginAgentToGrid(aCircuit, gatekeeper, destination, out reason)) if (m_UserAgentService.LoginAgentToGrid(aCircuit, gatekeeper, destination, clientIP, out reason))
{
IPAddress addr = NetworkUtil.GetExternalIPOf(clientIP.Address);
m_UserAgentService.SetClientToken(aCircuit.SessionID, addr.ToString() /* clientIP.Address.ToString() */);
return true; return true;
}
return false; return false;
} }