Example #1
0
        public async Task Disconnect(string id)
        {
            var vpnId = VpnId.Parse(id);
            var stats = await VpnCli.GetStats();

            if (stats.Server == vpnId.Server)
            {
                await VpnCli.Disconnect();
            }
        }
Example #2
0
        public async Task <IPAddress> GetIpAddress(string id)
        {
            var vpnId = VpnId.Parse(id);
            var stats = await VpnCli.GetStats();

            if (stats.Server == vpnId.Server && IPAddress.TryParse(stats.Ip, out var ipaddress))
            {
                return(ipaddress);
            }
            return(IPAddress.Any);
        }
Example #3
0
        public async Task <VpnStatus> GetStatus(string id)
        {
            var vpnId = VpnId.Parse(id);
            var stats = await VpnCli.GetStats();

            if (stats.Server == vpnId.Server)
            {
                if (Enum.TryParse <VpnStatus>(stats.State, out var status))
                {
                    return(status);
                }
                return(VpnStatus.Unknown);
            }
            return(VpnStatus.Disconnected);
        }
Example #4
0
 public async Task Connect(string id)
 {
     var vpnId = VpnId.Parse(id);
     await VpnCli.Connect(vpnId.Name, $"CiscoAnyConnect\\{vpnId.Name}.txt");
 }