From 0e75d9e7fdc2f35c0862994cb298f1560281cec0 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sat, 15 May 2021 14:57:58 -0500 Subject: use proxy options when instantiating SoulseekClient --- src/slskd/Service.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/slskd/Service.cs') diff --git a/src/slskd/Service.cs b/src/slskd/Service.cs index 7f5c1901..d7ea664e 100644 --- a/src/slskd/Service.cs +++ b/src/slskd/Service.cs @@ -54,11 +54,18 @@ namespace slskd RoomTracker = roomTracker; SharedFileCache = sharedFileCache; + var proxyOptions = new ProxyOptions( + address: Options.Soulseek.Connection.Proxy.Address, + port: Options.Soulseek.Connection.Proxy.Port, + username: Options.Soulseek.Connection.Proxy.Username, + password: Options.Soulseek.Connection.Proxy.Password); + var connectionOptions = new ConnectionOptions( readBufferSize: Options.Soulseek.Connection.Buffer.Read, writeBufferSize: Options.Soulseek.Connection.Buffer.Write, connectTimeout: Options.Soulseek.Connection.Timeout.Connect, - inactivityTimeout: Options.Soulseek.Connection.Timeout.Inactivity); + inactivityTimeout: Options.Soulseek.Connection.Timeout.Inactivity, + proxyOptions: proxyOptions); var clientOptions = new SoulseekClientOptions( listenPort: Options.Soulseek.ListenPort, @@ -72,6 +79,7 @@ namespace slskd serverConnectionOptions: connectionOptions, peerConnectionOptions: connectionOptions, transferConnectionOptions: connectionOptions, + distributedConnectionOptions: connectionOptions, userInfoResponseResolver: UserInfoResponseResolver, browseResponseResolver: BrowseResponseResolver, directoryContentsResponseResolver: DirectoryContentsResponseResolver, -- cgit v1.2.3 From 00cd66c8e74488244220f1c5e6cbb59253c022b1 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sun, 16 May 2021 23:28:11 -0500 Subject: don't set proxy options if none are supplied. log info when using proxy --- src/slskd/Service.cs | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'src/slskd/Service.cs') diff --git a/src/slskd/Service.cs b/src/slskd/Service.cs index d7ea664e..8daab772 100644 --- a/src/slskd/Service.cs +++ b/src/slskd/Service.cs @@ -54,11 +54,16 @@ namespace slskd RoomTracker = roomTracker; SharedFileCache = sharedFileCache; - var proxyOptions = new ProxyOptions( - address: Options.Soulseek.Connection.Proxy.Address, - port: Options.Soulseek.Connection.Proxy.Port, - username: Options.Soulseek.Connection.Proxy.Username, - password: Options.Soulseek.Connection.Proxy.Password); + ProxyOptions proxyOptions = default; + + if (UsingProxy) + { + proxyOptions = new ProxyOptions( + address: Options.Soulseek.Connection.Proxy.Address, + port: Options.Soulseek.Connection.Proxy.Port.Value, + username: Options.Soulseek.Connection.Proxy.Username, + password: Options.Soulseek.Connection.Proxy.Password); + } var connectionOptions = new ConnectionOptions( readBufferSize: Options.Soulseek.Connection.Buffer.Read, @@ -129,11 +134,17 @@ namespace slskd private IRoomTracker RoomTracker { get; set; } private ISharedFileCache SharedFileCache { get; set; } private ITransferTracker TransferTracker { get; set; } + private bool UsingProxy => !string.IsNullOrWhiteSpace(Options.Soulseek.Connection.Proxy.Address) && Options.Soulseek.Connection.Proxy.Port.HasValue; public async Task StartAsync(CancellationToken cancellationToken) { await Client.ConnectAsync(Options.Soulseek.Username, Options.Soulseek.Password).ConfigureAwait(false); + if (UsingProxy) + { + Logger.Information($"Using Proxy {Options.Soulseek.Connection.Proxy.Address}:{Options.Soulseek.Connection.Proxy.Port}"); + } + Logger.Information("Connected and logged in as {Username}", Options.Soulseek.Username); Logger.Information("Listening on port {Port}", Options.Soulseek.ListenPort); Logger.Information("Client started"); @@ -403,7 +414,7 @@ namespace slskd { var info = new UserInfo( description: $"Soulseek.NET Web Example! also, your username is {username}, and IP endpoint is {endpoint}", - picture: System.IO.File.ReadAllBytes(@"slsk_bird.jpg"), + picture: Array.Empty(), uploadSlots: 1, queueLength: 0, hasFreeUploadSlot: false); -- cgit v1.2.3