Пример #1
0
        public void EnableLeakProtection(FirewallParams firewallParams)
        {
            PermitOpenVpnServerAddress(firewallParams.ServerIp);

            if (firewallParams.DnsLeakOnly == _lastParams.DnsLeakOnly && LeakProtectionEnabled)
            {
                return;
            }

            _calloutDriver.Start();

            try
            {
                _logger.Info("Firewall: Blocking internet");

                var tapInterfaceIndex = _networkInterfaces.InterfaceIndex(_config.OpenVpn.TapAdapterDescription, _config.OpenVpn.TapAdapterId);
                EnableDnsLeakProtection(tapInterfaceIndex);

                if (firewallParams.DnsLeakOnly)
                {
                    DisableBaseProtection();
                }
                else
                {
                    EnableBaseLeakProtection(tapInterfaceIndex);
                }

                LeakProtectionEnabled = true;

                _logger.Info("Firewall: Internet blocked");
            }
            catch (NetworkFilterException ex)
            {
                _logger.Error(ex);
            }

            _lastParams = firewallParams;
        }
Пример #2
0
 private uint GetTapInterfaceIndex()
 {
     return(_networkInterfaces.InterfaceIndex(
                _config.OpenVpn.TapAdapterDescription,
                _config.OpenVpn.TapAdapterId));
 }