utils

package
v1.7.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 16, 2025 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsInvalidIPFormat

func IsInvalidIPFormat(host string) bool

IsInvalidIPFormat 检查是否为明显无效的IP格式

这个函数专门用于识别格式错误而非真正的网络不可达 例如:256.256.256.256, 999.999.999.999 等

func ParseHostToIP

func ParseHostToIP(host string) (net.IP, error)

ParseHostToIP 尝试将主机地址解析为IP地址

参数: - host string: 主机地址(域名或IP)

返回值: - net.IP: 解析出的IP地址,如果解析失败返回nil - error: 解析错误(可选)

func ValidateHost

func ValidateHost(host string) bool

ValidateHost 验证主机地址(支持域名和IP)

支持的格式: - IPv4: 192.168.1.1, 127.0.0.1 - IPv6: ::1, 2001:db8::1 - 域名: example.com, www.example.com, sub.domain.example.com - localhost: localhost

参数: - host string: 要验证的主机地址

返回值: - bool: true 表示格式有效,false 表示格式无效

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL