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 20, 2022
1 parent b08b834 commit 4484ddb
Show file tree
Hide file tree
Showing 14 changed files with 43 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
10 changes: 1 addition & 9 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ go 1.17
require (
github.com/Xuanwo/go-locale v1.1.0
github.com/atotto/clipboard v0.1.4
github.com/getlantern/systray v1.1.0
github.com/gorilla/handlers v1.5.1
github.com/gorilla/mux v1.8.0
github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8
Expand All @@ -20,6 +19,7 @@ require (
github.com/wzshiming/openapiui/v2 v2.0.0
github.com/wzshiming/sysnotify v0.0.2
github.com/wzshiming/sysproxy v0.2.2
github.com/wzshiming/systray v1.2.1
golang.org/x/text v0.3.7
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b
)
Expand All @@ -28,17 +28,9 @@ require (
github.com/Microsoft/go-winio v0.5.0 // indirect
github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da // indirect
github.com/felixge/httpsnoop v1.0.1 // indirect
github.com/getlantern/context v0.0.0-20190109183933-c447772a6520 // indirect
github.com/getlantern/errors v0.0.0-20190325191628-abdb3e3e36f7 // indirect
github.com/getlantern/golog v0.0.0-20190830074920-4ef2e798c2d7 // indirect
github.com/getlantern/hex v0.0.0-20190417191902-c6586a6fe0b7 // indirect
github.com/getlantern/hidden v0.0.0-20190325191715-f02dbb02be55 // indirect
github.com/getlantern/ops v0.0.0-20190325191751-d70cb0d6f85f // indirect
github.com/go-logr/logr v0.3.0 // indirect
github.com/go-logr/zapr v0.3.0 // indirect
github.com/go-stack/stack v1.8.0 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/oxtoacart/bpool v0.0.0-20190530202638-03653db5a59c // indirect
github.com/wzshiming/commandproxy v0.2.0 // indirect
github.com/wzshiming/emux v0.2.1 // indirect
github.com/wzshiming/httpproxy v0.4.1 // indirect
Expand Down
21 changes: 2 additions & 19 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,11 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/felixge/httpsnoop v1.0.1 h1:lvB5Jl89CsZtGIWuTcDM1E/vkVs49/Ml7JJe07l8SPQ=
github.com/felixge/httpsnoop v1.0.1/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
github.com/getlantern/context v0.0.0-20190109183933-c447772a6520 h1:NRUJuo3v3WGC/g5YiyF790gut6oQr5f3FBI88Wv0dx4=
github.com/getlantern/context v0.0.0-20190109183933-c447772a6520/go.mod h1:L+mq6/vvYHKjCX2oez0CgEAJmbq1fbb/oNJIWQkBybY=
github.com/getlantern/errors v0.0.0-20190325191628-abdb3e3e36f7 h1:6uJ+sZ/e03gkbqZ0kUG6mfKoqDb4XMAzMIwlajq19So=
github.com/getlantern/errors v0.0.0-20190325191628-abdb3e3e36f7/go.mod h1:l+xpFBrCtDLpK9qNjxs+cHU6+BAdlBaxHqikB6Lku3A=
github.com/getlantern/golog v0.0.0-20190830074920-4ef2e798c2d7 h1:guBYzEaLz0Vfc/jv0czrr2z7qyzTOGC9hiQ0VC+hKjk=
github.com/getlantern/golog v0.0.0-20190830074920-4ef2e798c2d7/go.mod h1:zx/1xUUeYPy3Pcmet8OSXLbF47l+3y6hIPpyLWoR9oc=
github.com/getlantern/hex v0.0.0-20190417191902-c6586a6fe0b7 h1:micT5vkcr9tOVk1FiH8SWKID8ultN44Z+yzd2y/Vyb0=
github.com/getlantern/hex v0.0.0-20190417191902-c6586a6fe0b7/go.mod h1:dD3CgOrwlzca8ed61CsZouQS5h5jIzkK9ZWrTcf0s+o=
github.com/getlantern/hidden v0.0.0-20190325191715-f02dbb02be55 h1:XYzSdCbkzOC0FDNrgJqGRo8PCMFOBFL9py72DRs7bmc=
github.com/getlantern/hidden v0.0.0-20190325191715-f02dbb02be55/go.mod h1:6mmzY2kW1TOOrVy+r41Za2MxXM+hhqTtY3oBKd2AgFA=
github.com/getlantern/ops v0.0.0-20190325191751-d70cb0d6f85f h1:wrYrQttPS8FHIRSlsrcuKazukx/xqO/PpLZzZXsF+EA=
github.com/getlantern/ops v0.0.0-20190325191751-d70cb0d6f85f/go.mod h1:D5ao98qkA6pxftxoqzibIBBrLSUli+kYnJqrgBf9cIA=
github.com/getlantern/systray v1.1.0 h1:U0wCEqseLi2ok1fE6b88gJklzriavPJixZysZPkZd/Y=
github.com/getlantern/systray v1.1.0/go.mod h1:AecygODWIsBquJCJFop8MEQcJbWFfw/1yWbVabNgpCM=
github.com/go-logr/logr v0.2.0/go.mod h1:z6/tIYblkpsD+a4lm/fGIIU9mZ+XfAiaFtq7xTgseGU=
github.com/go-logr/logr v0.3.0 h1:q4c+kbcR0d5rSurhBR8dIgieOaYpXtsdTYfx22Cu6rs=
github.com/go-logr/logr v0.3.0/go.mod h1:z6/tIYblkpsD+a4lm/fGIIU9mZ+XfAiaFtq7xTgseGU=
github.com/go-logr/zapr v0.3.0 h1:iyiCRZ29uPmbO7mWIjOEiYMXrTxZWTyK4tCatLyGpUY=
github.com/go-logr/zapr v0.3.0/go.mod h1:qhKdvif7YF5GI9NWEpyxTSSBdGmzkNguibrdCNVPunU=
github.com/go-stack/stack v1.8.0 h1:5SgMzNM5HxrEjV0ww2lTmX6E2Izsfxas4+YHWRs3Lsk=
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM=
github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
Expand All @@ -52,8 +36,6 @@ github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORN
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/oxtoacart/bpool v0.0.0-20190530202638-03653db5a59c h1:rp5dCmg/yLR3mgFuSOe4oEnDDmGLROTvMragMUXpTQw=
github.com/oxtoacart/bpool v0.0.0-20190530202638-03653db5a59c/go.mod h1:X07ZCGwUbLaax7L0S3Tw4hpejzu63ZrrQiUe6W0hcy0=
github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 h1:KoWmjvw+nsYOo29YJK9vDA65RGE3NrOnUtO7a+RF9HU=
github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
Expand Down Expand Up @@ -115,6 +97,8 @@ github.com/wzshiming/sysnotify v0.0.2 h1:a5h1lm2D35Sof8MaM0htjwFRNNqkx42o3pgsoAR
github.com/wzshiming/sysnotify v0.0.2/go.mod h1:wV51YHA43Y1rhnhTi4qdpyPMoyG+sB1bAGORkANLW5I=
github.com/wzshiming/sysproxy v0.2.2 h1:OOZ7jRier8qA5U5hnzHwJCLlZleWqdqiNKEhJY+0H1E=
github.com/wzshiming/sysproxy v0.2.2/go.mod h1:Epx6hex0nK1YhLHDnIhrhusgCtBQFR2NQPhM8WlMDTc=
github.com/wzshiming/systray v1.2.1 h1:VHt4DA9+6GBbv/zW/kcP2azYU71i5eFXNMntrKSSnNI=
github.com/wzshiming/systray v1.2.1/go.mod h1:Kyt+ovrTuHHlcF42YLu37TaP9NS5gyJcvpa8VQbX8zQ=
github.com/wzshiming/trie v0.0.1 h1:6xnhRyO5tZWR6aKjEpFfm8KSNNHYsNbpKrY1+NdyHME=
github.com/wzshiming/trie v0.0.1/go.mod h1:Z20IrQFTHnjWz//dssIoiEPWInBZFyuFlPOFPxV0Rec=
github.com/xtaci/smux v1.5.16 h1:FBPYOkW8ZTjLKUM4LI4xnnuuDC8CQ/dB04HD519WoEk=
Expand Down Expand Up @@ -150,7 +134,6 @@ golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJ
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200722175500-76b94024e4b6/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
Expand Down

0 comments on commit 4484ddb

Please sign in to comment.