2024-08-17 08:31:47 +08:00
|
|
|
package ip
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/gin-gonic/gin"
|
2024-08-18 23:23:18 +08:00
|
|
|
"ipv6-test-node/internal/pkg/response"
|
|
|
|
"ipv6-test-node/internal/pkg/utils"
|
2024-08-17 08:31:47 +08:00
|
|
|
"net/http"
|
2024-08-18 23:23:18 +08:00
|
|
|
"strconv"
|
2024-08-17 08:31:47 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
func MyIP(c *gin.Context) {
|
2024-08-18 23:23:18 +08:00
|
|
|
version, err := utils.GetIPVersion(c.ClientIP())
|
|
|
|
if err != nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
c.JSON(http.StatusOK, response.MyIPResponse{
|
|
|
|
Address: c.ClientIP(),
|
|
|
|
Version: strconv.Itoa(version),
|
|
|
|
})
|
2024-08-17 08:31:47 +08:00
|
|
|
}
|