Skip to content

Commit 9e56840

Browse files
committed
feat(agent): add shell selection for command execution and fix agent registration
1 parent e220685 commit 9e56840

17 files changed

Lines changed: 638 additions & 1166 deletions

agent-manager/agent/agent.pb.go

Lines changed: 214 additions & 390 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

agent-manager/agent/agent_grpc.pb.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

agent-manager/agent/agent_imp.go

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -75,17 +75,13 @@ func (s *AgentService) RegisterAgent(ctx context.Context, req *AgentRequest) (*A
7575
}
7676

7777
oldAgent := &models.Agent{}
78-
err := s.DBConnection.GetFirst(oldAgent, "hostname = ?", agent.Hostname)
78+
err := s.DBConnection.GetFirst(oldAgent, "hostname = ? AND mac = ?", agent.Hostname, agent.Mac)
7979
if err == nil {
80-
if oldAgent.Ip == agent.Ip {
81-
return &AuthResponse{
82-
Id: uint32(oldAgent.ID),
83-
Key: oldAgent.AgentKey,
84-
}, nil
85-
} else {
86-
catcher.Error("agent already exists", err, map[string]any{"hostname": agent.Hostname, "process": "agent-manager"})
87-
return nil, status.Errorf(codes.AlreadyExists, "hostname has already been registered")
88-
}
80+
// Same machine re-registering, return existing agent
81+
return &AuthResponse{
82+
Id: uint32(oldAgent.ID),
83+
Key: oldAgent.AgentKey,
84+
}, nil
8985
}
9086

9187
key := uuid.New().String()
@@ -334,6 +330,7 @@ func (s *AgentService) ProcessCommand(stream PanelService_ProcessCommandServer)
334330
AgentId: cmd.AgentId,
335331
Command: replaceSecretValues(cmd.Command),
336332
CmdId: cmdID,
333+
Shell: cmd.Shell,
337334
},
338335
},
339336
})

agent-manager/agent/collector.pb.go

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

agent-manager/agent/collector_grpc.pb.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

agent-manager/agent/common.pb.go

Lines changed: 55 additions & 107 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)