public string ImportShadowsocks(string url) { var link = url.Contains("#") ? url.Substring(5, url.IndexOf("#") - 5) : url.Substring(5); var tag = url.Contains("#") ? url.Substring(url.IndexOf("#") + 1).Trim() : "Newtag" + new Random(Guid.NewGuid().GetHashCode()).Next(100, 1000); var linkParseArray = ExtraUtils.Base64Decode(link).Split(new char[2] { ':', '@' }); Dictionary <string, object> ShadowsocksProfiles = Utilities.outboundTemplate; Dictionary <string, object> ShadowsocksTemplate = Utilities.ShadowsocksOutboundTemplateNew(); ShadowsocksProfiles["protocol"] = "shadowsocks"; ShadowsocksProfiles["tag"] = tag; ShadowsocksTemplate["email"] = "*****@*****.**"; ShadowsocksTemplate["address"] = linkParseArray[2]; ShadowsocksTemplate["port"] = Convert.ToInt32(linkParseArray[3]); ShadowsocksTemplate["method"] = linkParseArray[0]; ShadowsocksTemplate["password"] = linkParseArray[1]; ShadowsocksTemplate["ota"] = false; ShadowsocksTemplate["level"] = 0; ShadowsocksProfiles["settings"] = new Dictionary <string, object> { { "servers", new List <Dictionary <string, object> > { ShadowsocksTemplate } } }; outbounds.Add(Utilities.DeepClone(ShadowsocksProfiles)); return(tag); }
void subscribeWorker_DoWork(object sender, DoWorkEventArgs e) { mainWindow.subscribeTag = ""; List <string> subscribeTag = new List <string>(); foreach (string url in subscribeUrl) { var tag = ImportURL(ExtraUtils.Base64Decode(ExtraUtils.GetUrl(url))); subscribeTag = subscribeTag.Concat(tag).ToList(); this.Dispatcher.Invoke(() => { RefreshListBox(); }); } mainWindow.subscribeTag = String.Join(",", subscribeTag); }
public string ImportVmess(string url) { Dictionary <string, object> VmessProfiles = Utilities.VmessOutboundTemplateNew(); Dictionary <string, object> muxSettings = VmessProfiles["mux"] as Dictionary <string, object>; Dictionary <string, object> streamSettings = VmessProfiles["streamSettings"] as Dictionary <string, object>; Dictionary <string, object> settings = VmessProfiles["settings"] as Dictionary <string, object>; Dictionary <string, object> vnext = (settings["vnext"] as IList <object>)[0] as Dictionary <string, object>; Dictionary <string, object> UserInfo = (vnext["users"] as IList <object>)[0] as Dictionary <string, object>; Dictionary <string, object> kcpSettings = streamSettings["kcpSettings"] as Dictionary <string, object>; Dictionary <string, object> kcpSettingsT = kcpSettings["header"] as Dictionary <string, object>; Dictionary <string, object> tcpSettings = streamSettings["tcpSettings"] as Dictionary <string, object>; Dictionary <string, object> tcpSettingsT = tcpSettings["header"] as Dictionary <string, object>; Dictionary <string, object> wsSettings = streamSettings["wsSettings"] as Dictionary <string, object>; Dictionary <string, object> wsSettingsT = wsSettings["headers"] as Dictionary <string, object>; Dictionary <string, object> httpSettings = streamSettings["httpSettings"] as Dictionary <string, object>; Dictionary <string, object> quicSettings = streamSettings["quicSettings"] as Dictionary <string, object>; Dictionary <string, object> quicSettingsT = quicSettings["header"] as Dictionary <string, object>; Dictionary <string, object> tlsSettings = streamSettings["tlsSettings"] as Dictionary <string, object>; VmessLink VmessLink = JsonConvert.DeserializeObject <VmessLink>(ExtraUtils.Base64Decode(url.Substring(8))); UserInfo["id"] = VmessLink.id; UserInfo["alterId"] = Convert.ToInt32(VmessLink.aid); vnext["address"] = VmessLink.add; vnext["port"] = Convert.ToInt32(VmessLink.port); streamSettings["network"] = VmessLink.net == "h2" ? "http" : VmessLink.net; streamSettings["security"] = VmessLink.tls == "" ? "none" : VmessLink.tls; tlsSettings["serverName"] = VmessLink.add; VmessProfiles["tag"] = VmessLink.ps; switch (VmessLink.net) { case "ws": wsSettingsT["host"] = VmessLink.host; wsSettings["path"] = VmessLink.path; break; case "h2": httpSettings["host"] = VmessLink.host.Split(','); httpSettings["path"] = VmessLink.path; break; case "tcp": tcpSettingsT["type"] = VmessLink.type; break; case "kcp": kcpSettingsT["type"] = VmessLink.type; break; case "quic": quicSettingsT["type"] = VmessLink.type; quicSettings["securty"] = VmessLink.host; quicSettings["key"] = VmessLink.path; break; default: break; } profiles.Add(VmessProfiles); return(VmessLink.ps); }