Skip to main content
Glama
nettools.go340 B
package utils import ( "fmt" "net" ) func CidrTotalIPs(cidr string) (int, error) { _, ipNet, err := net.ParseCIDR(cidr) if err != nil { return 0, fmt.Errorf("invalid CIDR: %v", err) } // 获取 CIDR 的掩码大小 ones, bits := ipNet.Mask.Size() // 计算总 IP 数量 totalIPs := 1 << (bits - ones) return totalIPs, nil }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/weibaohui/kom'

If you have feedback or need assistance with the MCP directory API, please join our Discord server