package open import ( "context" "github.com/gogf/gf/v2/frame/g" ipapi "service.xpcool.com/api/open/v1/tools/ip" "service.xpcool.com/common/tools/ip" ) // IP returns the caller's IP and whether it is an internal address. func (c *Controller) IP(ctx context.Context, req *ipapi.IPReq) (res *ipapi.IPRes, err error) { clientIP := g.RequestFromCtx(ctx).GetClientIp() return &ipapi.IPRes{IP: clientIP, Internal: ip.IsInternal(clientIP)}, nil }