Exemplo n.º 1
0
        private static void Main(string[] args)
        {
            Console.Title = "Fabiano Swagger of Doom - World Server";
            try
            {
                XmlConfigurator.ConfigureAndWatch(new FileInfo("log4net_wServer.config"));

                Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
                Thread.CurrentThread.Name           = "Entry";

                Settings = new Settings("wServer");
                using (var db = new Database(
                           Settings.GetValue <string>("db_host", "127.0.0.1"),
                           Settings.GetValue <int>("db_port", "6379"),
                           Settings.GetValue <string>("db_auth", "")))
                {
                    manager = new RealmManager(
                        Settings.GetValue <int>("maxClients", "100"),
                        Settings.GetValue <int>("tps", "20"),
                        db);

                    WhiteList        = Settings.GetValue <bool>("whiteList", "false");
                    Verify           = Settings.GetValue <bool>("verifyEmail", "false");
                    WhiteListTurnOff = Settings.GetValue <DateTime>("whitelistTurnOff");

                    manager.Initialize();
                    manager.Run();

                    Server       server = new Server(manager);
                    PolicyServer policy = new PolicyServer();

                    Console.CancelKeyPress += (sender, e) => e.Cancel = true;

                    policy.Start();
                    server.Start();
                    log.Info("Server initialized.");

                    while (Console.ReadKey(true).Key != ConsoleKey.Escape)
                    {
                        ;
                    }

                    log.Info("Terminating...");
                    server.Stop();
                    policy.Stop();
                    manager.Stop();
                    log.Info("Server terminated.");
                }
            }
            catch (Exception e)
            {
                log.Fatal(e);

                foreach (var c in manager.Clients)
                {
                    c.Value.Disconnect();
                }
                Console.ReadLine();
            }
        }
Exemplo n.º 2
0
        public override bool ProcessRequestAsync(IRequest request, ICallback callback)
        {
            var url = request.Url;

            Task.Run(() =>
            {
                using (callback)
                {
                    var raw = Download(url);

                    if (raw.Length >= 3 && "CWS" == Encoding.ASCII.GetString(raw.Take(3).ToArray()))
                    {
                        var policyPort = 843;
                        var infoPort   = Rand.om(49152, 65535);
                        var info       = ProductConfiguration.InfoWebSocketUrl;
                        var compileSwf = DefacingAbc.EditHost(raw, infoPort);
                        var cws        = Converter.ToCws(compileSwf);

                        PolicyServer.Start(policyPort);
                        PiggInfoProxy.Start(info, infoPort);

                        var stream     = new MemoryStream(cws);
                        ResponseLength = stream.Length;
                        StatusCode     = (int)HttpStatusCode.OK;
                        Stream         = stream;

                        callback.Continue();
                    }
                }
            });

            return(true);
        }
Exemplo n.º 3
0
        private static void Main(string[] args)
        {
            Console.Title = "Loading...";

            XmlConfigurator.ConfigureAndWatch(new FileInfo("_gameserver.config"));

            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
            Thread.CurrentThread.Name           = "Entry";

            using (var db = new Database())
            {
                Usage = -1;

                manager = new RealmManager(db);

                autoRestart = Settings.NETWORKING.RESTART.ENABLE_RESTART;

                manager.Initialize();
                manager.Run();

                Server       server = new Server(manager);
                PolicyServer policy = new PolicyServer();

                Console.CancelKeyPress += (sender, e) => e.Cancel = true;

                policy.Start();
                server.Start();

                if (autoRestart)
                {
                    chat   = manager.Chat;
                    uptime = DateTime.Now;
                    restart();
                    usage();
                }

                Console.Title = Settings.GAMESERVER.TITLE;

                Logger.Info("Server initialized.");

                Console.CancelKeyPress += delegate
                {
                    Shutdown?.Set();
                };

                while (Console.ReadKey(true).Key != ConsoleKey.Escape)
                {
                    ;
                }

                Logger.Info("Terminating...");
                server?.Stop();
                policy?.Stop();
                manager?.Stop();
                Shutdown?.Dispose();
                Logger.Info("Server terminated.");
                Environment.Exit(0);
            }
        }
Exemplo n.º 4
0
        private static void Main(string[] args)
        {
            Console.Title = "Zy's Realm - World Server";
            try
            {
                Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
                Thread.CurrentThread.Name           = "Entry";

                Settings = new SimpleSettings("wServer");
                new Database(
                    Settings.GetValue <string>("db_host", "127.0.0.1"),
                    Settings.GetValue <string>("db_database", "rotmgprod"),
                    Settings.GetValue <string>("db_user", "root"),
                    Settings.GetValue <string>("db_auth", ""));

                manager = new RealmManager(
                    Settings.GetValue <int>("maxClients", "100"),
                    Settings.GetValue <int>("tps", "20"));

                WhiteList = Settings.GetValue <bool>("whiteList", "false");
                DebugMode = Settings.GetValue <bool>("debugMode", "false");

                manager.Initialize();
                manager.Run();

                Server       server = new Server(manager);
                PolicyServer policy = new PolicyServer();

                Console.CancelKeyPress += (sender, e) => e.Cancel = true;

                policy.Start();
                server.Start();
                if (Settings.GetValue <bool>("broadcastNews", "false") && File.Exists("news.txt"))
                {
                    new Thread(autoBroadcastNews).Start();
                }
                Console.WriteLine("Server initialized.");


                if (isStopped())
                {
                    Console.WriteLine("Terminating...");
                    server.Stop();
                    policy.Stop();
                    manager.Stop();
                    Console.WriteLine("Server terminated.");
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);

                foreach (var c in manager.Clients)
                {
                    c.Value.Disconnect(Client.DisconnectReason.STOPPING_SERVER);
                }
                Console.ReadLine();
            }
        }
Exemplo n.º 5
0
        private static void InitiatePolicy()
        {
            var policyServer = new PolicyServer();

            ServerManager.Create(policyServer);

            Out.WriteLog("Policy-Server created successfully!", LogKeys.INFO);
        }
