For easier reading, I've put your FreeBSD output into a two-liners:
Code: Select all
>>> info = [(28, 2, 17, '', (28, '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')), (28, 1, 6, '', (28, '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')), (28, 5, 132, '', (28, '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')), (2, 2, 17, '', ('127.0.0.1', 0)), (2, 1, 6, '', ('127.0.0.1', 0)), (2, 5, 132, '', ('127.0.0.1', 0))]
>>> for item in info:
... print item
...
(28, 2, 17, '', (28, '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'))
(28, 1, 6, '', (28, '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'))
(28, 5, 132, '', (28, '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'))
(2, 2, 17, '', ('127.0.0.1', 0))
(2, 1, 6, '', ('127.0.0.1', 0))
(2, 5, 132, '', ('127.0.0.1', 0))
So we need/expect the lines beginning with "2", but SAB also gets the lines starting with "28", and that causes the problem.
https://docs.python.org/2/library/socke ... etaddrinfo tells about socket.getaddrinfo():
The function returns a list of 5-tuples with the following structure: (family, socktype, proto, canonname, sockaddr)
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.
On Linux (and Windows) Family 2 is IPv4, family 10 is IPv6, but what is 28? ... Found it on
http://www.cz.freebsd.org/doc/en/books/ ... tions.html :
Code: Select all
#define AF_UNSPEC 0 /* unspecified */
#define AF_LOCAL 1 /* local to host (pipes, portals) */
#define AF_UNIX AF_LOCAL /* backward compatibility */
#define AF_INET 2 /* internetwork: UDP, TCP, etc. */
<snip>
#define AF_INET6 28 /* IPv6 */
Ah, on FreeBSD 28 is AF_INET6. The "10" for IPv6 is on Linux.
Now back to your problem: if the code ignores anything else than AF_INET I think we are safe ... as long as we are in an IPv4 world.
Code: Select all
>>> import socket
>>> for item in info:
... if item[0] == socket.AF_INET:
... print item
...
(2, 2, 17, '', ('127.0.0.1', 0))
(2, 1, 6, '', ('127.0.0.1', 0))
(2, 5, 132, '', ('127.0.0.1', 0))
So that works. In the next post I'll give code you should try.