diff --git a/Makefile b/Makefile index 54caa4b..1312d60 100644 --- a/Makefile +++ b/Makefile @@ -5,16 +5,16 @@ BUILDTIME = $(shell date -u --iso-8601=seconds) # 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}'" + ./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}'" ./cloud-control-panel --debugging -run: - @echo your version of go must be greater than 2.10. Your version is ${GOVERSION} - go build -ldflags "-X main.GITCOMMIT=${GITCOMMIT}" - ./cloud-control-panel - nogui: go build ./cloud-control-panel -nogui diff --git a/gorilla.go b/gorilla.go index 30626d5..ad38e50 100644 --- a/gorilla.go +++ b/gorilla.go @@ -85,15 +85,28 @@ func gorillaDial(hostname string) { // var addr = flag.String("addr", "v000185.testing.com.customers.wprod.wit.com:9000", "http service address") for { - // u := url.URL{Scheme: "ws", Host: *addr, Path: "/event"} - u := url.URL{Scheme: "ws", Host: hostname, Path: "/event"} + u := url.URL{ + Scheme: "ws", + Host: hostname, + Path: "/event", + } log.Printf("connecting to %s", u.String()) - conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil) + conn, resp, err := websocket.DefaultDialer.Dial(u.String(), nil) if err != nil { log.Println("gorilla Dial failed", err) } else { + log.Println("RESPONSE HEADER = ", resp.Header) + log.Println("RESPONSE HEADER = ", resp.Header) + resp.Header.Set("jcarrname", "jcarrvalue") + log.Println("RESPONSE HEADER = ", resp.Header) gorillaConn = conn + origconn := conn.UnderlyingConn() + + laddr := origconn.LocalAddr() + raddr := origconn.RemoteAddr() + log.Println("RESPONSE HEADER origconn.LocalAddr()= ", laddr) + log.Println("RESPONSE HEADER origconn.RemoteAddr()= ", raddr) // handle inbound messages on the channel gorillaReadProtobuf(conn) diff --git a/main.go b/main.go index 59c917a..77ef7ec 100644 --- a/main.go +++ b/main.go @@ -94,6 +94,11 @@ func main() { gui.Data.Width = config.Int("width") gui.Data.Height = config.Int("height") + + // TODO: figure out the hostname the right way + gui.Data.Hostname = "librem15.lab.wit.com" + gui.Data.IPv6 = "2604:bbc0:3:3:0:10:0:1004" + gui.Data.Version = "v0.5" gui.Data.GitCommit = GITCOMMIT gui.Data.GoVersion = GOVERSION @@ -156,6 +161,41 @@ func buttonClick(b *gui.ButtonMap) { config.Set("accounts." + gui.Data.AccNick + ".hostname", "v000185.testing.com.customers.wprod.wit.com") } } + if (b.Note == "LOGIN") { + log.Println("\tTRIGGER LOGIN ACCOUNT") + gui.Data.State = "SEND LOGIN" + gui.Data.AccNick = b.AccNick + count := 0 + for { + log.Println("Sleep() in buttonClick() gui.Data.State =", gui.Data.State) + time.Sleep(200 * time.Millisecond) + if (gui.Data.State == "NEW PROTOBUF") { + if (currentMessage == nil) { + gui.SocketError() + gui.Data.State = "done" + } else { + count := countVMS(currentMessage) + log.Println("LOGIN VMS currentMessage =", currentMessage) + log.Println("LOGIN VMS count =", count) + if (count != 0) { + name := "Virtual Machines (" + b.AccNick + ")" + mh := gui.AddVmsTab(name, count) + ReadReceivedData(currentMessage, mh) + } + currentMessage = nil + gui.Data.State = "done" + } + return + } + count += 1 + if (count > 10) { + log.Println("ERROR: waited too long for a resposne") + currentMessage = nil + gui.Data.State = "done" + return + } + } + } if (b.Note == "SHOW") { log.Println("\tTRIGGER DISPLAY ACCOUNT") gui.Data.State = "SEND WEBSOCKET" @@ -207,6 +247,7 @@ func buttonClick(b *gui.ButtonMap) { } } +// this watches the GUI primarily to process protobuf's func watchGUI() { count := 0 @@ -230,6 +271,20 @@ func watchGUI() { gorillaSendProtobuf(event) gui.Data.State = "READ PROTOBUF" } + if (gui.Data.State == "SEND LOGIN") { + log.Println("\tTRIGGERING LOGIN HERE on AccNick =", gui.Data.AccNick) + log.Println("\tTRIGGERING LOGIN HERE on AccNick =", gui.Data.AccNick) + log.Println("\tTRIGGERING LOGIN HERE on AccNick =", gui.Data.AccNick) + + event := pb.MakeLoginEvent() + event.Username = config.String("accounts." + gui.Data.AccNick + ".username") + event.Password = config.String("accounts." + gui.Data.AccNick + ".password") + event.Token = config.String("accounts." + gui.Data.AccNick + ".token") + log.Println("\tTRIGGERING LOGIN HERE with event.Token =", event.Token) + + gorillaSendProtobuf(event) + gui.Data.State = "READ PROTOBUF" + } if (gui.Data.State == "kill") { log.Println("gui.State = kill") log.Println("gui.State = kill")