Exemplo n.º 6
0
 private void MainForm_Load(object sender, EventArgs e)
 {
     _usageControl.Maximum        = 10;
     _usageHistoryControl.Maximum = 10;
     _policyServer             = new PolicyServer("clientaccesspolicy.xml");
     _policyServer.Connect    += new ConnectHandler(_policyServer_Connect);
     _policyServer.Disconnect += new DisconnectHandler(_policyServer_Disconnect);
     _timer.Enabled            = true;
 }
Exemplo n.º 7
0
        static void Main(string[] args)
        {
            AppDomain.CurrentDomain.UnhandledException += LogUnhandledException;

            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
            Thread.CurrentThread.Name           = "Entry";

            Config = args.Length > 0 ?
                     ServerConfig.ReadFile(args[0]) :
                     ServerConfig.ReadFile("wServer.json");

            Environment.SetEnvironmentVariable("ServerLogFolder", Config.serverSettings.logFolder);
            GlobalContext.Properties["ServerName"] = Config.serverInfo.name;
            GlobalContext.Properties["ServerType"] = Config.serverInfo.type.ToString();

            XmlConfigurator.ConfigureAndWatch(new FileInfo(Config.serverSettings.log4netConfig));

            using (Resources = new Resources(Config.serverSettings.resourceFolder, true))
                using (var db = new Database(
                           Config.dbInfo.host,
                           Config.dbInfo.port,
                           Config.dbInfo.auth,
                           Config.dbInfo.index,
                           Resources))
                {
                    var manager = new RealmManager(Resources, db, Config);
                    manager.Run();

                    var policy = new PolicyServer();
                    policy.Start();

                    var server = new Server(manager,
                                            Config.serverInfo.port,
                                            Config.serverSettings.maxConnections,
                                            StringUtils.StringToByteArray(Config.serverSettings.key));

                    server.Start();

                    Console.CancelKeyPress += delegate
                    {
                        Shutdown.Set();
                    };

                    Shutdown.WaitOne();

                    Log.Info("Terminating...");
                    manager.Stop();
                    server.Stop();
                    policy.Stop();
                    Log.Info("Server terminated.");
                }
        }
        public MainWindow()
        {
            InitializeComponent();

            logListBox.Margin = new Thickness(10);
            MainGrid.Children.Add(logListBox);

            // start policy server
            var ps = new PolicyServer("clientaccesspolicy.xml", _logListBox);

            // start server
            StartServer();
        }
Exemplo n.º 9
0
        /// <summary>
        /// </summary>
        /// <param name="sender">
        /// </param>
        /// <param name="e">
        /// </param>
        protected void Application_Start(object sender, EventArgs e)
        {
            var            policyServer  = new PolicyServer("clientaccesspolicy.xml");
            IMessageServer messageServer = new MessageServer(
                IPAddress.Any,
                4530,
                new JsonMessageSerializer(new List <Type>()
            {
                typeof(WeatherMessage), typeof(SubscribeMessage)
            }));

            ThreadPool.QueueUserWorkItem((o) => { policyServer.Start(); });
            ThreadPool.QueueUserWorkItem((o) => { messageServer.Start(); });

            var weatherService = new WeatherService(messageServer);
        }
Exemplo n.º 10
0
        static void Main(string[] args)
        {
            AppDomain.CurrentDomain.UnhandledException += LogUnhandledException;
            Thread.CurrentThread.CurrentCulture         = CultureInfo.InvariantCulture;
            Thread.CurrentThread.Name = "Entry";

            Config = args.Length > 0 ?
                     ServerConfig.ReadFile(args[0]) :
                     ServerConfig.ReadFile("wServer.json");

            LogManager.Configuration.Variables["logDirectory"] = Config.serverSettings.logFolder + "/wServer";
            LogManager.Configuration.Variables["buildConfig"]  = Utils.GetBuildConfiguration();

            using (Resources = new Resources(Config.serverSettings.resourceFolder, true))
                using (Database = new Database(Resources, Config))
                {
                    Config.serverInfo.instanceId = Guid.NewGuid().ToString();

                    var marketSweeper = new MarketSweeper(Database);
                    marketSweeper.Run();

                    var manager = new RealmManager(Resources, Database, Config);
                    manager.Run();

                    var policy = new PolicyServer();
                    policy.Start();

                    var server = new Server(manager,
                                            Config.serverInfo.port,
                                            Config.serverSettings.maxConnections,
                                            StringUtils.StringToByteArray(Config.serverSettings.key));
                    server.Start();

                    Console.CancelKeyPress += delegate
                    {
                        Shutdown.Set();
                    };

                    Shutdown.WaitOne();
                    Log.Info("Terminating...");
                    manager.Stop();
                    server.Stop();
                    policy.Stop();
                    Log.Info("Server terminated.");
                }
        }
Exemplo n.º 11
0
        static void Main(string[] args)
        {
            Console.Title       = "Stable World Server";
            Console.WindowWidth = 110;
            XmlConfigurator.ConfigureAndWatch(new FileInfo("log4net.config"));

            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
            Thread.CurrentThread.Name           = "Entry";

            using (Settings = new SimpleSettings("wServer"))
                using (var db = new Database(
                           Settings.GetValue <string>("db_host", "127.0.0.1"),
                           Settings.GetValue <int>("db_port", "6379"),
                           Settings.GetValue <string>("db_auth", "")))
                {
                    RealmManager manager = new RealmManager(
                        Settings.GetValue <int>("maxClient", "100"),
                        Settings.GetValue <int>("tps", "20"),
                        db);

                    manager.Initialize();
                    manager.Run();

                    Server       server = new Server(manager, 2050);
                    PolicyServer policy = new PolicyServer();

                    Console.CancelKeyPress += (sender, e) => e.Cancel = true;

                    policy.Start();
                    server.Start();
                    log.Info("Server initialized.");

                    while (Console.ReadKey(true).Key != ConsoleKey.Escape)
                    {
                        ;
                    }

                    log.Info("Terminating...");
                    server.Stop();
                    policy.Stop();
                    manager.Stop();
                    db.Dispose();
                    log.Info("Server terminated.");
                }
        }
