diff options
author | Jeff Ames | 2008-03-18 14:51:42 +0000 |
---|---|---|
committer | Jeff Ames | 2008-03-18 14:51:42 +0000 |
commit | bf8b5844f24d294c459f54147bd511e7112288bf (patch) | |
tree | 1b6a1ba4e9888d43694a8a33c21beb6913ce2d3a /OpenSim/Grid/GridServer/GridManager.cs | |
parent | * Applied Grumly57 patch for #781; Thanks, Grumly! (diff) | |
download | opensim-SC-bf8b5844f24d294c459f54147bd511e7112288bf.zip opensim-SC-bf8b5844f24d294c459f54147bd511e7112288bf.tar.gz opensim-SC-bf8b5844f24d294c459f54147bd511e7112288bf.tar.bz2 opensim-SC-bf8b5844f24d294c459f54147bd511e7112288bf.tar.xz |
Formatting cleanup. Minor refactoring.
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Grid/GridServer/GridManager.cs | 108 |
1 files changed, 52 insertions, 56 deletions
diff --git a/OpenSim/Grid/GridServer/GridManager.cs b/OpenSim/Grid/GridServer/GridManager.cs index 86fc445..56f294c 100644 --- a/OpenSim/Grid/GridServer/GridManager.cs +++ b/OpenSim/Grid/GridServer/GridManager.cs | |||
@@ -219,6 +219,7 @@ namespace OpenSim.Grid.GridServer | |||
219 | RegionProfileData central_region = getRegion(reqhandle); | 219 | RegionProfileData central_region = getRegion(reqhandle); |
220 | RegionProfileData neighbour; | 220 | RegionProfileData neighbour; |
221 | for (int x = -1; x < 2; x++) | 221 | for (int x = -1; x < 2; x++) |
222 | { | ||
222 | for (int y = -1; y < 2; y++) | 223 | for (int y = -1; y < 2; y++) |
223 | { | 224 | { |
224 | if ( | 225 | if ( |
@@ -230,6 +231,7 @@ namespace OpenSim.Grid.GridServer | |||
230 | getRegion( | 231 | getRegion( |
231 | Util.UIntsToLong((uint)((central_region.regionLocX + x) * Constants.RegionSize), | 232 | Util.UIntsToLong((uint)((central_region.regionLocX + x) * Constants.RegionSize), |
232 | (uint)(central_region.regionLocY + y) * Constants.RegionSize)); | 233 | (uint)(central_region.regionLocY + y) * Constants.RegionSize)); |
234 | |||
233 | response += "<neighbour>"; | 235 | response += "<neighbour>"; |
234 | response += "<sim_ip>" + neighbour.serverIP + "</sim_ip>"; | 236 | response += "<sim_ip>" + neighbour.serverIP + "</sim_ip>"; |
235 | response += "<sim_port>" + neighbour.serverPort.ToString() + "</sim_port>"; | 237 | response += "<sim_port>" + neighbour.serverPort.ToString() + "</sim_port>"; |
@@ -239,23 +241,20 @@ namespace OpenSim.Grid.GridServer | |||
239 | response += "</neighbour>"; | 241 | response += "</neighbour>"; |
240 | } | 242 | } |
241 | } | 243 | } |
244 | } | ||
242 | return response; | 245 | return response; |
243 | } | 246 | } |
244 | 247 | ||
245 | protected virtual bool ValidateOverwrite(RegionProfileData sim, RegionProfileData existingSim) | 248 | protected virtual bool ValidateOverwrite(RegionProfileData sim, RegionProfileData existingSim) |
246 | { | 249 | { |
247 | bool validated; | 250 | return (existingSim.regionRecvKey == sim.regionRecvKey && |
248 | validated = (existingSim.regionRecvKey == sim.regionRecvKey && | 251 | existingSim.regionSendKey == sim.regionSendKey); |
249 | existingSim.regionSendKey == sim.regionSendKey); | ||
250 | return validated; | ||
251 | } | 252 | } |
252 | 253 | ||
253 | protected virtual bool ValidateNewRegion(RegionProfileData sim) | 254 | protected virtual bool ValidateNewRegion(RegionProfileData sim) |
254 | { | 255 | { |
255 | bool validated; | 256 | return (sim.regionRecvKey == Config.SimSendKey && |
256 | validated = (sim.regionRecvKey == Config.SimSendKey && | 257 | sim.regionSendKey == Config.SimRecvKey); |
257 | sim.regionSendKey == Config.SimRecvKey); | ||
258 | return validated; | ||
259 | } | 258 | } |
260 | 259 | ||
261 | private XmlRpcResponse ErrorResponse(string error) | 260 | private XmlRpcResponse ErrorResponse(string error) |
@@ -274,17 +273,13 @@ namespace OpenSim.Grid.GridServer | |||
274 | /// <returns>Startup parameters</returns> | 273 | /// <returns>Startup parameters</returns> |
275 | public XmlRpcResponse XmlRpcSimulatorLoginMethod(XmlRpcRequest request) | 274 | public XmlRpcResponse XmlRpcSimulatorLoginMethod(XmlRpcRequest request) |
276 | { | 275 | { |
277 | |||
278 | RegionProfileData sim; | 276 | RegionProfileData sim; |
279 | RegionProfileData existingSim; | 277 | RegionProfileData existingSim; |
280 | 278 | ||
281 | Hashtable requestData = (Hashtable)request.Params[0]; | 279 | Hashtable requestData = (Hashtable)request.Params[0]; |
282 | LLUUID uuid; | 280 | LLUUID uuid; |
283 | 281 | ||
284 | if (requestData.ContainsKey("UUID") && LLUUID.TryParse((string)requestData["UUID"], out uuid)) | 282 | if (!requestData.ContainsKey("UUID") || !LLUUID.TryParse((string)requestData["UUID"], out uuid)) |
285 | { | ||
286 | } | ||
287 | else | ||
288 | { | 283 | { |
289 | m_log.Info("[GRID]: Region connected without a UUID, ignoring."); | 284 | m_log.Info("[GRID]: Region connected without a UUID, ignoring."); |
290 | return ErrorResponse("No UUID passed to grid server - unable to connect you"); | 285 | return ErrorResponse("No UUID passed to grid server - unable to connect you"); |
@@ -459,6 +454,7 @@ namespace OpenSim.Grid.GridServer | |||
459 | else | 454 | else |
460 | { | 455 | { |
461 | for (int x = -1; x < 2; x++) | 456 | for (int x = -1; x < 2; x++) |
457 | { | ||
462 | for (int y = -1; y < 2; y++) | 458 | for (int y = -1; y < 2; y++) |
463 | { | 459 | { |
464 | if ( | 460 | if ( |
@@ -482,6 +478,7 @@ namespace OpenSim.Grid.GridServer | |||
482 | if (neighbour.UUID != sim.UUID) SimNeighboursData.Add(NeighbourBlock); | 478 | if (neighbour.UUID != sim.UUID) SimNeighboursData.Add(NeighbourBlock); |
483 | } | 479 | } |
484 | } | 480 | } |
481 | } | ||
485 | } | 482 | } |
486 | return SimNeighboursData; | 483 | return SimNeighboursData; |
487 | } | 484 | } |
@@ -505,7 +502,6 @@ namespace OpenSim.Grid.GridServer | |||
505 | sim.regionUserSendKey = Config.UserSendKey; | 502 | sim.regionUserSendKey = Config.UserSendKey; |
506 | sim.regionUserRecvKey = Config.UserRecvKey; | 503 | sim.regionUserRecvKey = Config.UserRecvKey; |
507 | 504 | ||
508 | |||
509 | sim.serverIP = (string)requestData["sim_ip"]; | 505 | sim.serverIP = (string)requestData["sim_ip"]; |
510 | sim.serverPort = Convert.ToUInt32((string)requestData["sim_port"]); | 506 | sim.serverPort = Convert.ToUInt32((string)requestData["sim_port"]); |
511 | sim.httpPort = Convert.ToUInt32((string)requestData["http_port"]); | 507 | sim.httpPort = Convert.ToUInt32((string)requestData["http_port"]); |
@@ -514,7 +510,6 @@ namespace OpenSim.Grid.GridServer | |||
514 | sim.regionLocY = Convert.ToUInt32((string)requestData["region_locy"]); | 510 | sim.regionLocY = Convert.ToUInt32((string)requestData["region_locy"]); |
515 | sim.regionLocZ = 0; | 511 | sim.regionLocZ = 0; |
516 | 512 | ||
517 | |||
518 | LLUUID textureID; | 513 | LLUUID textureID; |
519 | if (LLUUID.TryParse((string)requestData["map-image-id"], out textureID)) | 514 | if (LLUUID.TryParse((string)requestData["map-image-id"], out textureID)) |
520 | { | 515 | { |
@@ -650,7 +645,7 @@ namespace OpenSim.Grid.GridServer | |||
650 | else | 645 | else |
651 | { | 646 | { |
652 | m_log.Info("[DATA]: found " + (string)simData.regionName + " regionHandle = " + | 647 | m_log.Info("[DATA]: found " + (string)simData.regionName + " regionHandle = " + |
653 | (string)requestData["region_handle"]); | 648 | (string)requestData["region_handle"]); |
654 | responseData["sim_ip"] = Util.GetHostFromDNS(simData.serverIP).ToString(); | 649 | responseData["sim_ip"] = Util.GetHostFromDNS(simData.serverIP).ToString(); |
655 | responseData["sim_port"] = simData.serverPort.ToString(); | 650 | responseData["sim_port"] = simData.serverPort.ToString(); |
656 | responseData["server_uri"] = simData.serverURI; | 651 | responseData["server_uri"] = simData.serverURI; |
@@ -730,7 +725,7 @@ namespace OpenSim.Grid.GridServer | |||
730 | simProfileList.Add(simProfileBlock); | 725 | simProfileList.Add(simProfileBlock); |
731 | } | 726 | } |
732 | m_log.Info("[MAP]: Fast map " + simProfileList.Count.ToString() + | 727 | m_log.Info("[MAP]: Fast map " + simProfileList.Count.ToString() + |
733 | " regions @ (" + xmin + "," + ymin + ")..(" + xmax + "," + ymax + ")"); | 728 | " regions @ (" + xmin + "," + ymin + ")..(" + xmax + "," + ymax + ")"); |
734 | } | 729 | } |
735 | else | 730 | else |
736 | { | 731 | { |
@@ -765,7 +760,7 @@ namespace OpenSim.Grid.GridServer | |||
765 | } | 760 | } |
766 | } | 761 | } |
767 | m_log.Info("[MAP]: Std map " + simProfileList.Count.ToString() + | 762 | m_log.Info("[MAP]: Std map " + simProfileList.Count.ToString() + |
768 | " regions @ (" + xmin + "," + ymin + ")..(" + xmax + "," + ymax + ")"); | 763 | " regions @ (" + xmin + "," + ymin + ")..(" + xmax + "," + ymax + ")"); |
769 | } | 764 | } |
770 | 765 | ||
771 | responseData["sim-profiles"] = simProfileList; | 766 | responseData["sim-profiles"] = simProfileList; |
@@ -852,14 +847,14 @@ namespace OpenSim.Grid.GridServer | |||
852 | public string RestSetSimMethod(string request, string path, string param) | 847 | public string RestSetSimMethod(string request, string path, string param) |
853 | { | 848 | { |
854 | Console.WriteLine("Processing region update via REST method"); | 849 | Console.WriteLine("Processing region update via REST method"); |
855 | RegionProfileData TheSim; | 850 | RegionProfileData theSim; |
856 | TheSim = getRegion(new LLUUID(param)); | 851 | theSim = getRegion(new LLUUID(param)); |
857 | if ((TheSim) == null) | 852 | if (theSim == null) |
858 | { | 853 | { |
859 | TheSim = new RegionProfileData(); | 854 | theSim = new RegionProfileData(); |
860 | LLUUID UUID = new LLUUID(param); | 855 | LLUUID UUID = new LLUUID(param); |
861 | TheSim.UUID = UUID; | 856 | theSim.UUID = UUID; |
862 | TheSim.regionRecvKey = Config.SimRecvKey; | 857 | theSim.regionRecvKey = Config.SimRecvKey; |
863 | } | 858 | } |
864 | 859 | ||
865 | XmlDocument doc = new XmlDocument(); | 860 | XmlDocument doc = new XmlDocument(); |
@@ -877,59 +872,59 @@ namespace OpenSim.Grid.GridServer | |||
877 | return "ERROR! bad XML - expected sim tag"; | 872 | return "ERROR! bad XML - expected sim tag"; |
878 | } | 873 | } |
879 | 874 | ||
880 | //TheSim.regionSendKey = Cfg; | 875 | //theSim.regionSendKey = Cfg; |
881 | TheSim.regionRecvKey = Config.SimRecvKey; | 876 | theSim.regionRecvKey = Config.SimRecvKey; |
882 | TheSim.regionSendKey = Config.SimSendKey; | 877 | theSim.regionSendKey = Config.SimSendKey; |
883 | TheSim.regionSecret = Config.SimRecvKey; | 878 | theSim.regionSecret = Config.SimRecvKey; |
884 | TheSim.regionDataURI = String.Empty; | 879 | theSim.regionDataURI = String.Empty; |
885 | TheSim.regionAssetURI = Config.DefaultAssetServer; | 880 | theSim.regionAssetURI = Config.DefaultAssetServer; |
886 | TheSim.regionAssetRecvKey = Config.AssetRecvKey; | 881 | theSim.regionAssetRecvKey = Config.AssetRecvKey; |
887 | TheSim.regionAssetSendKey = Config.AssetSendKey; | 882 | theSim.regionAssetSendKey = Config.AssetSendKey; |
888 | TheSim.regionUserURI = Config.DefaultUserServer; | 883 | theSim.regionUserURI = Config.DefaultUserServer; |
889 | TheSim.regionUserSendKey = Config.UserSendKey; | 884 | theSim.regionUserSendKey = Config.UserSendKey; |
890 | TheSim.regionUserRecvKey = Config.UserRecvKey; | 885 | theSim.regionUserRecvKey = Config.UserRecvKey; |
891 | 886 | ||
892 | for (int i = 0; i < simnode.ChildNodes.Count; i++) | 887 | for (int i = 0; i < simnode.ChildNodes.Count; i++) |
893 | { | 888 | { |
894 | switch (simnode.ChildNodes[i].Name) | 889 | switch (simnode.ChildNodes[i].Name) |
895 | { | 890 | { |
896 | case "regionname": | 891 | case "regionname": |
897 | TheSim.regionName = simnode.ChildNodes[i].InnerText; | 892 | theSim.regionName = simnode.ChildNodes[i].InnerText; |
898 | break; | 893 | break; |
899 | 894 | ||
900 | case "sim_ip": | 895 | case "sim_ip": |
901 | TheSim.serverIP = simnode.ChildNodes[i].InnerText; | 896 | theSim.serverIP = simnode.ChildNodes[i].InnerText; |
902 | break; | 897 | break; |
903 | 898 | ||
904 | case "sim_port": | 899 | case "sim_port": |
905 | TheSim.serverPort = Convert.ToUInt32(simnode.ChildNodes[i].InnerText); | 900 | theSim.serverPort = Convert.ToUInt32(simnode.ChildNodes[i].InnerText); |
906 | break; | 901 | break; |
907 | 902 | ||
908 | case "region_locx": | 903 | case "region_locx": |
909 | TheSim.regionLocX = Convert.ToUInt32((string)simnode.ChildNodes[i].InnerText); | 904 | theSim.regionLocX = Convert.ToUInt32((string)simnode.ChildNodes[i].InnerText); |
910 | TheSim.regionHandle = Helpers.UIntsToLong((TheSim.regionLocX * Constants.RegionSize), (TheSim.regionLocY * Constants.RegionSize)); | 905 | theSim.regionHandle = Helpers.UIntsToLong((theSim.regionLocX * Constants.RegionSize), (theSim.regionLocY * Constants.RegionSize)); |
911 | break; | 906 | break; |
912 | 907 | ||
913 | case "region_locy": | 908 | case "region_locy": |
914 | TheSim.regionLocY = Convert.ToUInt32((string)simnode.ChildNodes[i].InnerText); | 909 | theSim.regionLocY = Convert.ToUInt32((string)simnode.ChildNodes[i].InnerText); |
915 | TheSim.regionHandle = Helpers.UIntsToLong((TheSim.regionLocX * Constants.RegionSize), (TheSim.regionLocY * Constants.RegionSize)); | 910 | theSim.regionHandle = Helpers.UIntsToLong((theSim.regionLocX * Constants.RegionSize), (theSim.regionLocY * Constants.RegionSize)); |
916 | break; | 911 | break; |
917 | } | 912 | } |
918 | } | 913 | } |
919 | 914 | ||
920 | TheSim.serverURI = "http://" + TheSim.serverIP + ":" + TheSim.serverPort + "/"; | 915 | theSim.serverURI = "http://" + theSim.serverIP + ":" + theSim.serverPort + "/"; |
921 | bool requirePublic = false; | 916 | bool requirePublic = false; |
922 | bool requireValid = true; | 917 | bool requireValid = true; |
923 | 918 | ||
924 | if (requirePublic && | 919 | if (requirePublic && |
925 | (TheSim.serverIP.StartsWith("172.16") || TheSim.serverIP.StartsWith("192.168") || | 920 | (theSim.serverIP.StartsWith("172.16") || theSim.serverIP.StartsWith("192.168") || |
926 | TheSim.serverIP.StartsWith("10.") || TheSim.serverIP.StartsWith("0.") || | 921 | theSim.serverIP.StartsWith("10.") || theSim.serverIP.StartsWith("0.") || |
927 | TheSim.serverIP.StartsWith("255."))) | 922 | theSim.serverIP.StartsWith("255."))) |
928 | { | 923 | { |
929 | return "ERROR! Servers must register with public addresses."; | 924 | return "ERROR! Servers must register with public addresses."; |
930 | } | 925 | } |
931 | 926 | ||
932 | if (requireValid && (TheSim.serverIP.StartsWith("0.") || TheSim.serverIP.StartsWith("255."))) | 927 | if (requireValid && (theSim.serverIP.StartsWith("0.") || theSim.serverIP.StartsWith("255."))) |
933 | { | 928 | { |
934 | return "ERROR! 0.*.*.* / 255.*.*.* Addresses are invalid, please check your server config and try again"; | 929 | return "ERROR! 0.*.*.* / 255.*.*.* Addresses are invalid, please check your server config and try again"; |
935 | } | 930 | } |
@@ -937,27 +932,28 @@ namespace OpenSim.Grid.GridServer | |||
937 | try | 932 | try |
938 | { | 933 | { |
939 | m_log.Info("[DATA]: " + | 934 | m_log.Info("[DATA]: " + |
940 | "Updating / adding via " + _plugins.Count + " storage provider(s) registered."); | 935 | "Updating / adding via " + _plugins.Count + " storage provider(s) registered."); |
936 | |||
941 | foreach (KeyValuePair<string, IGridData> kvp in _plugins) | 937 | foreach (KeyValuePair<string, IGridData> kvp in _plugins) |
942 | { | 938 | { |
943 | try | 939 | try |
944 | { | 940 | { |
945 | //Check reservations | 941 | //Check reservations |
946 | ReservationData reserveData = | 942 | ReservationData reserveData = |
947 | kvp.Value.GetReservationAtPoint(TheSim.regionLocX, TheSim.regionLocY); | 943 | kvp.Value.GetReservationAtPoint(theSim.regionLocX, theSim.regionLocY); |
948 | if ((reserveData != null && reserveData.gridRecvKey == TheSim.regionRecvKey) || | 944 | if ((reserveData != null && reserveData.gridRecvKey == theSim.regionRecvKey) || |
949 | (reserveData == null && authkeynode.InnerText != TheSim.regionRecvKey)) | 945 | (reserveData == null && authkeynode.InnerText != theSim.regionRecvKey)) |
950 | { | 946 | { |
951 | kvp.Value.AddProfile(TheSim); | 947 | kvp.Value.AddProfile(theSim); |
952 | m_log.Info("[grid]: New sim added to grid (" + TheSim.regionName + ")"); | 948 | m_log.Info("[grid]: New sim added to grid (" + theSim.regionName + ")"); |
953 | logToDB(TheSim.UUID.ToString(), "RestSetSimMethod", String.Empty, 5, | 949 | logToDB(theSim.UUID.ToString(), "RestSetSimMethod", String.Empty, 5, |
954 | "Region successfully updated and connected to grid."); | 950 | "Region successfully updated and connected to grid."); |
955 | } | 951 | } |
956 | else | 952 | else |
957 | { | 953 | { |
958 | m_log.Warn("[grid]: " + | 954 | m_log.Warn("[grid]: " + |
959 | "Unable to update region (RestSetSimMethod): Incorrect reservation auth key."); | 955 | "Unable to update region (RestSetSimMethod): Incorrect reservation auth key."); |
960 | // Wanted: " + reserveData.gridRecvKey + ", Got: " + TheSim.regionRecvKey + "."); | 956 | // Wanted: " + reserveData.gridRecvKey + ", Got: " + theSim.regionRecvKey + "."); |
961 | return "Unable to update region (RestSetSimMethod): Incorrect auth key."; | 957 | return "Unable to update region (RestSetSimMethod): Incorrect auth key."; |
962 | } | 958 | } |
963 | } | 959 | } |