Exemple #1
0
        public HttpServerMd createNewModel()
        {
            HttpServerMd md = new HttpServerMd();

            md.port = SystemCtl.getFreePort(MainMd.ins.maxStartPort());

            md.desc = md.ip + ":" + md.port;
            md.path = SysConst.rootPath();
            return(md);
        }
Exemple #2
0
        HttpServerGo.HttpParamMd createParam(HttpServerMd md)
        {
            HttpServerGo.HttpParamMd param = new HttpServerGo.HttpParamMd();
            param.Ip          = MainCtl.createStrPtr(md.ip);
            param.Port        = MainCtl.createStrPtr("" + md.port);
            param.IsHttps     = md.isHttps;
            param.Path        = MainCtl.createStrPtr(md.path);
            param.VirtualPath = MainCtl.createStrPtr(md.virtualDir);
            param.Proxy       = MainCtl.createStrPtr(md.rewrite);

            return(param);
        }
Exemple #3
0
        private void updateData(string name, bool value)
        {
            if (nowData == null)
            {
                return;
            }

            HttpServerMd md = nowData;

            switch (name)
            {
            case "isRun": {
                md.isRun = value;
                var lastIp   = md.ip;
                var lastPort = md.port;
                md.ip          = cbxIp.Text;
                md.port        = toInt(txtPort.Text, md.port);
                md.isHttps     = (chkHttps.IsChecked == true);
                lblUrl.Content = getUrl();

                md.desc               = md.desc.Replace(lastIp, md.ip);
                md.desc               = md.desc.Replace("" + lastPort, "" + md.port);
                txtDesc.Text          = md.desc;
                md.serverItem.Content = md.desc;

                updateServer(md);

                if (value == true)
                {
                    //md.ctl.restartServer();
                    HttpServerGo.RestartServer(md.ctlId);
                }
                else
                {
                    //md.ctl.clear();
                    HttpServerGo.StopServer(md.ctlId);
                }
                break;
            }
                //case "isHttps": {
                //	md.isHttps = value;
                //	nowData.serverItem.Content = nowData.desc + " *";
                //	break;
                //}
            }
            MainWindow.ins.delaySaveConfig();
            //Debug.WriteLine("bbb");
        }
Exemple #4
0
        public void updateData(HttpServerMd md)
        {
            nowData = md;

            txtDesc.Text = md.desc;

            cbxIp.Text   = md.ip;
            txtPort.Text = "" + md.port;

            txtPath.Text       = md.path;
            txtVirtualDir.Text = md.virtualDir;
            txtUrlParam.Text   = md.urlParam;
            txtRewrite.Text    = md.rewrite;
            chkHttps.IsChecked = md.isHttps;

            lblUrl.Content = getUrl();
        }
Exemple #5
0
        private void updateData(string name, string value)
        {
            if (nowData == null)
            {
                return;
            }

            HttpServerMd md = nowData;

            switch (name)
            {
            case "desc": {
                md.desc = value;
                md.serverItem.Content = value;
                break;
            }

            case "path": {
                md.path = value;
                updateServer(md);
                break;
            }

            case "urlParam": {
                md.urlParam    = value;
                lblUrl.Content = getUrl();
                break;
            }

            case "rewrite": {
                md.rewrite = value;
                updateServer(md);
                break;
            }

            case "virtualDir": {
                md.virtualDir  = value;
                lblUrl.Content = getUrl();
                updateServer(md);
                break;
            }
            }
            MainWindow.ins.delaySaveConfig();
            //Debug.WriteLine("aaa");
        }
Exemple #6
0
        public void initData(HttpServerMd md)
        {
            //HttpServerGroup ctl = new HttpServerGroup();
            //ctl.md = md;
            //md.ctl = ctl;

            var param = createParam(md);

            long id = HttpServerGo.CreateServer(ref param);

            md.ctlId = id;

            if (md.isRun)
            {
                HttpServerGo.RestartServer(id);
                //ctl.restartServer();
            }
        }
Exemple #7
0
        private string getUrl()
        {
            HttpServerMd md = nowData;

            string ip  = (md.ip == "0.0.0.0" ? "localhost" : md.ip);
            string dir = md.virtualDir.Trim();

            if (dir != "")
            {
                dir = dir + "/";
            }
            string protocol = "http";

            if (md.isHttps)
            {
                protocol = "https";
            }
            return(protocol + "://" + ip + ":" + md.port + "/" + dir + md.urlParam);
        }
Exemple #8
0
 public void clear(HttpServerMd md)
 {
     //md.ctl.clear();
     HttpServerGo.StopServer(md.ctlId);
 }
Exemple #9
0
        void updateServer(HttpServerMd md)
        {
            var param = createParam(md);

            HttpServerGo.UpdateServer(md.ctlId, ref param);
        }