public void Initialise(IConfigSource config) { IConfig friendsConfig = config.Configs["Friends"]; if (friendsConfig != null) { int mPort = friendsConfig.GetInt("Port", 0); string connector = friendsConfig.GetString("Connector", String.Empty); Object[] args = new Object[] { config }; m_FriendsService = ServerUtils.LoadPlugin <IFriendsService>(connector, args); m_FriendsSimConnector = new FriendsSimConnector(); // Instantiate the request handler IHttpServer server = MainServer.GetHttpServer((uint)mPort); server.AddStreamHandler(new FriendsRequestHandler(this)); } if (m_FriendsService == null) { m_log.Error("[FRIENDS]: No Connector defined in section Friends, or failed to load, cannot continue"); throw new Exception("Connector load error"); } }
public UserAgentService(IConfigSource config, IFriendsSimConnector friendsConnector) { // Let's set this always, because we don't know the sequence // of instantiations if (friendsConnector != null) { m_FriendsLocalSimConnector = friendsConnector; } if (!m_Initialized) { m_Initialized = true; m_log.DebugFormat("[HOME USERS SECURITY]: Starting..."); m_FriendsSimConnector = new FriendsSimConnector(); IConfig serverConfig = config.Configs["UserAgentService"]; if (serverConfig == null) { throw new Exception(String.Format("No section UserAgentService in config file")); } string gridService = serverConfig.GetString("GridService", String.Empty); string gridUserService = serverConfig.GetString("GridUserService", String.Empty); string gatekeeperService = serverConfig.GetString("GatekeeperService", String.Empty); string friendsService = serverConfig.GetString("FriendsService", String.Empty); string presenceService = serverConfig.GetString("PresenceService", String.Empty); string userAccountService = serverConfig.GetString("UserAccountService", String.Empty); m_BypassClientVerification = serverConfig.GetBoolean("BypassClientVerification", false); if (gridService == string.Empty || gridUserService == string.Empty || gatekeeperService == string.Empty) { throw new Exception(String.Format("Incomplete specifications, UserAgent Service cannot function.")); } Object[] args = new Object[] { config }; m_GridService = ServerUtils.LoadPlugin <IGridService>(gridService, args); m_GridUserService = ServerUtils.LoadPlugin <IGridUserService>(gridUserService, args); m_GatekeeperConnector = new GatekeeperServiceConnector(); m_GatekeeperService = ServerUtils.LoadPlugin <IGatekeeperService>(gatekeeperService, args); m_FriendsService = ServerUtils.LoadPlugin <IFriendsService>(friendsService, args); m_PresenceService = ServerUtils.LoadPlugin <IPresenceService>(presenceService, args); m_UserAccountService = ServerUtils.LoadPlugin <IUserAccountService>(userAccountService, args); m_GridName = serverConfig.GetString("ExternalName", string.Empty); if (m_GridName == string.Empty) { serverConfig = config.Configs["GatekeeperService"]; m_GridName = serverConfig.GetString("ExternalName", string.Empty); } if (!m_GridName.EndsWith("/")) { m_GridName = m_GridName + "/"; } } }
public HGFriendsService(IConfigSource config, String configName, IFriendsSimConnector localSimConn) { if (m_FriendsLocalSimConnector == null) { m_FriendsLocalSimConnector = localSimConn; } if (!m_Initialized) { m_Initialized = true; if (configName != String.Empty) { m_ConfigName = configName; } Object[] args = new Object[] { config }; IConfig serverConfig = config.Configs[m_ConfigName]; if (serverConfig == null) { throw new Exception(String.Format("No section {0} in config file", m_ConfigName)); } string theService = serverConfig.GetString("FriendsService", string.Empty); if (theService == String.Empty) { throw new Exception("No FriendsService in config file " + m_ConfigName); } m_FriendsService = ServerUtils.LoadPlugin <IFriendsService>(theService, args); theService = serverConfig.GetString("UserAccountService", string.Empty); if (theService == String.Empty) { throw new Exception("No UserAccountService in " + m_ConfigName); } m_UserAccountService = ServerUtils.LoadPlugin <IUserAccountService>(theService, args); theService = serverConfig.GetString("GridService", string.Empty); if (theService == String.Empty) { throw new Exception("No GridService in " + m_ConfigName); } m_GridService = ServerUtils.LoadPlugin <IGridService>(theService, args); theService = serverConfig.GetString("PresenceService", string.Empty); if (theService == String.Empty) { throw new Exception("No PresenceService in " + m_ConfigName); } m_PresenceService = ServerUtils.LoadPlugin <IPresenceService>(theService, args); m_FriendsSimConnector = new FriendsSimConnector(); m_log.DebugFormat("[HGFRIENDS SERVICE]: Starting..."); } }
public UserAgentService(IConfigSource config, IFriendsSimConnector friendsConnector) : base(config) { // Let's set this always, because we don't know the sequence // of instantiations if (friendsConnector != null) { m_FriendsLocalSimConnector = friendsConnector; } if (!m_Initialized) { m_Initialized = true; m_log.DebugFormat("[HOME USERS SECURITY]: Starting..."); m_FriendsSimConnector = new FriendsSimConnector(); IConfig serverConfig = config.Configs["UserAgentService"]; if (serverConfig == null) { throw new Exception(String.Format("No section UserAgentService in config file")); } string gridService = serverConfig.GetString("GridService", String.Empty); string gridUserService = serverConfig.GetString("GridUserService", String.Empty); string gatekeeperService = serverConfig.GetString("GatekeeperService", String.Empty); string friendsService = serverConfig.GetString("FriendsService", String.Empty); string presenceService = serverConfig.GetString("PresenceService", String.Empty); string userAccountService = serverConfig.GetString("UserAccountService", String.Empty); m_BypassClientVerification = serverConfig.GetBoolean("BypassClientVerification", false); if (gridService == string.Empty || gridUserService == string.Empty || gatekeeperService == string.Empty) { throw new Exception(String.Format("Incomplete specifications, UserAgent Service cannot function.")); } Object[] args = new Object[] { config }; m_GridService = ServerUtils.LoadPlugin <IGridService>(gridService, args); m_GridUserService = ServerUtils.LoadPlugin <IGridUserService>(gridUserService, args); m_GatekeeperConnector = new GatekeeperServiceConnector(); m_GatekeeperService = ServerUtils.LoadPlugin <IGatekeeperService>(gatekeeperService, args); m_FriendsService = ServerUtils.LoadPlugin <IFriendsService>(friendsService, args); m_PresenceService = ServerUtils.LoadPlugin <IPresenceService>(presenceService, args); m_UserAccountService = ServerUtils.LoadPlugin <IUserAccountService>(userAccountService, args); m_LevelOutsideContacts = serverConfig.GetInt("LevelOutsideContacts", 0); m_ShowDetails = serverConfig.GetBoolean("ShowUserDetailsInHGProfile", true); LoadTripPermissionsFromConfig(serverConfig, "ForeignTripsAllowed"); LoadDomainExceptionsFromConfig(serverConfig, "AllowExcept", m_TripsAllowedExceptions); LoadDomainExceptionsFromConfig(serverConfig, "DisallowExcept", m_TripsDisallowedExceptions); m_GridName = Util.GetConfigVarFromSections <string>(config, "GatekeeperURI", new string[] { "Startup", "Hypergrid", "UserAgentService" }, String.Empty); if (string.IsNullOrEmpty(m_GridName)) // Legacy. Remove soon. { m_GridName = serverConfig.GetString("ExternalName", string.Empty); if (m_GridName == string.Empty) { serverConfig = config.Configs["GatekeeperService"]; m_GridName = serverConfig.GetString("ExternalName", string.Empty); } } if (!string.IsNullOrEmpty(m_GridName)) { m_GridName = m_GridName.ToLowerInvariant(); if (!m_GridName.EndsWith("/")) { m_GridName = m_GridName + "/"; } Uri gateURI; if (!Uri.TryCreate(m_GridName, UriKind.Absolute, out gateURI)) { throw new Exception(String.Format("[UserAgentService] could not parse gatekeeper uri")); } string host = gateURI.DnsSafeHost; IPAddress ip = Util.GetHostFromDNS(host); if (ip == null) { throw new Exception(String.Format("[UserAgentService] failed to resolve gatekeeper host")); } m_MyExternalIP = ip.ToString(); } // Finally some cleanup m_Database.DeleteOld(); } }