merge master

httptests
UbitUmarov 2017-05-23 07:35:02 +01:00
commit c0bfaac0ac
23 changed files with 147 additions and 111 deletions

View File

@ -206,7 +206,7 @@ namespace OpenSim.Data.PGSQL
cmd.CommandText = String.Format(@"select bit_or(""inventoryCurrentPermissions"") as ""inventoryCurrentPermissions"" cmd.CommandText = String.Format(@"select bit_or(""inventoryCurrentPermissions"") as ""inventoryCurrentPermissions""
from inventoryitems from inventoryitems
where ""avatarID""::uuid = :PrincipalID where ""avatarID""::uuid = :PrincipalID
and ""assetID"" = :AssetID and ""assetID""::uuid = :AssetID
group by ""assetID"" "); group by ""assetID"" ");
cmd.Parameters.Add(m_database.CreateParameter("PrincipalID", principalID)); cmd.Parameters.Add(m_database.CreateParameter("PrincipalID", principalID));

View File

@ -34,6 +34,6 @@ namespace OpenSim.Framework.Client
{ {
public interface IClientIPEndpoint public interface IClientIPEndpoint
{ {
IPAddress EndPoint { get; } IPEndPoint RemoteEndPoint { get; }
} }
} }

View File

@ -82,6 +82,11 @@ namespace OpenSim.Framework.Monitoring
HandleControlCommand); HandleControlCommand);
} }
public static void Stop()
{
JobEngine.Stop();
}
/// <summary> /// <summary>
/// Start a new long-lived thread. /// Start a new long-lived thread.
/// </summary> /// </summary>
@ -131,7 +136,6 @@ namespace OpenSim.Framework.Monitoring
thread.Start(); thread.Start();
return thread; return thread;
} }

View File

@ -136,12 +136,19 @@ namespace OpenSim.Framework.Servers
protected override void ShutdownSpecific() protected override void ShutdownSpecific()
{ {
m_log.Info("[SHUTDOWN]: Shutdown processing on main thread complete. Exiting...");
RemovePIDFile();
base.ShutdownSpecific(); base.ShutdownSpecific();
MainServer.Stop();
Thread.Sleep(5000);
WorkManager.Stop();
RemovePIDFile();
m_log.Info("[SHUTDOWN]: Shutdown processing on main thread complete. Exiting...");
if (!SuppressExit) if (!SuppressExit)
Environment.Exit(0); Environment.Exit(0);
} }

View File

