diff --git a/README.md b/README.md new file mode 100644 index 0000000..46b4fd6 --- /dev/null +++ b/README.md @@ -0,0 +1,115 @@ +# Redirector + +## API Routes + +### Agents + +```json +GET /api/agents + +RESPONSE 200 (No Agents) +[] +RESPONSE 200 (Agents) +[ + { + "id": 1, + "os": "windows", + "ip": "192.168.1.10", + "profile: "g1", + ... + }, + ... +] +``` + +```json +GET /api/agents/:agentId + +RESPONSE 200 +{ + "id": 1, + "os": "windows", + "ip": "192.168.1.10", + "profile: "g1", +} +RESPONSE 404 (Invalid Agent) +{ + "message": "agent does not exist" +} +``` + +```json +PUT /api/agents/:agentId/status + +RESPONSE 200 +``` + +```json +GET /api/agents/:agentId/tasks + +RESPONSE 200 (No Tasks) +[] +RESPONSE 200 (Tasks) +[ + { + "id" 1, + "agentId": 1, + "command": "Z2V0LWhvc3Q=". + ... + }, + ... +] +RESPONSE 404 (Invalid Agent) +{ + "message": "agent does not exist" +} +``` + +### Tasks + +```json +POST /api/tasks +{ + "command": "Z2V0LWhvc3Q=", + "agentId": 1 +} + +RESPONSE 200 +{ + "taskId": 1, + "agentId: 1 +} +``` + +```json +GET /api/tasks + +RESPONSE 200 (No Tasks) +[] +RESPONSE 200 (Tasks) +[ + { + "id" 1, + "agentId": 1, + "command": "Z2V0LWhvc3Q=". + ... + }, + ... +] +``` + +```json +GET /api/tasks/:taskId + +RESPONSE 200 +{ + "id" 1, + "agentId": 1, + "command": "Z2V0LWhvc3Q=". + ... +} +RESPONSE (Invalid Task) +{ + "message": "task does not exist" +} +``` diff --git a/app/app.js b/app/app.js index 0cdcee0..50693fe 100644 --- a/app/app.js +++ b/app/app.js @@ -50,7 +50,7 @@ app.get('/api/agents/:agentId', (req, res) => { app.put('/api/agents/:agentId/status', (req, res) => { const agentId = parseInt(req.params.agentId) agentStore.updateAgentBeaconTime(agentId) - res.status(200).json(status) + res.status(200).send() }) app.get('/api/agents/:agentId/tasks', (req, res) => {