Use zenity password setter in static builds
This commit is contained in:
28
main.go
28
main.go
@ -9,12 +9,14 @@ import (
|
|||||||
"os/signal"
|
"os/signal"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/cloudfoundry/jibber_jabber"
|
"github.com/cloudfoundry/jibber_jabber"
|
||||||
i2cpcheck "github.com/eyedeekay/checki2cp"
|
i2cpcheck "github.com/eyedeekay/checki2cp"
|
||||||
"github.com/itchio/damage"
|
"github.com/itchio/damage"
|
||||||
"github.com/itchio/damage/hdiutil"
|
"github.com/itchio/damage/hdiutil"
|
||||||
"github.com/itchio/headway/state"
|
"github.com/itchio/headway/state"
|
||||||
|
"github.com/ncruces/zenity"
|
||||||
tbget "i2pgit.org/idk/i2p.plugins.tor-manager/get"
|
tbget "i2pgit.org/idk/i2p.plugins.tor-manager/get"
|
||||||
tbserve "i2pgit.org/idk/i2p.plugins.tor-manager/serve"
|
tbserve "i2pgit.org/idk/i2p.plugins.tor-manager/serve"
|
||||||
|
|
||||||
@ -93,6 +95,32 @@ var (
|
|||||||
/*ptop = flag.Bool("p2p", tbget.TorrentReady(), "Use bittorrent over I2P to download the initial copy of Tor Browser")*/
|
/*ptop = flag.Bool("p2p", tbget.TorrentReady(), "Use bittorrent over I2P to download the initial copy of Tor Browser")*/
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func Password() string {
|
||||||
|
require_password := os.Getenv("TOR_MANAGER_REQUIRE_PASSWORD")
|
||||||
|
if !PluginStat() {
|
||||||
|
require_password = "true"
|
||||||
|
}
|
||||||
|
if require_password == "true" || require_password == "1" {
|
||||||
|
passwd, err := zenity.Entry(
|
||||||
|
"Enter a password if you want to encrypt the working directory",
|
||||||
|
zenity.Title("Work Directory Encryption"),
|
||||||
|
zenity.CancelLabel("Don't encrypt"),
|
||||||
|
zenity.OKLabel("Encrypt"),
|
||||||
|
zenity.Width(400),
|
||||||
|
zenity.EntryText("password"),
|
||||||
|
)
|
||||||
|
if err != nil {
|
||||||
|
if !strings.Contains(err.Error(), "canceled") {
|
||||||
|
log.Panicln(err)
|
||||||
|
}
|
||||||
|
log.Println("Password dialog canceled")
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
return passwd
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
func Mirror() string {
|
func Mirror() string {
|
||||||
if tbget.TestHTTPDefaultProxy() {
|
if tbget.TestHTTPDefaultProxy() {
|
||||||
return "http://dist.torproject.i2p/torbrowser/"
|
return "http://dist.torproject.i2p/torbrowser/"
|
||||||
|
@ -9,10 +9,6 @@ import (
|
|||||||
|
|
||||||
var shutdown = false
|
var shutdown = false
|
||||||
|
|
||||||
func Password() string {
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
||||||
func runSysTray(down bool) {
|
func runSysTray(down bool) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
28
systray.go
28
systray.go
@ -8,44 +8,16 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/eyedeekay/go-i2pcontrol"
|
"github.com/eyedeekay/go-i2pcontrol"
|
||||||
"github.com/getlantern/systray"
|
"github.com/getlantern/systray"
|
||||||
"github.com/ncruces/zenity"
|
|
||||||
"i2pgit.org/idk/i2p.plugins.tor-manager/icon"
|
"i2pgit.org/idk/i2p.plugins.tor-manager/icon"
|
||||||
)
|
)
|
||||||
|
|
||||||
var running = false
|
var running = false
|
||||||
var shutdown = false
|
var shutdown = false
|
||||||
|
|
||||||
func Password() string {
|
|
||||||
require_password := os.Getenv("TOR_MANAGER_REQUIRE_PASSWORD")
|
|
||||||
if !PluginStat() {
|
|
||||||
require_password = "true"
|
|
||||||
}
|
|
||||||
if require_password == "true" || require_password == "1" {
|
|
||||||
passwd, err := zenity.Entry(
|
|
||||||
"Enter a password if you want to encrypt the working directory",
|
|
||||||
zenity.Title("Work Directory Encryption"),
|
|
||||||
zenity.CancelLabel("Don't encrypt"),
|
|
||||||
zenity.OKLabel("Encrypt"),
|
|
||||||
zenity.Width(400),
|
|
||||||
zenity.EntryText("password"),
|
|
||||||
)
|
|
||||||
if err != nil {
|
|
||||||
if !strings.Contains(err.Error(), "canceled") {
|
|
||||||
log.Panicln(err)
|
|
||||||
}
|
|
||||||
log.Println("Password dialog canceled")
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
return passwd
|
|
||||||
}
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
||||||
func onReady() {
|
func onReady() {
|
||||||
systray.SetTemplateIcon(icon.Data, icon.Data)
|
systray.SetTemplateIcon(icon.Data, icon.Data)
|
||||||
systray.SetTitle("Tor Manager for I2P")
|
systray.SetTitle("Tor Manager for I2P")
|
||||||
|
Reference in New Issue
Block a user