From 1955b797598d61548521c444ea8d3721fd5435ba Mon Sep 17 00:00:00 2001
From: Diva Canto
Date: Thu, 19 Aug 2010 18:55:30 -0700
Subject: Partial rewrite of client IP verification. Not completely finished
yet, and untested. Committing to move to my other computer.
---
OpenSim/Framework/Constants.cs | 4 +-
.../Server/Handlers/Simulation/AgentHandlers.cs | 20 ++++++
.../Hypergrid/GatekeeperServiceConnector.cs | 44 ++++++++++++
.../Hypergrid/UserAgentServiceConnector.cs | 7 ++
.../Simulation/SimulationServiceConnector.cs | 83 +++++++++++++++-------
.../Services/HypergridService/UserAgentService.cs | 44 ++++++++----
OpenSim/Services/Interfaces/IGatekeeperService.cs | 6 +-
OpenSim/Services/LLLoginService/LLLoginService.cs | 6 +-
8 files changed, 167 insertions(+), 47 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Framework/Constants.cs b/OpenSim/Framework/Constants.cs
index 5757061..1b1aaf2 100644
--- a/OpenSim/Framework/Constants.cs
+++ b/OpenSim/Framework/Constants.cs
@@ -83,7 +83,9 @@ namespace OpenSim.Framework
/// Finished, Sim Changed
FinishedViaNewSim = 1 << 28,
/// Finished, Same Sim
- FinishedViaSameSim = 1 << 29
+ FinishedViaSameSim = 1 << 29,
+ /// Agent coming into the grid from another grid
+ ViaHGLogin = 1 << 30
}
}
diff --git a/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs b/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs
index d261678..392927a 100644
--- a/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs
+++ b/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs
@@ -178,6 +178,8 @@ namespace OpenSim.Server.Handlers.Simulation
resp["reason"] = OSD.FromString(reason);
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?
responsedata["int_response_code"] = HttpStatusCode.OK;
@@ -352,6 +354,24 @@ namespace OpenSim.Server.Handlers.Simulation
{
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;
+ }
}
}
diff --git a/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs b/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs
index c426bba..291dd73 100644
--- a/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs
@@ -38,6 +38,7 @@ using GridRegion = OpenSim.Services.Interfaces.GridRegion;
using OpenMetaverse;
using OpenMetaverse.Imaging;
+using OpenMetaverse.StructuredData;
using Nwc.XmlRpc;
using log4net;
@@ -268,5 +269,48 @@ namespace OpenSim.Services.Connectors.Hypergrid
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;
+ }
+ }
+ }
+
+
}
}
diff --git a/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs b/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs
index 69dff3c..c1e5949 100644
--- a/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs
@@ -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)
{
reason = String.Empty;
diff --git a/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs b/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs
index 6244565..2b96b96 100644
--- a/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs
@@ -77,8 +77,26 @@ namespace OpenSim.Services.Connectors.Simulation
public bool CreateAgent(GridRegion destination, AgentCircuitData aCircuit, uint flags, out string reason)
{
+ HttpWebRequest AgentCreateRequest = null;
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)
{
reason = "Destination is null";
@@ -101,7 +119,7 @@ namespace OpenSim.Services.Connectors.Simulation
//Console.WriteLine(" >>> DoCreateChildAgentCall <<< " + uri);
- HttpWebRequest AgentCreateRequest = (HttpWebRequest)WebRequest.Create(uri);
+ AgentCreateRequest = (HttpWebRequest)WebRequest.Create(uri);
AgentCreateRequest.Method = "POST";
AgentCreateRequest.ContentType = "application/json";
AgentCreateRequest.Timeout = 10000;
@@ -134,7 +152,7 @@ namespace OpenSim.Services.Connectors.Simulation
AgentCreateRequest.ContentLength = buffer.Length; //Count bytes to send
os = AgentCreateRequest.GetRequestStream();
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);
}
//catch (WebException ex)
@@ -150,11 +168,18 @@ namespace OpenSim.Services.Connectors.Simulation
os.Close();
}
+ return true;
+ }
+
+ protected string GetResponse(HttpWebRequest AgentCreateRequest, out string reason)
+ {
// Let's wait for the response
//m_log.Info("[REMOTE SIMULATION CONNECTOR]: Waiting for a reply after DoCreateChildAgentCall");
+ reason = string.Empty;
WebResponse webResponse = null;
StreamReader sr = null;
+ string response = string.Empty;
try
{
webResponse = AgentCreateRequest.GetResponse();
@@ -166,37 +191,15 @@ namespace OpenSim.Services.Connectors.Simulation
{
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);
-
- 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)
{
m_log.InfoFormat("[REMOTE SIMULATION CONNECTOR]: exception on reply of DoCreateChildAgentCall {0}", ex.Message);
reason = "Destination did not reply";
- return false;
+ return string.Empty;
}
finally
{
@@ -204,7 +207,33 @@ namespace OpenSim.Services.Connectors.Simulation
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)
diff --git a/OpenSim/Services/HypergridService/UserAgentService.cs b/OpenSim/Services/HypergridService/UserAgentService.cs
index 181d7f2..6b14e21 100644
--- a/OpenSim/Services/HypergridService/UserAgentService.cs
+++ b/OpenSim/Services/HypergridService/UserAgentService.cs
@@ -131,10 +131,11 @@ namespace OpenSim.Services.HypergridService
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}",
- agentCircuit.firstname, agentCircuit.lastname, gatekeeper.ExternalHostName +":"+ gatekeeper.HttpPort);
+ 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.ToString()),
+ gatekeeper.ExternalHostName +":"+ gatekeeper.HttpPort);
// Take the IP address + port of the gatekeeper (reg) plus the info of finalDestination
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 = false;
+ string myExternalIP = string.Empty;
string gridName = "http://" + gatekeeper.ExternalHostName + ":" + gatekeeper.HttpPort;
if (m_GridName == gridName)
success = m_GatekeeperService.LoginAgent(agentCircuit, finalDestination, out reason);
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)
{
@@ -167,15 +169,25 @@ namespace OpenSim.Services.HypergridService
return false;
}
+ // else set the IP addresses associated with this client
+ if (clientIP != null)
+ m_TravelingAgents[agentCircuit.SessionID].ClientIPAddress = clientIP.ToString();
+ m_TravelingAgents[agentCircuit.SessionID].MyIpAddress = myExternalIP;
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))
{
- m_log.DebugFormat("[USER AGENT SERVICE]: Setting token {0} for session {1}", token, sessionID);
- m_TravelingAgents[sessionID].ClientToken = token;
+ m_log.DebugFormat("[USER AGENT SERVICE]: Setting IP {0} for session {1}", ip, sessionID);
+ m_TravelingAgents[sessionID].ClientIPAddress = ip;
}
}
@@ -196,7 +208,7 @@ namespace OpenSim.Services.HypergridService
travel.GridExternalName = "http://" + region.ExternalHostName + ":" + region.HttpPort;
travel.ServiceToken = agentCircuit.ServiceSessionID;
if (old != null)
- travel.ClientToken = old.ClientToken;
+ travel.ClientIPAddress = old.ClientIPAddress;
return old;
}
@@ -233,15 +245,22 @@ namespace OpenSim.Services.HypergridService
return travel.GridExternalName == thisGridExternalName;
}
- public bool VerifyClient(UUID sessionID, string token)
+ public bool VerifyClient(UUID sessionID, string reportedIP)
{
if (m_BypassClientVerification)
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))
- 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;
}
@@ -266,7 +285,8 @@ namespace OpenSim.Services.HypergridService
public UUID UserID;
public string GridExternalName = 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
}
}
diff --git a/OpenSim/Services/Interfaces/IGatekeeperService.cs b/OpenSim/Services/Interfaces/IGatekeeperService.cs
index 2d397bc..aac8293 100644
--- a/OpenSim/Services/Interfaces/IGatekeeperService.cs
+++ b/OpenSim/Services/Interfaces/IGatekeeperService.cs
@@ -48,13 +48,15 @@ namespace OpenSim.Services.Interfaces
///
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);
- void SetClientToken(UUID sessionID, string token);
void LogoutAgent(UUID userID, UUID sessionID);
GridRegion GetHomeRegion(UUID userID, out Vector3 position, out Vector3 lookAt);
bool AgentIsComingHome(UUID sessionID, string thisGridExternalName);
bool VerifyAgent(UUID sessionID, string token);
- bool VerifyClient(UUID sessionID, string token);
+ bool VerifyClient(UUID sessionID, string reportedIP);
}
}
diff --git a/OpenSim/Services/LLLoginService/LLLoginService.cs b/OpenSim/Services/LLLoginService/LLLoginService.cs
index 4b7cb5d..b740297 100644
--- a/OpenSim/Services/LLLoginService/LLLoginService.cs
+++ b/OpenSim/Services/LLLoginService/LLLoginService.cs
@@ -755,12 +755,8 @@ 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, out reason))
- {
- IPAddress addr = NetworkUtil.GetExternalIPOf(clientIP.Address);
- m_UserAgentService.SetClientToken(aCircuit.SessionID, addr.ToString() /* clientIP.Address.ToString() */);
+ if (m_UserAgentService.LoginAgentToGrid(aCircuit, gatekeeper, destination, clientIP, out reason))
return true;
- }
return false;
}
--
cgit v1.1
From a39ea07158756a76757d4b616c60cbcedf06f268 Mon Sep 17 00:00:00 2001
From: Diva Canto
Date: Thu, 19 Aug 2010 19:54:40 -0700
Subject: Finished implementing ViaLogin vs ViaHGLogin. Removed lookup on
myipaddress.com. Also removed client IP verification upon UDP connection that
had been left there -- we can't do that in general.
---
OpenSim/Framework/NetworkUtil.cs | 82 ----------------------
OpenSim/Region/Framework/Scenes/Scene.cs | 52 +++++++-------
.../Services/HypergridService/GatekeeperService.cs | 28 +++++---
.../Services/HypergridService/UserAgentService.cs | 5 +-
4 files changed, 48 insertions(+), 119 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Framework/NetworkUtil.cs b/OpenSim/Framework/NetworkUtil.cs
index 831ff70..2e94b0d 100644
--- a/OpenSim/Framework/NetworkUtil.cs
+++ b/OpenSim/Framework/NetworkUtil.cs
@@ -181,18 +181,10 @@ namespace OpenSim.Framework
throw new ArgumentException("[NetworkUtil] Unable to resolve defaultHostname to an IPv4 address for an IPv4 client");
}
- static IPAddress externalIPAddress;
-
static NetworkUtil()
{
try
{
- externalIPAddress = GetExternalIP();
- }
- catch { /* ignore */ }
-
- try
- {
foreach (NetworkInterface ni in NetworkInterface.GetAllNetworkInterfaces())
{
foreach (UnicastIPAddressInformation address in ni.GetIPProperties().UnicastAddresses)
@@ -254,79 +246,5 @@ namespace OpenSim.Framework
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 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;
- }
}
}
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 18705a8..e742b55 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -2507,26 +2507,26 @@ namespace OpenSim.Region.Framework.Scenes
{
AgentCircuitData aCircuit = m_authenticateHandler.GetAgentCircuitData(client.CircuitCode);
- // Do the verification here
- System.Net.IPEndPoint ep = (System.Net.IPEndPoint)client.GetClientEP();
- if (aCircuit != null)
- {
- if (!VerifyClient(aCircuit, ep, out vialogin))
- {
- // uh-oh, this is fishy
- m_log.WarnFormat("[SCENE]: Agent {0} with session {1} connecting with unidentified end point {2}. Refusing service.",
- client.AgentId, client.SessionId, ep.ToString());
- try
- {
- client.Close();
- }
- catch (Exception e)
- {
- m_log.DebugFormat("[SCENE]: Exception while closing aborted client: {0}", e.StackTrace);
- }
- return;
- }
- }
+ //// 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();
+ //if (aCircuit != null)
+ //{
+ // if (!VerifyClient(aCircuit, ep, out vialogin))
+ // {
+ // // uh-oh, this is fishy
+ // m_log.WarnFormat("[SCENE]: Agent {0} with session {1} connecting with unidentified end point {2}. Refusing service.",
+ // client.AgentId, client.SessionId, ep.ToString());
+ // try
+ // {
+ // client.Close();
+ // }
+ // catch (Exception e)
+ // {
+ // m_log.DebugFormat("[SCENE]: Exception while closing aborted client: {0}", e.StackTrace);
+ // }
+ // return;
+ // }
+ //}
m_log.Debug("[SCENE]: Adding new agent " + client.Name + " to scene " + RegionInfo.RegionName);
@@ -2555,16 +2555,14 @@ namespace OpenSim.Region.Framework.Scenes
vialogin = false;
// 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;
IUserAgentVerificationModule userVerification = RequestModuleInterface();
if (userVerification != null && ep != null)
{
- System.Net.IPAddress addr = NetworkUtil.GetExternalIPOf(ep.Address);
-
- if (!userVerification.VerifyClient(aCircuit, /*ep.Address.ToString() */ addr.ToString()))
+ if (!userVerification.VerifyClient(aCircuit, ep.Address.ToString()))
{
// 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);
@@ -2575,6 +2573,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;
}
diff --git a/OpenSim/Services/HypergridService/GatekeeperService.cs b/OpenSim/Services/HypergridService/GatekeeperService.cs
index 6f041da..3f5c4f1 100644
--- a/OpenSim/Services/HypergridService/GatekeeperService.cs
+++ b/OpenSim/Services/HypergridService/GatekeeperService.cs
@@ -225,17 +225,23 @@ namespace OpenSim.Services.HypergridService
// 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))
- {
- 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");
+ PresenceInfo presence = m_PresenceService.GetAgent(aCircuit.SessionID);
+ if (presence != null) // it has been placed there by the login service
+ isFirstLogin = true;
+
+ else
+ if (!m_PresenceService.LoginAgent(aCircuit.AgentID.ToString(), aCircuit.SessionID, aCircuit.SecureSessionID))
+ {
+ 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
@@ -274,7 +280,9 @@ namespace OpenSim.Services.HypergridService
//
// 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)
diff --git a/OpenSim/Services/HypergridService/UserAgentService.cs b/OpenSim/Services/HypergridService/UserAgentService.cs
index 6b14e21..8c3be70 100644
--- a/OpenSim/Services/HypergridService/UserAgentService.cs
+++ b/OpenSim/Services/HypergridService/UserAgentService.cs
@@ -134,7 +134,7 @@ namespace OpenSim.Services.HypergridService
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} (@{2}) to grid {3}",
- agentCircuit.firstname, agentCircuit.lastname, ((clientIP == null) ? "(stored IP)" : clientIP.ToString()),
+ 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
@@ -169,9 +169,10 @@ namespace OpenSim.Services.HypergridService
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.ToString();
+ m_TravelingAgents[agentCircuit.SessionID].ClientIPAddress = clientIP.Address.ToString();
m_TravelingAgents[agentCircuit.SessionID].MyIpAddress = myExternalIP;
return true;
}
--
cgit v1.1
From ae554a48d0cea61d05dc931c04f336d83de4834b Mon Sep 17 00:00:00 2001
From: Melanie
Date: Fri, 20 Aug 2010 08:36:23 +0100
Subject: Add some maptile options, change maptile generation from OpenSimBase
to Scene to make it more configurable.
---
OpenSim/Region/Application/OpenSimBase.cs | 8 ----
OpenSim/Region/Framework/Scenes/Scene.cs | 63 ++++++++++++++++++++++++++-----
2 files changed, 54 insertions(+), 17 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs
index eb18e83..b80d17d 100644
--- a/OpenSim/Region/Application/OpenSimBase.cs
+++ b/OpenSim/Region/Application/OpenSimBase.cs
@@ -347,14 +347,6 @@ namespace OpenSim
// Prims have to be loaded after module configuration since some modules may be invoked during the load
scene.LoadPrimsFromStorage(regionInfo.originRegionID);
- // moved these here as the map texture has to be created after the modules are initialized
- // and has to happen before the region is registered with the grid.
- IWorldMapModule mapModule = scene.RequestModuleInterface();
- if (mapModule != null)
- mapModule.GenerateMaptile();
- else
- m_log.WarnFormat("[STARTUP]: No map module available to generate map tile");
-
// TODO : Try setting resource for region xstats here on scene
MainServer.Instance.AddStreamHandler(new Region.Framework.Scenes.RegionStatsHandler(regionInfo));
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 18705a8..2890ecd 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -396,6 +396,9 @@ namespace OpenSim.Region.Framework.Scenes
private double m_rootReprioritizationDistance = 10.0;
private double m_childReprioritizationDistance = 20.0;
+ private Timer m_mapGenerationTimer = new Timer();
+ bool m_generateMaptiles = false;
+
#endregion
#region Properties
@@ -646,6 +649,29 @@ namespace OpenSim.Region.Framework.Scenes
}
m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl);
+
+ m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true);
+ if (m_generateMaptiles)
+ {
+ int maptileRefresh = startupConfig.GetInt("MaptileRefresh", 0);
+ if (maptileRefresh != 0)
+ {
+ m_mapGenerationTimer.Interval = maptileRefresh * 1000;
+ m_mapGenerationTimer.Elapsed += RegenerateMaptile;
+ m_mapGenerationTimer.AutoReset = true;
+ m_mapGenerationTimer.Start();
+ }
+ }
+ else
+ {
+ string tile = startupConfig.GetString("MaptileStaticUUID", UUID.Zero.ToString());
+ UUID tileID;
+
+ if (UUID.TryParse(tile, out tileID))
+ {
+ RegionInfo.RegionSettings.TerrainImageID = tileID;
+ }
+ }
}
catch
{
@@ -1662,16 +1688,21 @@ namespace OpenSim.Region.Framework.Scenes
m_sceneGridService.SetScene(this);
- // These two 'commands' *must be* next to each other or sim rebooting fails.
- //m_sceneGridService.RegisterRegion(m_interregionCommsOut, RegionInfo);
-
- GridRegion region = new GridRegion(RegionInfo);
- string error = GridService.RegisterRegion(RegionInfo.ScopeID, region);
- if (error != String.Empty)
+ // If we generate maptiles internally at all, the maptile generator
+ // will register the region. If not, do it here
+ if (m_generateMaptiles)
{
- throw new Exception(error);
+ RegenerateMaptile(null, null);
+ }
+ else
+ {
+ GridRegion region = new GridRegion(RegionInfo);
+ string error = GridService.RegisterRegion(RegionInfo.ScopeID, region);
+ if (error != String.Empty)
+ {
+ throw new Exception(error);
+ }
}
-
}
#endregion
@@ -4878,5 +4909,19 @@ namespace OpenSim.Region.Framework.Scenes
return offsets.ToArray();
}
+
+ public void RegenerateMaptile(object sender, ElapsedEventArgs e)
+ {
+ IWorldMapModule mapModule = RequestModuleInterface();
+ if (mapModule != null)
+ {
+ mapModule.GenerateMaptile();
+
+ string error = GridService.RegisterRegion(RegionInfo.ScopeID, new GridRegion(RegionInfo));
+
+ if (error != String.Empty)
+ throw new Exception(error);
+ }
+ }
}
-}
\ No newline at end of file
+}
--
cgit v1.1
From 6f83b0ee4625ae6b94a7ca0525f7d8369da7e126 Mon Sep 17 00:00:00 2001
From: Diva Canto
Date: Fri, 20 Aug 2010 09:02:05 -0700
Subject: Cleaned up a few more things related to incoming agents.
---
OpenSim/Region/Framework/Scenes/Scene.cs | 87 +++++++++++++++-----------------
1 file changed, 42 insertions(+), 45 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 2f862ea..a147628 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -2502,18 +2502,25 @@ namespace OpenSim.Region.Framework.Scenes
///
public override void AddNewClient(IClientAPI client)
{
+ AgentCircuitData aCircuit = m_authenticateHandler.GetAgentCircuitData(client.CircuitCode);
bool vialogin = false;
- m_clientManager.Add(client);
+ if (aCircuit == null) // no good, didn't pass NewUserConnection successfully
+ return;
+
+ vialogin = (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0 ||
+ (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0;
CheckHeartbeat();
- SubscribeToClientEvents(client);
ScenePresence presence;
if (m_restorePresences.ContainsKey(client.AgentId))
{
m_log.DebugFormat("[SCENE]: Restoring agent {0} {1} in {2}", client.Name, client.AgentId, RegionInfo.RegionName);
+ m_clientManager.Add(client);
+ SubscribeToClientEvents(client);
+
presence = m_restorePresences[client.AgentId];
m_restorePresences.Remove(client.AgentId);
@@ -2536,49 +2543,35 @@ namespace OpenSim.Region.Framework.Scenes
}
else
{
- AgentCircuitData aCircuit = m_authenticateHandler.GetAgentCircuitData(client.CircuitCode);
-
- //// 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();
- //if (aCircuit != null)
- //{
- // if (!VerifyClient(aCircuit, ep, out vialogin))
- // {
- // // uh-oh, this is fishy
- // m_log.WarnFormat("[SCENE]: Agent {0} with session {1} connecting with unidentified end point {2}. Refusing service.",
- // client.AgentId, client.SessionId, ep.ToString());
- // try
- // {
- // client.Close();
- // }
- // catch (Exception e)
- // {
- // m_log.DebugFormat("[SCENE]: Exception while closing aborted client: {0}", e.StackTrace);
- // }
- // return;
- // }
- //}
+ if (GetScenePresence(client.AgentId) == null) // ensure there is no SP here
+ {
+ 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);
+ m_clientManager.Add(client);
+ SubscribeToClientEvents(client);
- ScenePresence sp = CreateAndAddScenePresence(client);
- if (aCircuit != null)
- sp.Appearance = aCircuit.Appearance;
+ ScenePresence sp = CreateAndAddScenePresence(client);
+ if (aCircuit != null)
+ sp.Appearance = aCircuit.Appearance;
- // HERE!!! Do the initial attachments right here
- // first agent upon login is a root agent by design.
- // All other AddNewClient calls find aCircuit.child to be true
- if (aCircuit == null || (aCircuit != null && aCircuit.child == false))
- {
- sp.IsChildAgent = false;
- Util.FireAndForget(delegate(object o) { sp.RezAttachments(); });
+ // HERE!!! Do the initial attachments right here
+ // first agent upon login is a root agent by design.
+ // All other AddNewClient calls find aCircuit.child to be true
+ if (aCircuit == null || (aCircuit != null && aCircuit.child == false))
+ {
+ sp.IsChildAgent = false;
+ Util.FireAndForget(delegate(object o) { sp.RezAttachments(); });
+ }
}
}
- m_LastLogin = Util.EnvironmentTickCount();
- EventManager.TriggerOnNewClient(client);
- if (vialogin)
- EventManager.TriggerOnClientLogin(client);
+ if (GetScenePresence(client.AgentId) != null)
+ {
+ m_LastLogin = Util.EnvironmentTickCount();
+ EventManager.TriggerOnNewClient(client);
+ if (vialogin)
+ EventManager.TriggerOnClientLogin(client);
+ }
}
private bool VerifyClient(AgentCircuitData aCircuit, System.Net.IPEndPoint ep, out bool vialogin)
@@ -2605,8 +2598,11 @@ 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.",
+ {
+ 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);
+ vialogin = true;
+ }
return true;
}
@@ -3245,7 +3241,8 @@ namespace OpenSim.Region.Framework.Scenes
/// also return a reason.
public bool NewUserConnection(AgentCircuitData agent, uint teleportFlags, out string reason)
{
- TeleportFlags tp = (TeleportFlags)teleportFlags;
+ bool vialogin = ((teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0 ||
+ (teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0);
reason = String.Empty;
//Teleport flags:
@@ -3282,7 +3279,7 @@ namespace OpenSim.Region.Framework.Scenes
ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y);
//On login test land permisions
- if (tp == TeleportFlags.ViaLogin)
+ if (vialogin)
{
if (land != null && !TestLandRestrictions(agent, land, out reason))
{
@@ -3341,7 +3338,7 @@ namespace OpenSim.Region.Framework.Scenes
agent.teleportFlags = teleportFlags;
m_authenticateHandler.AddNewCircuit(agent.circuitcode, agent);
- if (tp == TeleportFlags.ViaLogin)
+ if (vialogin)
{
if (TestBorderCross(agent.startpos, Cardinals.E))
{
@@ -3459,7 +3456,7 @@ namespace OpenSim.Region.Framework.Scenes
IPresenceService presence = RequestModuleInterface();
if (presence == null)
{
- reason = String.Format("Failed to verify user {0} {1} in region {2}. Presence service does not exist.", agent.firstname, agent.lastname, RegionInfo.RegionName);
+ reason = String.Format("Failed to verify user presence in the grid for {0} {1} in region {2}. Presence service does not exist.", agent.firstname, agent.lastname, RegionInfo.RegionName);
return false;
}
@@ -3467,7 +3464,7 @@ namespace OpenSim.Region.Framework.Scenes
if (pinfo == null)
{
- reason = String.Format("Failed to verify user {0} {1}, access denied to region {2}.", agent.firstname, agent.lastname, RegionInfo.RegionName);
+ reason = String.Format("Failed to verify user presence in the grid for {0} {1}, access denied to region {2}.", agent.firstname, agent.lastname, RegionInfo.RegionName);
return false;
}
--
cgit v1.1
From bb5dd9fbbc39d2023c29ecc9deecd06523c7e467 Mon Sep 17 00:00:00 2001
From: Marck
Date: Tue, 17 Aug 2010 20:54:51 +0200
Subject: Some code cleanup for console command alert.
Made parsing of parameters more robust.
Allow general alerts without specifying keyword 'general'.
Extended help texts.
---
.../CoreModules/Avatar/Dialog/DialogModule.cs | 52 ++++++++++++++++++----
1 file changed, 43 insertions(+), 9 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs b/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs
index 2105f3c..2b3d2a9 100644
--- a/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs
@@ -51,10 +51,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Dialog
m_scene.RegisterModuleInterface(this);
m_scene.AddCommand(
- this, "alert", "alert ", "Send an alert to a user", HandleAlertConsoleCommand);
+ this, "alert", "alert ",
+ "Send an alert to a user",
+ HandleAlertConsoleCommand);
m_scene.AddCommand(
- this, "alert general", "alert general ", "Send an alert to everyone", HandleAlertConsoleCommand);
+ this, "alert general", "alert [general] ",
+ "Send an alert to everyone",
+ "If keyword 'general' is omitted, then must be surrounded by quotation marks.",
+ HandleAlertConsoleCommand);
}
public void PostInitialise() {}
@@ -173,20 +178,49 @@ namespace OpenSim.Region.CoreModules.Avatar.Dialog
if (m_scene.ConsoleScene() != null && m_scene.ConsoleScene() != m_scene)
return;
- if (cmdparams[1] == "general")
+ bool isGeneral = false;
+ string firstName = string.Empty;
+ string lastName = string.Empty;
+ string message = string.Empty;
+
+ if (cmdparams.Length > 1)
+ {
+ firstName = cmdparams[1];
+ isGeneral = firstName.ToLower().Equals("general");
+ }
+ if (cmdparams.Length == 2 && !isGeneral)
+ {
+ // alert "message"
+ message = cmdparams[1];
+ isGeneral = true;
+ }
+ else if (cmdparams.Length > 2 && isGeneral)
+ {
+ // alert general
+ message = CombineParams(cmdparams, 2);
+ }
+ else if (cmdparams.Length > 3)
{
- string message = CombineParams(cmdparams, 2);
+ // alert
+ lastName = cmdparams[2];
+ message = CombineParams(cmdparams, 3);
+ }
+ else
+ {
+ OpenSim.Framework.Console.MainConsole.Instance.Output(
+ "Usage: alert \"message\" | alert general | alert ");
+ return;
+ }
+ if (isGeneral)
+ {
m_log.InfoFormat(
- "[DIALOG]: Sending general alert in region {0} with message {1}", m_scene.RegionInfo.RegionName, message);
+ "[DIALOG]: Sending general alert in region {0} with message {1}",
+ m_scene.RegionInfo.RegionName, message);
SendGeneralAlert(message);
}
else
{
- string firstName = cmdparams[1];
- string lastName = cmdparams[2];
- string message = CombineParams(cmdparams, 3);
-
m_log.InfoFormat(
"[DIALOG]: Sending alert in region {0} to {1} {2} with message {3}",
m_scene.RegionInfo.RegionName, firstName, lastName, message);
--
cgit v1.1
From 86a61696d714f92264528a51486c9dce7840a9bb Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Fri, 20 Aug 2010 17:58:02 +0100
Subject: minor: remove mono compiler warning
---
.../CoreModules/InterGrid/OpenGridProtocolModule.cs | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Region/CoreModules/InterGrid/OpenGridProtocolModule.cs b/OpenSim/Region/CoreModules/InterGrid/OpenGridProtocolModule.cs
index 87a0a8d..fd0e879 100644
--- a/OpenSim/Region/CoreModules/InterGrid/OpenGridProtocolModule.cs
+++ b/OpenSim/Region/CoreModules/InterGrid/OpenGridProtocolModule.cs
@@ -100,7 +100,7 @@ namespace OpenSim.Region.CoreModules.InterGrid
bool enabled = false;
IConfig cfg = null;
IConfig httpcfg = null;
- IConfig startupcfg = null;
+// IConfig startupcfg = null;
try
{
cfg = config.Configs["OpenGridProtocol"];
@@ -117,14 +117,14 @@ namespace OpenSim.Region.CoreModules.InterGrid
{
}
- try
- {
- startupcfg = config.Configs["Startup"];
- }
- catch (NullReferenceException)
- {
-
- }
+// try
+// {
+// startupcfg = config.Configs["Startup"];
+// }
+// catch (NullReferenceException)
+// {
+//
+// }
// if (startupcfg != null)
// {
--
cgit v1.1
From f347d25675dbe84345d4b1bfbad041303c75e293 Mon Sep 17 00:00:00 2001
From: Diva Canto
Date: Fri, 20 Aug 2010 11:09:02 -0700
Subject: Unit test breakage fix.
---
OpenSim/Framework/Capabilities/Caps.cs | 4 +-
OpenSim/Framework/Capabilities/CapsHandlers.cs | 2 +-
.../Agent/Capabilities/CapabilitiesModule.cs | 6 +--
.../Scenes/Tests/SceneObjectBasicTests.cs | 8 ++--
.../Framework/Scenes/Tests/ScenePresenceTests.cs | 9 +++-
OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs | 56 ++++++++++++++++++----
6 files changed, 65 insertions(+), 20 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Framework/Capabilities/Caps.cs b/OpenSim/Framework/Capabilities/Caps.cs
index da953bb..0db7bb9 100644
--- a/OpenSim/Framework/Capabilities/Caps.cs
+++ b/OpenSim/Framework/Capabilities/Caps.cs
@@ -142,7 +142,7 @@ namespace OpenSim.Framework.Capabilities
m_httpListenPort = httpPort;
- if (httpServer.UseSSL)
+ if (httpServer != null && httpServer.UseSSL)
{
m_httpListenPort = httpServer.SSLPort;
httpListen = httpServer.SSLCommonName;
@@ -151,7 +151,7 @@ namespace OpenSim.Framework.Capabilities
m_agentID = agent;
m_dumpAssetsToFile = dumpAssetsToFile;
- m_capsHandlers = new CapsHandlers(httpServer, httpListen, httpPort, httpServer.UseSSL);
+ m_capsHandlers = new CapsHandlers(httpServer, httpListen, httpPort, (httpServer == null) ? false : httpServer.UseSSL);
m_regionName = regionName;
}
diff --git a/OpenSim/Framework/Capabilities/CapsHandlers.cs b/OpenSim/Framework/Capabilities/CapsHandlers.cs
index f000aed..864e6dd 100644
--- a/OpenSim/Framework/Capabilities/CapsHandlers.cs
+++ b/OpenSim/Framework/Capabilities/CapsHandlers.cs
@@ -74,7 +74,7 @@ namespace OpenSim.Framework.Capabilities
m_httpListenerHostName = httpListenerHostname;
m_httpListenerPort = httpListenerPort;
m_useSSL = https;
- if (m_useSSL)
+ if (httpListener != null && m_useSSL)
{
m_httpListenerHostName = httpListener.SSLCommonName;
m_httpListenerPort = httpListener.SSLPort;
diff --git a/OpenSim/Region/CoreModules/Agent/Capabilities/CapabilitiesModule.cs b/OpenSim/Region/CoreModules/Agent/Capabilities/CapabilitiesModule.cs
index a6f5d97..c023a6f 100644
--- a/OpenSim/Region/CoreModules/Agent/Capabilities/CapabilitiesModule.cs
+++ b/OpenSim/Region/CoreModules/Agent/Capabilities/CapabilitiesModule.cs
@@ -109,9 +109,9 @@ namespace OpenSim.Region.CoreModules.Agent.Capabilities
Caps caps
= new Caps(m_scene,
m_scene.AssetService, MainServer.Instance, m_scene.RegionInfo.ExternalHostName,
- MainServer.Instance.Port,
+ (MainServer.Instance == null) ? 0: MainServer.Instance.Port,
capsObjectPath, agentId, m_scene.DumpAssetsToFile, m_scene.RegionInfo.RegionName);
-
+
caps.RegisterHandlers();
m_scene.EventManager.TriggerOnRegisterCaps(agentId, caps);
@@ -121,7 +121,7 @@ namespace OpenSim.Region.CoreModules.Agent.Capabilities
caps.TaskScriptUpdatedCall = m_scene.CapsUpdateTaskInventoryScriptAsset;
caps.CAPSFetchInventoryDescendents = m_scene.HandleFetchInventoryDescendentsCAPS;
caps.GetClient = m_scene.SceneContents.GetControllingClient;
-
+
m_capsHandlers[agentId] = caps;
}
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs
index d4f9f18..54b3260 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs
@@ -130,11 +130,11 @@ namespace OpenSim.Region.Framework.Scenes.Tests
{
TestHelper.InMethod();
//log4net.Config.XmlConfigurator.Configure();
-
+
UUID agentId = UUID.Parse("00000000-0000-0000-0000-000000000001");
-
+
TestScene scene = SceneSetupHelpers.SetupScene();
-
+
// Turn off the timer on the async sog deleter - we'll crank it by hand for this test.
AsyncSceneObjectGroupDeleter sogd = scene.SceneObjectGroupDeleter;
sogd.Enabled = false;
@@ -147,7 +147,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
SceneObjectPart retrievedPart = scene.GetSceneObjectPart(part.LocalId);
Assert.That(retrievedPart, Is.Not.Null);
-
+
sogd.InventoryDeQueueAndDelete();
SceneObjectPart retrievedPart2 = scene.GetSceneObjectPart(part.LocalId);
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs
index 501207e..e39a362 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs
@@ -104,8 +104,8 @@ namespace OpenSim.Region.Framework.Scenes.Tests
agent.AgentID = agent1;
agent.firstname = firstName;
agent.lastname = "testlastname";
- agent.SessionID = UUID.Zero;
- agent.SecureSessionID = UUID.Zero;
+ agent.SessionID = UUID.Random();
+ agent.SecureSessionID = UUID.Random();
agent.circuitcode = 123;
agent.BaseFolder = UUID.Zero;
agent.InventoryFolder = UUID.Zero;
@@ -114,6 +114,11 @@ namespace OpenSim.Region.Framework.Scenes.Tests
agent.ChildrenCapSeeds = new Dictionary();
agent.child = true;
+ if (scene.PresenceService == null)
+ Console.WriteLine("Presence Service is null");
+
+ scene.PresenceService.LoginAgent(agent.AgentID.ToString(), agent.SessionID, agent.SecureSessionID);
+
string reason;
scene.NewUserConnection(agent, (uint)TeleportFlags.ViaLogin, out reason);
testclient = new TestClient(agent, scene);
diff --git a/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs b/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs
index 4a356e2..eaa0d33 100644
--- a/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs
+++ b/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs
@@ -46,6 +46,7 @@ using OpenSim.Region.CoreModules.ServiceConnectorsOut.Authentication;
using OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory;
using OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid;
using OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts;
+using OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence;
using OpenSim.Services.Interfaces;
using OpenSim.Tests.Common.Mock;
@@ -63,6 +64,7 @@ namespace OpenSim.Tests.Common.Setup
private static ISharedRegionModule m_inventoryService = null;
private static ISharedRegionModule m_gridService = null;
private static ISharedRegionModule m_userAccountService = null;
+ private static ISharedRegionModule m_presenceService = null;
///
/// Set up a test scene
@@ -180,7 +182,7 @@ namespace OpenSim.Tests.Common.Setup
else
StartAssetService(testScene, false);
- // For now, always started a 'real' authenication service
+ // For now, always started a 'real' authentication service
StartAuthenticationService(testScene, true);
if (realServices.Contains("inventory"))
@@ -188,10 +190,9 @@ namespace OpenSim.Tests.Common.Setup
else
StartInventoryService(testScene, false);
- if (realServices.Contains("grid"))
- StartGridService(testScene, true);
-
+ StartGridService(testScene, true);
StartUserAccountService(testScene);
+ StartPresenceService(testScene);
}
// If not, make sure the shared module gets references to this new scene
else
@@ -202,11 +203,15 @@ namespace OpenSim.Tests.Common.Setup
m_inventoryService.RegionLoaded(testScene);
m_userAccountService.AddRegion(testScene);
m_userAccountService.RegionLoaded(testScene);
+ m_presenceService.AddRegion(testScene);
+ m_presenceService.RegionLoaded(testScene);
+
}
m_inventoryService.PostInitialise();
m_assetService.PostInitialise();
m_userAccountService.PostInitialise();
+ m_presenceService.PostInitialise();
testScene.RegionInfo.EstateSettings.EstateOwner = UUID.Random();
testScene.SetModuleInterfaces();
@@ -225,7 +230,11 @@ namespace OpenSim.Tests.Common.Setup
m_inventoryService = null;
m_gridService = null;
m_userAccountService = null;
-
+ m_presenceService = null;
+
+ testScene.RegionInfo.EstateSettings = new EstateSettings();
+ testScene.LoginsDisabled = false;
+
return testScene;
}
@@ -337,6 +346,32 @@ namespace OpenSim.Tests.Common.Setup
}
///
+ /// Start a presence service
+ ///
+ ///
+ private static void StartPresenceService(Scene testScene)
+ {
+ IConfigSource config = new IniConfigSource();
+ config.AddConfig("Modules");
+ config.AddConfig("PresenceService");
+ config.Configs["Modules"].Set("PresenceServices", "LocalPresenceServicesConnector");
+ config.Configs["PresenceService"].Set("StorageProvider", "OpenSim.Data.Null.dll");
+ config.Configs["PresenceService"].Set(
+ "LocalServiceModule", "OpenSim.Services.PresenceService.dll:PresenceService");
+
+ if (m_presenceService == null)
+ {
+ ISharedRegionModule presenceService = new LocalPresenceServicesConnector();
+ presenceService.Initialise(config);
+ m_presenceService = presenceService;
+ }
+
+ m_presenceService.AddRegion(testScene);
+ m_presenceService.RegionLoaded(testScene);
+ testScene.AddRegionModule(m_presenceService.Name, m_presenceService);
+ }
+
+ ///
/// Setup modules for a scene using their default settings.
///
///
@@ -446,9 +481,14 @@ namespace OpenSim.Tests.Common.Setup
{
string reason;
- // We emulate the proper login sequence here by doing things in three stages
+ // We emulate the proper login sequence here by doing things in four stages
+
+ // Stage 0: log the presence
+ scene.PresenceService.LoginAgent(agentData.AgentID.ToString(), agentData.SessionID, agentData.SecureSessionID);
+
// Stage 1: simulate login by telling the scene to expect a new user connection
- scene.NewUserConnection(agentData, (uint)TeleportFlags.ViaLogin, out reason);
+ if (!scene.NewUserConnection(agentData, (uint)TeleportFlags.ViaLogin, out reason))
+ Console.WriteLine("NewUserConnection failed: " + reason);
// Stage 2: add the new client as a child agent to the scene
TestClient client = new TestClient(agentData, scene);
@@ -459,7 +499,7 @@ namespace OpenSim.Tests.Common.Setup
//scene.AgentCrossing(agentData.AgentID, new Vector3(90, 90, 90), false); OBSOLETE
ScenePresence scp = scene.GetScenePresence(agentData.AgentID);
- scp.MakeRootAgent(new Vector3(90,90,90), true);
+ scp.MakeRootAgent(new Vector3(90, 90, 90), true);
return client;
}
--
cgit v1.1
From 7aad5af49850b3938282426dd1ecf160d7053032 Mon Sep 17 00:00:00 2001
From: Marck
Date: Sat, 14 Aug 2010 12:46:17 +0200
Subject: Some code cleanup for console command "create region".
Make region name an optional command parameter.
Avoid question for region name if it has already been specified.
Extend help text.
---
OpenSim/Framework/RegionInfo.cs | 2 +-
OpenSim/Region/Application/OpenSim.cs | 65 +++++++++++++++++++----------------
2 files changed, 36 insertions(+), 31 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Framework/RegionInfo.cs b/OpenSim/Framework/RegionInfo.cs
index afc4060..ea1a594 100644
--- a/OpenSim/Framework/RegionInfo.cs
+++ b/OpenSim/Framework/RegionInfo.cs
@@ -393,7 +393,7 @@ namespace OpenSim.Framework
if (!File.Exists(filename)) // New region config request
{
IniConfigSource newFile = new IniConfigSource();
- ReadNiniConfig(newFile, String.Empty);
+ ReadNiniConfig(newFile, configName);
newFile.Save(filename);
diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs
index d9ec287..6834606 100644
--- a/OpenSim/Region/Application/OpenSim.cs
+++ b/OpenSim/Region/Application/OpenSim.cs
@@ -308,8 +308,13 @@ namespace OpenSim
"Persist objects to the database now", RunCommand);
m_console.Commands.AddCommand("region", false, "create region",
- "create region",
- "Create a new region", HandleCreateRegion);
+ "create region [\"region name\"] ",
+ "Create a new region.",
+ "The settings for \"region name\" are read from ."
+ + " If \"region name\" does not exist in , it will be added." + Environment.NewLine
+ + "Without \"region name\", the first region found in will be created." + Environment.NewLine
+ + "If does not exist, it will be created.",
+ HandleCreateRegion);
m_console.Commands.AddCommand("region", false, "restart",
"restart",
@@ -513,47 +518,47 @@ namespace OpenSim
/// Creates a new region based on the parameters specified. This will ask the user questions on the console
///
///
- /// 0,1,region name, region XML file
+ /// 0,1,region name, region ini or XML file
private void HandleCreateRegion(string module, string[] cmd)
{
- if (cmd.Length < 4)
+ string regionName = string.Empty;
+ string regionFile = string.Empty;
+ if (cmd.Length == 3)
{
- MainConsole.Instance.Output("Usage: create region ");
+ regionFile = cmd[2];
+ }
+ else if (cmd.Length > 3)
+ {
+ regionName = cmd[2];
+ regionFile = cmd[3];
+ }
+ string extension = Path.GetExtension(regionFile).ToLower();
+ bool isXml = extension.Equals(".xml");
+ bool isIni = extension.Equals(".ini");
+ if (!isXml && !isIni)
+ {
+ MainConsole.Instance.Output("Usage: create region [\"region name\"] ");
return;
}
- if (cmd[3].EndsWith(".xml"))
+ if (!Path.IsPathRooted(regionFile))
{
string regionsDir = ConfigSource.Source.Configs["Startup"].GetString("regionload_regionsdir", "Regions").Trim();
- string regionFile = String.Format("{0}/{1}", regionsDir, cmd[3]);
- // Allow absolute and relative specifiers
- if (cmd[3].StartsWith("/") || cmd[3].StartsWith("\\") || cmd[3].StartsWith(".."))
- regionFile = cmd[3];
-
- IScene scene;
- RegionInfo regInfo = new RegionInfo(cmd[2], regionFile, false, ConfigSource.Source);
- PopulateRegionEstateInfo(regInfo);
- CreateRegion(regInfo, true, out scene);
- regInfo.EstateSettings.Save();
+ regionFile = Path.Combine(regionsDir, regionFile);
}
- else if (cmd[3].EndsWith(".ini"))
+
+ RegionInfo regInfo;
+ if (isXml)
{
- string regionsDir = ConfigSource.Source.Configs["Startup"].GetString("regionload_regionsdir", "Regions").Trim();
- string regionFile = String.Format("{0}/{1}", regionsDir, cmd[3]);
- // Allow absolute and relative specifiers
- if (cmd[3].StartsWith("/") || cmd[3].StartsWith("\\") || cmd[3].StartsWith(".."))
- regionFile = cmd[3];
-
- IScene scene;
- RegionInfo regInfo = new RegionInfo(cmd[2], regionFile, false, ConfigSource.Source, cmd[2]);
- PopulateRegionEstateInfo(regInfo);
- CreateRegion(regInfo, true, out scene);
- regInfo.EstateSettings.Save();
+ regInfo = new RegionInfo(regionName, regionFile, false, ConfigSource.Source);
}
else
{
- MainConsole.Instance.Output("Usage: create region ");
- return;
+ regInfo = new RegionInfo(regionName, regionFile, false, ConfigSource.Source, regionName);
}
+ IScene scene;
+ PopulateRegionEstateInfo(regInfo);
+ CreateRegion(regInfo, true, out scene);
+ regInfo.EstateSettings.Save();
}
///
--
cgit v1.1
From ea1df09fa4cc0c3322b147651f5d8ac3fefce55e Mon Sep 17 00:00:00 2001
From: Melanie Thielker
Date: Sat, 21 Aug 2010 00:46:16 +0200
Subject: Forward-port a small improvement to the land out connector
---
.../ServiceConnectorsOut/Land/RemoteLandServiceConnector.cs | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Land/RemoteLandServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Land/RemoteLandServiceConnector.cs
index 2386060..252d9e7 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Land/RemoteLandServiceConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Land/RemoteLandServiceConnector.cs
@@ -102,7 +102,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Land
public void RegionLoaded(Scene scene)
{
- m_GridService = scene.GridService;
+ if (m_Enabled)
+ m_GridService = scene.GridService;
}
--
cgit v1.1