-
Notifications
You must be signed in to change notification settings - Fork 85
Open
Description
Lines 19 to 30 in 3d1737c
| func IsPublicAddr(addr netip.Addr) bool { | |
| return !(addr.IsPrivate() || | |
| addr.IsLoopback() || | |
| addr.IsMulticast() || | |
| addr.IsLinkLocalUnicast() || | |
| addr.IsInterfaceLocalMulticast() || | |
| addr.IsUnspecified()) | |
| } | |
| func IsVirtual(addr netip.Addr) bool { | |
| return addr.IsLoopback() || addr.IsMulticast() || addr.IsInterfaceLocalMulticast() | |
| } |
IsMulticast()是IsInterfaceLocalMulticast()的超集,IsInterfaceLocalMulticast()是多余的IsPublicAddr()名不符实,仅排除这几项并不能得到准确的结果
这一问题在 Go 标准库的IsGlobalUnicast()同样存在,且尚未得到解决 net: apply ICANN/IANA-managed semantics to IP.IsGlobalUnicast golang/go#11772
应当排除被 IANA 标记了Globally Reachable为False的地址块- https://www.iana.org/assignments/iana-ipv4-special-registry/iana-ipv4-special-registry.xhtml
- https://www.iana.org/assignments/iana-ipv6-special-registry/iana-ipv6-special-registry.xhtml
一个典型 Use Case 是阿里云使用 100.64.0.0/10 的 CGNAT 段提供内网服务,但是 sing-box 的ip_is_private目前并不能匹配
Metadata
Metadata
Assignees
Labels
No labels