private void HandleSetFlags(string module, string[] cmd) { if (cmd.Length < 5) { MainConsole.Instance.Output("Syntax: set region flags <region name> <flags>"); return; } List <RegionData> regions = m_Database.Get(cmd[3], UUID.Zero); if (regions == null || regions.Count < 1) { MainConsole.Instance.Output("Region not found"); return; } foreach (RegionData r in regions) { int flags = Convert.ToInt32(r.Data["flags"]); flags = ParseFlags(flags, cmd[4]); r.Data["flags"] = flags.ToString(); OpenSim.Data.RegionFlags f = (OpenSim.Data.RegionFlags)flags; MainConsole.Instance.Output(String.Format("Set region {0} to {1}", r.RegionName, f)); m_Database.Store(r); } }
private void HandleShowRegion(string module, string[] cmd) { if (cmd.Length != 3) { MainConsole.Instance.Output("Syntax: show region <region name>"); return; } List <RegionData> regions = m_Database.Get(cmd[2], UUID.Zero); if (regions == null || regions.Count < 1) { MainConsole.Instance.Output("Region not found"); return; } MainConsole.Instance.Output("Region Name Region UUID"); MainConsole.Instance.Output("Location URI"); MainConsole.Instance.Output("Owner ID Flags"); MainConsole.Instance.Output("-------------------------------------------------------------------------------"); foreach (RegionData r in regions) { OpenSim.Data.RegionFlags flags = (OpenSim.Data.RegionFlags)Convert.ToInt32(r.Data["flags"]); MainConsole.Instance.Output(String.Format("{0,-20} {1}\n{2,-20} {3}\n{4,-39} {5}\n\n", r.RegionName, r.RegionID, String.Format("{0},{1}", r.posX, r.posY), "http://" + r.Data["serverIP"].ToString() + ":" + r.Data["serverPort"].ToString(), r.Data["owner_uuid"].ToString(), flags.ToString())); } return; }
public bool TryUnlinkRegion(string mapName) { m_log.DebugFormat("[HYPERGRID LINKER]: Request to unlink {0}", mapName); GridRegion regInfo = null; List <RegionData> regions = m_Database.Get(mapName, m_ScopeID); if (regions != null && regions.Count > 0) { OpenSim.Data.RegionFlags rflags = (OpenSim.Data.RegionFlags)Convert.ToInt32(regions[0].Data["flags"]); if ((rflags & OpenSim.Data.RegionFlags.Hyperlink) != 0) { regInfo = new GridRegion(); regInfo.RegionID = regions[0].RegionID; regInfo.ScopeID = m_ScopeID; } } if (regInfo != null) { RemoveHyperlinkRegion(regInfo.RegionID); return(true); } else { m_log.InfoFormat("[HYPERGRID LINKER]: Region {0} not found", mapName); return(false); } }
private void OutputRegionToConsole(RegionData r) { OpenSim.Data.RegionFlags flags = (OpenSim.Data.RegionFlags)Convert.ToInt32(r.Data["flags"]); ConsoleDisplayList dispList = new ConsoleDisplayList(); dispList.AddRow("Region Name", r.RegionName); dispList.AddRow("Region ID", r.RegionID); dispList.AddRow("Location", string.Format("{0},{1}", r.coordX, r.coordY)); dispList.AddRow("URI", r.Data["serverURI"]); dispList.AddRow("Owner ID", r.Data["owner_uuid"]); dispList.AddRow("Flags", flags); MainConsole.Instance.Output(dispList.ToString()); }
private void OutputRegionsToConsoleSummary(List <RegionData> regions) { ConsoleDisplayTable dispTable = new ConsoleDisplayTable(); dispTable.AddColumn("Name", 16); dispTable.AddColumn("ID", 36); dispTable.AddColumn("Position", 11); dispTable.AddColumn("Owner ID", 36); dispTable.AddColumn("Flags", 60); foreach (RegionData r in regions) { OpenSim.Data.RegionFlags flags = (OpenSim.Data.RegionFlags)Convert.ToInt32(r.Data["flags"]); dispTable.AddRow( r.RegionName, r.RegionID.ToString(), string.Format("{0},{1}", r.coordX, r.coordY), r.Data["owner_uuid"].ToString(), flags.ToString()); } MainConsole.Instance.Output(dispTable.ToString()); }
private int ParseFlags(int prev, string flags) { OpenSim.Data.RegionFlags f = (OpenSim.Data.RegionFlags)prev; string[] parts = flags.Split(new char[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries); foreach (string p in parts) { int val; try { if (p.StartsWith("+")) { val = (int)Enum.Parse(typeof(OpenSim.Data.RegionFlags), p.Substring(1)); f |= (OpenSim.Data.RegionFlags)val; } else if (p.StartsWith("-")) { val = (int)Enum.Parse(typeof(OpenSim.Data.RegionFlags), p.Substring(1)); f &= ~(OpenSim.Data.RegionFlags)val; } else { val = (int)Enum.Parse(typeof(OpenSim.Data.RegionFlags), p); f |= (OpenSim.Data.RegionFlags)val; } } catch (Exception) { MainConsole.Instance.Output("Error in flag specification: " + p); } } return((int)f); }
public bool TryUnlinkRegion(string mapName) { m_log.DebugFormat("[HYPERGRID LINKER]: Request to unlink {0}", mapName); GridRegion regInfo = null; List <RegionData> regions = m_Database.Get(mapName, m_ScopeID); if (regions != null && regions.Count > 0) { OpenSim.Data.RegionFlags rflags = (OpenSim.Data.RegionFlags)Convert.ToInt32(regions[0].Data["flags"]); if ((rflags & OpenSim.Data.RegionFlags.Hyperlink) != 0) { regInfo = new GridRegion(); regInfo.RegionID = regions[0].RegionID; regInfo.ScopeID = m_ScopeID; } } //foreach (GridRegion r in m_HyperlinkRegions.Values) //{ // m_log.DebugFormat("XXX Comparing {0}:{1} with {2}:{3}", host, port, r.ExternalHostName, r.HttpPort); // if (host.Equals(r.ExternalHostName) && (port == r.HttpPort)) // regInfo = r; //} if (regInfo != null) { RemoveHyperlinkRegion(regInfo.RegionID); return(true); } else { m_log.InfoFormat("[HYPERGRID LINKER]: Region {0} not found", mapName); return(false); } }
public string RegisterRegion(UUID scopeID, GridRegion regionInfos) { IConfig gridConfig = m_config.Configs["GridService"]; // This needs better sanity testing. What if regionInfo is registering in // overlapping coords? RegionData region = m_Database.Get(regionInfos.RegionLocX, regionInfos.RegionLocY, scopeID); if (region != null) { // There is a preexisting record // // Get it's flags // OpenSim.Data.RegionFlags rflags = (OpenSim.Data.RegionFlags)Convert.ToInt32(region.Data["flags"]); // Is this a reservation? // if ((rflags & OpenSim.Data.RegionFlags.Reservation) != 0) { // Regions reserved for the null key cannot be taken. if ((string)region.Data["PrincipalID"] == UUID.Zero.ToString()) { return("Region location is reserved"); } // Treat it as an auth request // // NOTE: Fudging the flags value here, so these flags // should not be used elsewhere. Don't optimize // this with the later retrieval of the same flags! rflags |= OpenSim.Data.RegionFlags.Authenticate; } if ((rflags & OpenSim.Data.RegionFlags.Authenticate) != 0) { // Can we authenticate at all? // if (m_AuthenticationService == null) { return("No authentication possible"); } if (!m_AuthenticationService.Verify(new UUID(region.Data["PrincipalID"].ToString()), regionInfos.Token, 30)) { return("Bad authentication"); } } } if ((region != null) && (region.RegionID != regionInfos.RegionID)) { m_log.WarnFormat("[GRID SERVICE]: Region {0} tried to register in coordinates {1}, {2} which are already in use in scope {3}.", regionInfos.RegionID, regionInfos.RegionLocX, regionInfos.RegionLocY, scopeID); return("Region overlaps another region"); } if ((region != null) && (region.RegionID == regionInfos.RegionID) && ((region.posX != regionInfos.RegionLocX) || (region.posY != regionInfos.RegionLocY))) { if ((Convert.ToInt32(region.Data["flags"]) & (int)OpenSim.Data.RegionFlags.NoMove) != 0) { return("Can't move this region"); } // Region reregistering in other coordinates. Delete the old entry m_log.DebugFormat("[GRID SERVICE]: Region {0} ({1}) was previously registered at {2}-{3}. Deleting old entry.", regionInfos.RegionName, regionInfos.RegionID, regionInfos.RegionLocX, regionInfos.RegionLocY); try { m_Database.Delete(regionInfos.RegionID); } catch (Exception e) { m_log.DebugFormat("[GRID SERVICE]: Database exception: {0}", e); } } if (!m_AllowDuplicateNames) { List <RegionData> dupe = m_Database.Get(regionInfos.RegionName, scopeID); if (dupe != null && dupe.Count > 0) { foreach (RegionData d in dupe) { if (d.RegionID != regionInfos.RegionID) { m_log.WarnFormat("[GRID SERVICE]: Region {0} tried to register duplicate name with ID {1}.", regionInfos.RegionName, regionInfos.RegionID); return("Duplicate region name"); } } } } // Everything is ok, let's register RegionData rdata = RegionInfo2RegionData(regionInfos); rdata.ScopeID = scopeID; if (region != null) { int oldFlags = Convert.ToInt32(region.Data["flags"]); if ((oldFlags & (int)OpenSim.Data.RegionFlags.LockedOut) != 0) { return("Region locked out"); } oldFlags &= ~(int)OpenSim.Data.RegionFlags.Reservation; rdata.Data["flags"] = oldFlags.ToString(); // Preserve flags } else { rdata.Data["flags"] = "0"; if ((gridConfig != null) && rdata.RegionName != string.Empty) { int newFlags = 0; string regionName = rdata.RegionName.Trim().Replace(' ', '_'); newFlags = ParseFlags(newFlags, gridConfig.GetString("DefaultRegionFlags", String.Empty)); newFlags = ParseFlags(newFlags, gridConfig.GetString("Region_" + regionName, String.Empty)); newFlags = ParseFlags(newFlags, gridConfig.GetString("Region_" + rdata.RegionID.ToString(), String.Empty)); rdata.Data["flags"] = newFlags.ToString(); } } int flags = Convert.ToInt32(rdata.Data["flags"]); flags |= (int)OpenSim.Data.RegionFlags.RegionOnline; rdata.Data["flags"] = flags.ToString(); try { rdata.Data["last_seen"] = Util.UnixTimeSinceEpoch(); m_Database.Store(rdata); } catch (Exception e) { m_log.DebugFormat("[GRID SERVICE]: Database exception: {0}", e); } m_log.DebugFormat("[GRID SERVICE]: Region {0} ({1}) registered successfully at {2}-{3}", regionInfos.RegionName, regionInfos.RegionID, regionInfos.RegionLocX, regionInfos.RegionLocY); return(String.Empty); }