robotpy / robotpy-wpilib

Moved to https://github.com/robotpy/mostrobotpy
https://robotpy.github.io
Other
169 stars 59 forks source link

Deploy issue connected to another network #193

Closed ryannazaretian closed 8 years ago

ryannazaretian commented 8 years ago

I believe I found a bug when connected to non-FRC networking equipment.

In \pyfrc\robotpy\installer.py, I'm having unpacking issues.

socket.getaddrinfo('roborio-4901-frc.local', None) returns [(<AddressFamily.AF_INET6: 23>, 0, 0, '', ('fe80::280:2fff:fe17:3af1%8', 0, 0, 8)), (<AddressFamily.AF_INET: 2>, 0, 0, '', ('129.252.23.54', 0))]

However, socket.getaddrinfo('129.252.23.54', None) returns [(<AddressFamily.AF_INET: 2>, 0, 0, '', ('129.252.23.54', 0))]

The first item in the list is invalid for the unpacking done by the 'for' loop on line 333.

Specifically the issue has to do with the last tuple returned. From the Python socket documentation: "sockaddr is a tuple describing a socket address, whose format depends on the returned family (a (address, port) 2-tuple for AF_INET, a (address, port, flow info, scope id) 4-tuple for AF_INET6), and is meant to be passed to the socket.connect() method."

Here is my fix:

pick the first address that is sock_stream

    for addr in addrs:
        if len(addr[4]) == 2: # Only addr with IPv4 addresses
            (_, t, _, _, (ip, _)) = addr
            if t == socket.SOCK_STREAM:
                print("-> Found %s at %s" % (hostname, ip))
                print()
                hostname = ip
                break 
ryannazaretian commented 8 years ago

Wrong repo. Should have been pyfrc.