Added IME and stdin tools
This commit is contained in:
parent
576e70a989
commit
5794ea43a3
@ -16,7 +16,7 @@ When GoSmartKeyboard is started in client mode, it does the following:
|
|||||||
if len(os.Args) > 1 && os.Args[1] == "connect" {
|
if len(os.Args) > 1 && os.Args[1] == "connect" {
|
||||||
@{get client fifo input file from environment}
|
@{get client fifo input file from environment}
|
||||||
@{setup client}
|
@{setup client}
|
||||||
if clientFifioInputFileExists {
|
if clientFifoInputFileExists {
|
||||||
@{start client with fifo}
|
@{start client with fifo}
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ authTokenFile, authTokenFileIsSet := os.LookupEnv("KEYBOARD_AUTH_TOKEN_FILE")
|
|||||||
|
|
||||||
--- get client fifo input file from environment
|
--- get client fifo input file from environment
|
||||||
|
|
||||||
clientFifoInputFile, clientFifioInputFileExists := os.LookupEnv("KEYBOARD_FIFO")
|
clientFifoInputFile, clientFifoInputFileExists := os.LookupEnv("KEYBOARD_FIFO")
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
2
Makefile
2
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
|
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
|
util/removefencedcode.py
|
||||||
tangle:
|
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:
|
clean:
|
||||||
rm -rf docs
|
rm -rf docs
|
||||||
find smartkeyboard/ -type f -not -name "*_test.go" -delete
|
find smartkeyboard/ -type f -not -name "*_test.go" -delete
|
||||||
|
@ -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 <text>")
|
|
||||||
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)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
---
|
|
||||||
```
|
|
@ -1,3 +1,39 @@
|
|||||||
# Input Method Editor
|
# Input Method Editor
|
||||||
|
|
||||||
This tool uses your $EDITOR to buffer keystrokes.
|
This tool uses your $EDITOR to buffer keystrokes.
|
||||||
|
|
||||||
|
``` go
|
||||||
|
--- /tools/editor/editor.go
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"io/ioutil"
|
||||||
|
"os"
|
||||||
|
)
|
||||||
|
// #include <stdlib.h>
|
||||||
|
//
|
||||||
|
// 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)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
---
|
||||||
|
```
|
@ -1,15 +0,0 @@
|
|||||||
# Hello World
|
|
||||||
|
|
||||||
Bare bones keyboard tool.
|
|
||||||
|
|
||||||
``` go
|
|
||||||
--- /tools/helloworld.go
|
|
||||||
@{tool header}
|
|
||||||
|
|
||||||
func doTool(){
|
|
||||||
fmt.Println("Hello World")
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@{tool main}
|
|
||||||
---
|
|
38
tools/Input.md
Normal file
38
tools/Input.md
Normal file
@ -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 = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
---
|
@ -1,48 +1,5 @@
|
|||||||
# Keyboarding Tools
|
# Keyboarding Tools
|
||||||
|
|
||||||
The actual keyboarding tools are completely seperate from the server and client code.
|
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)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
---
|
|
||||||
|
Loading…
Reference in New Issue
Block a user