static void Main(string[] args) { Encrypt aes = new Encrypt(); // 文件加密测试 // aes.testEncryptFile(); // 测试 //aes.testSecureRandom(); //aes.testIsPassword(); //aes.test(); //byte[] original = new byte[1024*1024]; //var random = new Random(); //for (int i = 0;i< original.Length;i++) //{ // original[i] = (byte)random.Next(0, 255); //} //key = aes.getKey(); //byte[] encrypted = aes.encryptNet(key, original); //byte[] decrypted = DecryptNet(key, encrypted); //if(original.Length==decrypted.Length) //{ // for(int i = 0;i< original.Length;i++) // { // if(original[i]!=decrypted[i]) // { // Console.WriteLine(i); // } // } //} key = aes.getPasswordKey("Q1w2e3r$"); Listener server = new GFWPressForwardServerListener(IPAddress.Parse("192.168.1.107"), 4567, IPAddress.Parse("192.168.1.200"), 8500, key); //server.Start(); Listener client = new GFWPressForwardClientListener(IPAddress.Parse("192.168.1.107"), 1234, IPAddress.Parse("192.168.1.107"), 4567, key); //Listener client = new TransparentForwardListener(IPAddress.Parse("192.168.1.107"), 1234, IPAddress.Parse("192.168.1.200"), 8500); //Listener client = new GFWPressForwardClientListener(IPAddress.Parse("127.0.0.1"), 1234, IPAddress.Parse("192.168.1.104"), 4567, key); //Listener server = new TransparentForwardListener(IPAddress.Parse("192.168.1.107"), 4567, IPAddress.Parse("192.168.1.200"), 8500); server.Start(); //Listener client = new TransparentForwardListener(IPAddress.Parse("192.168.1.107"), 1234, IPAddress.Parse("192.168.1.107"), 4567); client.Start(); //var ipExt = Listener.GetLocalExternalIP(); //var ipInt = Listener.GetLocalInternalIP(); Console.ReadLine(); }
static void Main(string[] args) { System.Console.WriteLine(""); string lip = "127.0.0.1"; int lport = 8558; int rport = 0; string rip = null, p = null; var arguments = CommandLineArgumentParser.Parse(args); if (arguments.Has("-lip") && arguments.Get("-lip").Next != null && arguments.Get("-lip").Next.ToString() != string.Empty && IsLocalIP(arguments.Get("-lip").Next)) { lip = arguments.Get("-lip").Next; } if (arguments.Has("-lport") && arguments.Get("-lport").Next != null) { int newPort = 0; if (int.TryParse(arguments.Get("-lport").Next, out newPort) && newPort > 0 && newPort < 65536) { lport = newPort; } } if (arguments.Has("-rip") && arguments.Get("-rip").Next != null && IsIP(arguments.Get("-rip").Next)) { rip = arguments.Get("-rip").Next; } else { ShowHelp(); return; } if (arguments.Has("-rport") && arguments.Get("-rport").Next != null && int.TryParse(arguments.Get("-rport").Next, out rport) && rport > 0 && rport < 65536) { } else { ShowHelp(); return; } if (arguments.Has("-p") && arguments.Get("-p").Next != null && arguments.Get("-p").Next.ToString() != string.Empty && Core.Ciphering.Encrypt.isPassword(arguments.Get("-p").Next)) { p = arguments.Get("-p").Next; } else { ShowHelp(); return; } if (arguments.Has("-server")) { Logger.Write("Server is running! Press enter/ctrl+c to exit."); Logger.Write(string.Format("local ip:\t{0}", lip)); Logger.Write(string.Format("local port:\t{0}", lport)); Logger.Write(string.Format("remote ip:\t{0}", rip)); Logger.Write(string.Format("remote port:\t{0}", rport)); SecretKey key = new Encrypt().getPasswordKey(p); var server = new GFWPressForwardServerListener(IPAddress.Parse(lip), lport, IPAddress.Parse(rip), rport, key); server.Start(); } else if (arguments.Has("-client")) { Logger.Write("Client is running! Press enter/ctrl+c to exit."); Logger.Write(string.Format("local ip:\t{0}", lip)); Logger.Write(string.Format("local port:\t{0}", lport)); Logger.Write(string.Format("remote ip:\t{0}", rip)); Logger.Write(string.Format("remote port:\t{0}", rport)); SecretKey key = new Encrypt().getPasswordKey(p); var client = new GFWPressForwardClientListener(IPAddress.Parse(lip), lport, IPAddress.Parse(rip), rport, key); client.Start(); } else { ShowHelp(); return; } System.Console.ReadLine(); }