1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/ext/socket
akr b5c6fc8561 Deprecation document for gethostbyname,gethostbyaddr.
[Feature #13097]

I confirmed current ruby (Ruby 2.4 and trunk) uses
gethostbyname() and gethostbyaddr().

Socket.gethostbyname uses getaddrinfo() and gethostbyname().
Socket.gethostbyaddr uses gethostbyaddr().

Socket.gethostbyname uses gethostbyname() to obtain alias hostnames.

RFC 3493 defines getaddrinfo()/getnameinfo() and
describes the problems of gethostbyname()/gethostbyaddr().
The problems are difficult protocol handling and thread-unsafety.

Since Ruby has GVL, the thread-unsafety doesn't cause wrong result.
But it may block other threads until finishing DNS query.

Socket.gethostbyname has the protocol handling problem.
It returns only one address family:

```
% ruby -rpp -rsocket -e 'pp Socket.gethostbyname("www.wide.ad.jp")'
["www.wide.ad.jp",
 [],
 10,
 " \x01\x02\x00\r\xFF\xFF\xF1\x02\x16>\xFF\xFEKe\x1C",
 "\xCB\xB2\x89:"]
```

www.wide.ad.jp has one IPv6 address and one IPv4 address.
But Socket.gethostbyname returns only one address family, 10 (AF_INET6),
which is the address family of the first address.

Also, Socket.gethostbyname and Socket.gethostbyaddr uses
4-bytes binary IPv4 address and 16-bytes binary IPv6 address.
This is not usual in other socket API in Ruby.
(Most socket API uses binary sockaddr string or Addrinfo object)

I think Socket.gethostbyname and Socket.gethostbyaddr are too far
from recommendable API.

So, I added deprecation description for documents for them.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60266 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-21 13:13:02 +00:00
..
lib socket: avoid fcntl for read/write_nonblock on Linux 2017-04-19 01:08:16 +00:00
.document
addrinfo.h
ancdata.c * ext/socket/*.c: Add proper require for example to work. 2016-10-05 03:57:32 +00:00
basicsocket.c basicsocket.c: proper system call name 2017-04-08 03:25:50 +00:00
constants.c
depend separate constdefs.c and constdefs.h 2017-05-08 05:31:02 +00:00
extconf.rb Add Socket::Ifaddr.vhid on supported platforms [Feature #13803] 2017-08-31 08:29:38 +00:00
getaddrinfo.c
getnameinfo.c getnameinfo.c: rubysocket.h for inet_ntop 2016-08-13 01:26:24 +00:00
ifaddr.c Add Socket::Ifaddr.vhid on supported platforms [Feature #13803] 2017-08-31 08:29:38 +00:00
init.c
ipsocket.c IPSocket#inspect 2017-04-14 10:03:43 +00:00
mkconstants.rb
option.c * ext/socket/*.c: Add proper require for example to work. 2016-10-05 03:57:32 +00:00
raddrinfo.c ext/socket/raddrinfo.c (addrinfo_mark): avoid needless branch 2017-03-09 03:49:47 +00:00
rubysocket.h socket/option.c: inet_ntop 2016-08-02 03:37:02 +00:00
socket.c Deprecation document for gethostbyname,gethostbyaddr. 2017-10-21 13:13:02 +00:00
sockport.h
sockssocket.c
tcpserver.c
tcpsocket.c
udpsocket.c * ext/socket/*.c: Add proper require for example to work. 2016-10-05 03:57:32 +00:00
unixserver.c * ext/socket/*.c: Add proper require for example to work. 2016-10-05 03:57:32 +00:00
unixsocket.c * ext/socket/*.c: Add proper require for example to work. 2016-10-05 03:57:32 +00:00