Skip to content

Commit

Permalink
Display public IP in submenu
Browse files Browse the repository at this point in the history
  • Loading branch information
rubiojr committed Feb 3, 2020
1 parent 4593c78 commit 9e9768e
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
1 change: 1 addition & 0 deletions docs/configs/vpnflag.service
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Description=VPNFlag - A little tool to display VPN country exit flag and "networ
[Service]
ExecStart=/usr/local/bin/vpnflag
Restart=on-failure
Environment=PATH=/usr/bin

# Hardening
SystemCallArchitectures=native
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ go 1.13

require (
bazil.org/fuse v0.0.0-20200117225306-7b5117fecadc
github.com/atotto/clipboard v0.1.2
github.com/getlantern/systray v0.0.0-20200109124156-9abdfb6448b3
github.com/ip2location/ip2location-go v8.2.0+incompatible
github.com/jayco/go-emoji-flag v0.0.0-20190810054606-01604da018da
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
bazil.org/fuse v0.0.0-20200117225306-7b5117fecadc h1:utDghgcjE8u+EBjHOgYT+dJPcnDF05KqWMBcjuJy510=
bazil.org/fuse v0.0.0-20200117225306-7b5117fecadc/go.mod h1:FbcW6z/2VytnFDhZfumh8Ss8zxHE6qpMP5sHTRe0EaM=
github.com/atotto/clipboard v0.1.2 h1:YZCtFu5Ie8qX2VmVTBnrqLSiU9XOWwqNRmdT3gIQzbY=
github.com/atotto/clipboard v0.1.2/go.mod h1:ZY9tmq7sm5xIbd9bOK4onWV4S6X0u6GY7Vn0Yu86PYI=
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/getlantern/context v0.0.0-20190109183933-c447772a6520 h1:NRUJuo3v3WGC/g5YiyF790gut6oQr5f3FBI88Wv0dx4=
Expand Down
17 changes: 15 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,32 @@ import (
"github.com/oschwald/geoip2-golang"
"github.com/rdegges/go-ipify"

"github.com/atotto/clipboard"
"github.com/rakyll/statik/fs"
_ "github.com/rubiojr/vpnflag/statik" // TODO: Replace with the absolute import path
)

var configDir, dbPath string
var dbOpen = false
var ipMenu *systray.MenuItem
var currentIP string

func main() {
quit := systray.AddMenuItem("Quit", "Quit the whole app")
ipMenu = systray.AddMenuItem("Public IP", "Public IP address")
go func() {
<-quit.ClickedCh
systray.Quit()
}()

go func() {
<-ipMenu.ClickedCh
err := clipboard.WriteAll(currentIP)
if err != nil {
fmt.Printf("Error copying IP to clipboard: %s", err)
}
}()

setupConfig()
dbPath = path.Join(configDir, "ipdb")
systray.Run(do, onExit)
Expand Down Expand Up @@ -71,10 +83,11 @@ func do() {
for {
c2 := make(chan string, 1)
go func() {
ip, err := ipify.GetIp()
currentIP, err := ipify.GetIp()
if err == nil {
ipMenu.SetTitle("Public IP: " + currentIP)
gh := pingTime("https://api.github.com/zen")
ccode := countryFromIP(ip)
ccode := countryFromIP(currentIP)
c2 <- fmt.Sprintf("%s %sms", emoji.GetFlag(ccode), gh)
}
}()
Expand Down

0 comments on commit 9e9768e

Please sign in to comment.