Exemplo n.º 12
0
 /// <summary>
 /// This method supports the infrastructure and is not intended to be used directly from your code.
 /// </summary>
 public void Stop()
 {
     lock (SyncRoot) {
         if (_messageBroker != null)
         {
             if (log.IsInfoEnabled)
             {
                 log.Info(__Res.GetString(__Res.MessageServer_Stop));
             }
             _messageBroker.Stop();
             _messageBroker = null;
             if (_policyServer != null)
             {
                 _policyServer.Close();
                 _policyServer = null;
             }
         }
     }
 }
Exemplo n.º 13
0
        private static void Main(string[] args)
        {
            XmlConfigurator.ConfigureAndWatch(new FileInfo("log4net.config"));

            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
            Thread.CurrentThread.Name           = "Entry";

            Settings = new SimpleSettings("wServer");

            Database.Init(Settings.GetValue <string>("db_host", "nillysrealm.com"),
                          Settings.GetValue <string>("db_port", "3306"),
                          Settings.GetValue <string>("db_name", "rotmg"),
                          Settings.GetValue <string>("db_user", ""),
                          Settings.GetValue <string>("db_pass", "botmaker"));

            var manager = new RealmManager();

            manager.Initialize();
            manager.Run();

            var server = new Server(Settings.GetValue <int>("port", "2050"));
            var policy = new PolicyServer();

            policy.Start();
            server.Start();
            log.Info("Server initialized.");

            Console.CancelKeyPress += delegate
            {
                log.Info("Terminating...");
                server.Stop();
                policy.Stop();
                //Settings.Dispose();
                log.Info("Server terminated.");
                Thread.Sleep(500);
                Environment.Exit(0);
            };

            while (true)
            {
                Thread.Sleep(500);
            }
        }
Exemplo n.º 14
0
        public static void Initialize(IGameLogger logger, string connectionString, string database,
                                      IPEndPoint gameServerConfiguration, IPEndPoint policyServerConfiguration,
                                      IPEndPoint chatServerConfiguration)
        {
            lock (_lock) {
                if (_initialized || !(_initialized = true))
                {
                    return;
                }

                _logger = logger ?? throw new ArgumentNullException(nameof(logger));

                _database      = new DatabaseContext(connectionString, database);
                _lookupBuilder = new NettyLookupBuilder();
                _gameServer    = new GameServer(gameServerConfiguration);
                _policyServer  = new PolicyServer(policyServerConfiguration);
                _chatServer    = new ChatServer(chatServerConfiguration);
            }
        }
Exemplo n.º 15
0
        private static void Main(string[] args)
        {
            XmlConfigurator.ConfigureAndWatch(new FileInfo("log4net_wServer.config"));

            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
            Thread.CurrentThread.Name           = "Entry";

            using (Settings = new SimpleSettings("wServer"))
            {
                new Database(
                    Settings.GetValue("dbHost", "127.0.0.1"),
                    Settings.GetValue("dbName", "fluffyadventure"),
                    Settings.GetValue("dbUser", "root"),
                    Settings.GetValue("dbPassword", ""));
                RealmManager manager = new RealmManager(
                    Settings.GetValue <int>("maxClient", "100"),
                    Settings.GetValue <int>("tps", "20"));

                manager.Initialize();
                manager.Run();

                Server       server = new Server(manager, 2050);
                PolicyServer policy = new PolicyServer();

                Console.CancelKeyPress += (sender, e) => e.Cancel = true;

                policy.Start();
                server.Start();
                log.Info("Server initialized.");

                while (Console.ReadKey(true).Key != ConsoleKey.Escape)
                {
                    ;
                }

                log.Info("Terminating...");
                server.Stop();
                policy.Stop();
                manager.Stop();
                log.Info("Server terminated.");
            }
        }
Exemplo n.º 16
0
        protected void Application_Start(object sender, EventArgs e)
        {
            //===========================================================================
            // Setup logging.
            //===========================================================================
            Lionsguard.Log.LogFilePath    = Server.MapPath("/Logs");
            Lionsguard.Log.WriteLogEntry += new LogWriteEventHandler(Log_WriteLogEntry);

            Logger.LogMessage += Logger_LogMessage;

            //===========================================================================
            // Setup world event handlers.
            //===========================================================================
            Game.Server.World.PlayerAdvanced     += new PlayerAdvancedEventHandler(World_PlayerAdvanced);
            Game.Server.World.AvatarKilledAvatar += new AvatarKilledAvatarEventHandler(World_AvatarKilledAvatar);

            //===========================================================================
            // Start the policy server.
            //===========================================================================
            var policyEndPoint = new IPEndPoint(IPAddress.Any, 943);

            _policyServer                  = new PolicyServer(Encoding.UTF8.GetBytes(Depot.ClientAccessPolicyData), policyEndPoint);
            _policyServer.Error           += new NetworkExceptionEventHandler(_policyServer_Error);
            _policyServer.RequestReceived += new PolicyRequestReceivedEventHandler(_policyServer_RequestReceived);
            _policyServer.Start();

            Logger.LogInformation("Policy Server Started on {0}", policyEndPoint);

            //===========================================================================
            // Start the game socket server.
            //===========================================================================
            var gameEndPoint = new IPEndPoint(IPAddress.Any, 4530);

            _socketServer = new SocketServer(gameEndPoint);
            _socketServer.Start();

            Logger.LogInformation("Game Server Started on {0}", gameEndPoint);


            _serverThread.Name = "MainGameThread";
            _serverThread.Start();
        }
