public StickyTcpServer(IPAddress address, StickyServerConfig config, ReportService reporter, ILogger logger) : base(address, config.Port) { Config = config; Reporter = reporter; Logger = logger; }
public StickyUpdServer(IPAddress address, StickyServerConfig config, IUdpProtocol protocol, ReportService reporter, ILogger logger) : base(address, config.Port) { Config = config; Protocol = protocol; Reporter = reporter; Logger = logger; }
private Task StopServerAsync(StickyServerConfig config) { if (!Servers.TryGetValue(config.Port, out var server)) { return(Task.CompletedTask); } server.Stop(); server.Dispose(); Servers.TryRemove(server.Port, out _); return(Task.CompletedTask); }
private async Task CreateAsync(CreateOptions options) { var existingConfig = Configuration.ServerConfigs.Where(x => x.Port == options.Port).FirstOrDefault(); if (existingConfig != null) { Logger.LogError($"Could not create StickyNet! This port is already occupied by another StickyNet!"); return; } var config = new StickyServerConfig(options.Port, options.Protocol, options.OutputPath, options.ConnectionTimeout); Logger.LogInformation($"Creating {config}"); await Configuration.AddServerConfigAsync(config); }
private Task StartServerAsync(StickyServerConfig config) { Logger.LogDebug("Found new StickyNet in config file..."); var ip = IPAddress.Any; var logger = LoggerFactory.CreateLogger($"StickyNet Port{config.Port} [{config.Protocol}]"); var server = config.Protocol switch { Protocol.None => (IStickyServer) new StickyTcpServer <NoneSession>(ip, config, Reporter, logger), Protocol.FTP => new StickyTcpServer <FtpSession>(ip, config, Reporter, logger), Protocol.SSH => new StickyTcpServer <SshSession>(ip, config, Reporter, logger), Protocol.Telnet => new StickyTcpServer <TelnetSession>(ip, config, Reporter, logger), _ => null }; Servers.TryAdd(server.Port, server); server.Start(); return(Task.CompletedTask); }