diff --git a/Client.md b/Client.md index 69614b2..ac68158 100644 --- a/Client.md +++ b/Client.md @@ -1,9 +1,9 @@ # GoSmartKeyboard Client -When GoSmartKeyboard is started in client mode, it does the following: +When the GoSmartKeyboard client is started, it does the following: -1. Load the connection URL from the second CLI argument. -2. Load the auth token from the environment variable `KEYBOARD_AUTH` or stdin. +1. Load the connection URL from the first CLI argument. +2. Load the auth token from the environment variable `KEYBOARD_AUTH` or stdin if it does not exist. 3. Connect to the server. 4 Send the auth token to the server. 5. If the server responds with "authenticated", we start reading keys from stdin and sending them to the server until EOF. @@ -13,7 +13,7 @@ When GoSmartKeyboard is started in client mode, it does the following: ``` go --- handle client command -if len(os.Args) > 1 && os.Args[1] == "connect" { +if len(os.Args) > 1 { @{get client fifo input file from environment} @{setup client} if clientFifoInputFileExists { @@ -174,4 +174,26 @@ addXDoToolIfNonQWERTY := func(message string)(string) { } --- -``` \ No newline at end of file +``` + + +``` go +--- /client/main-client.go +package main +import ( + "strings" + "io/ioutil" + "io" + "bufio" + "log" + "fmt" + "os" +@{gorilla/websocket import string} + +) + +func main(){@{handle client command}} + + +--- +``` diff --git a/Makefile b/Makefile index 0be4e54..b2645a5 100644 --- a/Makefile +++ b/Makefile @@ -10,9 +10,12 @@ clean: rm go.sum build: tangle - - cd smartkeyboard && go mod init keyboard.voidnet.tech - - cd smartkeyboard && go mod tidy - - cd smartkeyboard && go build -o ../bin/keyboard + - cd smartkeyboard/server && go mod init keyboard.voidnet.tech + - cd smartkeyboard/server && go mod tidy + - cd smartkeyboard/server && go build -o ../../bin/keyboard + - cd smartkeyboard/client && go mod init keyboard.voidnet.tech + - cd smartkeyboard/client && go mod tidy + - cd smartkeyboard/client && go build -o ../../bin/keyboard-client test: tangle diff --git a/ReadMe.md b/ReadMe.md index 3d5397c..e60c46a 100644 --- a/ReadMe.md +++ b/ReadMe.md @@ -65,8 +65,6 @@ Then we can start the web server and listen for websocket connections. func main(){ - @{handle client command} - tokenBase64, _ := auth.ProvisionToken() if len(tokenBase64) > 0 { fmt.Println("This is your authentication token, it will only be shown once: " + tokenBase64) @@ -79,7 +77,7 @@ Then we can start the web server and listen for websocket connections. --- ---- /main.go +--- /server/main.go package main import( diff --git a/Server.md b/Server.md index cb1e1e8..0ec4fe2 100644 --- a/Server.md +++ b/Server.md @@ -53,7 +53,7 @@ func StartServer() { --- ---- /server/server.go +--- /server/server/server.go package server import( diff --git a/security/Authentication.md b/security/Authentication.md index 7c26581..db1e37e 100644 --- a/security/Authentication.md +++ b/security/Authentication.md @@ -98,7 +98,7 @@ The following is the structure of the authentication package. Both CheckAuthToken and ProvisionToken are exported. The former is used by the server on client connect and the latter is called on startup. ---- /auth/auth.go +--- /server/auth/auth.go package auth import(