-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add dns check to domains * Remove resolvers that shouldn't be honored * Add dnspython to requirements * Update script with NoAnswer and Timeout * Add dnscheck command * Remove NoAnswer and Timeout from dns response exceptions * Update dnscheck command with ns records and assertion * Remove looking for A records * TEMP Remove early exit * Update Github Action name * Automate removing domains without ns records * Add check for changes to automate removing domains without ns records * Remove failure * Update automate removing domains without ns records * Update automate removing domains without ns records name * Update automate removing domains without ns records * Remove domains without NS records --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
- Loading branch information
1 parent
93337bd
commit f951a0a
Showing
5 changed files
with
80 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
name: DNS | ||
on: [push] | ||
jobs: | ||
dns-check: | ||
name: Remove domains without NS records | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- run: | | ||
git config --global user.name 'github-actions[bot]' | ||
git config --global user.email '41898282+github-actions[bot]@users.noreply.github.com' | ||
name: Python setup | ||
- uses: actions/setup-python@v2 | ||
with: | ||
python-version: 3.8 | ||
- name: Install Requirements | ||
run: pip install -r requirements.txt | ||
- name: Check if list includes domains without NS records | ||
run: | | ||
cd scripts | ||
python3 dnscheck.py | ||
- name: Check for changes | ||
id: check_changes | ||
run: | | ||
if [[ `git status --porcelain pihole-google.txt` ]]; then | ||
echo "Domains found without NS records" | ||
echo "::set-output name=changes_detected::true" | ||
else | ||
echo "No domains without NS records found" | ||
echo "::set-output name=changes_detected::false" | ||
fi | ||
- name: Commit updated pihole-google.txt | ||
if: steps.check_changes.outputs.changes_detected == 'true' | ||
run: | | ||
git add pihole-google.txt | ||
git commit -am "Remove domains without NS records" | ||
git push |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
python-whois==0.9.4 | ||
python-whois==0.9.4 | ||
dnspython==2.6.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import dns.resolver | ||
|
||
def check_domain(domain): | ||
try: | ||
# Query for 'NS' records | ||
dns.resolver.resolve(domain, "NS") | ||
has_ns_record = True | ||
except dns.resolver.NXDOMAIN: | ||
has_ns_record = False | ||
except: | ||
has_ns_record = True | ||
|
||
return not has_ns_record | ||
|
||
def main(): | ||
found_domains = 0 | ||
domains_with_ns_records = [] | ||
|
||
with open("../pihole-google.txt") as f: | ||
for line in f: | ||
domain = line.strip() # strip whitespace | ||
if domain and not domain.startswith("#"): | ||
if check_domain(domain): | ||
print(f"Domain without NS records: {domain}") | ||
found_domains += 1 | ||
else: | ||
domains_with_ns_records.append(line) | ||
else: | ||
domains_with_ns_records.append(line) | ||
|
||
# Write remaining domains back to the file | ||
with open("../pihole-google.txt", "w") as f: | ||
f.writelines(domains_with_ns_records) | ||
|
||
if __name__ == "__main__": | ||
main() |