Skip to content

Commit

Permalink
format config as apipb.ConfigResponse
Browse files Browse the repository at this point in the history
  • Loading branch information
garmr-ulfr committed Dec 2, 2024
1 parent 021ecb7 commit 8d16fbf
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions hit_proxy.bash
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,22 @@ set -ef -o pipefail

PROXY="${1:?please specify the proxy IP}"
TMPDIR="${TMP:-/tmp}/hit_lc_proxy/$PROXY"
OUTFILE="$TMPDIR/proxies.yaml"
OUTFILE="$TMPDIR/user.conf"

rm -rf "$TMPDIR"
mkdir -p "$TMPDIR"

echo "Generating config for ${PROXY} in ${OUTFILE}..."
$LANTERN_CLOUD/bin/lc route dump-config --legacy "$PROXY" > "$OUTFILE"
CONFIG=$($LANTERN_CLOUD/bin/lc route dump-config $PROXY)
OUTPUT="{\"proxy\":{\"proxies\":[${CONFIG}]}}"

# check if jq is installed and reformat the output
if command -v jq &> /dev/null
then
echo $OUTPUT | jq . > $OUTFILE
else
echo $OUTPUT > $OUTFILE
fi

make darwin ffigen
LANTERN_CONFIGDIR=$TMPDIR \
Expand Down

0 comments on commit 8d16fbf

Please sign in to comment.