Skip to content

Commit 9ccf899

Browse files
committed
diag: dwc: Download suites from hyperion-cs.github.io
1 parent 5ae0383 commit 9ccf899

File tree

1 file changed

+47
-42
lines changed

1 file changed

+47
-42
lines changed

zapret/dwc.sh

Lines changed: 47 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -65,40 +65,43 @@ if [ -f /etc/openwrt_release ]; then
6565
return 15
6666
fi
6767
fi
68-
68+
69+
mkdir -p "$ZAP_TMP_DIR"
70+
6971
#echo 'Original sources: https://github.com/hyperion-cs/dpi-checkers'
7072
#echo 'WEB-version: https://hyperion-cs.github.io/dpi-checkers/ru/tcp-16-20/'
7173

72-
TEST_SUITE='
73-
{ id: "US.CF-01", provider: "🇺🇸 Cloudflare", times: 1, url: "https://img.wzstats.gg/cleaver/gunFullDisplay" },
74-
{ id: "US.CF-02", provider: "🇺🇸 Cloudflare", times: 1, url: "https://genshin.jmp.blue/characters/all#" },
75-
{ id: "US.CF-03", provider: "🇺🇸 Cloudflare", times: 1, url: "https://api.frankfurter.dev/v1/2000-01-01..2002-12-31" },
76-
{ id: "US.CF-04", provider: "🇨🇦 Cloudflare", times: 1, url: "https://www.bigcartel.com/" },
77-
{ id: "US.DO-01", provider: "🇺🇸 DigitalOcean", times: 2, url: "https://genderize.io/" },
78-
{ id: "DE.HE-01", provider: "🇩🇪 Hetzner", times: 1, url: "https://j.dejure.org/jcg/doctrine/doctrine_banner.webp" },
79-
{ id: "DE.HE-02", provider: "🇩🇪 Hetzner", times: 1, url: "https://accesorioscelular.com/tienda/css/plugins.css" },
80-
{ id: "FI.HE-01", provider: "🇫🇮 Hetzner", times: 1, url: "https://251b5cd9.nip.io/1MB.bin" },
81-
{ id: "FI.HE-02", provider: "🇫🇮 Hetzner", times: 1, url: "https://nioges.com/libs/fontawesome/webfonts/fa-solid-900.woff2" },
82-
{ id: "FI.HE-03", provider: "🇫🇮 Hetzner", times: 1, url: "https://5fd8bdae.nip.io/1MB.bin" },
83-
{ id: "FI.HE-04", provider: "🇫🇮 Hetzner", times: 1, url: "https://5fd8bca5.nip.io/1MB.bin" },
84-
{ id: "FR.OVH-01", provider: "🇫🇷 OVH", times: 1, url: "https://eu.api.ovh.com/console/rapidoc-min.js" },
85-
{ id: "FR.OVH-02", provider: "🇫🇷 OVH", times: 1, url: "https://ovh.sfx.ovh/10M.bin" },
86-
{ id: "SE.OR-01", provider: "🇸🇪 Oracle", times: 1, url: "https://oracle.sfx.ovh/10M.bin" },
87-
{ id: "DE.AWS-01", provider: "🇩🇪 AWS", times: 1, url: "https://www.getscope.com/assets/fonts/fa-solid-900.woff2" },
88-
{ id: "US.AWS-01", provider: "🇺🇸 AWS", times: 1, url: "https://corp.kaltura.com/wp-content/cache/min/1/wp-content/themes/airfleet/dist/styles/theme.css" },
89-
{ id: "US.GC-01", provider: "🇺🇸 Google Cloud", times: 1, url: "https://api.usercentrics.eu/gvl/v3/en.json" },
90-
{ id: "US.FST-01", provider: "🇺🇸 Fastly", times: 1, url: "https://www.jetblue.com/footer/footer-element-es2015.js" },
91-
{ id: "CA.FST-01", provider: "🇨🇦 Fastly", times: 1, url: "https://ssl.p.jwpcdn.com/player/v/8.40.5/bidding.js" },
92-
{ id: "US.AKM-01", provider: "🇺🇸 Akamai", times: 1, url: "https://www.roxio.com/static/roxio/images/products/creator/nxt9/call-action-footer-bg.jpg" },
93-
{ id: "PL.AKM-01", provider: "🇵🇱 Akamai", times: 1, url: "https://media-assets.stryker.com/is/image/stryker/gateway_1?$max_width_1410$" },
94-
{ id: "US.CDN77-01", provider: "🇺🇸 CDN77", times: 1, url: "https://cdn.eso.org/images/banner1920/eso2520a.jpg" },
95-
{ id: "FR.CNTB-01", provider: "🇫🇷 Contabo", times: 1, url: "https://xdmarineshop.gr/index.php?route=index" },
96-
{ id: "NL.SW-01", provider: "🇳🇱 Scaleway", times: 1, url: "https://www.velivole.fr/img/header.jpg" },
97-
{ id: "US.CNST-01", provider: "🇺🇸 Constant", times: 1, url: "https://cdn.xuansiwei.com/common/lib/font-awesome/4.7.0/fontawesome-webfont.woff2?v=4.7.0" }
98-
'
74+
TEST_SUITE_URL="https://hyperion-cs.github.io/dpi-checkers/ru/tcp-16-20/suite.json"
75+
TEST_SUITE_FN="$ZAP_TMP_DIR/${TEST_SUITE_URL##*/}"
76+
TEST_SUITE_HDR="$TEST_SUITE_FN.hdr"
77+
rm -f "$TEST_SUITE_FN"
78+
rm -f "$TEST_SUITE_HDR"
9979

