示例#1
0
 /// <summary>
 /// 测试节点延迟
 /// </summary>
 private void TestLine()
 {
     Task.Run(new Action(() =>
     {
         string hostname = EncryptsHelper.Decrypt(shadowsocksR.HostName);
         int result      = int.Parse(NetWorkHelper.GetIPPing(hostname));
         if (result > 0 && result < 100)
         {
             lbPingText.ForeColor = Color.LimeGreen;
         }
         else if (result > 90 && result < 200)
         {
             lbPingText.ForeColor = Color.Yellow;
         }
         else if (result == 0 || result >= 200)
         {
             lbPingText.ForeColor = Color.Red;
         }
         if (lbPingText.InvokeRequired)
         {
             lbPingText.BeginInvoke(new Action(() =>
             {
                 lbPingText.Text = result.ToString() + " ms";
             }));
         }
     }));
 }
示例#2
0
        static void Main()
        {
            bool isRuned;

            System.Threading.Mutex mutex = new System.Threading.Mutex(true, "OnlyRunOneInstance", out isRuned);
            if (!isRuned)
            {
                CCWin.MessageBoxEx.Show("另一个风雪加速器客户端已经在运行了哦,请勿重复开启!", "消息", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }

            #region 配置数据库连接字符串
            string NoBoundaries = ConfigurationManager.ConnectionStrings["NoBoundaries"].ToString();
            XCode.DataAccessLayer.DAL.AddConnStr("NoBoundaries", EncryptsHelper.Decrypt(NoBoundaries), null, "SqlServer");
            NewLife.Setting.Current.LogLevel = NewLife.Log.LogLevel.Error;
            XCode.Setting.Current.Debug      = false;
            XCode.Setting.Current.ShowSQL    = false;
            #endregion

            string path = System.Environment.CurrentDirectory;
            if (!Directory.Exists(path + @"\bin"))//如果不存在就创建bin文件夹
            {
                Directory.CreateDirectory(path + @"\bin");
            }
            if (!Directory.Exists(path + @"\res"))//如果不存在就创建res文件夹
            {
                Directory.CreateDirectory(path + @"\res");
            }
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new MainFrm());
            mutex.ReleaseMutex();
        }
