1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Show deprecation warning on Socket.gethostbyname and Socket.gethostbyaddr

This commit is contained in:
Masaki Matsushita 2020-08-29 17:18:59 +09:00
parent 56dd578d7e
commit 6d946665bd

View file

@ -965,6 +965,7 @@ sock_sockaddr(struct sockaddr *addr, socklen_t len)
static VALUE static VALUE
sock_s_gethostbyname(VALUE obj, VALUE host) sock_s_gethostbyname(VALUE obj, VALUE host)
{ {
rb_warn("Socket.gethostbyname is deprecated; use Addrinfo.getaddrinfo instead.");
struct rb_addrinfo *res = struct rb_addrinfo *res =
rsock_addrinfo(host, Qnil, AF_UNSPEC, SOCK_STREAM, AI_CANONNAME); rsock_addrinfo(host, Qnil, AF_UNSPEC, SOCK_STREAM, AI_CANONNAME);
return rsock_make_hostent(host, res, sock_sockaddr); return rsock_make_hostent(host, res, sock_sockaddr);
@ -1004,6 +1005,8 @@ sock_s_gethostbyaddr(int argc, VALUE *argv, VALUE _)
VALUE ary, names; VALUE ary, names;
int t = AF_INET; int t = AF_INET;
rb_warn("Socket.gethostbyaddr is deprecated; use Addrinfo#getnameinfo instead.");
rb_scan_args(argc, argv, "11", &addr, &family); rb_scan_args(argc, argv, "11", &addr, &family);
StringValue(addr); StringValue(addr);
if (!NIL_P(family)) { if (!NIL_P(family)) {