Compare commits

..

7 Commits

Author SHA1 Message Date
Icedream b6b245c65e
Enforce colorized output for QR code. 2017-09-04 11:53:17 +02:00
Icedream c7bd31c631
Fix build path. 2017-09-04 11:47:01 +02:00
Icedream d288c96f2d
Add some more debug output. 2017-09-04 11:41:40 +02:00
Icedream 9da29de05b
Fix missing git during build. 2017-09-04 11:40:15 +02:00
Icedream b00f9a5605
Add ignore files. 2017-09-04 11:39:24 +02:00
Icedream 024a2c75e9
Add Dockerfile. 2017-09-04 11:39:17 +02:00
Icedream cfda71a3aa
Add simple test SSH server. 2017-09-04 11:32:24 +02:00
5 changed files with 135 additions and 0 deletions

27
.dockerignore Normal file
View File

@ -0,0 +1,27 @@
# Compiled Object files, Static and Dynamic libs (Shared Objects)
*.o
*.a
*.so
# Folders
_obj
_test
# Architecture specific extensions/prefixes
*.[568vq]
[568vq].out
*.cgo1.go
*.cgo2.c
_cgo_defun.c
_cgo_gotypes.go
_cgo_export.*
_testmain.go
# Binaries
*.exe
/pixelqr
# Test files
*.test

15
Dockerfile Normal file
View File

@ -0,0 +1,15 @@
FROM golang:1.9-alpine
COPY . ${GOPATH}/src/git.icedream.tech/icedream/pixelqr
RUN cd "${GOPATH}/src/git.icedream.tech/icedream/pixelqr/testssh" \
&& apk add --no-cache --virtual .build-deps git \
&& echo == Downloading... == \
&& go get -v -d ./... \
&& echo == Building... == \
&& go build -v \
&& mv testssh /usr/local/bin \
&& cd / \
&& rm -r ${GOPATH} \
&& apk del --no-cache .build-deps
CMD ["testssh"]

24
testssh/.dockerignore Normal file
View File

@ -0,0 +1,24 @@
# Compiled Object files, Static and Dynamic libs (Shared Objects)
*.o
*.a
*.so
# Folders
_obj
_test
# Architecture specific extensions/prefixes
*.[568vq]
[568vq].out
*.cgo1.go
*.cgo2.c
_cgo_defun.c
_cgo_gotypes.go
_cgo_export.*
_testmain.go
testssh
*.exe
*.test

24
testssh/.gitignore vendored Normal file
View File

@ -0,0 +1,24 @@
# Compiled Object files, Static and Dynamic libs (Shared Objects)
*.o
*.a
*.so
# Folders
_obj
_test
# Architecture specific extensions/prefixes
*.[568vq]
[568vq].out
*.cgo1.go
*.cgo2.c
_cgo_defun.c
_cgo_gotypes.go
_cgo_export.*
_testmain.go
testssh
*.exe
*.test

45
testssh/main.go Normal file
View File

@ -0,0 +1,45 @@
package main
import (
"bytes"
"io"
"log"
"github.com/fatih/color"
"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"
color.NoColor = false
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))
}