@@ -261,7 +261,7 @@ func (n *Node) startRPC(services map[reflect.Type]Service) error {
261
261
n .stopInProc ()
262
262
return err
263
263
}
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 {
265
265
n .stopHTTP ()
266
266
n .stopIPC ()
267
267
n .stopInProc ()
@@ -412,7 +412,7 @@ func (n *Node) stopHTTP() {
412
412
}
413
413
414
414
// 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 {
416
416
// Short circuit if the WS endpoint isn't being exposed
417
417
if endpoint == "" {
418
418
return nil
@@ -425,7 +425,7 @@ func (n *Node) startWS(endpoint string, apis []rpc.API, modules []string, wsOrig
425
425
// Register all the APIs exposed by the services
426
426
handler := rpc .NewServer ()
427
427
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 ) {
429
429
if err := handler .RegisterName (api .Namespace , api .Service ); err != nil {
430
430
return err
431
431
}
@@ -441,7 +441,7 @@ func (n *Node) startWS(endpoint string, apis []rpc.API, modules []string, wsOrig
441
441
return err
442
442
}
443
443
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 () ))
445
445
446
446
// All listeners booted successfully
447
447
n .wsEndpoint = endpoint
@@ -556,6 +556,17 @@ func (n *Node) Attach() (*rpc.Client, error) {
556
556
return rpc .DialInProc (n .inprocHandler ), nil
557
557
}
558
558
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
+
559
570
// Server retrieves the currently running P2P network layer. This method is meant
560
571
// only to inspect fields of the currently running server, life cycle management
561
572
// should be left to this Node entity.
0 commit comments