1
- import asyncio , websockets , sys , click , time , os
1
+ import asyncio , websockets , sys , click , http . client , time
2
2
from prompt_toolkit import print_formatted_text , HTML
3
3
from websockets .exceptions import ConnectionClosedError
4
4
from utils .helper_display import HelperDisplay
@@ -20,6 +20,21 @@ def obtntime():
20
20
return timehour + ":" + timemint + ":" + timesecs
21
21
22
22
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
+
23
38
def getallus (chatroom ):
24
39
userlist = []
25
40
for indx in USERS :
@@ -104,9 +119,11 @@ def mainfunc(chatport, netprotc):
104
119
if netprotc == "ipprotv6" :
105
120
print_formatted_text (HTML ("[" + obtntime () + "] " + "<b>SNCTRYZERO</b> > <green>IP version : 6</green>" ))
106
121
netpdata = "::"
122
+ print_formatted_text (HTML ("[" + obtntime () + "] " + "<b>SNCTRYZERO</b> > <green>IP address : " + ipaddress (6 ) + "</green>" ))
107
123
elif netprotc == "ipprotv4" :
108
124
print_formatted_text (HTML ("[" + obtntime () + "] " + "<b>SNCTRYZERO</b> > <green>IP version : 4</green>" ))
109
125
netpdata = "0.0.0.0"
126
+ print_formatted_text (HTML ("[" + obtntime () + "] " + "<b>SNCTRYZERO</b> > <green>IP address : " + ipaddress (4 ) + "</green>" ))
110
127
servenow (netpdata , chatport )
111
128
except OSError :
112
129
print_formatted_text (HTML ("[" + obtntime () + "] " + "<b>SNCTRYZERO</b> > <red><b>The server could not be started up</b></red>" ))
0 commit comments