The FilteredAppModel class represents a system-local application that has performed socket IO over standard HTTP ports, including port 80 and port 443. Such applications are represented by this class, and presented to the user via a special control where the user can specify that the application should or should not have its port 80 and port 443 forced through the filtering process.
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            JObject jo = JObject.Load(reader);

            var appPath = jo["ApplicationPath"].ToObject<string>();
            var filter = jo["Filter"].ToObject<bool>();

            var model = new FilteredAppModel(appPath, filter);

            return model;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Callback for the Engine to determine if the given binary should be filtered or not. The
        /// reason why this callback is named FirewallCheck is because the transparent proxy that the
        /// Engine employs could theoretically allow an application access to the internet even when
        /// the installed firewall has not necessarily given permission for this particular
        /// application to have internet access. This also why users are told this in plain text in
        /// the UI component for enabling/disabling filtering on applications.
        /// </summary>
        /// <param name="binaryFullPath">
        /// </param>
        /// <returns>
        /// True if the supplied binary should have its traffic filtered, false otherwise.
        /// </returns>
        private bool FirewallCheck(string binaryFullPath)
        {
            // Note that returning "false" doesn't mean the app doesn't get to access the internet, it
            // means it won't be diverted through our proxy. So we can also choose which applications we
            // want to filter as well.

            FilteredAppModel famdl;
            if (m_filteredApplicationsTable.TryGetValue(binaryFullPath, out famdl))
            {
                if (famdl != null)
                {
                    return famdl.Filter;
                }
            }

            // No entry for this binary. Create it and push it to the dashboard collection for the user
            // to have.
            try
            {
                famdl = new FilteredAppModel(binaryFullPath, false);

                if (m_filteredApplicationsTable.TryAdd(binaryFullPath, famdl))
                {
                    Current.Dispatcher.BeginInvoke(
                        System.Windows.Threading.DispatcherPriority.Normal,
                        (Action)delegate ()
                        {
                            m_viewModelDashboard.FilteredApplications.Add(new FilteredAppViewModel(famdl));
                        }
                    );
                }
                else
                {
                    m_logger.Error("Error pushing new binary {0} to collection.");
                }
            }
            catch (ArgumentException ae)
            {
                m_logger.Error("Got erreor while constructing new FilteredAppModel: {0}.", ae.Message);
            }

            return false;
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="model"></param>
        /// <exception cref="ArgumentException">
        /// </exception>
        public FilteredAppViewModel(FilteredAppModel model)
        {
            m_model = model;

            if (m_model == null)
            {
                throw new ArgumentException("Expected valid FilteredAppModel instance.");
            }
        }