DragonBuild / dragon

pip install dragon | A Powerful buildsystem and toolkit currently targeting darwin (iOS/macOS) machines
MIT License
220 stars 23 forks source link

Support for connecting to devices using hostnames #22

Closed DimitarNestorov closed 4 years ago

DimitarNestorov commented 4 years ago

image Commenting out this line will get it to work for the desperate ones: https://github.com/DragonBuild/DragonBuild/blob/3b59c890d875cc0176cdd2006db32168a1e03c1d/dragon#L378

0cyn commented 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.

0cyn commented 4 years ago
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.

0cyn commented 4 years ago

Should be fixed now, update me if otherwise.