Пример #1
0
        private static void ConfigureServices(ApeCliOptions opts)
        {
            IServiceCollection serviceCollection = new ServiceCollection();

            serviceCollection.AddLogging();
            serviceCollection.AddSingleton(serviceCollection);

            if (opts.PcapProviderUri != null)
            {
                serviceCollection.AddSingleton <ICaptureDeviceFactory, CaptureDeviceFactory>();
                serviceCollection.AddSingleton <IPcapLoader, PcapLoader.PcapLoader>();
                serviceCollection.AddSingleton <IL7ConversationProvider, PcapL7ConversationProvider>();
                serviceCollection.AddSingleton(new PcapL7ConversationProviderOptions {
                    PcapUri = opts.PcapProviderUri
                });
            }
            // Setup for Cassandra repository
            else
            {
                serviceCollection.AddSingleton <IL7ConversationProvider, RepositoryL7ConversationProvider>();

                var dynamicExpressoInterpreter = new DynamicExpresso.Interpreter();
                Expression <Func <IL7ConversationEntity, Boolean> > l7ConversationFilterPredicate = null;

                if (opts.L7ConversationFilter != null)
                {
                    l7ConversationFilterPredicate = dynamicExpressoInterpreter
                                                    .ParseAsExpression <Func <IL7ConversationEntity, Boolean> >(opts.L7ConversationFilter, "l7c");
                }
                serviceCollection.AddSingleton(new RepositoryL7ConversationProviderOptions
                {
                    L7ConversationFilterPredicate = l7ConversationFilterPredicate
                });
            }

            if (opts.PrintSnooperExports == false)
            {
                serviceCollection.AddSingleton <ISnooperExportFacade, SnooperExportFacade>();
            }

            serviceCollection.AddSingleton <ICaptureFacade, CaptureFacade>();
            serviceCollection.AddSingleton <IL7ConversationFacade, L7ConversationFacade>();
            serviceCollection.AddSingleton <IL7ConversationFacade, L7ConversationFacade>();
            CassandraServiceInstaller.Install(serviceCollection, opts.CassandraKeyspace, opts.CassandraContactPoint);

            _services = serviceCollection.BuildServiceProvider();
        }
Пример #2
0
        private static void ConfigureServices(IServiceCollection services, ReassemblerCliOptions opts)
        {
            services.AddLogging();

            services.AddSingleton <IClusterSettings, ClusterSettings>(
                provider => new ClusterSettings
            {
                ClusterNodeHostname     = opts.ClusterNodeHostname,
                ClusterNodePort         = opts.ClusterNodePort,
                ClusterSeedNodeHostname = opts.ClusterSeedNodeHostname
            });

            services.AddSingleton <IHostedService, ReassemblerService>();

            ActorsServiceInstaller.Install(services);
            FacadesServiceInstaller.Install(services);

            if (opts.DevnullRepository)
            {
                DevNullServiceInstaller.Install(services);
            }
            else if (opts.CassandraRepository)
            {
                CassandraServiceInstaller.Install(services, opts.CassandraKeyspace, opts.CassandraContactPoint);
            }
            else
            {
                InMemoryServiceInstaller.Install(services);
            }

            if (opts.OutPcapDirectory != null)
            {
                services.AddSingleton <IPcapFacadeConfiguration>(new PcapFacadeConfiguration
                {
                    BaseDirectory = opts.OutPcapDirectory
                });
                services.AddSingleton <IPcapFacade, PcapFacade>();
            }
            else
            {
                services.AddSingleton <IPcapFacade, PcapDevnullFacade>();
            }
        }
