diff --git a/Makefile b/Makefile index 8ffff27db..7936e267d 100644 --- a/Makefile +++ b/Makefile @@ -59,6 +59,8 @@ VERSION_LDFLAGS:= -X \"golift.io/version.Branch=$(BRANCH) ($(COMMIT))\" \ -X \"golift.io/version.Revision=$(ITERATION)\" \ -X \"golift.io/version.Version=$(VERSION)\" +WINDOWS_LDFLAGS:= -H=windowsgui + # Makefile targets follow. all: notifiarr diff --git a/go.mod b/go.mod index 79f76cbbd..ca4efdbd9 100644 --- a/go.mod +++ b/go.mod @@ -14,7 +14,6 @@ require ( github.com/gen2brain/dlgs v0.0.0-20220603100644-40c77870fa8d github.com/go-ping/ping v1.1.0 github.com/go-sql-driver/mysql v1.8.1 - github.com/gonutz/w32/v2 v2.11.1 github.com/gorilla/mux v1.8.1 github.com/gorilla/schema v1.3.0 github.com/gorilla/securecookie v1.1.2 diff --git a/go.sum b/go.sum index c57db4415..191553980 100644 --- a/go.sum +++ b/go.sum @@ -102,8 +102,6 @@ github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5y github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= -github.com/gonutz/w32/v2 v2.11.1 h1:plG738ZY7VIkPGf3adZ6lFeAf2evCKrULKyZT5GrPoc= -github.com/gonutz/w32/v2 v2.11.1/go.mod h1:MgtHx0AScDVNKyB+kjyPder4xIi3XAcHS6LDDU2DmdE= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= diff --git a/main.go b/main.go index 1b84f1046..da5c5db36 100644 --- a/main.go +++ b/main.go @@ -23,14 +23,12 @@ import ( // @in header // @name X-API-Key func main() { - ui.HideConsoleWindow() // setup log package in case we throw an error in main.go before logging is setup. log.SetFlags(log.LstdFlags) log.SetPrefix("[ERROR] ") defer func() { if r := recover(); r != nil { - ui.ShowConsoleWindow() log.Printf("Go Panic! %s\n%v\n%s", mnd.BugIssue, r, string(debug.Stack())) } }() diff --git a/pkg/bindata/templates/tunnel.html b/pkg/bindata/templates/tunnel.html index 517bbc393..3e401e5de 100644 --- a/pkg/bindata/templates/tunnel.html +++ b/pkg/bindata/templates/tunnel.html @@ -1,7 +1,7 @@

Site Tunnel

This client keeps a persistent websocket connection to a notifiarr.com - Mulery tunnel. + Mulery tunnel. This tunnel allows the website to make requests to your client without the need for opening a port, or having a static IP. This page allows you to select your primary tunnel and which tunnel you wish to use as backup in case the primary @@ -12,7 +12,7 @@

Site Tunnel

Select another fast tunnel as backup.

