Exemple #1
0
        public ActionResult Index()
        {
            var model = new Models.Setup(sessionInstance.UserId, sessionInstance.Username)
            {
                SessionVariables = sessionInstance
            };

            return(View(model));
        }
Exemple #2
0
        public void ProcessRequest(HttpContext context)
        {
            if (Helpers.SessionVariables.Instance.LoggedIn == false)
            {
                return;
            }

            int vpnServerId = Convert.ToInt32(Helpers.GlobalHelper.RequestParam("VpnId"));

            context.Response.ContentType = "text/json";
            try
            {
                VpnServer(vpnServerId);
            }
            catch (Exception ex)
            {
                LibLogic.Helpers.Logging.Log(ex);

                context.Response.StatusCode = (int)System.Net.HttpStatusCode.InternalServerError;
                context.Response.Write(ex.Message);
                context.Response.StatusDescription = ex.Message;
                return;
            }


            try
            {
                PptpServer(vpnServerId);
            }
            catch (Exception ex)
            {
                LibLogic.Helpers.Logging.Log(ex);


                context.Response.StatusCode = (int)System.Net.HttpStatusCode.InternalServerError;
                context.Response.Write(ex.Message);
                context.Response.StatusDescription = ex.Message;

                using (var ssh = new LibLogic.Ssh.LiveSsh(LibLogic.Helpers.SiteInfo.SshPort,
                                                          LibLogic.Helpers.SiteInfo.VpnSshUser, LibLogic.Helpers.SiteInfo.VpnSshPassword))
                {
                    var revokeOVPN = new LibLogic.OpenVpn.CertsOpenVpnRevokeCommand(Helpers.SessionVariables.Instance.UserId, ssh);
                    revokeOVPN.Execute();
                }

                return;
            }

            var model = new Models.Setup();

            context.Response.StatusCode = (int)System.Net.HttpStatusCode.OK;

            var output = Newtonsoft.Json.JsonConvert.SerializeObject(model);

            context.Response.Write(output);
        }
Exemple #3
0
        public JsonResult SaveUserVpnServer(int vpnId)
        {
            if (sessionInstance.LoggedIn == false)
            {
                return(null);
            }


            try
            {
                VpnServer(vpnId);
            }
            catch (Exception ex)
            {
                Majorsilence.Vpn.Logic.Helpers.Logging.Log(ex);

                this.HttpContext.Response.StatusCode = (int)System.Net.HttpStatusCode.InternalServerError;
                return(null);
            }


            try
            {
                PptpServer(vpnId);
            }
            catch (Exception ex)
            {
                Majorsilence.Vpn.Logic.Helpers.Logging.Log(ex);


                this.HttpContext.Response.StatusCode = (int)System.Net.HttpStatusCode.InternalServerError;

                using (var ssh = new Majorsilence.Vpn.Logic.Ssh.LiveSsh(Majorsilence.Vpn.Logic.Helpers.SiteInfo.SshPort,
                                                                        Majorsilence.Vpn.Logic.Helpers.SiteInfo.VpnSshUser, Majorsilence.Vpn.Logic.Helpers.SiteInfo.VpnSshPassword))
                {
                    var revokeOVPN = new Majorsilence.Vpn.Logic.OpenVpn.CertsOpenVpnRevokeCommand(sessionInstance.UserId, ssh);
                    revokeOVPN.Execute();
                }

                return(null);
            }

            var model = new Models.Setup(sessionInstance.UserId, sessionInstance.Username);

            this.HttpContext.Response.StatusCode = (int)System.Net.HttpStatusCode.OK;


            return(Json(model));
        }
Exemple #4
0
        public ActionResult Index()
        {
            var model = new Models.Setup();

            return(View(model));
        }