100-
if [ "$opt_sites" = true ]; then
101-
TEST_SUITE='
80+
#echo "Download $TEST_SUITE_URL ..."
81+
curl -s -L -D "$TEST_SUITE_HDR" -o "$TEST_SUITE_FN" --max-time 15 "$TEST_SUITE_URL" 2>/dev/null
82+
if [ ! -f "$TEST_SUITE_HDR" ] || [ -z "$TEST_SUITE_HDR" ] ; then
83+
echo "ERROR: Cannot download file \"$TEST_SUITE_URL\" (connection problem)"
84+
return 17
85+
fi
86+
RESP_STATUS=$( cat "$TEST_SUITE_HDR" | head -n 1 | awk '{print $2}' )
87+
if [ "$RESP_STATUS" != 200 ]; then
88+
echo "ERROR: Cannot download file \"$TEST_SUITE_URL\" (status = $RESP_STATUS)"
89+
return 18
90+
fi
91+
if [ ! -f "$TEST_SUITE_FN" ] || [ -z "$TEST_SUITE_FN" ] ; then
92+
echo "ERROR: Cannot download file \"$TEST_SUITE_URL\" (resp body empty)"
93+
return 19
94+
fi
95+
if [ "$(head -c 2 "$TEST_SUITE_FN" 2>/dev/null)" != "$(printf '[\n')" ]; then
96+
echo "ERROR: incorrect format of \"$TEST_SUITE_URL\""
97+
return 19
98+
fi
99+
if [ "$(tail -c 2 "$TEST_SUITE_FN" 2>/dev/null)" != "$(printf ']\n')" ]; then
100+
echo "ERROR: incorrect format of \"$TEST_SUITE_URL\""
101+
return 19
102+
fi
103+
104+
TEST_SUITE='
102105
gosuslugi.ru | @ | 40000 | https://gosuslugi.ru/__jsch/static/script.js
103106
esia.gosuslugi.ru | @ | 40000 | https://esia.gosuslugi.ru/__jsch/static/script.js
104107
gu-st.ru | | | https://gu-st.ru/portal-st/lib-assets/fonts/Lato-Regular-v3.woff2
@@ -125,17 +128,20 @@ if [ "$opt_sites" = true ]; then
125128
play.google.com | @# | 100000 | https://gstatic.com/feedback/js/help/prod/service/lazy.min.js
126129
genderize.io | @# | 210000 | https://genderize.io
127130
ottai.com | @ | 70000 | https://seas.static.ottai.com/ottai-website/public/images/new/home/banner/uk/banner.webp
128-
'
131+
'
132+
133+
if [ "$opt_sites" = true ]; then
129134
CURL_TIMEOUT=7
135+
else
136+
CURL_TIMEOUT=5
137+
TEST_SUITE=$( cat "$TEST_SUITE_FN" )
130138
fi
131139

132140
function trim
133141
{
134142
echo "$1" | sed 's/^[[:space:]]*//;s/[[:space:]]*$//'
135143
}
136144

137-
mkdir -p "$ZAP_TMP_DIR"
138-
139145
: > "$TARGET_LIST_FILE"
140146
IDX=0
141147
while IFS= read -r line; do
@@ -151,15 +157,14 @@ while IFS= read -r line; do
151157
continue
152158
fi
153159
case "$line" in
154-
*id:*provider:*url:*)
160+
*id*provider*thresholdBytes*url*)
155161
IDX=$((IDX + 1))
156-
TAG=$( printf '%s\n' "$line" | cut -d'"' -f2 )
162+
TAG=$( printf '%s\n' "$line" | cut -d'"' -f4 )
157163
COUNTRY="${TAG%%.*}"
158-
PROVIDER_RAW=$( printf '%s\n' "$line" | cut -d'"' -f4 )
159-
PROVIDER="${PROVIDER_RAW#* }"
160-
TIMES=$( printf '%s\n' "$line" | cut -d':' -f4 | cut -d',' -f1 | tr -d ' ')
161-
URL=$( printf '%s\n' "$line" | cut -d'"' -f6 )
162-
echo "${IDX}|${TAG}|${COUNTRY}|${PROVIDER}|${TIMES}|${URL}" >> "$TARGET_LIST_FILE"
164+
PROVIDER=$( printf '%s\n' "$line" | cut -d'"' -f8 )
165+
BYTES=$( printf '%s\n' "$line" | cut -d'"' -f15 | cut -d':' -f2 | cut -d',' -f1 | tr -d ' ')
166+
URL=$( printf '%s\n' "$line" | cut -d'"' -f20 )
167+
echo "${IDX}|${TAG}|${COUNTRY}|${PROVIDER}|${BYTES}|${URL}" >> "$TARGET_LIST_FILE"
163168
;;
164169
esac
165170
done <<EOF
@@ -170,15 +175,15 @@ CURL_CON_TIMEOUT=$((CURL_TIMEOUT-2))
170175
CURL_SPEED_TIME=$((CURL_TIMEOUT-2))
171176
CURL_SPEED_LIMIT=1
172177

173-
while IFS='|' read -r ID TAG COUNTRY PROVIDER TIMES URL; do
178+
while IFS='|' read -r ID TAG COUNTRY PROVIDER BYTES URL; do
174179
[ -z "$TAG" ] && continue
175180
ID3=$( printf '%03d' "$ID" )
176181
RANGETO=""
177182
REDIRECT=""
178183
USERAGENT="$CURL_USERAGENT"
179184
if [ "$opt_sites" = true ]; then
180185
FLAGS="$PROVIDER"
181-
TSIZE="$TIMES"
186+
TSIZE="$BYTES"
182187
[ "$TSIZE" = "" ] && TSIZE=$CURL_MAXBODY
183188
if echo "$FLAGS" | grep -q '@'; then
184189
RANGETO=""

0 commit comments

Comments
 (0)