diff --git a/Client.md b/Client.md index 7281cc3..69614b2 100644 --- a/Client.md +++ b/Client.md @@ -16,7 +16,7 @@ When GoSmartKeyboard is started in client mode, it does the following: if len(os.Args) > 1 && os.Args[1] == "connect" { @{get client fifo input file from environment} @{setup client} - if clientFifioInputFileExists { + if clientFifoInputFileExists { @{start client with fifo} os.Exit(0) } diff --git a/EnvironmentVariables.md b/EnvironmentVariables.md index c4537a7..c7ce0f4 100644 --- a/EnvironmentVariables.md +++ b/EnvironmentVariables.md @@ -28,7 +28,7 @@ authTokenFile, authTokenFileIsSet := os.LookupEnv("KEYBOARD_AUTH_TOKEN_FILE") --- get client fifo input file from environment - clientFifoInputFile, clientFifioInputFileExists := os.LookupEnv("KEYBOARD_FIFO") + clientFifoInputFile, clientFifoInputFileExists := os.LookupEnv("KEYBOARD_FIFO") --- diff --git a/Makefile b/Makefile index a680bcd..0be4e54 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ weave: srcweave --formatter srcweave-format --weave docs/ ReadMe.md security/Authentication.md EnvironmentVariables.md Dependencies.md Server.md Streaming.md ThreatModel.md Client.md util/removefencedcode.py tangle: - srcweave --formatter srcweave-format --tangle smartkeyboard/ ReadMe.md security/Authentication.md EnvironmentVariables.md Dependencies.md Server.md Streaming.md ThreatModel.md Client.md tools/Tools.md tools/Cowsay.md tools/Editor.md tools/HelloWorld.md + srcweave --formatter srcweave-format --tangle smartkeyboard/ ReadMe.md security/Authentication.md EnvironmentVariables.md Dependencies.md Server.md Streaming.md ThreatModel.md Client.md tools/Tools.md tools/Editor.md tools/Input.md clean: rm -rf docs find smartkeyboard/ -type f -not -name "*_test.go" -delete diff --git a/tools/Cowsay.md b/tools/Cowsay.md deleted file mode 100644 index 06414ad..0000000 --- a/tools/Cowsay.md +++ /dev/null @@ -1,29 +0,0 @@ -# Cowsay - -This tool sends your text as cow speech to the server. It is a simple example of a tool that can be used to send text to the server. - -``` go - ---- /tools/cowsay.go -@{tool header} -@{tool main} - -func doTool(){ - if len(os.Args) < 2 { - fmt.Println("Usage: cowsay ") - os.Exit(1) - } - cmd := exec.Command("cowsay", os.Args[1:]) - //cmd.Stdin = strings.NewReader("some input") - var out bytes.Buffer - cmd.Stdout = &out - err := cmd.Run() - if err != nil { - log.Fatal(err) - } - fmt.Println(strings) -} - - ---- -``` \ No newline at end of file diff --git a/tools/Editor.md b/tools/Editor.md index fc9f6dd..6f703e9 100644 --- a/tools/Editor.md +++ b/tools/Editor.md @@ -1,3 +1,39 @@ # Input Method Editor This tool uses your $EDITOR to buffer keystrokes. + +``` go +--- /tools/editor/editor.go + +package main + +import ( + "io/ioutil" + "os" +) +// #include +// +// void vim() { +// system("vi inputfile"); +// } +import "C" + +func main() { + + var inputFile := "inputFile" + @{get client fifo input file from environment} + + C.vim() + data, _ := ioutil.ReadFile(inputFile) + f, err := os.OpenFile(clientFifoInputFile, os.O_WRONLY, 0600) + if err != nil { + panic(err) + } + f.Write(data) + os.Remove(inputFile) + +} + + +--- +``` \ No newline at end of file diff --git a/tools/HelloWorld.md b/tools/HelloWorld.md deleted file mode 100644 index 6f79497..0000000 --- a/tools/HelloWorld.md +++ /dev/null @@ -1,15 +0,0 @@ -# Hello World - -Bare bones keyboard tool. - -``` go ---- /tools/helloworld.go -@{tool header} - -func doTool(){ - fmt.Println("Hello World") - -} - -@{tool main} ---- \ No newline at end of file diff --git a/tools/Input.md b/tools/Input.md new file mode 100644 index 0000000..f0f30b6 --- /dev/null +++ b/tools/Input.md @@ -0,0 +1,38 @@ +# Simple Input + +This tool reads lines from stdin and sends them to the server. + +Newline characters are only sent when a blank line is entered. + + +``` go + +--- /tools/input/input.go + +package main + +import ( + "io/ioutil" + "bufio" + "os" +) + +func main(){ + var input string + @{get client fifo input file from environment} + if ! clientFifoInputFileExists { + os.Exit(1) + } + for { + reader := bufio.NewReader(os.Stdin) + input, _ = reader.ReadString('\n') + if len(input) > 0 { + ioutil.WriteFile(clientFifoInputFile, []byte(input), 0644) + } else { + ioutil.WriteFile(clientFifoInputFile, []byte("\n"), 0644) + } + input = "" + } + +} +--- \ No newline at end of file diff --git a/tools/Tools.md b/tools/Tools.md index 5a85047..d9d04b2 100644 --- a/tools/Tools.md +++ b/tools/Tools.md @@ -1,48 +1,5 @@ # Keyboarding Tools The actual keyboarding tools are completely seperate from the server and client code. -As far as features are concerned, they only need to write to stdout. +As far as features are concerned, they only need to write to a file (a fifo read by the client) -All tools have the same initial structure: -``` go ---- tool header -package main -import ( - "fmt" - "os" - "log" - "time" -) ---- ---- tool main -func main(){ - @{get auth token} - @{start tool} -} - ---- - ---- start tool - -time.Sleep(1 * time.Second) - -fmt.Println(authTokenInput) - -doTool() - - ---- - ---- get auth token --- noWeave - -@{get authTokenInput from environment} - -if !authTokenInputExists { - //fmt.Print("Enter authentication token: ") - _, err := fmt.Scanln(&authTokenInput) - if err != nil { - log.Fatal(err) - } -} - ----