Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 811892e

Browse files
Merge pull request avinashkranjan#1084 from sur16-cse/DNS
DNS
2 parents 177a0a7 + f75714f commit 811892e

File tree

3 files changed

+84
-0
lines changed

3 files changed

+84
-0
lines changed

‎DNS verifier/main.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# DNS VERIFIER
2+
3+
import json
4+
import sys
5+
from collections import OrderedDict
6+
7+
import dns.resolver
8+
9+
10+
def checker(dns_val=None) -> OrderedDict:
11+
12+
ip_values = None
13+
avail = False
14+
15+
if dns_val is None:
16+
raise ValueError("Sorry DNS not found, DNS is needed")
17+
if isinstance(dns_val, str) is False:
18+
raise TypeError("Sorry, \'DNS\' must be type \'str\'")
19+
try:
20+
output = dns.resolver.resolve(dns_val, 'A')
21+
ip_values = [ipval.to_text() for ipval in output]
22+
except dns.resolver.NXDOMAIN:
23+
avail = True
24+
25+
return OrderedDict([
26+
("DNS", dns_val),
27+
("IP", ip_values),
28+
("AVAIL", avail),
29+
])
30+
31+
32+
if __name__ == '__main__':
33+
dns_val = None
34+
option = None
35+
print("Enter the DNS:")
36+
dns_val=input()
37+
try:
38+
response = checker(dns_val=dns_val)
39+
except Exception as err:
40+
print(f"error: {err}")
41+
sys.exit(1)
42+
43+
print(json.dumps(response, indent=4))
44+
sys.exit(0)

‎DNS verifier/readme.MD

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# DNS VERIFIER
2+
## Description
3+
A Script to verify the Domain Name System.
4+
- This is useful to check for availability of DNS.
5+
6+
## Language
7+
- [X] Python
8+
9+
## Instructions to run this application
10+
11+
1. Python 3 must be installed in your system.
12+
13+
- For first time, run this in terminal or powershell
14+
```
15+
pip3 install -r requirements.txt
16+
```
17+
2. It will download all the required modules
18+
19+
- Now run the below command
20+
21+
Usage:
22+
23+
```
24+
python main.py
25+
```
26+
27+
example:
28+
```
29+
python main.py
30+
```
31+
32+
Enter the DNS: gaana.com
33+
{
34+
"DNS": "gaana.com",
35+
"IP": [
36+
"23.211.222.138"
37+
],
38+
"AVAIL": false
39+
}

‎DNS verifier/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
dnspython==2.0.0

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /