aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Server/Handlers/Hypergrid/HomeAgentHandlers.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Server/Handlers/Hypergrid/HomeAgentHandlers.cs')
-rw-r--r--OpenSim/Server/Handlers/Hypergrid/HomeAgentHandlers.cs23
1 files changed, 21 insertions, 2 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}