Add: 增加了tokens,方便管理API密钥

This commit is contained in:
sjlleo
2022-05-13 16:16:06 +08:00
parent afa61d6e8d
commit 89ed828e6e
3 changed files with 17 additions and 3 deletions

View File

@@ -9,7 +9,7 @@ import (
func IPInfo(ip string) (*IPGeoData, error) {
resp, err := http.Get("https://ipinfo.io/" + ip + "?token=42764a944dabd0")
resp, err := http.Get("https://ipinfo.io/" + ip + "?token=" + token.ipinfo)
if err != nil {
return nil, err
}

View File

@@ -1,13 +1,14 @@
package ipgeo
import (
"github.com/tidwall/gjson"
"io/ioutil"
"net/http"
"github.com/tidwall/gjson"
)
func LeoIP(ip string) (*IPGeoData, error) {
resp, err := http.Get("https://api.leo.moe/ip/?ip=" + ip)
resp, err := http.Get("https://api.leo.moe/ip/?ip=" + ip + "&token=" + token.ipleo)
if err != nil {
return nil, err
}

13
ipgeo/tokens.go Normal file
View File

@@ -0,0 +1,13 @@
package ipgeo
type tokenData struct {
ipinsight string
ipinfo string
ipleo string
}
var token = tokenData{
ipinsight: "",
ipinfo: "42764a944dabd0",
ipleo: "NextTraceDemo",
}