aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Server/Handlers/Hypergrid/HomeAgentHandlers.cs
diff options
context:
space:
mode:
authorJonathan Freedman2010-10-05 14:17:18 -0400
committerJonathan Freedman2010-10-05 14:17:18 -0400
commit8f1acb890ac49ea004bf43065ce8d3472bb27708 (patch)
tree07e4e5fc77f764232c958bdbf8f93f2651da1663 /OpenSim/Server/Handlers/Hypergrid/HomeAgentHandlers.cs
parentMerge branch 'master' of git://opensimulator.org/git/opensim (diff)
parentFormatting cleanup. (diff)
downloadopensim-SC_OLD-8f1acb890ac49ea004bf43065ce8d3472bb27708.zip
opensim-SC_OLD-8f1acb890ac49ea004bf43065ce8d3472bb27708.tar.gz
opensim-SC_OLD-8f1acb890ac49ea004bf43065ce8d3472bb27708.tar.bz2
opensim-SC_OLD-8f1acb890ac49ea004bf43065ce8d3472bb27708.tar.xz
Merge branch 'master' of git://opensimulator.org/git/opensim
Diffstat (limited to 'OpenSim/Server/Handlers/Hypergrid/HomeAgentHandlers.cs')
-rw-r--r--OpenSim/Server/Handlers/Hypergrid/HomeAgentHandlers.cs25
1 files changed, 22 insertions, 3 deletions
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}