aboutsummaryrefslogtreecommitdiffstats
path: root/cmd/geth
diff options
context:
space:
mode:
authorzelig <viktor.tron@gmail.com>2015-04-22 21:55:01 +0800
committerzelig <viktor.tron@gmail.com>2015-04-24 19:45:11 +0800
commit6b1b5a4a2a8b315f4d0e7a08ab10563653711a92 (patch)
tree697ed17f77ce843ce0086e9532a2ee2d992a906d /cmd/geth
parent1b7c017076ae578a89a18b5c7ffc61e9c8d59eee (diff)
downloaddexon-6b1b5a4a2a8b315f4d0e7a08ab10563653711a92.tar
dexon-6b1b5a4a2a8b315f4d0e7a08ab10563653711a92.tar.gz
dexon-6b1b5a4a2a8b315f4d0e7a08ab10563653711a92.tar.bz2
dexon-6b1b5a4a2a8b315f4d0e7a08ab10563653711a92.tar.lz
dexon-6b1b5a4a2a8b315f4d0e7a08ab10563653711a92.tar.xz
dexon-6b1b5a4a2a8b315f4d0e7a08ab10563653711a92.tar.zst
dexon-6b1b5a4a2a8b315f4d0e7a08ab10563653711a92.zip
cli/js console: if corsDomain is not given to startRpc, we fall back to value set on command line with `-corsDomain`
Diffstat (limited to 'cmd/geth')
-rw-r--r--cmd/geth/admin.go3
-rw-r--r--cmd/geth/js.go16
-rw-r--r--cmd/geth/js_test.go2
-rw-r--r--cmd/geth/main.go4
4 files changed, 14 insertions, 11 deletions
diff --git a/cmd/geth/admin.go b/cmd/geth/admin.go
index 646b45bf9..31f8d4400 100644
--- a/cmd/geth/admin.go
+++ b/cmd/geth/admin.go
@@ -203,13 +203,14 @@ func (js *jsre) startRPC(call otto.FunctionCall) otto.Value {
fmt.Println(err)
return otto.FalseValue()
}
+
port, err := call.Argument(1).ToInteger()
if err != nil {
fmt.Println(err)
return otto.FalseValue()
}
- var corsDomain string
+ corsDomain := js.corsDomain
if len(call.ArgumentList) > 2 {
corsDomain, err = call.Argument(2).ToString()
if err != nil {
diff --git a/cmd/geth/js.go b/cmd/geth/js.go
index abbd65513..a545de1d0 100644
--- a/cmd/geth/js.go
+++ b/cmd/geth/js.go
@@ -59,17 +59,19 @@ func (r dumbterm) PasswordPrompt(p string) (string, error) {
func (r dumbterm) AppendHistory(string) {}
type jsre struct {
- re *re.JSRE
- ethereum *eth.Ethereum
- xeth *xeth.XEth
- ps1 string
- atexit func()
-
+ re *re.JSRE
+ ethereum *eth.Ethereum
+ xeth *xeth.XEth
+ ps1 string
+ atexit func()
+ corsDomain string
prompter
}
-func newJSRE(ethereum *eth.Ethereum, libPath string, interactive bool) *jsre {
+func newJSRE(ethereum *eth.Ethereum, libPath string, interactive bool, corsDomain string) *jsre {
js := &jsre{ethereum: ethereum, ps1: "> "}
+ // set default cors domain used by startRpc from CLI flag
+ js.corsDomain = corsDomain
js.xeth = xeth.New(ethereum, js)
js.re = re.New(libPath)
js.apiBindings()
diff --git a/cmd/geth/js_test.go b/cmd/geth/js_test.go
index 662e195e5..50528b80a 100644
--- a/cmd/geth/js_test.go
+++ b/cmd/geth/js_test.go
@@ -36,7 +36,7 @@ func testJEthRE(t *testing.T) (*jsre, *eth.Ethereum) {
t.Fatal("%v", err)
}
assetPath := path.Join(os.Getenv("GOPATH"), "src", "github.com", "ethereum", "go-ethereum", "cmd", "mist", "assets", "ext")
- repl := newJSRE(ethereum, assetPath, false)
+ repl := newJSRE(ethereum, assetPath, false, "")
return repl, ethereum
}
diff --git a/cmd/geth/main.go b/cmd/geth/main.go
index 70be2ed2e..dd87632b6 100644
--- a/cmd/geth/main.go
+++ b/cmd/geth/main.go
@@ -296,7 +296,7 @@ func console(ctx *cli.Context) {
}
startEth(ctx, ethereum)
- repl := newJSRE(ethereum, ctx.String(utils.JSpathFlag.Name), true)
+ repl := newJSRE(ethereum, ctx.String(utils.JSpathFlag.Name), true, ctx.GlobalString(utils.RPCCORSDomainFlag.Name))
repl.interactive()
ethereum.Stop()
@@ -311,7 +311,7 @@ func execJSFiles(ctx *cli.Context) {
}
startEth(ctx, ethereum)
- repl := newJSRE(ethereum, ctx.String(utils.JSpathFlag.Name), false)
+ repl := newJSRE(ethereum, ctx.String(utils.JSpathFlag.Name), false, ctx.GlobalString(utils.RPCCORSDomainFlag.Name))
for _, file := range ctx.Args() {
repl.exec(file)
}