ipv6-test-backend/internal/router/routes/ip/myip.go
thehrz 063f32fcbb
All checks were successful
CI / deploy (push) Successful in 1m28s
feat: add ISP query
2024-08-20 13:38:32 +08:00

20 lines
352 B
Go

package ip
import (
"github.com/gin-gonic/gin"
"ipv6-test-node/internal/pkg/protocol"
"ipv6-test-node/internal/pkg/utils"
"net"
"net/http"
"strconv"
)
func MyIP(c *gin.Context) {
ip := utils.ToIP(net.ParseIP(c.ClientIP()))
c.JSON(http.StatusOK, protocol.MyIPResponse{
Address: c.ClientIP(),
Version: strconv.Itoa(int(ip.Version)),
})
}