aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Server/Handlers
diff options
context:
space:
mode:
authorDiva Canto2010-10-03 21:21:02 -0700
committerDiva Canto2010-10-03 21:21:02 -0700
commit37231e0941cec02a8d24a1f08e946525cca33afb (patch)
tree47b45fc64c1577b17f43916ce32057c6df5dddff /OpenSim/Server/Handlers
parentMade the Gatekeeper proxy-able. (diff)
downloadopensim-SC-37231e0941cec02a8d24a1f08e946525cca33afb.zip
opensim-SC-37231e0941cec02a8d24a1f08e946525cca33afb.tar.gz
opensim-SC-37231e0941cec02a8d24a1f08e946525cca33afb.tar.bz2
opensim-SC-37231e0941cec02a8d24a1f08e946525cca33afb.tar.xz
Made the home agent handler check for xff if behind a proxy.
Diffstat (limited to '')
-rw-r--r--OpenSim/Server/Handlers/Hypergrid/HomeAgentHandlers.cs23
-rw-r--r--OpenSim/Server/Handlers/Hypergrid/UserAgentServerConnector.cs3
2 files changed, 23 insertions, 3 deletions
diff --git a/OpenSim/Server/Handlers/Hypergrid/HomeAgentHandlers.cs b/OpenSim/Server/Handlers/Hypergrid/HomeAgentHandlers.cs
index 21f4f3d..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,7 +155,7 @@ 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);
@@ -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)