aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Server/Handlers
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Server/Handlers')
-rw-r--r--OpenSim/Server/Handlers/Hypergrid/HomeAgentHandlers.cs26
-rw-r--r--OpenSim/Server/Handlers/Hypergrid/UserAgentServerConnector.cs4
-rw-r--r--OpenSim/Server/Handlers/Login/LLLoginHandlers.cs12
-rw-r--r--OpenSim/Server/Handlers/Login/LLLoginServiceInConnector.cs5
-rw-r--r--OpenSim/Server/Handlers/Simulation/AgentHandlers.cs19
5 files changed, 43 insertions, 23 deletions
diff --git a/OpenSim/Server/Handlers/Hypergrid/HomeAgentHandlers.cs b/OpenSim/Server/Handlers/Hypergrid/HomeAgentHandlers.cs
index e50481a..d10d6fc 100644
--- a/OpenSim/Server/Handlers/Hypergrid/HomeAgentHandlers.cs
+++ b/OpenSim/Server/Handlers/Hypergrid/HomeAgentHandlers.cs
@@ -54,9 +54,12 @@ 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 IUserAgentService m_UserAgentService; 55 private IUserAgentService m_UserAgentService;
56 56
57 public HomeAgentHandler(IUserAgentService userAgentService) 57 private string m_LoginServerIP;
58
59 public HomeAgentHandler(IUserAgentService userAgentService, string loginServerIP)
58 { 60 {
59 m_UserAgentService = userAgentService; 61 m_UserAgentService = userAgentService;
62 m_LoginServerIP = loginServerIP;
60 } 63 }
61 64
62 public Hashtable Handler(Hashtable request) 65 public Hashtable Handler(Hashtable request)
@@ -120,6 +123,7 @@ namespace OpenSim.Server.Handlers.Hypergrid
120 string regionname = string.Empty; 123 string regionname = string.Empty;
121 string gatekeeper_host = string.Empty; 124 string gatekeeper_host = string.Empty;
122 int gatekeeper_port = 0; 125 int gatekeeper_port = 0;
126 IPEndPoint client_ipaddress = null;
123 127
124 if (args.ContainsKey("gatekeeper_host") && args["gatekeeper_host"] != null) 128 if (args.ContainsKey("gatekeeper_host") && args["gatekeeper_host"] != null)
125 gatekeeper_host = args["gatekeeper_host"].AsString(); 129 gatekeeper_host = args["gatekeeper_host"].AsString();
@@ -144,6 +148,24 @@ namespace OpenSim.Server.Handlers.Hypergrid
144 if (args.ContainsKey("destination_name") && args["destination_name"] != null) 148 if (args.ContainsKey("destination_name") && args["destination_name"] != null)
145 regionname = args["destination_name"].ToString(); 149 regionname = args["destination_name"].ToString();
146 150
151 if (args.ContainsKey("client_ip") && args["client_ip"] != null)
152 {
153 string ip_str = args["client_ip"].ToString();
154 try
155 {
156 string callerIP = Util.GetCallerIP(request);
157 // Verify if this caller has authority to send the client IP
158 if (callerIP == m_LoginServerIP)
159 client_ipaddress = new IPEndPoint(IPAddress.Parse(ip_str), 0);
160 else
161 m_log.WarnFormat("[HOME AGENT HANDLER]: Unauthorized machine {0} tried to set client ip to {1}", callerIP, ip_str);
162 }
163 catch
164 {
165 m_log.DebugFormat("[HOME AGENT HANDLER]: Exception parsing client ip address from {0}", ip_str);
166 }
167 }
168
147 GridRegion destination = new GridRegion(); 169 GridRegion destination = new GridRegion();
148 destination.RegionID = uuid; 170 destination.RegionID = uuid;
149 destination.RegionLocX = x; 171 destination.RegionLocX = x;
@@ -166,7 +188,7 @@ namespace OpenSim.Server.Handlers.Hypergrid
166 OSDMap resp = new OSDMap(2); 188 OSDMap resp = new OSDMap(2);
167 string reason = String.Empty; 189 string reason = String.Empty;
168 190
169 bool result = m_UserAgentService.LoginAgentToGrid(aCircuit, gatekeeper, destination, out reason); 191 bool result = m_UserAgentService.LoginAgentToGrid(aCircuit, gatekeeper, destination, client_ipaddress, out reason);
170 192
171 resp["reason"] = OSD.FromString(reason); 193 resp["reason"] = OSD.FromString(reason);
172 resp["success"] = OSD.FromBoolean(result); 194 resp["success"] = OSD.FromBoolean(result);
diff --git a/OpenSim/Server/Handlers/Hypergrid/UserAgentServerConnector.cs b/OpenSim/Server/Handlers/Hypergrid/UserAgentServerConnector.cs
index 6b1152b..70157d5 100644
--- a/OpenSim/Server/Handlers/Hypergrid/UserAgentServerConnector.cs
+++ b/OpenSim/Server/Handlers/Hypergrid/UserAgentServerConnector.cs
@@ -66,13 +66,15 @@ namespace OpenSim.Server.Handlers.Hypergrid
66 if (m_HomeUsersService == null) 66 if (m_HomeUsersService == null)
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");
70
69 server.AddXmlRPCHandler("agent_is_coming_home", AgentIsComingHome, false); 71 server.AddXmlRPCHandler("agent_is_coming_home", AgentIsComingHome, false);
70 server.AddXmlRPCHandler("get_home_region", GetHomeRegion, false); 72 server.AddXmlRPCHandler("get_home_region", GetHomeRegion, false);
71 server.AddXmlRPCHandler("verify_agent", VerifyAgent, false); 73 server.AddXmlRPCHandler("verify_agent", VerifyAgent, false);
72 server.AddXmlRPCHandler("verify_client", VerifyClient, false); 74 server.AddXmlRPCHandler("verify_client", VerifyClient, false);
73 server.AddXmlRPCHandler("logout_agent", LogoutAgent, false); 75 server.AddXmlRPCHandler("logout_agent", LogoutAgent, false);
74 76
75 server.AddHTTPHandler("/homeagent/", new HomeAgentHandler(m_HomeUsersService).Handler); 77 server.AddHTTPHandler("/homeagent/", new HomeAgentHandler(m_HomeUsersService, loginServerIP).Handler);
76 } 78 }
77 79
78 public XmlRpcResponse GetHomeRegion(XmlRpcRequest request, IPEndPoint remoteClient) 80 public XmlRpcResponse GetHomeRegion(XmlRpcRequest request, IPEndPoint remoteClient)
diff --git a/OpenSim/Server/Handlers/Login/LLLoginHandlers.cs b/OpenSim/Server/Handlers/Login/LLLoginHandlers.cs
index 5bb529c..30dc65e 100644
--- a/OpenSim/Server/Handlers/Login/LLLoginHandlers.cs
+++ b/OpenSim/Server/Handlers/Login/LLLoginHandlers.cs
@@ -52,15 +52,24 @@ namespace OpenSim.Server.Handlers.Login
52 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 52 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
53 53
54 private ILoginService m_LocalService; 54 private ILoginService m_LocalService;
55 private bool m_Proxy;
55 56
56 public LLLoginHandlers(ILoginService service) 57 public LLLoginHandlers(ILoginService service, bool hasProxy)
57 { 58 {
58 m_LocalService = service; 59 m_LocalService = service;
60 m_Proxy = hasProxy;
59 } 61 }
60 62
61 public XmlRpcResponse HandleXMLRPCLogin(XmlRpcRequest request, IPEndPoint remoteClient) 63 public XmlRpcResponse HandleXMLRPCLogin(XmlRpcRequest request, IPEndPoint remoteClient)
62 { 64 {
63 Hashtable requestData = (Hashtable)request.Params[0]; 65 Hashtable requestData = (Hashtable)request.Params[0];
66 if (m_Proxy && request.Params[3] != null)
67 {
68 IPEndPoint ep = Util.GetClientIPFromXFF((string)request.Params[3]);
69 if (ep != null)
70 // Bang!
71 remoteClient = ep;
72 }
64 73
65 if (requestData != null) 74 if (requestData != null)
66 { 75 {
@@ -189,6 +198,7 @@ namespace OpenSim.Server.Handlers.Login
189 198
190 return map; 199 return map;
191 } 200 }
201
192 } 202 }
193 203
194} 204}
diff --git a/OpenSim/Server/Handlers/Login/LLLoginServiceInConnector.cs b/OpenSim/Server/Handlers/Login/LLLoginServiceInConnector.cs
index 67e8392..16c93c8 100644
--- a/OpenSim/Server/Handlers/Login/LLLoginServiceInConnector.cs
+++ b/OpenSim/Server/Handlers/Login/LLLoginServiceInConnector.cs
@@ -43,6 +43,7 @@ namespace OpenSim.Server.Handlers.Login
43 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 43 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
44 44
45 private ILoginService m_LoginService; 45 private ILoginService m_LoginService;
46 private bool m_Proxy;
46 47
47 public LLLoginServiceInConnector(IConfigSource config, IHttpServer server, IScene scene) : 48 public LLLoginServiceInConnector(IConfigSource config, IHttpServer server, IScene scene) :
48 base(config, server, String.Empty) 49 base(config, server, String.Empty)
@@ -81,12 +82,14 @@ namespace OpenSim.Server.Handlers.Login
81 if (loginService == string.Empty) 82 if (loginService == string.Empty)
82 throw new Exception(String.Format("No LocalServiceModule for LoginService in config file")); 83 throw new Exception(String.Format("No LocalServiceModule for LoginService in config file"));
83 84
85 m_Proxy = serverConfig.GetBoolean("HasProxy", false);
86
84 return loginService; 87 return loginService;
85 } 88 }
86 89
87 private void InitializeHandlers(IHttpServer server) 90 private void InitializeHandlers(IHttpServer server)
88 { 91 {
89 LLLoginHandlers loginHandlers = new LLLoginHandlers(m_LoginService); 92 LLLoginHandlers loginHandlers = new LLLoginHandlers(m_LoginService, m_Proxy);
90 server.AddXmlRPCHandler("login_to_simulator", loginHandlers.HandleXMLRPCLogin, false); 93 server.AddXmlRPCHandler("login_to_simulator", loginHandlers.HandleXMLRPCLogin, false);
91 server.AddXmlRPCHandler("set_login_level", loginHandlers.HandleXMLRPCSetLoginLevel, false); 94 server.AddXmlRPCHandler("set_login_level", loginHandlers.HandleXMLRPCSetLoginLevel, false);
92 server.SetDefaultLLSDHandler(loginHandlers.HandleLLSDLogin); 95 server.SetDefaultLLSDHandler(loginHandlers.HandleLLSDLogin);
diff --git a/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs b/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs
index 05b00e5..42ea296 100644
--- a/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs
+++ b/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs
@@ -184,7 +184,7 @@ namespace OpenSim.Server.Handlers.Simulation
184 resp["reason"] = OSD.FromString(reason); 184 resp["reason"] = OSD.FromString(reason);
185 resp["success"] = OSD.FromBoolean(result); 185 resp["success"] = OSD.FromBoolean(result);
186 // Let's also send out the IP address of the caller back to the caller (HG 1.5) 186 // Let's also send out the IP address of the caller back to the caller (HG 1.5)
187 resp["your_ip"] = OSD.FromString(GetCallerIP(request)); 187 resp["your_ip"] = OSD.FromString(Util.GetCallerIP(request));
188 188
189 // TODO: add reason if not String.Empty? 189 // TODO: add reason if not String.Empty?
190 responsedata["int_response_code"] = HttpStatusCode.OK; 190 responsedata["int_response_code"] = HttpStatusCode.OK;
@@ -378,23 +378,6 @@ namespace OpenSim.Server.Handlers.Simulation
378 m_SimulationService.ReleaseAgent(regionID, id, ""); 378 m_SimulationService.ReleaseAgent(regionID, id, "");
379 } 379 }
380 380
381 private string GetCallerIP(Hashtable req)
382 {
383 if (req.ContainsKey("headers"))
384 {
385 try
386 {
387 Hashtable headers = (Hashtable)req["headers"];
388 if (headers.ContainsKey("remote_addr") && headers["remote_addr"] != null)
389 return headers["remote_addr"].ToString();
390 }
391 catch (Exception e)
392 {
393 m_log.WarnFormat("[AGENT HANDLER]: exception in GetCallerIP: {0}", e.Message);
394 }
395 }
396 return string.Empty;
397 }
398 } 381 }
399 382
400} 383}