Skip to content

Terrible but efficient hack for retrieving online DNS #17

@JiffB

Description

@JiffB

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions