/*
* Copyright (c) 2026 Proton AG
*
* This file is part of ProtonVPN.
*
* ProtonVPN is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ProtonVPN is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ProtonVPN. If not, see .
*/
using Autofac;
using ProtonVPN.Common.Installers.Extensions;
using ProtonVPN.Common.Legacy.OS.DeviceIds;
using ProtonVPN.Common.Legacy.OS.Net.Http;
using ProtonVPN.Common.Legacy.OS.Processes;
using ProtonVPN.Common.Legacy.Threading;
using ProtonVPN.Configurations.Contracts;
using ProtonVPN.EntityMapping.Installers;
using ProtonVPN.Files.Installers;
using ProtonVPN.IssueReporting.Installers;
using ProtonVPN.OperatingSystems.NRPT.Installers;
using ProtonVPN.OperatingSystems.Processes.Installers;
using ProtonVPN.OperatingSystems.Registries.Installers;
using ProtonVPN.OperatingSystems.Services.Contracts;
using ProtonVPN.OperatingSystems.Services.Installers;
using ProtonVPN.OperatingSystems.TaskScheduling.Installers;
using ProtonVPN.ProcessCommunication.Service.Installers;
using ProtonVPN.ProTun.Installers;
using ProtonVPN.Serialization.Installers;
using ProtonVPN.Service.ControllerRetries;
using ProtonVPN.Service.Driver;
using ProtonVPN.Service.Firewall;
using ProtonVPN.Service.ProcessCommunication;
using ProtonVPN.Service.Settings;
using ProtonVPN.Service.SplitTunneling;
using ProtonVPN.Service.StateMachine;
using ProtonVPN.Service.StateMachine.SideEffects;
using ProtonVPN.Service.Update;
using ProtonVPN.Service.Vpn;
using ProtonVPN.Vpn.Connection;
using Module = Autofac.Module;
namespace ProtonVPN.Service.Start;
internal class ServiceModule : Module
{
protected override void Load(ContainerBuilder builder)
{
base.Load(builder);
builder.RegisterType().SingleInstance();
builder.RegisterType().AsImplementedInterfaces().SingleInstance();
builder.RegisterType().AsImplementedInterfaces().SingleInstance();
builder.RegisterType().AsImplementedInterfaces().SingleInstance();
builder.Register(c => new CalloutDriver(c.Resolve().Get(c.Resolve().CalloutServiceName)))
.AsImplementedInterfaces()
.AsSelf()
.SingleInstance();
builder.RegisterType().AsImplementedInterfaces().SingleInstance();
ProtonVPN.Vpn.Config.Module vpnModule = new();
vpnModule.Load(builder);
builder.Register(_ => new SerialTaskQueue()).As().SingleInstance();
builder.RegisterType().AsImplementedInterfaces().SingleInstance();
builder.RegisterType().SingleInstance();
builder.RegisterType().AsImplementedInterfaces().SingleInstance();
builder.RegisterType().AsImplementedInterfaces().SingleInstance();
builder.RegisterType().AsImplementedInterfaces().SingleInstance();
builder.RegisterType().AsImplementedInterfaces().SingleInstance();
builder.RegisterType().As().SingleInstance();
builder.RegisterType().AsImplementedInterfaces().SingleInstance();
builder.RegisterType().AsImplementedInterfaces().SingleInstance();
builder.RegisterType().AsImplementedInterfaces().SingleInstance();
builder.RegisterType().AsImplementedInterfaces().SingleInstance();
builder.RegisterType().AsImplementedInterfaces().AsSelf().SingleInstance();
builder.RegisterType().AsSelf().SingleInstance();
builder.RegisterType().AsImplementedInterfaces().SingleInstance();
builder.RegisterType().As().SingleInstance();
builder.RegisterType().AsImplementedInterfaces().SingleInstance();
builder.RegisterType().AsImplementedInterfaces().SingleInstance();
builder.RegisterType().SingleInstance();
builder.RegisterType().AsImplementedInterfaces().SingleInstance();
builder.RegisterType().AsImplementedInterfaces().SingleInstance();
builder.RegisterType().AsImplementedInterfaces().SingleInstance();
builder.RegisterType().AsImplementedInterfaces().SingleInstance();
builder.RegisterType().AsImplementedInterfaces().SingleInstance();
builder.RegisterType().AsImplementedInterfaces().SingleInstance();
builder.RegisterType().AsImplementedInterfaces().SingleInstance();
RegisterModules(builder);
}
private void RegisterModules(ContainerBuilder builder)
{
builder.RegisterAssemblyModule()
.RegisterAssemblyModule()
.RegisterAssemblyModule()
.RegisterAssemblyModule()
.RegisterAssemblyModule()
.RegisterAssemblyModule()
.RegisterAssemblyModule()
.RegisterAssemblyModule()
.RegisterAssemblyModule()
.RegisterAssemblyModule()
.RegisterAssemblyModule()
.RegisterAssemblyModule();
}
}