#!/bin/bash
echo "Lethean Name Service (LNS)"
curl -s localhost:5553/health | python3 -c "
import sys,json
d=json.load(sys.stdin)
print(f'  Mode:    {d.get(\"mode\",\"?\")}')
print(f'  Names:   {d.get(\"names\",0)} cached')
print(f'  Status:  {d.get(\"status\",\"?\")}')
"
echo ""
echo "Resolving .lthn names:"
for name in charon gateway explorer trading; do
  result=$(curl -s "localhost:5553/resolve?name=$name.lthn" | python3 -c "import sys,json; d=json.load(sys.stdin); print('found' if d.get('found') else 'not cached')" 2>/dev/null)
  printf "  %-16s %s\n" "$name.lthn" "$result"
done
