diff options
author | Melanie | 2010-10-04 04:49:54 +0100 |
---|---|---|
committer | Melanie | 2010-10-04 04:49:54 +0100 |
commit | da6816c805b8e68d5858ce9e241ea71941312c8c (patch) | |
tree | d78a4f04cf6bc0f7245ad5048a0434fa585dd761 /OpenSim/Server/Handlers/Hypergrid | |
parent | Merge branch 'master' into careminster-presence-refactor (diff) | |
parent | Merge branch 'master' of melanie@opensimulator.org:/var/git/opensim (diff) | |
download | opensim-SC-da6816c805b8e68d5858ce9e241ea71941312c8c.zip opensim-SC-da6816c805b8e68d5858ce9e241ea71941312c8c.tar.gz opensim-SC-da6816c805b8e68d5858ce9e241ea71941312c8c.tar.bz2 opensim-SC-da6816c805b8e68d5858ce9e241ea71941312c8c.tar.xz |
Merge branch 'master' into careminster-presence-refactor
Diffstat (limited to 'OpenSim/Server/Handlers/Hypergrid')
4 files changed, 31 insertions, 6 deletions
diff --git a/OpenSim/Server/Handlers/Hypergrid/AgentHandlers.cs b/OpenSim/Server/Handlers/Hypergrid/AgentHandlers.cs index c951653..31eefb1 100644 --- a/OpenSim/Server/Handlers/Hypergrid/AgentHandlers.cs +++ b/OpenSim/Server/Handlers/Hypergrid/AgentHandlers.cs | |||
@@ -54,9 +54,10 @@ namespace OpenSim.Server.Handlers.Hypergrid | |||
54 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 54 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
55 | private IGatekeeperService m_GatekeeperService; | 55 | private IGatekeeperService m_GatekeeperService; |
56 | 56 | ||
57 | public GatekeeperAgentHandler(IGatekeeperService gatekeeper) | 57 | public GatekeeperAgentHandler(IGatekeeperService gatekeeper, bool proxy) |
58 | { | 58 | { |
59 | m_GatekeeperService = gatekeeper; | 59 | m_GatekeeperService = gatekeeper; |
60 | m_Proxy = proxy; | ||
60 | } | 61 | } |
61 | 62 | ||
62 | protected override bool CreateAgent(GridRegion destination, AgentCircuitData aCircuit, uint teleportFlags, out string reason) | 63 | protected override bool CreateAgent(GridRegion destination, AgentCircuitData aCircuit, uint teleportFlags, out string reason) |
diff --git a/OpenSim/Server/Handlers/Hypergrid/GatekeeperServerConnector.cs b/OpenSim/Server/Handlers/Hypergrid/GatekeeperServerConnector.cs index dcb2725..49de8b1 100644 --- a/OpenSim/Server/Handlers/Hypergrid/GatekeeperServerConnector.cs +++ b/OpenSim/Server/Handlers/Hypergrid/GatekeeperServerConnector.cs | |||
@@ -51,6 +51,8 @@ namespace OpenSim.Server.Handlers.Hypergrid | |||
51 | get { return m_GatekeeperService; } | 51 | get { return m_GatekeeperService; } |
52 | } | 52 | } |
53 | 53 | ||
54 | bool m_Proxy = false; | ||
55 | |||
54 | public GatekeeperServiceInConnector(IConfigSource config, IHttpServer server, ISimulationService simService) : | 56 | public GatekeeperServiceInConnector(IConfigSource config, IHttpServer server, ISimulationService simService) : |
55 | base(config, server, String.Empty) | 57 | base(config, server, String.Empty) |
56 | { | 58 | { |
@@ -65,11 +67,13 @@ namespace OpenSim.Server.Handlers.Hypergrid | |||
65 | if (m_GatekeeperService == null) | 67 | if (m_GatekeeperService == null) |
66 | throw new Exception("Gatekeeper server connector cannot proceed because of missing service"); | 68 | throw new Exception("Gatekeeper server connector cannot proceed because of missing service"); |
67 | 69 | ||
70 | m_Proxy = gridConfig.GetBoolean("HasProxy", false); | ||
71 | |||
68 | HypergridHandlers hghandlers = new HypergridHandlers(m_GatekeeperService); | 72 | HypergridHandlers hghandlers = new HypergridHandlers(m_GatekeeperService); |
69 | server.AddXmlRPCHandler("link_region", hghandlers.LinkRegionRequest, false); | 73 | server.AddXmlRPCHandler("link_region", hghandlers.LinkRegionRequest, false); |
70 | server.AddXmlRPCHandler("get_region", hghandlers.GetRegion, false); | 74 | server.AddXmlRPCHandler("get_region", hghandlers.GetRegion, false); |
71 | 75 | ||
72 | server.AddHTTPHandler("/foreignagent/", new GatekeeperAgentHandler(m_GatekeeperService).Handler); | 76 | server.AddHTTPHandler("/foreignagent/", new GatekeeperAgentHandler(m_GatekeeperService, m_Proxy).Handler); |
73 | } | 77 | } |
74 | 78 | ||
75 | public GatekeeperServiceInConnector(IConfigSource config, IHttpServer server) | 79 | public GatekeeperServiceInConnector(IConfigSource config, IHttpServer server) |
diff --git a/OpenSim/Server/Handlers/Hypergrid/HomeAgentHandlers.cs b/OpenSim/Server/Handlers/Hypergrid/HomeAgentHandlers.cs index d10d6fc..f64a079 100644 --- a/OpenSim/Server/Handlers/Hypergrid/HomeAgentHandlers.cs +++ b/OpenSim/Server/Handlers/Hypergrid/HomeAgentHandlers.cs | |||
@@ -55,11 +55,13 @@ namespace OpenSim.Server.Handlers.Hypergrid | |||
55 | private IUserAgentService m_UserAgentService; | 55 | private IUserAgentService m_UserAgentService; |
56 | 56 | ||
57 | private string m_LoginServerIP; | 57 | private string m_LoginServerIP; |
58 | private bool m_Proxy = false; | ||
58 | 59 | ||
59 | public HomeAgentHandler(IUserAgentService userAgentService, string loginServerIP) | 60 | public HomeAgentHandler(IUserAgentService userAgentService, string loginServerIP, bool proxy) |
60 | { | 61 | { |
61 | m_UserAgentService = userAgentService; | 62 | m_UserAgentService = userAgentService; |
62 | m_LoginServerIP = loginServerIP; | 63 | m_LoginServerIP = loginServerIP; |
64 | m_Proxy = proxy; | ||
63 | } | 65 | } |
64 | 66 | ||
65 | public Hashtable Handler(Hashtable request) | 67 | public Hashtable Handler(Hashtable request) |
@@ -153,11 +155,11 @@ namespace OpenSim.Server.Handlers.Hypergrid | |||
153 | string ip_str = args["client_ip"].ToString(); | 155 | string ip_str = args["client_ip"].ToString(); |
154 | try | 156 | try |
155 | { | 157 | { |
156 | string callerIP = Util.GetCallerIP(request); | 158 | string callerIP = GetCallerIP(request); |
157 | // Verify if this caller has authority to send the client IP | 159 | // Verify if this caller has authority to send the client IP |
158 | if (callerIP == m_LoginServerIP) | 160 | if (callerIP == m_LoginServerIP) |
159 | client_ipaddress = new IPEndPoint(IPAddress.Parse(ip_str), 0); | 161 | client_ipaddress = new IPEndPoint(IPAddress.Parse(ip_str), 0); |
160 | else | 162 | else // leaving this for now, but this warning should be removed |
161 | m_log.WarnFormat("[HOME AGENT HANDLER]: Unauthorized machine {0} tried to set client ip to {1}", callerIP, ip_str); | 163 | m_log.WarnFormat("[HOME AGENT HANDLER]: Unauthorized machine {0} tried to set client ip to {1}", callerIP, ip_str); |
162 | } | 164 | } |
163 | catch | 165 | catch |
@@ -198,6 +200,23 @@ namespace OpenSim.Server.Handlers.Hypergrid | |||
198 | responsedata["str_response_string"] = OSDParser.SerializeJsonString(resp); | 200 | responsedata["str_response_string"] = OSDParser.SerializeJsonString(resp); |
199 | } | 201 | } |
200 | 202 | ||
203 | private string GetCallerIP(Hashtable request) | ||
204 | { | ||
205 | if (!m_Proxy) | ||
206 | return Util.GetCallerIP(request); | ||
207 | |||
208 | // We're behind a proxy | ||
209 | Hashtable headers = (Hashtable)request["headers"]; | ||
210 | if (headers.ContainsKey("X-Forwarded-For") && headers["X-Forwarded-For"] != null) | ||
211 | { | ||
212 | IPEndPoint ep = Util.GetClientIPFromXFF((string)headers["X-Forwarded-For"]); | ||
213 | if (ep != null) | ||
214 | return ep.Address.ToString(); | ||
215 | } | ||
216 | |||
217 | // Oops | ||
218 | return Util.GetCallerIP(request); | ||
219 | } | ||
201 | } | 220 | } |
202 | 221 | ||
203 | } | 222 | } |
diff --git a/OpenSim/Server/Handlers/Hypergrid/UserAgentServerConnector.cs b/OpenSim/Server/Handlers/Hypergrid/UserAgentServerConnector.cs index 70157d5..e5f6a5d 100644 --- a/OpenSim/Server/Handlers/Hypergrid/UserAgentServerConnector.cs +++ b/OpenSim/Server/Handlers/Hypergrid/UserAgentServerConnector.cs | |||
@@ -67,6 +67,7 @@ namespace OpenSim.Server.Handlers.Hypergrid | |||
67 | throw new Exception("UserAgent server connector cannot proceed because of missing service"); | 67 | throw new Exception("UserAgent server connector cannot proceed because of missing service"); |
68 | 68 | ||
69 | string loginServerIP = gridConfig.GetString("LoginServerIP", "127.0.0.1"); | 69 | string loginServerIP = gridConfig.GetString("LoginServerIP", "127.0.0.1"); |
70 | bool proxy = gridConfig.GetBoolean("HasProxy", false); | ||
70 | 71 | ||
71 | server.AddXmlRPCHandler("agent_is_coming_home", AgentIsComingHome, false); | 72 | server.AddXmlRPCHandler("agent_is_coming_home", AgentIsComingHome, false); |
72 | server.AddXmlRPCHandler("get_home_region", GetHomeRegion, false); | 73 | server.AddXmlRPCHandler("get_home_region", GetHomeRegion, false); |
@@ -74,7 +75,7 @@ namespace OpenSim.Server.Handlers.Hypergrid | |||
74 | server.AddXmlRPCHandler("verify_client", VerifyClient, false); | 75 | server.AddXmlRPCHandler("verify_client", VerifyClient, false); |
75 | server.AddXmlRPCHandler("logout_agent", LogoutAgent, false); | 76 | server.AddXmlRPCHandler("logout_agent", LogoutAgent, false); |
76 | 77 | ||
77 | server.AddHTTPHandler("/homeagent/", new HomeAgentHandler(m_HomeUsersService, loginServerIP).Handler); | 78 | server.AddHTTPHandler("/homeagent/", new HomeAgentHandler(m_HomeUsersService, loginServerIP, proxy).Handler); |
78 | } | 79 | } |
79 | 80 | ||
80 | public XmlRpcResponse GetHomeRegion(XmlRpcRequest request, IPEndPoint remoteClient) | 81 | public XmlRpcResponse GetHomeRegion(XmlRpcRequest request, IPEndPoint remoteClient) |