From c0fad35e1e4a60f0615bd04af052860e386b974b Mon Sep 17 00:00:00 2001
From: Rasmus Dahlberg <rasmus@rgdd.se>
Date: Tue, 11 Mar 2025 18:56:25 +0100
Subject: fix: Attribute OL with the domain we arrived at

---
 main.go | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/main.go b/main.go
index 539e86f..72f6dd1 100644
--- a/main.go
+++ b/main.go
@@ -129,6 +129,15 @@ func work(ctx context.Context, cli *http.Client, timeout time.Duration, question
 	}
 	defer rsp.Body.Close()
 
+	// We're using an HTTP client that follows redirects.  Ensure that we're
+	// attributing any found Onion-Location header with the domain name we were
+	// redirected too, rather than the original domain name that we started
+	// from.  If there are no redirects this assignment doesn't change anything.
+	//
+	// More details on why this behavior matters:
+	// https://gitlab.torproject.org/tpo/onion-services/onion-grab/-/issues/1
+	answer.Domain = rsp.Request.URL.Host
+
 	onion, ok := onionloc.HTTP(rsp)
 	if ok {
 		answer.HTTP = onion
-- 
cgit v1.2.3