Last active
January 29, 2020 02:54
-
-
Save rcx/f569dd449ce7919db96523f2c18cd82f to your computer and use it in GitHub Desktop.
Socket server that returns your IP address -- try it online at http://tcpb.in:9999
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
from socket import * | |
s = socket(AF_INET, SOCK_STREAM) | |
s.bind(('', 9999)) | |
s.listen(1) | |
while True: | |
try: | |
c,a = s.accept() | |
print(a) | |
c.send((str(a[0]) + '\n').encode('utf-8')) | |
c.shutdown(SHUT_RDWR) | |
c.close() | |
except KeyboardInterrupt: | |
break | |
except: | |
pass |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
from socket import * | |
s = socket(AF_INET, SOCK_STREAM) | |
s.bind(('', 9999)) | |
s.listen(1) | |
while True: | |
try: | |
c,a = s.accept() | |
print a | |
c.send(str(a[0]) + '\n') | |
c.shutdown(SHUT_RDWR) | |
c.close() | |
except KeyboardInterrupt: | |
break | |
except: | |
pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Q: Why did you write this? Aren't there a million other services like this?
A: Yes, but...:
nc tcpb.in 9999
orcurl tcpb.in:9999
.Q: Don't other features offer other functionality like geoip?
A: Lack of features is a feature. Keep it simple. This makes it compatible with many tools as http support is no longer required, only tcp. Moreover, Geoip API query is a leak and therefore bad security. Plus, most people have their home IP address memorized anyways so Geoip is not so important as distinguishing between home IP or not; hostname is more useful than Geo.