示例#1
0
 private void RunTrojan()
 {
     if (IsConfigValid())
     {
         InitialTemp();
         try
         {
             File.WriteAllText("node.tcsdb", ShareLink.Generate(RemoteAddressBox.Text, RemotePortBox.Text, PasswordBox.Text));
         }
         catch
         {
             Message.Show("Conf file written failed!", Message.Mode.Error);
             goto final;
         }
         KillProcess();
         SaveTrojanConf();
         RunTrojanCommand();
         if (isHttp.Checked == true)
         {
             RunPivoxyCommand();
             Proxy.SetProxy("127.0.0.1:54392");
         }
         Message.Show("Stop Trojan succeeded!", Message.Mode.Info);
         final :;
     }
     else
     {
         Message.Show("Config invalid! Please enter current trojan information.", Message.Mode.Error);
     }
 }
示例#2
0
        private void TCS_Load(object sender, EventArgs e)
        {
            InitialTemp();

            if (File.Exists("config.ini"))
            {
                IniData iniData = iniParser.ReadFile("config.ini");

                try
                {
                    localPort = int.Parse(iniData["TCS"]["LocalPort"]);
                }
                catch
                {
                    iniData["TCS"]["LocalPort"] = "1080";
                    iniParser.WriteFile("config.ini", iniData);
                    localPort = 1080;
                }

                ConfigIniToCheckBox("TCS", "VerifyCert", isVerifyCert, "True");
                ConfigIniToCheckBox("TCS", "VerifyHostname", isVerifyHostname, "True");
                ConfigIniToCheckBox("TCS", "HttpProxy", isHttp, "True");
            }
            else
            {
                File.WriteAllText("config.ini", "" +
                                  "[TCS]\r\n" +
                                  "LocalPort = 1080\r\n" +
                                  "VerifyCert = True\r\n" +
                                  "VerifyHostname = True\r\n" +
                                  "HttpProxy = True");

                isVerifyCert.Checked     = true;
                isVerifyHostname.Checked = true;
            }
            if (IsPortUsed(localPort))
            {
                Message.Show($"Port {localPort} is in use!\r\nTrojan may fail to work.", Message.Mode.Warning);
            }
            if (IsPortUsed(54392))
            {
                Message.Show("Port 54392 is in use!\r\nTrojan may fail to work.", Message.Mode.Warning);
            }
            if (File.Exists("node.tcsdb"))
            {
                string[] tmp = ShareLink.ConvertShareToTrojanConf(File.ReadAllText("node.tcsdb"));
                if (!SetTrojanConf(File.ReadAllText("node.tcsdb")))
                {
                    File.Create("node.tcsdb").Dispose();
                }
            }
            else
            {
                File.Create("node.tcsdb").Dispose();
            }
#if DEBUG
            this.Text = "[D]" + this.Text;
#endif
        }
示例#3
0
 private void SaveTrojanConf()
 {
     try
     {
         File.WriteAllText("temp\\trojan.conf", GenerateCurrentTrojanConf());
     }
     catch
     {
         Message.Show("Conf file written failed!", Message.Mode.Error);
     }
 }
示例#4
0
 private void ShareStripMenuItem_Click(object sender, EventArgs e)
 {
     Clipboard.SetText(ShareLinkBox.Text);
     Message.Show("TCS share link has copied to clipboard!", Message.Mode.Info);
 }
示例#5
0
 private void Stop_Click(object sender, EventArgs e)
 {
     StopTrojan();
     InitialTemp();
     Message.Show("Stop Trojan succeeded!", Message.Mode.Info);
 }