diff --git a/main.py b/main.py index f3532e8..9599b7e 100644 --- a/main.py +++ b/main.py @@ -1,4 +1,4 @@ -import asyncio, websockets, sys, click, time, os +import asyncio, websockets, sys, click, urllib3, time from prompt_toolkit import print_formatted_text, HTML from websockets.exceptions import ConnectionClosedError from utils.helper_display import HelperDisplay @@ -20,6 +20,16 @@ def obtntime(): return timehour + ":" + timemint + ":" + timesecs +def ipaddress(v): + url = "https://api64.ipify.org" + if v == 4: + url = "https://api.ipify.org" + elif v == 6: + url = "https://api6.ipify.org" + response = urllib3.PoolManager().request('GET', url) + return response.data.decode('UTF-8') + + def getallus(chatroom): userlist = [] for indx in USERS: @@ -104,9 +114,11 @@ def mainfunc(chatport, netprotc): if netprotc == "ipprotv6": print_formatted_text(HTML("[" + obtntime() + "] " + "SNCTRYZERO > IP version : 6")) netpdata = "::" + print_formatted_text(HTML("[" + obtntime() + "] " + "SNCTRYZERO > IP address : " + ipaddress(6) + "")) elif netprotc == "ipprotv4": print_formatted_text(HTML("[" + obtntime() + "] " + "SNCTRYZERO > IP version : 4")) netpdata = "0.0.0.0" + print_formatted_text(HTML("[" + obtntime() + "] " + "SNCTRYZERO > IP address : " + ipaddress(4) + "")) servenow(netpdata, chatport) except OSError: print_formatted_text(HTML("[" + obtntime() + "] " + "SNCTRYZERO > The server could not be started up")) diff --git a/requirements.txt b/requirements.txt index 0bbb5d2..80dbda2 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,5 +4,6 @@ cryptography==3.0 prompt-toolkit==3.0.6 pycparser==2.20 six==1.15.0 +urllib3==1.25.10 wcwidth==0.2.5 -websockets==8.1 +websockets==8.1 \ No newline at end of file