public void ImportServersFromTextFile() { string v2rayLinks = Lib.UI.ShowReadFileDialog(StrConst.ExtText, out string filename); if (v2rayLinks == null) { return; } servers.ImportLinks(v2rayLinks); }
private void ImportFromSubscriptionUrls( Dictionary <string, string> subscriptions) { Task.Factory.StartNew(() => { // dict( [url]=>mark ) to list(url,mark) mark maybe null var subsUrl = subscriptions.Select(s => s).ToList(); List <string[]> links = BatchGetLinksFromSubsUrl(subsUrl); servers.ImportLinks(links); EnableBtnUpdate(); }); }
private void ImportFromSubscriptionUrls(Dictionary<string, string> subscriptions) { Task.Factory.StartNew(() => { // dict( [url]=>mark ) to list(url,mark) mark maybe null var list = subscriptions.Select(s => s).ToList(); var timeout = Lib.Utils.Str2Int(StrConst("ParseImportTimeOut")); var contents = Lib.Utils.ExecuteInParallel< KeyValuePair<string, string>, string[]>(list, (item) => { // item[url]=mark var subsString = Lib.Utils.Fetch(item.Key, timeout * 1000); if (string.IsNullOrEmpty(subsString)) { setting.SendLog(I18N("DownloadFail") + "\n" + item.Key); return new string[] { string.Empty, item.Value }; } var links = new List<string>(); var matches = Regex.Matches(subsString, StrConst("PatternBase64NonStandard")); foreach (Match match in matches) { try { links.Add(Lib.Utils.Base64Decode(match.Value)); } catch { } } return new string[] { string.Join("\n", links), item.Value }; }); servers.ImportLinks(contents); try { this.btnUpdate.Invoke((MethodInvoker)delegate { this.btnUpdate.Enabled = true; }); } catch { } }); }
private void ImportFromSubscriptionUrls(List <string> urls) { Task.Factory.StartNew(() => { var timeout = Lib.Utils.Str2Int(StrConst("ParseImportTimeOut")); var contents = Lib.Utils.ExecuteInParallel <string, string>(urls, (url) => { var subsString = Lib.Utils.Fetch(url, timeout * 1000); if (string.IsNullOrEmpty(subsString)) { setting.SendLog(I18N("DownloadFail") + "\n" + url); return(string.Empty); } var links = new List <string>(); var matches = Regex.Matches(subsString, StrConst("PatternBase64NonStandard")); foreach (Match match in matches) { try { links.Add(Lib.Utils.Base64Decode(match.Value)); } catch { } } return(string.Join("\n", links)); }); servers.ImportLinks(string.Join("\n", contents)); try { this.btnUpdate.Invoke((MethodInvoker) delegate { this.btnUpdate.Enabled = true; }); } catch { } }); }
private void btnOK_Click(object sender, System.EventArgs e) { // using vmess:// v1 do not need fix var vmess = new Model.Data.Vmess(); vmess.add = tboxHost.Text; vmess.port = tboxPort.Text; vmess.aid = tboxAID.Text; vmess.id = tboxUID.Text; vmess.ps = tboxAlias.Text; if (rbtnWS.Checked) { vmess.net = "ws"; vmess.host = tboxWSPath.Text; } if (rbtnKCP.Checked) { vmess.net = "kcp"; var index = Math.Max(0, cboxKCP.SelectedIndex); vmess.type = Model.Data.Table.kcpTypes[index]; } if (rbtnTCP.Checked) { vmess.net = "tcp"; } if (chkboxTLS.Checked) { vmess.tls = "tls"; } var link = Lib.Utils.Vmess2VmessLink(vmess); servers.ImportLinks(link); this.Close(); }
private void lbCopyFromClipboard_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { string links = Lib.Utils.GetClipboardText(); servers.ImportLinks(links); }