Exemplo n.º 1
0
        public ServerProfile ImportVmess(string vmessUrl)
        {
            VmessConf     vmessConf = js.Deserialize <VmessConf>(Utils.Base64Decode(vmessUrl.Substring(8)));
            ServerProfile tmp       = Utils.GenVmessConfig(vmessConf);

            //tmp.groupId = groupId;
            //subsProfiles.Add(tmp);
            return(tmp);
        }
Exemplo n.º 2
0
        /// <summary>
        /// gen Vmess Config
        /// </summary>
        /// <param name=vmessConf></param>
        /// <returns></returns>
        public static ServerProfile GenVmessConfig(VmessConf vmessConf)
        {
            ServerProfile serverProfile = new ServerProfile();

            //Dictionary<string, object> VmessProfiles = Utils.VmessOutboundTemplateNew();
            Dictionary <string, object> muxSettings    = serverProfile.muxSettings;
            Dictionary <string, object> streamSettings = serverProfile.streamSettings;
            //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>;


            serverProfile.address = vmessConf.add;
            serverProfile.port    = Convert.ToInt32(vmessConf.port);
            serverProfile.userId  = vmessConf.id;
            serverProfile.alterId = Convert.ToInt32(vmessConf.aid);
            serverProfile.remark  = vmessConf.ps;
            serverProfile.tag     = vmessConf.ps;
            serverProfile.network = (NetWorkType)Enum.Parse(typeof(NetWorkType), vmessConf.net, true);

            //streamSettings["network"] = vmessConf.net == "h2" ? "http" : vmessConf.net;
            streamSettings["security"] = vmessConf.tls == "" ? "none" : vmessConf.tls;
            //tlsSettings["serverName"] = vmessConf.add;

            string type = vmessConf.type == null ? "none" : vmessConf.type;

            switch (vmessConf.net)
            {
            case "ws":
                wsSettingsT["Host"] = vmessConf.host;
                wsSettings["path"]  = vmessConf.path;
                break;

            case "h2":
                httpSettings["host"] = vmessConf.host.Split(',');
                httpSettings["path"] = vmessConf.path;
                break;

            case "tcp":
                tcpSettingsT["type"] = type;
                break;

            case "kcp":
                kcpSettingsT["type"] = type;
                break;

            case "quic":
                quicSettingsT["type"]    = type;
                quicSettings["security"] = vmessConf.host;
                quicSettings["key"]      = vmessConf.path;
                break;

            default:
                break;
            }
            return(serverProfile);
        }