Exemplo n.º 1
0
 public frmProxy()
 {
     InitializeComponent();
     contextMenuStrip1.Renderer = new ToolStripProfessionalRenderer(new ContextMenuSetter());
     rbtnMtproto.Checked        = true;
     cls = new ProxyBussines();
 }
Exemplo n.º 2
0
        private async void mnuDelete_Click(object sender, EventArgs e)
        {
            try
            {
                if (DGrid.RowCount <= 0)
                {
                    return;
                }
                if (DGrid.CurrentRow == null)
                {
                    return;
                }
                var guid    = (Guid)DGrid[dgGuid.Index, DGrid.CurrentRow.Index].Value;
                var accGuid = (Guid)DGrid[dgGuid.Index, DGrid.CurrentRow.Index].Value;
                var Acc     = ProxyBussines.Get(accGuid);
                var message = "آیا از حذف پروکسی " + Acc.Server + " " + "اطمینان دارید؟";

                if (FarsiMessegeBox.Show(message, "حذف", FMessegeBoxButtons.YesNo, FMessegeBoxIcons.Question) !=
                    DialogResult.Yes)
                {
                    return;
                }
                Acc = ProxyBussines.Change_Status(accGuid, false);
                await Acc.SaveAsync();
                await Set_Data();
            }
            catch (Exception exception)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(exception);
            }
        }
Exemplo n.º 3
0
 private void mnuIns_Click(object sender, EventArgs e)
 {
     try
     {
         cls = new ProxyBussines();
         grpAccount.Enabled = true;
     }
     catch (Exception exception)
     {
         WebErrorLog.ErrorInstence.StartErrorLog(exception);
     }
 }
Exemplo n.º 4
0
        private async Task LoadData()
        {
            try
            {
                var list = await ProxyBussines.GetAllAsync();

                ProxyBindingSource.DataSource = list.Where(q => q.Status).ToList();
            }
            catch (Exception e)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(e);
            }
        }
Exemplo n.º 5
0
        private async void btnFinish_Click(object sender, EventArgs e)
        {
            try
            {
                btnFinish.Enabled = false;
                if (cls.Guid == Guid.Empty)
                {
                    cls.Guid     = Guid.NewGuid();
                    cls.DateSabt = DateConvertor.M2SH(DateTime.Now);
                }

                if (string.IsNullOrWhiteSpace(txtServer.Text))
                {
                    WebErrorLog.ErrorInstence.StartErrorLog("لطفا نام سرور را وارد نمایید", false);
                    txtServer.Focus();
                    return;
                }

                if (string.IsNullOrWhiteSpace(txtPort.Text))
                {
                    WebErrorLog.ErrorInstence.StartErrorLog("لطفا شماره پورت را وارد نمایید", false);
                    txtPort.Focus();
                    return;
                }

                cls.Password = txtPassword.Text;
                cls.Port     = txtPort.Text.ParseToInt();
                cls.Secret   = txtSecret.Text;
                cls.UserName = txtUserName.Text;
                cls.Server   = txtServer.Text;
                cls.Type     = rbtnMtproto.Checked ? ProxyType.MtProto : ProxyType.Socks5;
                cls.Status   = true;

                await cls.SaveAsync();

                cls = new ProxyBussines();
            }
            catch (Exception exception)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(exception);
            }
            finally
            {
                btnFinish.Enabled = true;
                await Set_Data();
            }
        }
Exemplo n.º 6
0
        public async Task StartSending(TelegramSendType type, string token = "", string chatId = "", string fileName = "", string caption = "", string smsReciver = "", string smsText = "")
        {
            var allPrx = await ProxyBussines.GetAllAsync();

            foreach (var item in allPrx)
            {
                try
                {
                    var socks5 = new HttpToSocks5Proxy(item.Server, item.Port, item.UserName, item.Password)
                    {
                        ResolveHostnamesLocally = false
                    };
                    var mtpropto = new WebProxy(Address: item.Server)
                    {
                        Credentials = new NetworkCredential(item.UserName, item.Password)
                    };
                    var a   = TelegramBotSettingBussines.GetAll();
                    var cls = a.Count > 0 ? a[0] : new TelegramBotSettingBussines();
                    if (string.IsNullOrEmpty(cls.Token) || string.IsNullOrEmpty(cls.ChanelForAds))
                    {
                        return;
                    }
                    token = cls.Token;
                    bot   = item.Type == ProxyType.Socks5
                        ? new TelegramBotClient(token, socks5)
                        : new TelegramBotClient(token, mtpropto);
                    if (type == TelegramSendType.SendBackUp)
                    {
                        await Send_(bot, fileName, cls.ChanelForAds, 10);
                    }
                    else
                    {
                        await Send_(bot, chatId : chatId, passage : caption, picPath : fileName, tryCount : 10,
                                    smsReciver : smsReciver, smsText : smsText);
                    }

                    break;
                }
                catch
                {
                    continue;
                }
            }
        }
Exemplo n.º 7
0
        private async void mnuEdit_Click(object sender, EventArgs e)
        {
            try
            {
                if (DGrid.RowCount <= 0)
                {
                    return;
                }
                if (DGrid.CurrentRow == null)
                {
                    return;
                }
                var guid = (Guid)DGrid[dgGuid.Index, DGrid.CurrentRow.Index].Value;
                cls = ProxyBussines.Get(guid);
                await Set_Data();

                grpAccount.Enabled = true;
            }
            catch (Exception exception)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(exception);
            }
        }