Esempio n. 1
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
        }
Esempio n. 2
0
 private bool SetTrojanConf(string TcsShareLink) => SetTrojanConf((string[])ShareLink.ConvertShareToTrojanConf(TcsShareLink));