Exemplo n.º 17
0
        private static void Main(string[] args)
        {
            Console.Title = "Phoenix Realms: Reborn - World Server";

            XmlConfigurator.ConfigureAndWatch(new FileInfo("log4net.config"));

            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
            Thread.CurrentThread.Name           = "Entry";

            using (Settings = new SimpleSettings("wServer"))
            {
                var db      = new Database(Settings.GetValue("conn"));
                var manager = new RealmManager(
                    Settings.GetValue <int>("maxClient", "100"),
                    Settings.GetValue <int>("tps", "10"),
                    db);

                manager.Initialize();
                manager.Run();

                var server = new Server(manager, 2050);
                var policy = new PolicyServer();

                Console.CancelKeyPress += (sender, e) => e.Cancel = true;

                policy.Start();
                server.Start();
                log.Info("Server initialized.");

                while (Console.ReadKey(true).Key != ConsoleKey.Escape)
                {
                    ;
                }

                log.Info("Terminating...");
                server.Stop();
                policy.Stop();
                manager.Stop();
                db.Dispose();
                log.Info("Server terminated.");
            }
        }
Exemplo n.º 18
0
        //This is set here, just in case the client SOMEHOW manages to connect before the Settings.Value is set. Which is impossible, but it's whatever.

        private static void Main(string[] args)
        {
            XmlConfigurator.ConfigureAndWatch(new FileInfo("log4net.config"));

            System.Timers.Timer timer = new System.Timers.Timer(65 * 60 * 1000);
            timer.Elapsed += AutoRestart;

            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
            Thread.CurrentThread.Name           = "Entry";

            using (Settings = new SimpleSettings("wServer"))
            {
                serverDatabaseConnString = Settings.GetValue("conn"); //Ugh, this should do good. :]
                serverTPS        = Settings.GetValue <int>("tps", "5");
                serverMaxClients = Settings.GetValue <int>("maxClient", "100");

                manager = new RealmManager(serverMaxClients, serverTPS);

                manager.Initialize();
                manager.Run();

                var server = new Server(manager, 2050);
                var policy = new PolicyServer();


                Console.CancelKeyPress += (sender, e) => e.Cancel = true;

                policy.Start();
                server.Start();
                log.Info("Server initialized.");
                timer.Start();

                while (((uint)Console.ReadKey(true).Key) != (uint)ConsoleKey.Escape)
                {
                    log.Info("Terminating...");
                    server.Stop();
                    policy.Stop();
                    manager.Stop();
                    log.Info("Server terminated.");
                }
            }
        }
Exemplo n.º 19
0
        public Program()
        {
            "started".Trace();
            GameServer.Database db = (GameServer.Database)_XmlSerializer.Deserialize(File.Open(Settings._Maps, FileMode.Open));
            List<GameServer.Server> svrs = new List<GameServer.Server>();
            foreach(Task task in db._tasks)
            {
                GameServer.Server _Server = new GameServer.Server();
                _Server._Task = task;
                _Server.StartAsync();
                svrs.Add(_Server);
            }

            PolicyServer ps = new PolicyServer { policyFile = "Server/PolicyFile.xml" };
            ps.StartAsync();

            WebServer.WebServer _WebServer = new WebServer.WebServer();
            _WebServer.StartAsync();
            Thread.Sleep(-1);
        }
Exemplo n.º 20
0
 public void Stop()
 {
     if (this._messageBroker != null)
     {
         if (log.get_IsInfoEnabled())
         {
             log.Info(__Res.GetString("MessageServer_Stop"));
         }
         if (this._messageBroker != null)
         {
             this._messageBroker.Stop();
             this._messageBroker = null;
         }
         if (this._policyServer != null)
         {
             this._policyServer.Close();
             this._policyServer = null;
         }
     }
 }
Exemplo n.º 21
0
        protected override void OnClosed(EventArgs e)
        {
            timer.Stop();

            if (SocketProxy != null)
            {
                SocketProxy.Stop();
            }

            if (WebProxy != null)
            {
                WebProxy.Stop();
            }

            if (PolicyServer != null)
            {
                PolicyServer.Stop();
            }

            base.OnClosed(e);
        }
Exemplo n.º 22
0
        public Program()
        {
            "started".Trace();
            GameServer.Database      db   = (GameServer.Database)_XmlSerializer.Deserialize(File.Open(Settings._Maps, FileMode.Open));
            List <GameServer.Server> svrs = new List <GameServer.Server>();

            foreach (Task task in db._tasks)
            {
                GameServer.Server _Server = new GameServer.Server();
                _Server._Task = task;
                _Server.StartAsync();
                svrs.Add(_Server);
            }

            PolicyServer ps = new PolicyServer {
                policyFile = "Server/PolicyFile.xml"
            };

            ps.StartAsync();

            WebServer.WebServer _WebServer = new WebServer.WebServer();
            _WebServer.StartAsync();
            Thread.Sleep(-1);
        }
