rpcperms: allow requests to be replaced as well

With this commit we allow a replacement message to be sent by the
middleware for a request type as well as the response type. This allows
an incoming RPC request to be modified before it is forwarded to lnd.
This commit is contained in:
Oliver Gugger
2022-07-06 21:16:57 +02:00
parent dc32ca61f8
commit 86c64abfe6
2 changed files with 30 additions and 32 deletions

View File

@ -263,11 +263,9 @@ func (h *MiddlewareHandler) sendInterceptRequests(errChan chan error,
break
}
// For intercepted responses we also allow the
// For intercepted messages we also allow the
// content itself to be overwritten.
if requestInfo.request.Type == TypeResponse &&
t.ReplaceResponse {
if t.ReplaceResponse {
response.replace = true
protoMsg, err := parseProto(
requestInfo.request.ProtoTypeName,
@ -322,7 +320,8 @@ const (
// TypeRequest is the type of intercept message that is sent when an RPC
// request message is sent to lnd. For client-streaming RPCs a new
// message of this type is sent for each individual RPC request sent to
// the stream.
// the stream. Middleware has the option to modify a request message
// before it is delivered to lnd.
TypeRequest InterceptType = 2
// TypeResponse is the type of intercept message that is sent when an