private void SetDefaultVpnServer() { Majorsilence.Vpn.Logic.ActionLog.Log_BackgroundThread("Attempt to set default vpn server after payment made", sessionInstance.UserId); try { var details = new Majorsilence.Vpn.Logic.Accounts.ServerDetails(); using (var sshNewServer = new Majorsilence.Vpn.Logic.Ssh.LiveSsh(SiteInfo.SshPort, SiteInfo.VpnSshUser, SiteInfo.VpnSshPassword)) using (var sshRevokeServer = new Majorsilence.Vpn.Logic.Ssh.LiveSsh(SiteInfo.SshPort, SiteInfo.VpnSshUser, SiteInfo.VpnSshPassword)) using (var sftp = new Majorsilence.Vpn.Logic.Ssh.LiveSftp(SiteInfo.SshPort, SiteInfo.VpnSshUser, SiteInfo.VpnSshPassword)) { var cert = new CertsOpenVpnGenerateCommand(sessionInstance.UserId, details.Info.First().VpnServerId, sshNewServer, sshRevokeServer, sftp); cert.Execute(); } using (var sshNewServer = new Majorsilence.Vpn.Logic.Ssh.LiveSsh(SiteInfo.SshPort, SiteInfo.VpnSshUser, SiteInfo.VpnSshPassword)) using (var sshRevokeServer = new Majorsilence.Vpn.Logic.Ssh.LiveSsh(SiteInfo.SshPort, SiteInfo.VpnSshUser, SiteInfo.VpnSshPassword)) { var pptp = new Majorsilence.Vpn.Logic.Ppp.ManagePPTP(sessionInstance.UserId, details.Info.First().VpnServerId, sshNewServer, sshRevokeServer); pptp.AddUser(); } } catch (Exception ex) { Majorsilence.Vpn.Logic.Helpers.Logging.Log(ex); Majorsilence.Vpn.Logic.ActionLog.Log_BackgroundThread("Failed to set default vpn server after payment made", sessionInstance.UserId); } }
public ContentResult Servers() { try { int userid = -1; if (!IsAuthenticateUserWithToken(this.HttpContext, out userid)) { Response.StatusCode = (int)System.Net.HttpStatusCode.Forbidden; Majorsilence.Vpn.Logic.Helpers.Logging.Log("IsAuthenticateUserWithToken is false", false); return(Content("Unauthorized")); } } catch (Exception ex) { Response.StatusCode = (int)System.Net.HttpStatusCode.InternalServerError; Majorsilence.Vpn.Logic.Helpers.Logging.Log(ex); return(Content("InternalServerError " + ex.Message + ex.StackTrace)); } try { var details = new Majorsilence.Vpn.Logic.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; Majorsilence.Vpn.Logic.Helpers.Logging.Log(ex); return(Content("InternalServerError")); } }
public Setup(int userid, string username) { var details = new Majorsilence.Vpn.Logic.Accounts.ServerDetails(); this.ServerInfo = details.Info; var pay = new Majorsilence.Vpn.Logic.Payments.Payment(userid); ActiveAccount = !pay.IsExpired(); var userServerDetails = new Majorsilence.Vpn.Logic.Accounts.UserServerDetails(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 = username; }