@ -194,17 +194,20 @@ namespace OpenSim.Framework.Servers.HttpServer
{ {
m_running = false; m_running = false;
Thread.Sleep(1000); // let the world move Thread.Sleep(100); // let the world move
foreach (Thread t in m_workerThreads) foreach (Thread t in m_workerThreads)
Watchdog.AbortThread(t.ManagedThreadId); Watchdog.AbortThread(t.ManagedThreadId);
m_threadPool.Shutdown();
// any entry in m_bycontext should have a active request on the other queues // any entry in m_bycontext should have a active request on the other queues
// so just delete contents to easy GC // so just delete contents to easy GC
foreach (Queue<PollServiceHttpRequest> qu in m_bycontext.Values) foreach (Queue<PollServiceHttpRequest> qu in m_bycontext.Values)
qu.Clear(); qu.Clear();
m_bycontext.Clear(); m_bycontext.Clear();
/*
try try
{ {
foreach (PollServiceHttpRequest req in m_retryRequests) foreach (PollServiceHttpRequest req in m_retryRequests)
@ -217,8 +220,9 @@ namespace OpenSim.Framework.Servers.HttpServer
} }
PollServiceHttpRequest wreq; PollServiceHttpRequest wreq;
*/
m_retryRequests.Clear(); m_retryRequests.Clear();
/*
while (m_requests.Count() > 0) while (m_requests.Count() > 0)
{ {
try try
@ -231,7 +235,7 @@ namespace OpenSim.Framework.Servers.HttpServer
{ {
} }
} }
*/
m_requests.Clear(); m_requests.Clear();
} }
@ -242,7 +246,6 @@ namespace OpenSim.Framework.Servers.HttpServer
while (m_running) while (m_running)
{ {
PollServiceHttpRequest req = m_requests.Dequeue(5000); PollServiceHttpRequest req = m_requests.Dequeue(5000);
Watchdog.UpdateThread(); Watchdog.UpdateThread();
if(req == null) if(req == null)
continue; continue;
@ -277,16 +280,16 @@ namespace OpenSim.Framework.Servers.HttpServer
try try
{ {
req.DoHTTPGruntWork(m_server, responsedata); req.DoHTTPGruntWork(m_server, responsedata);
}
catch (ObjectDisposedException) { }
finally
{
if(req.HttpContext.CanSend() && req.PollServiceArgs.Type == PollServiceEventArgs.EventType.Poll if(req.HttpContext.CanSend() && req.PollServiceArgs.Type == PollServiceEventArgs.EventType.Poll
&& (Environment.TickCount - req.RequestTime) > req.PollServiceArgs.TimeOutms) && (Environment.TickCount - req.RequestTime) > req.PollServiceArgs.TimeOutms)
ReQueueEvent(req); ReQueueEvent(req);
else else
byContextDequeue(req); byContextDequeue(req);
} }
catch (ObjectDisposedException) // Browser aborted before we could read body, server closed the stream
{
// Ignore it, no need to reply
}
return null; return null;
}, null); }, null);
} }
@ -300,11 +303,11 @@ namespace OpenSim.Framework.Servers.HttpServer
{ {
req.DoHTTPGruntWork(m_server, req.DoHTTPGruntWork(m_server,
req.PollServiceArgs.NoEvents(req.RequestID, req.PollServiceArgs.Id)); req.PollServiceArgs.NoEvents(req.RequestID, req.PollServiceArgs.Id));
byContextDequeue(req);
} }
catch (ObjectDisposedException) catch (ObjectDisposedException) {}
finally
{ {
// Ignore it, no need to reply byContextDequeue(req);
} }
return null; return null;
}, null); }, null);

View File

@ -369,5 +369,17 @@ namespace OpenSim.Framework.Servers
return m_Servers[port]; return m_Servers[port];
} }
} }
public static void Stop()
{
lock (m_Servers)
{
foreach (BaseHttpServer httpServer in m_Servers.Values)
{
httpServer.Stop();
}
}
}
} }
} }

View File

@ -77,7 +77,11 @@ namespace OpenSim
if(Util.IsWindows()) if(Util.IsWindows())
ServicePointManager.DefaultConnectionLimit = 32; ServicePointManager.DefaultConnectionLimit = 32;
else else
{
ServicePointManager.DefaultConnectionLimit = 12; ServicePointManager.DefaultConnectionLimit = 12;
try { ServicePointManager.DnsRefreshTimeout = 120000; } // just is case crazy some mono decides to have it infinity
catch { }
}
ServicePointManager.Expect100Continue = false; ServicePointManager.Expect100Continue = false;
ServicePointManager.UseNagleAlgorithm = false; ServicePointManager.UseNagleAlgorithm = false;

View File

