diff --git a/cmd/anubis/main.go b/cmd/anubis/main.go index 65241b9..6ad1027 100644 --- a/cmd/anubis/main.go +++ b/cmd/anubis/main.go @@ -439,26 +439,29 @@ func main() { } s, err := libanubis.New(libanubis.Options{ - BasePrefix: *basePrefix, - StripBasePrefix: *stripBasePrefix, - Next: rp, - Policy: policy, - ServeRobotsTXT: *robotsTxt, - ED25519PrivateKey: ed25519Priv, - HS512Secret: []byte(*hs512Secret), - CookieDomain: *cookieDomain, - CookieDynamicDomain: *cookieDynamicDomain, - CookieExpiration: *cookieExpiration, - CookiePartitioned: *cookiePartitioned, - RedirectDomains: redirectDomainsList, - Target: *target, - WebmasterEmail: *webmasterEmail, - OpenGraph: policy.OpenGraph, - CookieSecure: *cookieSecure, - CookieSameSite: parseSameSite(*cookieSameSite), - PublicUrl: *publicUrl, - JWTRestrictionHeader: *jwtRestrictionHeader, - DifficultyInJWT: *difficultyInJWT, + BasePrefix: *basePrefix, + StripBasePrefix: *stripBasePrefix, + Next: rp, + Policy: policy, + TargetHost: *targetHost, + TargetSNI: *targetSNI, + TargetInsecureSkipVerify: *targetInsecureSkipVerify, + ServeRobotsTXT: *robotsTxt, + ED25519PrivateKey: ed25519Priv, + HS512Secret: []byte(*hs512Secret), + CookieDomain: *cookieDomain, + CookieDynamicDomain: *cookieDynamicDomain, + CookieExpiration: *cookieExpiration, + CookiePartitioned: *cookiePartitioned, + RedirectDomains: redirectDomainsList, + Target: *target, + WebmasterEmail: *webmasterEmail, + OpenGraph: policy.OpenGraph, + CookieSecure: *cookieSecure, + CookieSameSite: parseSameSite(*cookieSameSite), + PublicUrl: *publicUrl, + JWTRestrictionHeader: *jwtRestrictionHeader, + DifficultyInJWT: *difficultyInJWT, }) if err != nil { log.Fatalf("can't construct libanubis.Server: %v", err) diff --git a/docs/docs/CHANGELOG.md b/docs/docs/CHANGELOG.md index 0c5858d..66e09ea 100644 --- a/docs/docs/CHANGELOG.md +++ b/docs/docs/CHANGELOG.md @@ -21,6 +21,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Allow Renovate as an OCI registry client. - Properly handle 4in6 addresses so that IP matching works with those addresses. - Add support to simple Valkey/Redis cluster mode +- Open Graph passthrough now reuses the configured target Host/SNI/TLS settings, so metadata fetches succeed when the upstream certificate differs from the public domain. ([1283](https://github.com/TecharoHQ/anubis/pull/1283)) - Stabilize the CVE-2025-24369 regression test by always submitting an invalid proof instead of relying on random POW failures. ## v1.23.1: Lyse Hext - Echo 1 diff --git a/internal/ogtags/cache_test.go b/internal/ogtags/cache_test.go index 08bf4e3..89ba229 100644 --- a/internal/ogtags/cache_test.go +++ b/internal/ogtags/cache_test.go @@ -24,7 +24,7 @@ func TestCacheReturnsDefault(t *testing.T) { TimeToLive: time.Minute, ConsiderHost: false, Override: want, - }, memory.New(t.Context())) + }, memory.New(t.Context()), TargetOptions{}) u, err := url.Parse("https://anubis.techaro.lol") if err != nil { @@ -52,7 +52,7 @@ func TestCheckCache(t *testing.T) { Enabled: true, TimeToLive: time.Minute, ConsiderHost: false, - }, memory.New(t.Context())) + }, memory.New(t.Context()), TargetOptions{}) // Set up test data urlStr := "http://example.com/page" @@ -115,7 +115,7 @@ func TestGetOGTags(t *testing.T) { Enabled: true, TimeToLive: time.Minute, ConsiderHost: false, - }, memory.New(t.Context())) + }, memory.New(t.Context()), TargetOptions{}) // Parse the test server URL parsedURL, err := url.Parse(ts.URL) @@ -271,7 +271,7 @@ func TestGetOGTagsWithHostConsideration(t *testing.T) { Enabled: true, TimeToLive: time.Minute, ConsiderHost: tc.ogCacheConsiderHost, - }, memory.New(t.Context())) + }, memory.New(t.Context()), TargetOptions{}) for i, req := range tc.requests { ogTags, err := cache.GetOGTags(t.Context(), parsedURL, req.host) diff --git a/internal/ogtags/fetch.go b/internal/ogtags/fetch.go index 26a0af2..0bfb0a1 100644 --- a/internal/ogtags/fetch.go +++ b/internal/ogtags/fetch.go @@ -27,16 +27,29 @@ func (c *OGTagCache) fetchHTMLDocumentWithCache(ctx context.Context, urlStr stri } // Set the Host header to the original host - if originalHost != "" { - req.Host = originalHost + var hostForRequest string + switch { + case c.targetHost != "": + hostForRequest = c.targetHost + case originalHost != "": + hostForRequest = originalHost + } + if hostForRequest != "" { + req.Host = hostForRequest } // Add proxy headers req.Header.Set("X-Forwarded-Proto", "https") req.Header.Set("User-Agent", "Anubis-OGTag-Fetcher/1.0") // For tracking purposes + serverName := hostForRequest + if serverName == "" { + serverName = req.URL.Hostname() + } + client := c.clientForSNI(serverName) + // Send the request - resp, err := c.client.Do(req) + resp, err := client.Do(req) if err != nil { var netErr net.Error if errors.As(err, &netErr) && netErr.Timeout() { diff --git a/internal/ogtags/fetch_test.go b/internal/ogtags/fetch_test.go index c986272..864e8f2 100644 --- a/internal/ogtags/fetch_test.go +++ b/internal/ogtags/fetch_test.go @@ -87,7 +87,7 @@ func TestFetchHTMLDocument(t *testing.T) { Enabled: true, TimeToLive: time.Minute, ConsiderHost: false, - }, memory.New(t.Context())) + }, memory.New(t.Context()), TargetOptions{}) doc, err := cache.fetchHTMLDocument(t.Context(), ts.URL, "anything") if tt.expectError { @@ -118,7 +118,7 @@ func TestFetchHTMLDocumentInvalidURL(t *testing.T) { Enabled: true, TimeToLive: time.Minute, ConsiderHost: false, - }, memory.New(t.Context())) + }, memory.New(t.Context()), TargetOptions{}) doc, err := cache.fetchHTMLDocument(t.Context(), "http://invalid.url.that.doesnt.exist.example", "anything") diff --git a/internal/ogtags/integration_test.go b/internal/ogtags/integration_test.go index 574172d..af56668 100644 --- a/internal/ogtags/integration_test.go +++ b/internal/ogtags/integration_test.go @@ -111,7 +111,7 @@ func TestIntegrationGetOGTags(t *testing.T) { Enabled: true, TimeToLive: time.Minute, ConsiderHost: false, - }, memory.New(t.Context())) + }, memory.New(t.Context()), TargetOptions{}) // Create URL for test testURL, _ := url.Parse(ts.URL) diff --git a/internal/ogtags/mem_test.go b/internal/ogtags/mem_test.go index b415cda..7d2ac0c 100644 --- a/internal/ogtags/mem_test.go +++ b/internal/ogtags/mem_test.go @@ -31,7 +31,7 @@ func BenchmarkGetTarget(b *testing.B) { for _, tt := range tests { b.Run(tt.name, func(b *testing.B) { - cache := NewOGTagCache(tt.target, config.OpenGraph{}, memory.New(b.Context())) + cache := NewOGTagCache(tt.target, config.OpenGraph{}, memory.New(b.Context()), TargetOptions{}) urls := make([]*url.URL, len(tt.paths)) for i, path := range tt.paths { u, _ := url.Parse(path) @@ -67,7 +67,7 @@ func BenchmarkExtractOGTags(b *testing.B) {
Content