remove the dnssec socket code.
TODO: add the dns IPv6 checks to the gorilla websocket daemon Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
58b5b2e923
commit
049dbdac72
|
@ -2,3 +2,4 @@ cloud-control-panel
|
|||
example-gui/example-gui
|
||||
example-systray/example-systray
|
||||
example-UI-table/example-UI-table
|
||||
example-dnssecsocket/example-dnssecsocket
|
||||
|
|
|
@ -26,6 +26,9 @@ func processEvents() {
|
|||
log.Println("processEvents() on channel recieved a message = ", message)
|
||||
mh := addVmsTab(30)
|
||||
ReadReceivedData(message, mh)
|
||||
if (message.Type == pb.Event_DEMO) {
|
||||
log.Println("processEvents() do Event DEMO")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -109,17 +112,6 @@ func addSampleEvent() {
|
|||
mychannel <- pdata
|
||||
}
|
||||
|
||||
func sendEventToWIT() {
|
||||
msg := pb.CreateSampleEvent()
|
||||
|
||||
var mybuf []byte
|
||||
mybuf, err := proto.Marshal(msg)
|
||||
if (err != nil) {
|
||||
log.Printf("something fucked up happened")
|
||||
}
|
||||
writeBytesToSocket(mybuf)
|
||||
}
|
||||
|
||||
func sendDataToDest() {
|
||||
msg := pb.CreateSampleEvent()
|
||||
msg.Name = "from dnssecsockettest()"
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
all:
|
||||
go build
|
|
@ -0,0 +1,109 @@
|
|||
package main
|
||||
|
||||
/*
|
||||
This simply parses the command line arguments using the default golang
|
||||
package called 'flag'. This can be used as a simple template to parse
|
||||
command line arguments in other programs.
|
||||
|
||||
It puts everything in the 'config' package which I think is a good
|
||||
wrapper around the 'flags' package and doesn't need a whole mess of
|
||||
global variables
|
||||
*/
|
||||
|
||||
import "log"
|
||||
import "os"
|
||||
import "flag"
|
||||
import "fmt"
|
||||
import "github.com/gookit/config"
|
||||
import "github.com/gookit/config/yaml"
|
||||
import "github.com/gookit/config/json"
|
||||
|
||||
// import "github.com/davecgh/go-spew/spew"
|
||||
|
||||
var customUsage = func() {
|
||||
fmt.Fprintf(flag.CommandLine.Output(), "Usage of %s:\n", os.Args[0])
|
||||
flag.PrintDefaults()
|
||||
|
||||
fmt.Println("")
|
||||
fmt.Println("EXAMPLES:")
|
||||
fmt.Println("")
|
||||
fmt.Println(os.Args[0] + "--hostname test.hostname.wit.com")
|
||||
fmt.Println("")
|
||||
}
|
||||
|
||||
func parseFlags() {
|
||||
var version string
|
||||
var nogui bool
|
||||
var hostname string
|
||||
var width int
|
||||
var height int
|
||||
|
||||
flag.StringVar (&version, "version", "v0.1", "Set compiled in version string")
|
||||
|
||||
flag.StringVar (&hostname, "hostname", "localhost", "Your full hostname")
|
||||
flag.IntVar (&width, "width", 400, "Width of the Window")
|
||||
flag.IntVar (&height, "height", 600, "Height of the Window")
|
||||
|
||||
flag.BoolVar (&nogui, "nogui", nogui, "Do not display the GUI")
|
||||
|
||||
// Set the output if something fails to stdout rather than stderr
|
||||
flag.CommandLine.SetOutput(os.Stdout)
|
||||
|
||||
flag.Usage = customUsage
|
||||
flag.Parse()
|
||||
|
||||
if flag.Parsed() {
|
||||
log.Println("flag.Parse() worked")
|
||||
} else {
|
||||
log.Println("flag.Parse() failed")
|
||||
}
|
||||
|
||||
config.Set("width", width)
|
||||
config.Set("height", height)
|
||||
config.Set("hostname", hostname)
|
||||
config.Set("nogui", nogui)
|
||||
}
|
||||
|
||||
func parseConfig() {
|
||||
config.WithOptions(config.ParseEnv)
|
||||
parseFlags()
|
||||
|
||||
config.LoadOSEnv([]string{"MAIL"})
|
||||
config.LoadOSEnv([]string{"USER"})
|
||||
config.LoadOSEnv([]string{"BUILDDEBUG"})
|
||||
|
||||
/*
|
||||
urls := flag.Args()
|
||||
log.Println("flag.Aargs() = ", urls)
|
||||
|
||||
for _, addr := range flag.Args() {
|
||||
log.Println("GET %s", addr)
|
||||
}
|
||||
*/
|
||||
|
||||
// add driver for support of yaml and json
|
||||
config.AddDriver(yaml.Driver)
|
||||
config.AddDriver(json.Driver)
|
||||
|
||||
config.LoadFiles("config.json")
|
||||
|
||||
for _, addr := range config.Strings("arr1") {
|
||||
log.Println("addr =", addr)
|
||||
}
|
||||
|
||||
map1 := config.StringMap("map1")
|
||||
fmt.Printf("%#v\n",map1)
|
||||
|
||||
log.Println(config.String("map1.key1.jwc1"))
|
||||
|
||||
for account, _ := range config.StringMap("cloud") {
|
||||
port := config.String("cloud." + account + ".port")
|
||||
proto := config.String("cloud." + account + ".proto")
|
||||
hostname := config.String("cloud." + account + ".hostname")
|
||||
fmt.Println(hostname, port, proto)
|
||||
}
|
||||
|
||||
if (config.String("nogui") == "true") {
|
||||
log.Println("DO NOT DISPLAY THE GUI")
|
||||
}
|
||||
}
|
|
@ -0,0 +1,151 @@
|
|||
package main
|
||||
|
||||
import "fmt"
|
||||
import "log"
|
||||
import "net"
|
||||
import "os"
|
||||
import "io"
|
||||
import "bytes"
|
||||
import "strconv"
|
||||
|
||||
import "github.com/golang/protobuf/proto"
|
||||
import pb "git.wit.com/wit/witProtobuf"
|
||||
|
||||
import "git.wit.com/wit/gui"
|
||||
|
||||
var mychannel chan *pb.Event
|
||||
|
||||
func initChannel() {
|
||||
mychannel = make(chan *pb.Event)
|
||||
}
|
||||
|
||||
// func processEvents(mychannel chan *pb.Event) {
|
||||
func processEvents() {
|
||||
for {
|
||||
message := <-mychannel
|
||||
log.Println("processEvents() on channel recieved a message = ", message)
|
||||
mh := addVmsTab(30)
|
||||
ReadReceivedData(message, mh)
|
||||
if (message.Type == pb.Event_DEMO) {
|
||||
log.Println("processEvents() do Event DEMO")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func ReadReceivedData(data *pb.Event, mh *gui.TableData) {
|
||||
msgItems := data.GetResults()
|
||||
log.Println("ReadReceivedData() Event msgItems=", msgItems)
|
||||
for _, item := range msgItems {
|
||||
log.Println(item)
|
||||
}
|
||||
|
||||
nets := data.GetNetworks()
|
||||
log.Println("ReadReceivedData() Event networks=", nets)
|
||||
for _, item := range nets {
|
||||
log.Println(item)
|
||||
}
|
||||
|
||||
vms := data.GetVms()
|
||||
log.Println("ReadReceivedData() Event vms=", vms)
|
||||
row := 0
|
||||
for _, item := range vms {
|
||||
mh.Rows[row].Cells[3].Raw = item.Name
|
||||
log.Println(item)
|
||||
row += 1
|
||||
}
|
||||
|
||||
log.Println("ReadReceivedData() mh rows")
|
||||
for row := 0; row < mh.RowCount; row++ {
|
||||
log.Println("\trow=", row)
|
||||
}
|
||||
}
|
||||
|
||||
func handleProtoClient(conn net.Conn) {
|
||||
fmt.Println("Connected!")
|
||||
defer conn.Close()
|
||||
var buf bytes.Buffer
|
||||
_, err := io.Copy(&buf, conn)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Fatal error: %s", err.Error())
|
||||
return
|
||||
}
|
||||
pdata := pb.CreateSampleEvent()
|
||||
err = proto.Unmarshal(buf.Bytes(), pdata)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Fatal error: %s", err.Error())
|
||||
return
|
||||
}
|
||||
mychannel <- pdata
|
||||
}
|
||||
|
||||
// Marshal & Unmarshal just to see if it ever fails
|
||||
func addEvent(msg *pb.Event) {
|
||||
data, err := proto.Marshal(msg)
|
||||
if (err != nil) {
|
||||
log.Printf("addEvent() something fucked up happened in Marshal")
|
||||
}
|
||||
|
||||
pdata := new(pb.Event)
|
||||
err = proto.Unmarshal(data, pdata)
|
||||
if (err != nil) {
|
||||
log.Printf("addEvent() something fucked up happened in Unmarshal")
|
||||
}
|
||||
|
||||
mychannel <- pdata
|
||||
}
|
||||
|
||||
func addSampleEvent() {
|
||||
msg := pb.CreateSampleEvent()
|
||||
msg.Name = "generated in addSampleEvent()"
|
||||
|
||||
data, err := proto.Marshal(msg)
|
||||
if (err != nil) {
|
||||
log.Printf("addSampleEvent() something fucked up happened in Marshal")
|
||||
}
|
||||
|
||||
pdata := new(pb.Event)
|
||||
err = proto.Unmarshal(data, pdata)
|
||||
if (err != nil) {
|
||||
log.Printf("addSampleEvent() something fucked up happened in Unmarshal")
|
||||
}
|
||||
|
||||
mychannel <- pdata
|
||||
}
|
||||
|
||||
func sendEventToWIT() {
|
||||
msg := pb.CreateSampleEvent()
|
||||
|
||||
var mybuf []byte
|
||||
mybuf, err := proto.Marshal(msg)
|
||||
if (err != nil) {
|
||||
log.Printf("something fucked up happened")
|
||||
}
|
||||
writeBytesToSocket(mybuf)
|
||||
}
|
||||
|
||||
func sendDataToDest() {
|
||||
msg := pb.CreateSampleEvent()
|
||||
msg.Name = "from dnssecsockettest()"
|
||||
|
||||
data, err := proto.Marshal(msg)
|
||||
if (err != nil) {
|
||||
log.Printf("something fucked up happened")
|
||||
}
|
||||
|
||||
conn, err := net.Dial("tcp", "localhost:8080")
|
||||
if err != nil {
|
||||
log.Println("Fatal error: %s", err.Error())
|
||||
return
|
||||
}
|
||||
n, err := conn.Write(data)
|
||||
if err != nil {
|
||||
// fmt.Fprintf(os.Stderr, "Fatal error: %s", err.Error())
|
||||
log.Println("Fatal error: %s", err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
pb.DumpEventData(msg)
|
||||
log.Println("Sent " + strconv.Itoa(n) + " bytes")
|
||||
// time.Sleep(3 * 1000 * 1000 * 1000)
|
||||
conn.Close()
|
||||
}
|
|
@ -0,0 +1,138 @@
|
|||
// Copyright 2015 The Gorilla WebSocket Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package main
|
||||
|
||||
// import "flag"
|
||||
import "log"
|
||||
import "net/url"
|
||||
import "os"
|
||||
import "os/signal"
|
||||
import "time"
|
||||
|
||||
import "github.com/gorilla/websocket"
|
||||
|
||||
import "github.com/golang/protobuf/proto"
|
||||
import pb "git.wit.com/wit/witProtobuf"
|
||||
|
||||
var gorillaConn *websocket.Conn
|
||||
|
||||
func readGorillaConn(conn *websocket.Conn) {
|
||||
for {
|
||||
mytype, message, err := conn.ReadMessage()
|
||||
if err != nil {
|
||||
log.Println("read:", err)
|
||||
return
|
||||
}
|
||||
if (mytype == websocket.BinaryMessage) {
|
||||
protobufMsg := new(pb.Event)
|
||||
err = proto.Unmarshal(message, protobufMsg)
|
||||
if (err != nil) {
|
||||
log.Printf("readConn() something fucked up happened in Unmarshal")
|
||||
}
|
||||
log.Printf("readGorillaConn() successfully read protobuf from gorilla websocket")
|
||||
addEvent(protobufMsg)
|
||||
} else {
|
||||
log.Printf("recv: %s", message)
|
||||
// log.Printf("type, err = ", mytype, err)
|
||||
}
|
||||
time.Sleep(time.Second)
|
||||
log.Println("gorilla readGorillaConn()", time.Now())
|
||||
}
|
||||
}
|
||||
|
||||
func gorillaSendProtobuf() {
|
||||
if (gorillaConn == nil) {
|
||||
log.Println("gorillaSendProtobuf() gorillaConn == nil")
|
||||
log.Println("Need to re-open connection here")
|
||||
return
|
||||
}
|
||||
msg := pb.CreateSampleEvent()
|
||||
msg.Name = "test echo over gorilla websocket"
|
||||
data, _ := proto.Marshal(msg)
|
||||
err2 := gorillaConn.WriteMessage(websocket.BinaryMessage, data)
|
||||
if err2 != nil {
|
||||
log.Println("write:", err2)
|
||||
gorillaConn = nil
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
func closeGorillaConn() {
|
||||
if gorillaConn == nil {
|
||||
log.Println("gorillaConn already was nil")
|
||||
return
|
||||
}
|
||||
|
||||
// Cleanly close the connection by sending a close message and then
|
||||
// waiting (with timeout) for the server to close the connection.
|
||||
err := gorillaConn.WriteMessage(websocket.CloseMessage, websocket.FormatCloseMessage(websocket.CloseNormalClosure, ""))
|
||||
if err != nil {
|
||||
log.Println("write close:", err)
|
||||
return
|
||||
}
|
||||
|
||||
// this must be called or set to be called with defer
|
||||
gorillaConn.Close()
|
||||
gorillaConn = nil
|
||||
}
|
||||
|
||||
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"}
|
||||
log.Printf("connecting to %s", u.String())
|
||||
|
||||
conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
|
||||
if err != nil {
|
||||
log.Println("gorilla Dial failed", err)
|
||||
} else {
|
||||
gorillaConn = conn
|
||||
|
||||
// handle inbound messages on the channel
|
||||
readGorillaConn(conn)
|
||||
closeGorillaConn()
|
||||
}
|
||||
|
||||
time.Sleep(time.Second * 5) // try every 5 seconds
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// this is a facinating code snippet that I wanted to leave here because it is
|
||||
// so interesting. Complements to the gorilla websocket example developers
|
||||
//
|
||||
func beautifulAndFacinatingChannel() {
|
||||
done := make(chan struct{})
|
||||
|
||||
interrupt := make(chan os.Signal, 1)
|
||||
signal.Notify(interrupt, os.Interrupt)
|
||||
|
||||
ticker := time.NewTicker(time.Second * 1)
|
||||
|
||||
defer ticker.Stop()
|
||||
defer close(done)
|
||||
|
||||
for {
|
||||
select {
|
||||
case <-done:
|
||||
return
|
||||
case t := <-ticker.C:
|
||||
log.Println("gorilla NewTicker()", t.String())
|
||||
case <-interrupt:
|
||||
log.Println("interrupt")
|
||||
|
||||
gorillaSendProtobuf()
|
||||
|
||||
// not sure what this does. nothing right?
|
||||
select {
|
||||
case <-done:
|
||||
case <-time.After(time.Second):
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,243 @@
|
|||
package main
|
||||
|
||||
import "log"
|
||||
import "time"
|
||||
import "fmt"
|
||||
import "runtime/debug"
|
||||
import "runtime"
|
||||
|
||||
import "github.com/gookit/config"
|
||||
|
||||
import "github.com/andlabs/ui"
|
||||
import _ "github.com/andlabs/ui/winmanifest"
|
||||
|
||||
import "git.wit.com/wit/gui"
|
||||
|
||||
// import "github.com/davecgh/go-spew/spew"
|
||||
|
||||
var cloudwin *ui.Window
|
||||
var cloudtab *ui.Tab
|
||||
var tabcount int
|
||||
|
||||
func makeCloudInfoBox() ui.Control {
|
||||
hbox := ui.NewHorizontalBox()
|
||||
hbox.SetPadded(true)
|
||||
|
||||
vbox := ui.NewVerticalBox()
|
||||
vbox.SetPadded(true)
|
||||
hbox.Append(vbox, false)
|
||||
|
||||
vbox.Append(ui.NewColorButton(), false)
|
||||
|
||||
mybutton := ui.NewButton("cpuinfo")
|
||||
mybutton.OnClicked(func(*ui.Button) {
|
||||
log.Println("send over socket")
|
||||
writelnToSocket("cpuinfo")
|
||||
})
|
||||
vbox.Append(mybutton, false)
|
||||
|
||||
// VM list test button
|
||||
listVMbutton := ui.NewButton("list")
|
||||
listVMbutton.OnClicked(func(*ui.Button) {
|
||||
log.Println("send over socket")
|
||||
writelnToSocket("list")
|
||||
})
|
||||
vbox.Append(listVMbutton, false)
|
||||
|
||||
vbox.Append(ui.NewLabel("Debugging:"), false)
|
||||
|
||||
// ATTEMPT TO ADD THE TABLE HERE
|
||||
add2button := ui.NewButton("Add a Test Table")
|
||||
add2button.OnClicked(func(*ui.Button) {
|
||||
log.Println("send over socket")
|
||||
addTableTab()
|
||||
})
|
||||
vbox.Append(add2button, false)
|
||||
// ATTEMPT TO ADD THE TABLE HERE END
|
||||
|
||||
hbox.Append(ui.NewVerticalSeparator(), false)
|
||||
|
||||
// Send a test protobuf Event to localhost
|
||||
add3button := ui.NewButton("Add buf to chann")
|
||||
add3button.OnClicked(func(*ui.Button) {
|
||||
log.Println("add protobuf event to the channel")
|
||||
addSampleEvent()
|
||||
})
|
||||
vbox.Append(add3button, false)
|
||||
|
||||
// Send a protobuf Event over the WIT socket
|
||||
add4button := ui.NewButton("Send protobuf to Event Channel")
|
||||
add4button.OnClicked(func(*ui.Button) {
|
||||
log.Println("sent a protobuf over the TCP socket")
|
||||
sendEventToWIT()
|
||||
})
|
||||
vbox.Append(add4button, false)
|
||||
|
||||
// Send a protobuf Event over the WIT socket
|
||||
add5button := ui.NewButton("Send protobuf to localhost")
|
||||
add5button.OnClicked(func(*ui.Button) {
|
||||
log.Println("sent a Marshal'd protobuf to a localhost socket")
|
||||
sendDataToDest()
|
||||
})
|
||||
vbox.Append(add5button, false)
|
||||
|
||||
// Send a protobuf over a gorilla websocket
|
||||
add6button := ui.NewButton("gorillaSendProtobuf()")
|
||||
add6button.OnClicked(func(*ui.Button) {
|
||||
log.Println("gorillaSendProtobuf()")
|
||||
gorillaSendProtobuf()
|
||||
})
|
||||
vbox.Append(add6button, false)
|
||||
|
||||
// debug all the golang goroutines
|
||||
add7button := ui.NewButton("debug.PrintStack()")
|
||||
add7button.OnClicked(func(*ui.Button) {
|
||||
log.Println("debug.PrintStack() (SHOULD BE JUST THIS goroutine)")
|
||||
debug.PrintStack()
|
||||
|
||||
log.Println("ATTEMPT FULL STACK DUMP")
|
||||
log.Println("ATTEMPT FULL STACK DUMP")
|
||||
log.Println("ATTEMPT FULL STACK DUMP")
|
||||
buf := make([]byte, 1<<16)
|
||||
runtime.Stack(buf, true)
|
||||
fmt.Printf("%s", buf)
|
||||
})
|
||||
vbox.Append(add7button, false)
|
||||
|
||||
hbox.Append(ui.NewVerticalSeparator(), false)
|
||||
|
||||
vbox = ui.NewVerticalBox()
|
||||
vbox.SetPadded(true)
|
||||
hbox.Append(vbox, true)
|
||||
|
||||
grid := ui.NewGrid()
|
||||
grid.SetPadded(true)
|
||||
vbox.Append(grid, false)
|
||||
|
||||
msggrid := ui.NewGrid()
|
||||
msggrid.SetPadded(true)
|
||||
|
||||
entryForm := ui.NewForm()
|
||||
entryForm.SetPadded(true)
|
||||
vbox.Append(entryForm, false)
|
||||
|
||||
hostnameEntry := ui.NewEntry()
|
||||
entryForm.Append("hostname:", hostnameEntry, false)
|
||||
hostnameEntry.SetText("librem15.lab.wit.com")
|
||||
|
||||
IPv6entry := ui.NewEntry()
|
||||
entryForm.Append("IPv6:", IPv6entry, false)
|
||||
IPv6entry.SetText("2604:bbc0:3:3:0:10:0:1003")
|
||||
|
||||
return hbox
|
||||
}
|
||||
|
||||
func setupCloudUI() {
|
||||
cloudwin = ui.NewWindow("Cloud Control Panel", config.Int("width"), config.Int("height"), false)
|
||||
cloudwin.OnClosing(func(*ui.Window) bool {
|
||||
ui.Quit()
|
||||
return true
|
||||
})
|
||||
ui.OnShouldQuit(func() bool {
|
||||
cloudwin.Destroy()
|
||||
return true
|
||||
})
|
||||
|
||||
cloudtab = ui.NewTab()
|
||||
cloudwin.SetChild(cloudtab)
|
||||
cloudwin.SetMargined(true)
|
||||
|
||||
tabcount = 0
|
||||
cloudtab.Append("Cloud Info", makeCloudInfoBox())
|
||||
cloudtab.SetMargined(tabcount, true)
|
||||
|
||||
cloudwin.Show()
|
||||
}
|
||||
|
||||
func addTableTab() {
|
||||
var parts []gui.InputData
|
||||
|
||||
for key, foo := range []string{"BG", "TEXTCOLOR", "BUTTON", "TEXTCOLOR", "TEXTCOLOR", "TEXT", "BUTTON", "TEXT", "BUTTON"} {
|
||||
log.Println(key, foo)
|
||||
|
||||
var b gui.InputData
|
||||
b.CellType = foo
|
||||
b.Heading = fmt.Sprintf("heading%d", key)
|
||||
parts = append(parts, b)
|
||||
}
|
||||
|
||||
log.Println("Sleep for 2 seconds, then try to add new tabs")
|
||||
time.Sleep(1 * 1000 * 1000 * 1000)
|
||||
gui.AddTableTab(cloudtab, 1, "test seven", 7, parts)
|
||||
}
|
||||
|
||||
func addProtobufTab() {
|
||||
var parts []gui.InputData
|
||||
|
||||
for key, foo := range []string{"BG", "TEXTCOLOR", "BUTTON", "TEXTCOLOR", "TEXTCOLOR", "TEXT", "BUTTON", "TEXT", "BUTTON"} {
|
||||
log.Println(key, foo)
|
||||
|
||||
var b gui.InputData
|
||||
b.CellType = foo
|
||||
b.Heading = fmt.Sprintf("heading%d", key)
|
||||
parts = append(parts, b)
|
||||
}
|
||||
|
||||
log.Println("Sleep for 2 seconds, then try to add new tabs")
|
||||
time.Sleep(1 * 1000 * 1000 * 1000)
|
||||
gui.AddTableTab(cloudtab, 1, "test seven", 7, parts)
|
||||
}
|
||||
|
||||
type aheader struct {
|
||||
headtype string
|
||||
name string
|
||||
}
|
||||
|
||||
func addVmsTab(count int) *gui.TableData {
|
||||
var parts []gui.InputData
|
||||
|
||||
human := 0
|
||||
|
||||
tmp := gui.InputData{}
|
||||
tmp.CellType = "BG"
|
||||
tmp.Heading = "background"
|
||||
tmp.Index = human
|
||||
parts = append(parts, tmp)
|
||||
human += 1
|
||||
|
||||
tmp = gui.InputData{}
|
||||
tmp.CellType = "TEXTCOLOR"
|
||||
tmp.Heading = "name"
|
||||
tmp.Index = human
|
||||
parts = append(parts, tmp)
|
||||
|
||||
tmp = gui.InputData{}
|
||||
tmp.CellType = "TEXTCOLOR"
|
||||
tmp.Heading = "hostname"
|
||||
tmp.Index = human
|
||||
parts = append(parts, tmp)
|
||||
|
||||
tmp = gui.InputData{}
|
||||
tmp.CellType = "TEXTCOLOR"
|
||||
tmp.Heading = "IPv6"
|
||||
tmp.Index = human
|
||||
parts = append(parts, tmp)
|
||||
|
||||
tmp = gui.InputData{}
|
||||
tmp.CellType = "TEXTCOLOR"
|
||||
tmp.Heading = "cpus"
|
||||
parts = append(parts, tmp)
|
||||
|
||||
tmp = gui.InputData{}
|
||||
tmp.CellType = "TEXTCOLOR"
|
||||
tmp.Heading = "memory"
|
||||
parts = append(parts, tmp)
|
||||
|
||||
tmp = gui.InputData{}
|
||||
tmp.CellType = "BUTTON"
|
||||
tmp.Heading = "Details"
|
||||
parts = append(parts, tmp)
|
||||
|
||||
mh := gui.AddTableTab(cloudtab, 1, "Virtual Machines", count, parts)
|
||||
return mh
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package main
|
||||
|
||||
// import "github.com/gookit/config"
|
||||
|
||||
import "github.com/andlabs/ui"
|
||||
import _ "github.com/andlabs/ui/winmanifest"
|
||||
|
||||
func main() {
|
||||
parseConfig()
|
||||
|
||||
initChannel()
|
||||
go processEvents()
|
||||
|
||||
// setups up a dnssecsocket()
|
||||
go retrySocket()
|
||||
|
||||
// make this the main loop in an attempt to figure out the crashes
|
||||
// do not change this until the GUI is stable
|
||||
ui.Main(setupCloudUI)
|
||||
}
|
|
@ -6,16 +6,10 @@ import "time"
|
|||
import "net"
|
||||
import "fmt"
|
||||
import "bufio"
|
||||
// import "strings"
|
||||
|
||||
import "git.wit.com/wit/shell"
|
||||
import "git.wit.com/jcarr/dnssecsocket"
|
||||
|
||||
// import "github.com/svent/go-nbreader"
|
||||
// import "github.com/gookit/config"
|
||||
|
||||
// import "github.com/davecgh/go-spew/spew"
|
||||
|
||||
var socketAlive bool = false
|
||||
var connCurrent *net.TCPConn
|
||||
|
30
infoTabUI.go
30
infoTabUI.go
|
@ -29,21 +29,6 @@ func makeCloudInfoBox() ui.Control {
|
|||
|
||||
vbox.Append(ui.NewColorButton(), false)
|
||||
|
||||
mybutton := ui.NewButton("cpuinfo")
|
||||
mybutton.OnClicked(func(*ui.Button) {
|
||||
log.Println("send over socket")
|
||||
writelnToSocket("cpuinfo")
|
||||
})
|
||||
vbox.Append(mybutton, false)
|
||||
|
||||
// VM list test button
|
||||
listVMbutton := ui.NewButton("list")
|
||||
listVMbutton.OnClicked(func(*ui.Button) {
|
||||
log.Println("send over socket")
|
||||
writelnToSocket("list")
|
||||
})
|
||||
vbox.Append(listVMbutton, false)
|
||||
|
||||
vbox.Append(ui.NewLabel("Debugging:"), false)
|
||||
|
||||
// ATTEMPT TO ADD THE TABLE HERE
|
||||
|
@ -65,14 +50,6 @@ func makeCloudInfoBox() ui.Control {
|
|||
})
|
||||
vbox.Append(add3button, false)
|
||||
|
||||
// Send a protobuf Event over the WIT socket
|
||||
add4button := ui.NewButton("Send protobuf")
|
||||
add4button.OnClicked(func(*ui.Button) {
|
||||
log.Println("sent a protobuf over the TCP socket")
|
||||
sendEventToWIT()
|
||||
})
|
||||
vbox.Append(add4button, false)
|
||||
|
||||
// Send a protobuf Event over the WIT socket
|
||||
add5button := ui.NewButton("Send protobuf to localhost")
|
||||
add5button.OnClicked(func(*ui.Button) {
|
||||
|
@ -196,24 +173,31 @@ type aheader struct {
|
|||
func addVmsTab(count int) *gui.TableData {
|
||||
var parts []gui.InputData
|
||||
|
||||
human := 0
|
||||
|
||||
tmp := gui.InputData{}
|
||||
tmp.CellType = "BG"
|
||||
tmp.Heading = "background"
|
||||
tmp.Index = human
|
||||
parts = append(parts, tmp)
|
||||
human += 1
|
||||
|
||||
tmp = gui.InputData{}
|
||||
tmp.CellType = "TEXTCOLOR"
|
||||
tmp.Heading = "name"
|
||||
tmp.Index = human
|
||||
parts = append(parts, tmp)
|
||||
|
||||
tmp = gui.InputData{}
|
||||
tmp.CellType = "TEXTCOLOR"
|
||||
tmp.Heading = "hostname"
|
||||
tmp.Index = human
|
||||
parts = append(parts, tmp)
|
||||
|
||||
tmp = gui.InputData{}
|
||||
tmp.CellType = "TEXTCOLOR"
|
||||
tmp.Heading = "IPv6"
|
||||
tmp.Index = human
|
||||
parts = append(parts, tmp)
|
||||
|
||||
tmp = gui.InputData{}
|
||||
|
|
5
main.go
5
main.go
|
@ -55,16 +55,13 @@ func main() {
|
|||
|
||||
// only test the socket code if no GUI
|
||||
if (config.String("nogui") == "true") {
|
||||
retrySocket()
|
||||
log.Println("Need to re-implement this")
|
||||
onExit()
|
||||
}
|
||||
|
||||
initChannel()
|
||||
go processEvents()
|
||||
|
||||
// setups up a dnssecsocket()
|
||||
go retrySocket()
|
||||
|
||||
go gorillaDial("v000185.testing.com.customers.wprod.wit.com:9000")
|
||||
|
||||
// make this the main loop in an attempt to figure out the crashes
|
||||
|
|
Loading…
Reference in New Issue