{{$activeTunnel := (cache "activeTunnel")}} -

  • Active Tunnel: {{if $activeTunnel}}{{$activeTunnel.Data}}{{else}}unknown{{end}}
  • +
  • Active Tunnel: {{if $activeTunnel}}{{$activeTunnel.Data}}{{else}}unknown{{end}}
  • @@ -33,10 +33,11 @@

    Site Tunnel

    {{- range $idx, $mule := .ClientInfo.User.Mulery}} {{$primary := and (gt (len $.ClientInfo.User.Tunnels) 0) (eq (index $.ClientInfo.User.Tunnels 0) $mule.Socket)}} - - + + {{$mule.Location}} + {{$mule.Socket}} {{- end}} @@ -48,7 +49,7 @@

    Site Tunnel

    {{- range $mule := .ClientInfo.User.Mulery}} {{$backup := and (gt (len $.ClientInfo.User.Tunnels) 1) (eq (index $.ClientInfo.User.Tunnels 1) $mule.Socket)}} {{- end}} @@ -62,7 +63,7 @@

    Tunnel Stats

    {{- if .Tunnel }} {{- range $socket, $stats := .Tunnel.PoolStats }} - Socket URL ({{if $stats.Active}}active{{else}}inactive{{end}}) + Socket URL ({{if $stats.Active}}active{{else}}inactive{{end}}) {{$socket}} Disconnects{{$stats.Disconnects}} diff --git a/pkg/client/tray.go b/pkg/client/tray.go index b8ec94c96..2a78b3002 100644 --- a/pkg/client/tray.go +++ b/pkg/client/tray.go @@ -327,17 +327,6 @@ func (c *Client) debugMenu() { c.Config.Services.RunChecks("log") }) - menu["console"] = debug.AddSubMenuItem("Console", "toggle the console window") - menu["console"].Click(func() { - if menu["console"].Checked() { - menu["console"].Uncheck() - ui.HideConsoleWindow() - } else { - menu["console"].Check() - ui.ShowConsoleWindow() - } - }) - if runtime.GOOS != mnd.Windows { menu["console"].Hide() } diff --git a/pkg/client/tunnel.go b/pkg/client/tunnel.go index 18cae399f..ab17f29aa 100644 --- a/pkg/client/tunnel.go +++ b/pkg/client/tunnel.go @@ -115,12 +115,12 @@ func (c *Client) roundRobinConfig(ci *clientinfo.ClientInfo) *mulery.RoundRobinC return &mulery.RoundRobinConfig{ RetryInterval: interval, Callback: func(_ context.Context, socket string) { - data.Save("activeTunnel", socket) + defer data.Save("activeTunnel", socket) // Tell the website we connected to a new tunnel, so it knows how to reach us. c.website.SendData(&website.Request{ Route: website.TunnelRoute, Event: website.EventSignal, - Payload: map[string]string{"socket": socket}, + Payload: map[string]interface{}{"socket": socket, "previous": data.Get("activeTunnel")}, LogMsg: fmt.Sprintf("Update Tunnel Target (%s)", socket), LogPayload: true, }) diff --git a/pkg/logs/logs.go b/pkg/logs/logs.go index 96c393b15..2aee0d47d 100644 --- a/pkg/logs/logs.go +++ b/pkg/logs/logs.go @@ -16,7 +16,6 @@ import ( "github.com/Notifiarr/notifiarr/pkg/logs/share" "github.com/Notifiarr/notifiarr/pkg/mnd" - "github.com/Notifiarr/notifiarr/pkg/ui" homedir "github.com/mitchellh/go-homedir" "golift.io/rotatorr" "golift.io/rotatorr/timerotator" @@ -168,7 +167,6 @@ func (l *Logger) Close() (errors []error) { // CapturePanic can be deferred in any go routine to log any panic that occurs. func (l *Logger) CapturePanic() { if r := recover(); r != nil { - ui.ShowConsoleWindow() l.ErrorLog.Output(callDepth, //nolint:errcheck fmt.Sprintf("Go Panic! %s\n%s-%s %s %v\n%s", mnd.BugIssue, version.Version, version.Revision, version.Branch, r, string(debug.Stack()))) diff --git a/pkg/ui/ui_darwin.go b/pkg/ui/ui_darwin.go index 63e104dc7..7720a63c3 100644 --- a/pkg/ui/ui_darwin.go +++ b/pkg/ui/ui_darwin.go @@ -22,12 +22,6 @@ func HasGUI() bool { return hasGUI } -// HideConsoleWindow doesn't work on maacOS. -func HideConsoleWindow() {} - -// ShowConsoleWindow does nothing on OSes besides Windows. -func ShowConsoleWindow() {} - func Notify(msg string, vars ...interface{}) error { if !hasGUI { return nil diff --git a/pkg/ui/ui_other.go b/pkg/ui/ui_other.go index c7f1f2378..8c980f4a2 100644 --- a/pkg/ui/ui_other.go +++ b/pkg/ui/ui_other.go @@ -25,12 +25,6 @@ func Notify(_ string, _ ...interface{}) error { return nil } -// HideConsoleWindow doesn't work on most OSes. -func HideConsoleWindow() {} - -// ShowConsoleWindow does nothing on OSes besides Windows. -func ShowConsoleWindow() {} - // StartCmd starts a command. func StartCmd(c string, v ...string) error { cmd := exec.Command(c, v...) diff --git a/pkg/ui/ui_windows.go b/pkg/ui/ui_windows.go index ecb0056b7..4da34afc0 100644 --- a/pkg/ui/ui_windows.go +++ b/pkg/ui/ui_windows.go @@ -12,7 +12,6 @@ import ( "github.com/Notifiarr/notifiarr/pkg/bindata" "github.com/Notifiarr/notifiarr/pkg/mnd" "github.com/gen2brain/beeep" - "github.com/gonutz/w32/v2" "github.com/kardianos/osext" ) @@ -68,26 +67,6 @@ func getPNG() string { return pngPath } -// HideConsoleWindow makes the console window vanish on startup. -func HideConsoleWindow() { - if console := w32.GetConsoleWindow(); console != 0 { - _, consoleProcID := w32.GetWindowThreadProcessId(console) - if w32.GetCurrentProcessId() == consoleProcID { - w32.ShowWindowAsync(console, w32.SW_HIDE) - } - } -} - -// ShowConsoleWindow does nothing on OSes besides Windows. -func ShowConsoleWindow() { - if console := w32.GetConsoleWindow(); console != 0 { - _, consoleProcID := w32.GetWindowThreadProcessId(console) - if w32.GetCurrentProcessId() == consoleProcID { - w32.ShowWindowAsync(console, w32.SW_SHOW) - } - } -} - // StartCmd starts a command. func StartCmd(c string, v ...string) error { cmd := exec.Command(c, v...) diff --git a/pkg/website/clientinfo/clientinfo.go b/pkg/website/clientinfo/clientinfo.go index 6caf3499a..616cb6d87 100644 --- a/pkg/website/clientinfo/clientinfo.go +++ b/pkg/website/clientinfo/clientinfo.go @@ -52,8 +52,9 @@ type ClientInfo struct { // MuleryServer is data from the website. It's a tunnel's https and wss urls. type MuleryServer struct { - Tunnel string `json:"tunnel"` // ex: "https://africa.notifiarr.com/" - Socket string `json:"socket"` // ex: "wss://africa.notifiarr.com/register" + Tunnel string `json:"tunnel"` // ex: "https://africa.notifiarr.com/" + Socket string `json:"socket"` // ex: "wss://africa.notifiarr.com/register" + Location string `json:"location"` // ex: "Nairobi, Kenya, Africa" } // CronConfig defines a custom GET timer from the website.