@@ -100,22 +100,25 @@ func newRpcProxy(cfg *Config, validator macaroons.MacaroonValidator,
100100// +---+----------------------+
101101// |
102102// v native gRPC call with macaroon
103- // +---+----------------------+ registered call
104- // | gRPC server +--------------+
105- // +---+----------------------+ |
106- // | |
107- // v non-registered call |
108- // +---+----------------------+ +---------v----------+
109- // | director | | local subserver |
110- // +---+----------------------+ | - faraday |
111- // | | - loop |
112- // v authenticated call | - pool |
113- // +---+----------------------+ +--------------------+
114- // | lnd (remote or local) |
115- // | faraday remote |
116- // | loop remote |
117- // | pool remote |
118- // +--------------------------+
103+ // +---+----------------------+
104+ // | gRPC server |
105+ // +---+----------------------+
106+ // |
107+ // v unknown authenticated call, gRPC server is just a wrapper
108+ // +---+----------------------+
109+ // | director |
110+ // +---+----------------------+
111+ // |
112+ // v authenticated call
113+ // +---+----------------------+ call to lnd or integrated daemon
114+ // | lnd (remote or local) +---------------+
115+ // | faraday remote | |
116+ // | loop remote | +----------v----------+
117+ // | pool remote | | lnd local subserver |
118+ // +--------------------------+ | - faraday |
119+ // | - loop |
120+ // | - pool |
121+ // +---------------------+
119122//
120123type rpcProxy struct {
121124 cfg * Config
@@ -263,16 +266,13 @@ func (p *rpcProxy) director(ctx context.Context,
263266
264267 outCtx := metadata .NewOutgoingContext (ctx , mdCopy )
265268
266- // Direct the call to the correct backend. For lnd we _always_ have a
267- // client connection, no matter if it's running in integrated or remote
268- // mode. For all other daemons the request shouldn't get here in
269- // integrated mode (after all, the director only picks up calls that the
270- // gRPC server itself would throw a 404 for) so we throw an error
271- // message for them if they're not in remote mode .
269+ // Direct the call to the correct backend. All gRPC calls end up here
270+ // since our gRPC server instance doesn't have any handlers registered
271+ // itself. So all daemon calls that are remote are forwarded to them
272+ // directly. Everything else will go to lnd since it must either be an
273+ // lnd call or something that'll be handled by the integrated daemons
274+ // that are hooking into lnd's gRPC server .
272275 switch {
273- case isLndURI (requestURI ):
274- return outCtx , p .lndConn , nil
275-
276276 case isFaradayURI (requestURI ) && p .cfg .faradayRemote :
277277 return outCtx , p .faradayConn , nil
278278
@@ -283,8 +283,7 @@ func (p *rpcProxy) director(ctx context.Context,
283283 return outCtx , p .poolConn , nil
284284
285285 default :
286- return ctx , nil , fmt .Errorf ("unknown gRPC web request: %v" ,
287- requestURI )
286+ return outCtx , p .lndConn , nil
288287 }
289288}
290289
0 commit comments