public FilterServiceProvider() { Filter.Platform.Mac.Platform.Init(); PlatformTypes.Register <IPlatformDns>((arr) => new MacPlatformDns()); PlatformTypes.Register <IWifiManager>((arr) => new MacWifiManager()); PlatformTypes.Register <IPlatformTrust>((arr) => new MacTrustManager()); PlatformTypes.Register <ISystemServices>((arr) => new MacSystemServices()); commonProvider = new CommonFilterServiceProvider(); }
private void OnExtension(CommonFilterServiceProvider provider) { IPCServer server = provider.IPCServer; IPathProvider paths = PlatformTypes.New <IPathProvider>(); Task.Run(async() => { ConnectivityCheck.Accessible accessible = ConnectivityCheck.Accessible.Yes; try { List <ConflictReason> conflicts = ConflictDetection.SearchConflictReason(); server.Send <List <ConflictReason> >(IpcCall.ConflictsDetected, conflicts); IFilterAgent agent = PlatformTypes.New <IFilterAgent>(); accessible = agent.CheckConnectivity(); } catch (Exception ex) { m_logger.Error(ex, "Failed to check connectivity."); } try { WindowsDiverter diverter = new WindowsDiverter(14301, 14301, 14301, 14301); diverter.ConfirmDenyFirewallAccess = this.OnAppFirewallCheck; diverter.Start(1, () => { m_logger.Info("Diverter was started successfully."); IFilterAgent agent = PlatformTypes.New <IFilterAgent>(); ConnectivityCheck.Accessible afterDiverter = agent.CheckConnectivity(); if (accessible == ConnectivityCheck.Accessible.Yes && afterDiverter != ConnectivityCheck.Accessible.Yes) { server.Send <bool>(IpcCall.InternetAccessible, false); } else { server.Send <bool>(IpcCall.InternetAccessible, true); } }); } catch (Exception ex) { m_logger.Error($"Error occurred while starting the diverter."); LoggerUtil.RecursivelyLogException(m_logger, ex); } }); }
/// <summary> /// Default ctor. /// </summary> public FilterServiceProvider() { AppDomain.CurrentDomain.UnhandledException += (sender, e) => { if (m_logger != null) { m_logger.Error((Exception)e.ExceptionObject); } else { File.WriteAllText("filterserviceprovider-unhandled-exception.log", $"Exception occurred: {((Exception)e.ExceptionObject).Message}"); } }; PlatformTypes.Register <IPlatformDns>((arr) => new WindowsDns()); PlatformTypes.Register <IWifiManager>((arr) => new WindowsWifiManager()); PlatformTypes.Register <IPlatformTrust>((arr) => new TrustManager()); PlatformTypes.Register <ISystemServices>((arr) => new WindowsSystemServices(this)); PlatformTypes.Register <IVersionProvider>((arr) => new VersionProvider()); Citadel.Core.Windows.Platform.Init(); m_provider = new CommonFilterServiceProvider(OnExtension); if (BitConverter.IsLittleEndian) { m_httpAltPort = (ushort)IPAddress.HostToNetworkOrder((short)8080); m_httpsAltPort = (ushort)IPAddress.HostToNetworkOrder((short)8443); m_httpsStandardPort = (ushort)IPAddress.HostToNetworkOrder((short)443); m_httpStandardPort = (ushort)IPAddress.HostToNetworkOrder((short)80); } else { m_httpAltPort = ((ushort)8080); m_httpsAltPort = ((ushort)8443); m_httpsStandardPort = ((ushort)443); m_httpStandardPort = ((ushort)80); } }