litrpc+rpcserver: add firewall service comments and cli directives

This commit is contained in:
Elle Mouton 2023-03-19 17:41:04 +02:00
parent 0164175f3b
commit e0747b5354
No known key found for this signature in database
GPG key ID: D7D916376026F177
3 changed files with 57 additions and 1 deletions

View file

@ -5,7 +5,24 @@ package litrpc;
option go_package = "github.com/lightninglabs/lightning-terminal/litrpc";
service Firewall {
/* litcli: `actions`
ListActions will return a list of actions that have been performed on the
node. The actions that will be persisted depends on the value of the
`--firewall.request-logger.level` config option. The default value of the
option is the "interceptor" mode which will persist only the actions (with
all request parameters) made with macaroons with caveats that force them
to be checked by an rpc middleware interceptor. If the "all" mode is used
then all actions will be persisted but only full request parameters will
only be stored if the actions are interceptor actions, otherwise only the
URI and timestamp of the actions will be stored. The "full" mode will
persist all request data for all actions.
*/
rpc ListActions (ListActionsRequest) returns (ListActionsResponse);
/* litcli: `privacy`
PrivacyMapConversion can be used map real values to their pseudo
counterpart and vice versa.
*/
rpc PrivacyMapConversion (PrivacyMapConversionRequest)
returns (PrivacyMapConversionResponse);
}

View file

@ -18,7 +18,21 @@ const _ = grpc.SupportPackageIsVersion7
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
type FirewallClient interface {
// litcli: `actions`
// ListActions will return a list of actions that have been performed on the
// node. The actions that will be persisted depends on the value of the
// `--firewall.request-logger.level` config option. The default value of the
// option is the "interceptor" mode which will persist only the actions (with
// all request parameters) made with macaroons with caveats that force them
// to be checked by an rpc middleware interceptor. If the "all" mode is used
// then all actions will be persisted but only full request parameters will
// only be stored if the actions are interceptor actions, otherwise only the
// URI and timestamp of the actions will be stored. The "full" mode will
// persist all request data for all actions.
ListActions(ctx context.Context, in *ListActionsRequest, opts ...grpc.CallOption) (*ListActionsResponse, error)
// litcli: `privacy`
// PrivacyMapConversion can be used map real values to their pseudo
// counterpart and vice versa.
PrivacyMapConversion(ctx context.Context, in *PrivacyMapConversionRequest, opts ...grpc.CallOption) (*PrivacyMapConversionResponse, error)
}
@ -52,7 +66,21 @@ func (c *firewallClient) PrivacyMapConversion(ctx context.Context, in *PrivacyMa
// All implementations must embed UnimplementedFirewallServer
// for forward compatibility
type FirewallServer interface {
// litcli: `actions`
// ListActions will return a list of actions that have been performed on the
// node. The actions that will be persisted depends on the value of the
// `--firewall.request-logger.level` config option. The default value of the
// option is the "interceptor" mode which will persist only the actions (with
// all request parameters) made with macaroons with caveats that force them
// to be checked by an rpc middleware interceptor. If the "all" mode is used
// then all actions will be persisted but only full request parameters will
// only be stored if the actions are interceptor actions, otherwise only the
// URI and timestamp of the actions will be stored. The "full" mode will
// persist all request data for all actions.
ListActions(context.Context, *ListActionsRequest) (*ListActionsResponse, error)
// litcli: `privacy`
// PrivacyMapConversion can be used map real values to their pseudo
// counterpart and vice versa.
PrivacyMapConversion(context.Context, *PrivacyMapConversionRequest) (*PrivacyMapConversionResponse, error)
mustEmbedUnimplementedFirewallServer()
}

View file

@ -581,6 +581,8 @@ func (s *sessionRpcServer) RevokeSession(ctx context.Context,
return &litrpc.RevokeSessionResponse{}, nil
}
// PrivacyMapConversion can be used map real values to their pseudo counterpart
// and vice versa.
func (s *sessionRpcServer) PrivacyMapConversion(_ context.Context,
req *litrpc.PrivacyMapConversionRequest) (
*litrpc.PrivacyMapConversionResponse, error) {
@ -611,7 +613,16 @@ func (s *sessionRpcServer) PrivacyMapConversion(_ context.Context,
}, nil
}
// ListActions lists all actions attempted on the Litd server.
// ListActions will return a list of actions that have been performed on the
// node. The actions that will be persisted depends on the value of the
// `--firewall.request-logger.level` config option. The default value of the
// option is the "interceptor" mode which will persist only the actions (with
// all request parameters) made with macaroons with caveats that force them to
// be checked by an rpc middleware interceptor. If the "all" mode is used then
// all actions will be persisted but only full request parameters will only be
// stored if the actions are interceptor actions, otherwise only the URI and
// timestamp of the actions will be stored. The "full" mode will persist all
// request data for all actions.
func (s *sessionRpcServer) ListActions(_ context.Context,
req *litrpc.ListActionsRequest) (*litrpc.ListActionsResponse, error) {