-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathhit_proxy.bash
executable file
·38 lines (30 loc) · 1.09 KB
/
hit_proxy.bash
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
35
36
37
38
#!/usr/bin/env bash
# This script allows running against a specific lantern-cloud proxy identified by the PFE IP
# Assume lantern-cloud is a sibling of lantern-client unless told otherwise.
LANTERN_CLOUD=$([[ ! -z "$LANTERN_CLOUD" ]] && echo "$LANTERN_CLOUD" || echo "../lantern-cloud")
set -ef -o pipefail
PROXY="${1:?please specify the proxy IP}"
TMPDIR="${TMP:-/tmp}/hit_lc_proxy/$PROXY"
OUTFILE="$TMPDIR/user.conf"
rm -rf "$TMPDIR"
mkdir -p "$TMPDIR"
echo "Generating config for ${PROXY} in ${OUTFILE}..."
CONFIG=$($LANTERN_CLOUD/bin/lc route dump-config $PROXY)
# wrap the proxy config to match the format expected by flashlight.
# [ConfigResponse (getlantern/flashlight/apipb/types.proto)]
OUTPUT="{\"country\": \"US\",\"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
if [ "$(uname)" == "Linux" ]; then
make linux-amd64
CMD="flutter run"
else
make macos ffigen
CMD="flutter run -d macOS"
fi
CONFIG_DIR=$TMPDIR READABLE_CONFIG=true STICKY_CONFIG=true $CMD