http://8 --> http://0.0.0.8 是标准约定吗?
http://8 --> http://0.0.0.8 is a standard convention?
今天我发现命令:
php -S 0:8888
在本地主机上启动一个服务器,就像:
php -S 0.0.0.0:8888
此外,将 Safari 导航至:
http://8
将重定向到:
http://0.0.0.8
此外,我发现 Safari 会以其他方式重定向 http://1.2 and http://1.2.3。
是否有任何文档化的标准或惯例对此进行解释,或者我是否在两种不同的软件中发现了类似的彩蛋?
不是官方的,但它是一个非常接近的 RFC 草案。它没有定义这种行为,但它提到了它并使它合法化。
Meanwhile, a very popular implementation of IP networking went off in
its own direction. 4.2BSD introduced a function inet_aton(), whose
job was to interpret character strings as IP addresses. It
interpreted both of the syntaxes mentioned in [MTP] (see above): a
single number giving the entire 32-bit address, and dot-separated
octet values. It also interpreted two intermediate syntaxes: octet-
dot-octet-dot-16bits, intended for class B addresses, and octet-
dot-24bits, intended for class A addresses. It also allowed some
flexibility in how the individual numeric parts were specified: it
allowed octal and hexadecimal in addition to decimal, distinguishing
these radices by using the C language syntax involving a prefix "0"
or "0x", and allowed the numbers to be arbitrarily long.
The 4.2BSD inet_aton() has been widely copied and imitated, and so is
a de facto standard for the textual representation of IPv4 addresses.
Nevertheless, these alternative syntaxes have now fallen out of use
(if they ever had significant use). The only practical use that they
now see is for deliberate obfuscation of addresses: giving an IPv4
address as a single 32-bit decimal number is favoured among people
wishing to conceal the true location that is encoded in a URL. All
the forms except for decimal octets are seen as non-standard (despite
being quite widely interoperable) and undesirable.
https://datatracker.ietf.org/doc/html/draft-main-ipaddr-text-rep-02
而且,我们可以看到这段代码至今仍然有效:
a single number giving the entire 32-bit address
❱ ping 2321319336
PING 2321319336 (138.92.133.168): 56 data bytes
...
octet- dot-octet-dot-16bits, intended for class B addresses
❱ ping 172.16.2342
PING 172.16.2342 (172.16.9.38): 56 data bytes
....
octet-dot-24bits, intended for class A addresses
❱ ping 10.45253
PING 10.45253 (10.0.176.197): 56 data bytes
...
请注意 RFC 3896 explicitly defines URI 中的 IP 地址作为点分四进制十进制表示形式,因此从技术上讲,URI 中根本不允许使用这些快捷方式!
IPv4 地址是一个无符号的 32 位整数。点分字节表示法只是一种更(人类)可读的变体 - 通常您可以互换使用这两种表示法:
ping 8.8.8.8
ping 134744072
今天我发现命令:
php -S 0:8888
在本地主机上启动一个服务器,就像:
php -S 0.0.0.0:8888
此外,将 Safari 导航至:
http://8
将重定向到:
http://0.0.0.8
此外,我发现 Safari 会以其他方式重定向 http://1.2 and http://1.2.3。
是否有任何文档化的标准或惯例对此进行解释,或者我是否在两种不同的软件中发现了类似的彩蛋?
不是官方的,但它是一个非常接近的 RFC 草案。它没有定义这种行为,但它提到了它并使它合法化。
Meanwhile, a very popular implementation of IP networking went off in its own direction. 4.2BSD introduced a function inet_aton(), whose job was to interpret character strings as IP addresses. It interpreted both of the syntaxes mentioned in [MTP] (see above): a single number giving the entire 32-bit address, and dot-separated octet values. It also interpreted two intermediate syntaxes: octet- dot-octet-dot-16bits, intended for class B addresses, and octet- dot-24bits, intended for class A addresses. It also allowed some flexibility in how the individual numeric parts were specified: it allowed octal and hexadecimal in addition to decimal, distinguishing these radices by using the C language syntax involving a prefix "0" or "0x", and allowed the numbers to be arbitrarily long.
The 4.2BSD inet_aton() has been widely copied and imitated, and so is a de facto standard for the textual representation of IPv4 addresses. Nevertheless, these alternative syntaxes have now fallen out of use (if they ever had significant use). The only practical use that they now see is for deliberate obfuscation of addresses: giving an IPv4 address as a single 32-bit decimal number is favoured among people wishing to conceal the true location that is encoded in a URL. All the forms except for decimal octets are seen as non-standard (despite being quite widely interoperable) and undesirable.
https://datatracker.ietf.org/doc/html/draft-main-ipaddr-text-rep-02
而且,我们可以看到这段代码至今仍然有效:
a single number giving the entire 32-bit address
❱ ping 2321319336
PING 2321319336 (138.92.133.168): 56 data bytes
...
octet- dot-octet-dot-16bits, intended for class B addresses
❱ ping 172.16.2342
PING 172.16.2342 (172.16.9.38): 56 data bytes
....
octet-dot-24bits, intended for class A addresses
❱ ping 10.45253
PING 10.45253 (10.0.176.197): 56 data bytes
...
请注意 RFC 3896 explicitly defines URI 中的 IP 地址作为点分四进制十进制表示形式,因此从技术上讲,URI 中根本不允许使用这些快捷方式!
IPv4 地址是一个无符号的 32 位整数。点分字节表示法只是一种更(人类)可读的变体 - 通常您可以互换使用这两种表示法:
ping 8.8.8.8
ping 134744072