@@ -261,8 +261,8 @@ var (
261261 }
262262 IPCPathFlag = DirectoryFlag {
263263 Name : "ipcpath" ,
264- Usage : "Filename for IPC socket/pipe" ,
265- Value : DirectoryString {common .DefaultIpcPath ()},
264+ Usage : "Filename for IPC socket/pipe within the datadir (explicit paths escape it) " ,
265+ Value : DirectoryString {common .DefaultIpcSocket ()},
266266 }
267267 WSEnabledFlag = cli.BoolFlag {
268268 Name : "ws" ,
@@ -394,6 +394,15 @@ func MustMakeDataDir(ctx *cli.Context) string {
394394 return ""
395395}
396396
397+ // MakeIpcPath creates an IPC path configuration from the set command line flags,
398+ // returning an empty string if IPC was explicitly disabled, or the set path.
399+ func MakeIpcPath (ctx * cli.Context ) string {
400+ if ctx .GlobalBool (IPCDisabledFlag .Name ) {
401+ return ""
402+ }
403+ return ctx .GlobalString (IPCPathFlag .Name )
404+ }
405+
397406// MakeNodeKey creates a node key from set command line flags, either loading it
398407// from a file or as a specified hex value. If neither flags were provided, this
399408// method returns nil and an emphemeral key is to be generated.
@@ -582,6 +591,7 @@ func MakeSystemNode(name, version string, extra []byte, ctx *cli.Context) *node.
582591 // Configure the node's service container
583592 stackConf := & node.Config {
584593 DataDir : MustMakeDataDir (ctx ),
594+ IpcPath : MakeIpcPath (ctx ),
585595 PrivateKey : MakeNodeKey (ctx ),
586596 Name : MakeNodeName (name , version , ctx ),
587597 NoDiscovery : ctx .GlobalBool (NoDiscoverFlag .Name ),
@@ -734,63 +744,6 @@ func MakeChain(ctx *cli.Context) (chain *core.BlockChain, chainDb ethdb.Database
734744 return chain , chainDb
735745}
736746
737- func IPCSocketPath (ctx * cli.Context ) (ipcpath string ) {
738- if runtime .GOOS == "windows" {
739- ipcpath = common .DefaultIpcPath ()
740- if ctx .GlobalIsSet (IPCPathFlag .Name ) {
741- ipcpath = ctx .GlobalString (IPCPathFlag .Name )
742- }
743- } else {
744- ipcpath = common .DefaultIpcPath ()
745- if ctx .GlobalIsSet (DataDirFlag .Name ) {
746- ipcpath = filepath .Join (ctx .GlobalString (DataDirFlag .Name ), "geth.ipc" )
747- }
748- if ctx .GlobalIsSet (IPCPathFlag .Name ) {
749- ipcpath = ctx .GlobalString (IPCPathFlag .Name )
750- }
751- }
752-
753- return
754- }
755-
756- func StartIPC (stack * node.Node , ctx * cli.Context ) error {
757- var ethereum * eth.Ethereum
758- if err := stack .Service (& ethereum ); err != nil {
759- return err
760- }
761-
762- endpoint := IPCSocketPath (ctx )
763- listener , err := rpc .CreateIPCListener (endpoint )
764- if err != nil {
765- return err
766- }
767-
768- server := rpc .NewServer ()
769-
770- // register package API's this node provides
771- offered := stack .APIs ()
772- for _ , api := range offered {
773- server .RegisterName (api .Namespace , api .Service )
774- glog .V (logger .Debug ).Infof ("Register %T under namespace '%s' for IPC service\n " , api .Service , api .Namespace )
775- }
776-
777- go func () {
778- glog .V (logger .Info ).Infof ("Start IPC server on %s\n " , endpoint )
779- for {
780- conn , err := listener .Accept ()
781- if err != nil {
782- glog .V (logger .Error ).Infof ("Unable to accept connection - %v\n " , err )
783- }
784-
785- codec := rpc .NewJSONCodec (conn )
786- go server .ServeCodec (codec )
787- }
788- }()
789-
790- return nil
791-
792- }
793-
794747// StartRPC starts a HTTP JSON-RPC API server.
795748func StartRPC (stack * node.Node , ctx * cli.Context ) error {
796749 for _ , api := range stack .APIs () {
0 commit comments