Skip to content

Commit

Permalink
Merge pull request #50 from Impa10r/v1.5.0
Browse files Browse the repository at this point in the history
v1.5.0
  • Loading branch information
Impa10r authored May 27, 2024
2 parents 87b6585 + a22de6f commit b83b263
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 10 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Versions

## 1.5.0

- Use hostname of the host in server.crt when run in Docker

## 1.4.9

- Fix HTTPS error when "PSWeb IPs" is blank
Expand Down
12 changes: 12 additions & 0 deletions cmd/psweb/config/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,3 +159,15 @@ func GetBlockIoHost() string {
return "https://go.getblock.io/6885fe0778944e28979adc739c7105b6"
}
}

// returns hostname of the machine or host if passed via Env
func GetHostname() string {
// Get the hostname of the machine
hostname, _ := os.Hostname()

if os.Getenv("HOSTNAME") != "" {
hostname = os.Getenv("HOSTNAME")
}

return hostname
}
5 changes: 1 addition & 4 deletions cmd/psweb/config/tls.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,7 @@ func GenereateServerCertificate() error {
pem.Encode(serverPrivKeyFile, &pem.Block{Type: "PRIVATE KEY", Bytes: x509.MarshalPKCS1PrivateKey(serverPrivKey)})

// Get the hostname of the machine
hostname, err := os.Hostname()
if err != nil {
return err
}
hostname := GetHostname()

// Set certificate name
subject := pkix.Name{
Expand Down
9 changes: 4 additions & 5 deletions cmd/psweb/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import (

const (
// App version tag
version = "v1.4.9"
version = "v1.5.0"
)

type SwapParams struct {
Expand Down Expand Up @@ -857,7 +857,7 @@ func configHandler(w http.ResponseWriter, r *http.Request) {
}

// Get the hostname of the machine
hostname, _ := os.Hostname()
hostname := config.GetHostname()

// populate server IP if empty
if config.Config.ServerIPs == "" {
Expand Down Expand Up @@ -888,7 +888,7 @@ func configHandler(w http.ResponseWriter, r *http.Request) {
Version: version,
Latest: latestVersion,
Implementation: ln.Implementation,
HTTPS: "https://" + hostname + ".local:" + config.Config.ListenPort,
HTTPS: "https://" + hostname + ".local:" + config.Config.SecurePort,
}

// executing template named "config"
Expand All @@ -906,8 +906,7 @@ func caHandler(w http.ResponseWriter, r *http.Request) {
errorMessage = keys[0]
}

// Get the hostname of the machine
hostname, _ := os.Hostname()
hostname := config.GetHostname()

urls := []string{
"https://localhost:" + config.Config.SecurePort,
Expand Down
2 changes: 1 addition & 1 deletion cmd/psweb/templates/ca.gohtml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<p>1. "Trusted Root Certification Authority" certificate <u>CA.crt</u> will inform the browser that the server is genuine.</p>
<p>2. "Personal" certificate <u>client.p12</u> will authenticate the client to the server.</p>
<br>
<p>Use secure methods to copy these files from peerswap data folder onto your devices. The password for client.p12 is "<u>{{.Password}}</u>". <u>Important:</u> write down this password before proceeding as it will not be saved nor displayed again.</p>
<p>Use secure methods to copy these files from peerswap data folder onto your devices. The password for client.p12 is "<b>{{.Password}}</b>". <u>Important:</u> write down this password before proceeding as it will not be saved nor displayed again.</p>
<br>
</p>After restart, PeerSwap Web UI will be listening on:<p>
<ol>
Expand Down

0 comments on commit b83b263

Please sign in to comment.