summaryrefslogtreecommitdiff
path: root/examples/list-tokens.sh
blob: 1dfc05163bdef475c77d330facb671fcb5662e7e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/bin/bash
# vim: set sts=2 sw=2 et tw=0 :
#

HOST="http://localhost:8000"

caps="application/x-rtp, media=(string)video"
start_port=5004
end_port=5018
udp_clients="localhost:$start_port"

set -e

add_tokens() {
  local id
  for port in $(seq $((start_port)) $end_port); do
    id=$(date +%H%M%S)-$RANDOM
    curl -s -X POST "$HOST/add-token?sessionid=$id&type=http,rtp-udp&udp-clients=localhost:$port"
  done
}

list_tokens() {
  curl -s -X GET "$HOST/list-tokens"
  echo
}

revoke_tokens() {
  local id
  list_sessionids | while read id; do 
    curl -s -X DELETE "$HOST/revoke-token?sessionid=$id"
  done
}

list_tokens