Made the Gatekeeper proxy-able.
parent
2d5173c205
commit
934ae03d44
|
@ -54,9 +54,10 @@ namespace OpenSim.Server.Handlers.Hypergrid
|
||||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
private IGatekeeperService m_GatekeeperService;
|
private IGatekeeperService m_GatekeeperService;
|
||||||
|
|
||||||
public GatekeeperAgentHandler(IGatekeeperService gatekeeper)
|
public GatekeeperAgentHandler(IGatekeeperService gatekeeper, bool proxy)
|
||||||
{
|
{
|
||||||
m_GatekeeperService = gatekeeper;
|
m_GatekeeperService = gatekeeper;
|
||||||
|
m_Proxy = proxy;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool CreateAgent(GridRegion destination, AgentCircuitData aCircuit, uint teleportFlags, out string reason)
|
protected override bool CreateAgent(GridRegion destination, AgentCircuitData aCircuit, uint teleportFlags, out string reason)
|
||||||
|
|
|
@ -51,6 +51,8 @@ namespace OpenSim.Server.Handlers.Hypergrid
|
||||||
get { return m_GatekeeperService; }
|
get { return m_GatekeeperService; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool m_Proxy = false;
|
||||||
|
|
||||||
public GatekeeperServiceInConnector(IConfigSource config, IHttpServer server, ISimulationService simService) :
|
public GatekeeperServiceInConnector(IConfigSource config, IHttpServer server, ISimulationService simService) :
|
||||||
base(config, server, String.Empty)
|
base(config, server, String.Empty)
|
||||||
{
|
{
|
||||||
|
@ -65,11 +67,13 @@ namespace OpenSim.Server.Handlers.Hypergrid
|
||||||
if (m_GatekeeperService == null)
|
if (m_GatekeeperService == null)
|
||||||
throw new Exception("Gatekeeper server connector cannot proceed because of missing service");
|
throw new Exception("Gatekeeper server connector cannot proceed because of missing service");
|
||||||
|
|
||||||
|
m_Proxy = gridConfig.GetBoolean("HasProxy", false);
|
||||||
|
|
||||||
HypergridHandlers hghandlers = new HypergridHandlers(m_GatekeeperService);
|
HypergridHandlers hghandlers = new HypergridHandlers(m_GatekeeperService);
|
||||||
server.AddXmlRPCHandler("link_region", hghandlers.LinkRegionRequest, false);
|
server.AddXmlRPCHandler("link_region", hghandlers.LinkRegionRequest, false);
|
||||||
server.AddXmlRPCHandler("get_region", hghandlers.GetRegion, false);
|
server.AddXmlRPCHandler("get_region", hghandlers.GetRegion, false);
|
||||||
|
|
||||||
server.AddHTTPHandler("/foreignagent/", new GatekeeperAgentHandler(m_GatekeeperService).Handler);
|
server.AddHTTPHandler("/foreignagent/", new GatekeeperAgentHandler(m_GatekeeperService, m_Proxy).Handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
public GatekeeperServiceInConnector(IConfigSource config, IHttpServer server)
|
public GatekeeperServiceInConnector(IConfigSource config, IHttpServer server)
|
||||||
|
|
|
@ -52,6 +52,8 @@ namespace OpenSim.Server.Handlers.Simulation
|
||||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
private ISimulationService m_SimulationService;
|
private ISimulationService m_SimulationService;
|
||||||
|
|
||||||
|
protected bool m_Proxy = false;
|
||||||
|
|
||||||
public AgentHandler() { }
|
public AgentHandler() { }
|
||||||
|
|
||||||
public AgentHandler(ISimulationService sim)
|
public AgentHandler(ISimulationService sim)
|
||||||
|
@ -179,13 +181,31 @@ 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)
|
// Let's also send out the IP address of the caller back to the caller (HG 1.5)
|
||||||
resp["your_ip"] = OSD.FromString(Util.GetCallerIP(request));
|
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;
|
||||||
responsedata["str_response_string"] = OSDParser.SerializeJsonString(resp);
|
responsedata["str_response_string"] = OSDParser.SerializeJsonString(resp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private string GetCallerIP(Hashtable request)
|
||||||
|
{
|
||||||
|
if (!m_Proxy)
|
||||||
|
return Util.GetCallerIP(request);
|
||||||
|
|
||||||
|
// We're behind a proxy
|
||||||
|
Hashtable headers = (Hashtable)request["headers"];
|
||||||
|
if (headers.ContainsKey("X-Forwarded-For") && headers["X-Forwarded-For"] != null)
|
||||||
|
{
|
||||||
|
IPEndPoint ep = Util.GetClientIPFromXFF((string)headers["X-Forwarded-For"]);
|
||||||
|
if (ep != null)
|
||||||
|
return ep.Address.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Oops
|
||||||
|
return Util.GetCallerIP(request);
|
||||||
|
}
|
||||||
|
|
||||||
// subclasses can override this
|
// subclasses can override this
|
||||||
protected virtual bool CreateAgent(GridRegion destination, AgentCircuitData aCircuit, uint teleportFlags, out string reason)
|
protected virtual bool CreateAgent(GridRegion destination, AgentCircuitData aCircuit, uint teleportFlags, out string reason)
|
||||||
{
|
{
|
||||||
|
|
|
@ -212,6 +212,10 @@ ServiceConnectors = "8003/OpenSim.Server.Handlers.dll:AssetServiceConnector,8003
|
||||||
; Does this grid allow incoming links to any region in it?
|
; Does this grid allow incoming links to any region in it?
|
||||||
; If false, HG TPs happen only to the Default regions specified in [GridService] section
|
; If false, HG TPs happen only to the Default regions specified in [GridService] section
|
||||||
AllowTeleportsToAnyRegion = true
|
AllowTeleportsToAnyRegion = true
|
||||||
|
|
||||||
|
; If you run this gatekeeper server behind a proxy, set this to true
|
||||||
|
; HasProxy = true
|
||||||
|
|
||||||
|
|
||||||
[UserAgentService]
|
[UserAgentService]
|
||||||
LocalServiceModule = "OpenSim.Services.HypergridService.dll:UserAgentService"
|
LocalServiceModule = "OpenSim.Services.HypergridService.dll:UserAgentService"
|
||||||
|
|
|
@ -141,6 +141,9 @@ ServiceConnectors = "8003/OpenSim.Server.Handlers.dll:AssetServiceConnector,8003
|
||||||
; For snowglobe's web map
|
; For snowglobe's web map
|
||||||
; MapTileURL = "";
|
; MapTileURL = "";
|
||||||
|
|
||||||
|
; If you run this login server behind a proxy, set this to true
|
||||||
|
; HasProxy = true
|
||||||
|
|
||||||
|
|
||||||
[GridInfoService]
|
[GridInfoService]
|
||||||
; These settings are used to return information on a get_grid_info call.
|
; These settings are used to return information on a get_grid_info call.
|
||||||
|
|
Loading…
Reference in New Issue