@@ -261,7 +261,7 @@ func (n *Node) startRPC(services map[reflect.Type]Service) error {
261261 n .stopInProc ()
262262 return err
263263 }
264- if err := n .startWS (n .wsEndpoint , apis , n .config .WSModules , n .config .WSOrigins ); err != nil {
264+ if err := n .startWS (n .wsEndpoint , apis , n .config .WSModules , n .config .WSOrigins , n . config . WSExposeAll ); err != nil {
265265 n .stopHTTP ()
266266 n .stopIPC ()
267267 n .stopInProc ()
@@ -412,7 +412,7 @@ func (n *Node) stopHTTP() {
412412}
413413
414414// startWS initializes and starts the websocket RPC endpoint.
415- func (n * Node ) startWS (endpoint string , apis []rpc.API , modules []string , wsOrigins []string ) error {
415+ func (n * Node ) startWS (endpoint string , apis []rpc.API , modules []string , wsOrigins []string , exposeAll bool ) error {
416416 // Short circuit if the WS endpoint isn't being exposed
417417 if endpoint == "" {
418418 return nil
@@ -425,7 +425,7 @@ func (n *Node) startWS(endpoint string, apis []rpc.API, modules []string, wsOrig
425425 // Register all the APIs exposed by the services
426426 handler := rpc .NewServer ()
427427 for _ , api := range apis {
428- if whitelist [api .Namespace ] || (len (whitelist ) == 0 && api .Public ) {
428+ if exposeAll || whitelist [api .Namespace ] || (len (whitelist ) == 0 && api .Public ) {
429429 if err := handler .RegisterName (api .Namespace , api .Service ); err != nil {
430430 return err
431431 }
@@ -441,7 +441,7 @@ func (n *Node) startWS(endpoint string, apis []rpc.API, modules []string, wsOrig
441441 return err
442442 }
443443 go rpc .NewWSServer (wsOrigins , handler ).Serve (listener )
444- log .Info (fmt .Sprintf ("WebSocket endpoint opened: ws://%s" , endpoint ))
444+ log .Info (fmt .Sprintf ("WebSocket endpoint opened: ws://%s" , listener . Addr () ))
445445
446446 // All listeners booted successfully
447447 n .wsEndpoint = endpoint
@@ -556,6 +556,17 @@ func (n *Node) Attach() (*rpc.Client, error) {
556556 return rpc .DialInProc (n .inprocHandler ), nil
557557}
558558
559+ // RPCHandler returns the in-process RPC request handler.
560+ func (n * Node ) RPCHandler () (* rpc.Server , error ) {
561+ n .lock .RLock ()
562+ defer n .lock .RUnlock ()
563+
564+ if n .inprocHandler == nil {
565+ return nil , ErrNodeStopped
566+ }
567+ return n .inprocHandler , nil
568+ }
569+
559570// Server retrieves the currently running P2P network layer. This method is meant
560571// only to inspect fields of the currently running server, life cycle management
561572// should be left to this Node entity.
0 commit comments