Add simple test SSH server.
parent
800d9897ff
commit
cfda71a3aa
|
@ -0,0 +1,42 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"io"
|
||||
"log"
|
||||
|
||||
"github.com/gliderlabs/ssh"
|
||||
"github.com/qpliu/qrencode-go/qrencode"
|
||||
|
||||
"git.icedream.tech/icedream/pixelqr/internal"
|
||||
)
|
||||
|
||||
func main() {
|
||||
greeting := "https://git.icedream.tech/icedream/pixelqr"
|
||||
|
||||
ssh.Handle(func(s ssh.Session) {
|
||||
grid, err := qrencode.Encode(greeting, qrencode.ECLevelQ)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
return
|
||||
}
|
||||
|
||||
w := new(bytes.Buffer)
|
||||
err = internal.ConvertGridToUnicode(w, grid)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
return
|
||||
}
|
||||
qrs := string(w.Bytes())
|
||||
|
||||
io.WriteString(s, "Scan this QR code for the link to the library that generated it:\n\n")
|
||||
io.WriteString(s, qrs)
|
||||
io.WriteString(s, "\n\nThank you!\n")
|
||||
|
||||
for err == nil {
|
||||
_, err = s.Read([]byte{})
|
||||
}
|
||||
})
|
||||
|
||||
log.Fatal(ssh.ListenAndServe(":2020", nil))
|
||||
}
|
Loading…
Reference in New Issue