//--------------------------------------------------------------------------------------- int RemoveDevice() { if (RasEntry.Exists(Globals.vpnIsim, phoneBook.Path)) { this.phoneBook.Entries.Remove(Globals.vpnIsim); } PLog("Vpn Silindi"); return(1); }
static public bool IsConnectionEntryExist(BaseProxyServer ps) { string path = RasPhoneBook.GetPhoneBookPath(RasPhoneBookType.User); if (path != null && File.Exists(path)) { string name = ps.GetConnectionName(); return(RasEntry.Exists(name, path)); } else { return(false); } }
//--------------------------------------------------------------------------------------- int CreateDevice(int i) { PLog(phoneBook.Path, false); if (RasEntry.Exists(Globals.vpnIsim, phoneBook.Path)) { PLog("Önceki Vpn Siliniyor..."); DisconnectDevice(); RemoveDevice(); } RasEntry entry; if (Vpnlist[i].Protocol == "pptp") { entry = RasEntry.CreateVpnEntry( Globals.vpnIsim, Vpnlist[i].Ip, RasVpnStrategy.PptpFirst, #pragma warning disable CS0618 // 'RasDevice.GetDeviceByName(string, RasDeviceType)' is obsolete: 'This method will be removed in a future version, please use the GetDevices method to find the devices.' RasDevice.GetDeviceByName(Vpnlist[i].Protocol, RasDeviceType.Vpn)); #pragma warning restore CS0618 // 'RasDevice.GetDeviceByName(string, RasDeviceType)' is obsolete: 'This method will be removed in a future version, please use the GetDevices method to find the devices.' this.phoneBook.Entries.Add(entry); } else { entry = RasEntry.CreateVpnEntry( Globals.vpnIsim, Vpnlist[i].Ip, RasVpnStrategy.L2tpFirst, #pragma warning disable CS0618 // 'RasDevice.GetDeviceByName(string, RasDeviceType)' is obsolete: 'This method will be removed in a future version, please use the GetDevices method to find the devices.' RasDevice.GetDeviceByName(Vpnlist[i].Protocol, RasDeviceType.Vpn)); #pragma warning restore CS0618 // 'RasDevice.GetDeviceByName(string, RasDeviceType)' is obsolete: 'This method will be removed in a future version, please use the GetDevices method to find the devices.' entry.Options.UsePreSharedKey = true; this.phoneBook.Entries.Add(entry); foreach (RasEntry e in this.phoneBook.Entries) { if (e.PhoneNumber == Vpnlist[i].Ip) { e.UpdateCredentials(RasPreSharedKey.Client, Vpnlist[i].xl2tp); } } } PLog(this.phoneBook.Entries.Count + ". # IP:" + this.phoneBook.Entries[this.phoneBook.Entries.Count - 1].PhoneNumber); PLog("Vpn Created: " + Vpnlist[i].Protocol); return(1); }