aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/slskd/Common/Base62Extensions.cs (renamed from src/slskd/Common/Cryptography/Base62Extensions.cs)2
-rw-r--r--src/slskd/Common/Base64Extensions.cs48
-rw-r--r--src/slskd/Relay/API/Controllers/RelayController.cs3
-rw-r--r--src/slskd/Relay/RelayClient.cs2
4 files changed, 52 insertions, 3 deletions
diff --git a/src/slskd/Common/Cryptography/Base62Extensions.cs b/src/slskd/Common/Base62Extensions.cs
index b9ab3a72..b0171299 100644
--- a/src/slskd/Common/Cryptography/Base62Extensions.cs
+++ b/src/slskd/Common/Base62Extensions.cs
@@ -27,7 +27,7 @@
*/
// <auto-generated /> -- suppress analysis
-namespace slskd.Cryptography
+namespace slskd
{
using System;
using System.Collections.Generic;
diff --git a/src/slskd/Common/Base64Extensions.cs b/src/slskd/Common/Base64Extensions.cs
new file mode 100644
index 00000000..6eaf2dff
--- /dev/null
+++ b/src/slskd/Common/Base64Extensions.cs
@@ -0,0 +1,48 @@
+// <copyright file="Base64Extensions.cs" company="slskd Team">
+// Copyright (c) slskd Team. All rights reserved.
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as published
+// by the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program 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 Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see https://www.gnu.org/licenses/.
+// </copyright>
+
+namespace slskd
+{
+ using System;
+ using System.Text;
+
+ /// <summary>
+ /// Base 64 extensions.
+ /// </summary>
+ public static class Base64Extensions
+ {
+ /// <summary>
+ /// Encode this string in Base 64.
+ /// </summary>
+ /// <param name="str">The string to encode.</param>
+ /// <returns>The encoded string.</returns>
+ public static string ToBase64(this string str)
+ {
+ return Convert.ToBase64String(Encoding.UTF8.GetBytes(str));
+ }
+
+ /// <summary>
+ /// Decode this string from Base 64.
+ /// </summary>
+ /// <param name="str">The string to decode.</param>
+ /// <returns>The decoded string.</returns>
+ public static string FromBase64(this string str)
+ {
+ return Encoding.UTF8.GetString(Convert.FromBase64String(str));
+ }
+ }
+} \ No newline at end of file
diff --git a/src/slskd/Relay/API/Controllers/RelayController.cs b/src/slskd/Relay/API/Controllers/RelayController.cs
index 49c76e2d..a7ed7e2d 100644
--- a/src/slskd/Relay/API/Controllers/RelayController.cs
+++ b/src/slskd/Relay/API/Controllers/RelayController.cs
@@ -31,6 +31,7 @@ namespace slskd.Relay
using Microsoft.AspNetCore.WebUtilities;
using Microsoft.Net.Http.Headers;
using Serilog;
+ using slskd.Cryptography;
using slskd.Shares;
/// <summary>
@@ -118,7 +119,7 @@ namespace slskd.Relay
var agentName = Request.Headers["X-Relay-Agent"].FirstOrDefault();
var credential = Request.Headers["X-Relay-Credential"].FirstOrDefault();
- var filename = Request.Headers["X-Relay-Filename"].FirstOrDefault();
+ var filename = Request.Headers["X-Relay-Filename-Base64"].FirstOrDefault()?.FromBase64();
if (!Relay.RegisteredAgents.Any(a => a.Name == agentName) || string.IsNullOrEmpty(credential))
{
diff --git a/src/slskd/Relay/RelayClient.cs b/src/slskd/Relay/RelayClient.cs
index eef84c27..f3880c97 100644
--- a/src/slskd/Relay/RelayClient.cs
+++ b/src/slskd/Relay/RelayClient.cs
@@ -457,7 +457,7 @@ namespace slskd.Relay
request.Headers.Add("X-API-Key", OptionsMonitor.CurrentValue.Relay.Controller.ApiKey);
request.Headers.Add("X-Relay-Agent", OptionsMonitor.CurrentValue.InstanceName);
request.Headers.Add("X-Relay-Credential", ComputeCredential(token));
- request.Headers.Add("X-Relay-Filename", filename);
+ request.Headers.Add("X-Relay-Filename-Base64", filename.ToBase64());
using var client = CreateHttpClient();
using var response = await client.SendAsync(request, HttpCompletionOption.ResponseHeadersRead);