mirror of
https://github.com/openziti/zrok.git
synced 2024-11-29 11:34:07 +01:00
roughed in share release (#463)
This commit is contained in:
parent
e7405cd9bb
commit
597776a835
@ -7,7 +7,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type share struct {
|
type share struct {
|
||||||
token string
|
shr *sdk.Share
|
||||||
target string
|
target string
|
||||||
|
|
||||||
basicAuth []string
|
basicAuth []string
|
||||||
|
@ -66,7 +66,7 @@ func (i *agentGrpcImpl) PublicShare(_ context.Context, req *agentGrpc.PublicShar
|
|||||||
}
|
}
|
||||||
|
|
||||||
agentShr := &share{
|
agentShr := &share{
|
||||||
token: shr.Token,
|
shr: shr,
|
||||||
target: req.Target,
|
target: req.Target,
|
||||||
basicAuth: req.BasicAuth,
|
basicAuth: req.BasicAuth,
|
||||||
frontendSelection: shr.FrontendEndpoints,
|
frontendSelection: shr.FrontendEndpoints,
|
||||||
|
@ -3,18 +3,34 @@ package agent
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"github.com/openziti/zrok/agent/agentGrpc"
|
"github.com/openziti/zrok/agent/agentGrpc"
|
||||||
|
"github.com/openziti/zrok/environment"
|
||||||
|
"github.com/openziti/zrok/sdk/golang/sdk"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (i *agentGrpcImpl) ReleaseShare(_ context.Context, req *agentGrpc.ReleaseShareRequest) (*agentGrpc.ReleaseShareReply, error) {
|
func (i *agentGrpcImpl) ReleaseShare(_ context.Context, req *agentGrpc.ReleaseShareRequest) (*agentGrpc.ReleaseShareReply, error) {
|
||||||
if shr, found := i.a.shares[req.Token]; found {
|
if shr, found := i.a.shares[req.Token]; found {
|
||||||
logrus.Infof("stopping share '%v'", shr.token)
|
logrus.Infof("stopping share '%v'", shr.shr.Token)
|
||||||
if err := shr.handler.Stop(); err != nil {
|
if err := shr.handler.Stop(); err != nil {
|
||||||
logrus.Error(err)
|
logrus.Errorf("error stopping share '%v': %v", shr.shr.Token, err)
|
||||||
}
|
}
|
||||||
delete(i.a.shares, shr.token)
|
|
||||||
logrus.Infof("released share '%v'", shr.token)
|
root, err := environment.LoadRoot()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if !root.IsEnabled() {
|
||||||
|
return nil, errors.New("unable to load environment; did you 'zrok enable'?")
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := sdk.DeleteShare(root, shr.shr); err != nil {
|
||||||
|
logrus.Errorf("error releasing share '%v': %v", shr.shr.Token, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
delete(i.a.shares, shr.shr.Token)
|
||||||
|
logrus.Infof("released share '%v'", shr.shr.Token)
|
||||||
} else {
|
} else {
|
||||||
return nil, errors.Errorf("agent has no share with token '%v'", req.Token)
|
return nil, errors.Errorf("agent has no share with token '%v'", req.Token)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user