feat: ping through agent — send ICMP ping from workstation via agent
Adds a ping tool in the Equipment page workstation card (visible when agent is online). User enters an IP/hostname, the request goes through the PMS backend → WebSocket → agent → executes ping -n 4, returns raw output displayed in a monospace block. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -343,6 +343,23 @@ const workstationRoutes: FastifyPluginAsync = async (fastify) => {
|
||||
},
|
||||
)
|
||||
|
||||
// ── POST /api/hotels/:slug/workstations/:id/ping ────────────────────────────
|
||||
fastify.post<WsParam & { Body: { host: string } }>(
|
||||
'/api/hotels/:slug/workstations/:id/ping',
|
||||
{ onRequest: [fastify.authenticate] },
|
||||
async (req, reply) => {
|
||||
const { id } = req.params
|
||||
const { host } = req.body
|
||||
if (!host?.trim()) return reply.code(400).send({ error: 'host required' })
|
||||
try {
|
||||
const result = await sendCommandAndWait(id, { type: 'ping_host', host: host.trim() }, 20000) as { ok: boolean; output?: string; error?: string }
|
||||
return result
|
||||
} catch (err) {
|
||||
return reply.code(502).send({ ok: false, error: err instanceof Error ? err.message : 'Ошибка' })
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
// ── POST /api/hotels/:slug/workstations/update-all ──────────────────────────
|
||||
fastify.post<SlugParam>(
|
||||
'/api/hotels/:slug/workstations/update-all',
|
||||
|
||||
Reference in New Issue
Block a user