Exemplo n.º 23
0
        public void Init(string configPath, bool serviceBrowserAvailable)
        {
            Type type;

            this._messageBroker         = new FluorineFx.Messaging.MessageBroker(this);
            this._serviceConfigSettings = FluorineFx.Messaging.Config.ServiceConfigSettings.Load(configPath, "services-config.xml");
            foreach (ChannelSettings settings in this._serviceConfigSettings.ChannelsSettings)
            {
                type = ObjectFactory.Locate(settings.Class);
                if (type != null)
                {
                    IEndpoint endpoint = ObjectFactory.CreateInstance(type, new object[] { this._messageBroker, settings }) as IEndpoint;
                    if (endpoint != null)
                    {
                        this._messageBroker.AddEndpoint(endpoint);
                    }
                }
                else
                {
                    log.Error(__Res.GetString("Type_InitError", new object[] { settings.Class }));
                }
                ChannelSettings channelSettings = new ChannelSettings("__@fluorinertmpt", null);
                IEndpoint       endpoint2       = new RtmptEndpoint(this._messageBroker, channelSettings);
                this._messageBroker.AddEndpoint(endpoint2);
            }
            foreach (FactorySettings settings3 in this._serviceConfigSettings.FactoriesSettings)
            {
                type = ObjectFactory.Locate(settings3.ClassId);
                if (type != null)
                {
                    IFlexFactory factory = ObjectFactory.CreateInstance(type, new object[0]) as IFlexFactory;
                    if (factory != null)
                    {
                        this._messageBroker.AddFactory(settings3.Id, factory);
                    }
                }
                else
                {
                    log.Error(__Res.GetString("Type_InitError", new object[] { settings3.ClassId }));
                }
            }
            this._messageBroker.AddFactory("dotnet", new DotNetFactory());
            if (serviceBrowserAvailable && (this._serviceConfigSettings.ServiceSettings["remoting-service"] != null))
            {
                ServiceSettings serviceSettings = this._serviceConfigSettings.ServiceSettings["remoting-service"];
                AdapterSettings adapterSettings = this._serviceConfigSettings.ServiceSettings["remoting-service"].AdapterSettings["dotnet"];
                this.InstallServiceBrowserDestinations(serviceSettings, adapterSettings);
            }
            foreach (ServiceSettings settings6 in this._serviceConfigSettings.ServiceSettings)
            {
                type = ObjectFactory.Locate(settings6.Class);
                if (type != null)
                {
                    IService service = ObjectFactory.CreateInstance(type, new object[] { this._messageBroker, settings6 }) as IService;
                    if (service != null)
                    {
                        this._messageBroker.AddService(service);
                    }
                }
                else
                {
                    log.Error(__Res.GetString("Type_InitError", new object[] { settings6.Class }));
                }
            }
            if ((this._serviceConfigSettings.SecuritySettings != null) && ((this._serviceConfigSettings.SecuritySettings.LoginCommands != null) && (this._serviceConfigSettings.SecuritySettings.LoginCommands.Count > 0)))
            {
                string loginCommand = this._serviceConfigSettings.SecuritySettings.LoginCommands.GetLoginCommand("asp.net");
                type = ObjectFactory.Locate(loginCommand);
                if (type != null)
                {
                    ILoginCommand command = ObjectFactory.CreateInstance(type, new object[0]) as ILoginCommand;
                    this._messageBroker.LoginCommand = command;
                }
                else
                {
                    log.Error(__Res.GetString("Type_InitError", new object[] { loginCommand }));
                }
            }
            this.InitAuthenticationService();
            try
            {
                if ((FluorineConfiguration.Instance.FluorineSettings.Silverlight.PolicyServerSettings != null) && FluorineConfiguration.Instance.FluorineSettings.Silverlight.PolicyServerSettings.Enable)
                {
                    IResource resource = FluorineContext.Current.GetResource(FluorineConfiguration.Instance.FluorineSettings.Silverlight.PolicyServerSettings.PolicyFile);
                    if (!resource.Exists)
                    {
                        throw new FileNotFoundException("Policy file not found", FluorineConfiguration.Instance.FluorineSettings.Silverlight.PolicyServerSettings.PolicyFile);
                    }
                    log.Info(__Res.GetString("Silverlight_StartPS", new object[] { resource.File.FullName }));
                    this._policyServer = new PolicyServer(resource.File.FullName);
                }
            }
            catch (Exception exception)
            {
                log.Error(__Res.GetString("Silverlight_PSError"), exception);
            }
        }
Exemplo n.º 24
0
        private void Initialize()
        {
            AppendLog("RotMG Tool initializing...");

            try
            {
                Settings = new SimpleSettings();
                string packetFile = Path.Combine(Program.RootDirectory, "packets.dat");
                if (File.Exists(packetFile))
                {
                    PacketTable = PacketTable.Load(File.ReadAllText(packetFile));
                }
                AppendLog("Settings loaded.");
            }
            catch (Exception ex)
            {
                AppendLog("Error when loading settings: " + ex.Message);
                return;
            }

            //new System.Threading.Thread(DoCheckUpdate) { IsBackground = true }.Start();

            AppendLog("Retrieving server list...");
            var doc =
                XDocument.Load("http://realmofthemadgodhrd.appspot.com/char/list?guid=" +
                               Guid.NewGuid().ToString().Replace("-", "").ToUpper());
            byte id = 1;

            Servers = doc.XPathSelectElements("//Server").Select(srv => new RemoteServer
            {
                Name     = srv.Element("Name").Value,
                DNS      = srv.Element("DNS").Value,
                Loopback = new IPAddress(new byte[] { 127, 0, 0, id++ })
            }).ToArray();
            AppendLog("Server list retrieved, total {0} servers.", Servers.Length);


            if (!InitializeComponent("Spam Filter", () =>
            {
                Filter = new SpamFilter(this);
                Filter.LoadWordList();
            }))
            {
                return;
            }

            if (!InitializeComponent("Handlers", () =>
            {
                Commands = new CommandManager();
                Hooks = new HookManager();
                Invoke(new Action(() => Windows = new WindowManager(this, windowDropDown)));
            }))
            {
                return;
            }

            AppendLog("If you see any firewall warning, allow this program to pass!");

            if (!InitializeComponent("Web Proxy", () =>
            {
                WebProxy = new HttpProxy(this);
                WebProxy.Start();
                BeginInvoke(new Action(() => { proxyLink.Text = new Uri(WebProxy.ProxyUrl).AbsoluteUri; }));
            }))
            {
                return;
            }

            if (!InitializeComponent("Socket Proxy", () =>
            {
                SocketProxy = new SocketProxy(this);
                SocketProxy.Start();
            }))
            {
                return;
            }

            if (!InitializeComponent("Policy Server", () =>
            {
                PolicyServer = new PolicyServer();
                if (!PolicyServer.Start())
                {
                    throw new Exception("Cannot start policy server! Try start as adminstrator/sudo!");
                }
            }))
            {
                return;
            }

            new HttpHandler(this).Attach();
            new SocketHandler(this).Attach();
            BeginInvoke(new Action(() => timer.Start()));

            AppendLog("RotMG Tool initialized.");
        }
