mirror of
https://github.com/bumi/lntip
synced 2025-06-16 17:55:35 +00:00
Fix: use correct header to get the original request host
Proxy servers can set the X-Forwarded-Host and X-Forwarded-Proto headers to pass on the original host and protocol. We should also support the Forwarded header (which combines this in one header described in RFC7239 - but seems echo does not support parsing that one?)
This commit is contained in:
parent
bdd3b70e1f
commit
5d2c9cd639
11
lnme.go
11
lnme.go
@ -152,9 +152,14 @@ func main() {
|
|||||||
if !cfg.Bool("disable-ln-address") {
|
if !cfg.Bool("disable-ln-address") {
|
||||||
lnurlHandler := func(c echo.Context) error {
|
lnurlHandler := func(c echo.Context) error {
|
||||||
host := c.Request().Host
|
host := c.Request().Host
|
||||||
if c.Request().Header.Get(echo.HeaderXForwardedFor) != "" {
|
proto := c.Scheme()
|
||||||
host = c.Request().Header.Get(echo.HeaderXForwardedFor)
|
// TODO: support RFC7239 Forwarded header
|
||||||
|
if c.Request().Header.Get("X-Forwarded-Host") != "" {
|
||||||
|
host = c.Request().Header.Get("X-Forwarded-Host")
|
||||||
}
|
}
|
||||||
|
if c.Request().Header.Get("X-Forwarded-Proto") != "" {
|
||||||
|
proto = c.Request().Header.Get("X-Forwarded-Proto")
|
||||||
|
}
|
||||||
name := c.Param("name")
|
name := c.Param("name")
|
||||||
lightningAddress := name + "@" + host
|
lightningAddress := name + "@" + host
|
||||||
lnurlMetadata := "[[\"text/identifier\", \"" + lightningAddress + "\"], [\"text/plain\", \"Sats for " + lightningAddress + "\"]]"
|
lnurlMetadata := "[[\"text/identifier\", \"" + lightningAddress + "\"], [\"text/plain\", \"Sats for " + lightningAddress + "\"]]"
|
||||||
@ -162,7 +167,7 @@ func main() {
|
|||||||
if amount := c.QueryParam("amount"); amount == "" {
|
if amount := c.QueryParam("amount"); amount == "" {
|
||||||
lnurlPayResponse1 := lnurl.LNURLPayResponse1{
|
lnurlPayResponse1 := lnurl.LNURLPayResponse1{
|
||||||
LNURLResponse: lnurl.LNURLResponse{Status: "OK"},
|
LNURLResponse: lnurl.LNURLResponse{Status: "OK"},
|
||||||
Callback: fmt.Sprintf("%s://%s%s", c.Scheme(), host, c.Request().URL.Path),
|
Callback: fmt.Sprintf("%s://%s%s", proto, host, c.Request().URL.Path),
|
||||||
MinSendable: 1000,
|
MinSendable: 1000,
|
||||||
MaxSendable: 100000000,
|
MaxSendable: 100000000,
|
||||||
EncodedMetadata: lnurlMetadata,
|
EncodedMetadata: lnurlMetadata,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user