aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services/HypergridService/UserAgentService.cs
diff options
context:
space:
mode:
authorUbitUmarov2019-04-06 16:09:42 +0100
committerUbitUmarov2019-04-06 16:09:42 +0100
commitb7c1d6e7f5b4005d5a416e991de32ab67d8e6693 (patch)
treea655e5c80e706aa51f0e9e9f560f046f8f9c5dc1 /OpenSim/Services/HypergridService/UserAgentService.cs
parentpresence detector: don't even try to logout agents that didn't made to root (diff)
downloadopensim-SC-b7c1d6e7f5b4005d5a416e991de32ab67d8e6693.zip
opensim-SC-b7c1d6e7f5b4005d5a416e991de32ab67d8e6693.tar.gz
opensim-SC-b7c1d6e7f5b4005d5a416e991de32ab67d8e6693.tar.bz2
opensim-SC-b7c1d6e7f5b4005d5a416e991de32ab67d8e6693.tar.xz
UserAgentService: change handling of its external IP
Diffstat (limited to '')
-rw-r--r--OpenSim/Services/HypergridService/UserAgentService.cs50
1 files changed, 28 insertions, 22 deletions
diff --git a/OpenSim/Services/HypergridService/UserAgentService.cs b/OpenSim/Services/HypergridService/UserAgentService.cs
index 6f2cdd5..bfa97a1 100644
--- a/OpenSim/Services/HypergridService/UserAgentService.cs
+++ b/OpenSim/Services/HypergridService/UserAgentService.cs
@@ -73,6 +73,7 @@ namespace OpenSim.Services.HypergridService
73 protected static FriendsSimConnector m_FriendsSimConnector; // grid 73 protected static FriendsSimConnector m_FriendsSimConnector; // grid
74 74
75 protected static string m_GridName; 75 protected static string m_GridName;
76 protected static string m_MyExternalIP = "";
76 77
77 protected static int m_LevelOutsideContacts; 78 protected static int m_LevelOutsideContacts;
78 protected static bool m_ShowDetails; 79 protected static bool m_ShowDetails;
@@ -147,9 +148,20 @@ namespace OpenSim.Services.HypergridService
147 } 148 }
148 } 149 }
149 150
150 if (!m_GridName.EndsWith("/")) 151 if (!string.IsNullOrEmpty(m_GridName))
151 m_GridName = m_GridName + "/"; 152 {
152 153 m_GridName = m_GridName.ToLowerInvariant();
154 if (!m_GridName.EndsWith("/"))
155 m_GridName = m_GridName + "/";
156 Uri gateURI;
157 if(!Uri.TryCreate(m_GridName, UriKind.Absolute, out gateURI))
158 throw new Exception(String.Format("[UserAgentService] could not parse gatekeeper uri"));
159 string host = gateURI.DnsSafeHost;
160 IPAddress ip = Util.GetHostFromDNS(host);
161 if(ip == null)
162 throw new Exception(String.Format("[UserAgentService] failed to resolve gatekeeper host"));
163 m_MyExternalIP = ip.ToString();
164 }
153 // Finally some cleanup 165 // Finally some cleanup
154 m_Database.DeleteOld(); 166 m_Database.DeleteOld();
155 167
@@ -189,7 +201,6 @@ namespace OpenSim.Services.HypergridService
189 } 201 }
190 } 202 }
191 203
192
193 public GridRegion GetHomeRegion(UUID userID, out Vector3 position, out Vector3 lookAt) 204 public GridRegion GetHomeRegion(UUID userID, out Vector3 position, out Vector3 lookAt)
194 { 205 {
195 position = new Vector3(128, 128, 0); lookAt = Vector3.UnitY; 206 position = new Vector3(128, 128, 0); lookAt = Vector3.UnitY;
@@ -222,7 +233,7 @@ namespace OpenSim.Services.HypergridService
222 m_log.DebugFormat("[USER AGENT SERVICE]: Request to login user {0} {1} (@{2}) to grid {3}", 233 m_log.DebugFormat("[USER AGENT SERVICE]: Request to login user {0} {1} (@{2}) to grid {3}",
223 agentCircuit.firstname, agentCircuit.lastname, (fromLogin ? agentCircuit.IPAddress : "stored IP"), gatekeeper.ServerURI); 234 agentCircuit.firstname, agentCircuit.lastname, (fromLogin ? agentCircuit.IPAddress : "stored IP"), gatekeeper.ServerURI);
224 235
225 string gridName = gatekeeper.ServerURI; 236 string gridName = gatekeeper.ServerURI.ToLowerInvariant();
226 237
227 UserAccount account = m_UserAccountService.GetUserAccount(UUID.Zero, agentCircuit.AgentID); 238 UserAccount account = m_UserAccountService.GetUserAccount(UUID.Zero, agentCircuit.AgentID);
228 if (account == null) 239 if (account == null)
@@ -269,8 +280,13 @@ namespace OpenSim.Services.HypergridService
269 TravelingAgentInfo old = null; 280 TravelingAgentInfo old = null;
270 TravelingAgentInfo travel = CreateTravelInfo(agentCircuit, region, fromLogin, out old); 281 TravelingAgentInfo travel = CreateTravelInfo(agentCircuit, region, fromLogin, out old);
271 282
283 if(!fromLogin && old != null && !string.IsNullOrEmpty(old.ClientIPAddress))
284 {
285 m_log.DebugFormat("[USER AGENT SERVICE]: stored IP = {0}. Old circuit IP: {1}", old.ClientIPAddress, agentCircuit.IPAddress);
286 agentCircuit.IPAddress = old.ClientIPAddress;
287 }
288
272 bool success = false; 289 bool success = false;
273 string myExternalIP = string.Empty;
274 290
275 m_log.DebugFormat("[USER AGENT SERVICE]: this grid: {0}, desired grid: {1}, desired region: {2}", m_GridName, gridName, region.RegionID); 291 m_log.DebugFormat("[USER AGENT SERVICE]: this grid: {0}, desired grid: {1}, desired region: {2}", m_GridName, gridName, region.RegionID);
276 292
@@ -282,7 +298,7 @@ namespace OpenSim.Services.HypergridService
282 { 298 {
283 //TODO: Should there not be a call to QueryAccess here? 299 //TODO: Should there not be a call to QueryAccess here?
284 EntityTransferContext ctx = new EntityTransferContext(); 300 EntityTransferContext ctx = new EntityTransferContext();
285 success = m_GatekeeperConnector.CreateAgent(source, region, agentCircuit, (uint)Constants.TeleportFlags.ViaLogin, ctx, out myExternalIP, out reason); 301 success = m_GatekeeperConnector.CreateAgent(source, region, agentCircuit, (uint)Constants.TeleportFlags.ViaLogin, ctx, out reason);
286 } 302 }
287 303
288 if (!success) 304 if (!success)
@@ -300,14 +316,6 @@ namespace OpenSim.Services.HypergridService
300 316
301 // Everything is ok 317 // Everything is ok
302 318
303 if (!fromLogin)
304 {
305 // Update the perceived IP Address of our grid
306 m_log.DebugFormat("[USER AGENT SERVICE]: Gatekeeper sees me as {0}", myExternalIP);
307 }
308
309 travel.MyIpAddress = myExternalIP;
310
311 StoreTravelInfo(travel); 319 StoreTravelInfo(travel);
312 320
313 return true; 321 return true;
@@ -384,10 +392,12 @@ namespace OpenSim.Services.HypergridService
384 392
385 TravelingAgentInfo travel = new TravelingAgentInfo(hgt); 393 TravelingAgentInfo travel = new TravelingAgentInfo(hgt);
386 394
387 bool result = travel.ClientIPAddress == reportedIP || travel.MyIpAddress == reportedIP; // NATed 395 bool result = travel.ClientIPAddress == reportedIP;
396 if(!result && !string.IsNullOrEmpty(m_MyExternalIP))
397 result = reportedIP == m_MyExternalIP; // NATed
388 398
389 m_log.DebugFormat("[USER AGENT SERVICE]: Comparing {0} with login IP {1} and MyIP {1}; result is {3}", 399 m_log.DebugFormat("[USER AGENT SERVICE]: Comparing {0} with login IP {1} and MyIP {2}; result is {3}",
390 reportedIP, travel.ClientIPAddress, travel.MyIpAddress, result); 400 reportedIP, travel.ClientIPAddress, m_MyExternalIP, result);
391 401
392 return result; 402 return result;
393 } 403 }
@@ -704,7 +714,6 @@ namespace OpenSim.Services.HypergridService
704 hgt.Data["GridExternalName"] = travel.GridExternalName; 714 hgt.Data["GridExternalName"] = travel.GridExternalName;
705 hgt.Data["ServiceToken"] = travel.ServiceToken; 715 hgt.Data["ServiceToken"] = travel.ServiceToken;
706 hgt.Data["ClientIPAddress"] = travel.ClientIPAddress; 716 hgt.Data["ClientIPAddress"] = travel.ClientIPAddress;
707 hgt.Data["MyIPAddress"] = travel.MyIpAddress;
708 717
709 m_Database.Store(hgt); 718 m_Database.Store(hgt);
710 } 719 }
@@ -719,7 +728,6 @@ namespace OpenSim.Services.HypergridService
719 public string GridExternalName = string.Empty; 728 public string GridExternalName = string.Empty;
720 public string ServiceToken = string.Empty; 729 public string ServiceToken = string.Empty;
721 public string ClientIPAddress = string.Empty; // as seen from this user agent service 730 public string ClientIPAddress = string.Empty; // as seen from this user agent service
722 public string MyIpAddress = string.Empty; // the user agent service's external IP, as seen from the next gatekeeper
723 731
724 public TravelingAgentInfo(HGTravelingData t) 732 public TravelingAgentInfo(HGTravelingData t)
725 { 733 {
@@ -730,7 +738,6 @@ namespace OpenSim.Services.HypergridService
730 GridExternalName = t.Data["GridExternalName"]; 738 GridExternalName = t.Data["GridExternalName"];
731 ServiceToken = t.Data["ServiceToken"]; 739 ServiceToken = t.Data["ServiceToken"];
732 ClientIPAddress = t.Data["ClientIPAddress"]; 740 ClientIPAddress = t.Data["ClientIPAddress"];
733 MyIpAddress = t.Data["MyIPAddress"];
734 } 741 }
735 } 742 }
736 743
@@ -743,7 +750,6 @@ namespace OpenSim.Services.HypergridService
743 GridExternalName = old.GridExternalName; 750 GridExternalName = old.GridExternalName;
744 ServiceToken = old.ServiceToken; 751 ServiceToken = old.ServiceToken;
745 ClientIPAddress = old.ClientIPAddress; 752 ClientIPAddress = old.ClientIPAddress;
746 MyIpAddress = old.MyIpAddress;
747 } 753 }
748 } 754 }
749 } 755 }