mirror of
https://github.com/openziti/zrok.git
synced 2025-08-16 02:47:56 +02:00
do not call 'ziti.NewContext' multiple times (#1023)
This commit is contained in:
@ -2,9 +2,9 @@ package controller
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/go-openapi/runtime/middleware"
|
||||
"github.com/openziti/zrok/agent/agentGrpc"
|
||||
"github.com/openziti/zrok/controller/agentController"
|
||||
"github.com/openziti/zrok/rest_model_zrok"
|
||||
"github.com/openziti/zrok/rest_server_zrok/operations/agent"
|
||||
"github.com/sirupsen/logrus"
|
||||
@ -37,12 +37,12 @@ func (h *agentRemoteAccessHandler) Handle(params agent.RemoteAccessParams, princ
|
||||
}
|
||||
_ = trx.Rollback() // ...or will block the access trx on sqlite
|
||||
|
||||
acli, aconn, err := agentController.NewAgentClient(ae.Token, cfg.AgentController)
|
||||
agentClient, agentConn, err := agentCtrl.NewClient(ae.Token)
|
||||
if err != nil {
|
||||
logrus.Errorf("error creating agent client for '%v' (%v): %v", params.Body.EnvZID, principal.Email, err)
|
||||
return agent.NewRemoteAccessInternalServerError()
|
||||
}
|
||||
defer aconn.Close()
|
||||
defer agentConn.Close()
|
||||
|
||||
req := &agentGrpc.AccessPrivateRequest{
|
||||
Token: params.Body.Token,
|
||||
@ -53,7 +53,7 @@ func (h *agentRemoteAccessHandler) Handle(params agent.RemoteAccessParams, princ
|
||||
AutoEndPort: uint32(params.Body.AutoEndPort),
|
||||
ResponseHeaders: params.Body.ResponseHeaders,
|
||||
}
|
||||
resp, err := acli.AccessPrivate(context.Background(), req)
|
||||
resp, err := agentClient.AccessPrivate(context.Background(), req)
|
||||
if err != nil {
|
||||
logrus.Errorf("error creating remote agent private access for '%v' (%v): %v", params.Body.EnvZID, principal.Email, err)
|
||||
return agent.NewRemoteAccessBadGateway()
|
||||
|
Reference in New Issue
Block a user