@ -504,7 +504,8 @@ namespace OpenSim
private void WatchdogTimeoutHandler(Watchdog.ThreadWatchdogInfo twi) private void WatchdogTimeoutHandler(Watchdog.ThreadWatchdogInfo twi)
{ {
int now = Environment.TickCount & Int32.MaxValue; int now = Environment.TickCount & Int32.MaxValue;
if(twi.Thread.ThreadState == System.Threading.ThreadState.Stopped)
return;
m_log.ErrorFormat( m_log.ErrorFormat(
"[WATCHDOG]: Timeout detected for thread \"{0}\". ThreadState={1}. Last tick was {2}ms ago. {3}", "[WATCHDOG]: Timeout detected for thread \"{0}\". ThreadState={1}. Last tick was {2}ms ago. {3}",
twi.Thread.Name, twi.Thread.Name,

View File

@ -62,7 +62,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
/// Handles new client connections /// Handles new client connections
/// Constructor takes a single Packet and authenticates everything /// Constructor takes a single Packet and authenticates everything
/// </summary> /// </summary>
public class LLClientView : IClientAPI, IClientCore, IClientIM, IClientChat, IClientInventory, IStatsCollector public class LLClientView : IClientAPI, IClientCore, IClientIM, IClientChat, IClientInventory, IStatsCollector, IClientIPEndpoint
{ {
/// <value> /// <value>
/// Debug packet level. See OpenSim.RegisterConsoleCommands() for more details. /// Debug packet level. See OpenSim.RegisterConsoleCommands() for more details.

View File

@ -53,9 +53,9 @@ namespace OpenSim.Region.CoreModules.Agent.IPBan
if (bans.Count > 0) if (bans.Count > 0)
{ {
IClientIPEndpoint ipEndpoint; IClientIPEndpoint ipEndpoint;
if (client.TryGet(out ipEndpoint)) if (client.TryGet(out ipEndpoint) && ipEndpoint.RemoteEndPoint != null)
{ {
IPAddress end = ipEndpoint.EndPoint; IPAddress end = ipEndpoint.RemoteEndPoint.Address;
try try
{ {

View File

@ -813,8 +813,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
agentCircuit.Id0 = currentAgentCircuit.Id0; agentCircuit.Id0 = currentAgentCircuit.Id0;
} }
IClientIPEndpoint ipepClient;
uint newRegionX, newRegionY, oldRegionX, oldRegionY; uint newRegionX, newRegionY, oldRegionX, oldRegionY;
Util.RegionHandleToRegionLoc(destinationHandle, out newRegionX, out newRegionY); Util.RegionHandleToRegionLoc(destinationHandle, out newRegionX, out newRegionY);
Util.RegionHandleToRegionLoc(sourceRegion.RegionHandle, out oldRegionX, out oldRegionY); Util.RegionHandleToRegionLoc(sourceRegion.RegionHandle, out oldRegionX, out oldRegionY);
@ -833,13 +831,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
finalDestination.RegionName, newRegionX, newRegionY,newSizeX, newSizeY, sp.Name, Scene.Name); finalDestination.RegionName, newRegionX, newRegionY,newSizeX, newSizeY, sp.Name, Scene.Name);
//sp.ControllingClient.SendTeleportProgress(teleportFlags, "Creating agent..."); //sp.ControllingClient.SendTeleportProgress(teleportFlags, "Creating agent...");
#region IP Translation for NAT
// Uses ipepClient above
if (sp.ClientView.TryGet(out ipepClient))
{
endPoint.Address = NetworkUtil.GetIPFor(ipepClient.EndPoint, endPoint.Address);
}
#endregion
agentCircuit.CapsPath = CapsUtil.GetRandomCapsObjectPath(); agentCircuit.CapsPath = CapsUtil.GetRandomCapsObjectPath();
} }
else else
@ -952,7 +943,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
agent.Position = agentCircuit.startpos; agent.Position = agentCircuit.startpos;
SetCallbackURL(agent, sp.Scene.RegionInfo); SetCallbackURL(agent, sp.Scene.RegionInfo);
// We will check for an abort before UpdateAgent since UpdateAgent will require an active viewer to // We will check for an abort before UpdateAgent since UpdateAgent will require an active viewer to
// establish th econnection to the destination which makes it return true. // establish th econnection to the destination which makes it return true.
if (m_entityTransferStateMachine.GetAgentTransferState(sp.UUID) == AgentTransferState.Aborting) if (m_entityTransferStateMachine.GetAgentTransferState(sp.UUID) == AgentTransferState.Aborting)
@ -1745,11 +1735,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
if (m_eqModule != null) if (m_eqModule != null)
{ {
#region IP Translation for NAT
IClientIPEndpoint ipepClient;
if (agent.ClientView.TryGet(out ipepClient))
endPoint.Address = NetworkUtil.GetIPFor(ipepClient.EndPoint, endPoint.Address);
m_log.DebugFormat("{0} {1} is sending {2} EnableSimulator for neighbour region {3}(loc=<{4},{5}>,siz=<{6},{7}>) " + m_log.DebugFormat("{0} {1} is sending {2} EnableSimulator for neighbour region {3}(loc=<{4},{5}>,siz=<{6},{7}>) " +
"and EstablishAgentCommunication with seed cap {8}", LogHeader, "and EstablishAgentCommunication with seed cap {8}", LogHeader,
source.RegionName, agent.Name, source.RegionName, agent.Name,
@ -2281,6 +2266,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
} }
#endregion // NotFoundLocationCache class #endregion // NotFoundLocationCache class
#region getregions
private NotFoundLocationCache m_notFoundLocationCache = new NotFoundLocationCache(); private NotFoundLocationCache m_notFoundLocationCache = new NotFoundLocationCache();
protected GridRegion GetRegionContainingWorldLocation(IGridService pGridService, UUID pScopeID, double px, double py) protected GridRegion GetRegionContainingWorldLocation(IGridService pGridService, UUID pScopeID, double px, double py)
@ -2398,17 +2384,9 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
if (m_eqModule != null) if (m_eqModule != null)
{ {
#region IP Translation for NAT
if(sp == null || sp.IsDeleted || sp.ClientView == null) // something bad already happened if(sp == null || sp.IsDeleted || sp.ClientView == null) // something bad already happened
return; return;
IClientIPEndpoint ipepClient;
if (sp.ClientView.TryGet(out ipepClient))
{
endPoint.Address = NetworkUtil.GetIPFor(ipepClient.EndPoint, endPoint.Address);
}
#endregion
m_log.DebugFormat("{0} {1} is sending {2} EnableSimulator for neighbour region {3}(loc=<{4},{5}>,siz=<{6},{7}>) " + m_log.DebugFormat("{0} {1} is sending {2} EnableSimulator for neighbour region {3}(loc=<{4},{5}>,siz=<{6},{7}>) " +
"and EstablishAgentCommunication with seed cap {8}", LogHeader, "and EstablishAgentCommunication with seed cap {8}", LogHeader,
scene.RegionInfo.RegionName, sp.Name, scene.RegionInfo.RegionName, sp.Name,

View File

@ -106,6 +106,8 @@ namespace OpenSim.Region.CoreModules.Hypergrid
if (!m_Enabled) if (!m_Enabled)
return; return;
base.RemoveRegion(scene);
scene.EventManager.OnClientClosed -= EventManager_OnClientClosed; scene.EventManager.OnClientClosed -= EventManager_OnClientClosed;
} }

View File

@ -415,6 +415,7 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest
public void Close() public void Close()
{ {
ThreadPool.Shutdown();
} }
public string Name public string Name
@ -538,6 +539,7 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest
{ {
Request = (HttpWebRequest)WebRequest.Create(Url); Request = (HttpWebRequest)WebRequest.Create(Url);
Request.AllowAutoRedirect = false; Request.AllowAutoRedirect = false;
Request.KeepAlive = false;
//This works around some buggy HTTP Servers like Lighttpd //This works around some buggy HTTP Servers like Lighttpd
Request.ServicePoint.Expect100Continue = false; Request.ServicePoint.Expect100Continue = false;

View File

@ -215,6 +215,8 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
m_scene.EventManager.OnNewClient -= OnNewClient; m_scene.EventManager.OnNewClient -= OnNewClient;
m_scene.EventManager.OnRegisterCaps -= OnRegisterCaps; m_scene.EventManager.OnRegisterCaps -= OnRegisterCaps;
m_scene.UnregisterModuleInterface<IWorldMapModule>(this);
string regionimage = "regionImage" + m_scene.RegionInfo.RegionID.ToString(); string regionimage = "regionImage" + m_scene.RegionInfo.RegionID.ToString();
regionimage = regionimage.Replace("-", ""); regionimage = regionimage.Replace("-", "");
MainServer.Instance.RemoveLLSDHandler("/MAP/MapItems/" + m_scene.RegionInfo.RegionHandle.ToString(), MainServer.Instance.RemoveLLSDHandler("/MAP/MapItems/" + m_scene.RegionInfo.RegionHandle.ToString(),
@ -1148,7 +1150,12 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
List<MapBlockRequestData> thisRunData = new List<MapBlockRequestData>(); List<MapBlockRequestData> thisRunData = new List<MapBlockRequestData>();
while (true) while (true)
{ {
m_mapBlockRequestEvent.WaitOne(); while(!m_mapBlockRequestEvent.WaitOne(4900))
{
if(m_scene == null)
return;
}
lock (m_mapBlockRequestEvent) lock (m_mapBlockRequestEvent)
{ {
int total = 0; int total = 0;

View File

@ -4687,7 +4687,10 @@ namespace OpenSim.Region.Framework.Scenes
cAgent.agentCOF = COF; cAgent.agentCOF = COF;
cAgent.ActiveGroupID = ControllingClient.ActiveGroupId; cAgent.ActiveGroupID = ControllingClient.ActiveGroupId;
cAgent.ActiveGroupName = ControllingClient.ActiveGroupName; cAgent.ActiveGroupName = ControllingClient.ActiveGroupName;
cAgent.ActiveGroupTitle = Grouptitle; if(Grouptitle == null)
cAgent.ActiveGroupTitle = String.Empty;
else
cAgent.ActiveGroupTitle = Grouptitle;
} }
} }

View File

@ -550,7 +550,16 @@ namespace OpenSim.Region.Framework.Scenes
/// </summary> /// </summary>
private void RecordMaterialAssetUuids(AssetBase materialAsset) private void RecordMaterialAssetUuids(AssetBase materialAsset)
{ {
OSDMap mat = (OSDMap)OSDParser.DeserializeLLSDXml(materialAsset.Data); OSDMap mat;
try
{
mat = (OSDMap)OSDParser.DeserializeLLSDXml(materialAsset.Data);
}
catch (Exception e)
{
m_log.WarnFormat("[Materials]: cannot decode material asset {0}: {1}", materialAsset.ID, e.Message);
return;
}
UUID normMap = mat["NormMap"].AsUUID(); UUID normMap = mat["NormMap"].AsUUID();
if (normMap != UUID.Zero) if (normMap != UUID.Zero)

View File

@ -51,7 +51,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
private static Thread cmdHandlerThread; private static Thread cmdHandlerThread;
private static int cmdHandlerThreadCycleSleepms; private static int cmdHandlerThreadCycleSleepms;
private static int numInstances;
/// <summary> /// <summary>
/// Lock for reading/writing static components of AsyncCommandManager. /// Lock for reading/writing static components of AsyncCommandManager.
/// </summary> /// </summary>
@ -172,18 +172,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (!m_XmlRequest.ContainsKey(m_ScriptEngine)) if (!m_XmlRequest.ContainsKey(m_ScriptEngine))
m_XmlRequest[m_ScriptEngine] = new XmlRequest(this); m_XmlRequest[m_ScriptEngine] = new XmlRequest(this);
StartThread(); numInstances++;
} if (cmdHandlerThread == null)
} {
cmdHandlerThread = WorkManager.StartThread(
private static void StartThread()
{
if (cmdHandlerThread == null)
{
// Start the thread that will be doing the work
cmdHandlerThread
= WorkManager.StartThread(
CmdHandlerThreadLoop, "AsyncLSLCmdHandlerThread", ThreadPriority.Normal, true, true); CmdHandlerThreadLoop, "AsyncLSLCmdHandlerThread", ThreadPriority.Normal, true, true);
}
} }
} }
@ -197,20 +191,27 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
~AsyncCommandManager() ~AsyncCommandManager()
{ {
// Shut down thread // Shut down thread
// try try
// { {
// if (cmdHandlerThread != null) lock (staticLock)
// { {
// if (cmdHandlerThread.IsAlive == true) numInstances--;
// { if(numInstances > 0)
// cmdHandlerThread.Abort(); return;
// //cmdHandlerThread.Join(); if (cmdHandlerThread != null)
// } {
// } if (cmdHandlerThread.IsAlive == true)
// } {
// catch cmdHandlerThread.Abort();
// { //cmdHandlerThread.Join();
// } cmdHandlerThread = null;
}
}
}
}
catch
{
}
} }
/// <summary> /// <summary>
@ -240,24 +241,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
lock (staticLock) lock (staticLock)
{ {
// Check HttpRequests // Check HttpRequests
m_HttpRequest[m_ScriptEngines[0]].CheckHttpRequests(); try { m_HttpRequest[m_ScriptEngines[0]].CheckHttpRequests(); } catch {}
// Check XMLRPCRequests // Check XMLRPCRequests
m_XmlRequest[m_ScriptEngines[0]].CheckXMLRPCRequests(); try { m_XmlRequest[m_ScriptEngines[0]].CheckXMLRPCRequests(); } catch {}
foreach (IScriptEngine s in m_ScriptEngines) foreach (IScriptEngine s in m_ScriptEngines)
{ {
// Check Listeners // Check Listeners
m_Listener[s].CheckListeners(); try { m_Listener[s].CheckListeners(); } catch {}
// Check timers // Check timers
m_Timer[s].CheckTimerEvents(); try { m_Timer[s].CheckTimerEvents(); } catch {}
// Check Sensors // Check Sensors
m_SensorRepeat[s].CheckSenseRepeaterEvents(); try { m_SensorRepeat[s].CheckSenseRepeaterEvents(); } catch {}
// Check dataserver // Check dataserver
m_Dataserver[s].ExpireRequests(); try { m_Dataserver[s].ExpireRequests(); } catch {}
} }
} }
} }
@ -387,8 +389,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
} }
} }
public static Object[] GetSerializationData(IScriptEngine engine, UUID itemID) public static Object[] GetSerializationData(IScriptEngine engine, UUID itemID)
{ {
List<Object> data = new List<Object>(); List<Object> data = new List<Object>();

View File

@ -827,6 +827,9 @@ namespace OpenSim.Region.ScriptEngine.XEngine
if (m_ScriptEngines.Contains(this)) if (m_ScriptEngines.Contains(this))
m_ScriptEngines.Remove(this); m_ScriptEngines.Remove(this);
} }
lock(m_Scripts)
m_ThreadPool.Shutdown();
} }
public object DoBackup(object o) public object DoBackup(object o)