Пример #3
0
        private static void ConfigureServices(IServiceCollection services, ReassemblerCliOptions opts)
        {
            services.AddLogging();

            services.AddSingleton <IClusterSettings, ClusterSettings>(
                provider => new ClusterSettings
            {
                ClusterNodeHostname     = opts.ClusterNodeHostname,
                ClusterNodePort         = opts.ClusterNodePort,
                ClusterSeedNodeHostname = opts.ClusterSeedNodeHostname
            });

            services.AddSingleton <IHostedService, ReassemblerService>();

            services.AddSingleton <ICaptureFacade, CaptureFacade>();
            services.AddSingleton <IL7ConversationFacade, L7ConversationFacade>();
            services.AddSingleton <ICaptureTrackingActorFactory, CaptureTrackingActorFactory>();
            services.AddSingleton <IRawPacketBatchParserActorFactory, RawPacketBatchParserActorFactory>();
            services.AddSingleton <ICaptureTrackingActorFactory, CaptureTrackingActorFactory>();
            services.AddSingleton <IL3ConversationTrackingActorFactory, L3ConversationTrackingActorFactory>();
            services.AddSingleton <IL4ConversationTrackingActorFactory, L4ConversationTrackingActorFactory>();
            services.AddSingleton <IL7ConversationStorageActorFactory, L7ConversationStorageActorFactory>();

            if (opts.DevnullRepository)
            {
                DevNullServiceInstaller.Install(services);
            }
            else if (opts.CassandraRepository)
            {
                CassandraServiceInstaller.Install(services, opts.CassandraKeyspace, opts.CassandraContactPoint);
            }
            else
            {
                InMemoryServiceInstaller.Install(services);
            }
        }
Пример #4
0
        private static void ConfigureServices(LoadBalancerCliOptions opts)
        {
            IServiceCollection services = new ServiceCollection();

            services.AddLogging();
            services.AddSingleton(services);
            services.AddSingleton(provider => provider);
            services.AddSingleton <IPcapLoader, PcapLoader.PcapLoader>();

            services.AddSingleton <LoadBalancerRunner>();
            services.AddSingleton <IAkkaSettings>(new AkkaSettings {
                IsDebug = opts.IsDebug
            });

            if (opts.Uri.Scheme == "rpcap")
            {
                services.AddSingleton <ICaptureDeviceFactory, CaptureLiveDeviceFactory>();
            }
            else
            {
                services.AddSingleton <ICaptureDeviceFactory, CaptureDeviceFactory>();
            }

            services.AddSingleton <ILoadBalancerRunner, LoadBalancerRunner>();
            services.AddSingleton <ILoadBalancerRunnerFactory, LoadBalancerRunnerFactory>();
            services.AddSingleton <IBatchLoader, BatchLoader>();
            services.AddSingleton <IBatchSender, BatchSender>();

            ActorsServiceInstaller.Install(services);
            FacadesServiceInstaller.Install(services);

            if (opts.Offline)
            {
                services.AddSingleton <IPacketIngestor, OfflineLoadBalancer>();
                services.AddSingleton <IOfflineLoadBalancerActorFactory, OfflineLoadBalancerActorFactory>();
            }
            else
            {
                services.AddSingleton <IPacketIngestor, OnlineLoadBalancer>();
                services.AddSingleton <IClusterSettings, ClusterSettings>(
                    provider => new ClusterSettings
                {
                    ClusterNodeHostname     = opts.ClusterNodeHostname,
                    ClusterNodePort         = opts.ClusterNodePort,
                    ClusterSeedNodeHostname = opts.ClusterSeedNodeHostname
                });
                services.AddSingleton <IClusterMember, OnlineLoadBalancer>();
                services.AddSingleton <IOnlineLoadBalancerActorFactory, OnlineLoadBalancerActorFactory>();
            }

            if (opts.DevnullRepository)
            {
                DevNullServiceInstaller.Install(services);
            }
            else if (opts.CassandraRepository)
            {
                CassandraServiceInstaller.Install(services, opts.CassandraKeyspace, opts.CassandraContactPoint);
            }
            // Not specified or InMemoryRepository selected
            else
            {
                InMemoryServiceInstaller.Install(services);
            }

            if (opts.OutPcapDirectory != null)
            {
                services.AddSingleton <IPcapFacadeConfiguration>(new PcapFacadeConfiguration
                {
                    BaseDirectory = opts.OutPcapDirectory
                });
                services.AddSingleton <IPcapFacade, PcapFacade>();
            }
            else
            {
                services.AddSingleton <IPcapFacade, PcapDevnullFacade>();
            }

            services.AddLogging(builder => builder.AddConsole());

            var serviceProvider = services.BuildServiceProvider();

            _loadBalancerRunnerFactory = serviceProvider.GetService <ILoadBalancerRunnerFactory>();
        }
