feat: optional proxy for link-preview (Open Graph) fetches - #358
Open
eliasmeireles wants to merge 1 commit into
Open
feat: optional proxy for link-preview (Open Graph) fetches#358eliasmeireles wants to merge 1 commit into
eliasmeireles wants to merge 1 commit into
Conversation
eliasmeireles
marked this pull request as ready for review
August 15, 2026 13:57
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Some sites answer a captcha or geo-block page instead of the real page when the request arrives from outside the country they serve.
getOpenGraphDatathen reads that page's metadata, and the preview card goes out showing the block page's title instead of the product or article.A concrete case, same URL and the same
WhatsApp/2.23.20.0User-Agent, fetched at the same moment from two hosts:/az-request-verify,<title>Captcha Magalu</title>, 24 KB, noog:metadataog:titlepresentThe card the user received read "Captcha Magalu". This is decided by source IP, not by headers — the User-Agent added in #345 does not change the outcome above.
What this adds
OG_FETCH_PROXYroutes only the Open Graph fetch through a proxy. It is off by default, so behaviour is unchanged unless the variable is set.It is deliberately not the conventional
HTTPS_PROXY.globalHTTPClientis used by exactly one call site (fetchOpenGraphDataviahelpers.go), and a dedicated name keeps a generic proxy setting from silently capturing traffic it was never meant to. WhatsApp session traffic keeps whatsmeow's own transport and its existing per-userproxy_url//session/proxyconfiguration, untouched.Two details worth review:
globalHTTPClientis a package-level var, so it is built beforemain()callsgodotenv.Load(). Reading the variable on first use instead of at init keeps both the process environment and.envworking.DialContexttargets the proxy, which commonly sits on a private address, soisPrivateOrLoopbackhas to allow that one host. This shifts responsibility rather than removing it: the real target is no longer resolved locally, so the proxy is what must deny internal ranges. That trade-off is called out in the code comment and in the README, since an operator pointing this at a permissive proxy would be widening SSRF exposure.An invalid value is logged and ignored rather than failing startup — a broken preview card is a smaller problem than a server that refuses to boot.