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 b5de392

Browse files
DNS
1 parent d899a22 commit b5de392

File tree

3 files changed

+91
-0
lines changed

3 files changed

+91
-0
lines changed

‎DNS verifier/main.py‎

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
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+
36+
if len(sys.argv) > 1:
37+
if '--dns' in sys.argv:
38+
d_index = sys.argv.index('--dns')
39+
if d_index == sys.argv.index(sys.argv[-1:][0]):
40+
print("Error, DNS was not specified")
41+
sys.exit(1)
42+
dns_val = sys.argv[sys.argv.index('--dns') + 1]
43+
else:
44+
print("help:\nuse \'--dns\' for DNS specification")
45+
sys.exit(1)
46+
try:
47+
response = checker(dns_val=dns_val)
48+
except Exception as err:
49+
print(f"error: {err}")
50+
sys.exit(1)
51+
52+
print(json.dumps(response, indent=4))
53+
sys.exit(0)

‎DNS verifier/readme.MD‎

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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 --dns <DNS>
25+
```
26+
27+
example:
28+
```
29+
python main.py --dns gaana.com
30+
```
31+
{
32+
"DNS": "gaana.com",
33+
"IP": [
34+
"23.211.222.138"
35+
],
36+
"AVAIL": false
37+
}

‎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 によって変換されたページ (->オリジナル) /