Closed DimitarNestorov closed 4 years ago
this has to be one of the worst lines of code in this program. the python3 rewrite of the main binary can’t come soon enough.
I’m both proud and ashamed of fitting this into a line of bash. expanded:
from socket import socket
sock = socket(AF_INET,SOCK_STREAM)
sock.settimeout(5)
try:
sock.connect(os.environ[‘DRBIP’], int(os.environ[‘DRBPORT’]))
sock.close()
exit(0)
except Exception:
exit(1)
According to python docs, this should support hostnames...
Maybe socket.gethostbyname(hostname)
needs used here.
python3 -c "check = lambda x,y,z: (lambda s: (s.settimeout(z), s.connect((x, int(y))), s.close(), True))(__import__(\"socket\").socket(__import__(\"socket\").AF_INET,__import__(\"socket\").SOCK_STREAM));check(__import__(\"socket\").gethostbyname('$DRBIP'),$DRBPORT,$DBTIMEOUT)" 2>/dev/null
should do it. god help us.
Should be fixed now, update me if otherwise.
Commenting out this line will get it to work for the desperate ones: https://github.com/DragonBuild/DragonBuild/blob/3b59c890d875cc0176cdd2006db32168a1e03c1d/dragon#L378