You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
MDEV-39169 Replace deprecated network functions in resolveip
Replace inet_aton/inet_addr/gethostbyname/gethostbyaddr with
their modern POSIX equivalents inet_pton/getaddrinfo/getnameinfo.
This adds IPv6 support to resolveip and removes dependency on the
deprecated h_errno global.
Handle IPv6 unspecified address (::) as Null-IP-Addr, consistent
with existing IPv4 INADDR_ANY handling for 0.0.0.0.
Add MTR test covering IPv4/IPv6 reverse lookups, special
addresses, multiple arguments, mixed address types, and
invalid hostname handling.
Co-Authored-By: Claude AI <noreply@anthropic.com>
--echo # IPv4 special addresses (deterministic, no DNS needed)
10
+
--echo #
11
+
--exec $MYSQL_RESOLVEIP 255.255.255.255
12
+
--exec $MYSQL_RESOLVEIP 0.0.0.0
13
+
14
+
--echo #
15
+
--echo # IPv4 reverse lookup
16
+
--echo #
17
+
--exec $MYSQL_RESOLVEIP 127.0.0.1 2>&1 | sed 's/Host name of 127\.0\.0\.1 is .*/Host name of 127.0.0.1 is HOSTNAME/' | sed "s|.*Unable to find hostname for '127.0.0.1'|Host name of 127.0.0.1 is HOSTNAME|"
18
+
19
+
--echo #
20
+
--echo # IPv4 reverse lookup (silent mode)
21
+
--echo #
22
+
--exec $MYSQL_RESOLVEIP -s 127.0.0.1 2>&1 | sed 's/.*/HOSTNAME/'
23
+
24
+
--echo #
25
+
--echo # IPv6 special address (deterministic, no DNS needed)
--exec $MYSQL_RESOLVEIP ::1 2>&1 | sed 's/Host name of ::1 is .*/Host name of ::1 is HOSTNAME/' | sed "s|.*Unable to find hostname for '::1'|Host name of ::1 is HOSTNAME|"
38
+
39
+
--echo #
40
+
--echo # IPv6 reverse lookup (silent mode)
41
+
--echo #
42
+
--exec $MYSQL_RESOLVEIP -s ::1 2>&1 | sed 's/.*/HOSTNAME/'
43
+
44
+
--echo #
45
+
--echo # IPv6 IPv4-mapped address
46
+
--echo #
47
+
--exec $MYSQL_RESOLVEIP ::ffff:127.0.0.1 2>&1 | sed 's/Host name of ::ffff:127\.0\.0\.1 is .*/Host name of ::ffff:127.0.0.1 is HOSTNAME/' | sed "s|.*Unable to find hostname for '::ffff:127.0.0.1'|Host name of ::ffff:127.0.0.1 is HOSTNAME|"
48
+
49
+
--echo #
50
+
--echo # IPv6 full form address
51
+
--echo #
52
+
--exec $MYSQL_RESOLVEIP 0000:0000:0000:0000:0000:0000:0000:0001 2>&1 | sed 's/Host name of 0000:0000:0000:0000:0000:0000:0000:0001 is .*/Host name of 0000:0000:0000:0000:0000:0000:0000:0001 is HOSTNAME/' | sed "s|.*Unable to find hostname for '0000:0000:0000:0000:0000:0000:0000:0001'|Host name of 0000:0000:0000:0000:0000:0000:0000:0001 is HOSTNAME|"
53
+
54
+
--echo #
55
+
--echo # Multiple addresses in one call
56
+
--echo #
57
+
--exec $MYSQL_RESOLVEIP 255.255.255.255 0.0.0.0
58
+
59
+
--echo #
60
+
--echo # Mixed IPv4 and IPv6 addresses
61
+
--echo #
62
+
--exec $MYSQL_RESOLVEIP 255.255.255.255 ::
63
+
64
+
--echo #
65
+
--echo # Mixed IP address and hostname
66
+
--echo #
67
+
--exec $MYSQL_RESOLVEIP -s 127.0.0.1 localhost | sed 's/.*/REPLACED/'
68
+
69
+
--echo #
70
+
--echo # Invalid hostname
71
+
--echo #
72
+
--exec $MYSQL_RESOLVEIP nonexistent.invalid 2>&1 | sed "s|.*Unable to find hostid for 'nonexistent.invalid': .*|resolveip: Unable to find hostid for 'nonexistent.invalid': NAME_RESOLUTION_ERROR|"
73
+
74
+
--echo #
75
+
--echo # Invalid address mixed with valid address
76
+
--echo #
77
+
--exec $MYSQL_RESOLVEIP 255.255.255.255 nonexistent.invalid 2>&1 | sed "s|.*Unable to find hostid for 'nonexistent.invalid': .*|resolveip: Unable to find hostid for 'nonexistent.invalid': NAME_RESOLUTION_ERROR|"
0 commit comments