Пример #1
0
        private string configGen()
        {
            log.access     = textBoxAccessLog.Text;
            log.error      = textBoxErrorLog.Text;
            log.loglevel   = comboBoxLogLevel.Text;
            serverInfo.log = log;

            inbound.port     = Convert.ToInt32(upDownPort.Value);
            inbound.protocol = comboBoxProtocol.Text;
            JArray centArray = new JArray();

            if (!checkBoxManyUser.Checked)
            {
                clients.id      = textBoxUUID.Text;
                clients.alterId = Convert.ToInt32(upDownAlterID.Value);
                if (checkBoxUserLevel.Checked)
                {
                    clients.level = 1;
                }
                else
                {
                    clients.level = 0;
                }
                centArray.Add(JObject.FromObject(clients));
            }
            else
            {
                foreach (var item in listBoxManyUser.Items)
                {
                    centArray.Add(JObject.Parse(item.ToString()));
                }
            }

            inBoundSetting.clients = centArray;
            inbound.settings       = inBoundSetting;
            serverInfo.inbound     = inbound;

            outbound.protocol   = "freedom";
            outbound.settings   = new JObject();
            serverInfo.outbound = outbound;

            JObject configJson = JObject.FromObject(serverInfo);
            JObject stream     = new JObject();

            configJson["outboundDetour"] = JArray.Parse(OutboundDetourStr);
            if (checkBoxRouting.Checked)
            {
                configJson["routing"] = JObject.Parse(RoutingStr);
            }

            if (checkBoxHttpFake.Checked)
            {
                stream["network"]            = "tcp";
                stream["tcpSettings"]        = JObject.Parse(HttpFakeStr);
                configJson["streamSettings"] = stream;
            }

            if (checkBoxKCP.Checked)
            {
                stream["network"] = "kcp";
                JObject KCPSet   = JObject.Parse(MKcpStr);
                JObject fakeType = new JObject();
                fakeType["type"]             = comboBoxFakeKCP.Text;
                KCPSet["header"]             = fakeType;
                stream["kcpSettings"]        = KCPSet;
                configJson["streamSettings"] = stream;
            }

            if (checkBoxTLS.Checked)
            {
                if (!checkBoxWS.Checked)
                {
                    stream["network"] = "tcp";
                }
                stream["security"] = "tls";
                JObject tlsSet  = new JObject();
                JObject certSet = new JObject();
                certSet["certificateFile"] = CertificateFile;
                certSet["keyFile"]         = KeyFile;
                JArray certificatesArray = new JArray();
                certificatesArray.Add(certSet);
                tlsSet["serverName"]         = ServerName;
                tlsSet["certificates"]       = certificatesArray;
                stream["tlsSettings"]        = tlsSet;
                configJson["streamSettings"] = stream;
            }

            if (checkBoxWS.Checked)
            {
                stream["network"]            = "ws";
                configJson["streamSettings"] = stream;
            }

            return(MyJson.FormatJsonString(configJson.ToString()));
        }
Пример #2
0
 private void EditForm_Load(object sender, EventArgs e)
 {
     richTextBoxConfig.Text = MyJson.FormatJsonString(HttpFakeStr);
     MaximizeBox            = false;
 }