tjibbevanderlaan / chromeos-filesystem-sftp

ChromeOS app to access SFTP server
https://chrome.google.com/webstore/detail/shared-network-folder-sft/gbheifiifcfekkamhepkeogobihicgmn
BSD 3-Clause "New" or "Revised" License
80 stars 21 forks source link

Connecting to a host over IPv6 does not seem to work. #75

Open redhat421 opened 9 years ago

redhat421 commented 9 years ago

When I supply a host which only has a AAAA record, connection attempts fail with this message: "hostent is NULL 0 0"

I suspect this is an issue requesting AF_INET vs AF_INET6 in gethostbyname (just a guess, my Chromebook is not in dev mode).

I think switching to gethostbyname2 might fix this.

There's a great writeup for these issues here: http://www.akkadia.org/drepper/userapi-ipv6.html

Thanks for an awesome extension!

cvmiller commented 8 years ago

I see the same when trying to connect to IPv6 hosts on my home network (via DNS AAAA record). And I see the same problem if I type in the IPv6 address directly. It appears that SFTP file system does not know how to open an IPv6 TCP socket.

cvmiller commented 8 years ago

OK, looking into your code I see the problem. In file: sftp_thread.cc, you have a function which opens a socket: int SftpThread::ConnectToSshServer(const std::string &hostname, const int port)

A few lines into the function you have the line: sock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP); ... sin.sin_family = AF_INET;

This defines it as an IPv4 only socket.

Since much of the world has run out of IPV4 addresses, it would be really nice if this App supported IPv6.

cvmiller commented 8 years ago

Sorry just another note, I seem to be working backwards up your code. I see that you are calling (in the same function) gethostbyname(). This has been deprecated in favour of getaddrinfo() which returns a structure signalling what kind of address is returned (ipv4 or ipv6). http://man7.org/linux/man-pages/man3/getaddrinfo.3.html

I hope this helps.