#!/usr/bin/env bash export keys_dir=~/projects/veilid-hacks/keys if [ "$1" = "-h" -o "$1" = "--help" ];then printf 'usage: veilid-new-private-route\n' >&2 exit 1 fi if [ "$1" != "socat" ];then exec socat tcp:"${VEILID_SERVER:-127.0.0.1:5959}" exec:"$0 socat" 2>&1 else shift fi printf '{"op":"NewPrivateRoute"}\n' state=0 stdbuf -oL jq -nc 'inputs | select(.type != "Update")' | while read -r line;do # printf 'state: %d line: %s\n' "$state" "$line" >&2 case "$state" in 0) ## { ## "type":"Response", ## "id":0, ## "op":"NewPrivateRoute", ## "value": ## { ## "route_id":"rSnuxYd0zbYEDVRzIXY9mD6TrnTLpH9wMJPmCAEniIg", ## "blob":"ARAeUAECAQJRBAEBURgBAg8wRExWEAT_0eBtVLM7VPUDEuvD_jGun0q44TRib_lSXxZxdxWb-IYwAAARBARBEAL_mDssjdEhtFMD1j54OmjLm3DAU-XqDEdNt_tEmWD7TxpEEQQDMQ3yAf8x73m97NoN5AnlxUOvGT7msh0XBE_GRVJ2PZ5dUvOCru0g3cKr_khfCsPqviHhmtyIraGzDjVQODa7UqGn5DSLf_Sr7xMaDbJGcODGTC6yipw_wvR64gY7" ## } } error="$(jq -r '.error.kind//""' <<< "${line}")" if [ "$error" ];then printf '\nQUIT :what? this isnt woodshop?\r\n' fi route_id="$(jq -r '.value.route_id//""' <<< "${line}")" route_blob="$(jq -r '.value.blob//""' <<< "${line}")" printf '%s\n' "${route_id}" >&2 printf '%s\n' "${route_blob}" >&2 printf '\nQUIT :what? this isnt woodshop?\r\n' ;; *) echo 'state: ' "$state" >&2 ;; esac state=$[$state+1] done #| tee /dev/stderr