Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Terrible but efficient hack for retrieving online DNS #17

Open
JiffB opened this issue Apr 8, 2019 · 0 comments
Open

Terrible but efficient hack for retrieving online DNS #17

JiffB opened this issue Apr 8, 2019 · 0 comments

Comments

@JiffB
Copy link

JiffB commented Apr 8, 2019

Hi folks,
The original script that retrieves all online DNS being awfully slooow, I found a modification that reduces it to ~1'30 (instead of 30') as my tests have shown that if a DNS is online, it'll answer in less a second :

cd contrib
cp resolvers-check.sh resolvers-check.sh_ORG

Then, edit resolvers-check.sh as follow :

#!/bin/bash

IMPORTANT: The following modification will not work if you leave it to: #!/bin/sh !

res=0
while read line; do
  if [ "x${IPV4_ONLY}" != "x" ]; then
    n=$(echo "$line" | egrep -c ',\[[0-9a-fA-F:]+\](:[0-9]+)?,')
    if [ $n -ne 0 ]; then
      continue
    fi
  fi
  resolver_name=$(echo "$line" | cut -d, -f1)

# NB: Above code is unmodified - just a beacon - modif is below.

  ( cmdpid=$BASHPID;
    (sleep 1; kill $cmdpid) & \
    while ! eval "${DNSCRYPT_PROXY} -L ${CSV_FILE} -R ${resolver_name} -t ${MARGIN} -m 1"
        do
            :
        done )

# NB: /Modification - Code below is genuine

  if [ $? -eq 0 ]; then
    echo "$line"
    echo "+ ${resolver_name} - OK" >&2
  else
    echo "- ${resolver_name} - Failed" >&2
    res=1
  fi
done

This modification will spit a lot of gargles when running (due to the nature of the code (return code test), I did not found a way to avoid that, may be some more experienced user can do that) but it will only cost you 90s instead of… 1800s.
 
My ¢2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant