add option to have external port
This commit is contained in:
parent
3a2096345d
commit
9bdbe1dc9c
3 changed files with 30 additions and 12 deletions
|
|
@ -1,12 +1,13 @@
|
||||||
package internalapi
|
package internalapi
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/boltcard/boltcard/db"
|
|
||||||
"github.com/boltcard/boltcard/resp_err"
|
|
||||||
log "github.com/sirupsen/logrus"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/boltcard/boltcard/db"
|
||||||
|
"github.com/boltcard/boltcard/resp_err"
|
||||||
|
log "github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
// random_hex() from Createboltcardwithpin used here
|
// random_hex() from Createboltcardwithpin used here
|
||||||
|
|
@ -100,11 +101,16 @@ func Createboltcard(w http.ResponseWriter, r *http.Request) {
|
||||||
// return the URI + one_time_code
|
// return the URI + one_time_code
|
||||||
|
|
||||||
hostdomain := db.Get_setting("HOST_DOMAIN")
|
hostdomain := db.Get_setting("HOST_DOMAIN")
|
||||||
|
hostdomainPort := db.Get_setting("HOST_DOMAIN_PORT")
|
||||||
|
hostdomainsuffix := ""
|
||||||
|
if hostdomainPort != "" {
|
||||||
|
hostdomainsuffix = ":" + hostdomainPort
|
||||||
|
}
|
||||||
url := ""
|
url := ""
|
||||||
if strings.HasSuffix(hostdomain, ".onion") {
|
if strings.HasSuffix(hostdomain, ".onion") {
|
||||||
url = "http://" + hostdomain + "/new?a=" + one_time_code
|
url = "http://" + hostdomain + hostdomainsuffix + "/new?a=" + one_time_code
|
||||||
} else {
|
} else {
|
||||||
url = "https://" + hostdomain + "/new?a=" + one_time_code
|
url = "https://" + hostdomain + hostdomainsuffix + "/new?a=" + one_time_code
|
||||||
}
|
}
|
||||||
|
|
||||||
// log the response
|
// log the response
|
||||||
|
|
|
||||||
|
|
@ -3,12 +3,13 @@ package internalapi
|
||||||
import (
|
import (
|
||||||
"crypto/rand"
|
"crypto/rand"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"github.com/boltcard/boltcard/db"
|
|
||||||
"github.com/boltcard/boltcard/resp_err"
|
|
||||||
log "github.com/sirupsen/logrus"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/boltcard/boltcard/db"
|
||||||
|
"github.com/boltcard/boltcard/resp_err"
|
||||||
|
log "github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
func random_hex() string {
|
func random_hex() string {
|
||||||
|
|
@ -132,11 +133,16 @@ func Createboltcardwithpin(w http.ResponseWriter, r *http.Request) {
|
||||||
// return the URI + one_time_code
|
// return the URI + one_time_code
|
||||||
|
|
||||||
hostdomain := db.Get_setting("HOST_DOMAIN")
|
hostdomain := db.Get_setting("HOST_DOMAIN")
|
||||||
|
hostdomainPort := db.Get_setting("HOST_DOMAIN_PORT")
|
||||||
|
hostdomainsuffix := ""
|
||||||
|
if hostdomainPort != "" {
|
||||||
|
hostdomainsuffix = ":" + hostdomainPort
|
||||||
|
}
|
||||||
url := ""
|
url := ""
|
||||||
if strings.HasSuffix(hostdomain, ".onion") {
|
if strings.HasSuffix(hostdomain, ".onion") {
|
||||||
url = "http://" + hostdomain + "/new?a=" + one_time_code
|
url = "http://" + hostdomain + hostdomainsuffix + "/new?a=" + one_time_code
|
||||||
} else {
|
} else {
|
||||||
url = "https://" + hostdomain + "/new?a=" + one_time_code
|
url = "https://" + hostdomain + hostdomainsuffix + "/new?a=" + one_time_code
|
||||||
}
|
}
|
||||||
|
|
||||||
// log the response
|
// log the response
|
||||||
|
|
|
||||||
|
|
@ -3,10 +3,11 @@ package main
|
||||||
import (
|
import (
|
||||||
"database/sql"
|
"database/sql"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
"github.com/boltcard/boltcard/db"
|
"github.com/boltcard/boltcard/db"
|
||||||
"github.com/boltcard/boltcard/resp_err"
|
"github.com/boltcard/boltcard/resp_err"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"net/http"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -55,7 +56,12 @@ func new_card_request(w http.ResponseWriter, req *http.Request) {
|
||||||
|
|
||||||
a := params_a[0]
|
a := params_a[0]
|
||||||
|
|
||||||
lnurlw_base := "lnurlw://" + db.Get_setting("HOST_DOMAIN") + "/ln"
|
hostdomainPort := db.Get_setting("HOST_DOMAIN_PORT")
|
||||||
|
hostdomainsuffix := ""
|
||||||
|
if hostdomainPort != "" {
|
||||||
|
hostdomainsuffix = ":" + hostdomainPort
|
||||||
|
}
|
||||||
|
lnurlw_base := "lnurlw://" + db.Get_setting("HOST_DOMAIN") + hostdomainsuffix + "/ln"
|
||||||
|
|
||||||
c, err := db.Get_new_card(a)
|
c, err := db.Get_new_card(a)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue