From 800c6e5400d40a8ce79c467f4d97e701a241a036 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Wed, 11 May 2022 09:37:27 -0500 Subject: Update README.md --- README.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index ea7024c4..85b04636 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,13 @@ # slskd -slskd is a modern client-server application for the Soulseek file sharing network. +[![Build](https://github.com/slskd/slskd/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/slskd/slskd/actions/workflows/ci.yml) +[![Docker Pulls](https://img.shields.io/docker/pulls/slskd/slskd)](https://hub.docker.com/r/slskd/slskd) +[![GitHub all releases](https://img.shields.io/github/downloads/slskd/slskd/total)](https://github.com/slskd/slskd/releases) +[![Activity](https://img.shields.io/github/commit-activity/m/slskd/slskd)](https://github.com/slskd/slskd/pulse) +[![Contributors](https://img.shields.io/github/contributors/slskd/slskd)](https://github.com/slskd/slskd/graphs/contributors) +[![Discord](https://img.shields.io/discord/971446666257391616?logo=discord)](https://slskd.org/discord) + +A modern client-server application for the Soulseek file sharing network. ## Quick Start -- cgit v1.2.3 From 79ae50e6042ab5127c74a1a35abd753ba5d94328 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Wed, 11 May 2022 09:59:19 -0500 Subject: Update README.md --- README.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 85b04636..ddd40f91 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,11 @@ # slskd - -[![Build](https://github.com/slskd/slskd/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/slskd/slskd/actions/workflows/ci.yml) -[![Docker Pulls](https://img.shields.io/docker/pulls/slskd/slskd)](https://hub.docker.com/r/slskd/slskd) -[![GitHub all releases](https://img.shields.io/github/downloads/slskd/slskd/total)](https://github.com/slskd/slskd/releases) -[![Activity](https://img.shields.io/github/commit-activity/m/slskd/slskd)](https://github.com/slskd/slskd/pulse) -[![Contributors](https://img.shields.io/github/contributors/slskd/slskd)](https://github.com/slskd/slskd/graphs/contributors) -[![Discord](https://img.shields.io/discord/971446666257391616?logo=discord)](https://slskd.org/discord) +[![Build](https://img.shields.io/github/checks-status/slskd/slskd/master?label=build&logo=github)](https://github.com/slskd/slskd/actions/workflows/ci.yml) +[![Docker Pulls](https://img.shields.io/docker/pulls/slskd/slskd?logo=docker)](https://hub.docker.com/r/slskd/slskd) +[![GitHub all releases](https://img.shields.io/github/downloads/slskd/slskd/total?logo=github)](https://github.com/slskd/slskd/releases) +[![Activity](https://img.shields.io/github/commit-activity/m/slskd/slskd?logo=github)](https://github.com/slskd/slskd/pulse) +[![Contributors](https://img.shields.io/github/contributors/slskd/slskd?logo=github)](https://github.com/slskd/slskd/graphs/contributors) +[![Discord](https://img.shields.io/discord/971446666257391616?label=Discord&logo=discord)](https://slskd.org/discord) +[![Matrix](https://img.shields.io/badge/Matrix-%3F%20online-na?logo=matrix&color=brightgreen)](https://matrix.to/#/#slskd:matrix.org) A modern client-server application for the Soulseek file sharing network. -- cgit v1.2.3 From caf3eb3c4c15a21c65549c4d360bf5415abe57bb Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Wed, 11 May 2022 10:31:01 -0500 Subject: Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ddd40f91..6dcf1bf4 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ [![Activity](https://img.shields.io/github/commit-activity/m/slskd/slskd?logo=github)](https://github.com/slskd/slskd/pulse) [![Contributors](https://img.shields.io/github/contributors/slskd/slskd?logo=github)](https://github.com/slskd/slskd/graphs/contributors) [![Discord](https://img.shields.io/discord/971446666257391616?label=Discord&logo=discord)](https://slskd.org/discord) -[![Matrix](https://img.shields.io/badge/Matrix-%3F%20online-na?logo=matrix&color=brightgreen)](https://matrix.to/#/#slskd:matrix.org) +[![Matrix](https://img.shields.io/badge/Matrix-%3F%20online-na?logo=matrix&color=brightgreen)](https://slskd.org/matrix) A modern client-server application for the Soulseek file sharing network. -- cgit v1.2.3 From f314ff92c8ce41a94944019801f391deefc4cc1c Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Thu, 12 May 2022 07:09:35 -0500 Subject: Update README.md --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 6dcf1bf4..33b8e234 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ # slskd -[![Build](https://img.shields.io/github/checks-status/slskd/slskd/master?label=build&logo=github)](https://github.com/slskd/slskd/actions/workflows/ci.yml) + +[![Build](https://img.shields.io/github/workflow/status/slskd/slskd/CI/master?logo=github)](https://github.com/slskd/slskd/actions/workflows/ci.yml) [![Docker Pulls](https://img.shields.io/docker/pulls/slskd/slskd?logo=docker)](https://hub.docker.com/r/slskd/slskd) [![GitHub all releases](https://img.shields.io/github/downloads/slskd/slskd/total?logo=github)](https://github.com/slskd/slskd/releases) [![Activity](https://img.shields.io/github/commit-activity/m/slskd/slskd?logo=github)](https://github.com/slskd/slskd/pulse) -- cgit v1.2.3 From 04b4ef849fde9d91336e112b778219df43767fa3 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Fri, 13 May 2022 09:22:58 -0500 Subject: replace headers on rewritten responses --- .../Common/Middleware/HTMLInjectionMiddleware.cs | 22 +++++++++++++++------- .../Common/Middleware/HTMLRewriteMiddleware.cs | 21 ++++++++++++++------- 2 files changed, 29 insertions(+), 14 deletions(-) diff --git a/src/slskd/Common/Middleware/HTMLInjectionMiddleware.cs b/src/slskd/Common/Middleware/HTMLInjectionMiddleware.cs index 217b2bce..3e2c003a 100644 --- a/src/slskd/Common/Middleware/HTMLInjectionMiddleware.cs +++ b/src/slskd/Common/Middleware/HTMLInjectionMiddleware.cs @@ -69,16 +69,14 @@ namespace slskd { context.Request.Headers.TryGetValue("accept", out var accept); var requestedTypes = accept.ToString().Split(','); - var injectableTypes = new[] { "text/html", "application/xhtml + xml", "application/xml" }; - - var isApiRoute = context.Request.Path.ToString().StartsWith("/api"); - var isGET = context.Request.Method == "GET"; - var isInjectableType = requestedTypes .Intersect(injectableTypes, StringComparer.InvariantCultureIgnoreCase) .Any(); + var isApiRoute = context.Request.Path.ToString().StartsWith("/api"); + var isGET = context.Request.Method == "GET"; + if (!isApiRoute && isGET && isInjectableType) { var originalStream = context.Response.Body; @@ -93,15 +91,25 @@ namespace slskd if (context.Response.StatusCode == 200) { // something downstream responded with a 200, meaning there's data in the body - // we need to read it, so we can reset then play it back with the appended HTML + // we need to read it, so we can reset then play it back with the modified HTML context.Response.Body.Seek(0, SeekOrigin.Begin); var body = await new StreamReader(context.Response.Body).ReadToEndAsync(); + var headers = context.Response.Headers + .ToDictionary(kvp => kvp.Key, kvp => kvp.Value) + .Where(kvp => !string.Equals(kvp.Key, "Content-Length", StringComparison.InvariantCultureIgnoreCase)); + context.Response.Clear(); + + foreach (var header in headers) + { + context.Response.Headers.Add(header); + } + await context.Response.WriteAsync(body + HTML); } - // rewind the stream we injected to the beginning, then replay the data to the + // rewind the stream we injected to the beginning, then replay the data to the // original stream stream.Seek(0, SeekOrigin.Begin); await stream.CopyToAsync(originalStream); diff --git a/src/slskd/Common/Middleware/HTMLRewriteMiddleware.cs b/src/slskd/Common/Middleware/HTMLRewriteMiddleware.cs index a15ba1e0..4b90d6da 100644 --- a/src/slskd/Common/Middleware/HTMLRewriteMiddleware.cs +++ b/src/slskd/Common/Middleware/HTMLRewriteMiddleware.cs @@ -74,16 +74,14 @@ namespace slskd { context.Request.Headers.TryGetValue("accept", out var accept); var requestedTypes = accept.ToString().Split(','); - - var rewriteableType = new[] { "text/html", "application/xhtml + xml", "application/xml" }; + var injectableTypes = new[] { "text/html", "application/xhtml + xml", "application/xml" }; + var isRewriteableType = requestedTypes + .Intersect(injectableTypes, StringComparer.InvariantCultureIgnoreCase) + .Any(); var isApiRoute = context.Request.Path.ToString().StartsWith("/api"); var isGET = context.Request.Method == "GET"; - var isRewriteableType = requestedTypes - .Intersect(rewriteableType, StringComparer.InvariantCultureIgnoreCase) - .Any(); - if (!isApiRoute && isGET && isRewriteableType) { var originalStream = context.Response.Body; @@ -98,12 +96,21 @@ namespace slskd if (context.Response.StatusCode == 200) { // something downstream responded with a 200, meaning there's data in the body - // we need to read it, so we can reset then play it back with the appended HTML + // we need to read it, so we can reset then play it back with the modified HTML context.Response.Body.Seek(0, SeekOrigin.Begin); var body = await new StreamReader(context.Response.Body).ReadToEndAsync(); + var headers = context.Response.Headers + .ToDictionary(kvp => kvp.Key, kvp => kvp.Value) + .Where(kvp => !string.Equals(kvp.Key, "Content-Length", StringComparison.InvariantCultureIgnoreCase)); + context.Response.Clear(); + foreach (var header in headers) + { + context.Response.Headers.Add(header); + } + await context.Response.WriteAsync(Regex.Replace(body, Pattern, Replacement)); } -- cgit v1.2.3 From 0241c9fd6917862ae47eb57d7e5ac364989229ff Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Fri, 13 May 2022 10:34:31 -0500 Subject: Update README.md --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index 33b8e234..e0f2e236 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,7 @@ [![Build](https://img.shields.io/github/workflow/status/slskd/slskd/CI/master?logo=github)](https://github.com/slskd/slskd/actions/workflows/ci.yml) [![Docker Pulls](https://img.shields.io/docker/pulls/slskd/slskd?logo=docker)](https://hub.docker.com/r/slskd/slskd) -[![GitHub all releases](https://img.shields.io/github/downloads/slskd/slskd/total?logo=github)](https://github.com/slskd/slskd/releases) -[![Activity](https://img.shields.io/github/commit-activity/m/slskd/slskd?logo=github)](https://github.com/slskd/slskd/pulse) +[![GitHub all releases](https://img.shields.io/github/downloads/slskd/slskd/total?logo=github&color=brightgreen)](https://github.com/slskd/slskd/releases) [![Contributors](https://img.shields.io/github/contributors/slskd/slskd?logo=github)](https://github.com/slskd/slskd/graphs/contributors) [![Discord](https://img.shields.io/discord/971446666257391616?label=Discord&logo=discord)](https://slskd.org/discord) [![Matrix](https://img.shields.io/badge/Matrix-%3F%20online-na?logo=matrix&color=brightgreen)](https://slskd.org/matrix) -- cgit v1.2.3 From 63f49e40eee9aaf09c7a105937155507ba1761c8 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sat, 14 May 2022 12:52:34 -0500 Subject: skip tests in Docker build --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index a1b2a921..b3b375ae 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,7 +7,7 @@ WORKDIR /slskd COPY bin bin/. COPY src/web src/web/. -RUN sh ./bin/build --web-only --version $VERSION +RUN sh ./bin/build --web-only --skip-tests --version $VERSION # build, test, and publish application binaries # note: this needs to be pinned to an amd64 image in order to publish armv7 binaries @@ -26,7 +26,7 @@ COPY tests tests/. COPY --from=web /slskd/src/web/build /slskd/src/slskd/wwwroot/. -RUN bash ./bin/build --dotnet-only --version $VERSION +#RUN bash ./bin/build --dotnet-only --version $VERSION RUN bash ./bin/publish --no-prebuild --platform $TARGETPLATFORM --version $VERSION --output ../../dist/${TARGETPLATFORM} -- cgit v1.2.3 From a446e70f962ff4c307540cfcad838a3dc12668d7 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sat, 14 May 2022 13:38:53 -0500 Subject: add tests back in --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index b3b375ae..a1b2a921 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,7 +7,7 @@ WORKDIR /slskd COPY bin bin/. COPY src/web src/web/. -RUN sh ./bin/build --web-only --skip-tests --version $VERSION +RUN sh ./bin/build --web-only --version $VERSION # build, test, and publish application binaries # note: this needs to be pinned to an amd64 image in order to publish armv7 binaries @@ -26,7 +26,7 @@ COPY tests tests/. COPY --from=web /slskd/src/web/build /slskd/src/slskd/wwwroot/. -#RUN bash ./bin/build --dotnet-only --version $VERSION +RUN bash ./bin/build --dotnet-only --version $VERSION RUN bash ./bin/publish --no-prebuild --platform $TARGETPLATFORM --version $VERSION --output ../../dist/${TARGETPLATFORM} -- cgit v1.2.3 From 2315ccac2306caff3942916326d1569886cfa4e8 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sat, 14 May 2022 20:40:08 -0500 Subject: improve logging of shares --- src/slskd/Shares/SharedFileCache.cs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/slskd/Shares/SharedFileCache.cs b/src/slskd/Shares/SharedFileCache.cs index 3e305f08..ac996fa6 100644 --- a/src/slskd/Shares/SharedFileCache.cs +++ b/src/slskd/Shares/SharedFileCache.cs @@ -199,11 +199,13 @@ namespace slskd.Shares Log.Warning("Aborting shared file scan; no shares configured."); } - foreach (var share in Shares) - { - Log.Information($"Sharing {share.LocalPath} as {share.RemotePath}"); - Log.Debug($"Raw: {share.Raw}, Alias: {share.Alias}, Mask: {share.Mask}, Remote: {share.RemotePath})"); - } + Shares.ForEach(s => Log.Debug(s.ToJson())); + + Shares.Where(s => !s.IsExcluded).ToList() + .ForEach(s => Log.Information("Sharing {Local} as {Remote}", s.LocalPath, s.RemotePath)); + + Shares.Where(s => s.IsExcluded).ToList() + .ForEach(s => Log.Information("Excluding {Local}", s.LocalPath)); Log.Debug("Enumerating shared directories"); swSnapshot = sw.ElapsedMilliseconds; -- cgit v1.2.3 From 7caa8e13b7dfefa76dee92897f459514f2983e6b Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sat, 14 May 2022 20:46:29 -0500 Subject: account for exclusions when validating shares --- src/slskd/Options.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/slskd/Options.cs b/src/slskd/Options.cs index a1493ca4..a8c3380c 100644 --- a/src/slskd/Options.cs +++ b/src/slskd/Options.cs @@ -342,7 +342,7 @@ namespace slskd bool IsRoot((string Raw, string Mask, string Alias, string Path) share) => share.Path == "/" || share.Path == "\\" || Path.GetPathRoot(share.Path) == share.Path; // starts with '/', 'X:\', or '\\' - bool IsAbsolutePath(string share) => Regex.IsMatch(share.ToLocalOSPath(), @"^(\[.*\])?(\/|[a-zA-Z]:\\|\\\\).*$"); + bool IsAbsolutePath(string share) => Regex.IsMatch(share.ToLocalOSPath(), @"^(!|-){0,1}(\[.*\])?(\/|[a-zA-Z]:\\|\\\\).*$"); var relativePaths = Shared.Where(share => !IsAbsolutePath(share)); foreach (var relativePath in relativePaths) -- cgit v1.2.3