Skip to content

Commit c472b7b

Browse files
Fix outgoing format of the forwarding appended by the reverse proxy for IPv6 (#726)
1 parent 253e4d3 commit c472b7b

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

Modules/ReverseProxy/Provider/ReverseProxyProvider.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System.Globalization;
22
using System.Net;
33
using System.Net.Http.Headers;
4+
using System.Net.Sockets;
45
using System.Web;
56

67
using GenHTTP.Api.Content;
@@ -260,7 +261,14 @@ private static string GetForwarding(Forwarding forwarding)
260261

261262
if (forwarding.For is not null)
262263
{
263-
result.Add($"for={forwarding.For}");
264+
if (forwarding.For.AddressFamily == AddressFamily.InterNetworkV6)
265+
{
266+
result.Add($"for=[{forwarding.For}]");
267+
}
268+
else
269+
{
270+
result.Add($"for={forwarding.For}");
271+
}
264272
}
265273

266274
if (forwarding.Host is not null)

Testing/Acceptance/Modules/ReverseProxy/ReverseProxyTests.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
using System.Net;
2+
23
using GenHTTP.Api.Content;
34
using GenHTTP.Api.Protocol;
5+
46
using GenHTTP.Modules.IO;
57
using GenHTTP.Modules.Layouting;
68
using GenHTTP.Modules.ReverseProxy;
9+
10+
711
using Microsoft.VisualStudio.TestTools.UnitTesting;
12+
813
using Cookie = GenHTTP.Api.Protocol.Cookie;
914

1015
namespace GenHTTP.Testing.Acceptance.Modules.ReverseProxy;
@@ -266,7 +271,6 @@ public async Task TestBadGateway(TestEngine engine)
266271
await response.AssertStatusAsync(HttpStatusCode.BadGateway);
267272
}
268273

269-
270274
[TestMethod]
271275
[MultiEngineTest]
272276
public async Task TestCompression(TestEngine engine)

0 commit comments

Comments
 (0)