Skip to content

Commit f9e3941

Browse files
committed
chore: add strfry binary verification to strfry29 relay install and turn server tokens off for nginx http server when redirecting to https
1 parent a7b78f8 commit f9e3941

File tree

13 files changed

+68
-48
lines changed

13 files changed

+68
-48
lines changed

pkg/relays/khatru29/install.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212

1313
// Function to download and make the binary executable
1414
func InstallRelayBinary() {
15-
downloadSpinner, _ := pterm.DefaultSpinner.Start(fmt.Sprintf("Downloading %s relay binary...", RelayName))
15+
downloadSpinner, _ := pterm.DefaultSpinner.Start(fmt.Sprintf("Downloading %s binary...", RelayName))
1616

1717
// Determine the file name from the URL
1818
tmpFileName := filepath.Base(DownloadURL)
@@ -26,12 +26,12 @@ func InstallRelayBinary() {
2626
// Download and copy the file
2727
files.DownloadAndCopyFile(tmpFilePath, DownloadURL)
2828

29-
downloadSpinner.Success(fmt.Sprintf("%s relay binary downloaded", RelayName))
29+
downloadSpinner.Success(fmt.Sprintf("%s binary downloaded", RelayName))
3030

3131
// Verify relay binary
32-
verification.VerifyRelayBinary(tmpFilePath)
32+
verification.VerifyRelayBinary(RelayName, tmpFilePath)
3333

34-
installSpinner, _ := pterm.DefaultSpinner.Start(fmt.Sprintf("Installing %s relay binary...", RelayName))
34+
installSpinner, _ := pterm.DefaultSpinner.Start(fmt.Sprintf("Installing %s binary...", RelayName))
3535

3636
// Check if the service file exists and disable and stop the service if it does
3737
if files.FileExists(ServiceFilePath) {
@@ -56,5 +56,5 @@ func InstallRelayBinary() {
5656
// Make the file executable
5757
files.SetPermissions(destPath, 0755)
5858

59-
installSpinner.Success(fmt.Sprintf("%s relay binary installed", RelayName))
59+
installSpinner.Success(fmt.Sprintf("%s binary installed", RelayName))
6060
}

pkg/relays/khatru29/nginx_https.go

+3
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,9 @@ server {
122122
location / {
123123
return 301 https://%s$request_uri;
124124
}
125+
126+
# Only return Nginx in server header
127+
server_tokens off;
125128
}
126129
`, domainName, network.WWWDirPath, domainName, network.AcmeChallengeDirPath, network.CertificateDirPath, domainName, network.FullchainFile, network.CertificateDirPath, domainName, network.PrivkeyFile, network.CertificateDirPath, domainName, network.ChainFile, domainName, network.WWWDirPath, domainName, domainName)
127130

pkg/relays/khatru_pyramid/install.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313

1414
// Function to download and make the binary executable
1515
func InstallRelayBinary(pubKey string) {
16-
downloadSpinner, _ := pterm.DefaultSpinner.Start(fmt.Sprintf("Downloading %s relay binary...", RelayName))
16+
downloadSpinner, _ := pterm.DefaultSpinner.Start(fmt.Sprintf("Downloading %s binary...", RelayName))
1717

1818
// Determine the file name from the URL
1919
tmpFileName := filepath.Base(DownloadURL)
@@ -27,12 +27,12 @@ func InstallRelayBinary(pubKey string) {
2727
// Download and copy the file
2828
files.DownloadAndCopyFile(tmpFilePath, DownloadURL)
2929

30-
downloadSpinner.Success(fmt.Sprintf("%s relay binary downloaded", RelayName))
30+
downloadSpinner.Success(fmt.Sprintf("%s binary downloaded", RelayName))
3131

3232
// Verify relay binary
33-
verification.VerifyRelayBinary(tmpFilePath)
33+
verification.VerifyRelayBinary(RelayName, tmpFilePath)
3434

35-
installSpinner, _ := pterm.DefaultSpinner.Start(fmt.Sprintf("Installing %s relay binary...", RelayName))
35+
installSpinner, _ := pterm.DefaultSpinner.Start(fmt.Sprintf("Installing %s binary...", RelayName))
3636

3737
// Check if the service file exists and disable and stop the service if it does
3838
if files.FileExists(ServiceFilePath) {
@@ -72,5 +72,5 @@ func InstallRelayBinary(pubKey string) {
7272
// Make the file executable
7373
files.SetPermissions(destPath, 0755)
7474

75-
installSpinner.Success(fmt.Sprintf("%s relay binary installed", RelayName))
75+
installSpinner.Success(fmt.Sprintf("%s binary installed", RelayName))
7676
}

pkg/relays/khatru_pyramid/nginx_https.go

+3
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,9 @@ server {
122122
location / {
123123
return 301 https://%s$request_uri;
124124
}
125+
126+
# Only return Nginx in server header
127+
server_tokens off;
125128
}
126129
`, domainName, network.WWWDirPath, domainName, network.AcmeChallengeDirPath, network.CertificateDirPath, domainName, network.FullchainFile, network.CertificateDirPath, domainName, network.PrivkeyFile, network.CertificateDirPath, domainName, network.ChainFile, domainName, network.WWWDirPath, domainName, domainName)
127130

pkg/relays/nostr_rs_relay/install.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414

1515
// Function to download and make the binary executable
1616
func InstallRelayBinary() {
17-
downloadSpinner, _ := pterm.DefaultSpinner.Start(fmt.Sprintf("Downloading %s relay binary...", RelayName))
17+
downloadSpinner, _ := pterm.DefaultSpinner.Start(fmt.Sprintf("Downloading %s binary...", RelayName))
1818

1919
// Check for and remove existing git repository
2020
directories.RemoveDirectory(GitRepoTmpDirPath)
@@ -36,12 +36,12 @@ func InstallRelayBinary() {
3636
// Download and copy the file
3737
files.DownloadAndCopyFile(tmpFilePath, DownloadURL)
3838

39-
downloadSpinner.Success(fmt.Sprintf("%s relay binary downloaded", RelayName))
39+
downloadSpinner.Success(fmt.Sprintf("%s binary downloaded", RelayName))
4040

4141
// Verify relay binary
42-
verification.VerifyRelayBinary(tmpFilePath)
42+
verification.VerifyRelayBinary(RelayName, tmpFilePath)
4343

44-
installSpinner, _ := pterm.DefaultSpinner.Start(fmt.Sprintf("Installing %s relay binary...", RelayName))
44+
installSpinner, _ := pterm.DefaultSpinner.Start(fmt.Sprintf("Installing %s binary...", RelayName))
4545

4646
// Check if the service file exists and disable and stop the service if it does
4747
if files.FileExists(ServiceFilePath) {
@@ -66,5 +66,5 @@ func InstallRelayBinary() {
6666
// Make the file executable
6767
files.SetPermissions(destPath, 0755)
6868

69-
installSpinner.Success(fmt.Sprintf("%s relay binary installed", RelayName))
69+
installSpinner.Success(fmt.Sprintf("%s binary installed", RelayName))
7070
}

pkg/relays/nostr_rs_relay/nginx_https.go

+3
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,9 @@ server {
122122
location / {
123123
return 301 https://%s$request_uri;
124124
}
125+
126+
# Only return Nginx in server header
127+
server_tokens off;
125128
}
126129
`, domainName, network.WWWDirPath, domainName, network.AcmeChallengeDirPath, network.CertificateDirPath, domainName, network.FullchainFile, network.CertificateDirPath, domainName, network.PrivkeyFile, network.CertificateDirPath, domainName, network.ChainFile, domainName, network.WWWDirPath, domainName, domainName)
127130

pkg/relays/strfry/install.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414

1515
// Function to download and make the binary executable
1616
func InstallRelayBinary() {
17-
downloadSpinner, _ := pterm.DefaultSpinner.Start(fmt.Sprintf("Downloading %s relay binary...", RelayName))
17+
downloadSpinner, _ := pterm.DefaultSpinner.Start(fmt.Sprintf("Downloading %s binary...", RelayName))
1818

1919
// Check for and remove existing git repository
2020
directories.RemoveDirectory(GitRepoTmpDirPath)
@@ -37,12 +37,12 @@ func InstallRelayBinary() {
3737
// Download and copy the file
3838
files.DownloadAndCopyFile(tmpFilePath, DownloadURL)
3939

40-
downloadSpinner.Success(fmt.Sprintf("%s relay binary downloaded", RelayName))
40+
downloadSpinner.Success(fmt.Sprintf("%s binary downloaded", RelayName))
4141

4242
// Verify relay binary
43-
verification.VerifyRelayBinary(tmpFilePath)
43+
verification.VerifyRelayBinary(RelayName, tmpFilePath)
4444

45-
installSpinner, _ := pterm.DefaultSpinner.Start(fmt.Sprintf("Installing %s relay binary...", RelayName))
45+
installSpinner, _ := pterm.DefaultSpinner.Start(fmt.Sprintf("Installing %s binary...", RelayName))
4646

4747
// Check if the service file exists and disable and stop the service if it does
4848
if files.FileExists(ServiceFilePath) {
@@ -67,5 +67,5 @@ func InstallRelayBinary() {
6767
// Make the file executable
6868
files.SetPermissions(destPath, 0755)
6969

70-
installSpinner.Success(fmt.Sprintf("%s relay binary installed", RelayName))
70+
installSpinner.Success(fmt.Sprintf("%s binary installed", RelayName))
7171
}

pkg/relays/strfry/nginx_https.go

+3
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,9 @@ server {
122122
location / {
123123
return 301 https://%s$request_uri;
124124
}
125+
126+
# Only return Nginx in server header
127+
server_tokens off;
125128
}
126129
`, domainName, network.WWWDirPath, domainName, network.AcmeChallengeDirPath, network.CertificateDirPath, domainName, network.FullchainFile, network.CertificateDirPath, domainName, network.PrivkeyFile, network.CertificateDirPath, domainName, network.ChainFile, domainName, network.WWWDirPath, domainName, domainName)
127130

pkg/relays/strfry29/install.go

+22-19
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ import (
1212
"path/filepath"
1313
)
1414

15-
// Function to download and make the binary executable
15+
// Function to download and make the binary and plugin binary executable
1616
func InstallRelayBinary() {
17-
downloadSpinner, _ := pterm.DefaultSpinner.Start(fmt.Sprintf("Downloading %s relay binary...", RelayName))
17+
downloadSpinner, _ := pterm.DefaultSpinner.Start(fmt.Sprintf("Downloading %s binaries...", RelayName))
1818

1919
// Check for and remove existing git repository
2020
directories.RemoveDirectory(GitRepoTmpDirPath)
@@ -26,38 +26,38 @@ func InstallRelayBinary() {
2626

2727
// Install
2828
// Determine the file name from the URL
29-
tmpFileName := filepath.Base(DownloadURL)
29+
tmpBinaryFileName := filepath.Base(DownloadURL)
3030

3131
// Temporary file path
32-
tmpFilePath := fmt.Sprintf("%s/%s", relays.TmpDirPath, tmpFileName)
32+
tmpBinaryFilePath := fmt.Sprintf("%s/%s", relays.TmpDirPath, tmpBinaryFileName)
3333

3434
// Check if the temporary file exists and remove it if it does
35-
files.RemoveFile(tmpFilePath)
35+
files.RemoveFile(tmpBinaryFilePath)
3636

3737
// Download and copy the file
38-
files.DownloadAndCopyFile(tmpFilePath, DownloadURL)
39-
40-
// Extract binary
41-
files.ExtractFile(tmpFilePath, relays.BinaryDestDir)
38+
files.DownloadAndCopyFile(tmpBinaryFilePath, DownloadURL)
4239

4340
// Determine the file name from the URL
44-
tmpFileName = filepath.Base(BinaryPluginDownloadURL)
41+
tmpBinaryPluginFileName := filepath.Base(BinaryPluginDownloadURL)
4542

4643
// Temporary file path
47-
tmpFilePath = fmt.Sprintf("%s/%s", relays.TmpDirPath, tmpFileName)
44+
tmpBinaryPluginFilePath := fmt.Sprintf("%s/%s", relays.TmpDirPath, tmpBinaryPluginFileName)
4845

4946
// Check if the temporary file exists and remove it if it does
50-
files.RemoveFile(tmpFilePath)
47+
files.RemoveFile(tmpBinaryPluginFilePath)
5148

5249
// Download and copy the file
53-
files.DownloadAndCopyFile(tmpFilePath, BinaryPluginDownloadURL)
50+
files.DownloadAndCopyFile(tmpBinaryPluginFilePath, BinaryPluginDownloadURL)
5451

55-
downloadSpinner.Success(fmt.Sprintf("%s relay binary downloaded", RelayName))
52+
downloadSpinner.Success(fmt.Sprintf("%s binaries downloaded", RelayName))
5653

5754
// Verify relay binary
58-
verification.VerifyRelayBinary(tmpFilePath)
55+
verification.VerifyRelayBinary(BinaryName, tmpBinaryFilePath)
56+
57+
// Verify relay binary plugin
58+
verification.VerifyRelayBinary(fmt.Sprintf("%s plugin", RelayName), tmpBinaryPluginFilePath)
5959

60-
installSpinner, _ := pterm.DefaultSpinner.Start(fmt.Sprintf("Installing %s relay binary...", RelayName))
60+
installSpinner, _ := pterm.DefaultSpinner.Start(fmt.Sprintf("Installing %s binaries...", RelayName))
6161

6262
// Check if the service file exists and disable and stop the service if it does
6363
if files.FileExists(ServiceFilePath) {
@@ -69,8 +69,11 @@ func InstallRelayBinary() {
6969
installSpinner.UpdateText("Service file not found...")
7070
}
7171

72-
// Extract binary
73-
files.ExtractFile(tmpFilePath, relays.BinaryDestDir)
72+
// Extract relay binary
73+
files.ExtractFile(tmpBinaryFilePath, relays.BinaryDestDir)
74+
75+
// Extract relay binary plugin
76+
files.ExtractFile(tmpBinaryPluginFilePath, relays.BinaryDestDir)
7477

7578
// TODO
7679
// Currently, the downloaded binary is expected to have a name that matches the BinaryName variable
@@ -88,5 +91,5 @@ func InstallRelayBinary() {
8891
// Make the file executable
8992
files.SetPermissions(destPath, 0755)
9093

91-
installSpinner.Success(fmt.Sprintf("%s relay binary installed", RelayName))
94+
installSpinner.Success(fmt.Sprintf("%s binaries installed", RelayName))
9295
}

pkg/relays/strfry29/nginx_https.go

+3
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,9 @@ server {
122122
location / {
123123
return 301 https://%s$request_uri;
124124
}
125+
126+
# Only return Nginx in server header
127+
server_tokens off;
125128
}
126129
`, domainName, network.WWWDirPath, domainName, network.AcmeChallengeDirPath, network.CertificateDirPath, domainName, network.FullchainFile, network.CertificateDirPath, domainName, network.PrivkeyFile, network.CertificateDirPath, domainName, network.ChainFile, domainName, network.WWWDirPath, domainName, domainName)
127130

pkg/relays/wot_relay/install.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414

1515
// Function to download and make the binary executable
1616
func InstallRelayBinary(pubKey string) {
17-
downloadSpinner, _ := pterm.DefaultSpinner.Start(fmt.Sprintf("Downloading %s relay binary...", RelayName))
17+
downloadSpinner, _ := pterm.DefaultSpinner.Start(fmt.Sprintf("Downloading %s binary...", RelayName))
1818

1919
// Check for and remove existing git repository
2020
directories.RemoveDirectory(GitRepoTmpDirPath)
@@ -36,12 +36,12 @@ func InstallRelayBinary(pubKey string) {
3636
// Download and copy the file
3737
files.DownloadAndCopyFile(tmpFilePath, DownloadURL)
3838

39-
downloadSpinner.Success(fmt.Sprintf("%s relay binary downloaded", RelayName))
39+
downloadSpinner.Success(fmt.Sprintf("%s binary downloaded", RelayName))
4040

4141
// Verify relay binary
42-
verification.VerifyRelayBinary(tmpFilePath)
42+
verification.VerifyRelayBinary(RelayName, tmpFilePath)
4343

44-
installSpinner, _ := pterm.DefaultSpinner.Start(fmt.Sprintf("Installing %s relay binary...", RelayName))
44+
installSpinner, _ := pterm.DefaultSpinner.Start(fmt.Sprintf("Installing %s binary...", RelayName))
4545

4646
// Check if the service file exists and disable and stop the service if it does
4747
if files.FileExists(ServiceFilePath) {
@@ -81,5 +81,5 @@ func InstallRelayBinary(pubKey string) {
8181
// Make the file executable
8282
files.SetPermissions(destPath, 0755)
8383

84-
installSpinner.Success(fmt.Sprintf("%s relay binary installed", RelayName))
84+
installSpinner.Success(fmt.Sprintf("%s binary installed", RelayName))
8585
}

pkg/relays/wot_relay/nginx_https.go

+3
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,9 @@ server {
122122
location / {
123123
return 301 https://%s$request_uri;
124124
}
125+
126+
# Only return Nginx in server header
127+
server_tokens off;
125128
}
126129
`, domainName, network.WWWDirPath, domainName, network.AcmeChallengeDirPath, network.CertificateDirPath, domainName, network.FullchainFile, network.CertificateDirPath, domainName, network.PrivkeyFile, network.CertificateDirPath, domainName, network.ChainFile, domainName, network.WWWDirPath, domainName, domainName)
127130

pkg/verification/verify.go

+3-4
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,8 @@ import (
1313
)
1414

1515
// Function to verify relay binaries
16-
func VerifyRelayBinary(path string) {
17-
spinner, _ := pterm.DefaultSpinner.Start("Verifying relay binary...")
18-
pterm.Println()
16+
func VerifyRelayBinary(relayName, path string) {
17+
spinner, _ := pterm.DefaultSpinner.Start(fmt.Sprintf("Verifying %s binary...", relayName))
1918

2019
// Import NODE-TEC PGP key
2120
commands.PipeTwoCommands(exec.Command("curl", NodeTecKeybasePGPKeyURL), exec.Command("gpg", "--import"), "Failed to import NODE-TEC PGP key:")
@@ -88,7 +87,7 @@ func VerifyRelayBinary(path string) {
8887
// Search the manifest file for the hash
8988
if strings.Contains(string(data), sha512Hash) {
9089
spinner.UpdateText(fmt.Sprintf("Verified the SHA512 hash of the %s file", path))
91-
spinner.Success("Relay binary verified")
90+
spinner.Success(fmt.Sprintf("%s binary verified", relayName))
9291
} else {
9392
pterm.Println()
9493
pterm.Error.Println(fmt.Sprintf("Failed to verify the %s file, the SHA512 hash doesn't match the SHA512 hash in the %s file", path, relaysManifestFilePath))

0 commit comments

Comments
 (0)