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

@ -1,12 +1,13 @@
package internalapi
import (
"github.com/boltcard/boltcard/db"
"github.com/boltcard/boltcard/resp_err"
log "github.com/sirupsen/logrus"
"net/http"
"strconv"
"strings"
"github.com/boltcard/boltcard/db"
"github.com/boltcard/boltcard/resp_err"
log "github.com/sirupsen/logrus"
)
// random_hex() from Createboltcardwithpin used here
@ -100,11 +101,16 @@ func Createboltcard(w http.ResponseWriter, r *http.Request) {
// return the URI + one_time_code
hostdomain := db.Get_setting("HOST_DOMAIN")
hostdomainPort := db.Get_setting("HOST_DOMAIN_PORT")
hostdomainsuffix := ""
if hostdomainPort != "" {
hostdomainsuffix = ":" + hostdomainPort
}
url := ""
if strings.HasSuffix(hostdomain, ".onion") {
url = "http://" + hostdomain + "/new?a=" + one_time_code
url = "http://" + hostdomain + hostdomainsuffix + "/new?a=" + one_time_code
} else {
url = "https://" + hostdomain + "/new?a=" + one_time_code
url = "https://" + hostdomain + hostdomainsuffix + "/new?a=" + one_time_code
}
// log the response

View file

@ -3,12 +3,13 @@ package internalapi
import (
"crypto/rand"
"encoding/hex"
"github.com/boltcard/boltcard/db"
"github.com/boltcard/boltcard/resp_err"
log "github.com/sirupsen/logrus"
"net/http"
"strconv"
"strings"
"github.com/boltcard/boltcard/db"
"github.com/boltcard/boltcard/resp_err"
log "github.com/sirupsen/logrus"
)
func random_hex() string {
@ -132,11 +133,16 @@ func Createboltcardwithpin(w http.ResponseWriter, r *http.Request) {
// return the URI + one_time_code
hostdomain := db.Get_setting("HOST_DOMAIN")
hostdomainPort := db.Get_setting("HOST_DOMAIN_PORT")
hostdomainsuffix := ""
if hostdomainPort != "" {
hostdomainsuffix = ":" + hostdomainPort
}
url := ""
if strings.HasSuffix(hostdomain, ".onion") {
url = "http://" + hostdomain + "/new?a=" + one_time_code
url = "http://" + hostdomain + hostdomainsuffix + "/new?a=" + one_time_code
} else {
url = "https://" + hostdomain + "/new?a=" + one_time_code
url = "https://" + hostdomain + hostdomainsuffix + "/new?a=" + one_time_code
}
// log the response