Skip to content

Commit ab3f248

Browse files
test
1 parent 42ff344 commit ab3f248

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

P2PBootstrap/Program.cs

+15
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,21 @@ public static void Main(string[] args)
187187
{
188188
app.MapGet("/api/Bootstrap/publicip", async (HttpContext context) =>
189189
{
190+
var headerInfo = context.Request.Headers.Select(header =>
191+
{
192+
// Try parsing the complete header value; note that some headers (like X-Forwarded-For)
193+
// may contain multiple comma-separated IPs, so this is a basic example.
194+
bool parsed = IPAddress.TryParse(header.Value.ToString(), out IPAddress ip);
195+
return new
196+
{
197+
Header = header.Key,
198+
Value = header.Value.ToString(),
199+
ParsedIP = parsed ? ip.ToString() : "Not an IP"
200+
};
201+
});
202+
return Results.Json(headerInfo);
203+
204+
190205
string ip = context.Connection.RemoteIpAddress?.ToString() ?? "Unknown";
191206
return Results.Text(ip, "text/plain");
192207
});

0 commit comments

Comments
 (0)