Add testinp binary

This commit is contained in:
qowevisa 2024-03-14 00:04:05 +02:00
parent e666ac8e3b
commit 0ab01ad7f5
2 changed files with 33 additions and 0 deletions

View File

@ -13,6 +13,9 @@ server:
client:
go build -o ./bin/$@ ./cmd/$@
testinp:
go build -o ./bin/$@ ./cmd/$@
gen_test_certs:
openssl ecparam -genkey -name prime256v1 -out server.key
openssl req -new -x509 -key server.key -out server.pem -days 3650

30
cmd/testinp/main.go Normal file
View File

@ -0,0 +1,30 @@
package main
import (
"bufio"
"log"
"os"
"golang.org/x/term"
)
func main() {
oldState, err := term.MakeRaw(int(os.Stdin.Fd()))
if err != nil {
panic(err)
}
defer term.Restore(int(os.Stdin.Fd()), oldState)
reader := bufio.NewReader(os.Stdin)
for {
r, _, err := reader.ReadRune()
if err != nil {
panic(err)
}
log.Printf("Read %c ; %d as rune\r\n", r, r)
// CTRL + C
if r == 3 {
break
}
}
}