-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
12 additions
and
7 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 |
---|---|---|
@@ -1,18 +1,23 @@ | ||
import requests | ||
import os | ||
#at the moment this code only checks if it is running with root privileges and checks your internet connection | ||
|
||
url = "https://www.google.com/" | ||
timeout = 5 | ||
|
||
maindns =("8.8.8.8") | ||
backupdns = ("8.8.8.4") | ||
|
||
if os.geteuid() == 0: | ||
try: | ||
request = requests.get(url, timeout=timeout) | ||
print(request) | ||
print("Connected to the Internet") | ||
#this code is not completed it will be updated with a working cod | ||
print("Your DNS is probably Alright...") | ||
except (requests.ConnectionError, requests.Timeout) as exception: | ||
print("No internet connection.") | ||
|
||
print("Possible DNS Failure!") | ||
print("Rewriting /etc/resolv.conf...") | ||
f = open('/etc/resolv.conf', 'r+') | ||
f.truncate(0) | ||
f.write("nameserver "+ maindns+"\nnameserver "+ backupdns) | ||
f.close() | ||
print("Good to Go...") | ||
else: | ||
print("Please run this script with root Privileages.") | ||
raise Exception("Please run this script with root Privileages.") |