add option to have external port
Some checks failed
Go / check-formatting (push) Has been cancelled
Go / build-and-test (push) Has been cancelled
Go / build-docker-images (push) Has been cancelled

This commit is contained in:
Gergely Hegedus 2025-01-19 15:18:16 +02:00
parent 3a2096345d
commit 6ef61fe1af
6 changed files with 61 additions and 25 deletions

View file

@ -4,14 +4,15 @@ import (
"encoding/hex"
"encoding/json"
"errors"
"github.com/boltcard/boltcard/crypto"
"github.com/boltcard/boltcard/db"
"github.com/boltcard/boltcard/resp_err"
log "github.com/sirupsen/logrus"
"net/http"
"os"
"strconv"
"strings"
"github.com/boltcard/boltcard/crypto"
"github.com/boltcard/boltcard/db"
"github.com/boltcard/boltcard/resp_err"
log "github.com/sirupsen/logrus"
)
func get_p_c(req *http.Request, p_name string, c_name string) (p string, c string) {
@ -246,6 +247,11 @@ func parse_request(req *http.Request) (int, error) {
func Response(w http.ResponseWriter, req *http.Request) {
env_host_domain := db.Get_setting("HOST_DOMAIN")
hostdomainPort := db.Get_setting("HOST_DOMAIN_PORT")
hostdomainsuffix := ""
if hostdomainPort != "" {
hostdomainsuffix = ":" + hostdomainPort
}
if req.Host != env_host_domain {
log.Warn("wrong host domain")
@ -280,10 +286,10 @@ func Response(w http.ResponseWriter, req *http.Request) {
}
lnurlw_cb_url := ""
if strings.HasSuffix(req.Host, ".onion") {
lnurlw_cb_url = "http://" + req.Host + "/cb"
if strings.HasSuffix(env_host_domain, ".onion") {
lnurlw_cb_url = "http://" + env_host_domain + hostdomainsuffix + "/cb"
} else {
lnurlw_cb_url = "https://" + req.Host + "/cb"
lnurlw_cb_url = "https://" + env_host_domain + hostdomainsuffix + "/cb"
}
min_withdraw_sats_str := db.Get_setting("MIN_WITHDRAW_SATS")