Example #1
0
        public static SubsProfile readingJson(string path)
        {
            string jsonStr = getJsonStr(path);
            //SubsProfile temp = JsonConvert.DeserializeObject<SubsProfile>(jsonStr);
            SubsProfile temp = js.Deserialize <SubsProfile>(jsonStr);

            return(temp);
        }
Example #2
0
        public static void writingJson(SubsProfile subsProfile, string dir = "")
        {
            string filename = Utils.MD5Sum(subsProfile.remark + "-" + subsProfile.url);
            //string json = JsonConvert.SerializeObject(subsProfile, Formatting.Indented);
            string json = js.Serialize(subsProfile);

            save(string.Format("{0}\\{1}.json", dir, filename), json);
        }
Example #3
0
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            string url = textBoxUrlIn.Text;

            if (url.Length > 0)
            {
                SubsProfile subsProfile = new SubsProfile(url);
                subsProfiles.Add(subsProfile);
                listBoxSubs.Items.Add(url);
                listBoxSubs.SelectedIndex = subsProfiles.Count - 1;
                subsProfiles[0].subsRefList.Add(subsProfile);
            }
        }
Example #4
0
        void subscribeWorker_DoWork2(object sender, DoWorkEventArgs e)
        {
            SubsProfile subsProfile = (SubsProfile)e.Argument;

            profiles.Clear();
            if (subsProfile.vmessList.Count > 0)
            {
                subsProfile.vmessList.Clear();
            }
            //MessageBox.Show("Update:\n" + subsProfile.url);
            var tag = ImportURL(Utils.Base64Decode(Utils.GetUrl(subsProfile.url)), subsProfile);

            //foreach (Vmess v in subsProfile.vmessList)
            //    subsProfiles[0].vmessList.Add(v);
            RefreshListServBox();
        }
Example #5
0
        public Form1()
        {
            InitializeComponent();
            Lang.InitControl(this);

            subsProfiles = new List <SubsProfile>();
            profiles     = new List <Dictionary <string, object> >();
            SubsProfile subsProfile0 = new SubsProfile();
            string      filepath     = string.Format("{0}\\{1}.json", subsSaveDir, Utils.MD5Sum("-"));

            if (File.Exists(filepath))
            {
                SubsProfile temp = IOSerialize.readingJson(filepath);
                subsProfile0.subsRefList = temp.subsRefList;
            }
            subsProfiles.Add(subsProfile0);
        }
Example #6
0
        private void buttonRemove_Click(object sender, EventArgs e)
        {
            var selectedIndex = listBoxSubs.SelectedIndex;

            if (selectedIndex > 0 && selectedIndex < subsProfiles.Count)
            {
                listBoxSubs.Items.RemoveAt(selectedIndex);
                SubsProfile deletedSubs = subsProfiles[selectedIndex];
                subsProfiles.Remove(deletedSubs);
                subsProfiles[0].subsRefList.Remove(deletedSubs);
                deletedSubs.vmessList.Clear();
                if (listBoxSubs.Items.Count == 1)
                {
                    setTexBoxesDefault();
                }
                listBoxSubs.SelectedIndex = subsProfiles.Count - 1;
            }
        }
Example #7
0
 private void updateUrl(SubsProfile subsProfile)
 {
     try
     {
         BackgroundWorker subscribeWorker = new BackgroundWorker();
         subscribeWorker.WorkerSupportsCancellation = true;
         subscribeWorker.DoWork += subscribeWorker_DoWork2;
         if (subscribeWorker.IsBusy)
         {
             return;
         }
         subscribeWorker.RunWorkerAsync(subsProfile);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString(), "request timeout");
         return;
     }
 }
Example #8
0
        void subscribeWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            profiles.Clear();
            //if (subsProfiles[0].vmessList.Count > 0)
            //    subsProfiles[0].vmessList.Clear();

            for (int i = 1; i < subsProfiles.Count; i++)
            {
                SubsProfile item = subsProfiles[i];
                //MessageBox.Show("Update:\n" + item.url);
                if (item.vmessList.Count > 0)
                {
                    item.vmessList.Clear();
                }
                var tag = ImportURL(Utils.Base64Decode(Utils.GetUrl(item.url)), item);
                //foreach (Vmess v in item.vmessList)
                //    subsProfiles[0].vmessList.Add(v);
            }

            RefreshListServBox();
        }
Example #9
0
        List <string> ImportURL(string importUrl, SubsProfile subsProfile = null)
        {
            List <string> linkMark = new List <string>();

            foreach (var link in importUrl.Split(Environment.NewLine.ToCharArray()))
            {
                //if (link.StartsWith("ss"))
                //{
                //    linkMark.Add(ImportShadowsocks(link));
                //}

                if (link.StartsWith("vmess"))
                {
                    Vmess vmess = ImportVmess(link);
                    linkMark.Add(vmess.ps);
                    if (subsProfile != null)
                    {
                        subsProfile.vmessList.Add(vmess);
                    }
                }
            }
            Debug.WriteLine("importurl " + String.Join(",", linkMark));
            return(linkMark);
        }