From 5caf3038283f9fc078998c12bf1a55ea2b9a79a7 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Fri, 31 May 2019 17:37:24 -0700 Subject: [PATCH] lots of changes to update window & tab mapping Signed-off-by: Jeff Carr --- Makefile | 2 +- example-lookupAAAA/main.go | 27 +++++++++++++++++++++ main.go | 49 ++++++++++++++++++++++---------------- 3 files changed, 56 insertions(+), 22 deletions(-) create mode 100644 example-lookupAAAA/main.go diff --git a/Makefile b/Makefile index 468c811..94be8d0 100644 --- a/Makefile +++ b/Makefile @@ -53,7 +53,7 @@ config-default-config: config-delete config-delete: echo deleting your current config - mv ~/.config/cloud-control-panel.json /tmp + -mv ~/.config/cloud-control-panel.json /tmp diff: git diff diff --git a/example-lookupAAAA/main.go b/example-lookupAAAA/main.go new file mode 100644 index 0000000..30e7104 --- /dev/null +++ b/example-lookupAAAA/main.go @@ -0,0 +1,27 @@ +package main + +import "log" +import "github.com/miekg/dns" + +import "git.wit.com/jcarr/dnssecsocket" + +import "github.com/davecgh/go-spew/spew" +// import "github.com/Showmax/go-fqdn" + +func lookupAAAA(hostname string) string { + // lookup the IP address from DNS + dnsRR := dnssecsocket.Dnstrace(hostname, "AAAA") + spew.Dump(dnsRR) + if (dnsRR == nil) { + return "BROKEN" + } + ipaddr := dns.Field(dnsRR, 1) + log.Println("ipaddr", ipaddr) + return ipaddr +} + +func main() { + hostname := "v000185.testing.com.customers.wprod.wit.com" + + lookupAAAA(hostname) +} diff --git a/main.go b/main.go index ad32c1b..f77537a 100644 --- a/main.go +++ b/main.go @@ -164,22 +164,29 @@ func mainMouseClick(b *gui.GuiButton) { onExit(fmt.Errorf("mainMouseClick() got b = nil")) } log.Println("mainMouseClick() b.Action =", b.Action) - log.Println("mainMouseClick() b.Action =", b.Account) + log.Println("mainMouseClick() b.Account =", b.Account) spew.Dump(b.Account) - var wm *gui.GuiWindow - - wm = b.WM + var gw *gui.GuiWindow + gw = b.GW // gui.Data.Current = b.Account - log.Println("mainMouseClick() BACK IN CONTROL PANEL CODE") + log.Println("mainMouseClick() BACK IN CONTROL PANEL CODE b =", b) if (b.Account != nil) { log.Println("\tmainMouseClick() setting current account = ", b.Account.Nick) } if (b.Action == "NEWTEXT") { - wm.Area.UiAttrstr = getNEWTEXT() - log.Println("Area.UiAttrstr = ", wm.Area.UiAttrstr) - wm.Area.UiArea.QueueRedrawAll() + if (b.Box == nil) { + log.Println("\tmainMouseClick() b.Box = nil") + os.Exit(-1) + } + if (b.Box.Area == nil) { + log.Println("\tmainMouseClick() b.Box.Area = nil") + os.Exit(-1) + } + b.Box.Area.UiAttrstr = getNEWTEXT() + log.Println("Area.UiAttrstr = ", b.Box.Area.UiAttrstr) + b.Box.Area.UiArea.QueueRedrawAll() } else if (b.Action == "AREA") { if (config == nil) { log.Println("gui.State = splash BUT SOMETHING HAS GONE VERY WRONG") @@ -197,25 +204,25 @@ func mainMouseClick(b *gui.GuiButton) { } } if (gui.Data.State == "splash") { - gui.ShowAccountQuestionTab(wm) + gui.ShowAccountQuestionTab(gw) gui.Data.State = "account1" return } if (gui.Data.State == "main") { log.Println("gui.Data.State == main b =", b) - log.Println("gui.Data.State == main wm =", wm) - gui.ShowMainTab(wm) + log.Println("gui.Data.State == main gw =", gw) + gui.ShowMainTab(gw) gui.Data.State = "done" return } else if (gui.Data.State == "account1") { - gui.ShowAccountTab(wm, 0) + gui.ShowAccountTab(gw, 0) gui.Data.State = "main" return } } else if (b.Action == "ADD TAB") { log.Println("\tADD TAB TRY b.Action = ", b.Action) log.Println("\tADD TAB TRY gui.ShowAccountTab(-1)") - gui.ShowAccountTab(wm, -1) + gui.ShowAccountTab(gw, -1) gui.Data.State = "done" return } else if (b.Action == "QUIT") { @@ -261,7 +268,7 @@ func mainMouseClick(b *gui.GuiButton) { log.Println("\tSHOULD ADD ACCOUNT HERE") subdomain := gui.GetText(b.Box, "SUBDOMAIN") if (subdomain == "") { - gui.ErrorWindow(wm, "Blank Name", "You must have a valid subdomain") + gui.ErrorWindow(gw, "Blank Name", "You must have a valid subdomain") return } log.Println("\tsubdomain =", subdomain) @@ -275,7 +282,7 @@ func mainMouseClick(b *gui.GuiButton) { acc.URL = "http://stackapi-api1.stackapi.customers.dev.wit.com:4000/" config.Accounts = append(config.Accounts, acc) - gui.ShowMainTab(wm) + gui.ShowMainTab(gw) gui.Data.State = "done" } else if (b.Action == "LOGIN") { log.Println("\tTRIGGER LOGIN ACCOUNT") @@ -292,7 +299,7 @@ func mainMouseClick(b *gui.GuiButton) { time.Sleep(200 * time.Millisecond) if (gui.Data.State == "NEW PROTOBUF") { if (currentMessage == nil) { - gui.SocketError(wm) + gui.SocketError(gw) gui.Data.State = "done" } else { log.Println("LOGIN currentMessage =", currentMessage) @@ -309,7 +316,7 @@ func mainMouseClick(b *gui.GuiButton) { } } log.Println("\tLOGIN WAS OK!") - gui.MessageWindow(wm, "Login OK", msg) + gui.MessageWindow(gw, "Login OK", msg) } else if (currentMessage.Type == pb.Event_FAIL) { log.Println("\tLOGIN FAILED") log.Println("\tLOGIN FAILED") @@ -319,7 +326,7 @@ func mainMouseClick(b *gui.GuiButton) { msg += "pb.Id = " + fmt.Sprintf("%d", currentMessage.Id) + "\n" msg += "pb.Email = " + b.Account.Email + "\n" msg += "pb.Username = " + b.Account.Username + "\n" - gui.ErrorWindow(wm, "Login Failed", msg) + gui.ErrorWindow(gw, "Login Failed", msg) } currentMessage = nil gui.Data.State = "done" @@ -342,7 +349,7 @@ func mainMouseClick(b *gui.GuiButton) { // go gui.GoShowVM() } else { log.Println("\tATTEMPTING TO SHOW VM TAB", b.T) - gui.CreateVmBox(wm, b.T, b.VM) + gui.CreateVmBox(gw, b.T, b.VM) } } else if (b.Action == "SHOW") { log.Println("\tTRIGGER DISPLAY ACCOUNT") @@ -358,7 +365,7 @@ func mainMouseClick(b *gui.GuiButton) { time.Sleep(200 * time.Millisecond) if (gui.Data.State == "NEW PROTOBUF") { if (currentMessage == nil) { - gui.SocketError(wm) + gui.SocketError(gw) gui.Data.State = "done" } else { count := countVMS(currentMessage) @@ -367,7 +374,7 @@ func mainMouseClick(b *gui.GuiButton) { // TODO: make sure login worked & the account really has zero VMs // if (count != 0) { name := "Virtual Machines (" + b.Account.Nick + ")" - mh := gui.AddVmsTab(wm, name, count, b.Account) + mh := gui.AddVmsTab(gw, name, count, b.Account) ReadReceivedData(currentMessage, mh, b.W, b.T) // } currentMessage = nil