From 0d87e2deae7c26f1007f07bc8cd297ca12d51b11 Mon Sep 17 00:00:00 2001 From: NBTX Date: Tue, 9 Jun 2020 22:17:39 +0100 Subject: [PATCH] Add linux support --- .github/workflows/main.yml | 2 +- README.md | 7 ++++++- build.sh | 1 - libproxy/crypto.go | 43 +++++++++++++++++++++++++------------- libproxy/proxy.go | 3 ++- stale_outputs_checked | 0 version.properties | 4 ++-- 7 files changed, 40 insertions(+), 20 deletions(-) create mode 100644 stale_outputs_checked diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 1b9e7e4..4778b81 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -30,7 +30,7 @@ jobs: run: | rm -rf ./out ./build.sh linux server - # ./build.sh linux desktop - Linux desktop build is not currently supported. + ./build.sh linux desktop - name: Upload Build Artifact uses: actions/upload-artifact@v2 with: diff --git a/README.md b/README.md index 1a2ea80..00a3590 100644 --- a/README.md +++ b/README.md @@ -11,11 +11,16 @@ A simple proxy server created by [@NBTX](https://github.com/NBTX/) for [Postwoman](https://github.com/liyasthomas/postwoman/) and hosted by [Apollo Software](https://apollosoftware.xyz/). +## Installation 📦 +**Proxywoman require `zenity` on Linux. This is available in most distribution package managers.** + +We're still working on automated installers. For now, copy the binary to a user-writeable location and launch the application. +A dialog will open and explain the certificate installation process - there are more detailed instructions in our [wiki](https://github.com/postwoman-io/proxywoman/wiki). + ## Demo 🚀 [https://postwoman.io](https://postwoman.io) - ## Building 🏗️ *These are bash scripts. In order to execute them on Windows, you will need to use some form of bash shell on Windows. We recommend [Git Bash](https://gitforwindows.org/).* diff --git a/build.sh b/build.sh index e12befc..ee324dd 100755 --- a/build.sh +++ b/build.sh @@ -171,7 +171,6 @@ elif [ "$PLATFORM" = "windows" ]; then # zip -r "Proxywoman-Windows-v${VERSION_NAME}.zip" "Proxywoman-Windows-v${VERSION_NAME}.exe" # cd "$WORKING_DIR" || exit 1 elif [ "$PLATFORM" = "linux" ]; then - echo "NOTICE: Proxywoman is untested and currently unsupported on Linux." GOOS="linux" GO111MODULE=on go build -ldflags "-X main.VersionName=$VERSION_NAME -X main.VersionCode=$VERSION_CODE" -o "$OUTPUT_DIR/Proxywoman-Linux-v${VERSION_NAME}" # Compressing output binaries diff --git a/libproxy/crypto.go b/libproxy/crypto.go index 5f3ac56..912a8e9 100644 --- a/libproxy/crypto.go +++ b/libproxy/crypto.go @@ -74,31 +74,37 @@ func CreateKeyPair() *[2]bytes.Buffer { } func EnsurePrivateKeyInstalled () error { - _, err := os.Stat(GetDataPath() + "/cert.pem"); - _, err = os.Stat(GetDataPath() + "/key.pem"); + _, err := os.Stat(GetOrCreateDataPath() + "/cert.pem"); + _, err = os.Stat(GetOrCreateDataPath() + "/key.pem"); // If the error is that the file does not exist, create the file // and then return no error (unless one was thrown in the process of creating the key.) if os.IsNotExist(err) { encodedPEM := CreateKeyPair(); - err = ioutil.WriteFile(GetDataPath() + "/cert.pem", encodedPEM[0].Bytes(), 0600); - err = ioutil.WriteFile(GetDataPath() + "/key.pem", encodedPEM[1].Bytes(), 0600); + err = ioutil.WriteFile(GetOrCreateDataPath() + "/cert.pem", encodedPEM[0].Bytes(), 0600); + err = ioutil.WriteFile(GetOrCreateDataPath() + "/key.pem", encodedPEM[1].Bytes(), 0600); if runtime.GOOS == "windows" { // Windows doesn't recognize .pem as certificates, but we can simply write the PEM data // into a .cer file and it works just fine! - err = ioutil.WriteFile(GetDataPath() + "/cert.cer", encodedPEM[0].Bytes(), 0600); + err = ioutil.WriteFile(GetOrCreateDataPath() + "/cert.cer", encodedPEM[0].Bytes(), 0600); } - if runtime.GOOS == "darwin" { - _ = exec.Command("open", GetDataPath()).Run(); - _, _ = dlgs.Warning("Proxywoman", "Proxywoman needs you to install a root certificate authority (cert.pem).\nPlease double-click the certificate file to open it in Keychain Access and follow the installation and trust process.\n\nFor more information about this process and why it's required, please click the Postwoman icon in the status tray and select 'Help'.\n\nClick OK when you have installed the certificate and marked it as trusted."); - } + if err == nil { + if runtime.GOOS == "darwin" { + _ = exec.Command("open", GetOrCreateDataPath()).Run(); + _, err = dlgs.Warning("Proxywoman", "Proxywoman needs you to install a root certificate authority (cert.pem).\nPlease double-click the certificate file to open it in Keychain Access and follow the installation and trust process.\n\nFor more information about this process and why it's required, please click the Postwoman icon in the status tray and select 'Help'.\n\nClick OK when you have installed the certificate and marked it as trusted."); + } + if runtime.GOOS == "windows" { + _ = exec.Command("explorer.exe", GetOrCreateDataPath()+string(os.PathSeparator)+"cert.cer").Run(); + _, err = dlgs.Warning("Proxywoman", "Proxywoman needs you to install a root certificate authority (cert.cer).\nPlease install the certificate (opened) into the 'Trusted Root Certification Authorities' store for the Local Machine.\n\nFor more information about this process and why it's required, please click the Postwoman icon in the system tray and select 'Help'.\n\nClick OK when you have installed the certificate and marked it as trusted."); + } - if runtime.GOOS == "windows" { - _ = exec.Command("explorer.exe", GetDataPath() + string(os.PathSeparator) + "cert.cer").Run(); - _, _ = dlgs.Warning("Proxywoman", "Proxywoman needs you to install a root certificate authority (cert.cer).\nPlease install the certificate (opened) into the 'Trusted Root Certification Authorities' store for the Local Machine.\n\nFor more information about this process and why it's required, please click the Postwoman icon in the system tray and select 'Help'.\n\nClick OK when you have installed the certificate and marked it as trusted."); + if runtime.GOOS == "linux" { + _ = exec.Command("xdg-open", GetOrCreateDataPath()).Run(); + _, err = dlgs.Warning("Proxywoman", "Proxywoman needs you to install a root certificate authority (cert.pem).\n[INSTRUCTIONS PENDING]\n\nFor more information about this process and why it's required, please click the Postwoman icon in the status tray and select 'Help'.\n\nClick OK when you have installed the certificate and marked it as trusted."); + } } return err; @@ -108,7 +114,16 @@ func EnsurePrivateKeyInstalled () error { return err; } -func GetDataPath() string { +func GetOrCreateDataPath() string { dir, _ := filepath.Abs(filepath.Dir(os.Args[0])); - return dir + string(os.PathSeparator) + "data"; + + dataDir := dir + string(os.PathSeparator) + "data"; + + // If the data directory stat fails because the direcotry does not exist, + // create the data directory. + if _, err := os.Stat(dataDir); os.IsNotExist(err) { + _ = os.Mkdir(dataDir, 0700); + } + + return dataDir; } \ No newline at end of file diff --git a/libproxy/proxy.go b/libproxy/proxy.go index 4d816b6..593c5aa 100644 --- a/libproxy/proxy.go +++ b/libproxy/proxy.go @@ -67,11 +67,12 @@ func Initialize( err := EnsurePrivateKeyInstalled(); if err != nil { + log.Println(err.Error()); onStatusChange("An error occurred.", false); } go func() { - httpServerError := http.ListenAndServeTLS(proxyURL, GetDataPath() + "/cert.pem", GetDataPath() + "/key.pem", nil); + httpServerError := http.ListenAndServeTLS(proxyURL, GetOrCreateDataPath() + "/cert.pem", GetOrCreateDataPath() + "/key.pem", nil); if httpServerError != nil { onStatusChange("An error occurred.", false); diff --git a/stale_outputs_checked b/stale_outputs_checked new file mode 100644 index 0000000..e69de29 diff --git a/version.properties b/version.properties index 285a25e..66353d2 100644 --- a/version.properties +++ b/version.properties @@ -1,3 +1,3 @@ # Version Information -VERSION_NAME=0.0.2 -VERSION_CODE=2 +VERSION_NAME=0.0.3 +VERSION_CODE=3