Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FEATURE - Checking the internet connection #117

Closed
guztavoalves opened this issue Sep 28, 2020 · 1 comment
Closed

FEATURE - Checking the internet connection #117

guztavoalves opened this issue Sep 28, 2020 · 1 comment
Labels
enhancement New feature or request

Comments

@guztavoalves
Copy link

Hi,
When the internet connection is down, it's caused many crashes in script.

Because this, I tried a solution for this:

import socket

def check_internet_connection():
    internet = ping_conn()
    
    if not internet:
        print(COLOR_FAIL + "[!] Internet connection lost." + COLOR_ENDC)
        print(COLOR_FAIL + "[!] Checking Internet connection status..." + COLOR_ENDC)
        
        while not internet:
            countdown(60)
            internet = ping_conn()

        print(COLOR_OKGREEN + "[!] Internet connection status: OK!" + COLOR_ENDC)

def ping_conn():
    
    IPaddress=socket.gethostbyname(socket.gethostname())
    
    if IPaddress=="127.0.0.1":
        return False
    else:
        
        try:
            socket.create_connection(("1.1.1.1", 53))
            return True
        except:
            return False

I use this function to time.sleep:

def countdown(t):
    while t:
        mins, secs = divmod(t, 60)
        timeformat = '{:02d}:{:02d}'.format(mins, secs)
        print(timeformat, end='\r')
        time.sleep(1)
        t -= 1
@gvmturl gvmturl added the enhancement New feature or request label Oct 15, 2020
@Fadude
Copy link
Collaborator

Fadude commented Jan 6, 2021

We have added an internet-speed checker at the beggining of the session, I dont think its reasonable to check the connection to frequent during the session, I mean, if you dont have internat connectivity, you can use Insomniac anyway, so whats the point of that connection checker?

@alexal1 alexal1 closed this as completed Jun 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants