jail
This commit is contained in:
parent
a0cd61464c
commit
df47de9aea
10
build/env.sh
10
build/env.sh
|
@ -10,11 +10,11 @@ fi
|
|||
# Create fake Go workspace if it doesn't exist yet.
|
||||
workspace="$PWD/build/_workspace"
|
||||
root="$PWD"
|
||||
ethdir="$workspace/src/github.com/ethereum"
|
||||
if [ ! -L "$ethdir/go-ethereum" ]; then
|
||||
ethdir="$workspace/src/github.com/status-im"
|
||||
if [ ! -L "$ethdir/status-go" ]; then
|
||||
mkdir -p "$ethdir"
|
||||
cd "$ethdir"
|
||||
ln -s ../../../../../. go-ethereum
|
||||
ln -s ../../../../../. status-go
|
||||
cd "$root"
|
||||
fi
|
||||
|
||||
|
@ -25,8 +25,8 @@ GOBIN="$PWD/build/bin"
|
|||
export GOPATH GOBIN
|
||||
|
||||
# Run the command inside the workspace.
|
||||
cd "$ethdir/go-ethereum"
|
||||
PWD="$ethdir/go-ethereum"
|
||||
cd "$ethdir/status-go"
|
||||
PWD="$ethdir/status-go"
|
||||
|
||||
# Launch the arguments with the configured environment.
|
||||
exec "$@"
|
|
@ -0,0 +1,35 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"github.com/robertkrimen/otto"
|
||||
)
|
||||
|
||||
var statusJs string
|
||||
var vms = make(map[string]*otto.Otto)
|
||||
|
||||
func Init(js string) {
|
||||
statusJs = js
|
||||
}
|
||||
|
||||
func Parse(chatId string, js string) string {
|
||||
vm := otto.New()
|
||||
jjs := statusJs + js + `
|
||||
var catalog = JSON.stringify(_status_catalog);
|
||||
`
|
||||
vms[chatId] = vm
|
||||
vm.Run(jjs)
|
||||
res, _ := vm.Get("catalog")
|
||||
|
||||
return res.String()
|
||||
}
|
||||
|
||||
func Call(chatId string, path string, args string) string {
|
||||
vm, ok := vms[chatId]
|
||||
if !ok {
|
||||
return ""
|
||||
}
|
||||
|
||||
res, _ := vm.Call("call", nil, path, args)
|
||||
|
||||
return res.String()
|
||||
}
|
|
@ -39,3 +39,20 @@ func doStartNode(datadir *C.char) C.int {
|
|||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
//export parse
|
||||
func parse(chatId *C.char, js *C.char) *C.char {
|
||||
res := Parse(C.GoString(chatId), C.GoString(js))
|
||||
return C.CString(res)
|
||||
}
|
||||
|
||||
//export call
|
||||
func call(chatId *C.char, path *C.char, params *C.char) *C.char {
|
||||
res := Call(C.GoString(chatId), C.GoString(path), C.GoString(params))
|
||||
return C.CString(res)
|
||||
}
|
||||
|
||||
//export initJail
|
||||
func initJail(js *C.char) {
|
||||
Init(C.GoString(js))
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue