diff --git a/cmpctircd/IRCd.cs b/cmpctircd/IRCd.cs index 3328a6e..bc132f3 100644 --- a/cmpctircd/IRCd.cs +++ b/cmpctircd/IRCd.cs @@ -10,6 +10,7 @@ public class IRCd { private readonly ISocketListenerFactory socketListenerFactory; + private readonly ISocketConnectorFactory socketConnectorFactory; private readonly IList Listeners = new List(); public readonly IList Connectors = new List(); public PacketManager PacketManager { get; } @@ -51,10 +52,11 @@ public class IRCd { public List Clients => ClientLists.SelectMany(clientList => clientList).ToList(); public List Servers => ServerLists.SelectMany(serverList => serverList).ToList(); - public IRCd(Log log, CmpctConfigurationSection config, IServiceProvider services, ISocketListenerFactory socketListenerFactory) { + public IRCd(Log log, CmpctConfigurationSection config, IServiceProvider services, ISocketListenerFactory socketListenerFactory, ISocketConnectorFactory socketConnectorFactory) { this.Log = log; this.Config = config; this.socketListenerFactory = socketListenerFactory; + this.socketConnectorFactory = socketConnectorFactory; // Interpret the ConfigData SID = config.SID; @@ -112,7 +114,7 @@ public void Run() { if (server.IsOutbound) { // tag with outbound="true" // We want to connect out to this server, not have them connect to us - var sc = new SocketConnector(this, server); + var sc = socketConnectorFactory.CreateSocketConnector(this, server); Log.Info($"==> Connecting to: {server.Destination}:{server.Port} ({server.Host}) ({(server.IsTls ? "TLS" : "Plain" )})"); Connectors.Add(sc); diff --git a/cmpctircd/Program.cs b/cmpctircd/Program.cs index 301312e..7176627 100644 --- a/cmpctircd/Program.cs +++ b/cmpctircd/Program.cs @@ -29,6 +29,7 @@ static IHostBuilder CreateHostBuilder(string[] args) { services.AddScoped(sp => sp.GetRequiredService().Sender as Client); services.AddScoped(sp => sp.GetRequiredService().Sender as Server); services.AddTransient(); + services.AddTransient(); services.AddHostedService(); }); }