1- import asyncio , websockets , sys , click , time , os
1+ import asyncio , websockets , sys , click , http . client , time
22from prompt_toolkit import print_formatted_text , HTML
33from websockets .exceptions import ConnectionClosedError
44from utils .helper_display import HelperDisplay
@@ -20,6 +20,21 @@ def obtntime():
2020 return timehour + ":" + timemint + ":" + timesecs
2121
2222
23+ def ipaddress (v ):
24+ url = "api64.ipify.org"
25+ if v == 4 :
26+ url = "api.ipify.org"
27+ elif v == 6 :
28+ url = "api6.ipify.org"
29+ try :
30+ connection = http .client .HTTPSConnection (url )
31+ connection .request ("GET" , "/" )
32+ response = connection .getresponse ()
33+ return response .read ().decode ("UTF-8" )
34+ except :
35+ return "Error getting IP address."
36+
37+
2338def getallus (chatroom ):
2439 userlist = []
2540 for indx in USERS :
@@ -104,9 +119,11 @@ def mainfunc(chatport, netprotc):
104119 if netprotc == "ipprotv6" :
105120 print_formatted_text (HTML ("[" + obtntime () + "] " + "<b>SNCTRYZERO</b> > <green>IP version : 6</green>" ))
106121 netpdata = "::"
122+ print_formatted_text (HTML ("[" + obtntime () + "] " + "<b>SNCTRYZERO</b> > <green>IP address : " + ipaddress (6 ) + "</green>" ))
107123 elif netprotc == "ipprotv4" :
108124 print_formatted_text (HTML ("[" + obtntime () + "] " + "<b>SNCTRYZERO</b> > <green>IP version : 4</green>" ))
109125 netpdata = "0.0.0.0"
126+ print_formatted_text (HTML ("[" + obtntime () + "] " + "<b>SNCTRYZERO</b> > <green>IP address : " + ipaddress (4 ) + "</green>" ))
110127 servenow (netpdata , chatport )
111128 except OSError :
112129 print_formatted_text (HTML ("[" + obtntime () + "] " + "<b>SNCTRYZERO</b> > <red><b>The server could not be started up</b></red>" ))
0 commit comments