Explorar o código

fixed windows ipc path issue

Bas van Kervel %!s(int64=10) %!d(string=hai) anos
pai
achega
359e6414e5
Modificáronse 4 ficheiros con 27 adicións e 4 borrados
  1. 1 1
      cmd/console/main.go
  2. 2 2
      cmd/geth/main.go
  3. 21 1
      cmd/utils/flags.go
  4. 3 0
      common/path.go

+ 1 - 1
cmd/console/main.go

@@ -93,7 +93,7 @@ func main() {
 
 func run(ctx *cli.Context) {
 	jspath := ctx.GlobalString(utils.JSpathFlag.Name)
-	ipcpath := ctx.GlobalString(utils.IPCPathFlag.Name)
+	ipcpath := utils.IpcSocketPath(ctx)
 
 	repl := newJSRE(jspath, ipcpath)
 	repl.welcome(ipcpath)

+ 2 - 2
cmd/geth/main.go

@@ -308,7 +308,7 @@ func console(ctx *cli.Context) {
 		ethereum,
 		ctx.String(utils.JSpathFlag.Name),
 		ctx.GlobalString(utils.RPCCORSDomainFlag.Name),
-		filepath.Join(ctx.GlobalString(utils.DataDirFlag.Name), "geth.ipc"),
+		utils.IpcSocketPath(ctx),
 		true,
 		nil,
 	)
@@ -330,7 +330,7 @@ func execJSFiles(ctx *cli.Context) {
 		ethereum,
 		ctx.String(utils.JSpathFlag.Name),
 		ctx.GlobalString(utils.RPCCORSDomainFlag.Name),
-		ctx.GlobalString(utils.IPCPathFlag.Name),
+		utils.IpcSocketPath(ctx),
 		false,
 		nil,
 	)

+ 21 - 1
cmd/utils/flags.go

@@ -385,9 +385,29 @@ func MakeAccountManager(ctx *cli.Context) *accounts.Manager {
 	return accounts.NewManager(ks)
 }
 
+func IpcSocketPath(ctx *cli.Context) (ipcpath string) {
+
+	if common.IsWindows() {
+		ipcpath = common.DefaultIpcPath()
+		if ipcpath != ctx.GlobalString(IPCPathFlag.Name) {
+			ipcpath = ctx.GlobalString(IPCPathFlag.Name)
+		}
+	} else {
+		ipcpath = common.DefaultIpcPath()
+		if ctx.GlobalString(IPCPathFlag.Name) != common.DefaultIpcPath() {
+			ipcpath = ctx.GlobalString(IPCPathFlag.Name)
+		} else if ctx.GlobalString(DataDirFlag.Name) != "" &&
+		ctx.GlobalString(DataDirFlag.Name) != common.DefaultDataDir() {
+			ipcpath = filepath.Join(ctx.GlobalString(DataDirFlag.Name), "geth.ipc")
+		}
+	}
+
+	return
+}
+
 func StartIPC(eth *eth.Ethereum, ctx *cli.Context) error {
 	config := comms.IpcConfig{
-		Endpoint: filepath.Join(ctx.GlobalString(DataDirFlag.Name), "geth.ipc"),
+		Endpoint: IpcSocketPath(ctx),
 	}
 
 	xeth := xeth.New(eth, nil)

+ 3 - 0
common/path.go

@@ -95,6 +95,9 @@ func DefaultDataDir() string {
 }
 
 func DefaultIpcPath() string {
+	if runtime.GOOS == "windows" {
+		return `\\.\pipe\geth.ipc`
+	}
 	return filepath.Join(DefaultDataDir(), "geth.ipc")
 }