Skip to main content
Glama
ip.go608 B
package utils import "net" // 获取本机所有 IPv4 地址 func GetLocalIPs() ([]string, error) { var ips []string interfaces, err := net.Interfaces() if err != nil { return nil, err } for _, i := range interfaces { addrs, err := i.Addrs() if err != nil { continue } for _, addr := range addrs { var ip net.IP switch v := addr.(type) { case *net.IPNet: ip = v.IP case *net.IPAddr: ip = v.IP } // 过滤掉回环地址和 IPv6 地址 if ip != nil && !ip.IsLoopback() && ip.To4() != nil { ips = append(ips, ip.String()) } } } return ips, 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/k8m'

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