diff --git a/Icon/128x128/wireguard.png b/Icon/128x128/wireguard.png new file mode 100755 index 0000000..f4e72d6 Binary files /dev/null and b/Icon/128x128/wireguard.png differ diff --git a/Icon/128x128/wireguard_off.png b/Icon/128x128/wireguard_off.png new file mode 100755 index 0000000..2e5c567 Binary files /dev/null and b/Icon/128x128/wireguard_off.png differ diff --git a/Icon/16x16/wireguard.png b/Icon/16x16/wireguard.png new file mode 100755 index 0000000..b915dfb Binary files /dev/null and b/Icon/16x16/wireguard.png differ diff --git a/Icon/16x16/wireguard_off.png b/Icon/16x16/wireguard_off.png new file mode 100755 index 0000000..082369a Binary files /dev/null and b/Icon/16x16/wireguard_off.png differ diff --git a/Icon/256x256/wireguard.png b/Icon/256x256/wireguard.png new file mode 100755 index 0000000..2e705cd Binary files /dev/null and b/Icon/256x256/wireguard.png differ diff --git a/Icon/256x256/wireguard_off.png b/Icon/256x256/wireguard_off.png new file mode 100755 index 0000000..cbdeab3 Binary files /dev/null and b/Icon/256x256/wireguard_off.png differ diff --git a/Icon/32x32/wireguard.png b/Icon/32x32/wireguard.png new file mode 100755 index 0000000..6438178 Binary files /dev/null and b/Icon/32x32/wireguard.png differ diff --git a/Icon/32x32/wireguard_off.png b/Icon/32x32/wireguard_off.png new file mode 100755 index 0000000..125f8df Binary files /dev/null and b/Icon/32x32/wireguard_off.png differ diff --git a/Icon/48x48/wireguard.png b/Icon/48x48/wireguard.png new file mode 100755 index 0000000..3b1d246 Binary files /dev/null and b/Icon/48x48/wireguard.png differ diff --git a/Icon/48x48/wireguard_off.png b/Icon/48x48/wireguard_off.png new file mode 100755 index 0000000..26879fb Binary files /dev/null and b/Icon/48x48/wireguard_off.png differ diff --git a/icon/dot-gray.png b/Icon/dot-gray.png old mode 100644 new mode 100755 similarity index 100% rename from icon/dot-gray.png rename to Icon/dot-gray.png diff --git a/icon/dot-gray.svg b/Icon/dot-gray.svg old mode 100644 new mode 100755 similarity index 100% rename from icon/dot-gray.svg rename to Icon/dot-gray.svg diff --git a/icon/dot-green.png b/Icon/dot-green.png old mode 100644 new mode 100755 similarity index 100% rename from icon/dot-green.png rename to Icon/dot-green.png diff --git a/icon/dot-green.svg b/Icon/dot-green.svg old mode 100644 new mode 100755 similarity index 100% rename from icon/dot-green.svg rename to Icon/dot-green.svg diff --git a/icon/wireguard.svg b/Icon/wireguard.svg old mode 100644 new mode 100755 similarity index 100% rename from icon/wireguard.svg rename to Icon/wireguard.svg diff --git a/Icon/wireguard_offz.png b/Icon/wireguard_offz.png new file mode 100755 index 0000000..cbdeab3 Binary files /dev/null and b/Icon/wireguard_offz.png differ diff --git a/Icon/wireguardz.png b/Icon/wireguardz.png new file mode 100755 index 0000000..2e705cd Binary files /dev/null and b/Icon/wireguardz.png differ diff --git a/deb/DEBIAN/changelog b/deb/DEBIAN/changelog new file mode 100644 index 0000000..94d7a0d --- /dev/null +++ b/deb/DEBIAN/changelog @@ -0,0 +1,5 @@ +wireguird (0.1) UNRELEASED; urgency=medium + + * Initial release. (Closes: #XXXXXX) + + -- unknown Thu, 11 Feb 2021 01:36:25 +0100 diff --git a/deb/DEBIAN/control b/deb/DEBIAN/control new file mode 100644 index 0000000..b532c6c --- /dev/null +++ b/deb/DEBIAN/control @@ -0,0 +1,9 @@ +Package: wireguird +Source: wireguird +Version: 0.1 +Section: utils +Priority: extra +Architecture: amd64 +Depends: wireguard-tools, resolvconf, libgtk-3-dev, libappindicator3-dev (>= 1.0.0) +Maintainer: UnnoTed +Description: GTK GUI for Wireguard diff --git a/deb/usr/local/bin/wireguird b/deb/usr/local/bin/wireguird new file mode 100755 index 0000000..db9aceb --- /dev/null +++ b/deb/usr/local/bin/wireguird @@ -0,0 +1,2 @@ +#!/bin/sh +pkexec /opt/wireguird/wireguird diff --git a/deb/usr/share/applications/wireguird.desktop b/deb/usr/share/applications/wireguird.desktop new file mode 100644 index 0000000..4401e39 --- /dev/null +++ b/deb/usr/share/applications/wireguird.desktop @@ -0,0 +1,8 @@ +[Desktop Entry] +Encoding=UTF-8 +Version=0.1 +Type=Application +Terminal=false +Exec=/usr/local/bin/wireguird +Name=Wireguird +Icon=/opt/wireguird/Icon/128x128/wireguard.png diff --git a/deb/usr/share/polkit-1/actions/wireguird.policy b/deb/usr/share/polkit-1/actions/wireguird.policy new file mode 100644 index 0000000..feddec4 --- /dev/null +++ b/deb/usr/share/polkit-1/actions/wireguird.policy @@ -0,0 +1,18 @@ + + + + + Wireguard GUI + Authentication is required to run wireguird + + + auth_admin + auth_admin + auth_admin + + /opt/wireguird/wireguird + true + + diff --git a/deps.sh b/deps.sh new file mode 100644 index 0000000..e32079a --- /dev/null +++ b/deps.sh @@ -0,0 +1 @@ +sudo apt install wireguard-tools libgtk-3-dev libappindicator3-dev diff --git a/fileb0x.toml b/fileb0x.toml old mode 100644 new mode 100755 index bd329c1..2395d11 --- a/fileb0x.toml +++ b/fileb0x.toml @@ -115,43 +115,6 @@ debug = false # type: array of objects [[custom]] - - # type: array of strings - files = ["./flags/*.png"] - - # base is the path that will be removed from all files' path - # type: string - base = "./flags/" - - # prefix is the path that will be added to all files' path - # type: string - prefix = "" - - # build tags for this set of files - # it will only work if spread mode is enabled - tags = "" -# end: custom -# type: array of objects -[[custom]] - - # type: array of strings - files = ["./icon/*"] - - # base is the path that will be removed from all files' path - # type: string - base = "./" - - # prefix is the path that will be added to all files' path - # type: string - prefix = "" - - # build tags for this set of files - # it will only work if spread mode is enabled - tags = "" -# end: custom -# type: array of objects -[[custom]] - # type: array of strings files = ["*.glade"] diff --git a/go.mod b/go.mod old mode 100644 new mode 100755 index 31cf978..9d80e87 --- a/go.mod +++ b/go.mod @@ -11,6 +11,7 @@ require ( github.com/nwidger/jsoncolor v0.3.0 // indirect github.com/olekukonko/ts v0.0.0-20171002115256-78ecb04241c0 // indirect github.com/rs/zerolog v1.18.0 + github.com/smartystreets/goconvey v1.6.4 // indirect github.com/ungerik/go-dry v0.0.0-20180411133923-654ae31114c8 golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2 golang.zx2c4.com/wireguard/wgctrl v0.0.0-20200515170644-ec7f26be9d9e diff --git a/go.sum b/go.sum old mode 100644 new mode 100755 index 1f2580d..624ae4b --- a/go.sum +++ b/go.sum @@ -19,11 +19,18 @@ github.com/gizak/termui/v3 v3.1.0 h1:ZZmVDgwHl7gR7elfKf1xc4IudXZ5qqfDh4wExk4Iajc github.com/gizak/termui/v3 v3.1.0/go.mod h1:bXQEBkJpzxUAKf0+xq9MSWAvWZlE7c+aidmyFlkYTrY= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.4.0 h1:xsAVV57WRhGj6kEIi8ReJzQlHHqcBYCElAvkovg3B/4= github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8= +github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/gotk3/gotk3 v0.4.0 h1:TIuhyQitGeRTxOQIV3AJlYtEWWJpC74JHwAIsxlH8MU= github.com/gotk3/gotk3 v0.4.0/go.mod h1:Eew3QBwAOBTrfFFDmsDE5wZWbcagBL1NUslj1GhRveo= +github.com/gotk3/gotk3 v0.5.1 h1:zIZM2K4gmkGz1idEFVUPTQfAK/pnWoLKrlIjLOc4kzo= github.com/jsimonetti/rtnetlink v0.0.0-20190606172950-9527aa82566a/go.mod h1:Oz+70psSo5OFh8DBl0Zv2ACw7Esh6pPUphlvZG9x7uw= +github.com/jsimonetti/rtnetlink v0.0.0-20200117123717-f846d4f6c1f4 h1:nwOc1YaOrYJ37sEBrtWZrdqzK22hiJs3GpDmP3sR2Yw= github.com/jsimonetti/rtnetlink v0.0.0-20200117123717-f846d4f6c1f4/go.mod h1:WGuG/smIU4J/54PblvSbh+xvCZmpJnFgr3ds6Z55XMQ= +github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo= +github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= github.com/karrick/godirwalk v1.7.8 h1:VfG72pyIxgtC7+3X9CMHI0AOl4LwyRAg98WAgsvffi8= github.com/karrick/godirwalk v1.7.8/go.mod h1:2c9FRhkDxdIbgkOnCEvnSWs71Bhugbl46shStcFDJ34= github.com/labstack/echo v3.2.1+incompatible h1:J2M7YArHx4gi8p/3fDw8tX19SXhBCoRpviyAZSN3I88= @@ -46,6 +53,7 @@ github.com/mdlayher/netlink v0.0.0-20190409211403-11939a169225/go.mod h1:eQB3mZE github.com/mdlayher/netlink v1.0.0/go.mod h1:KxeJAFOFLG6AjpyDkQ/iIhxygIUKD+vcwqcnu43w/+M= github.com/mdlayher/netlink v1.1.0 h1:mpdLgm+brq10nI9zM1BpX1kpDbh3NLl3RSnVq6ZSkfg= github.com/mdlayher/netlink v1.1.0/go.mod h1:H4WCitaheIsdF9yOYu8CFmCgQthAPIWZmcKp9uZHgmY= +github.com/mikioh/ipaddr v0.0.0-20190404000644-d465c8ab6721 h1:RlZweED6sbSArvlE924+mUcZuXKLBHA35U7LN621Bws= github.com/mikioh/ipaddr v0.0.0-20190404000644-d465c8ab6721/go.mod h1:Ickgr2WtCLZ2MDGd4Gr0geeCH5HybhRJbonOgQpvSxc= github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo= github.com/mitchellh/go-wordwrap v1.0.0 h1:6GlHJ/LTGMrIJbwgdqdl2eEH8o+Exx/0m8ir9Gns0u4= @@ -63,6 +71,10 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ= github.com/rs/zerolog v1.18.0 h1:CbAm3kP2Tptby1i9sYy2MGRg0uxIN9cyDb59Ys7W8z8= github.com/rs/zerolog v1.18.0/go.mod h1:9nvC1axdVrAHcu/s9taAVfBuIdTZLVQmKQyvrUjF5+I= +github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM= +github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= +github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s= +github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/ungerik/go-dry v0.0.0-20180411133923-654ae31114c8 h1:p6JzR5AMj5LyCEovRh5MOxmyuuwOEtfcVDwKqsBn41I= github.com/ungerik/go-dry v0.0.0-20180411133923-654ae31114c8/go.mod h1:+LeLocciSarKa1pxOY7gmBQ7dSk5nB1w1f3nvvLw0j0= @@ -104,12 +116,13 @@ golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190828213141-aed303cbaa74/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.zx2c4.com/wireguard v0.0.20200121 h1:vcswa5Q6f+sylDfjqyrVNNrjsFUUbPsgAQTBCAg/Qf8= golang.zx2c4.com/wireguard v0.0.20200121/go.mod h1:P2HsVp8SKwZEufsnezXZA4GRX/T49/HlU7DGuelXsU4= -golang.zx2c4.com/wireguard v0.0.20200320 h1:1vE6zVeO7fix9cJX1Z9ZQ+ikPIIx7vIyU0o0tLDD88g= golang.zx2c4.com/wireguard/wgctrl v0.0.0-20200515170644-ec7f26be9d9e h1:fqDhK9OlzaaiFjnyaAfR9Q1RPKCK7OCTLlHGP9f74Nk= golang.zx2c4.com/wireguard/wgctrl v0.0.0-20200515170644-ec7f26be9d9e/go.mod h1:UdS9frhv65KTfwxME1xE8+rHYoFpbm36gOud1GhBe9c= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/gui/gui.go b/gui/gui.go old mode 100644 new mode 100755 index dd1eec8..4c8bef6 --- a/gui/gui.go +++ b/gui/gui.go @@ -65,6 +65,7 @@ func ShowError(win *gtk.ApplicationWindow, err error, info ...string) { } if _, err := glib.IdleAdd(func() { + wlog("ERROR", err.Error()) dlg := gtk.MessageDialogNew(win, gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR, gtk.BUTTONS_OK, "%s", err.Error()) dlg.SetTitle("Error") dlg.Run() diff --git a/gui/tunnels.go b/gui/tunnels.go old mode 100644 new mode 100755 index e0136f4..a7efd35 --- a/gui/tunnels.go +++ b/gui/tunnels.go @@ -94,14 +94,14 @@ func (t *Tunnels) Create() error { var img *gtk.Image if activeName == name { - green, err := gtk.ImageNewFromFile("./icon/dot-green.png") + green, err := gtk.ImageNewFromFile("/opt/wireguird/Icon/dot-green.png") if err != nil { return err } img = green } else { - gray, err := gtk.ImageNewFromFile("./icon/dot-gray.png") + gray, err := gtk.ImageNewFromFile("/opt/wireguird/Icon/dot-gray.png") if err != nil { return err } @@ -109,7 +109,7 @@ func (t *Tunnels) Create() error { } t.icons[name] = img - // img, err := gtk.ImageNewFromFile("./icon/dot-gray.png") + // img, err := gtk.ImageNewFromFile("/opt/wireguird/Icon/dot-gray.png") // if err != nil { // return err // } @@ -249,7 +249,7 @@ func (t *Tunnels) Create() error { activeName = t.ActiveDeviceName() for _, d := range list { - gray, err := gtk.ImageNewFromFile("./icon/dot-gray.png") + gray, err := gtk.ImageNewFromFile("/opt/wireguird/Icon/dot-gray.png") if err != nil { return err } @@ -266,6 +266,11 @@ func (t *Tunnels) Create() error { } row := tl.GetSelectedRow() + // row not found for config + if row == nil { + return nil + } + name, err := row.GetName() if err != nil { return err @@ -274,7 +279,10 @@ func (t *Tunnels) Create() error { // dont connect to the new one if activeName != "" && activeName == name { t.UpdateRow(row) - header.SetSubtitle("Not connected!") + + glib.IdleAdd(func() { + header.SetSubtitle("Not connected!") + }) return nil } @@ -286,7 +294,7 @@ func (t *Tunnels) Create() error { header.SetSubtitle("Connected to " + name) }) - green, err := gtk.ImageNewFromFile("./icon/dot-green.png") + green, err := gtk.ImageNewFromFile("/opt/wireguird/Icon/dot-green.png") if err != nil { return err } @@ -296,6 +304,11 @@ func (t *Tunnels) Create() error { t.UpdateRow(row) indicator.SetIcon("wireguard") }) + + if err := wlog("INFO", "Connected to "+name); err != nil { + return err + } + return nil }() @@ -322,6 +335,11 @@ func (t *Tunnels) Create() error { } row := tl.GetSelectedRow() + if row == nil { + t.UnknownLabels() + continue + } + name, err := row.GetName() if err != nil { log.Error().Err(err).Msg("row get name err") @@ -343,9 +361,10 @@ func (t *Tunnels) Create() error { for _, p := range d.Peers { hs := humanize.Time(p.LastHandshakeTime) - t.Peer.LatestHandshake.SetText(hs) - - t.Peer.Transfer.SetText(humanize.Bytes(uint64(p.ReceiveBytes)) + " received, " + humanize.Bytes(uint64(p.TransmitBytes)) + " sent") + glib.IdleAdd(func() { + t.Peer.LatestHandshake.SetText(hs) + t.Peer.Transfer.SetText(humanize.Bytes(uint64(p.ReceiveBytes)) + " received, " + humanize.Bytes(uint64(p.TransmitBytes)) + " sent") + }) } } }() @@ -376,15 +395,17 @@ func (t *Tunnels) UpdateRow(row *gtk.ListBoxRow) { peersec := cfg.Section("Peer") insec := cfg.Section("Interface") - t.Interface.Addresses.SetText(insec.Key("Address").String()) - t.Interface.Status.SetText("Inactive") - t.Interface.DNS.SetText(insec.Key("DNS").String()) + glib.IdleAdd(func() { + t.Interface.Addresses.SetText(insec.Key("Address").String()) + t.Interface.Status.SetText("Inactive") + t.Interface.DNS.SetText(insec.Key("DNS").String()) - t.ButtonChangeState.SetLabel("Activate") + t.ButtonChangeState.SetLabel("Activate") - t.Peer.AllowedIPs.SetText(peersec.Key("AllowedIPs").String()) - t.Peer.PublicKey.SetText(peersec.Key("PublicKey").String()) - t.Peer.Endpoint.SetText(peersec.Key("Endpoint").String()) + t.Peer.AllowedIPs.SetText(peersec.Key("AllowedIPs").String()) + t.Peer.PublicKey.SetText(peersec.Key("PublicKey").String()) + t.Peer.Endpoint.SetText(peersec.Key("Endpoint").String()) + }) for _, d := range ds { if d.Name != id { @@ -397,16 +418,20 @@ func (t *Tunnels) UpdateRow(row *gtk.ListBoxRow) { // boxPeers.Remove(item.(*gtk.Widget)) // }) - t.Interface.Status.SetText("Active") - t.ButtonChangeState.SetLabel("Deactivate") - t.Interface.PublicKey.SetText(d.PublicKey.String()) - t.Interface.ListenPort.SetText(strconv.Itoa(d.ListenPort)) + glib.IdleAdd(func() { + t.Interface.Status.SetText("Active") + t.ButtonChangeState.SetLabel("Deactivate") + t.Interface.PublicKey.SetText(d.PublicKey.String()) + t.Interface.ListenPort.SetText(strconv.Itoa(d.ListenPort)) + }) for _, p := range d.Peers { hs := humanize.Time(p.LastHandshakeTime) - t.Peer.LatestHandshake.SetText(hs) - t.Peer.Transfer.SetText(humanize.Bytes(uint64(p.ReceiveBytes)) + " received, " + humanize.Bytes(uint64(p.TransmitBytes)) + " sent") + glib.IdleAdd(func() { + t.Peer.LatestHandshake.SetText(hs) + t.Peer.Transfer.SetText(humanize.Bytes(uint64(p.ReceiveBytes)) + " received, " + humanize.Bytes(uint64(p.TransmitBytes)) + " sent") + }) } break @@ -422,23 +447,25 @@ func (t *Tunnels) UpdateRow(row *gtk.ListBoxRow) { } func (t *Tunnels) UnknownLabels() { - t.ButtonChangeState.SetLabel("unknown") + glib.IdleAdd(func() { + t.ButtonChangeState.SetLabel("unknown") - t.Interface.Addresses.SetText("unknown") - t.Interface.Status.SetText("unknown") - t.Interface.DNS.SetText("unknown") + t.Interface.Addresses.SetText("unknown") + t.Interface.Status.SetText("unknown") + t.Interface.DNS.SetText("unknown") - t.Peer.AllowedIPs.SetText("unknown") - t.Peer.PublicKey.SetText("unknown") - t.Peer.Endpoint.SetText("unknown") + t.Peer.AllowedIPs.SetText("unknown") + t.Peer.PublicKey.SetText("unknown") + t.Peer.Endpoint.SetText("unknown") - t.Interface.Status.SetText("unknown") - t.ButtonChangeState.SetLabel("unknown") - t.Interface.PublicKey.SetText("unknown") - t.Interface.ListenPort.SetText("unknown") - t.Peer.LatestHandshake.SetText("unknown") + t.Interface.Status.SetText("unknown") + t.ButtonChangeState.SetLabel("unknown") + t.Interface.PublicKey.SetText("unknown") + t.Interface.ListenPort.SetText("unknown") + t.Peer.LatestHandshake.SetText("unknown") - t.Peer.Transfer.SetText("unknown") + t.Peer.Transfer.SetText("unknown") + }) } func (t *Tunnels) ActiveDeviceName() string { @@ -450,3 +477,30 @@ func (t *Tunnels) ActiveDeviceName() string { return "" } + +func wlog(t string, text string) error { + wlogs, err := get.ListBox("wireguard_logs") + if err != nil { + return err + } + + l, err := gtk.LabelNew("") + if err != nil { + return err + } + + if t == "ERROR" { + t = `` + t + "" + } + + l.SetMarkup(`[` + time.Now().Format("02/Jan/06 15:04:05 MST") + `][` + t + `]: ` + text) + l.SetHExpand(true) + l.SetHAlign(gtk.ALIGN_START) + + glib.IdleAdd(func() { + l.Show() + wlogs.Add(l) + }) + + return nil +} diff --git a/icon/wireguard.png b/icon/wireguard.png deleted file mode 100644 index 85fd7df..0000000 Binary files a/icon/wireguard.png and /dev/null differ diff --git a/icon/wireguard_off.png b/icon/wireguard_off.png deleted file mode 100644 index ca0c601..0000000 Binary files a/icon/wireguard_off.png and /dev/null differ diff --git a/main.go b/main.go old mode 100644 new mode 100755 index e2e8092..4a90d60 --- a/main.go +++ b/main.go @@ -4,7 +4,6 @@ package main import ( "os" - "runtime/debug" "github.com/UnnoTed/horizontal" "github.com/UnnoTed/wireguird/gui" @@ -21,7 +20,6 @@ var win *gtk.ApplicationWindow func main() { log.Logger = log.Output(horizontal.ConsoleWriter{Out: os.Stderr}) log.Info().Uint("major", gtk.GetMajorVersion()).Uint("minor", gtk.GetMinorVersion()).Uint("micro", gtk.GetMicroVersion()).Msg("GTK Version") - debug.SetGCPercent(100) const appID = "com.wireguard.desktop" application, err := gtk.ApplicationNew(appID, glib.APPLICATION_FLAGS_NONE) @@ -56,9 +54,9 @@ func createTray(application *gtk.Application) (*appindicator.Indicator, error) { } indicator := appindicator.New(application.GetApplicationID(), "wireguard_off", appindicator.CategoryApplicationStatus) - indicator.SetIconThemePath("./icon") + indicator.SetIconThemePath("/opt/wireguird/Icon/32x32") indicator.SetTitle("Wireguird") - indicator.SetLabel("Wireguird", "") + // indicator.SetLabel("Wireguird", "") indicator.SetStatus(appindicator.StatusActive) indicator.SetMenu(menu) diff --git a/package.sh b/package.sh new file mode 100755 index 0000000..d7d1f81 --- /dev/null +++ b/package.sh @@ -0,0 +1,14 @@ +echo "wireguird: cleaning..." +rm -r ./build/wireguird_amd64.deb +rm -r ./deb/opt/wireguird/ +mkdir ./deb/opt/wireguird + +echo "wireguird: building go binary..." +go build -ldflags "-s -w" -trimpath -o ./deb/opt/wireguird/wireguird + +echo "wireguird: copying icons..." +cp -r ./Icon/ ./deb/opt/wireguird/ + +echo "wireguird: building debian package..." +dpkg-deb --root-owner-group --build ./deb ./build/wireguird_amd64.deb +echo "wireguird: done" diff --git a/wireguird.glade b/wireguird.glade old mode 100644 new mode 100755 index f58620e..e7f699a --- a/wireguird.glade +++ b/wireguird.glade @@ -1,236 +1,326 @@ - + - 650 - 470 - False - center - False + 650 + 470 + False + center + False True - False + False vertical True - False - 8 - 8 - 8 - 8 + False + 8 + 8 + 8 + 8 True True - slide-left-right + slide-left-right True - False + False 8 - - 200 + True - True - never - in + False + False + True + vertical - - 200 + + 200 True - False + True + True + True + never + in - - 200 + + 200 True - False + False + + + 200 + True + False + True + True + + + + False + True + 0 + + + + + True + False + 8 + 8 + + + Add tunnel + True + True + True + + + False + True + 0 + + + + + R + True + True + True + + + False + True + 1 + + + + + Z + True + True + True + + + False + True + 2 + + + + + False + True + 1 + False True - 0 + 1 True - True + True True - never + True + never True - False + False True - False + False True vertical 4 True - False - 0 - out + False + 0 + out True - False + False start start - 8 - 8 - 8 - 8 + 8 + 8 + 8 + 8 + True - False - 8 + False + 8 True - False + False end Status: - 0 - 0 + 0 + 0 True - False + False end Public key: - 0 - 1 + 0 + 1 True - False + False end Listen port: - 0 - 2 + 0 + 2 True - False + False end Addresses: - 0 - 3 + 0 + 3 True - False + False end DNS servers: - 0 - 4 + 0 + 4 True - False + False start label - 1 - 0 + 1 + 0 True - False + False start label - 1 - 1 + 1 + 1 True - False + False start label - 1 - 2 + 1 + 2 True - False + False start label - 1 - 3 + 1 + 3 True - False + False start label - 1 - 4 + 1 + 4 Activate True - True - True + True + True start - 1 - 5 + 1 + 5 + + + + + + + + + + + + + + + + + + @@ -238,7 +328,7 @@ True - False + False Interface: @@ -252,151 +342,167 @@ True - False + False vertical True True - False - 0 - out + False + 0 + out True - False + False start start - 8 - 8 - 8 - 8 + 8 + 8 + 8 + 8 + True - False - 8 - True + False + 8 + True True - False + False end Public key: - 0 - 0 + 0 + 0 True - False + False end Allowed IPs: - 0 - 1 + 0 + 1 True - False + False end Endpoint: - 0 - 2 + 0 + 2 True - False + False end Latest handshake: - 0 - 3 + 0 + 3 True - False + False end Transfer: - 0 - 4 + 0 + 4 True - False + False start label - 1 - 0 + 1 + 0 True - False + False start label - 1 - 1 + 1 + 1 True - False + False start label - 1 - 2 + 1 + 2 True - False + False start label - 1 - 3 + 1 + 3 True - False + False start label - 1 - 4 + 1 + 4 + + + + + + + + + + + + + + + @@ -404,7 +510,7 @@ True - False + False Peer @@ -425,12 +531,12 @@ True - False + False start True - False + False True @@ -443,8 +549,8 @@ Edit True - True - True + True + True start start @@ -479,23 +585,32 @@ - + True - False - vertical - - - - - - + True + in - + + True + False + True + True + natural + natural + + + True + False + True + True + + + - log - Log + logs + Logs 1 @@ -512,14 +627,14 @@ True - False + False Wireguird Not connected - True + True True - False + False main_stack