public ChatServer() { _packetLogger = new PacketLogger(); _logger = new Logger() { WriteToConsole = true }; _logger.Load(Path.Combine("logs", string.Format("chat_{0}.log", DateTime.Now.ToString("dd-MM-yyyy_HH-mm-ss")))); AppDomain.CurrentDomain.UnhandledException += (s, e) => { Error(s, new ExceptionEventArgs((Exception)e.ExceptionObject)); Environment.Exit(0); }; _packetLogger.Load("chat_packets.log"); _logger.Info("Loading chat_config.xml..."); ChatConfig.Load(); _logger.Info("Setting up servers..."); _server = new TcpServer(IPAddress.Parse(ChatConfig.Instance.IP), ChatConfig.Instance.Port); _server.PacketReceived += HandlePacket; _server.ClientDisconnected += ClientDisconnected; _server.Error += Error; var isMono = Type.GetType("Mono.Runtime") != null; switch (ChatConfig.Instance.AuthRemote.Binding) { case "pipe": if (isMono) { _logger.Error("pipe is not supported in mono, use http!"); Environment.Exit(1); return; } _authRemoteClient = new RemoteClient(ERemoteBinding.Pipe, string.Format("localhost/AuthServer/{0}/", SHA256.ComputeHash(ChatConfig.Instance.AuthRemote.Password))); break; case "tcp": if (isMono) { _logger.Error("pipe is not supported in mono, use http!"); Environment.Exit(1); return; } _authRemoteClient = new RemoteClient(ERemoteBinding.Pipe, string.Format("{0}:{1}/AuthServer/{2}/", ChatConfig.Instance.AuthRemote.Server, ChatConfig.Instance.AuthRemote.Port, SHA256.ComputeHash(ChatConfig.Instance.AuthRemote.Password))); break; case "http": _authRemoteClient = new RemoteClient(ERemoteBinding.Http, string.Format("{0}:{1}/AuthServer/{2}/", ChatConfig.Instance.AuthRemote.Server, ChatConfig.Instance.AuthRemote.Port, SHA256.ComputeHash(ChatConfig.Instance.AuthRemote.Password))); break; default: _logger.Error("Invalid remote binding '{0}' for AuthRemote", ChatConfig.Instance.AuthRemote.Binding); Environment.Exit(1); break; } }
public RelayServer() { _packetLogger = new PacketLogger(); _logger = new Logger() { WriteToConsole = true }; _logger.Load(Path.Combine("logs", string.Format("relay_{0}.log", DateTime.Now.ToString("dd-MM-yyyy_HH-mm-ss")))); AppDomain.CurrentDomain.UnhandledException += (s, e) => { Error(s, new ExceptionEventArgs((Exception)e.ExceptionObject)); Environment.Exit(0); }; _packetLogger.Load("relay_packets.log"); _logger.Info("Loading relay_config.xml..."); RelayConfig.Load(); _logger.Info("Setting up servers..."); _server = new TcpServer(IPAddress.Parse(RelayConfig.Instance.IP), RelayConfig.Instance.Port); _server.PacketReceived += HandlePacket; _server.ClientDisconnected += ClientDisconnected; _server.Error += Error; }
public AuthServer() { _packetLogger = new PacketLogger(); _logger = new Logger() { WriteToConsole = true }; _logger.Load(Path.Combine("logs", string.Format("auth_{0}.log", DateTime.Now.ToString("dd-MM-yyyy_HH-mm-ss")))); AppDomain.CurrentDomain.UnhandledException += (s, e) => { Error(s, new ExceptionEventArgs((Exception)e.ExceptionObject)); Environment.Exit(0); }; _packetLogger.Load("auth_packets.log"); _logger.Info("Loaded Packet Logger"); Stopwatch sw = Stopwatch.StartNew(); AuthConfig.Load(); sw.Stop(); _logger.Info("Loaded Auth Configuration in {0} ms", sw.Elapsed.TotalMilliseconds); _logger.Info("Starting up server connections..."); _server = new TcpServer(IPAddress.Parse(AuthConfig.Instance.IP), AuthConfig.Instance.Port); _server.PacketReceived += HandlePacket; _server.Error += Error; // // Initalize a list of ports // ushort[] ports = { 38915, 38917 }; for (uint i = 0; ports.Length > i; i++ ) { // Handle NAT tests before starting... switch (i) { case 0: _natServer = new UDPClient(ports[0]); _natServer.PacketReceived += HandleNATTest; _natServer.Error += Error; _logger.InfoAuth("NAT Test successful at Port {0}", ports[0]); break; case 1: _natServer2 = new UDPClient(ports[1]); _natServer2.PacketReceived += HandleNATTest2; _natServer2.Error += Error; _logger.InfoAuth("NAT Test successful at Port {0}", ports[1]); break; default: break; } } // Bind to pipe/tcp/http settings in configuration var isMono = Type.GetType("Mono.Runtime") != null; switch (AuthConfig.Instance.Remote.Binding) { case "pipe": if (isMono) { _logger.Error("pipe is not supported in mono, use http!"); Environment.Exit(1); return; } _remoteServer = new RemoteServer(this, ERemoteBinding.Pipe, string.Format("localhost/AuthServer/{0}/", SHA256.ComputeHash(AuthConfig.Instance.Remote.Password))); break; case "tcp": if (isMono) { _logger.Error("tcp is not supported in mono, use http!"); Environment.Exit(1); return; } _remoteServer = new RemoteServer(this, ERemoteBinding.Pipe, string.Format("{0}:{1}/AuthServer/{2}/", AuthConfig.Instance.Remote.Server, AuthConfig.Instance.Remote.Port, SHA256.ComputeHash(AuthConfig.Instance.Remote.Password))); break; case "http": _remoteServer = new RemoteServer(this, ERemoteBinding.Http, string.Format("{0}:{1}/AuthServer/{2}/", AuthConfig.Instance.Remote.Server, AuthConfig.Instance.Remote.Port, SHA256.ComputeHash(AuthConfig.Instance.Remote.Password))); break; default: _logger.Error("Invalid remote binding '{0}'", AuthConfig.Instance.Remote.Binding); Environment.Exit(1); return; } _remoteServer.AddServiceEndpoint(typeof(IAuthRemote), "IAuthRemote"); }
public GameServer() { Channels = new ChannelCollection(); Rooms = new RoomCollection(); Players = new PlayerCollection(); Logger = new Logger() { WriteToConsole = true }; _packetLogger = new PacketLogger(); Logger.Load(Path.Combine("logs", string.Format("game_{0}.log", DateTime.Now.ToString("dd-MM-yyyy_HH-mm-ss")))); AppDomain.CurrentDomain.UnhandledException += (s, e) => { Error(s, new ExceptionEventArgs((Exception)e.ExceptionObject)); Environment.Exit(0); }; _packetLogger.Load("game_packets.log"); Logger.Info("Loading game_config.xml..."); GameConfig.Load(); Logger.Info("Setting up servers..."); _server = new TcpServer(IPAddress.Parse(GameConfig.Instance.IP), GameConfig.Instance.Port); _server.PacketReceived += HandlePacket; _server.ClientDisconnected += ClientDisconnected; _server.Error += Error; var isMono = Type.GetType("Mono.Runtime") != null; switch (GameConfig.Instance.AuthRemote.Binding) { case "pipe": if (isMono) { Logger.Error("pipe is not supported in mono, use http!"); Environment.Exit(1); return; } _authRemoteClient = new RemoteClient(ERemoteBinding.Pipe, string.Format("localhost/AuthServer/{0}/", SHA256.ComputeHash(GameConfig.Instance.AuthRemote.Password))); break; case "tcp": if (isMono) { Logger.Error("pipe is not supported in mono, use http!"); Environment.Exit(1); return; } _authRemoteClient = new RemoteClient(ERemoteBinding.Pipe, string.Format("{0}:{1}/AuthServer/{2}/", GameConfig.Instance.AuthRemote.Server, GameConfig.Instance.AuthRemote.Port, SHA256.ComputeHash(GameConfig.Instance.AuthRemote.Password))); break; case "http": _authRemoteClient = new RemoteClient(ERemoteBinding.Http, string.Format("{0}:{1}/AuthServer/{2}/", GameConfig.Instance.AuthRemote.Server, GameConfig.Instance.AuthRemote.Port, SHA256.ComputeHash(GameConfig.Instance.AuthRemote.Password))); break; default: Logger.Error("Invalid remote binding '{0}' for AuthRemote", GameConfig.Instance.AuthRemote.Binding); Environment.Exit(1); break; } Logger.Info("Loading plugins... {0}",AppDomain.CurrentDomain.BaseDirectory); _pluginManager.Load(); foreach (var plugin in _pluginManager.Plugins) Logger.Info("Loaded {0}", plugin.Name); }
public AuthServer() { _packetLogger = new PacketLogger(); _logger = new Logger() { WriteToConsole = true }; _logger.Load(Path.Combine("logs", string.Format("auth_{0}.log", DateTime.Now.ToString("dd-MM-yyyy_HH-mm-ss")))); AppDomain.CurrentDomain.UnhandledException += (s, e) => { Error(s, new ExceptionEventArgs((Exception)e.ExceptionObject)); Environment.Exit(0); }; _packetLogger.Load("auth_packets.log"); _logger.Info("Loaded Packet Logger"); Stopwatch sw = Stopwatch.StartNew(); AuthConfig.Load(); sw.Stop(); _logger.Info("Loaded Auth Configuration in {0} ms", sw.Elapsed.TotalMilliseconds); _logger.Info("Starting up server connections..."); _server = new TcpServer(IPAddress.Parse(AuthConfig.Instance.IP), AuthConfig.Instance.Port); _server.PacketReceived += HandlePacket; _server.Error += Error; // // Initalize a list of ports // ushort[] ports = { 38915, 38917 }; for (uint i = 0; ports.Length > i; i++) { // Handle NAT tests before starting... switch (i) { case 0: _natServer = new UDPClient(ports[0]); _natServer.PacketReceived += HandleNATTest; _natServer.Error += Error; _logger.InfoAuth("NAT Test successful at Port {0}", ports[0]); break; case 1: _natServer2 = new UDPClient(ports[1]); _natServer2.PacketReceived += HandleNATTest2; _natServer2.Error += Error; _logger.InfoAuth("NAT Test successful at Port {0}", ports[1]); break; default: break; } } // Bind to pipe/tcp/http settings in configuration var isMono = Type.GetType("Mono.Runtime") != null; switch (AuthConfig.Instance.Remote.Binding) { case "pipe": if (isMono) { _logger.Error("pipe is not supported in mono, use http!"); Environment.Exit(1); return; } _remoteServer = new RemoteServer(this, ERemoteBinding.Pipe, string.Format("localhost/AuthServer/{0}/", SHA256.ComputeHash(AuthConfig.Instance.Remote.Password))); break; case "tcp": if (isMono) { _logger.Error("tcp is not supported in mono, use http!"); Environment.Exit(1); return; } _remoteServer = new RemoteServer(this, ERemoteBinding.Pipe, string.Format("{0}:{1}/AuthServer/{2}/", AuthConfig.Instance.Remote.Server, AuthConfig.Instance.Remote.Port, SHA256.ComputeHash(AuthConfig.Instance.Remote.Password))); break; case "http": _remoteServer = new RemoteServer(this, ERemoteBinding.Http, string.Format("{0}:{1}/AuthServer/{2}/", AuthConfig.Instance.Remote.Server, AuthConfig.Instance.Remote.Port, SHA256.ComputeHash(AuthConfig.Instance.Remote.Password))); break; default: _logger.Error("Invalid remote binding '{0}'", AuthConfig.Instance.Remote.Binding); Environment.Exit(1); return; } _remoteServer.AddServiceEndpoint(typeof(IAuthRemote), "IAuthRemote"); }
public AuthServer() { _packetLogger = new PacketLogger(); _logger = new Logger() { WriteToConsole = true }; _logger.Load(Path.Combine("logs", string.Format("auth_{0}.log", DateTime.Now.ToString("dd-MM-yyyy_HH-mm-ss")))); AppDomain.CurrentDomain.UnhandledException += (s, e) => { Error(s, new ExceptionEventArgs((Exception)e.ExceptionObject)); Environment.Exit(0); }; _packetLogger.Load("auth_packets.log"); _logger.Info("Loading auth_config.xml..."); AuthConfig.Load(); _logger.Info("Setting up servers..."); _server = new TcpServer(IPAddress.Parse(AuthConfig.Instance.IP), AuthConfig.Instance.Port); _server.PacketReceived += HandlePacket; _server.Error += Error; _natServer = new UDPClient(38915); _natServer.PacketReceived += HandleNATTest; _natServer.Error += Error; _natServer2 = new UDPClient(38917); _natServer2.PacketReceived += HandleNATTest2; _natServer2.Error += Error; var isMono = Type.GetType("Mono.Runtime") != null; switch (AuthConfig.Instance.Remote.Binding) { case "pipe": if (isMono) { _logger.Error("pipe is not supported in mono, use http!"); Environment.Exit(1); return; } _remoteServer = new RemoteServer(this, ERemoteBinding.Pipe, string.Format("localhost/FagNetAuth/{0}/", SHA256.ComputeHash(AuthConfig.Instance.Remote.Password))); break; case "tcp": if (isMono) { _logger.Error("tcp is not supported in mono, use http!"); Environment.Exit(1); return; } _remoteServer = new RemoteServer(this, ERemoteBinding.Pipe, string.Format("{0}:{1}/FagNetAuth/{2}/", AuthConfig.Instance.Remote.Server, AuthConfig.Instance.Remote.Port, SHA256.ComputeHash(AuthConfig.Instance.Remote.Password))); break; case "http": _remoteServer = new RemoteServer(this, ERemoteBinding.Http, string.Format("{0}:{1}/FagNetAuth/{2}/", AuthConfig.Instance.Remote.Server, AuthConfig.Instance.Remote.Port, SHA256.ComputeHash(AuthConfig.Instance.Remote.Password))); break; default: _logger.Error("Invalid remote binding '{0}'", AuthConfig.Instance.Remote.Binding); Environment.Exit(1); return; } _remoteServer.AddServiceEndpoint(typeof(IAuthRemote), "IAuthRemote"); }