mirror of
https://github.com/fankes/komari-agent.git
synced 2025-10-19 11:09:22 +08:00
feat: #8 添加获取IP的API接口
This commit is contained in:
@@ -9,7 +9,14 @@ import (
|
|||||||
var userAgent = "curl/8.0.1"
|
var userAgent = "curl/8.0.1"
|
||||||
|
|
||||||
func GetIPv4Address() (string, error) {
|
func GetIPv4Address() (string, error) {
|
||||||
webAPIs := []string{"https://www.qualcomm.cn/cdn-cgi/trace", "https://ip.sb", "https://api.ipify.org?format=json"}
|
webAPIs := []string{
|
||||||
|
"https://www.visa.cn/cdn-cgi/trace",
|
||||||
|
"https://www.qualcomm.cn/cdn-cgi/trace",
|
||||||
|
"https://www.toutiao.com/stream/widget/local_weather/data/",
|
||||||
|
"https://edge-ip.html.zone/geo",
|
||||||
|
"https://vercel-ip.html.zone/geo",
|
||||||
|
"http://ipv4.ip.sb",
|
||||||
|
"https://api.ipify.org?format=json"}
|
||||||
|
|
||||||
for _, api := range webAPIs {
|
for _, api := range webAPIs {
|
||||||
// get ipv4
|
// get ipv4
|
||||||
@@ -38,7 +45,11 @@ func GetIPv4Address() (string, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func GetIPv6Address() (string, error) {
|
func GetIPv6Address() (string, error) {
|
||||||
webAPIs := []string{"https://api6.ipify.org?format=json", "https://ipv6.icanhazip.com"}
|
webAPIs := []string{
|
||||||
|
"https://v6.ip.zxinc.org/info.php?type=json",
|
||||||
|
"https://api6.ipify.org?format=json",
|
||||||
|
"https://ipv6.icanhazip.com",
|
||||||
|
"https://api-ipv6.ip.sb/geoip"}
|
||||||
|
|
||||||
for _, api := range webAPIs {
|
for _, api := range webAPIs {
|
||||||
// get ipv6
|
// get ipv6
|
||||||
|
Reference in New Issue
Block a user