示例#3
0
        private void AddGameIcon(object sender)
        {
            string path = System.Environment.CurrentDirectory;
            string url  = EncryptsHelper.Decrypt(ConfigurationManager.ConnectionStrings["GamesURL"].ToString());

            foreach (IconList list in panel.Controls)
            {
                string iconpath = string.Format(path + @"\res\{0}.png", list.gameCode);
                if (!File.Exists(iconpath))
                {
                    NetWorkHelper.ImgSave(url + list.gameCode + ".png", iconpath);
                }
                list.Image = Image.FromFile(iconpath);
            }
        }
        public bool Start()
        {
            string HostName      = EncryptsHelper.Decrypt(ssr.HostName);
            string Port          = EncryptsHelper.Decrypt(ssr.Port);
            string Password      = EncryptsHelper.Decrypt(ssr.Password);
            string Method        = EncryptsHelper.Decrypt(ssr.Method);
            string Protocol      = EncryptsHelper.Decrypt(ssr.Protocol);
            string ProtocolParam = EncryptsHelper.Decrypt(ssr.ProtocolParam);
            string Obfs          = EncryptsHelper.Decrypt(ssr.Obfs);
            string OBFSParam     = EncryptsHelper.Decrypt(ssr.OBFSParam);

            string arguments = $"-s {HostName} -p {Port} -k \"{Password}\" -m {Method} -t 120 -b 127.0.0.1 -l 2801 -u";

            if (!string.IsNullOrEmpty(Protocol))
            {
                arguments += $" -O {Protocol}";
                if (!string.IsNullOrEmpty(ProtocolParam))
                {
                    arguments += $" -G \"{ProtocolParam}\"";
                }
            }
            if (!string.IsNullOrEmpty(Obfs))
            {
                arguments += $" -o {Obfs}";
                if (!string.IsNullOrEmpty(OBFSParam))
                {
                    arguments += $" -g \"{OBFSParam}\"";
                }
            }
            Console.WriteLine(arguments);
            string path = System.Environment.CurrentDirectory;

            if (!File.Exists(path + @"\bin\Utils.exe"))//判断SSR是否存在
            {
                CCWin.MessageBoxEx.Show("驱动文件不存在,请重新安装解决此问题!", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return(false);
            }

            Utils = new Process();
            Utils.StartInfo.FileName               = path + @"\bin\Utils.exe";
            Utils.StartInfo.Arguments              = arguments.ToString();
            Utils.StartInfo.UseShellExecute        = false; //是否使用操作系统shell启动
            Utils.StartInfo.RedirectStandardInput  = true;  //接受来自调用程序的输入信息
            Utils.StartInfo.RedirectStandardOutput = true;  //由调用程序获取输出信息
            Utils.StartInfo.CreateNoWindow         = true;  //不显示程序窗口
            Utils.Start();
            return(true);
        }
示例#5
0
 private void LoginFrm_Load(object sender, EventArgs e)
 {
     skinCheckBox1.Checked = MySetting.Default.RemmberUser;
     skinCheckBox2.Checked = MySetting.Default.AutoLogin;
     if (MySetting.Default.RemmberUser)
     {
         if (MySetting.Default.UserID != string.Empty || MySetting.Default.UserPwd != string.Empty)
         {
             tbUserID.Text  = MySetting.Default.UserID;
             tbUserPwd.Text = EncryptsHelper.Decrypt(MySetting.Default.UserPwd);
         }
         else
         {
             tbUserID.Text  = string.Empty;
             tbUserPwd.Text = string.Empty;
         }
     }
 }
        private void ChooseLine_Load(object sender, EventArgs e)
        {
            ssList = new Dictionary <string, string>();//字典需要初始化才能赋值
            var listAll = ShadowsocksR.FindAll(Shadowsocks._.State, "启用");

            foreach (var list in listAll)
            {
                ssList.Add(EncryptsHelper.Decrypt(list.HostName), list.Remark);
            }
            if (ssList.Count > 0)
            {
                for (int i = 0; i < ssList.Count; i++)
                {
                    SkinListBoxItem item = new SkinListBoxItem(ssList.ElementAt(i).Value);
                    item.Tag = ssList.ElementAt(i).Key;
                    skinListBox1.Items.Add(item);
                }
            }
            TestIP();
            timer1.Enabled = true;
        }
示例#7
0
        private void CreatRes()
        {
            string path = System.Environment.CurrentDirectory;
            string url  = EncryptsHelper.Decrypt(ConfigurationManager.ConnectionStrings["GamesURL"].ToString());

            if (!Directory.Exists(path + @"\res"))//如果不存在就创建res文件夹
            {
                Directory.CreateDirectory(path + @"\res");
            }
            var allGame = Game.FindAll();

            for (int i = 0; i < allGame.Count; i++)
            {
                IconList iconList = new IconList();
                iconList.GameName = allGame[i].Name;
                iconList.gameCode = allGame[i].SerialCode;
                panel.Controls.Add(iconList);
            }
            //加载图片放入线程池中
            ThreadPool.QueueUserWorkItem(new WaitCallback(AddGameIcon));
        }
        public bool Start()
        {
            string TUNTAPaddress = "10.0.0.2";
            string TUNTAPgw      = "10.0.0.1";
            string hostName      = "127.0.0.1";
            string port          = "2801";

            // 查找并安装 TAP 适配器
            if (string.IsNullOrEmpty(TUNTAP.GetComponentID()))
            {
                //CCWin.MessageBoxEx.Show("未检测到虚拟网卡驱动,驱动即将自动安装,请在弹出的窗口内点击'始终安装此驱动程序软件',并重新加速!", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Information);
                TUNTAP.addtap();
            }
            string path = System.Environment.CurrentDirectory;

            if (!Directory.Exists(path + @"\bin"))//如果不存在就创建bin文件夹
            {
                Directory.CreateDirectory(path + @"\bin");
            }
            if (!File.Exists(path + @"\bin\Accelerator.exe"))//tun2socks.exe不存在就从资源导出
            {
                CCWin.MessageBoxEx.Show("驱动文件丢失,请重新安装本软件!", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return(false);
            }
            string url       = EncryptsHelper.Decrypt(ConfigurationManager.ConnectionStrings["GamesURL"].ToString());
            string tempParh  = Path.GetTempPath();
            string routepath = tempParh + "routetmp.txt";

            if (File.Exists(tempParh + "routetmp.txt"))
            {
                File.Delete(tempParh + "routetmp.txt");
            }
            NetWorkHelper.RoutetxtSave(url + MainFrm.CurrentGame.SerialCode + ".txt", routepath);
            if (!File.Exists(tempParh + "routetmp.txt"))
            {
                CCWin.MessageBoxEx.Show("获取路由表文件失败,请联系开发者!", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }
            Task.Run(() =>
            {
                //修改路由表文件
                string routeif = TUNTAPController.GetIF().ToString();
                //防止文本字符中有特殊字符。必须用Encoding.Default
                StreamReader reader = new StreamReader(tempParh + "routetmp.txt", Encoding.Default);
                String a            = reader.ReadToEnd();
                a = a.Replace("IFZ", $"{routeif}");//替换IF值
                StreamWriter readTxt = new StreamWriter(tempParh + "routetmp1.txt", false, Encoding.Default);
                readTxt.Write(a);
                readTxt.Flush();
                readTxt.Close();
                reader.Close();
                File.Copy(tempParh + "routetmp1.txt", tempParh + "routetmp.txt", true);
                File.Delete(tempParh + "routetmp1.txt");
            });
            var argument = new StringBuilder();

            //argument.Append(
            //    $"-tunAddr {TUNTAPaddress} -tunGw {TUNTAPgw} -dnsServer 8.8.8.8,8.8.4.4 -proxyType shadowsocks -proxyServer {hostName}:{port} " +
            //    $"-proxyCipher {method} -proxyPassword {pwd}");
            argument.Append(
                $"-tunAddr {TUNTAPaddress} -tunGw {TUNTAPgw} -dnsServer 8.8.8.8,8.8.4.4 -proxyServer {hostName}:{port} ");

            NoBoundaries = new Process();
            NoBoundaries.StartInfo.FileName               = path + @"\bin\Accelerator.exe";
            NoBoundaries.StartInfo.Arguments              = argument.ToString();
            NoBoundaries.StartInfo.UseShellExecute        = false; //是否使用操作系统shell启动
            NoBoundaries.StartInfo.RedirectStandardInput  = true;  //接受来自调用程序的输入信息
            NoBoundaries.StartInfo.RedirectStandardOutput = true;  //由调用程序获取输出信息
            NoBoundaries.StartInfo.CreateNoWindow         = true;  //不显示程序窗口
            NoBoundaries.Start();
            return(true);
        }