diff --git a/agent/access.go b/agent/access.go index 7a97108c..de7ffcda 100644 --- a/agent/access.go +++ b/agent/access.go @@ -22,14 +22,14 @@ type access struct { bootComplete chan struct{} bootErr error - a *Agent + agent *Agent } func (a *access) monitor() { if err := proctree.WaitChild(a.process); err != nil { pfxlog.ChannelLogger(a.token).Error(err) } - a.a.outAccesses <- a + a.agent.rmAccess <- a } func (a *access) tail(data []byte) { diff --git a/agent/accessPrivate.go b/agent/accessPrivate.go index 2a749a1a..7d7212ff 100644 --- a/agent/accessPrivate.go +++ b/agent/accessPrivate.go @@ -26,7 +26,7 @@ func (i *agentGrpcImpl) AccessPrivate(_ context.Context, req *agentGrpc.AccessPr bindAddress: req.BindAddress, responseHeaders: req.ResponseHeaders, bootComplete: make(chan struct{}), - a: i.a, + agent: i.agent, } logrus.Infof("executing '%v'", accCmd) @@ -40,7 +40,7 @@ func (i *agentGrpcImpl) AccessPrivate(_ context.Context, req *agentGrpc.AccessPr <-acc.bootComplete if acc.bootErr == nil { - i.a.inAccesses <- acc + i.agent.addAccess <- acc return &agentGrpc.AccessPrivateResponse{FrontendToken: acc.frontendToken}, nil } diff --git a/agent/agent.go b/agent/agent.go index a44f0f45..4deb5611 100644 --- a/agent/agent.go +++ b/agent/agent.go @@ -16,11 +16,11 @@ type Agent struct { root env_core.Root agentSocket string shares map[string]*share - inShares chan *share - outShares chan *share + addShare chan *share + rmShare chan *share accesses map[string]*access - inAccesses chan *access - outAccesses chan *access + addAccess chan *access + rmAccess chan *access } func NewAgent(root env_core.Root) (*Agent, error) { @@ -28,13 +28,13 @@ func NewAgent(root env_core.Root) (*Agent, error) { return nil, errors.Errorf("unable to load environment; did you 'zrok enable'?") } return &Agent{ - root: root, - shares: make(map[string]*share), - inShares: make(chan *share), - outShares: make(chan *share), - accesses: make(map[string]*access), - inAccesses: make(chan *access), - outAccesses: make(chan *access), + root: root, + shares: make(map[string]*share), + addShare: make(chan *share), + rmShare: make(chan *share), + accesses: make(map[string]*access), + addAccess: make(chan *access), + rmAccess: make(chan *access), }, nil } @@ -57,7 +57,7 @@ func (a *Agent) Run() error { a.agentSocket = agentSocket srv := grpc.NewServer() - agentGrpc.RegisterAgentServer(srv, &agentGrpcImpl{a: a}) + agentGrpc.RegisterAgentServer(srv, &agentGrpcImpl{agent: a}) if err := srv.Serve(l); err != nil { return err } @@ -73,11 +73,11 @@ func (a *Agent) Shutdown() { } for _, shr := range a.shares { logrus.Debugf("stopping share '%v'", shr.token) - a.outShares <- shr + a.rmShare <- shr } for _, acc := range a.accesses { logrus.Debugf("stopping access '%v'", acc.token) - a.outAccesses <- acc + a.rmAccess <- acc } } @@ -87,11 +87,11 @@ func (a *Agent) manager() { for { select { - case inShare := <-a.inShares: + case inShare := <-a.addShare: logrus.Infof("adding new share '%v'", inShare.token) a.shares[inShare.token] = inShare - case outShare := <-a.outShares: + case outShare := <-a.rmShare: if shr, found := a.shares[outShare.token]; found { logrus.Infof("removing share '%v'", shr.token) if err := proctree.StopChild(shr.process); err != nil { @@ -110,11 +110,11 @@ func (a *Agent) manager() { logrus.Debug("skipping unidentified (orphaned) share removal") } - case inAccess := <-a.inAccesses: + case inAccess := <-a.addAccess: logrus.Infof("adding new access '%v'", inAccess.frontendToken) a.accesses[inAccess.frontendToken] = inAccess - case outAccess := <-a.outAccesses: + case outAccess := <-a.rmAccess: if acc, found := a.accesses[outAccess.frontendToken]; found { logrus.Infof("removing access '%v'", acc.frontendToken) if err := proctree.StopChild(acc.process); err != nil { @@ -152,5 +152,5 @@ func (a *Agent) deleteAccess(token, frontendToken string) error { type agentGrpcImpl struct { agentGrpc.UnimplementedAgentServer - a *Agent + agent *Agent } diff --git a/agent/releaseAccess.go b/agent/releaseAccess.go index ba9d3445..86e2f8d2 100644 --- a/agent/releaseAccess.go +++ b/agent/releaseAccess.go @@ -8,8 +8,8 @@ import ( ) func (i *agentGrpcImpl) ReleaseAccess(_ context.Context, req *agentGrpc.ReleaseAccessRequest) (*agentGrpc.ReleaseAccessResponse, error) { - if acc, found := i.a.accesses[req.FrontendToken]; found { - i.a.outAccesses <- acc + if acc, found := i.agent.accesses[req.FrontendToken]; found { + i.agent.rmAccess <- acc logrus.Infof("released access '%v'", acc.frontendToken) } else { diff --git a/agent/releaseShare.go b/agent/releaseShare.go index 0fd4d56e..0759e1c5 100755 --- a/agent/releaseShare.go +++ b/agent/releaseShare.go @@ -8,8 +8,8 @@ import ( ) func (i *agentGrpcImpl) ReleaseShare(_ context.Context, req *agentGrpc.ReleaseShareRequest) (*agentGrpc.ReleaseShareResponse, error) { - if shr, found := i.a.shares[req.Token]; found { - i.a.outShares <- shr + if shr, found := i.agent.shares[req.Token]; found { + i.agent.rmShare <- shr logrus.Infof("released share '%v'", shr.token) } else { diff --git a/agent/share.go b/agent/share.go index c25479c8..2d309748 100644 --- a/agent/share.go +++ b/agent/share.go @@ -34,14 +34,14 @@ type share struct { bootComplete chan struct{} bootErr error - a *Agent + agent *Agent } func (s *share) monitor() { if err := proctree.WaitChild(s.process); err != nil { pfxlog.ChannelLogger(s.token).Error(err) } - s.a.outShares <- s + s.agent.rmShare <- s } func (s *share) tail(data []byte) { diff --git a/agent/sharePrivate.go b/agent/sharePrivate.go index 5cca4d1c..eaa2359f 100644 --- a/agent/sharePrivate.go +++ b/agent/sharePrivate.go @@ -26,7 +26,7 @@ func (i *agentGrpcImpl) SharePrivate(_ context.Context, req *agentGrpc.SharePriv shareMode: sdk.PrivateShareMode, backendMode: sdk.BackendMode(req.BackendMode), bootComplete: make(chan struct{}), - a: i.a, + agent: i.agent, } if req.Insecure { @@ -58,7 +58,7 @@ func (i *agentGrpcImpl) SharePrivate(_ context.Context, req *agentGrpc.SharePriv <-shr.bootComplete if shr.bootErr == nil { - i.a.inShares <- shr + i.agent.addShare <- shr return &agentGrpc.SharePrivateResponse{Token: shr.token}, nil } diff --git a/agent/sharePublic.go b/agent/sharePublic.go index 6e48c114..43963854 100644 --- a/agent/sharePublic.go +++ b/agent/sharePublic.go @@ -26,7 +26,7 @@ func (i *agentGrpcImpl) SharePublic(_ context.Context, req *agentGrpc.SharePubli shareMode: sdk.PublicShareMode, backendMode: sdk.BackendMode(req.BackendMode), bootComplete: make(chan struct{}), - a: i.a, + agent: i.agent, } for _, basicAuth := range req.BasicAuth { @@ -82,7 +82,7 @@ func (i *agentGrpcImpl) SharePublic(_ context.Context, req *agentGrpc.SharePubli <-shr.bootComplete if shr.bootErr == nil { - i.a.inShares <- shr + i.agent.addShare <- shr return &agentGrpc.SharePublicResponse{ Token: shr.token, FrontendEndpoints: shr.frontendEndpoints, diff --git a/agent/shareReserved.go b/agent/shareReserved.go index def2d04d..33719b50 100644 --- a/agent/shareReserved.go +++ b/agent/shareReserved.go @@ -23,7 +23,7 @@ func (i *agentGrpcImpl) ShareReserved(_ context.Context, req *agentGrpc.ShareRes shr := &share{ reserved: true, bootComplete: make(chan struct{}), - a: i.a, + agent: i.agent, } if req.OverrideEndpoint != "" { @@ -47,7 +47,7 @@ func (i *agentGrpcImpl) ShareReserved(_ context.Context, req *agentGrpc.ShareRes <-shr.bootComplete if shr.bootErr == nil { - i.a.inShares <- shr + i.agent.addShare <- shr return &agentGrpc.ShareReservedResponse{ Token: shr.token, BackendMode: string(shr.backendMode), diff --git a/agent/status.go b/agent/status.go index f738a361..18fc1ded 100644 --- a/agent/status.go +++ b/agent/status.go @@ -7,7 +7,7 @@ import ( func (i *agentGrpcImpl) Status(_ context.Context, _ *agentGrpc.StatusRequest) (*agentGrpc.StatusResponse, error) { var accesses []*agentGrpc.AccessDetail - for feToken, acc := range i.a.accesses { + for feToken, acc := range i.agent.accesses { accesses = append(accesses, &agentGrpc.AccessDetail{ FrontendToken: feToken, Token: acc.token, @@ -17,7 +17,7 @@ func (i *agentGrpcImpl) Status(_ context.Context, _ *agentGrpc.StatusRequest) (* } var shares []*agentGrpc.ShareDetail - for token, shr := range i.a.shares { + for token, shr := range i.agent.shares { shares = append(shares, &agentGrpc.ShareDetail{ Token: token, ShareMode: string(shr.shareMode),