public LoginForm() { InitializeComponent(); var lastLogin = LastLogin.GetLastLogin(); if (lastLogin != null) { usernameTextBox.Text = lastLogin.Username; passwordTextBox.Text = lastLogin.Password; rememberMeCheckBox.Checked = true; } }
private void MainForm_Load(object sender, EventArgs e) { if (!Directory.Exists(location)) { Directory.CreateDirectory(location); } //CONSOLE _writer = new ConsoleStringWriter(this); Console.SetOut(_writer); //END CONSOLE //SETTINGS lastLogin = new LastLogin(); if (File.Exists(Path.Combine(location, "lastlogin"))) { String[] lastLoginData = lastLogin.GetLastLogin(); userText.Text = lastLoginData[0]; passText.Text = lastLoginData[1]; } try { FileStream stream = new FileStream(location + "settings", FileMode.Open); optionRememberBox.Checked = Convert.ToBoolean(stream.ReadByte()); optionConsoleBox.Checked = Convert.ToBoolean(stream.ReadByte()); } catch (Exception) { } //END SETTINGS //SERVER STATUS status = new ServerStatus(this); //END SERVER STATUS //NEM nemQuery = new QueryNEM(this); //END NEM //VERSIONLIST versionList = new VersionList(this); //END VERSIONLIST //OLD REPO repo = new Repo.QueryRepo(this); //END OLD REPO //TECHNIC PLATFORM technicDefaultPacks = new TechnicDefaultPacks(this); }
static void Main(string[] args) { ProxySettings = new ProxySettings(); // Load plugins into AppDomain foreach (var plugin in Directory.GetFiles(Directory.GetCurrentDirectory(), "*.dll")) { try { Assembly.LoadFile(plugin); } catch { } } LoadPlugins(); bool remoteSet = false, localSet = false; // Interpret command line args for (int i = 0; i < args.Length; i++) { var arg = args[i]; if (arg.StartsWith("-")) { switch (arg) { case "--authenticate-clients": ProxySettings.AuthenticateClients = true; break; case "--local-endpoint": ProxySettings.LocalEndPoint = ParseEndPoint(args[++i]); break; case "--remote-endpoint": ProxySettings.RemoteEndPoint = ParseEndPoint(args[++i], 25565); break; case "--filter": ProxySettings.PacketFilter = ParseFilter(args[++i]); break; case "--unfilter": var filter = ParseFilter(args[++i]); ProxySettings.PacketFilter.RemoveAll(p => filter.Contains(p)); break; case "--omit-client": ProxySettings.LogClient = false; break; case "--omit-server": ProxySettings.LogServer = false; break; case "--username": ProxySettings.Username = args[++i]; break; case "--password": ProxySettings.Password = args[++i]; break; case "--help": DisplayHelp(); return; default: var eventArgs = new UnrecognizedArgumentEventArgs { Argument = arg, Args = args, Index = i, Handled = false }; if (UnrecognizedArgument != null) { UnrecognizedArgument(null, eventArgs); } if (!eventArgs.Handled) { Console.WriteLine("Invalid command line arguments. Use --help for more information."); return; } break; } } else { if (!remoteSet) { ProxySettings.RemoteEndPoint = ParseEndPoint(arg, 25565); remoteSet = true; } else if (!localSet) { ProxySettings.LocalEndPoint = ParseEndPoint(arg); localSet = true; } else { var eventArgs = new UnrecognizedArgumentEventArgs { Argument = arg, Args = args, Index = i, Handled = false }; if (UnrecognizedArgument != null) { UnrecognizedArgument(null, eventArgs); } if (!eventArgs.Handled) { Console.WriteLine("Invalid command line arguments. Use --help for more information."); return; } } } } if (ProxySettings.Password == null) { // Grab lastlogin if possible var login = LastLogin.GetLastLogin(); if (login != null) { if (ProxySettings.Username == null) { ProxySettings.Username = login.Username; } ProxySettings.Password = login.Password; } } Listener = new TcpListener(ProxySettings.LocalEndPoint); Sessions = new List <Proxy>(); Listener.Start(); Listener.BeginAcceptTcpClient(AcceptClient, null); Console.WriteLine("Proxy started on " + ProxySettings.LocalEndPoint); Console.WriteLine("Press 'q' to exit."); ConsoleKeyInfo cki = new ConsoleKeyInfo(); do { cki = Console.ReadKey(); } while (cki.KeyChar != 'q'); }