Skip to content

Commit 903a96f

Browse files
node: disable personal on ipc as well
1 parent 3e294fc commit 903a96f

File tree

3 files changed

+18
-14
lines changed

3 files changed

+18
-14
lines changed

cmd/geth/consolecmd.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ func localConsole(ctx *cli.Context) error {
7777
// Attach to the newly started node and create the JavaScript console.
7878
client, err := stack.Attach()
7979
if err != nil {
80-
return fmt.Errorf("Failed to attach to the inproc geth: %v", err)
80+
return fmt.Errorf("failed to attach to the inproc geth: %v", err)
8181
}
8282
config := console.Config{
8383
DataDir: utils.MakeDataDir(ctx),
@@ -87,7 +87,7 @@ func localConsole(ctx *cli.Context) error {
8787
}
8888
console, err := console.New(config)
8989
if err != nil {
90-
return fmt.Errorf("Failed to start the JavaScript console: %v", err)
90+
return fmt.Errorf("failed to start the JavaScript console: %v", err)
9191
}
9292
defer console.Stop(false)
9393

cmd/geth/consolecmd_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import (
3030
)
3131

3232
const (
33-
ipcAPIs = "admin:1.0 debug:1.0 engine:1.0 eth:1.0 ethash:1.0 miner:1.0 net:1.0 personal:1.0 rpc:1.0 txpool:1.0 web3:1.0"
33+
ipcAPIs = "admin:1.0 debug:1.0 engine:1.0 eth:1.0 ethash:1.0 miner:1.0 net:1.0 rpc:1.0 txpool:1.0 web3:1.0"
3434
httpAPIs = "eth:1.0 net:1.0 rpc:1.0 web3:1.0"
3535
)
3636

node/node.go

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -376,13 +376,24 @@ func (n *Node) obtainJWTSecret(cliParam string) ([]byte, error) {
376376
// startup. It's not meant to be called at any time afterwards as it makes certain
377377
// assumptions about the state of the node.
378378
func (n *Node) startRPC() error {
379-
if err := n.startInProc(); err != nil {
379+
// Filter out personal api
380+
apis := n.rpcAPIs
381+
for i, api := range apis {
382+
if api.Namespace == "personal" {
383+
if !n.config.EnablePersonal {
384+
apis = append(apis[:i], apis[i+1:]...)
385+
} else {
386+
log.Error("Deprecated personal namespace activated")
387+
}
388+
}
389+
}
390+
if err := n.startInProc(apis); err != nil {
380391
return err
381392
}
382393

383394
// Configure IPC.
384395
if n.ipc.endpoint != "" {
385-
if err := n.ipc.start(n.rpcAPIs); err != nil {
396+
if err := n.ipc.start(apis); err != nil {
386397
return err
387398
}
388399
}
@@ -510,15 +521,8 @@ func (n *Node) stopRPC() {
510521
}
511522

512523
// startInProc registers all RPC APIs on the inproc server.
513-
func (n *Node) startInProc() error {
514-
for _, api := range n.rpcAPIs {
515-
if api.Namespace == "personal" {
516-
if !n.config.EnablePersonal {
517-
continue
518-
} else {
519-
log.Error("Deprecated personal namespace activated")
520-
}
521-
}
524+
func (n *Node) startInProc(apis []rpc.API) error {
525+
for _, api := range apis {
522526
if err := n.inprocHandler.RegisterName(api.Namespace, api.Service); err != nil {
523527
return err
524528
}

0 commit comments

Comments
 (0)