diff options
author | Diva Canto | 2010-09-04 16:39:03 -0700 |
---|---|---|
committer | Diva Canto | 2010-09-04 16:39:03 -0700 |
commit | 9fd98368416ce9514e0926301a1fc20648d9ad59 (patch) | |
tree | 1d548f5311c51ad3dc5095232e87a45ef71c98b0 /OpenSim | |
parent | Merge branch 'master' of ssh://opensimulator.org/var/git/opensim (diff) | |
download | opensim-SC_OLD-9fd98368416ce9514e0926301a1fc20648d9ad59.zip opensim-SC_OLD-9fd98368416ce9514e0926301a1fc20648d9ad59.tar.gz opensim-SC_OLD-9fd98368416ce9514e0926301a1fc20648d9ad59.tar.bz2 opensim-SC_OLD-9fd98368416ce9514e0926301a1fc20648d9ad59.tar.xz |
Make User Agent Service and Login Service separable.
Diffstat (limited to '')
5 files changed, 77 insertions, 32 deletions
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs index 2ac4eb1..e7a7f49 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs | |||
@@ -1521,7 +1521,23 @@ namespace OpenSim.Framework | |||
1521 | return null; | 1521 | return null; |
1522 | } | 1522 | } |
1523 | 1523 | ||
1524 | 1524 | public static string GetCallerIP(Hashtable req) | |
1525 | { | ||
1526 | if (req.ContainsKey("headers")) | ||
1527 | { | ||
1528 | try | ||
1529 | { | ||
1530 | Hashtable headers = (Hashtable)req["headers"]; | ||
1531 | if (headers.ContainsKey("remote_addr") && headers["remote_addr"] != null) | ||
1532 | return headers["remote_addr"].ToString(); | ||
1533 | } | ||
1534 | catch (Exception e) | ||
1535 | { | ||
1536 | m_log.WarnFormat("[UTIL]: exception in GetCallerIP: {0}", e.Message); | ||
1537 | } | ||
1538 | } | ||
1539 | return string.Empty; | ||
1540 | } | ||
1525 | 1541 | ||
1526 | } | 1542 | } |
1527 | } | 1543 | } |
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/Simulation/AgentHandlers.cs b/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs index 392927a..2997430 100644 --- a/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs +++ b/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs | |||
@@ -179,7 +179,7 @@ namespace OpenSim.Server.Handlers.Simulation | |||
179 | resp["reason"] = OSD.FromString(reason); | 179 | resp["reason"] = OSD.FromString(reason); |
180 | resp["success"] = OSD.FromBoolean(result); | 180 | resp["success"] = OSD.FromBoolean(result); |
181 | // Let's also send out the IP address of the caller back to the caller (HG 1.5) | 181 | // Let's also send out the IP address of the caller back to the caller (HG 1.5) |
182 | resp["your_ip"] = OSD.FromString(GetCallerIP(request)); | 182 | resp["your_ip"] = OSD.FromString(Util.GetCallerIP(request)); |
183 | 183 | ||
184 | // TODO: add reason if not String.Empty? | 184 | // TODO: add reason if not String.Empty? |
185 | responsedata["int_response_code"] = HttpStatusCode.OK; | 185 | responsedata["int_response_code"] = HttpStatusCode.OK; |
@@ -355,23 +355,6 @@ namespace OpenSim.Server.Handlers.Simulation | |||
355 | m_SimulationService.ReleaseAgent(regionID, id, ""); | 355 | m_SimulationService.ReleaseAgent(regionID, id, ""); |
356 | } | 356 | } |
357 | 357 | ||
358 | private string GetCallerIP(Hashtable req) | ||
359 | { | ||
360 | if (req.ContainsKey("headers")) | ||
361 | { | ||
362 | try | ||
363 | { | ||
364 | Hashtable headers = (Hashtable)req["headers"]; | ||
365 | if (headers.ContainsKey("remote_addr") && headers["remote_addr"] != null) | ||
366 | return headers["remote_addr"].ToString(); | ||
367 | } | ||
368 | catch (Exception e) | ||
369 | { | ||
370 | m_log.WarnFormat("[AGENT HANDLER]: exception in GetCallerIP: {0}", e.Message); | ||
371 | } | ||
372 | } | ||
373 | return string.Empty; | ||
374 | } | ||
375 | } | 358 | } |
376 | 359 | ||
377 | } | 360 | } |
diff --git a/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs b/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs index 7fa086a..5d29087 100644 --- a/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs +++ b/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs | |||
@@ -70,16 +70,29 @@ namespace OpenSim.Services.Connectors.Hypergrid | |||
70 | 70 | ||
71 | public UserAgentServiceConnector(IConfigSource config) | 71 | public UserAgentServiceConnector(IConfigSource config) |
72 | { | 72 | { |
73 | } | 73 | IConfig serviceConfig = config.Configs["UserAgentService"]; |
74 | if (serviceConfig == null) | ||
75 | { | ||
76 | m_log.Error("[USER AGENT CONNECTOR]: UserAgentService missing from ini"); | ||
77 | throw new Exception("UserAgent connector init error"); | ||
78 | } | ||
74 | 79 | ||
75 | public bool LoginAgentToGrid(AgentCircuitData agent, GridRegion gatekeeper, GridRegion finalDestination, IPEndPoint ipaddress, out string reason) | 80 | string serviceURI = serviceConfig.GetString("UserAgentServerURI", |
76 | { | 81 | String.Empty); |
77 | // not available over remote calls | 82 | |
78 | reason = "Method not available over remote calls"; | 83 | if (serviceURI == String.Empty) |
79 | return false; | 84 | { |
85 | m_log.Error("[USER AGENT CONNECTOR]: No Server URI named in section UserAgentService"); | ||
86 | throw new Exception("UserAgent connector init error"); | ||
87 | } | ||
88 | m_ServerURL = serviceURI; | ||
89 | |||
90 | m_log.DebugFormat("[USER AGENT CONNECTOR]: UserAgentServiceConnector started for {0}", m_ServerURL); | ||
80 | } | 91 | } |
81 | 92 | ||
82 | public bool LoginAgentToGrid(AgentCircuitData aCircuit, GridRegion gatekeeper, GridRegion destination, out string reason) | 93 | |
94 | // The Login service calls this interface with a non-null [client] ipaddress | ||
95 | public bool LoginAgentToGrid(AgentCircuitData aCircuit, GridRegion gatekeeper, GridRegion destination, IPEndPoint ipaddress, out string reason) | ||
83 | { | 96 | { |
84 | reason = String.Empty; | 97 | reason = String.Empty; |
85 | 98 | ||
@@ -90,7 +103,7 @@ namespace OpenSim.Services.Connectors.Hypergrid | |||
90 | return false; | 103 | return false; |
91 | } | 104 | } |
92 | 105 | ||
93 | string uri = m_ServerURL + "/homeagent/" + aCircuit.AgentID + "/"; | 106 | string uri = m_ServerURL + "/homeagent/" + aCircuit.AgentID + "/"; |
94 | 107 | ||
95 | Console.WriteLine(" >>> LoginAgentToGrid <<< " + uri); | 108 | Console.WriteLine(" >>> LoginAgentToGrid <<< " + uri); |
96 | 109 | ||
@@ -102,7 +115,7 @@ namespace OpenSim.Services.Connectors.Hypergrid | |||
102 | //AgentCreateRequest.Headers.Add("Authorization", authKey); | 115 | //AgentCreateRequest.Headers.Add("Authorization", authKey); |
103 | 116 | ||
104 | // Fill it in | 117 | // Fill it in |
105 | OSDMap args = PackCreateAgentArguments(aCircuit, gatekeeper, destination); | 118 | OSDMap args = PackCreateAgentArguments(aCircuit, gatekeeper, destination, ipaddress); |
106 | 119 | ||
107 | string strBuffer = ""; | 120 | string strBuffer = ""; |
108 | byte[] buffer = new byte[1]; | 121 | byte[] buffer = new byte[1]; |
@@ -199,7 +212,14 @@ namespace OpenSim.Services.Connectors.Hypergrid | |||
199 | 212 | ||
200 | } | 213 | } |
201 | 214 | ||
202 | protected OSDMap PackCreateAgentArguments(AgentCircuitData aCircuit, GridRegion gatekeeper, GridRegion destination) | 215 | |
216 | // The simulators call this interface | ||
217 | public bool LoginAgentToGrid(AgentCircuitData aCircuit, GridRegion gatekeeper, GridRegion destination, out string reason) | ||
218 | { | ||
219 | return LoginAgentToGrid(aCircuit, gatekeeper, destination, null, out reason); | ||
220 | } | ||
221 | |||
222 | protected OSDMap PackCreateAgentArguments(AgentCircuitData aCircuit, GridRegion gatekeeper, GridRegion destination, IPEndPoint ipaddress) | ||
203 | { | 223 | { |
204 | OSDMap args = null; | 224 | OSDMap args = null; |
205 | try | 225 | try |
@@ -217,6 +237,8 @@ namespace OpenSim.Services.Connectors.Hypergrid | |||
217 | args["destination_y"] = OSD.FromString(destination.RegionLocY.ToString()); | 237 | args["destination_y"] = OSD.FromString(destination.RegionLocY.ToString()); |
218 | args["destination_name"] = OSD.FromString(destination.RegionName); | 238 | args["destination_name"] = OSD.FromString(destination.RegionName); |
219 | args["destination_uuid"] = OSD.FromString(destination.RegionID.ToString()); | 239 | args["destination_uuid"] = OSD.FromString(destination.RegionID.ToString()); |
240 | if (ipaddress != null) | ||
241 | args["client_ip"] = OSD.FromString(ipaddress.Address.ToString()); | ||
220 | 242 | ||
221 | return args; | 243 | return args; |
222 | } | 244 | } |