Exemplo n.º 25
0
        private static void Main(string[] args)
        {
            Console.Title = "FSOD";
            try
            {
                XmlConfigurator.ConfigureAndWatch(new FileInfo("log4net_wServer.config"));

                Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
                Thread.CurrentThread.Name           = "Entry";

                Settings = new SimpleSettings("wServer");
                new Database(
                    Settings.GetValue <string>("db_host", "127.0.0.1"),
                    Settings.GetValue <string>("db_database", "rotmgprod"),
                    Settings.GetValue <string>("db_user", "root"),
                    Settings.GetValue <string>("db_auth", ""));

                manager = new RealmManager(
                    Settings.GetValue <int>("maxClients", "100"),
                    Settings.GetValue <int>("tps", "20"));

                WhiteList        = Settings.GetValue <bool>("whiteList", "false");
                Verify           = Settings.GetValue <bool>("verifyEmail", "false");
                WhiteListTurnOff = Settings.GetValue <DateTime>("whitelistTurnOff");

                manager.Initialize();
                manager.Run();

                Server       server = new Server(manager);
                PolicyServer policy = new PolicyServer();

                Console.CancelKeyPress += (sender, e) => e.Cancel = true;

                policy.Start();
                server.Start();
                if (Settings.GetValue <bool>("broadcastNews", "false") && File.Exists("news.txt"))
                {
                    new Thread(autoBroadcastNews).Start();
                }
                log.Info("Server initialized.");

                foreach (var type in typeof(World).Assembly.GetTypes())
                {
                    if (type.IsAbstract || !typeof(World).IsAssignableFrom(type))
                    {
                        continue;
                    }
                    if (type.GetConstructors().First().GetParameters().Length > 0)
                    {
                        continue;
                    }
                    var world = (World)type.Assembly.CreateInstance(type.FullName);
                    if (world == null)
                    {
                        log.Warn($"Cant make World {type.Name}");
                    }
                    if (world?.Difficulty == -1)
                    {
                        log.Warn($"World {type.Name} has the default difficulty (-1)");
                    }
                    world?.Dispose();
                }

                uint key = 0;
                while ((key = (uint)Console.ReadKey(true).Key) != (uint)ConsoleKey.Escape)
                {
                    if (key == (2 | 80))
                    {
                        Settings.Reload();
                    }
                }

                log.Info("Terminating...");
                server.Stop();
                policy.Stop();
                manager.Stop();
                log.Info("Server terminated.");
            }
            catch (Exception e)
            {
                log.Fatal(e);

                foreach (var c in manager.Clients)
                {
                    c.Value.Disconnect();
                }
                Console.ReadLine();
            }
        }
Exemplo n.º 26
0
        private static void Main(string[] args)
        {
            Console.Title = "Loading...";

            XmlConfigurator.ConfigureAndWatch(new FileInfo("_gameserver.config"));

            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
            Thread.CurrentThread.Name           = "Entry";

            if (!Directory.Exists(LootCachePath))
            {
                Directory.CreateDirectory(LootCachePath);
            }
            if (!Directory.Exists(MonsterCachePath))
            {
                Directory.CreateDirectory(MonsterCachePath);
            }
            if (!Directory.Exists(TaskCachePath))
            {
                Directory.CreateDirectory(TaskCachePath);
            }
            if (!Directory.Exists(AchievementCachePath))
            {
                Directory.CreateDirectory(AchievementCachePath);
            }

            try
            {
                var db = new Database();
                GameUsage = -1;

                Manager = new RealmManager(db);

                AutoRestart = Settings.NETWORKING.RESTART.ENABLE_RESTART;

                Manager.Initialize();
                Manager.Run();

                var policy = new PolicyServer();
                var server = new Server();

                Console.CancelKeyPress += (sender, e) => e.Cancel = true;

                policy.Start();
                server.Start();

                if (AutoRestart)
                {
                    Chat   = Manager.Chat;
                    Uptime = DateTime.Now;
                    Restart();
                }

                Console.Title = Settings.GAMESERVER.TITLE;

                Console.CancelKeyPress += delegate
                {
                    Shutdown?.Set();
                };

                while (Console.ReadKey(true).Key != ConsoleKey.Escape)
                {
                    ;
                }

                Log.Info("Terminating...");

                policy?.Stop();
                server?.Stop();
                Manager?.Stop();
                Manager?.Database.Dispose();
                Shutdown?.Dispose();

                Log.Warn("Terminated GameServer.");

                Thread.Sleep(1000);

                Environment.Exit(0);
            }
            catch (Exception e) { ForceShutdown(e); }
        }
Exemplo n.º 27
0
        private static void Main(string[] args)
        {
            Console.Title = "Loading...";

            XmlConfigurator.ConfigureAndWatch(new FileInfo("_gameserver.config"));

            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
            Thread.CurrentThread.Name           = "Entry";

            using (var db = new Database())
            {
                GameUsage = -1;

                Manager = new RealmManager(db);

                AutoRestart = Settings.NETWORKING.RESTART.ENABLE_RESTART;

                Manager.Initialize();
                Manager.Run();

                Log._("Message", Message.Messages.Count);

                Server server = new Server(Manager);

                PolicyServer policy = new PolicyServer();

                Console.CancelKeyPress += (sender, e) => e.Cancel = true;

                Settings.DISPLAY_SUPPORTED_VERSIONS();

                Log.Info("Initializing GameServer...");

                policy.Start();
                server.Start();

                if (AutoRestart)
                {
                    Chat   = Manager.Chat;
                    Uptime = DateTime.Now;
                    Restart();
                    Usage();
                }

                Console.Title = Settings.GAMESERVER.TITLE;

                Log.Info("Initializing GameServer... OK!");

                Console.CancelKeyPress += delegate
                {
                    Shutdown?.Set();
                };

                while (Console.ReadKey(true).Key != ConsoleKey.Escape)
                {
                    ;
                }

                Log.Info("Terminating...");

                server?.Stop();
                policy?.Stop();
                Manager?.Stop();
                Shutdown?.Dispose();

                Log.Warn("Terminated GameServer.");

                Thread.Sleep(1000);

                Environment.Exit(0);
            }
        }
