mirror of
https://github.com/nxtrace/NTrace-core.git
synced 2025-08-12 06:26:39 +00:00
Add: 增加了tokens,方便管理API密钥
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
13
ipgeo/tokens.go
Normal file
@@ -0,0 +1,13 @@
|
||||
package ipgeo
|
||||
|
||||
type tokenData struct {
|
||||
ipinsight string
|
||||
ipinfo string
|
||||
ipleo string
|
||||
}
|
||||
|
||||
var token = tokenData{
|
||||
ipinsight: "",
|
||||
ipinfo: "42764a944dabd0",
|
||||
ipleo: "NextTraceDemo",
|
||||
}
|
||||
Reference in New Issue
Block a user