Skip to content

Commit 61f1a70

Browse files
author
Shivang P Swain
committed
Revert "Merge remote-tracking branch 'upstream/master' into upstream"
This reverts commit 44b453d, reversing changes made to 84d1f88.
1 parent 44b453d commit 61f1a70

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

main.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import asyncio, websockets, sys, click, time, os
1+
import asyncio, websockets, sys, click, http.client, time
22
from prompt_toolkit import print_formatted_text, HTML
33
from websockets.exceptions import ConnectionClosedError
44
from 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+
2338
def 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>"))

requirements.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
cffi==1.14.3
1+
cffi==1.14.2
22
click==7.1.2
3-
cryptography==3.2.1
4-
prompt-toolkit==3.0.8
3+
cryptography==3.0
4+
prompt-toolkit==3.0.6
55
pycparser==2.20
66
six==1.15.0
77
wcwidth==0.2.5
8-
websockets==8.1
8+
websockets==8.1

0 commit comments

Comments
 (0)