lolly/internal/lua/ip_guard.go
xfy911 63ce8ecd2a docs(lua): add package comments for lua module
- Add package documentation for ip_guard file
- Include author attribution (xfy)
2026-06-03 15:28:53 +08:00

17 lines
529 B
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// Package lua 提供 Lua 脚本扩展功能,支持 IP 黑白名单、请求处理等。
//
// 包含 IP 守卫相关的逻辑,用于处理 IP 黑白名单功能。
//
// 作者xfy
package lua
import "net"
// isRestrictedIP 检查 IP 地址是否属于受限范围(私有、回环、链路本地等)。
//
// 用于防止 Lua Cosocket 的 SSRF 攻击。
func isRestrictedIP(ip net.IP) bool {
return ip.IsLoopback() || ip.IsPrivate() || ip.IsLinkLocalUnicast() ||
ip.IsLinkLocalMulticast() || ip.IsUnspecified()
}