aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzelig <viktor.tron@gmail.com>2015-04-22 01:08:47 +0800
committerzelig <viktor.tron@gmail.com>2015-04-24 19:45:11 +0800
commit22450c069b181e362710b71a763549cc6bc3e29b (patch)
tree7359f743adcc1408013441853bf924994bf7a961
parenta3fb41981e49fd90d8c76b371782831f243a919e (diff)
downloadgo-tangerine-22450c069b181e362710b71a763549cc6bc3e29b.tar
go-tangerine-22450c069b181e362710b71a763549cc6bc3e29b.tar.gz
go-tangerine-22450c069b181e362710b71a763549cc6bc3e29b.tar.bz2
go-tangerine-22450c069b181e362710b71a763549cc6bc3e29b.tar.lz
go-tangerine-22450c069b181e362710b71a763549cc6bc3e29b.tar.xz
go-tangerine-22450c069b181e362710b71a763549cc6bc3e29b.tar.zst
go-tangerine-22450c069b181e362710b71a763549cc6bc3e29b.zip
js console: add cors domain optional argument to startRpc
-rw-r--r--cmd/geth/admin.go11
-rw-r--r--cmd/geth/js_test.go14
2 files changed, 17 insertions, 8 deletions
diff --git a/cmd/geth/admin.go b/cmd/geth/admin.go
index c23fe9b43..b9a455a0d 100644
--- a/cmd/geth/admin.go
+++ b/cmd/geth/admin.go
@@ -209,10 +209,19 @@ func (js *jsre) startRPC(call otto.FunctionCall) otto.Value {
return otto.FalseValue()
}
+ var corsDomain string
+ if len(call.ArgumentList) > 2 {
+ corsDomain, err = call.Argument(2).ToString()
+ if err != nil {
+ fmt.Println(err)
+ return otto.FalseValue()
+ }
+ }
+
config := rpc.RpcConfig{
ListenAddress: addr,
ListenPort: uint(port),
- // CorsDomain: ctx.GlobalString(RPCCORSDomainFlag.Name),
+ CorsDomain: corsDomain,
}
xeth := xeth.New(js.ethereum, nil)
diff --git a/cmd/geth/js_test.go b/cmd/geth/js_test.go
index 521039121..662e195e5 100644
--- a/cmd/geth/js_test.go
+++ b/cmd/geth/js_test.go
@@ -3,16 +3,16 @@ package main
import (
"fmt"
"io/ioutil"
- "path/filepath"
"os"
"path"
+ "path/filepath"
"testing"
"github.com/ethereum/go-ethereum/accounts"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/eth"
- "runtime"
"regexp"
+ "runtime"
"strconv"
)
@@ -70,8 +70,8 @@ func TestAccounts(t *testing.T) {
t.Errorf("address not hex: %q", addr)
}
- checkEvalJSON(t, repl, `eth.accounts`, `["` + addr + `"]`)
- checkEvalJSON(t, repl, `eth.coinbase`, `"` + addr + `"`)
+ checkEvalJSON(t, repl, `eth.accounts`, `["`+addr+`"]`)
+ checkEvalJSON(t, repl, `eth.coinbase`, `"`+addr+`"`)
}
func TestBlockChain(t *testing.T) {
@@ -97,13 +97,13 @@ func TestBlockChain(t *testing.T) {
tmpfile := filepath.Join(tmp, "export.chain")
tmpfileq := strconv.Quote(tmpfile)
- checkEvalJSON(t, repl, `admin.export(` + tmpfileq + `)`, `true`)
+ checkEvalJSON(t, repl, `admin.export(`+tmpfileq+`)`, `true`)
if _, err := os.Stat(tmpfile); err != nil {
t.Fatal(err)
}
// check import, verify that dumpBlock gives the same result.
- checkEvalJSON(t, repl, `admin.import(` + tmpfileq + `)`, `true`)
+ checkEvalJSON(t, repl, `admin.import(`+tmpfileq+`)`, `true`)
checkEvalJSON(t, repl, `admin.debug.dumpBlock()`, beforeExport)
}
@@ -129,7 +129,7 @@ func TestRPC(t *testing.T) {
}
func checkEvalJSON(t *testing.T, re *jsre, expr, want string) error {
- val, err := re.re.Run("JSON.stringify("+ expr + ")")
+ val, err := re.re.Run("JSON.stringify(" + expr + ")")
if err == nil && val.String() != want {
err = fmt.Errorf("Output mismatch for `%s`:\ngot: %s\nwant: %s", expr, val.String(), want)
}