Compare commits

...

4 Commits

Author SHA1 Message Date
bol-van
fd4dc89360 auto setup_md5 2024-06-13 17:55:33 +03:00
bol-van
4dd27c848f blockcheck: mdig dns cache 2024-06-13 15:42:12 +03:00
bol-van
4c11274508 blockcheck: mdig dns cache 2024-06-13 15:40:55 +03:00
bol-van
222fb283c8 tpws: fix clang warning 2024-06-13 15:35:40 +03:00
4 changed files with 32 additions and 6 deletions

View File

@ -193,8 +193,28 @@ mdig_resolve()
# $1 - ip version 4/6
# $2 - hostname
# windows version of mdig outputs 0D0A line ending. remove 0D.
echo "$2" | "$MDIG" --family=$1 | head -n 1 | tr -d '\r'
local hostvar=$(echo $2 | sed -e 's/[\.-]/_/g')
local cachevar=DNSCACHE_${hostvar}_$1
local countvar=${cachevar}_COUNT
local count n ip ips
eval count=\$${countvar}
if [ -n "$count" ]; then
n=$(random 0 $(($count-1)))
eval ip=\$${cachevar}_$n
echo $ip
return 0
else
# windows version of mdig outputs 0D0A line ending. remove 0D.
ips="$(echo $2 | "$MDIG" --family=$1 | tr -d '\r' | xargs)"
[ -n "$ips" ] || return 1
count=0
for ip in $ips; do
eval ${cachevar}_$count=$ip
count=$(($count+1))
done
eval $countvar=$count
mdig_resolve "$@"
fi
}
check_system()

View File

@ -275,10 +275,18 @@ replace_char()
echo "$@" | tr $a $b
}
setup_md5()
{
[ -n "$MD5" ] && return
MD5=md5sum
exists $MD5 || MD5=md5
}
random()
{
# $1 - min, $2 - max
local r rs
setup_md5
if [ -c /dev/urandom ]; then
read rs </dev/urandom
else

View File

@ -24,9 +24,6 @@ GET_LIST="$IPSET_DIR/get_config.sh"
[ -n "$TPPORT" ] || TPPORT=988
MD5=md5sum
exists $MD5 || MD5=md5
check_readonly_system()
{
local RO

View File

@ -36,8 +36,9 @@ static size_t tls_pos(enum tlspos tpos_type, size_t tpos_pos, const uint8_t *tls
// fall through
case tlspos_pos:
return tpos_pos;
default:
return 0;
}
return 0;
}