Пример #5
0
        private static void ConfigureServices(LoadBalancerCliOptions opts)
        {
            IServiceCollection serviceCollection = new ServiceCollection();

            serviceCollection.AddLogging();
            serviceCollection.AddSingleton(serviceCollection);
            serviceCollection.AddSingleton(provider => provider);
            serviceCollection.AddSingleton <IPcapLoader, PcapLoader.PcapLoader>();

            serviceCollection.AddSingleton <LoadBalancerRunner>();
            serviceCollection.AddSingleton <IAkkaSettings>(new AkkaSettings {
                IsDebug = opts.IsDebug
            });

            if (opts.Uri.Scheme == "rpcap")
            {
                serviceCollection.AddSingleton <ICaptureDeviceFactory, CaptureLiveDeviceFactory>();
            }
            else
            {
                serviceCollection.AddSingleton <ICaptureDeviceFactory, CaptureDeviceFactory>();
            }

            serviceCollection.AddSingleton <ICaptureFacade, CaptureFacade>();
            serviceCollection.AddSingleton <IL7ConversationFacade, L7ConversationFacade>();

            serviceCollection.AddSingleton <ILoadBalancerRunner, LoadBalancerRunner>();
            serviceCollection.AddSingleton <ILoadBalancerRunnerFactory, LoadBalancerRunnerFactory>();
            serviceCollection.AddSingleton <IBatchLoader, BatchLoader>();
            serviceCollection.AddSingleton <IBatchSender, BatchSender>();
            serviceCollection.AddSingleton <IRawPacketBatchParserActorFactory, RawPacketBatchParserActorFactory>();
            serviceCollection.AddSingleton <ICaptureTrackingActorFactory, CaptureTrackingActorFactory>();
            serviceCollection.AddSingleton <IL3ConversationTrackingActorFactory, L3ConversationTrackingActorFactory>();
            serviceCollection.AddSingleton <IL4ConversationTrackingActorFactory, L4ConversationTrackingActorFactory>();
            serviceCollection.AddSingleton <IL7ConversationStorageActorFactory, L7ConversationStorageActorFactory>();

            if (opts.Offline)
            {
                serviceCollection.AddSingleton <IPacketIngestor, OfflineLoadBalancer>();
                serviceCollection.AddSingleton <IOfflineLoadBalancerActorFactory, OfflineLoadBalancerActorFactory>();
            }
            else
            {
                serviceCollection.AddSingleton <IPacketIngestor, OnlineLoadBalancer>();
                serviceCollection.AddSingleton <IClusterSettings, ClusterSettings>(
                    provider => new ClusterSettings
                {
                    ClusterNodeHostname     = opts.ClusterNodeHostname,
                    ClusterNodePort         = opts.ClusterNodePort,
                    ClusterSeedNodeHostname = opts.ClusterSeedNodeHostname
                });
                serviceCollection.AddSingleton <IClusterMember, OnlineLoadBalancer>();
                serviceCollection.AddSingleton <IOnlineLoadBalancerActorFactory, OnlineLoadBalancerActorFactory>();
            }

            if (opts.DevnullRepository)
            {
                DevNullServiceInstaller.Install(serviceCollection);
            }
            else if (opts.CassandraRepository)
            {
                CassandraServiceInstaller.Install(serviceCollection, opts.CassandraKeyspace, opts.CassandraContactPoint);
            }
            // Not specified or InMemoryRepository selected
            else
            {
                InMemoryServiceInstaller.Install(serviceCollection);
            }

            var services = serviceCollection.BuildServiceProvider();

            services.GetService <ILoggerFactory>().AddProvider(opts.IsDebug ?
                                                               new ConsoleLoggerProvider((s, level) => level >= LogLevel.Debug, true) :
                                                               new ConsoleLoggerProvider((s, level) => level >= LogLevel.Error, true));

            _loadBalancerRunnerFactory = services.GetService <ILoadBalancerRunnerFactory>();
        }