[#414] ir: Serve ControlService

Serve `ControlService` instance on configured endpoint (do not serve if not
specified). Read allowed keys from config.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2021-06-09 18:49:10 +03:00 committed by Alex Vanin
parent 4001ba2967
commit 455fd952dd
5 changed files with 73 additions and 10 deletions

View file

@ -2,8 +2,6 @@ package control
import (
"fmt"
crypto "github.com/nspcc-dev/neofs-crypto"
)
// Server is an entity that serves
@ -34,8 +32,6 @@ func panicOnPrmValue(n string, v interface{}) {
func New(prm Prm, opts ...Option) *Server {
// verify required parameters
switch {
case prm.key == nil:
panicOnPrmValue("key", prm.key)
case prm.healthChecker == nil:
panicOnPrmValue("health checker", prm.healthChecker)
}
@ -50,6 +46,6 @@ func New(prm Prm, opts ...Option) *Server {
return &Server{
prm: prm,
allowedKeys: append(o.allowedKeys, crypto.MarshalPublicKey(&prm.key.PublicKey)),
allowedKeys: append(o.allowedKeys, prm.key.PublicKey().Bytes()),
}
}