Exemplo n.º 28
0
        /// <summary>
        /// This method supports the Fluorine infrastructure and is not intended to be used directly from your code.
        /// </summary>
        /// <param name="configFolderPaths">Possible configuration file locations.</param>
        /// <param name="serviceBrowserAvailable">Indicates whether the service browser is avaliable.</param>
        public void Init(string[] configFolderPaths, bool serviceBrowserAvailable)
        {
            _messageBroker = new MessageBroker(this);

            string servicesConfigFile = null;

            for (int i = 0; i < configFolderPaths.Length; i++)
            {
                servicesConfigFile = Path.Combine(configFolderPaths[i], "services-config.xml");
                if (log.IsDebugEnabled)
                {
                    log.Debug(__Res.GetString(__Res.MessageServer_TryingServiceConfig, servicesConfigFile));
                }
                if (File.Exists(servicesConfigFile))
                {
                    break;
                }
            }
            if (servicesConfigFile != null && File.Exists(servicesConfigFile))
            {
                if (log.IsDebugEnabled)
                {
                    log.Debug(__Res.GetString(__Res.MessageServer_LoadingServiceConfig, servicesConfigFile));
                }
                _servicesConfiguration = ServicesConfiguration.Load(servicesConfigFile);
            }
            else
            {
                if (log.IsDebugEnabled)
                {
                    log.Debug(__Res.GetString(__Res.MessageServer_LoadingConfigDefault));
                }
                _servicesConfiguration = ServicesConfiguration.CreateDefault();
            }

            foreach (ChannelDefinition channelDefinition in _servicesConfiguration.Channels)
            {
                Type type = ObjectFactory.Locate(FluorineConfiguration.Instance.ClassMappings.GetType(channelDefinition.Endpoint.Class));
                if (type != null)
                {
                    IEndpoint endpoint = ObjectFactory.CreateInstance(type, new object[] { _messageBroker, channelDefinition }) as IEndpoint;
                    if (endpoint != null)
                    {
                        _messageBroker.AddEndpoint(endpoint);
                    }
                }
                else
                {
                    log.Error(__Res.GetString(__Res.Type_InitError, channelDefinition.Class));
                }
            }
            ChannelDefinition rtmptChannelDefinition = new ChannelDefinition();

            rtmptChannelDefinition.Id = RtmptEndpoint.FluorineRtmptEndpointId;
            IEndpoint rtmptEndpoint = new RtmptEndpoint(_messageBroker, rtmptChannelDefinition);

            _messageBroker.AddEndpoint(rtmptEndpoint);

            if (_servicesConfiguration.Factories != null)
            {
                foreach (Factory factory in _servicesConfiguration.Factories)
                {
                    Type type = ObjectFactory.Locate(FluorineConfiguration.Instance.ClassMappings.GetType(factory.Class));
                    if (type != null)
                    {
                        IFlexFactory flexFactory = ObjectFactory.CreateInstance(type, new object[0]) as IFlexFactory;
                        if (flexFactory != null)
                        {
                            _messageBroker.AddFactory(factory.Id, flexFactory);
                        }
                    }
                    else
                    {
                        log.Error(__Res.GetString(__Res.Type_InitError, factory.Class));
                    }
                }
            }
            //Add the dotnet Factory
            _messageBroker.AddFactory(DotNetFactory.Id, new DotNetFactory());

            if (serviceBrowserAvailable)
            {
                ServiceDefinition serviceConfiguration = _servicesConfiguration.GetServiceByClass("flex.messaging.services.RemotingService");
                if (serviceConfiguration != null)
                {
                    AdapterDefinition adapter = serviceConfiguration.GetAdapterByClass(typeof(Remoting.RemotingAdapter).FullName);
                    if (adapter != null)
                    {
                        InstallServiceBrowserDestinations(serviceConfiguration, adapter);
                    }
                    else
                    {
                        adapter = serviceConfiguration.GetDefaultAdapter();
                        if (adapter != null)
                        {
                            InstallServiceBrowserDestinations(serviceConfiguration, adapter);
                        }
                    }
                }
            }
            if (_servicesConfiguration.Services.ServiceDefinitions != null)
            {
                foreach (ServiceDefinition serviceDefinition in _servicesConfiguration.Services.ServiceDefinitions)
                {
                    Type type = ObjectFactory.Locate(FluorineConfiguration.Instance.ClassMappings.GetType(serviceDefinition.Class));//current assembly only
                    if (type != null)
                    {
                        IService service = ObjectFactory.CreateInstance(type, new object[] { _messageBroker, serviceDefinition }) as IService;
                        if (service != null)
                        {
                            _messageBroker.AddService(service);
                        }
                    }
                    else
                    {
                        log.Error(__Res.GetString(__Res.Type_InitError, serviceDefinition.Class));
                    }
                }
            }
            if (_servicesConfiguration.Services.Includes != null)
            {
                foreach (ServiceInclude include in _servicesConfiguration.Services.Includes)
                {
                    ServiceDefinition serviceDefinition = include.ServiceDefinition;
                    Type type = ObjectFactory.Locate(FluorineConfiguration.Instance.ClassMappings.GetType(serviceDefinition.Class));//current assembly only
                    if (type != null)
                    {
                        IService service = ObjectFactory.CreateInstance(type, new object[] { _messageBroker, serviceDefinition }) as IService;
                        if (service != null)
                        {
                            _messageBroker.AddService(service);
                        }
                    }
                    else
                    {
                        log.Error(__Res.GetString(__Res.Type_InitError, serviceDefinition.Class));
                    }
                }
            }
            if (_servicesConfiguration.Security != null)
            {
                if (_servicesConfiguration.Security.LoginCommands != null && _servicesConfiguration.Security.LoginCommands.Length > 0)
                {
                    LoginCommand loginCommand = _servicesConfiguration.Security.GetLoginCommand(LoginCommand.FluorineLoginCommand);
                    if (loginCommand != null)
                    {
                        Type type = ObjectFactory.Locate(FluorineConfiguration.Instance.ClassMappings.GetType(loginCommand.Class));
                        if (type != null)
                        {
                            ILoginCommand loginCommandObj = ObjectFactory.CreateInstance(type, new object[] { }) as ILoginCommand;
                            _messageBroker.LoginManager.LoginCommand = loginCommandObj;
                            _messageBroker.LoginManager.IsPerClientAuthentication = loginCommand.IsPerClientAuthentication;
                        }
                        else
                        {
                            log.Error(__Res.GetString(__Res.Type_InitError, loginCommand.Class));
                        }
                    }
                    else
                    {
                        log.Error(__Res.GetString(__Res.Type_InitError, "<<LoginCommand class>>"));
                    }
                }
            }
            InitAuthenticationService();

            try
            {
                if (FluorineConfiguration.Instance.FluorineSettings.Silverlight.PolicyServerSettings != null &&
                    FluorineConfiguration.Instance.FluorineSettings.Silverlight.PolicyServerSettings.Enable)
                {
                    IResource resource;
                    if (FluorineContext.Current != null)
                    {
                        resource = FluorineContext.Current.GetResource(FluorineConfiguration.Instance.FluorineSettings.Silverlight.PolicyServerSettings.PolicyFile);
                    }
                    else
                    {
                        resource = new FileSystemResource(FluorineConfiguration.Instance.FluorineSettings.Silverlight.PolicyServerSettings.PolicyFile);
                    }
                    if (resource.Exists)
                    {
                        log.Info(__Res.GetString(__Res.Silverlight_StartPS, resource.File.FullName));
                        _policyServer = new PolicyServer(resource.File.FullName);
                    }
                    else
                    {
                        throw new FileNotFoundException("Policy file not found", FluorineConfiguration.Instance.FluorineSettings.Silverlight.PolicyServerSettings.PolicyFile);
                    }
                }
            }
            catch (Exception ex)
            {
                log.Error(__Res.GetString(__Res.Silverlight_PSError), ex);
            }
        }
