aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBas van Kervel <basvankervel@ziggo.nl>2015-06-08 17:01:02 +0800
committerBas van Kervel <basvankervel@gmail.com>2015-06-11 20:01:39 +0800
commit2a0d888326036be9cabe6680617ce2d1a27761d3 (patch)
tree8458bcb21f07fbc5290712029f1f4f78ab54aa5a
parent8ebf2d8fad729a8261f237bb05b6073e6c1b652f (diff)
downloaddexon-2a0d888326036be9cabe6680617ce2d1a27761d3.tar
dexon-2a0d888326036be9cabe6680617ce2d1a27761d3.tar.gz
dexon-2a0d888326036be9cabe6680617ce2d1a27761d3.tar.bz2
dexon-2a0d888326036be9cabe6680617ce2d1a27761d3.tar.lz
dexon-2a0d888326036be9cabe6680617ce2d1a27761d3.tar.xz
dexon-2a0d888326036be9cabe6680617ce2d1a27761d3.tar.zst
dexon-2a0d888326036be9cabe6680617ce2d1a27761d3.zip
added API/IPC commandline flags
-rw-r--r--cmd/geth/main.go8
-rw-r--r--cmd/utils/flags.go33
-rw-r--r--common/path.go4
-rw-r--r--rpc/api/api.go5
4 files changed, 50 insertions, 0 deletions
diff --git a/cmd/geth/main.go b/cmd/geth/main.go
index 4d7d57220..d180c269f 100644
--- a/cmd/geth/main.go
+++ b/cmd/geth/main.go
@@ -239,6 +239,9 @@ JavaScript API. See https://github.com/ethereum/go-ethereum/wiki/Javascipt-Conso
utils.RPCEnabledFlag,
utils.RPCListenAddrFlag,
utils.RPCPortFlag,
+ utils.IPCDisabledFlag,
+ utils.IPCApiFlag,
+ utils.IPCPathFlag,
utils.WhisperEnabledFlag,
utils.VMDebugFlag,
utils.ProtocolVersionFlag,
@@ -382,6 +385,11 @@ func startEth(ctx *cli.Context, eth *eth.Ethereum) {
}
}
// Start auxiliary services if enabled.
+ if !ctx.GlobalBool(utils.IPCDisabledFlag.Name) {
+ if err := utils.StartIPC(eth, ctx); err != nil {
+ utils.Fatalf("Error string IPC: %v", err)
+ }
+ }
if ctx.GlobalBool(utils.RPCEnabledFlag.Name) {
if err := utils.StartRPC(eth, ctx); err != nil {
utils.Fatalf("Error starting RPC: %v", err)
diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go
index ab7eaf023..4c3690d49 100644
--- a/cmd/utils/flags.go
+++ b/cmd/utils/flags.go
@@ -24,6 +24,9 @@ import (
"github.com/ethereum/go-ethereum/p2p/nat"
"github.com/ethereum/go-ethereum/rpc"
"github.com/ethereum/go-ethereum/xeth"
+ "github.com/ethereum/go-ethereum/rpc/api"
+ "github.com/ethereum/go-ethereum/rpc/comms"
+ "github.com/ethereum/go-ethereum/rpc/codec"
)
func init() {
@@ -206,6 +209,20 @@ var (
Usage: "Domain on which to send Access-Control-Allow-Origin header",
Value: "",
}
+ IPCDisabledFlag = cli.BoolFlag{
+ Name: "ipcdisable",
+ Usage: "Disable the IPC-RPC server",
+ }
+ IPCApiFlag = cli.StringFlag{
+ Name: "ipcapi",
+ Usage: "Specify the API's which are offered over this interface",
+ Value: api.DefaultIpcApis,
+ }
+ IPCPathFlag = DirectoryFlag{
+ Name: "ipcpath",
+ Usage: "Filename for IPC socket/pipe",
+ Value: DirectoryString{common.DefaultIpcPath()},
+ }
// Network Settings
MaxPeersFlag = cli.IntFlag{
Name: "maxpeers",
@@ -368,6 +385,22 @@ func MakeAccountManager(ctx *cli.Context) *accounts.Manager {
return accounts.NewManager(ks)
}
+func StartIPC(eth *eth.Ethereum, ctx *cli.Context) error {
+ config := comms.IpcConfig{
+ Endpoint: ctx.GlobalString(IPCPathFlag.Name),
+ }
+
+ xeth := xeth.New(eth, nil)
+ codec := codec.JSON
+
+ apis, err := api.ParseApiString(ctx.GlobalString(IPCApiFlag.Name), codec, xeth, eth)
+ if err != nil {
+ return err
+ }
+
+ return comms.StartIpc(config, codec, apis...)
+}
+
func StartRPC(eth *eth.Ethereum, ctx *cli.Context) error {
config := rpc.RpcConfig{
ListenAddress: ctx.GlobalString(RPCListenAddrFlag.Name),
diff --git a/common/path.go b/common/path.go
index 3468b3366..63a23abcd 100644
--- a/common/path.go
+++ b/common/path.go
@@ -94,6 +94,10 @@ func DefaultDataDir() string {
}
}
+func DefaultIpcPath() string {
+ return filepath.Join(DefaultDataDir(), "geth.ipc")
+}
+
func IsWindows() bool {
return runtime.GOOS == "windows"
}
diff --git a/rpc/api/api.go b/rpc/api/api.go
index 758e056ed..93dc3058c 100644
--- a/rpc/api/api.go
+++ b/rpc/api/api.go
@@ -2,6 +2,11 @@ package api
import "github.com/ethereum/go-ethereum/rpc/shared"
+const (
+ // List with all API's which are offered over the IPC interface by default
+ DefaultIpcApis = "eth"
+)
+
// Ethereum RPC API interface
type EthereumApi interface {
// Execute the given request and returns the response or an error