Skip to content

Commit

Permalink
Use github.com/wzshiming/systray instead of github.com/getlantern/sys…
Browse files Browse the repository at this point in the history
…tray
  • Loading branch information
wzshiming committed Jan 26, 2022
1 parent b08b834 commit b0fb1f8
Show file tree
Hide file tree
Showing 16 changed files with 418 additions and 41 deletions.
2 changes: 1 addition & 1 deletion app/tray/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import (
"path/filepath"
"time"

"github.com/getlantern/systray"
"github.com/wzshiming/jumpway/config"
"github.com/wzshiming/jumpway/i18n"
"github.com/wzshiming/jumpway/log"
"github.com/wzshiming/notify"
"github.com/wzshiming/systray"
)

type App struct {
Expand Down
2 changes: 1 addition & 1 deletion app/tray/on_ready.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package tray

import (
"github.com/getlantern/systray"
"github.com/wzshiming/jumpway/i18n"
"github.com/wzshiming/jumpway/icon"
"github.com/wzshiming/systray"
)

func (a *App) onReady() {
Expand Down
2 changes: 1 addition & 1 deletion app/tray/tray_about.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package tray

import (
"github.com/getlantern/systray"
"github.com/pkg/browser"
"github.com/wzshiming/jumpway/i18n"
"github.com/wzshiming/jumpway/log"
"github.com/wzshiming/systray"
)

func (a *App) ItemAbout(menu *systray.MenuItem) {
Expand Down
2 changes: 1 addition & 1 deletion app/tray/tray_daemon.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package tray

import (
"github.com/getlantern/systray"
"github.com/wzshiming/jumpway/daemon"
"github.com/wzshiming/systray"
)

func (a *App) ItemDaemon(menu *systray.MenuItem) {
Expand Down
2 changes: 1 addition & 1 deletion app/tray/tray_edit_config.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package tray

import (
"github.com/getlantern/systray"
"github.com/wzshiming/jumpway/config"
"github.com/wzshiming/jumpway/i18n"
"github.com/wzshiming/jumpway/log"
"github.com/wzshiming/systray"
)

func (a *App) ItemEditConfig(menu *systray.MenuItem) {
Expand Down
17 changes: 16 additions & 1 deletion app/tray/tray_export_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ package tray

import (
"fmt"
"net"

"github.com/atotto/clipboard"
"github.com/getlantern/systray"
"github.com/wzshiming/jumpway/i18n"
"github.com/wzshiming/jumpway/log"
"github.com/wzshiming/systray"
)

func (a *App) ItemExportCommand(menu *systray.MenuItem) {
Expand All @@ -18,6 +19,9 @@ func (a *App) ItemExportCommand(menu *systray.MenuItem) {

mPowerShell := menu.AddSubMenuItem("PowerShell", "")
go a.itemExportCommandPowerShell(mPowerShell)

mShellGit := menu.AddSubMenuItem("Shell git", "")
go a.itemExportCommandShellGit(mShellGit)
}

func (a *App) itemExportCommandShell(menu *systray.MenuItem) {
Expand Down Expand Up @@ -49,3 +53,14 @@ func (a *App) itemExportCommandPowerShell(menu *systray.MenuItem) {
}
}
}

func (a *App) itemExportCommandShellGit(menu *systray.MenuItem) {
for range menu.ClickedCh {
host, port, _ := net.SplitHostPort(a.Address)
command := fmt.Sprintf("export GIT_SSH_COMMAND='ssh -o ProxyCommand=\"nc -x %s:%s %%h %%p\"' http_proxy=http://%s https_proxy=http://%s; ", host, port, a.Address, a.Address)
err := clipboard.WriteAll(command)
if err != nil {
log.Error(err, i18n.WriteClipboard())
}
}
}
2 changes: 1 addition & 1 deletion app/tray/tray_log.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package tray

import (
"github.com/getlantern/systray"
"github.com/pkg/browser"
"github.com/wzshiming/jumpway/i18n"
"github.com/wzshiming/jumpway/log"
"github.com/wzshiming/systray"
)

func (a *App) ItemLog(menu *systray.MenuItem) {
Expand Down
2 changes: 1 addition & 1 deletion app/tray/tray_quit.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package tray

import (
"github.com/getlantern/systray"
"github.com/wzshiming/systray"
)

func (a *App) ItemQuit(menu *systray.MenuItem) {
Expand Down
16 changes: 14 additions & 2 deletions app/tray/tray_reload_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"net"
"strconv"

"github.com/getlantern/systray"
"github.com/wzshiming/bridge/chain"
"github.com/wzshiming/bridge/protocols/local"
"github.com/wzshiming/hostmatcher"
Expand All @@ -14,6 +13,7 @@ import (
"github.com/wzshiming/jumpway/i18n"
"github.com/wzshiming/jumpway/log"
"github.com/wzshiming/jumpway/utils"
"github.com/wzshiming/systray"
)

func (a *App) ItemReloadConfig(menu *systray.MenuItem) {
Expand Down Expand Up @@ -49,7 +49,8 @@ func (a *App) ItemReloadConfig(menu *systray.MenuItem) {
return
}

a.Address = listener.Addr().String()
a.Address = formatAddress(listener.Addr().String())

a.RawHost = host
a.UpdateStatus()
go func() {
Expand Down Expand Up @@ -85,3 +86,14 @@ func (a *App) ItemReloadConfig(menu *systray.MenuItem) {
check()
}
}

func formatAddress(address string) string {
host, port, err := net.SplitHostPort(address)
if err != nil {
return address
}
if net.ParseIP(host).IsUnspecified() {
host = "127.0.0.1"
}
return net.JoinHostPort(host, port)
}
2 changes: 1 addition & 1 deletion app/tray/tray_status.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package tray

import (
"github.com/getlantern/systray"
"github.com/wzshiming/jumpway/i18n"
"github.com/wzshiming/systray"
)

func (a *App) ItemStatus(menu *systray.MenuItem) {
Expand Down
2 changes: 1 addition & 1 deletion app/tray/tray_system_proxy.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package tray

import (
"github.com/getlantern/systray"
"github.com/wzshiming/jumpway/i18n"
"github.com/wzshiming/jumpway/log"
"github.com/wzshiming/sysproxy"
"github.com/wzshiming/systray"
)

func (a *App) ItemProxyMode(global, manual *systray.MenuItem) {
Expand Down
2 changes: 1 addition & 1 deletion app/tray/tray_view.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ package tray
import (
"fmt"

"github.com/getlantern/systray"
"github.com/pkg/browser"
"github.com/wzshiming/jumpway/i18n"
"github.com/wzshiming/logger"
"github.com/wzshiming/systray"
)

func (a *App) ItemView(menu *systray.MenuItem) {
Expand Down

0 comments on commit b0fb1f8

Please sign in to comment.