Esempio n. 1
0
        //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 = Utils.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;
        //}

        public Vmess ImportVmess(string vmessUrl)
        {
            Vmess VmessLink = js.Deserialize <Vmess>(Utils.Base64Decode(vmessUrl.Substring(8)));

            profiles.Add(Utils.GenVmessConfig(VmessLink));
            return(VmessLink);
        }
Esempio n. 2
0
        /// <summary>
        /// gen Vmess Config
        /// </summary>
        /// <param name=VmessLink></param>
        /// <returns></returns>
        public static Dictionary <string, object> GenVmessConfig(Vmess VmessLink)
        {
            Dictionary <string, object> VmessProfiles  = Utils.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>;

            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;
            }
            return(VmessProfiles);
        }
Esempio n. 3
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);
        }
Esempio n. 4
0
 public void ImportVmess(Vmess VmessLink)
 {
     profiles.Add(Utils.GenVmessConfig(VmessLink));
 }