mirror of
https://github.com/bumi/lntip
synced 2025-07-06 09:08:57 +00:00
Generate lightning address host either from the x-forwarded-for header or from the request host
When LnMe runs behind a proxy and the X-Forwarded-For HTTP header is set we want to use that value to generate the lightning address and not the local/internal host
This commit is contained in:
parent
bf44f314dd
commit
d1be2e20aa
8
lnme.go
8
lnme.go
@ -146,14 +146,18 @@ 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
|
||||||
|
if c.Request().Header.Get(echo.HeaderXForwardedFor) != "" {
|
||||||
|
host = c.Request().Header.Get(echo.HeaderXForwardedFor)
|
||||||
|
}
|
||||||
name := c.Param("name")
|
name := c.Param("name")
|
||||||
lightningAddress := name + "@" + c.Request().Host
|
lightningAddress := name + "@" + host
|
||||||
lnurlMetadata := "[[\"text/identifier\", \"" + lightningAddress + "\"], [\"text/plain\", \"Sats for " + lightningAddress + "\"]]"
|
lnurlMetadata := "[[\"text/identifier\", \"" + lightningAddress + "\"], [\"text/plain\", \"Sats for " + lightningAddress + "\"]]"
|
||||||
|
|
||||||
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(), c.Request().Host, c.Request().URL.Path),
|
Callback: fmt.Sprintf("%s://%s%s", c.Scheme(), 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