fix all the tab and windows names finally
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
f0b86fd1a7
commit
b95667f6e6
|
@ -0,0 +1,100 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"io"
|
||||||
|
"io/ioutil"
|
||||||
|
"log"
|
||||||
|
|
||||||
|
"code.google.com/p/go.crypto/ssh"
|
||||||
|
"code.google.com/p/go.crypto/ssh/terminal"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
// An SSH server is represented by a ServerConfig, which holds
|
||||||
|
// certificate details and handles authentication of ServerConns.
|
||||||
|
config := &ssh.ServerConfig{
|
||||||
|
PasswordCallback: func(conn *ssh.ServerConn, user, pass string) bool {
|
||||||
|
return user == "testuser" && pass == "tiger"
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
pemBytes, err := ioutil.ReadFile("id_rsa")
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal("Failed to load private key:", err)
|
||||||
|
}
|
||||||
|
if err = config.SetRSAPrivateKey(pemBytes); err != nil {
|
||||||
|
log.Fatal("Failed to parse private key:", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Once a ServerConfig has been configured, connections can be
|
||||||
|
// accepted.
|
||||||
|
conn, err := ssh.Listen("tcp", "0.0.0.0:2022", config)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal("failed to listen for connection")
|
||||||
|
}
|
||||||
|
for {
|
||||||
|
// A ServerConn multiplexes several channels, which must
|
||||||
|
// themselves be Accepted.
|
||||||
|
log.Println("accept")
|
||||||
|
sConn, err := conn.Accept()
|
||||||
|
if err != nil {
|
||||||
|
log.Println("failed to accept incoming connection")
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if err := sConn.Handshake(); err != nil {
|
||||||
|
log.Println("failed to handshake")
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
go handleServerConn(sConn)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func handleServerConn(sConn *ssh.ServerConn) {
|
||||||
|
defer sConn.Close()
|
||||||
|
for {
|
||||||
|
// Accept reads from the connection, demultiplexes packets
|
||||||
|
// to their corresponding channels and returns when a new
|
||||||
|
// channel request is seen. Some goroutine must always be
|
||||||
|
// calling Accept; otherwise no messages will be forwarded
|
||||||
|
// to the channels.
|
||||||
|
ch, err := sConn.Accept()
|
||||||
|
if err == io.EOF {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
log.Println("handleServerConn Accept:", err)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
// Channels have a type, depending on the application level
|
||||||
|
// protocol intended. In the case of a shell, the type is
|
||||||
|
// "session" and ServerShell may be used to present a simple
|
||||||
|
// terminal interface.
|
||||||
|
if ch.ChannelType() != "session" {
|
||||||
|
ch.Reject(ssh.UnknownChannelType, "unknown channel type")
|
||||||
|
break
|
||||||
|
}
|
||||||
|
go handleChannel(ch)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func handleChannel(ch ssh.Channel) {
|
||||||
|
term := terminal.NewTerminal(ch, "> ")
|
||||||
|
serverTerm := &ssh.ServerTerminal{
|
||||||
|
Term: term,
|
||||||
|
Channel: ch,
|
||||||
|
}
|
||||||
|
ch.Accept()
|
||||||
|
defer ch.Close()
|
||||||
|
for {
|
||||||
|
line, err := serverTerm.ReadLine()
|
||||||
|
if err == io.EOF {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
log.Println("handleChannel readLine err:", err)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
fmt.Println(line)
|
||||||
|
}
|
||||||
|
}
|
|
@ -10,7 +10,8 @@ func makeCloudInfoBox(gw *gui.GuiWindow) {
|
||||||
log.Println("makeCloudInfoBox() START gw =", gw)
|
log.Println("makeCloudInfoBox() START gw =", gw)
|
||||||
|
|
||||||
gw.UiTab.Delete(0) // does this make things more or less stable or neither?
|
gw.UiTab.Delete(0) // does this make things more or less stable or neither?
|
||||||
gw = gui.InitGuiWindow("makeCloudInfoBox() Box23", gw)
|
gw.Name = "Cloud Accounts"
|
||||||
|
gw = gui.InitGuiWindow(gw)
|
||||||
// TODO: make this text i18n
|
// TODO: make this text i18n
|
||||||
box := gui.HardBox(gw, gui.Yaxis, "Cloud Accounts")
|
box := gui.HardBox(gw, gui.Yaxis, "Cloud Accounts")
|
||||||
|
|
||||||
|
@ -62,7 +63,8 @@ func initWindow(gw *gui.GuiWindow, name string, axis int) *gui.GuiBox {
|
||||||
}
|
}
|
||||||
|
|
||||||
// if there is not an account, then go to 'make account'
|
// if there is not an account, then go to 'make account'
|
||||||
newWindow := gui.InitGuiWindow("createAccount", gw)
|
gw.Name = name
|
||||||
|
newWindow := gui.InitGuiWindow(gw)
|
||||||
|
|
||||||
var box *gui.GuiBox
|
var box *gui.GuiBox
|
||||||
if (axis == gui.Xaxis) {
|
if (axis == gui.Xaxis) {
|
||||||
|
|
|
@ -84,7 +84,8 @@ func createAddVmBox(b *gui.GuiButton) {
|
||||||
// gw.BoxMap["ADD VM" + name] = box
|
// gw.BoxMap["ADD VM" + name] = box
|
||||||
|
|
||||||
txt := "ADD VM " + name
|
txt := "ADD VM " + name
|
||||||
gw = gui.InitGuiWindow(txt, gw)
|
gw.Name = txt
|
||||||
|
gw = gui.InitGuiWindow(gw)
|
||||||
box := gui.HardBox(gw, gui.Yaxis, txt)
|
box := gui.HardBox(gw, gui.Yaxis, txt)
|
||||||
box = gui.HardBox(gw, gui.Xaxis, txt)
|
box = gui.HardBox(gw, gui.Xaxis, txt)
|
||||||
// box := gui.AddGenericBox(gw, name)
|
// box := gui.AddGenericBox(gw, name)
|
||||||
|
@ -114,7 +115,8 @@ func createVmBox(gw *gui.GuiWindow, vm *pb.Event_VM) {
|
||||||
log.Println("CreateVmBox() START vm.Name =", vm.Name)
|
log.Println("CreateVmBox() START vm.Name =", vm.Name)
|
||||||
|
|
||||||
txt := "VM " + vm.Name
|
txt := "VM " + vm.Name
|
||||||
gw = gui.InitGuiWindow(txt, gw)
|
gw.Name = txt
|
||||||
|
gw = gui.InitGuiWindow(gw)
|
||||||
box := gui.HardBox(gw, gui.Yaxis, txt)
|
box := gui.HardBox(gw, gui.Yaxis, txt)
|
||||||
box = gui.HardBox(gw, gui.Xaxis, txt)
|
box = gui.HardBox(gw, gui.Xaxis, txt)
|
||||||
|
|
||||||
|
|
2
main.go
2
main.go
|
@ -140,7 +140,7 @@ func main() {
|
||||||
|
|
||||||
// make this the main loop in an attempt to figure out the crashes
|
// make this the main loop in an attempt to figure out the crashes
|
||||||
// do not change this until the GUI is stable
|
// do not change this until the GUI is stable
|
||||||
gui.StartNewWindow(false, "Cloud Control Panel", showSplashBox)
|
gui.StartNewWindow(false, "Cloud Control Panel", gui.Yaxis, showSplashBox)
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
Loading…
Reference in New Issue