lnrpc/verrpc: add Versioner RPC server
This commit is contained in:
6 files changed
+443
No files matched your search
@@ -0,0 +1,75 @@
|
||||
package verrpc
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/lightningnetwork/lnd/build"
|
||||
"google.golang.org/grpc"
|
||||
"gopkg.in/macaroon-bakery.v2/bakery"
|
||||
)
|
||||
|
||||
const subServerName = "VersionRPC"
|
||||
|
||||
var macPermissions = map[string][]bakery.Op{
|
||||
"/verrpc.Versioner/GetVersion": {{
|
||||
Entity: "info",
|
||||
Action: "read",
|
||||
}},
|
||||
}
|
||||
|
||||
// Server is an rpc server that supports querying for information about the
|
||||
// running binary.
|
||||
type Server struct{}
|
||||
|
||||
// Start launches any helper goroutines required for the rpcServer to function.
|
||||
//
|
||||
// NOTE: This is part of the lnrpc.SubServer interface.
|
||||
func (s *Server) Start() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Stop signals any active goroutines for a graceful closure.
|
||||
//
|
||||
// NOTE: This is part of the lnrpc.SubServer interface.
|
||||
func (s *Server) Stop() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Name returns a unique string representation of the sub-server. This can be
|
||||
// used to identify the sub-server and also de-duplicate them.
|
||||
//
|
||||
// NOTE: This is part of the lnrpc.SubServer interface.
|
||||
func (s *Server) Name() string {
|
||||
return subServerName
|
||||
}
|
||||
|
||||
// RegisterWithRootServer will be called by the root gRPC server to direct a
|
||||
// sub RPC server to register itself with the main gRPC root server. Until this
|
||||
// is called, each sub-server won't be able to have requests routed towards it.
|
||||
//
|
||||
// NOTE: This is part of the lnrpc.SubServer interface.
|
||||
func (s *Server) RegisterWithRootServer(grpcServer *grpc.Server) error {
|
||||
RegisterVersionerServer(grpcServer, s)
|
||||
|
||||
log.Debugf("Versioner RPC server successfully registered with root " +
|
||||
"gRPC server")
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetVersion returns information about the compiled binary.
|
||||
func (s *Server) GetVersion(_ context.Context,
|
||||
_ *VersionRequest) (*Version, error) {
|
||||
|
||||
return &Version{
|
||||
Commit: build.Commit,
|
||||
CommitHash: build.CommitHash,
|
||||
Version: build.Version(),
|
||||
AppMajor: uint32(build.AppMajor),
|
||||
AppMinor: uint32(build.AppMinor),
|
||||
AppPatch: uint32(build.AppPatch),
|
||||
AppPreRelease: build.AppPreRelease,
|
||||
BuildTags: build.Tags(),
|
||||
GoVersion: build.GoVersion,
|
||||
}, nil
|
||||
}
|
||||
Reference in new issue
Block a user