View File

@ -64,7 +64,7 @@ namespace OpenSim.Server.Handlers.Login
public XmlRpcResponse HandleXMLRPCLogin(XmlRpcRequest request, IPEndPoint remoteClient) public XmlRpcResponse HandleXMLRPCLogin(XmlRpcRequest request, IPEndPoint remoteClient)
{ {
Hashtable requestData = (Hashtable)request.Params[0]; Hashtable requestData = (Hashtable)request.Params[0];
if (m_Proxy && request.Params[3] != null) if (request.Params[3] != null)
{ {
IPEndPoint ep = Util.GetClientIPFromXFF((string)request.Params[3]); IPEndPoint ep = Util.GetClientIPFromXFF((string)request.Params[3]);
if (ep != null) if (ep != null)

View File

@ -225,8 +225,8 @@ namespace OpenSim.Server.Handlers.MapImage
private System.Net.IPAddress GetCallerIP(IOSHttpRequest request) private System.Net.IPAddress GetCallerIP(IOSHttpRequest request)
{ {
if (!m_Proxy) // if (!m_Proxy)
return request.RemoteIPEndPoint.Address; // return request.RemoteIPEndPoint.Address;
// We're behind a proxy // We're behind a proxy
string xff = "X-Forwarded-For"; string xff = "X-Forwarded-For";
@ -236,7 +236,7 @@ namespace OpenSim.Server.Handlers.MapImage
if (xffValue == null || (xffValue != null && xffValue == string.Empty)) if (xffValue == null || (xffValue != null && xffValue == string.Empty))
{ {
m_log.WarnFormat("[MAP IMAGE HANDLER]: No XFF header"); // m_log.WarnFormat("[MAP IMAGE HANDLER]: No XFF header");
return request.RemoteIPEndPoint.Address; return request.RemoteIPEndPoint.Address;
} }

View File

@ -229,8 +229,8 @@ namespace OpenSim.Server.Handlers.MapImage
private System.Net.IPAddress GetCallerIP(IOSHttpRequest request) private System.Net.IPAddress GetCallerIP(IOSHttpRequest request)
{ {
if (!m_Proxy) // if (!m_Proxy)
return request.RemoteIPEndPoint.Address; // return request.RemoteIPEndPoint.Address;
// We're behind a proxy // We're behind a proxy
string xff = "X-Forwarded-For"; string xff = "X-Forwarded-For";
@ -240,7 +240,7 @@ namespace OpenSim.Server.Handlers.MapImage
if (xffValue == null || (xffValue != null && xffValue == string.Empty)) if (xffValue == null || (xffValue != null && xffValue == string.Empty))
{ {
m_log.WarnFormat("[MAP IMAGE HANDLER]: No XFF header"); // m_log.WarnFormat("[MAP IMAGE HANDLER]: No XFF header");
return request.RemoteIPEndPoint.Address; return request.RemoteIPEndPoint.Address;
} }

View File

@ -517,32 +517,30 @@ namespace OpenSim.Server.Handlers.Simulation
protected string GetCallerIP(Hashtable request) protected string GetCallerIP(Hashtable request)
{ {
if (!m_Proxy) if (request.ContainsKey("headers"))
return Util.GetCallerIP(request);
// We're behind a proxy
Hashtable headers = (Hashtable)request["headers"];
//// DEBUG
//foreach (object o in headers.Keys)
// m_log.DebugFormat("XXX {0} = {1}", o.ToString(), (headers[o] == null? "null" : headers[o].ToString()));
string xff = "X-Forwarded-For";
if (headers.ContainsKey(xff.ToLower()))
xff = xff.ToLower();
if (!headers.ContainsKey(xff) || headers[xff] == null)
{ {
m_log.WarnFormat("[AGENT HANDLER]: No XFF header"); Hashtable headers = (Hashtable)request["headers"];
return Util.GetCallerIP(request);
//// DEBUG
//foreach (object o in headers.Keys)
// m_log.DebugFormat("XXX {0} = {1}", o.ToString(), (headers[o] == null? "null" : headers[o].ToString()));
string xff = "X-Forwarded-For";
if (!headers.ContainsKey(xff))
xff = xff.ToLower();
if (!headers.ContainsKey(xff) || headers[xff] == null)
{
// m_log.WarnFormat("[AGENT HANDLER]: No XFF header");
return Util.GetCallerIP(request);
}
// m_log.DebugFormat("[AGENT HANDLER]: XFF is {0}", headers[xff]);
IPEndPoint ep = Util.GetClientIPFromXFF((string)headers[xff]);
if (ep != null)
return ep.Address.ToString();
} }
m_log.DebugFormat("[AGENT HANDLER]: XFF is {0}", headers[xff]);
IPEndPoint ep = Util.GetClientIPFromXFF((string)headers[xff]);
if (ep != null)
return ep.Address.ToString();
// Oops // Oops
return Util.GetCallerIP(request); return Util.GetCallerIP(request);
} }

View File

@ -81,6 +81,9 @@ namespace OpenSim.Server
ServicePointManager.UseNagleAlgorithm = false; ServicePointManager.UseNagleAlgorithm = false;
ServicePointManager.ServerCertificateValidationCallback = ValidateServerCertificate; ServicePointManager.ServerCertificateValidationCallback = ValidateServerCertificate;
try { ServicePointManager.DnsRefreshTimeout = 120000; } // just is case some mono decides to have it infinity
catch { }
m_Server = new HttpServerBase("R.O.B.U.S.T.", args); m_Server = new HttpServerBase("R.O.B.U.S.T.", args);
string registryLocation; string registryLocation;