From 9a2b03fc96bc0760f0d8aa14cdf0f890f3757e0b Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Sat, 1 Jun 2019 22:24:26 -0700 Subject: [PATCH] pass the mouse click to the area Signed-off-by: Jeff Carr --- Makefile | 5 +++-- VERSION | 2 +- crash1-fqdn | 5 +++++ fqdn.go | 37 +++++++++++++++++++++++++++++++++++++ main.go | 10 ++-------- splash.go | 2 +- 6 files changed, 49 insertions(+), 12 deletions(-) create mode 100644 crash1-fqdn create mode 100644 fqdn.go diff --git a/Makefile b/Makefile index 7586406..e50695e 100644 --- a/Makefile +++ b/Makefile @@ -1,18 +1,19 @@ GITCOMMIT = $(shell git rev-list -1 HEAD) GOVERSION = $(shell go version | cut -d' ' -f 3) BUILDTIME = $(shell date -u --iso-8601=seconds) +VERSION = $(shell cat VERSION) # try go get github.com/ahmetb/govvv # this will add branch info & build RFC3339 date also run: @echo your version of go must be greater than 2.10. Your version is ${GOVERSION} - go build -ldflags "-X main.GITCOMMIT=${GITCOMMIT} -X main.GOVERSION='${GOVERSION}' -X main.BUILDTIME='${BUILDTIME}'" + go build -ldflags "-X main.GITCOMMIT=${GITCOMMIT} -X main.GOVERSION='${GOVERSION}' -X main.BUILDTIME='${BUILDTIME}' -X main.VERSION=${VERSION}" ./cloud-control-panel debug: @echo your version of go must be greater than 2.10. Your version is ${GOVERSION} - go build -ldflags "-X main.GITCOMMIT=${GITCOMMIT} -X main.GOVERSION='${GOVERSION}' -X main.BUILDTIME='${BUILDTIME}'" + go build -ldflags "-X main.GITCOMMIT=${GITCOMMIT} -X main.GOVERSION='${GOVERSION}' -X main.BUILDTIME='${BUILDTIME}' -X main.VERSION=${VERSION}" ./cloud-control-panel --debug nogui: diff --git a/VERSION b/VERSION index 1811f96..74d5120 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -v0.4 +v0.6 diff --git a/crash1-fqdn b/crash1-fqdn new file mode 100644 index 0000000..e9a6fb4 --- /dev/null +++ b/crash1-fqdn @@ -0,0 +1,5 @@ +2019/06/01 21:11:47 connecting to ws://v000185.testing.com.customers.wprod.wit.com:9000/event +2019/06/01 21:11:47 fqdn.Get() = librem15.lab.wit.com +INFO[0000] *** error: read udp [2604:bbc0:1:22::f5d3:7f44]:50435->[2001:500:12::d0d]:53: i/o timeout + +make: *** [Makefile:52: config-default-config] Error 1 diff --git a/fqdn.go b/fqdn.go new file mode 100644 index 0000000..78bd22b --- /dev/null +++ b/fqdn.go @@ -0,0 +1,37 @@ +package main + +import ( + "net" + "os" + "strings" +) + +// Get Fully Qualified Domain Name +// returns "unknown" or hostanme in case of error +func FqdnGet() string { + hostname, err := os.Hostname() + if err != nil { + return "unknown" + } + + addrs, err := net.LookupIP(hostname) + if err != nil { + return hostname + } + + for _, addr := range addrs { + if ipv4 := addr.To4(); ipv4 != nil { + ip, err := ipv4.MarshalText() + if err != nil { + return hostname + } + hosts, err := net.LookupAddr(string(ip)) + if err != nil || len(hosts) == 0 { + return hostname + } + fqdn := hosts[0] + return strings.TrimSuffix(fqdn, ".") // return fqdn without trailing dot + } + } + return hostname +} diff --git a/main.go b/main.go index a36fdfb..a3faf05 100644 --- a/main.go +++ b/main.go @@ -16,13 +16,10 @@ import "git.wit.com/jcarr/dnssecsocket" import "github.com/gobuffalo/packr" import "github.com/davecgh/go-spew/spew" -// will try to get this hosts FQDN -import "github.com/Showmax/go-fqdn" - var GITCOMMIT string // this is passed in as an ldflag var GOVERSION string // this is passed in as an ldflag var BUILDTIME string // this is passed in as an ldflag -const VERSION = "0.2" +var VERSION string // this is passed in as an ldflag // use mergo to merge structs // import "github.com/imdario/mergo" @@ -104,13 +101,10 @@ func main() { onExit(err) } -// gui.Data.Width = int(config.Width) -// gui.Data.Height = int(config.Height) - // use this to discover what the OS thinks it's hostname is // seems to be cross platform (?) // Windows: WMIC computersystem where caption='current_pc_name' rename new_pc_name - hostname := fqdn.Get() + hostname := FqdnGet() log.Println("fqdn.Get() = ", hostname) gui.Data.Hostname = hostname diff --git a/splash.go b/splash.go index b3bd5ce..eb27ebb 100644 --- a/splash.go +++ b/splash.go @@ -13,7 +13,7 @@ import pb "git.wit.com/wit/witProtobuf" func showSplashBox(gw *gui.GuiWindow) *gui.GuiBox { log.Println("ShowSplashBox() START") text := getNEWTEXT() - box := gui.ShowTextBox(gw, text) + box := gui.ShowTextBox(gw, text, splashClick) if runtime.GOOS == "linux" { gui.NewLabel(box,"OS: Linux")