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; }
private uint GetTapInterfaceIndex() { return(_networkInterfaces.InterfaceIndex( _config.OpenVpn.TapAdapterDescription, _config.OpenVpn.TapAdapterId)); }