aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services/HypergridService/UserAgentService.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Services/HypergridService/UserAgentService.cs45
1 files changed, 33 insertions, 12 deletions
diff --git a/OpenSim/Services/HypergridService/UserAgentService.cs b/OpenSim/Services/HypergridService/UserAgentService.cs
index 181d7f2..8c3be70 100644
--- a/OpenSim/Services/HypergridService/UserAgentService.cs
+++ b/OpenSim/Services/HypergridService/UserAgentService.cs
@@ -131,10 +131,11 @@ namespace OpenSim.Services.HypergridService
131 return home; 131 return home;
132 } 132 }
133 133
134 public bool LoginAgentToGrid(AgentCircuitData agentCircuit, GridRegion gatekeeper, GridRegion finalDestination, out string reason) 134 public bool LoginAgentToGrid(AgentCircuitData agentCircuit, GridRegion gatekeeper, GridRegion finalDestination, IPEndPoint clientIP, out string reason)
135 { 135 {
136 m_log.DebugFormat("[USER AGENT SERVICE]: Request to login user {0} {1} to grid {2}", 136 m_log.DebugFormat("[USER AGENT SERVICE]: Request to login user {0} {1} (@{2}) to grid {3}",
137 agentCircuit.firstname, agentCircuit.lastname, gatekeeper.ExternalHostName +":"+ gatekeeper.HttpPort); 137 agentCircuit.firstname, agentCircuit.lastname, ((clientIP == null) ? "stored IP" : clientIP.Address.ToString()),
138 gatekeeper.ExternalHostName +":"+ gatekeeper.HttpPort);
138 139
139 // Take the IP address + port of the gatekeeper (reg) plus the info of finalDestination 140 // Take the IP address + port of the gatekeeper (reg) plus the info of finalDestination
140 GridRegion region = new GridRegion(gatekeeper); 141 GridRegion region = new GridRegion(gatekeeper);
@@ -149,11 +150,12 @@ namespace OpenSim.Services.HypergridService
149 150
150 //bool success = m_GatekeeperConnector.CreateAgent(region, agentCircuit, (uint)Constants.TeleportFlags.ViaLogin, out reason); 151 //bool success = m_GatekeeperConnector.CreateAgent(region, agentCircuit, (uint)Constants.TeleportFlags.ViaLogin, out reason);
151 bool success = false; 152 bool success = false;
153 string myExternalIP = string.Empty;
152 string gridName = "http://" + gatekeeper.ExternalHostName + ":" + gatekeeper.HttpPort; 154 string gridName = "http://" + gatekeeper.ExternalHostName + ":" + gatekeeper.HttpPort;
153 if (m_GridName == gridName) 155 if (m_GridName == gridName)
154 success = m_GatekeeperService.LoginAgent(agentCircuit, finalDestination, out reason); 156 success = m_GatekeeperService.LoginAgent(agentCircuit, finalDestination, out reason);
155 else 157 else
156 success = m_GatekeeperConnector.CreateAgent(region, agentCircuit, (uint)Constants.TeleportFlags.ViaLogin, out reason); 158 success = m_GatekeeperConnector.CreateAgent(region, agentCircuit, (uint)Constants.TeleportFlags.ViaLogin, out myExternalIP, out reason);
157 159
158 if (!success) 160 if (!success)
159 { 161 {
@@ -167,15 +169,26 @@ namespace OpenSim.Services.HypergridService
167 return false; 169 return false;
168 } 170 }
169 171
172 m_log.DebugFormat("[USER AGENT SERVICE]: Gatekeeper sees me as {0}", myExternalIP);
173 // else set the IP addresses associated with this client
174 if (clientIP != null)
175 m_TravelingAgents[agentCircuit.SessionID].ClientIPAddress = clientIP.Address.ToString();
176 m_TravelingAgents[agentCircuit.SessionID].MyIpAddress = myExternalIP;
170 return true; 177 return true;
171 } 178 }
172 179
173 public void SetClientToken(UUID sessionID, string token) 180 public bool LoginAgentToGrid(AgentCircuitData agentCircuit, GridRegion gatekeeper, GridRegion finalDestination, out string reason)
181 {
182 reason = string.Empty;
183 return LoginAgentToGrid(agentCircuit, gatekeeper, finalDestination, null, out reason);
184 }
185
186 private void SetClientIP(UUID sessionID, string ip)
174 { 187 {
175 if (m_TravelingAgents.ContainsKey(sessionID)) 188 if (m_TravelingAgents.ContainsKey(sessionID))
176 { 189 {
177 m_log.DebugFormat("[USER AGENT SERVICE]: Setting token {0} for session {1}", token, sessionID); 190 m_log.DebugFormat("[USER AGENT SERVICE]: Setting IP {0} for session {1}", ip, sessionID);
178 m_TravelingAgents[sessionID].ClientToken = token; 191 m_TravelingAgents[sessionID].ClientIPAddress = ip;
179 } 192 }
180 } 193 }
181 194
@@ -196,7 +209,7 @@ namespace OpenSim.Services.HypergridService
196 travel.GridExternalName = "http://" + region.ExternalHostName + ":" + region.HttpPort; 209 travel.GridExternalName = "http://" + region.ExternalHostName + ":" + region.HttpPort;
197 travel.ServiceToken = agentCircuit.ServiceSessionID; 210 travel.ServiceToken = agentCircuit.ServiceSessionID;
198 if (old != null) 211 if (old != null)
199 travel.ClientToken = old.ClientToken; 212 travel.ClientIPAddress = old.ClientIPAddress;
200 213
201 return old; 214 return old;
202 } 215 }
@@ -233,15 +246,22 @@ namespace OpenSim.Services.HypergridService
233 return travel.GridExternalName == thisGridExternalName; 246 return travel.GridExternalName == thisGridExternalName;
234 } 247 }
235 248
236 public bool VerifyClient(UUID sessionID, string token) 249 public bool VerifyClient(UUID sessionID, string reportedIP)
237 { 250 {
238 if (m_BypassClientVerification) 251 if (m_BypassClientVerification)
239 return true; 252 return true;
240 253
241 m_log.DebugFormat("[USER AGENT SERVICE]: Verifying Client session {0} with token {1}", sessionID, token); 254 m_log.DebugFormat("[USER AGENT SERVICE]: Verifying Client session {0} with reported IP {1}.",
255 sessionID, reportedIP);
242 256
243 if (m_TravelingAgents.ContainsKey(sessionID)) 257 if (m_TravelingAgents.ContainsKey(sessionID))
244 return m_TravelingAgents[sessionID].ClientToken == token; 258 {
259 m_log.DebugFormat("[USER AGENT SERVICE]: Comparing with login IP {0} and MyIP {1}",
260 m_TravelingAgents[sessionID].ClientIPAddress, m_TravelingAgents[sessionID].MyIpAddress);
261
262 return m_TravelingAgents[sessionID].ClientIPAddress == reportedIP ||
263 m_TravelingAgents[sessionID].MyIpAddress == reportedIP; // NATed
264 }
245 265
246 return false; 266 return false;
247 } 267 }
@@ -266,7 +286,8 @@ namespace OpenSim.Services.HypergridService
266 public UUID UserID; 286 public UUID UserID;
267 public string GridExternalName = string.Empty; 287 public string GridExternalName = string.Empty;
268 public string ServiceToken = string.Empty; 288 public string ServiceToken = string.Empty;
269 public string ClientToken = string.Empty; 289 public string ClientIPAddress = string.Empty; // as seen from this user agent service
290 public string MyIpAddress = string.Empty; // the user agent service's external IP, as seen from the next gatekeeper
270 } 291 }
271 292
272} 293}