aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services/HypergridService/UserAgentService.cs
diff options
context:
space:
mode:
authorDiva Canto2010-08-19 18:55:30 -0700
committerDiva Canto2010-08-19 18:55:30 -0700
commit1955b797598d61548521c444ea8d3721fd5435ba (patch)
treef9c111e3e8a34e6ef56e1aeddea90a85dbe702f9 /OpenSim/Services/HypergridService/UserAgentService.cs
parentThese files want to be committed. This time I'm doing it separately from othe... (diff)
downloadopensim-SC_OLD-1955b797598d61548521c444ea8d3721fd5435ba.zip
opensim-SC_OLD-1955b797598d61548521c444ea8d3721fd5435ba.tar.gz
opensim-SC_OLD-1955b797598d61548521c444ea8d3721fd5435ba.tar.bz2
opensim-SC_OLD-1955b797598d61548521c444ea8d3721fd5435ba.tar.xz
Partial rewrite of client IP verification. Not completely finished yet, and untested. Committing to move to my other computer.
Diffstat (limited to 'OpenSim/Services/HypergridService/UserAgentService.cs')
-rw-r--r--OpenSim/Services/HypergridService/UserAgentService.cs44
1 files changed, 32 insertions, 12 deletions
diff --git a/OpenSim/Services/HypergridService/UserAgentService.cs b/OpenSim/Services/HypergridService/UserAgentService.cs
index 181d7f2..6b14e21 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.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,25 @@ namespace OpenSim.Services.HypergridService
167 return false; 169 return false;
168 } 170 }
169 171
172 // else set the IP addresses associated with this client
173 if (clientIP != null)
174 m_TravelingAgents[agentCircuit.SessionID].ClientIPAddress = clientIP.ToString();
175 m_TravelingAgents[agentCircuit.SessionID].MyIpAddress = myExternalIP;
170 return true; 176 return true;
171 } 177 }
172 178
173 public void SetClientToken(UUID sessionID, string token) 179 public bool LoginAgentToGrid(AgentCircuitData agentCircuit, GridRegion gatekeeper, GridRegion finalDestination, out string reason)
180 {
181 reason = string.Empty;
182 return LoginAgentToGrid(agentCircuit, gatekeeper, finalDestination, null, out reason);
183 }
184
185 private void SetClientIP(UUID sessionID, string ip)
174 { 186 {
175 if (m_TravelingAgents.ContainsKey(sessionID)) 187 if (m_TravelingAgents.ContainsKey(sessionID))
176 { 188 {
177 m_log.DebugFormat("[USER AGENT SERVICE]: Setting token {0} for session {1}", token, sessionID); 189 m_log.DebugFormat("[USER AGENT SERVICE]: Setting IP {0} for session {1}", ip, sessionID);
178 m_TravelingAgents[sessionID].ClientToken = token; 190 m_TravelingAgents[sessionID].ClientIPAddress = ip;
179 } 191 }
180 } 192 }
181 193
@@ -196,7 +208,7 @@ namespace OpenSim.Services.HypergridService
196 travel.GridExternalName = "http://" + region.ExternalHostName + ":" + region.HttpPort; 208 travel.GridExternalName = "http://" + region.ExternalHostName + ":" + region.HttpPort;
197 travel.ServiceToken = agentCircuit.ServiceSessionID; 209 travel.ServiceToken = agentCircuit.ServiceSessionID;
198 if (old != null) 210 if (old != null)
199 travel.ClientToken = old.ClientToken; 211 travel.ClientIPAddress = old.ClientIPAddress;
200 212
201 return old; 213 return old;
202 } 214 }
@@ -233,15 +245,22 @@ namespace OpenSim.Services.HypergridService
233 return travel.GridExternalName == thisGridExternalName; 245 return travel.GridExternalName == thisGridExternalName;
234 } 246 }
235 247
236 public bool VerifyClient(UUID sessionID, string token) 248 public bool VerifyClient(UUID sessionID, string reportedIP)
237 { 249 {
238 if (m_BypassClientVerification) 250 if (m_BypassClientVerification)
239 return true; 251 return true;
240 252
241 m_log.DebugFormat("[USER AGENT SERVICE]: Verifying Client session {0} with token {1}", sessionID, token); 253 m_log.DebugFormat("[USER AGENT SERVICE]: Verifying Client session {0} with reported IP {1}.",
254 sessionID, reportedIP);
242 255
243 if (m_TravelingAgents.ContainsKey(sessionID)) 256 if (m_TravelingAgents.ContainsKey(sessionID))
244 return m_TravelingAgents[sessionID].ClientToken == token; 257 {
258 m_log.DebugFormat("[USER AGENT SERVICE]: Comparing with login IP {0} and MyIP {1}",
259 m_TravelingAgents[sessionID].ClientIPAddress, m_TravelingAgents[sessionID].MyIpAddress);
260
261 return m_TravelingAgents[sessionID].ClientIPAddress == reportedIP ||
262 m_TravelingAgents[sessionID].MyIpAddress == reportedIP; // NATed
263 }
245 264
246 return false; 265 return false;
247 } 266 }
@@ -266,7 +285,8 @@ namespace OpenSim.Services.HypergridService
266 public UUID UserID; 285 public UUID UserID;
267 public string GridExternalName = string.Empty; 286 public string GridExternalName = string.Empty;
268 public string ServiceToken = string.Empty; 287 public string ServiceToken = string.Empty;
269 public string ClientToken = string.Empty; 288 public string ClientIPAddress = string.Empty; // as seen from this user agent service
289 public string MyIpAddress = string.Empty; // the user agent service's external IP, as seen from the next gatekeeper
270 } 290 }
271 291
272} 292}