repo: veilid-hacks
action: blob
revision: 
path_from: veilid-import-remote-private-route
revision_from: refs/heads/trunk:
path_to: 
revision_to: 
git.thebackupbox.net
veilid-hacks
git clone git://git.thebackupbox.net/veilid-hacks

blob of:

veilid-hacks

/ veilid-import-remote-private-route

blob_plain of this file

refs/heads/trunk:/veilid-import-remote-private-route

 #!/usr/bin/env bash

 export keys_dir=~/projects/veilid-hacks/keys

 if [ ! "$1" ];then
   printf 'usage: veilid-import-remote-private-route \n' >&2
   exit 1
 fi

 if [ "$1" != "socat" ];then
   export route_blob="$1"
   exec socat tcp:"${VEILID_SERVER:-127.0.0.1:5959}" exec:"$0 socat" 2>&1
 else
   shift
 fi

 printf '{"op":"ImportRemotePrivateRoute","blob":"%s"}\n' "${route_blob}"
 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)
 ### what is the response of this look like?
 # {"type":"Response","id":0,"op":"ImportRemotePrivateRoute","value":"6_Xd6hQO27s3p3FSXLkZF0xYeVcNYF4zTzJz8eR_f8M"}
       route_id="$(jq -r .value <<< "${line}")"
       printf '%s\n' "${route_id}" >&2
       printf '\nQUIT :what? this isnt woodshop?\r\n'
 #    ;;
 #    *)
 #      echo 'state: ' "$state" >&2
 #    ;;
 #  esac
 #  state=$[$state+1]
 done #| tee /dev/stderr