Update main.go
parent
6efba7de05
commit
cfc5445ed9
12
main.go
12
main.go
|
|
@ -6,6 +6,7 @@ import (
|
|||
"fmt"
|
||||
"log"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
|
|
@ -29,9 +30,11 @@ func getIPInfoAndRespond(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
// 获取IP信息
|
||||
IPinfo := modules.GetIPInformation(ip)
|
||||
fmt.Println("IP", IPinfo.IP)
|
||||
fmt.Println("IsPrivate", IPinfo.IsPrivate)
|
||||
fmt.Println("PrivateCIDR", IPinfo.PrivateCIDR)
|
||||
if IPinfo.IsPrivate != false {
|
||||
log.Println("tag:main", "IP: "+IPinfo.IP+", IsPrivate: "+strconv.FormatBool(IPinfo.IsPrivate)+", PrivateCIDR: "+IPinfo.PrivateCIDR)
|
||||
} else {
|
||||
log.Println("tag:main", "IP: "+IPinfo.IP+", IsPrivate: "+strconv.FormatBool(IPinfo.IsPrivate))
|
||||
}
|
||||
|
||||
// 检查是否为私有IP
|
||||
if IPinfo.IsPrivate == true {
|
||||
|
|
@ -41,9 +44,6 @@ func getIPInfoAndRespond(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
// 使用mmdb查询ip
|
||||
IpIformation := modules.MmdbQueryIP(IPinfo.IP)
|
||||
// 使用MySql查询ip
|
||||
//dsn := modules.Readconfig()
|
||||
//IpIformation := modules.MysqlQuery(ip, dsn)
|
||||
|
||||
log.Println("tag:main", IpIformation)
|
||||
jsonData, err := json.Marshal(IpIformation)
|
||||
|
|
|
|||
Loading…
Reference in New Issue