summaryrefslogtreecommitdiff
path: root/termshare/main.go
diff options
context:
space:
mode:
authorCody Hiar <cody@hiar.ca>2022-03-05 12:53:15 -0700
committerCody Hiar <cody@hiar.ca>2022-03-05 12:53:15 -0700
commit90e2e053d25feabd2dcf384dfc262a8bcdbe3ab8 (patch)
tree8e2799822b4de29014b86ca708123c1dfc8f45f5 /termshare/main.go
Initial CommitHEADmaster
Diffstat (limited to 'termshare/main.go')
-rw-r--r--termshare/main.go64
1 files changed, 64 insertions, 0 deletions
diff --git a/termshare/main.go b/termshare/main.go
new file mode 100644
index 0000000..600e8b1
--- /dev/null
+++ b/termshare/main.go
@@ -0,0 +1,64 @@
+package main
+
+import (
+ "termshare/cmd"
+)
+
+func main() {
+ cmd.Execute()
+}
+
+// import (
+// "fmt"
+// "bufio"
+// "io"
+// "log"
+// "os"
+// "os/exec"
+// "syscall"
+// "strconv"
+// "unsafe"
+
+// "github.com/gliderlabs/ssh"
+// "github.com/creack/pty"
+// )
+
+// func setWinsize(f *os.File, w, h int) {
+// syscall.Syscall(syscall.SYS_IOCTL, f.Fd(), uintptr(syscall.TIOCSWINSZ),
+// uintptr(unsafe.Pointer(&struct{ h, w, x, y uint16 }{uint16(h), uint16(w), 0, 0})))
+// }
+
+// func main() {
+// ssh.Handle(func(s ssh.Session) {
+// cmd := exec.Command("bash")
+// ptyReq, winCh, isPty := s.Pty()
+// if isPty {
+// cmd.Env = append(cmd.Env, fmt.Sprintf("TERM=%s", ptyReq.Term))
+// f, err := pty.Start(cmd)
+// if err != nil {
+// panic(err)
+// }
+// go func() {
+// for win := range winCh {
+// setWinsize(f, win.Width, win.Height)
+// }
+// }()
+// go func() {
+// io.Copy(f, s) // stdin
+// }()
+// io.Copy(s, f) // stdout
+// cmd.Wait()
+// } else {
+// io.WriteString(s, "No PTY requested.\n")
+// reader := bufio.NewReader(s)
+// for {
+// input, _, _ := reader.ReadRune()
+// io.WriteString(os.Stdout, strconv.QuoteRune(input))
+// }
+// s.Exit(1)
+// }
+// })
+
+// log.Println("starting ssh server on port 2222...")
+// log.Fatal(ssh.ListenAndServe(":2222", nil))
+// }