feat(TALE-36): support exit node enabling/disabling

This commit is contained in:
Aarnav Tale 2024-11-06 16:48:14 -05:00
parent 6e55f442fd
commit e1c87412d4
No known key found for this signature in database
2 changed files with 109 additions and 4 deletions

View file

@ -62,6 +62,24 @@ export async function menuAction(request: ActionFunctionArgs['request']) {
return json({ message: 'Route updated' })
}
case 'exit-node': {
if (!data.has('routes') || !data.has('enabled')) {
return json({ message: 'No route or enabled provided' }, {
status: 400,
})
}
const routes = data.get('routes')?.toString().split(',') ?? []
const enabled = data.get('enabled') === 'true'
const postfix = enabled ? 'enable' : 'disable'
await Promise.all(routes.map(async (route) => {
await post(`v1/routes/${route}/${postfix}`, session.get('hsApiKey')!)
}))
return json({ message: 'Exit node updated' })
}
case 'move': {
if (!data.has('to')) {
return json({ message: 'No destination provided' }, {