public GridRegion GetRegionByURI(UUID scopeID, RegionURI uri) { GridRegion rinfo = m_LocalGridService.GetRegionByURI(scopeID, uri); if (rinfo != null) { m_RegionInfoCache.Cache(scopeID, rinfo); return(rinfo); } if (m_RemoteGridService == null || !uri.IsLocalGrid) { return(rinfo); } if (uri.HasRegionName) { rinfo = m_RemoteGridService.GetRegionByName(scopeID, uri.RegionName); } else { rinfo = m_RemoteGridService.GetDefaultRegions(UUID.Zero)[0]; if (rinfo == null) { m_log.Warn("[REMOTE GRID CONNECTOR] returned null default region"); } else { m_log.WarnFormat("[REMOTE GRID CONNECTOR] returned default region {0}", rinfo.RegionName); } } m_RegionInfoCache.Cache(scopeID, rinfo); return(rinfo); }
public GridRegion GetRegionByName(UUID scopeID, string name) { GridRegion rinfo = m_LocalGridService.GetRegionByName(scopeID, name); if (rinfo != null) { return(rinfo); } // HG urls should not get here, strip them // side effect is that local regions with same name as HG may also be found // this mb good or bad string regionName = name; if (name.Contains(".")) { if (string.IsNullOrWhiteSpace(m_ThisGatekeeperIP)) { return(rinfo); // no HG } string regionURI = ""; string regionHost = ""; if (!Util.buildHGRegionURI(name, out regionURI, out regionHost, out regionName)) { return(rinfo); // invalid } if (!m_ThisGatekeeperHost.Equals(regionHost, StringComparison.InvariantCultureIgnoreCase) && !m_ThisGatekeeperIP.Equals(regionHost) && !m_ThisGateKeeperAlias.Contains(regionHost.ToLower())) { return(rinfo); // not local grid } } if (String.IsNullOrEmpty(regionName)) { rinfo = m_RemoteGridService.GetDefaultRegions(UUID.Zero)[0]; if (rinfo == null) { m_log.Warn("[REMOTE GRID CONNECTOR] returned null default region"); } else { m_log.WarnFormat("[REMOTE GRID CONNECTOR] returned default region {0}", rinfo.RegionName); } } else { rinfo = m_RemoteGridService.GetRegionByName(scopeID, regionName); } m_RegionInfoCache.Cache(scopeID, rinfo); return(rinfo); }
public GridRegion GetRegionByName(UUID scopeID, string name) { GridRegion rinfo = m_LocalGridService.GetRegionByName(scopeID, name); if (rinfo != null) { return(rinfo); } // HG urls should not get here, strip them // side effect is that local regions with same name as HG may also be found // this mb good or bad string regionName = name; if (name.Contains(".")) { if (!m_ThisGridInfo.HasHGConfig) { return(rinfo); // no HG } string regionURI = ""; if (!Util.buildHGRegionURI(name, out regionURI, out regionName)) { return(rinfo); // invalid } if (m_ThisGridInfo.IsLocalGrid(regionURI) != 1) { return(rinfo); // not local grid } } if (String.IsNullOrEmpty(regionName)) { rinfo = m_RemoteGridService.GetDefaultRegions(UUID.Zero)[0]; if (rinfo == null) { m_log.Warn("[REMOTE GRID CONNECTOR] returned null default region"); } else { m_log.WarnFormat("[REMOTE GRID CONNECTOR] returned default region {0}", rinfo.RegionName); } } else { rinfo = m_RemoteGridService.GetRegionByName(scopeID, regionName); } m_RegionInfoCache.Cache(scopeID, rinfo); return(rinfo); }
public GridRegion GetHomeRegion(UUID userID, out Vector3 position, out Vector3 lookAt) { position = new Vector3(128, 128, 0); lookAt = Vector3.UnitY; m_log.DebugFormat("[USER AGENT SERVICE]: Request to get home region of user {0}", userID); GridRegion home = null; GridUserInfo uinfo = m_GridUserService.GetGridUserInfo(userID.ToString()); if (uinfo != null) { if (uinfo.HomeRegionID != UUID.Zero) { home = m_GridService.GetRegionByUUID(UUID.Zero, uinfo.HomeRegionID); position = uinfo.HomePosition; lookAt = uinfo.HomeLookAt; } if (home == null) { List <GridRegion> defs = m_GridService.GetDefaultRegions(UUID.Zero); if (defs != null && defs.Count > 0) { home = defs[0]; } } } return(home); }
public bool LinkRegion(string regionName, out UUID regionID, out ulong regionHandle, out string externalName, out string imageURL, out string reason) { regionID = UUID.Zero; regionHandle = 0; externalName = m_ExternalName + ((regionName != string.Empty) ? " " + regionName : ""); imageURL = string.Empty; reason = string.Empty; GridRegion region = null; m_log.DebugFormat("[GATEKEEPER SERVICE]: Request to link to {0}", (regionName == string.Empty)? "default region" : regionName); if (!m_AllowTeleportsToAnyRegion || regionName == string.Empty) { List <GridRegion> defs = m_GridService.GetDefaultRegions(m_ScopeID); if (defs != null && defs.Count > 0) { region = defs[0]; m_DefaultGatewayRegion = region; } else { reason = "Grid setup problem. Try specifying a particular region here."; m_log.DebugFormat("[GATEKEEPER SERVICE]: Unable to send information. Please specify a default region for this grid!"); return(false); } } else { region = m_GridService.GetRegionByName(m_ScopeID, regionName); if (region == null) { reason = "Region not found"; return(false); } } regionID = region.RegionID; regionHandle = region.RegionHandle; string regionimage = "regionImage" + regionID.ToString(); regionimage = regionimage.Replace("-", ""); imageURL = region.ServerURI + "index.php?method=" + regionimage; return(true); }
public GridRegion GetRegionByName(UUID scopeID, string name) { GridRegion rinfo = m_LocalGridService.GetRegionByName(scopeID, name); if (rinfo != null) { return(rinfo); } // HG urls should not get here, strip them // side effect is that local regions with same name as HG may also be found // this mb good or bad string regionName = name; if (name.Contains(".")) { if (string.IsNullOrWhiteSpace(m_ThisGatekeeperIP)) { return(rinfo); // no HG } string regionURI = ""; string regionHost = ""; if (!Util.buildHGRegionURI(name, out regionURI, out regionHost, out regionName)) { return(rinfo); // invalid } if (!m_ThisGatekeeperHost.Equals(regionHost, StringComparison.InvariantCultureIgnoreCase) && !m_ThisGatekeeperIP.Equals(regionHost)) { return(rinfo); // not local grid } if (String.IsNullOrEmpty(regionName)) { return(m_RemoteGridService.GetDefaultRegions(scopeID)[0]); } } rinfo = m_RemoteGridService.GetRegionByName(scopeID, regionName); m_RegionInfoCache.Cache(scopeID, rinfo); return(rinfo); }
private byte[] GetDefaultRegions(Dictionary <string, object> request) { //MainConsole.Instance.DebugFormat("[GRID HANDLER]: GetDefaultRegions"); UUID scopeID = UUID.Zero; if (request.ContainsKey("SCOPEID")) { UUID.TryParse(request["SCOPEID"].ToString(), out scopeID); } else { MainConsole.Instance.WarnFormat("[GRID HANDLER]: no scopeID in request to get region range"); } List <GridRegion> rinfos = m_GridService.GetDefaultRegions(scopeID); rinfos = CleanRegions(rinfos); Dictionary <string, object> result = new Dictionary <string, object>(); if ((rinfos == null) || ((rinfos != null) && (rinfos.Count == 0))) { result["result"] = "null"; } else { int i = 0; #if (!ISWIN) foreach (GridRegion rinfo in rinfos) { Dictionary <string, object> rinfoDict = rinfo.ToKVP(); result["region" + i] = rinfoDict; i++; } #else foreach (Dictionary <string, object> rinfoDict in rinfos.Select(rinfo => rinfo.ToKVP())) { result["region" + i] = rinfoDict; i++; } #endif } string xmlString = WebUtils.BuildXmlResponse(result); //MainConsole.Instance.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString); UTF8Encoding encoding = new UTF8Encoding(); return(encoding.GetBytes(xmlString)); }
private GridRegion FindDefaultRegion() { GridRegion region = null; if (m_defaultRegion != "")//This overrides all { region = m_GridService.GetRegionByName(null, m_defaultRegion); if (region != null) { m_foundDefaultRegion = true; return(region); } } List <GridRegion> defs = m_GridService.GetDefaultRegions(null); if (defs != null && defs.Count > 0) { region = FindRegion(defs); } if (region == null) { defs = m_GridService.GetFallbackRegions(null, 0, 0); if (defs != null && defs.Count > 0) { region = FindRegion(defs); } if (region == null) { defs = m_GridService.GetSafeRegions(null, 0, 0); if (defs != null && defs.Count > 0) { region = FindRegion(defs); } if (region == null) { MainConsole.Instance.WarnFormat("[GATEKEEPER SERVICE]: Please specify a default region for this grid!"); } } } if (region != null) { m_foundDefaultRegion = true; } return(region); }
public List <GridRegion> GetDefaultRegions(UUID scopeID) { List <GridRegion> rinfo = m_LocalGridService.GetDefaultRegions(scopeID); //m_log.DebugFormat("[REMOTE GRID CONNECTOR]: Local GetDefaultRegions {0} found {1} regions", name, rinfo.Count); List <GridRegion> grinfo = m_RemoteGridService.GetDefaultRegions(scopeID); if (grinfo != null) { //m_log.DebugFormat("[REMOTE GRID CONNECTOR]: Remote GetDefaultRegions {0} found {1} regions", name, grinfo.Count); foreach (GridRegion r in grinfo) { if (rinfo.Find(delegate(GridRegion gr) { return(gr.RegionID == r.RegionID); }) == null) { rinfo.Add(r); } } } return(rinfo); }
byte[] GetDefaultRegions(Dictionary <string, object> request) { //m_log.DebugFormat("[GRID HANDLER]: GetDefaultRegions"); UUID scopeID = UUID.Zero; if (request.ContainsKey("SCOPEID")) { UUID.TryParse(request["SCOPEID"].ToString(), out scopeID); } else { m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get region range"); } List <GridRegion> rinfos = m_GridService.GetDefaultRegions(scopeID); Dictionary <string, object> result = new Dictionary <string, object>(); if ((rinfos == null) || ((rinfos != null) && (rinfos.Count == 0))) { result["result"] = "null"; } else { int i = 0; foreach (GridRegion rinfo in rinfos) { Dictionary <string, object> rinfoDict = rinfo.ToKeyValuePairs(); result["region" + i] = rinfoDict; i++; } } string xmlString = ServerUtils.BuildXmlResponse(result); //m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString); UTF8Encoding encoding = new UTF8Encoding(); return(encoding.GetBytes(xmlString)); }
protected GridRegion FindDestination( UserAccount account, UUID scopeID, GridUserInfo pinfo, UUID sessionID, string startLocation, GridRegion home, out GridRegion gatekeeper, out string where, out Vector3 position, out Vector3 lookAt, out TeleportFlags flags) { flags = TeleportFlags.ViaLogin; m_log.DebugFormat( "[LLOGIN SERVICE]: Finding destination matching start location {0} for {1}", startLocation, account.Name); gatekeeper = null; where = "home"; position = new Vector3(128, 128, 0); lookAt = new Vector3(0, 1, 0); if (m_GridService == null) { return(null); } if (startLocation.Equals("home")) { // logging into home region if (pinfo == null) { return(null); } GridRegion region = null; bool tryDefaults = false; if (home == null) { tryDefaults = true; } else { region = home; position = pinfo.HomePosition; lookAt = pinfo.HomeLookAt; flags |= TeleportFlags.ViaHome; } if (tryDefaults) { List <GridRegion> defaults = m_GridService.GetDefaultRegions(scopeID); if (defaults != null && defaults.Count > 0) { region = defaults[0]; where = "safe"; } else { m_log.WarnFormat("[LLOGIN SERVICE]: User {0} {1} does not have a valid home and this grid does not have default locations. Attempting to find random region", account.FirstName, account.LastName); region = FindAlternativeRegion(scopeID); if (region != null) { where = "safe"; } } } return(region); } else if (startLocation.Equals("last")) { // logging into last visited region where = "last"; if (pinfo == null) { return(null); } GridRegion region = null; if (pinfo.LastRegionID.Equals(UUID.Zero) || (region = m_GridService.GetRegionByUUID(scopeID, pinfo.LastRegionID)) == null) { List <GridRegion> defaults = m_GridService.GetDefaultRegions(scopeID); if (defaults != null && defaults.Count > 0) { region = defaults[0]; where = "safe"; } else { m_log.Info("[LLOGIN SERVICE]: Last Region Not Found Attempting to find random region"); region = FindAlternativeRegion(scopeID); if (region != null) { where = "safe"; } } } else { position = pinfo.LastPosition; lookAt = pinfo.LastLookAt; } return(region); } else { flags |= TeleportFlags.ViaRegionID; // free uri form // e.g. New Moon&135&46 New [email protected]:8002&153&34 where = "url"; GridRegion region = null; Regex reURI = new Regex(@"^uri:(?<region>[^&]+)&(?<x>\d+)&(?<y>\d+)&(?<z>\d+)$"); Match uriMatch = reURI.Match(startLocation); if (uriMatch == null) { m_log.InfoFormat("[LLLOGIN SERVICE]: Got Custom Login URI {0}, but can't process it", startLocation); return(null); } else { position = new Vector3(float.Parse(uriMatch.Groups["x"].Value, Culture.NumberFormatInfo), float.Parse(uriMatch.Groups["y"].Value, Culture.NumberFormatInfo), float.Parse(uriMatch.Groups["z"].Value, Culture.NumberFormatInfo)); string regionName = uriMatch.Groups["region"].ToString(); if (regionName != null) { if (!regionName.Contains("@")) { List <GridRegion> regions = m_GridService.GetRegionsByName(scopeID, regionName, 1); if ((regions == null) || (regions != null && regions.Count == 0)) { m_log.InfoFormat("[LLLOGIN SERVICE]: Got Custom Login URI {0}, can't locate region {1}. Trying defaults.", startLocation, regionName); regions = m_GridService.GetDefaultRegions(scopeID); if (regions != null && regions.Count > 0) { where = "safe"; return(regions[0]); } else { m_log.Info("[LLOGIN SERVICE]: Last Region Not Found Attempting to find random region"); region = FindAlternativeRegion(scopeID); if (region != null) { where = "safe"; return(region); } else { m_log.InfoFormat("[LLLOGIN SERVICE]: Got Custom Login URI {0}, Grid does not provide default regions and no alternative found.", startLocation); return(null); } } } return(regions[0]); } else { if (m_UserAgentService == null) { m_log.WarnFormat("[LLLOGIN SERVICE]: This llogin service is not running a user agent service, as such it can't lauch agents at foreign grids"); return(null); } string[] parts = regionName.Split(new char[] { '@' }); if (parts.Length < 2) { m_log.InfoFormat("[LLLOGIN SERVICE]: Got Custom Login URI {0}, can't locate region {1}", startLocation, regionName); return(null); } // Valid specification of a remote grid regionName = parts[0]; string domainLocator = parts[1]; parts = domainLocator.Split(new char[] { ':' }); string domainName = parts[0]; uint port = 0; if (parts.Length > 1) { UInt32.TryParse(parts[1], out port); } region = FindForeignRegion(domainName, port, regionName, account, out gatekeeper); return(region); } } else { List <GridRegion> defaults = m_GridService.GetDefaultRegions(scopeID); if (defaults != null && defaults.Count > 0) { where = "safe"; return(defaults[0]); } else { return(null); } } } //response.LookAt = "[r0,r1,r0]"; //// can be: last, home, safe, url //response.StartLocation = "url"; } }
/// <summary> /// Create a user /// </summary> /// <param name="scopeID">Allows hosting of multiple grids in a single database. Normally left as UUID.Zero</param> /// <param name="principalID">ID of the user</param> /// <param name="firstName"></param> /// <param name="lastName"></param> /// <param name="password"></param> /// <param name="email"></param> public UserAccount CreateUser(UUID scopeID, UUID principalID, string firstName, string lastName, string password, string email) { UserAccount account = GetUserAccount(UUID.Zero, firstName, lastName); if (null == account) { account = new UserAccount(UUID.Zero, principalID, firstName, lastName, email); if (account.ServiceURLs == null || (account.ServiceURLs != null && account.ServiceURLs.Count == 0)) { account.ServiceURLs = new Dictionary <string, object>(); account.ServiceURLs["HomeURI"] = string.Empty; account.ServiceURLs["InventoryServerURI"] = string.Empty; account.ServiceURLs["AssetServerURI"] = string.Empty; } if (StoreUserAccount(account)) { bool success; if (m_AuthenticationService != null) { success = m_AuthenticationService.SetPassword(account.PrincipalID, password); if (!success) { m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to set password for account {0} {1}.", firstName, lastName); } } GridRegion home = null; if (m_GridService != null) { List <GridRegion> defaultRegions = m_GridService.GetDefaultRegions(UUID.Zero); if (defaultRegions != null && defaultRegions.Count >= 1) { home = defaultRegions[0]; } if (m_GridUserService != null && home != null) { m_GridUserService.SetHome(account.PrincipalID.ToString(), home.RegionID, new Vector3(128, 128, 0), new Vector3(0, 1, 0)); } else { m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to set home for account {0} {1}.", firstName, lastName); } } else { m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to retrieve home region for account {0} {1}.", firstName, lastName); } if (m_InventoryService != null) { success = m_InventoryService.CreateUserInventory(account.PrincipalID); if (!success) { m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to create inventory for account {0} {1}.", firstName, lastName); } else { m_log.DebugFormat( "[USER ACCOUNT SERVICE]: Created user inventory for {0} {1}", firstName, lastName); } if (m_CreateDefaultAvatarEntries) { CreateDefaultAppearanceEntries(account.PrincipalID); } } m_log.InfoFormat( "[USER ACCOUNT SERVICE]: Account {0} {1} {2} created successfully", firstName, lastName, account.PrincipalID); } else { m_log.ErrorFormat("[USER ACCOUNT SERVICE]: Account creation failed for account {0} {1}", firstName, lastName); } } else { m_log.ErrorFormat("[USER ACCOUNT SERVICE]: A user with the name {0} {1} already exists!", firstName, lastName); } return(account); }
public List <GridRegion> GetDefaultRegions(UUID scopeID) { return(m_GridService.GetDefaultRegions(scopeID)); }