Пример #1
0
        public ContentResult Servers()
        {
            try
            {
                int userid = -1;
                if (!IsAuthenticateUserWithToken(HttpContext, out userid))
                {
                    Response.StatusCode = (int)System.Net.HttpStatusCode.Forbidden;
                    LibLogic.Helpers.Logging.Log("IsAuthenticateUserWithToken is false", false);
                    return(Content("Unauthorized"));
                }
            }
            catch (Exception ex)
            {
                Response.StatusCode = (int)System.Net.HttpStatusCode.InternalServerError;
                LibLogic.Helpers.Logging.Log(ex);
                return(Content("InternalServerError " + ex.Message + ex.StackTrace));
            }

            try
            {
                var details = new LibLogic.Accounts.ServerDetails();

                string data = Newtonsoft.Json.JsonConvert.SerializeObject(details.Info);
                Response.StatusCode = (int)System.Net.HttpStatusCode.OK;
                return(Content(data));
            }
            catch (Exception ex)
            {
                Response.StatusCode = (int)System.Net.HttpStatusCode.InternalServerError;
                LibLogic.Helpers.Logging.Log(ex);
                return(Content("InternalServerError"));
            }
        }
Пример #2
0
        private void SetDefaultVpnServer()
        {
            LibLogic.ActionLog.Log_BackgroundThread("Attempt to set default vpn server after payment made",
                                                    Helpers.SessionVariables.Instance.UserId);
            try
            {
                var details = new LibLogic.Accounts.ServerDetails();

                using (var sshNewServer = new LibLogic.Ssh.LiveSsh(SiteInfo.SshPort, SiteInfo.VpnSshUser, SiteInfo.VpnSshPassword))
                    using (var sshRevokeServer = new LibLogic.Ssh.LiveSsh(SiteInfo.SshPort, SiteInfo.VpnSshUser, SiteInfo.VpnSshPassword))
                        using (var sftp = new LibLogic.Ssh.LiveSftp(SiteInfo.SshPort, SiteInfo.VpnSshUser, SiteInfo.VpnSshPassword))
                        {
                            var cert = new CertsOpenVpnGenerateCommand(Helpers.SessionVariables.Instance.UserId,
                                                                       details.Info.First().VpnServerId, sshNewServer, sshRevokeServer, sftp);
                            cert.Execute();
                        }

                using (var sshNewServer = new LibLogic.Ssh.LiveSsh(SiteInfo.SshPort, SiteInfo.VpnSshUser, SiteInfo.VpnSshPassword))
                    using (var sshRevokeServer = new LibLogic.Ssh.LiveSsh(SiteInfo.SshPort, SiteInfo.VpnSshUser, SiteInfo.VpnSshPassword))
                    {
                        var pptp = new LibLogic.Ppp.ManagePPTP(Helpers.SessionVariables.Instance.UserId,
                                                               details.Info.First().VpnServerId, sshNewServer, sshRevokeServer);
                        pptp.AddUser();
                    }
            }
            catch (Exception ex)
            {
                LibLogic.Helpers.Logging.Log(ex);
                LibLogic.ActionLog.Log_BackgroundThread("Failed to set default vpn server after payment made", Helpers.SessionVariables.Instance.UserId);
            }
        }
Пример #3
0
        public Setup()
        {
            var details = new LibLogic.Accounts.ServerDetails();

            this.ServerInfo = details.Info;

            var pay = new LibLogic.Payments.Payment(Helpers.SessionVariables.Instance.UserId);

            ActiveAccount = !pay.IsExpired();


            var userServerDetails = new LibLogic.Accounts.UserServerDetails(Helpers.SessionVariables.Instance.UserId);

            if (userServerDetails.Info == null)
            {
                CurrentServer = "none";
                PptpIP        = "none";
                PptpPassword  = "******";
            }
            else
            {
                CurrentServer = userServerDetails.Info.VpnServerName + " - Region: " + userServerDetails.Info.RegionName;
                PptpIP        = userServerDetails.Info.Address;
                PptpPassword  = userServerDetails.Info.PptpPassword;
            }

            Username = Helpers.SessionVariables.Instance.Username;
        }