2022-09-06 20:57:41 -06:00
|
|
|
#!/bin/bash
|
2023-04-02 13:46:52 -06:00
|
|
|
# FILE: wagon:back/dashboard.cgi
|
2022-09-06 20:57:41 -06:00
|
|
|
# DESCRIPTION: Recieves incoming dashboard API requests
|
2022-12-03 18:23:13 -07:00
|
|
|
|
2023-04-02 13:46:52 -06:00
|
|
|
source /etc/wagon/config
|
2022-09-06 20:57:41 -06:00
|
|
|
|
|
|
|
case "${REQUEST_METHOD}" in
|
|
|
|
|
2022-09-14 14:44:00 -06:00
|
|
|
# List peers
|
2023-04-02 13:46:52 -06:00
|
|
|
'GET') /usr/lib/wagon/dashboard/peer/list "${HTTP_X_REAL_IP}";;
|
2022-09-06 20:57:41 -06:00
|
|
|
|
|
|
|
# Add peer
|
2023-04-02 13:46:52 -06:00
|
|
|
'POST') /usr/lib/wagon/dashboard/peer/add "${HTTP_X_REAL_IP}" "${QUERY_STRING}";;
|
2022-09-06 20:57:41 -06:00
|
|
|
|
|
|
|
# Delete peer
|
2023-04-02 13:46:52 -06:00
|
|
|
'DELETE') /usr/lib/wagon/dashboard/peer/del "${HTTP_X_REAL_IP}" "${QUERY_STRING}";;
|
2022-09-06 20:57:41 -06:00
|
|
|
|
2022-09-13 11:33:13 -06:00
|
|
|
# Needed for CORS preflight
|
2023-04-02 13:46:52 -06:00
|
|
|
'OPTIONS') /usr/lib/wagon/http_res 200;;
|
2022-09-13 11:33:13 -06:00
|
|
|
|
2022-09-06 20:57:41 -06:00
|
|
|
# Bad request
|
2023-04-02 13:46:52 -06:00
|
|
|
*) printf 'Invalid HTTP verb' | /usr/lib/wagon/http_res 405;;
|
2022-11-08 21:05:34 -07:00
|
|
|
|
2022-09-14 14:44:00 -06:00
|
|
|
esac
|