Exemplo n.º 29
0
        private static void Main(string[] args)
        {
            Console.Title = "wServer";
            try
            {
                XmlConfigurator.ConfigureAndWatch(new FileInfo("log4net_wServer.config"));

                Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
                Thread.CurrentThread.Name           = "Entry";

                Settings = new SimpleSettings("wServer");
                new Database();

                manager = new RealmManager(
                    Settings.GetValue <int>("maxClients", "50"),
                    Settings.GetValue <int>("tps", "20"));

                WhiteList        = Settings.GetValue <bool>("whiteList", "false");
                Verify           = Settings.GetValue <bool>("verifyEmail", "false");
                WhiteListTurnOff = Settings.GetValue <DateTime>("whitelistTurnOff");

                manager.Initialize();
                manager.Run();

                Server       server = new Server(manager);
                PolicyServer policy = new PolicyServer();

                Console.CancelKeyPress += (sender, e) => e.Cancel = true;

                policy.Start();
                server.Start();
                new Thread(AutoNotify).Start();
                if (Settings.GetValue <bool>("broadcastNews", "false") && File.Exists("news.txt"))
                {
                    new Thread(autoBroadcastNews).Start();
                }
                log.Info("Server initialized.");

                uint key = 0;
                while ((key = (uint)Console.ReadKey(true).Key) != (uint)ConsoleKey.Escape)
                {
                    if (key == (2 | 80))
                    {
                        Settings.Reload();
                    }
                }

                log.Info("Terminating...");
                server.Stop();
                policy.Stop();
                manager.Stop();
                log.Info("Server terminated.");
            }
            catch (Exception e)
            {
                log.Fatal(e);

                foreach (var c in manager.Clients)
                {
                    c.Value.Disconnect();
                }
                Console.ReadLine();
            }
        }
Exemplo n.º 30
0
        private static void Main(string[] args)
        {
            Console.Title = "Rotux - World Server";
            try
            {
                Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
                Thread.CurrentThread.Name           = "Entry";

                Settings = new SimpleSettings("wServer");
                new Database(
                    Settings.GetValue <string>("db_host", "127.0.0.1"),
                    Settings.GetValue <string>("db_database", "rotmgprod"),
                    Settings.GetValue <string>("db_user", "root"),
                    Settings.GetValue <string>("db_auth", ""));

                manager = new RealmManager(
                    Settings.GetValue <int>("maxClients", "100"),
                    Settings.GetValue <int>("tps", "20"));

                WhiteList        = Settings.GetValue <bool>("whiteList", "false");
                Verify           = Settings.GetValue <bool>("verifyEmail", "false");
                WhiteListTurnOff = Settings.GetValue <DateTime>("whitelistTurnOff");

                manager.Initialize();
                manager.Run();

                Server       server = new Server(manager);
                PolicyServer policy = new PolicyServer();

                Console.CancelKeyPress += (sender, e) => e.Cancel = true;

                policy.Start();
                server.Start();
                if (Settings.GetValue <bool>("broadcastNews", "false") && File.Exists("news.txt"))
                {
                    new Thread(autoBroadcastNews).Start();
                }
                Console.WriteLine("Server initialized.");

                uint key = 0;
                while ((key = (uint)Console.ReadKey(true).Key) != (uint)ConsoleKey.Escape)
                {
                    if (key == (2 | 80))
                    {
                        Settings.Reload();
                    }
                }

                Console.WriteLine("Terminating...");
                server.Stop();
                policy.Stop();
                manager.Stop();
                Console.WriteLine("Server terminated.");
            }
            catch (Exception e)
            {
                Console.WriteLine(e);

                foreach (var c in manager.Clients)
                {
                    c.Value.Disconnect();
                }
                Console.ReadLine();
            }
        }