forked from spinesystemspublic/documentation
782eb80d85
Signed-off-by: Denys Fedoryshchenko <denys.f@collabora.com>
108 lines
2.8 KiB
Markdown
108 lines
2.8 KiB
Markdown
# GlobalOS API
|
|
|
|
## Setting up
|
|
|
|
To enable API, you need to add following file /etc/api.conf
|
|
|
|
```ini
|
|
# set API key
|
|
apikey=ZZZZZ
|
|
# disable API key check
|
|
# disableapikey=1
|
|
|
|
allowip=1.2.3.4,2.4.5.6
|
|
```
|
|
|
|
API key should be present in header X-Auth-Token: ZZZZZ
|
|
|
|
## Hooks
|
|
|
|
### API hook: /hooks/counters
|
|
|
|
Available counters for a given interface
|
|
GET parameters:
|
|
iface - interface name
|
|
source - source of data (tc, ip, ethtool)
|
|
type - type of data (for source tc: qdisc, class, filter; for source ip: link, addr; for source ethtool: statistics, module)
|
|
|
|
Example:
|
|
/hook/counters?iface=ppp100&source=ip&type=link
|
|
|
|
### API hook: /ppp/list
|
|
|
|
Optional GET params:
|
|
&tag=XXXX - filter by radattr tag
|
|
&tag=XXXX&value=YYYY - filter by radattr tag and value (full match)
|
|
X-Auth-Token: XXXX
|
|
Login-LAT-Service gaming
|
|
curl -H "X-Auth-Token: XXXX" http://localhost:8080/ppp/list?tag=Login-LAT-Service&value=gaming
|
|
|
|
|
|
|
|
|
|
Work in progress...
|
|
```
|
|
http.HandleFunc("/hooks/counters", counters_hook)
|
|
http.HandleFunc("/hooks/radattr", radattr_hook)
|
|
http.HandleFunc("/hooks/ping", ping_hook)
|
|
http.HandleFunc("/hooks/proc_data", proc_hook)
|
|
http.HandleFunc("/hooks/sessions", sessions_hook)
|
|
http.HandleFunc("/hooks/tcpdump", tcpdump_hook)
|
|
http.HandleFunc("/hooks/diag_counters", diag_counters_hook)
|
|
// /shaper/download - retrieve /etc/config.json
|
|
// /shaper/upload - upload /etc/config.json
|
|
http.HandleFunc("/shaper/download", shaper_download_hook)
|
|
http.HandleFunc("/shaper/upload", shaper_upload_hook)
|
|
http.HandleFunc("/accel/vlans", accel_vlans_hook)
|
|
// returns interface, ip, username
|
|
http.HandleFunc("/ppp/list", ppp_data_hook)
|
|
http.HandleFunc("/", unknown)
|
|
```
|
|
|
|
Availaible hooks:
|
|
|
|
TC:
|
|
|
|
* http://x.x.x.x/hooks/counters?iface=<IF_NAME>&source=tc&type=qdisc&format=json
|
|
* http://x.x.x.x/hooks/counters?iface=<IF_NAME>&source=tc&type=class&format=json
|
|
* http://x.x.x.x/hooks/counters?iface=<IF_NAME>&source=tc&type=filter&format=json
|
|
|
|
IP:
|
|
|
|
* http://x.x.x.x/hooks/counters?iface=<IF_NAME>&source=ip&type=link&format=json
|
|
* http://x.x.x.x/hooks/counters?iface=<IF_NAME>&source=ip&type=addr&format=json
|
|
|
|
ETHTOOL:
|
|
|
|
* http://x.x.x.x/hooks/counters?iface=<IF_NAME>&source=ethtool&type=statistics&format=json
|
|
* http://x.x.x.x/hooks/counters?iface=<IF_NAME>&source=ethtool&type=module&format=json
|
|
|
|
RADIUS ATTRIBUTES
|
|
|
|
* http://x.x.x.x/hooks/radattr?iface=<pppX>
|
|
|
|
TRAFFIC DUMP
|
|
|
|
* http://x.x.x.x/hooks/traffic_dump?iface=<IF_NAME>
|
|
|
|
PING
|
|
|
|
* http://x.x.x.x/hooks/ping?iface=<IF_NAME>&ip=<x.x.x.x>
|
|
|
|
PROC FS DATA
|
|
|
|
* http://x.x.x.x/hooks/proc_data?type=vlans
|
|
* http://x.x.x.x/hooks/proc_data?type=pppoe
|
|
* http://x.x.x.x/hooks/proc_data?type=vlan&iface=<IF_NAME>
|
|
|
|
SESSIONS
|
|
|
|
# Show all sessions
|
|
* http://x.x.x.x/hooks/sessions
|
|
# Show selected user session
|
|
* http://x.x.x.x/hooks/sessions?username=<USERNAME>
|
|
# Show defined fields (ifname,username,inbound-if,service-name)
|
|
* http://x.x.x.x/hooks/sessions?view=optimal
|
|
|
|
|